With auth
This commit is contained in:
parent
9ee21dbe30
commit
5454183d86
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/type-script-helper"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"Kanban",
|
||||
"VSIX"
|
||||
]
|
||||
}
|
@ -19,7 +19,7 @@ yo code
|
||||
# ? What's the identifier of your extension? helloworld
|
||||
# ? What's the description of your extension? LEAVE BLANK
|
||||
# ? Initialize a git repository? Yes
|
||||
# ? Bundle the source code with webpack? No
|
||||
# ? Bundle the source code with webpack? No (should be yes?)
|
||||
# ? Which package manager to use? npm
|
||||
|
||||
# ? Do you want to open the new folder with Visual Studio Code? Open with `code`
|
||||
@ -103,4 +103,9 @@ None
|
||||
## 1.4.4
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Transform to Param Case
|
||||
- Transform to Param Case
|
||||
|
||||
## 1.5.1
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Webview
|
@ -4,24 +4,21 @@
|
||||
|
||||
const path = require('path');
|
||||
|
||||
//@ts-check
|
||||
/** @typedef {import('webpack').Configuration} WebpackConfig **/
|
||||
|
||||
/** @type WebpackConfig */
|
||||
const extensionConfig = {
|
||||
target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
|
||||
/**@type {import('webpack').Configuration}*/
|
||||
const config = {
|
||||
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
|
||||
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
|
||||
|
||||
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
|
||||
output: {
|
||||
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
path: path.resolve(__dirname, '..', 'dist'),
|
||||
filename: 'extension.js',
|
||||
libraryTarget: 'commonjs2'
|
||||
},
|
||||
devtool: 'nosources-source-map',
|
||||
externals: {
|
||||
vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
|
||||
// modules added here also need to be added in the .vscodeignore file
|
||||
},
|
||||
resolve: {
|
||||
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
|
||||
@ -39,10 +36,6 @@ const extensionConfig = {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
devtool: 'nosources-source-map',
|
||||
infrastructureLogging: {
|
||||
level: "log", // enables logging required for problem matchers
|
||||
},
|
||||
}
|
||||
};
|
||||
module.exports = [ extensionConfig ];
|
||||
module.exports = config;
|
1
type-script-helper/media/checklist.svg
Normal file
1
type-script-helper/media/checklist.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"/></svg>
|
After Width: | Height: | Size: 479 B |
7
type-script-helper/media/main.js
Normal file
7
type-script-helper/media/main.js
Normal file
@ -0,0 +1,7 @@
|
||||
// This script will be run within the webview itself
|
||||
// It cannot access the main VS Code APIs directly.
|
||||
(function () {
|
||||
const vscode = acquireVsCodeApi();
|
||||
|
||||
console.log("hello there from javascript");
|
||||
})();
|
30
type-script-helper/media/reset.css
Normal file
30
type-script-helper/media/reset.css
Normal file
@ -0,0 +1,30 @@
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
ol,
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
91
type-script-helper/media/vscode.css
Normal file
91
type-script-helper/media/vscode.css
Normal file
@ -0,0 +1,91 @@
|
||||
:root {
|
||||
--container-paddding: 20px;
|
||||
--input-padding-vertical: 6px;
|
||||
--input-padding-horizontal: 4px;
|
||||
--input-margin-vertical: 4px;
|
||||
--input-margin-horizontal: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 0 var(--container-paddding);
|
||||
color: var(--vscode-foreground);
|
||||
font-size: var(--vscode-font-size);
|
||||
font-weight: var(--vscode-font-weight);
|
||||
font-family: var(--vscode-font-family);
|
||||
background-color: var(--vscode-editor-background);
|
||||
}
|
||||
|
||||
ol,
|
||||
ul {
|
||||
padding-left: var(--container-paddding);
|
||||
}
|
||||
|
||||
body > *,
|
||||
form > * {
|
||||
margin-block-start: var(--input-margin-vertical);
|
||||
margin-block-end: var(--input-margin-vertical);
|
||||
}
|
||||
|
||||
*:focus {
|
||||
outline-color: var(--vscode-focusBorder) !important;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--vscode-textLink-foreground);
|
||||
}
|
||||
|
||||
a:hover,
|
||||
a:active {
|
||||
color: var(--vscode-textLink-activeForeground);
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: var(--vscode-editor-font-size);
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
}
|
||||
|
||||
button {
|
||||
border: none;
|
||||
padding: var(--input-padding-vertical) var(--input-padding-horizontal);
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
outline: 1px solid transparent;
|
||||
outline-offset: 2px !important;
|
||||
color: var(--vscode-button-foreground);
|
||||
background: var(--vscode-button-background);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
cursor: pointer;
|
||||
background: var(--vscode-button-hoverBackground);
|
||||
}
|
||||
|
||||
button:focus {
|
||||
outline-color: var(--vscode-focusBorder);
|
||||
}
|
||||
|
||||
button.secondary {
|
||||
color: var(--vscode-button-secondaryForeground);
|
||||
background: var(--vscode-button-secondaryBackground);
|
||||
}
|
||||
|
||||
button.secondary:hover {
|
||||
background: var(--vscode-button-secondaryHoverBackground);
|
||||
}
|
||||
|
||||
input:not([type="checkbox"]),
|
||||
textarea {
|
||||
display: block;
|
||||
width: 100%;
|
||||
border: none;
|
||||
font-family: var(--vscode-font-family);
|
||||
padding: var(--input-padding-vertical) var(--input-padding-horizontal);
|
||||
color: var(--vscode-input-foreground);
|
||||
outline-color: var(--vscode-input-border);
|
||||
background-color: var(--vscode-input-background);
|
||||
}
|
||||
|
||||
input::placeholder,
|
||||
textarea::placeholder {
|
||||
color: var(--vscode-input-placeholderForeground);
|
||||
}
|
2093
type-script-helper/package-lock.json
generated
2093
type-script-helper/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,158 +1,244 @@
|
||||
{
|
||||
"name": "type-script-helper",
|
||||
"displayName": "Type Script Helper",
|
||||
"description": "Helper for VS Code in TypeScript",
|
||||
"publisher": "IFX",
|
||||
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
||||
"version": "1.4.4",
|
||||
"engines": {
|
||||
"vscode": "^1.79.0"
|
||||
},
|
||||
"activationEvents": [],
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [],
|
||||
"main": "./dist/extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"category": "Helper",
|
||||
"command": "open-in-new-window.open",
|
||||
"title": "Open in New Window"
|
||||
},
|
||||
{
|
||||
"category": "Helper",
|
||||
"command": "promiseLinesHelper.codeGeneratorQuickPick",
|
||||
"title": "Code Generator - Quick Pick"
|
||||
},
|
||||
{
|
||||
"category": "Helper",
|
||||
"command": "promiseLinesHelper.insertDateTime",
|
||||
"title": "Insert DateTime"
|
||||
},
|
||||
{
|
||||
"command": "promiseLinesHelper.transformToPopperCase",
|
||||
"title": "Transform to Popper Case"
|
||||
},
|
||||
{
|
||||
"category": "Helper",
|
||||
"command": "promiseLinesHelper.transformToParamCase",
|
||||
"title": "Transform to Param Case"
|
||||
},
|
||||
{
|
||||
"category": "Helper",
|
||||
"command": "promiseLinesHelper.transformToPopperCase",
|
||||
"title": "Transform to Popper Case"
|
||||
},
|
||||
{
|
||||
"category": "Helper",
|
||||
"command": "readOnlyLinesHelper.searchGoogle",
|
||||
"title": "Search Google"
|
||||
},
|
||||
{
|
||||
"category": "Kanban",
|
||||
"command": "kanban.apiAuthenticate",
|
||||
"title": "API Authenticate Kanban"
|
||||
},
|
||||
{
|
||||
"category": "Kanban",
|
||||
"command": "kanban.newEntry",
|
||||
"title": "New Kanban Entry"
|
||||
},
|
||||
{
|
||||
"category": "Kanban",
|
||||
"command": "kanban.refresh",
|
||||
"title": "Refresh Kanban"
|
||||
},
|
||||
{
|
||||
"category": "Kanban",
|
||||
"command": "kanban.debugReload",
|
||||
"title": "Debug Reload Kanban"
|
||||
},
|
||||
{
|
||||
"category": "Quick Fix",
|
||||
"command": "replaceLinesHelper.quickFixCamelCaseProperties",
|
||||
"title": "Camel Case Properties"
|
||||
},
|
||||
{
|
||||
"category": "Quick Fix",
|
||||
"command": "replaceLinesHelper.quickFixCS0108",
|
||||
"title": " CS0108 (Data Annotations)"
|
||||
},
|
||||
{
|
||||
"category": "Quick Fix",
|
||||
"command": "replaceLinesHelper.quickFixInstanceFieldToCalisthenics",
|
||||
"title": "Instance Field to Calisthenics"
|
||||
},
|
||||
{
|
||||
"category": "Quick Fix",
|
||||
"command": "replaceLinesHelper.quickFixProperCaseProperties",
|
||||
"title": "Proper Case Properties"
|
||||
},
|
||||
{
|
||||
"category": "Quick Fix",
|
||||
"command": "replaceLinesHelper.quickFixPublic",
|
||||
"title": "Public (Expression Body)"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.addCSharpComment",
|
||||
"title": "Add C# Comment"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.addVBComment",
|
||||
"title": "Add VB Comment"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.convertToRegularExpression",
|
||||
"title": "Convert to Regular Expression"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.cutEachLine",
|
||||
"title": "Cut each line after |||"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.distinctLines",
|
||||
"title": "Distinct Lines"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.expandSql",
|
||||
"title": "Expand Sql"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.listToListFamily",
|
||||
"title": "List to list family (Kristy, Mike ...)"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.listToListWrappedComma",
|
||||
"title": "List to list wrapped comma"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.prettySql",
|
||||
"title": "Pretty Sql"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.quickFixCamelCaseProperties",
|
||||
"title": "Quick Fix - Camel Case Properties"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.quickFixCS0108",
|
||||
"title": "Quick Fix - CS0108 (Data Annotations)"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.quickFixInstanceFieldToCalisthenics",
|
||||
"title": "Quick Fix - Instance Field to Calisthenics"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.quickFixProperCaseProperties",
|
||||
"title": "Quick Fix - Proper Case Properties"
|
||||
},
|
||||
{
|
||||
"command": "replaceLinesHelper.quickFixPublic",
|
||||
"title": "Quick Fix - Public (Expression Body)"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.removeComment",
|
||||
"title": "Remove comment"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.sortLength",
|
||||
"title": "Sort by Length"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.sortNormal",
|
||||
"title": "My Sort lines (ascending, case sensitive)"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.splitBySpaceReverseJoinSort",
|
||||
"title": "Split by Space Reverse Join Sort lines (ascending, case sensitive)"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.unwrapSql",
|
||||
"title": "Un-wrap Sql"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.wrapSqlCSharp",
|
||||
"title": "Wrap Sql for C#"
|
||||
},
|
||||
{
|
||||
"category": "Replace",
|
||||
"command": "replaceLinesHelper.wrapSqlVB",
|
||||
"title": "Wrap Sql for VB"
|
||||
},
|
||||
{
|
||||
"category": "WebView",
|
||||
"command": "webView.webView",
|
||||
"title": "Web View"
|
||||
}
|
||||
]
|
||||
],
|
||||
"views": {
|
||||
"kanban-sidebar-view": [
|
||||
{
|
||||
"contextualTitle": "Kanban",
|
||||
"icon": "media/checklist.svg",
|
||||
"id": "kanban-sidebar",
|
||||
"name": "Kanban",
|
||||
"type": "webview"
|
||||
}
|
||||
]
|
||||
},
|
||||
"viewsContainers": {
|
||||
"activitybar": [
|
||||
{
|
||||
"icon": "media/checklist.svg",
|
||||
"id": "kanban-sidebar-view",
|
||||
"title": "Kanban"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run package",
|
||||
"compile": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
"package": "webpack --mode production --devtool hidden-source-map",
|
||||
"compile-tests": "tsc -p . --outDir out",
|
||||
"watch-tests": "tsc -p . -w --outDir out",
|
||||
"pretest": "npm run compile-tests && npm run compile && npm run lint",
|
||||
"lint": "eslint src --ext ts",
|
||||
"test": "node ./out/test/runTest.js"
|
||||
"dependencies": {
|
||||
"@vscode/vsce": "^2.19.0",
|
||||
"polka": "^0.5.2"
|
||||
},
|
||||
"description": "Helper for VS Code in TypeScript",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^25.0.4",
|
||||
"@rollup/plugin-node-resolve": "^15.2.1",
|
||||
"@rollup/plugin-typescript": "^11.1.4",
|
||||
"@tsconfig/svelte": "^1.0.10",
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "20.2.5",
|
||||
"@types/polka": "^0.5.1",
|
||||
"@types/vscode": "^1.79.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
||||
"@typescript-eslint/parser": "^5.59.8",
|
||||
"@vscode/test-electron": "^2.3.2",
|
||||
"concurrently": "^8.2.1",
|
||||
"eslint": "^8.41.0",
|
||||
"glob": "^8.1.0",
|
||||
"mocha": "^10.2.0",
|
||||
"rollup": "^2.3.4",
|
||||
"rollup-plugin-svelte": "^6.1.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"svelte": "^3.31.0",
|
||||
"svelte-check": "^1.1.23",
|
||||
"svelte-preprocess": "^5.0.4",
|
||||
"ts-loader": "^9.4.3",
|
||||
"typescript": "^5.1.3",
|
||||
"webpack": "^5.85.0",
|
||||
"webpack-cli": "^5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vscode/vsce": "^2.19.0"
|
||||
}
|
||||
"displayName": "Type Script Helper",
|
||||
"engines": {
|
||||
"vscode": "^1.79.0"
|
||||
},
|
||||
"main": "./dist/extension.js",
|
||||
"name": "type-script-helper",
|
||||
"publisher": "IFX",
|
||||
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
||||
"scripts": {
|
||||
"compile": "webpack --config ./build/node-extension.webpack.config.js",
|
||||
"lint": "eslint src --ext ts",
|
||||
"package": "webpack --mode production --devtool hidden-source-map --config ./build/node-extension.webpack.config.js",
|
||||
"pretest": "npm run test-compile && npm run lint",
|
||||
"rollup:compile": "rollup -c && webpack --mode production",
|
||||
"test": "node ./out/test/runTest.js",
|
||||
"test-compile": "tsc -p ./",
|
||||
"test-watch": "tsc -watch -p ./",
|
||||
"vscode:prepublish": "npm run package",
|
||||
"watch": "concurrently \"rollup -c -w\" \"webpack --watch --config ./build/node-extension.webpack.config.js\""
|
||||
},
|
||||
"version": "1.5.1"
|
||||
}
|
68
type-script-helper/rollup.config.js
Normal file
68
type-script-helper/rollup.config.js
Normal file
@ -0,0 +1,68 @@
|
||||
import svelte from "rollup-plugin-svelte";
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import sveltePreprocess from "svelte-preprocess";
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
const production = !process.env.ROLLUP_WATCH;
|
||||
|
||||
export default fs
|
||||
.readdirSync(path.join(__dirname, "webviews", "pages"))
|
||||
.map((input) => {
|
||||
const name = input.split(".")[0];
|
||||
return {
|
||||
input: "webviews/pages/" + input,
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: "iife",
|
||||
name: "app",
|
||||
file: "out/compiled/" + name + ".js",
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
// enable run-time checks when not in production
|
||||
dev: !production,
|
||||
// we'll extract any component CSS out into
|
||||
// a separate file - better for performance
|
||||
css: (css) => {
|
||||
css.write(name + ".css");
|
||||
},
|
||||
preprocess: sveltePreprocess(),
|
||||
}),
|
||||
|
||||
// If you have external dependencies installed from
|
||||
// npm, you'll most likely need these plugins. In
|
||||
// some cases you'll need additional configuration -
|
||||
// consult the documentation for details:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||
resolve({
|
||||
browser: true,
|
||||
dedupe: ["svelte"],
|
||||
}),
|
||||
commonjs(),
|
||||
typescript({
|
||||
tsconfig: "webviews/tsconfig.json",
|
||||
sourceMap: !production,
|
||||
inlineSources: !production,
|
||||
}),
|
||||
|
||||
// In dev mode, call `npm run start` once
|
||||
// the bundle has been generated
|
||||
// !production && serve(),
|
||||
|
||||
// Watch the `public` directory and refresh the
|
||||
// browser on changes when not in production
|
||||
// !production && livereload("public"),
|
||||
|
||||
// If we're building for production (npm run build
|
||||
// instead of npm run dev), minify
|
||||
production && terser(),
|
||||
],
|
||||
watch: {
|
||||
clearScreen: false,
|
||||
},
|
||||
};
|
||||
});
|
115
type-script-helper/src/SidebarProvider.ts
Normal file
115
type-script-helper/src/SidebarProvider.ts
Normal file
@ -0,0 +1,115 @@
|
||||
import * as vscode from "vscode";
|
||||
// import { authenticate } from "./authenticate";
|
||||
import { apiBaseUrl } from "./constants";
|
||||
import { key } from "./constants";
|
||||
import { getNonce } from "./getNonce";
|
||||
|
||||
export class SidebarProvider implements vscode.WebviewViewProvider {
|
||||
_view?: vscode.WebviewView;
|
||||
_doc?: vscode.TextDocument;
|
||||
|
||||
constructor(private readonly _extensionContext: vscode.ExtensionContext) { }
|
||||
|
||||
public resolveWebviewView(webviewView: vscode.WebviewView) {
|
||||
this._view = webviewView;
|
||||
|
||||
webviewView.webview.options = {
|
||||
// Allow scripts in the webview
|
||||
enableScripts: true,
|
||||
|
||||
localResourceRoots: [this._extensionContext.extensionUri],
|
||||
};
|
||||
|
||||
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);
|
||||
|
||||
webviewView.webview.onDidReceiveMessage(async (data) => {
|
||||
switch (data.type) {
|
||||
case "logout": {
|
||||
this._extensionContext.workspaceState.update(key, "");
|
||||
break;
|
||||
}
|
||||
case "authenticate": {
|
||||
// authenticate(this._extensionContext, () => {
|
||||
// webviewView.webview.postMessage({
|
||||
// type: "token",
|
||||
// value: this._extensionContext.workspaceState.get(key),
|
||||
// });
|
||||
// });
|
||||
webviewView.webview.postMessage({
|
||||
type: "token",
|
||||
value: this._extensionContext.workspaceState.get(key),
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "get-token": {
|
||||
webviewView.webview.postMessage({
|
||||
type: "token",
|
||||
value: this._extensionContext.workspaceState.get(key),
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "onInfo": {
|
||||
if (!data.value) {
|
||||
return;
|
||||
}
|
||||
vscode.window.showInformationMessage(data.value);
|
||||
break;
|
||||
}
|
||||
case "onError": {
|
||||
if (!data.value) {
|
||||
return;
|
||||
}
|
||||
vscode.window.showErrorMessage(data.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public revive(panel: vscode.WebviewView) {
|
||||
this._view = panel;
|
||||
}
|
||||
|
||||
private _getHtmlForWebview(webview: vscode.Webview) {
|
||||
const styleResetUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "reset.css")
|
||||
);
|
||||
const styleVSCodeUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "media", "vscode.css")
|
||||
);
|
||||
|
||||
const scriptUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/sidebar.js")
|
||||
);
|
||||
const styleMainUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionContext.extensionUri, "out", "compiled/sidebar.css")
|
||||
);
|
||||
|
||||
// Use a nonce to only allow a specific script to be run.
|
||||
const nonce = getNonce();
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!--
|
||||
Use a content security policy to only allow loading images from https or from our extension directory,
|
||||
and only allow scripts that have a specific nonce.
|
||||
-->
|
||||
<meta http-equiv="Content-Security-Policy" content="img-src https: data:; style-src 'unsafe-inline' ${webview.cspSource
|
||||
}; script-src 'nonce-${nonce}';">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="${styleResetUri}" rel="stylesheet">
|
||||
<link href="${styleVSCodeUri}" rel="stylesheet">
|
||||
<link href="${styleMainUri}" rel="stylesheet">
|
||||
<script nonce="${nonce}">
|
||||
const acquiredVsCodeApi = acquireVsCodeApi();
|
||||
const apiBaseUrl = ${JSON.stringify(apiBaseUrl)}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script nonce="${nonce}" src="${scriptUri}"></script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
}
|
165
type-script-helper/src/WebViewPanel.ts
Normal file
165
type-script-helper/src/WebViewPanel.ts
Normal file
@ -0,0 +1,165 @@
|
||||
import * as vscode from "vscode";
|
||||
import { getNonce } from "./getNonce";
|
||||
|
||||
export class WebViewPanel {
|
||||
/**
|
||||
* Track the currently panel. Only allow a single panel to exist at a time.
|
||||
*/
|
||||
public static currentPanel: WebViewPanel | undefined;
|
||||
|
||||
public static readonly viewType = "web-view-panel";
|
||||
|
||||
private readonly _panel: vscode.WebviewPanel;
|
||||
private readonly _extensionUri: vscode.Uri;
|
||||
private _disposables: vscode.Disposable[] = [];
|
||||
|
||||
public static createOrShow(extensionUri: vscode.Uri) {
|
||||
const column = vscode.window.activeTextEditor
|
||||
? vscode.window.activeTextEditor.viewColumn
|
||||
: undefined;
|
||||
|
||||
// If we already have a panel, show it.
|
||||
if (WebViewPanel.currentPanel) {
|
||||
WebViewPanel.currentPanel._panel.reveal(column);
|
||||
WebViewPanel.currentPanel._update();
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, create a new panel.
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
WebViewPanel.viewType,
|
||||
"Web-View-Panel",
|
||||
column || vscode.ViewColumn.One,
|
||||
{
|
||||
// Enable javascript in the webview
|
||||
enableScripts: true,
|
||||
|
||||
// And restrict the webview to only loading content from our extension's `media` directory.
|
||||
localResourceRoots: [
|
||||
vscode.Uri.joinPath(extensionUri, "media"),
|
||||
vscode.Uri.joinPath(extensionUri, "out/compiled"),
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
WebViewPanel.currentPanel = new WebViewPanel(panel, extensionUri);
|
||||
}
|
||||
|
||||
public static kill() {
|
||||
WebViewPanel.currentPanel?.dispose();
|
||||
WebViewPanel.currentPanel = undefined;
|
||||
}
|
||||
|
||||
public static revive(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
|
||||
WebViewPanel.currentPanel = new WebViewPanel(panel, extensionUri);
|
||||
}
|
||||
|
||||
private constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
|
||||
this._panel = panel;
|
||||
this._extensionUri = extensionUri;
|
||||
|
||||
// Set the webview's initial html content
|
||||
this._update();
|
||||
|
||||
// Listen for when the panel is disposed
|
||||
// This happens when the user closes the panel or when the panel is closed programmatically
|
||||
this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
|
||||
|
||||
// // Handle messages from the webview
|
||||
// this._panel.webview.onDidReceiveMessage(
|
||||
// (message) => {
|
||||
// switch (message.command) {
|
||||
// case "alert":
|
||||
// vscode.window.showErrorMessage(message.text);
|
||||
// return;
|
||||
// }
|
||||
// },
|
||||
// null,
|
||||
// this._disposables
|
||||
// );
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
WebViewPanel.currentPanel = undefined;
|
||||
|
||||
// Clean up our resources
|
||||
this._panel.dispose();
|
||||
|
||||
while (this._disposables.length) {
|
||||
const x = this._disposables.pop();
|
||||
if (x) {
|
||||
x.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async _update() {
|
||||
const webview = this._panel.webview;
|
||||
|
||||
this._panel.webview.html = this._getHtmlForWebview(webview);
|
||||
webview.onDidReceiveMessage(async (data) => {
|
||||
switch (data.type) {
|
||||
case "onInfo": {
|
||||
if (!data.value) {
|
||||
return;
|
||||
}
|
||||
vscode.window.showInformationMessage(data.value);
|
||||
break;
|
||||
}
|
||||
case "onError": {
|
||||
if (!data.value) {
|
||||
return;
|
||||
}
|
||||
vscode.window.showErrorMessage(data.value);
|
||||
break;
|
||||
}
|
||||
// case "tokens": {
|
||||
// await Util.globalState.update(accessTokenKey, data.accessToken);
|
||||
// await Util.globalState.update(refreshTokenKey, data.refreshToken);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private _getHtmlForWebview(webview: vscode.Webview) {
|
||||
// // And the uri we use to load this script in the webview
|
||||
const scriptUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionUri, "out/compiled", "WebView.js")
|
||||
);
|
||||
|
||||
// Uri to load styles into webview
|
||||
const stylesResetUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionUri, "media", "reset.css")
|
||||
);
|
||||
const stylesMainUri = webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(this._extensionUri, "media", "vscode.css")
|
||||
);
|
||||
// const cssUri = webview.asWebviewUri(
|
||||
// vscode.Uri.joinPath(this._extensionUri, "out", "compiled/swiper.css")
|
||||
// );
|
||||
|
||||
// // Use a nonce to only allow specific scripts to be run
|
||||
const nonce = getNonce();
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!--
|
||||
Use a content security policy to only allow loading images from https or from our extension directory,
|
||||
and only allow scripts that have a specific nonce.
|
||||
-->
|
||||
<meta http-equiv="Content-Security-Policy" content="img-src https: data:; style-src 'unsafe-inline' ${webview.cspSource}; script-src 'nonce-${nonce}';">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="${stylesResetUri}" rel="stylesheet">
|
||||
<link href="${stylesMainUri}" rel="stylesheet">
|
||||
<script nonce="${nonce}">
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script src="${scriptUri}" nonce="${nonce}">
|
||||
</html>`;
|
||||
}
|
||||
}
|
34
type-script-helper/src/authenticate.ts
Normal file
34
type-script-helper/src/authenticate.ts
Normal file
@ -0,0 +1,34 @@
|
||||
// import * as vscode from "vscode";
|
||||
// import { apiBaseUrl } from "./constants";
|
||||
// import { key } from "./constants";
|
||||
// import * as polka from "polka";
|
||||
|
||||
// export const authenticate = (extensionContext: vscode.ExtensionContext, fn: () => void) => {
|
||||
// const app = polka();
|
||||
|
||||
// app.get(`/auth/:token`, async (req, res) => {
|
||||
// const { token } = req.params;
|
||||
// if (!token) {
|
||||
// res.end(`<h1>something went wrong</h1>`);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// await extensionContext.workspaceState.update(key, token);
|
||||
// fn();
|
||||
|
||||
// res.end(`<h1>auth was successful, you can close this now</h1>`);
|
||||
|
||||
// (app as any).server.close();
|
||||
// });
|
||||
|
||||
// app.listen(54321, (err: Error) => {
|
||||
// if (err) {
|
||||
// vscode.window.showErrorMessage(err.message);
|
||||
// } else {
|
||||
// vscode.commands.executeCommand(
|
||||
// "vscode.open",
|
||||
// vscode.Uri.parse(`${apiBaseUrl}/auth/github`)
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// };
|
2
type-script-helper/src/constants.ts
Normal file
2
type-script-helper/src/constants.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export const key = "type-script-helper";
|
||||
export const apiBaseUrl = "http://localhost:3002";
|
@ -1,13 +1,25 @@
|
||||
// The module 'vscode' contains the VS Code extensibility API
|
||||
// Import the module and reference it with the alias vscode in your code below
|
||||
import * as vscode from 'vscode';
|
||||
import * as kanbanHelper from './kanbanHelper';
|
||||
import * as replaceLinesHelper from './replaceLinesHelper';
|
||||
import * as readOnlyLinesHelper from './readOnlyLinesHelper';
|
||||
import * as promiseLinesHelper from './promiseLinesHelper';
|
||||
import { SidebarProvider } from "./SidebarProvider";
|
||||
import { WebViewPanel } from "./WebViewPanel";
|
||||
|
||||
// This method is called when your extension is activated
|
||||
// Your extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
export async function activate(extensionContext: vscode.ExtensionContext) {
|
||||
|
||||
const sidebarProvider = new SidebarProvider(extensionContext);
|
||||
|
||||
const item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
|
||||
item.text = "$(beaker) Show Kanban";
|
||||
// item.command = "kanban.show";
|
||||
item.show();
|
||||
|
||||
extensionContext.subscriptions.push(vscode.window.registerWebviewViewProvider("kanban-sidebar", sidebarProvider));
|
||||
|
||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||
// This line of code will only be executed once when your extension is activated
|
||||
@ -25,6 +37,10 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
// context.subscriptions.push(disposable);
|
||||
|
||||
const commands = [
|
||||
// vscode.commands.registerCommand("kanban.apiAuthenticate", kanbanHelper.apiAuthenticate(extensionContext)),
|
||||
vscode.commands.registerCommand("kanban.newEntry", kanbanHelper.newEntry(sidebarProvider)),
|
||||
vscode.commands.registerCommand("kanban.refresh", await kanbanHelper.refresh()),
|
||||
// vscode.commands.registerCommand("kanban.debugReload", await kanbanHelper.debugReload(extensionContext)),
|
||||
vscode.commands.registerCommand('promiseLinesHelper.codeGeneratorQuickPick', promiseLinesHelper.codeGeneratorQuickPick),
|
||||
vscode.commands.registerCommand('promiseLinesHelper.insertDateTime', promiseLinesHelper.insertDateTime),
|
||||
vscode.commands.registerCommand('promiseLinesHelper.transformToPopperCase', promiseLinesHelper.transformToPopperCase),
|
||||
@ -50,10 +66,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.registerCommand('replaceLinesHelper.splitBySpaceReverseJoinSort', replaceLinesHelper.splitBySpaceReverseJoinSort),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.unwrapSql', replaceLinesHelper.unwrapSql),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlCSharp', replaceLinesHelper.wrapSqlCSharp),
|
||||
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlVB', replaceLinesHelper.wrapSqlVB)
|
||||
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlVB', replaceLinesHelper.wrapSqlVB),
|
||||
vscode.commands.registerCommand("webView.webView", () => { WebViewPanel.createOrShow(extensionContext.extensionUri); })
|
||||
];
|
||||
|
||||
commands.forEach(command => context.subscriptions.push(command));
|
||||
commands.forEach(command => extensionContext.subscriptions.push(command));
|
||||
}
|
||||
|
||||
// This method is called when your extension is deactivated
|
||||
|
9
type-script-helper/src/getNonce.ts
Normal file
9
type-script-helper/src/getNonce.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export function getNonce() {
|
||||
let text = "";
|
||||
const possible =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for (let i = 0; i < 32; i++) {
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
return text;
|
||||
}
|
40
type-script-helper/src/kanbanHelper.ts
Normal file
40
type-script-helper/src/kanbanHelper.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import * as vscode from 'vscode';
|
||||
// import { authenticate } from "./authenticate";
|
||||
import { SidebarProvider } from './SidebarProvider';
|
||||
// import { WebViewPanel } from "./WebViewPanel";
|
||||
|
||||
export function newEntry(sidebarProvider: SidebarProvider): any {
|
||||
const { activeTextEditor } = vscode.window;
|
||||
if (!activeTextEditor) {
|
||||
vscode.window.showInformationMessage("No active text editor");
|
||||
return;
|
||||
}
|
||||
const text = activeTextEditor.document.getText(
|
||||
activeTextEditor.selection
|
||||
);
|
||||
sidebarProvider._view?.webview.postMessage({
|
||||
type: "new-entry",
|
||||
value: text,
|
||||
});
|
||||
}
|
||||
|
||||
// export function apiAuthenticate(extensionContext: vscode.ExtensionContext): any {
|
||||
// try {
|
||||
// authenticate(extensionContext, () => { });
|
||||
// } catch (err) {
|
||||
// console.log(err);
|
||||
// }
|
||||
// }
|
||||
|
||||
export async function refresh(): Promise<any> {
|
||||
await vscode.commands.executeCommand("workbench.action.closeSidebar");
|
||||
await vscode.commands.executeCommand("workbench.view.extension.kanban-sidebar-view");
|
||||
}
|
||||
|
||||
// export async function debugReload(extensionContext: vscode.ExtensionContext): Promise<any> {
|
||||
// WebViewPanel.kill();
|
||||
// WebViewPanel.createOrShow(extensionContext.extensionUri);
|
||||
// await vscode.commands.executeCommand("workbench.action.closeSidebar");
|
||||
// await vscode.commands.executeCommand("workbench.view.extension.kanban-sidebar-view");
|
||||
// setTimeout(() => { vscode.commands.executeCommand("workbench.action.webview.openDeveloperTools"); }, 500);
|
||||
// }
|
@ -1,16 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "ES2020",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"lib": [
|
||||
"ES2020"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"module": "commonjs",
|
||||
"rootDir": "src",
|
||||
"strict": true /* enable all strict type-checking options */
|
||||
/* Additional Checks */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
}
|
||||
}
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"target": "ES2020"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode-test",
|
||||
"webviews"
|
||||
]
|
||||
}
|
87
type-script-helper/webviews/components/Entries.svelte
Normal file
87
type-script-helper/webviews/components/Entries.svelte
Normal file
@ -0,0 +1,87 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import type { User } from "../types";
|
||||
import type { Entry } from "../types";
|
||||
|
||||
export let user: User;
|
||||
export let accessToken: string;
|
||||
let text = "";
|
||||
let entries: Array<Entry> = [];
|
||||
|
||||
async function addEntry(t: string) {
|
||||
const response = await fetch(`${apiBaseUrl}/entry`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
text: t,
|
||||
}),
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
const { entry } = await response.json();
|
||||
entries = [entry, ...entries];
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
window.addEventListener("message", async (event) => {
|
||||
const message = event.data;
|
||||
switch (message.type) {
|
||||
case "new-entry":
|
||||
addEntry(message.value);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
const response = await fetch(`${apiBaseUrl}/entry`, {
|
||||
headers: {
|
||||
authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
const payload = await response.json();
|
||||
entries = payload.entries;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div>Hello: {user.name}</div>
|
||||
|
||||
<form
|
||||
on:submit|preventDefault={async () => {
|
||||
addEntry(text);
|
||||
text = "";
|
||||
}}
|
||||
>
|
||||
<input bind:value={text} />
|
||||
</form>
|
||||
|
||||
<ul>
|
||||
{#each entries as entry (entry.id)}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore missing-declaration -->
|
||||
<li
|
||||
class:complete={entry.completed}
|
||||
on:click={async () => {
|
||||
entry.completed = !entry.completed;
|
||||
const response = await fetch(`${apiBaseUrl}/entry`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
id: entry.id,
|
||||
}),
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
console.log(await response.json());
|
||||
}}
|
||||
>
|
||||
{entry.text}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<style>
|
||||
.complete {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
</style>
|
70
type-script-helper/webviews/components/Sidebar.svelte
Normal file
70
type-script-helper/webviews/components/Sidebar.svelte
Normal file
@ -0,0 +1,70 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import type { User } from "../types";
|
||||
import Entries from "./Entries.svelte";
|
||||
|
||||
let accessToken = "";
|
||||
let loading = true;
|
||||
let user: User | null = null;
|
||||
let page: "entries" | "contact" =
|
||||
acquiredVsCodeApi.getState()?.page || "entries";
|
||||
|
||||
$: {
|
||||
acquiredVsCodeApi.setState({ page });
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
window.addEventListener("message", async (event) => {
|
||||
const message = event.data;
|
||||
switch (message.type) {
|
||||
case "token":
|
||||
accessToken = message.value;
|
||||
const response = await fetch(`${apiBaseUrl}/me`, {
|
||||
headers: {
|
||||
authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
const data = await response.json();
|
||||
user = data.user;
|
||||
loading = false;
|
||||
}
|
||||
});
|
||||
|
||||
acquiredVsCodeApi.postMessage({ type: "get-token", value: undefined });
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if loading}
|
||||
<div>loading...</div>
|
||||
{:else if user}
|
||||
{#if page === "entries"}
|
||||
<Entries {user} {accessToken} />
|
||||
<button
|
||||
on:click={() => {
|
||||
page = "contact";
|
||||
}}>go to contact</button
|
||||
>
|
||||
{:else}
|
||||
<div>Contact me here: adlkfjjqioefeqio</div>
|
||||
<button
|
||||
on:click={() => {
|
||||
page = "entries";
|
||||
}}>go back</button
|
||||
>
|
||||
{/if}
|
||||
<!-- svelte-ignore missing-declaration -->
|
||||
<button
|
||||
on:click={() => {
|
||||
accessToken = "";
|
||||
user = null;
|
||||
acquiredVsCodeApi.postMessage({ type: "logout", value: undefined });
|
||||
}}>logout</button
|
||||
>
|
||||
{:else}
|
||||
<!-- svelte-ignore missing-declaration -->
|
||||
<button
|
||||
on:click={() => {
|
||||
acquiredVsCodeApi.postMessage({ type: "authenticate", value: undefined });
|
||||
}}>login with GitHub</button
|
||||
>
|
||||
{/if}
|
4
type-script-helper/webviews/components/WebView.svelte
Normal file
4
type-script-helper/webviews/components/WebView.svelte
Normal file
@ -0,0 +1,4 @@
|
||||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
<h1>WebView 2023-09-23-15-20</h1>
|
10
type-script-helper/webviews/globals.d.ts
vendored
Normal file
10
type-script-helper/webviews/globals.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import * as _vscode from "vscode";
|
||||
|
||||
declare global {
|
||||
const acquiredVsCodeApi: {
|
||||
postMessage: ({ type: string, value: any }) => void;
|
||||
getState: () => any;
|
||||
setState: (state: any) => void;
|
||||
};
|
||||
const apiBaseUrl: string;
|
||||
}
|
7
type-script-helper/webviews/pages/sidebar.ts
Normal file
7
type-script-helper/webviews/pages/sidebar.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import App from "../components/Sidebar.svelte";
|
||||
|
||||
const app = new App({
|
||||
target: document.body,
|
||||
});
|
||||
|
||||
export default app;
|
7
type-script-helper/webviews/pages/webView.ts
Normal file
7
type-script-helper/webviews/pages/webView.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import App from "../components/WebView.svelte";
|
||||
|
||||
const app = new App({
|
||||
target: document.body,
|
||||
});
|
||||
|
||||
export default app;
|
13
type-script-helper/webviews/tsconfig.json
Normal file
13
type-script-helper/webviews/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"ignoreDeprecations": "5.0",
|
||||
"strict": true
|
||||
},
|
||||
"exclude": [
|
||||
"../node_modules/*"
|
||||
],
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
"include": [
|
||||
"./**/*"
|
||||
]
|
||||
}
|
11
type-script-helper/webviews/types.ts
Normal file
11
type-script-helper/webviews/types.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export type User = {
|
||||
id: string;
|
||||
name: string;
|
||||
githubId: string;
|
||||
};
|
||||
|
||||
export type Entry = {
|
||||
text: string;
|
||||
completed: boolean;
|
||||
id: number;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user