@tomjs/create-app 0.15.0 → 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/index.js +25 -0
  2. package/package.json +25 -20
  3. package/dist/index.mjs +0 -11
  4. package/template-config/.commitlintrc.cjs +0 -3
  5. package/template-config/.editorconfig +0 -15
  6. package/template-config/.eslintignore +0 -14
  7. package/template-config/.gitattributes +0 -203
  8. package/template-config/.husky/commit-msg +0 -1
  9. package/template-config/.husky/pre-commit +0 -1
  10. package/template-config/.prettierignore +0 -17
  11. package/template-config/.prettierrc.cjs +0 -1
  12. package/template-config/.stylelintignore +0 -16
  13. package/template-config/.stylelintrc.cjs +0 -3
  14. package/template-config/_gitignore +0 -60
  15. package/template-electron-react/.vscode/launch.json +0 -28
  16. package/template-electron-react/.vscode/tasks.json +0 -37
  17. package/template-electron-react/README.md +0 -97
  18. package/template-electron-react/_eslintrc.cjs +0 -7
  19. package/template-electron-react/_lintstagedrc.cjs +0 -5
  20. package/template-electron-react/electron/env.d.ts +0 -1
  21. package/template-electron-react/electron/main/index.ts +0 -128
  22. package/template-electron-react/electron/polyfills.ts +0 -4
  23. package/template-electron-react/electron/preload/index.ts +0 -1
  24. package/template-electron-react/index.html +0 -15
  25. package/template-electron-react/package.json +0 -54
  26. package/template-electron-react/public/img/icon.png +0 -0
  27. package/template-electron-react/public/vite.svg +0 -1
  28. package/template-electron-react/src/App.css +0 -45
  29. package/template-electron-react/src/App.tsx +0 -42
  30. package/template-electron-react/src/assets/electron.svg +0 -10
  31. package/template-electron-react/src/assets/react.svg +0 -1
  32. package/template-electron-react/src/index.css +0 -69
  33. package/template-electron-react/src/main.tsx +0 -11
  34. package/template-electron-react/src/vite-env.d.ts +0 -1
  35. package/template-electron-react/tsconfig.json +0 -10
  36. package/template-electron-react/tsconfig.node.json +0 -7
  37. package/template-electron-react/vite.config.ts +0 -27
  38. package/template-electron-vue/.vscode/launch.json +0 -28
  39. package/template-electron-vue/.vscode/tasks.json +0 -37
  40. package/template-electron-vue/README.md +0 -92
  41. package/template-electron-vue/_eslintrc.cjs +0 -7
  42. package/template-electron-vue/_lintstagedrc.cjs +0 -6
  43. package/template-electron-vue/electron/env.d.ts +0 -1
  44. package/template-electron-vue/electron/main/index.ts +0 -123
  45. package/template-electron-vue/electron/polyfills.ts +0 -4
  46. package/template-electron-vue/electron/preload/index.ts +0 -1
  47. package/template-electron-vue/index.html +0 -15
  48. package/template-electron-vue/package.json +0 -52
  49. package/template-electron-vue/public/img/icon.png +0 -0
  50. package/template-electron-vue/public/vite.svg +0 -1
  51. package/template-electron-vue/src/App.vue +0 -55
  52. package/template-electron-vue/src/assets/electron.svg +0 -10
  53. package/template-electron-vue/src/assets/vue.svg +0 -1
  54. package/template-electron-vue/src/components/HelloWorld.vue +0 -43
  55. package/template-electron-vue/src/main.ts +0 -6
  56. package/template-electron-vue/src/style.css +0 -80
  57. package/template-electron-vue/src/vite-env.d.ts +0 -1
  58. package/template-electron-vue/tsconfig.json +0 -10
  59. package/template-electron-vue/tsconfig.node.json +0 -7
  60. package/template-electron-vue/vite.config.ts +0 -26
  61. package/template-node/.vscode/launch.json +0 -19
  62. package/template-node/.vscode/tasks.json +0 -36
  63. package/template-node/LICENSE +0 -21
  64. package/template-node/README.md +0 -13
  65. package/template-node/README.zh_CN.md +0 -13
  66. package/template-node/_eslintrc.cjs +0 -7
  67. package/template-node/_lintstagedrc.cjs +0 -4
  68. package/template-node/_lintstagedrc.examples.cjs +0 -6
  69. package/template-node/package.json +0 -79
  70. package/template-node/scripts/info.ts +0 -12
  71. package/template-node/src/index.ts +0 -3
  72. package/template-node/test/index.test.ts +0 -7
  73. package/template-node/tsconfig.json +0 -4
  74. package/template-node/tsconfig.test.json +0 -4
  75. package/template-node/tsup.config.ts +0 -16
  76. package/template-node/vite.config.ts +0 -42
  77. package/template-node/vitest.workspace.ts +0 -3
  78. package/template-react/README.md +0 -3
  79. package/template-react/_eslintrc.cjs +0 -7
  80. package/template-react/_lintstagedrc.cjs +0 -5
  81. package/template-react/index.html +0 -14
  82. package/template-react/package.json +0 -44
  83. package/template-react/public/vite.svg +0 -1
  84. package/template-react/src/App.css +0 -42
  85. package/template-react/src/App.tsx +0 -32
  86. package/template-react/src/assets/react.svg +0 -1
  87. package/template-react/src/index.css +0 -69
  88. package/template-react/src/main.tsx +0 -11
  89. package/template-react/src/vite-env.d.ts +0 -1
  90. package/template-react/tsconfig.json +0 -5
  91. package/template-react/tsconfig.node.json +0 -7
  92. package/template-react/vite.config.ts +0 -7
  93. package/template-vscode/.vscode/launch.json +0 -21
  94. package/template-vscode/.vscode/tasks.json +0 -36
  95. package/template-vscode/.vscodeignore +0 -71
  96. package/template-vscode/LICENSE +0 -21
  97. package/template-vscode/README.md +0 -3
  98. package/template-vscode/_eslintrc.cjs +0 -7
  99. package/template-vscode/_lintstagedrc.cjs +0 -5
  100. package/template-vscode/package.json +0 -66
  101. package/template-vscode/package.nls.json +0 -4
  102. package/template-vscode/package.nls.zh-cn.json +0 -4
  103. package/template-vscode/resources/logo.png +0 -0
  104. package/template-vscode/src/index.ts +0 -12
  105. package/template-vscode/tsconfig.json +0 -5
  106. package/template-vscode/tsup.config.ts +0 -13
  107. package/template-vscode-react/.vscode/launch.json +0 -21
  108. package/template-vscode-react/.vscode/tasks.json +0 -36
  109. package/template-vscode-react/.vscodeignore +0 -72
  110. package/template-vscode-react/LICENSE +0 -21
  111. package/template-vscode-react/README.md +0 -3
  112. package/template-vscode-react/_eslintrc.cjs +0 -7
  113. package/template-vscode-react/_lintstagedrc.cjs +0 -5
  114. package/template-vscode-react/extension/env.d.ts +0 -1
  115. package/template-vscode-react/extension/index.ts +0 -13
  116. package/template-vscode-react/extension/views/helper.ts +0 -27
  117. package/template-vscode-react/extension/views/panel.ts +0 -48
  118. package/template-vscode-react/index.html +0 -14
  119. package/template-vscode-react/package.json +0 -82
  120. package/template-vscode-react/package.nls.json +0 -4
  121. package/template-vscode-react/package.nls.zh-cn.json +0 -4
  122. package/template-vscode-react/resources/logo.png +0 -0
  123. package/template-vscode-react/src/App.css +0 -7
  124. package/template-vscode-react/src/App.tsx +0 -51
  125. package/template-vscode-react/src/main.tsx +0 -9
  126. package/template-vscode-react/src/utils/index.ts +0 -1
  127. package/template-vscode-react/src/utils/vscode.ts +0 -83
  128. package/template-vscode-react/src/vite-env.d.ts +0 -1
  129. package/template-vscode-react/tsconfig.json +0 -10
  130. package/template-vscode-react/tsconfig.node.json +0 -7
  131. package/template-vscode-react/vite.config.ts +0 -20
  132. package/template-vscode-vue/.vscode/launch.json +0 -21
  133. package/template-vscode-vue/.vscode/tasks.json +0 -36
  134. package/template-vscode-vue/.vscodeignore +0 -72
  135. package/template-vscode-vue/LICENSE +0 -21
  136. package/template-vscode-vue/README.md +0 -3
  137. package/template-vscode-vue/_eslintrc.cjs +0 -7
  138. package/template-vscode-vue/_lintstagedrc.cjs +0 -6
  139. package/template-vscode-vue/extension/env.d.ts +0 -1
  140. package/template-vscode-vue/extension/index.ts +0 -13
  141. package/template-vscode-vue/extension/views/helper.ts +0 -27
  142. package/template-vscode-vue/extension/views/panel.ts +0 -48
  143. package/template-vscode-vue/index.html +0 -14
  144. package/template-vscode-vue/package.json +0 -80
  145. package/template-vscode-vue/package.nls.json +0 -4
  146. package/template-vscode-vue/package.nls.zh-cn.json +0 -4
  147. package/template-vscode-vue/resources/logo.png +0 -0
  148. package/template-vscode-vue/src/App.vue +0 -58
  149. package/template-vscode-vue/src/main.ts +0 -4
  150. package/template-vscode-vue/src/utils/index.ts +0 -1
  151. package/template-vscode-vue/src/utils/vscode.ts +0 -83
  152. package/template-vscode-vue/src/vite-env.d.ts +0 -1
  153. package/template-vscode-vue/tsconfig.json +0 -10
  154. package/template-vscode-vue/tsconfig.node.json +0 -7
  155. package/template-vscode-vue/vite.config.ts +0 -29
  156. package/template-vue/README.md +0 -3
  157. package/template-vue/_eslintrc.cjs +0 -7
  158. package/template-vue/_lintstagedrc.cjs +0 -6
  159. package/template-vue/index.html +0 -14
  160. package/template-vue/package.json +0 -42
  161. package/template-vue/public/vite.svg +0 -1
  162. package/template-vue/src/App.vue +0 -32
  163. package/template-vue/src/assets/vue.svg +0 -1
  164. package/template-vue/src/components/HelloWorld.vue +0 -37
  165. package/template-vue/src/main.ts +0 -6
  166. package/template-vue/src/style.css +0 -80
  167. package/template-vue/src/vite-env.d.ts +0 -1
  168. package/template-vue/tsconfig.json +0 -5
  169. package/template-vue/tsconfig.node.json +0 -7
  170. package/template-vue/vite.config.ts +0 -7
@@ -1,83 +0,0 @@
1
- import type { WebviewApi } from 'vscode-webview';
2
-
3
- /**
4
- * A utility wrapper around the acquireVsCodeApi() function, which enables
5
- * message passing and state management between the webview and extension
6
- * contexts.
7
- *
8
- * This utility also enables webview code to be run in a web browser-based
9
- * dev server by using native web browser features that mock the functionality
10
- * enabled by acquireVsCodeApi.
11
- */
12
- class VSCodeAPIWrapper {
13
- private readonly vsCodeApi: WebviewApi<unknown> | undefined;
14
-
15
- constructor() {
16
- // Check if the acquireVsCodeApi function exists in the current development
17
- // context (i.e. VS Code development window or web browser)
18
- if (typeof acquireVsCodeApi === 'function') {
19
- this.vsCodeApi = acquireVsCodeApi();
20
- }
21
- }
22
-
23
- // private init() {
24
- // // TODO 环境变量判断
25
- // }
26
-
27
- /**
28
- * Post a message (i.e. send arbitrary data) to the owner of the webview.
29
- *
30
- * @remarks When running webview code inside a web browser, postMessage will instead
31
- * log the given message to the console.
32
- *
33
- * @param message Abitrary data (must be JSON serializable) to send to the extension context.
34
- */
35
- public postMessage(message: unknown) {
36
- if (this.vsCodeApi) {
37
- this.vsCodeApi.postMessage(message);
38
- } else {
39
- window.parent.postMessage({ type: 'page:message', data: message }, '*');
40
- console.log(message);
41
- }
42
- }
43
-
44
- /**
45
- * Get the persistent state stored for this webview.
46
- *
47
- * @remarks When running webview source code inside a web browser, getState will retrieve state
48
- * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
49
- *
50
- * @return The current state or `undefined` if no state has been set.
51
- */
52
- public getState(): unknown | undefined {
53
- if (this.vsCodeApi) {
54
- return this.vsCodeApi.getState();
55
- } else {
56
- const state = localStorage.getItem('vscodeState');
57
- return state ? JSON.parse(state) : undefined;
58
- }
59
- }
60
-
61
- /**
62
- * Set the persistent state stored for this webview.
63
- *
64
- * @remarks When running webview source code inside a web browser, setState will set the given
65
- * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
66
- *
67
- * @param newState New persisted state. This must be a JSON serializable object. Can be retrieved
68
- * using {@link getState}.
69
- *
70
- * @return The new state.
71
- */
72
- public setState<T extends unknown | undefined>(newState: T): T {
73
- if (this.vsCodeApi) {
74
- return this.vsCodeApi.setState(newState);
75
- } else {
76
- localStorage.setItem('vscodeState', JSON.stringify(newState));
77
- return newState;
78
- }
79
- }
80
- }
81
-
82
- // Exports class singleton to prevent multiple invocations of acquireVsCodeApi.
83
- export const vscode = new VSCodeAPIWrapper();
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@tomjs/tsconfig/vue-dom.json",
3
- "compilerOptions": {},
4
- "include": ["src"],
5
- "references": [
6
- {
7
- "path": "./tsconfig.node.json"
8
- }
9
- ]
10
- }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "@tomjs/tsconfig/node.json",
3
- "compilerOptions": {
4
- "composite": true
5
- },
6
- "include": ["extension", "package.json", "vite.config.ts"]
7
- }
@@ -1,20 +0,0 @@
1
- import path from 'node:path';
2
- import vscode from '@tomjs/vite-plugin-vscode';
3
- import react from '@vitejs/plugin-react-swc';
4
- import { defineConfig } from 'vite';
5
- import pkg from './package.json';
6
-
7
- // https://vitejs.dev/config/
8
- export default defineConfig(() => {
9
- process.env.APP_BUILD_TIME = Date.now() + '';
10
- process.env.APP_VERSION = pkg.version;
11
-
12
- return {
13
- resolve: {
14
- alias: {
15
- '@': path.join(__dirname, 'src'),
16
- },
17
- },
18
- plugins: [react(), vscode()],
19
- };
20
- });
@@ -1,21 +0,0 @@
1
- // A launch configuration that compiles the extension and then opens it inside a new window
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- {
6
- "version": "0.2.0",
7
- "configurations": [
8
- {
9
- "name": "Debug Extension",
10
- "type": "extensionHost",
11
- "request": "launch",
12
- "args": [
13
- "--extensionDevelopmentPath=${workspaceFolder}"
14
- ],
15
- "outFiles": [
16
- "${workspaceFolder}/dist/extension/*.js"
17
- ],
18
- "preLaunchTask": "${defaultBuildTask}"
19
- }
20
- ]
21
- }
@@ -1,36 +0,0 @@
1
- // See https://go.microsoft.com/fwlink/?LinkId=733558
2
- // for the documentation about the tasks.json format
3
- {
4
- "version": "2.0.0",
5
- "tasks": [
6
- {
7
- "type": "npm",
8
- "script": "dev",
9
- "problemMatcher": {
10
- "owner": "typescript",
11
- "fileLocation": "relative",
12
- "pattern": {
13
- "regexp": "^([a-zA-Z]\\:\/?([\\w\\-]\/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
14
- "file": 1,
15
- "line": 3,
16
- "column": 4,
17
- "code": 5,
18
- "message": 6
19
- },
20
- "background": {
21
- "activeOnStart": true,
22
- "beginsPattern": "^.*extension build start*$",
23
- "endsPattern": "^.*extension (build|rebuild) success.*$"
24
- }
25
- },
26
- "isBackground": true,
27
- "presentation": {
28
- "reveal": "never"
29
- },
30
- "group": {
31
- "kind": "build",
32
- "isDefault": true
33
- }
34
- }
35
- ]
36
- }
@@ -1,72 +0,0 @@
1
- # logs
2
- *.log
3
- lerna-debug.log*
4
- logs
5
- npm-debug.log*
6
- pnpm-debug.log*
7
- yarn-debug.log*
8
- yarn-error.log*
9
-
10
- # diagnostic reports (https://nodejs.org/api/report.html)
11
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12
-
13
- # runtime data
14
- *.pid
15
- *.pid.lock
16
- *.seed
17
- pids
18
-
19
- # dependency directory
20
- node_modules
21
-
22
- # cache
23
- .cache
24
- .npm
25
- .tmp
26
- .temp
27
- .eslintcache
28
- .stylelintcache
29
- tsconfig.tsbuildinfo
30
-
31
- # environment
32
- *.local
33
-
34
- # macOS
35
- .DS_Store
36
-
37
- # package files
38
- *.7z
39
- *.gz
40
- *.gzip
41
- *.rar
42
- *.tar
43
- *.tar.*
44
- *.tgz
45
- *.zip
46
- *.vsix
47
-
48
- # IDEA
49
- .idea
50
-
51
- # vscode
52
- .vscode
53
- .history
54
-
55
- # project
56
- src
57
- extension
58
-
59
- .husky
60
- .commitlintrc*
61
- .editorconfig
62
- .eslintrc*
63
- .eslintignore
64
- .gitattributes
65
- .gitignore
66
- .lintstagedrc*
67
- .prettierrc*
68
- .prettierignore
69
- pnpm-lock.yaml
70
- tsconfig.json
71
- tsconfig.*.json
72
- *.config.ts
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023-PRESENT {{user.name}}<{{user.email}}>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,3 +0,0 @@
1
- # extension-vue
2
-
3
- vite + extension + vue
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- es6: true,
5
- },
6
- extends: [require.resolve('@tomjs/eslint/vue')],
7
- };
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- '*.{js,cjs,ts,tsx}': ['eslint --fix', 'prettier --write'],
3
- '*.{json,md}': ['prettier --write'],
4
- '*.vue': ['eslint --fix', 'stylelint --fix', 'prettier --write'],
5
- '*.{css,scss,less,html}': ['stylelint --fix', 'prettier --write'],
6
- };
@@ -1 +0,0 @@
1
- /// <reference types="@tomjs/vite-plugin-vscode/env" />
@@ -1,13 +0,0 @@
1
- import type { ExtensionContext } from 'vscode';
2
- import { commands } from 'vscode';
3
- import { MainPanel } from './views/panel';
4
-
5
- export function activate(context: ExtensionContext) {
6
- context.subscriptions.push(
7
- commands.registerCommand('hello-world.showHelloWorld', async () => {
8
- MainPanel.render(context.extensionUri);
9
- }),
10
- );
11
- }
12
-
13
- export function deactivate() {}
@@ -1,27 +0,0 @@
1
- import type { Disposable, ExtensionContext, Webview } from 'vscode';
2
- import { window } from 'vscode';
3
-
4
- export class WebviewHelper {
5
- public static setupHtml(webview: Webview, context: ExtensionContext) {
6
- return process.env.VITE_DEV_SERVER_URL
7
- ? __getWebviewHtml__(process.env.VITE_DEV_SERVER_URL)
8
- : __getWebviewHtml__(webview, context);
9
- }
10
-
11
- public static setupWebviewHooks(webview: Webview, disposables: Disposable[]) {
12
- webview.onDidReceiveMessage(
13
- (message: any) => {
14
- const command = message.command;
15
- const text = message.text;
16
- console.log(`command: ${command}`);
17
- switch (command) {
18
- case 'hello':
19
- window.showInformationMessage(text);
20
- return;
21
- }
22
- },
23
- undefined,
24
- disposables,
25
- );
26
- }
27
- }
@@ -1,48 +0,0 @@
1
- import type { Disposable, ExtensionContext, WebviewPanel } from 'vscode';
2
- import { ViewColumn, window } from 'vscode';
3
- import { WebviewHelper } from './helper';
4
-
5
- export class MainPanel {
6
- public static currentPanel: MainPanel | undefined;
7
- private readonly _panel: WebviewPanel;
8
- private _disposables: Disposable[] = [];
9
-
10
- private constructor(panel: WebviewPanel, context: ExtensionContext) {
11
- this._panel = panel;
12
-
13
- this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
14
- this._panel.webview.html = WebviewHelper.setupHtml(this._panel.webview, context);
15
-
16
- WebviewHelper.setupWebviewHooks(this._panel.webview, this._disposables);
17
- }
18
-
19
- public static render(context: ExtensionContext) {
20
- if (MainPanel.currentPanel) {
21
- MainPanel.currentPanel._panel.reveal(ViewColumn.One);
22
- } else {
23
- const panel = window.createWebviewPanel('showHelloWorld', 'Hello World', ViewColumn.One, {
24
- enableScripts: true,
25
- });
26
-
27
- MainPanel.currentPanel = new MainPanel(panel, context);
28
- }
29
- }
30
-
31
- /**
32
- * Cleans up and disposes of webview resources when the webview panel is closed.
33
- */
34
- public dispose() {
35
- MainPanel.currentPanel = undefined;
36
-
37
- // Dispose of the current webview panel
38
- this._panel.dispose();
39
-
40
- // Dispose of all disposables (i.e. commands) for the current webview panel
41
- while (this._disposables.length) {
42
- const disposable = this._disposables.pop();
43
- if (disposable) {
44
- disposable.dispose();
45
- }
46
- }
47
- }
48
- }
@@ -1,14 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
7
- <title>Vite + VSCode Extension + Vue</title>
8
- </head>
9
-
10
- <body>
11
- <div id="app"></div>
12
- <script type="module" src="/src/main.ts"></script>
13
- </body>
14
- </html>
@@ -1,80 +0,0 @@
1
- {
2
- "name": "vscode-extension",
3
- "displayName": "%displayName%",
4
- "description": "%description%",
5
- "version": "0.0.0",
6
- "publisher": "{{git.org}}",
7
- "license": "MIT",
8
- "engines": {
9
- "node": ">=14",
10
- "vscode": "^1.75.0"
11
- },
12
- "main": "dist/extension/index.js",
13
- "keywords": [
14
- "vscode"
15
- ],
16
- "categories": [
17
- "Other"
18
- ],
19
- "activationEvents": [],
20
- "contributes": {
21
- "commands": [
22
- {
23
- "command": "hello-world.showHelloWorld",
24
- "title": "Hello World: Show"
25
- }
26
- ]
27
- },
28
- "repository": {
29
- "type": "git",
30
- "url": "git+{{git.url}}.git"
31
- },
32
- "bugs": {
33
- "url": "git+{{git.url}}/issues"
34
- },
35
- "homepage": "{{git.url}}/blob/main/README.md",
36
- "icon": "resources/logo.png",
37
- "vsce": {
38
- "dependencies": false,
39
- "yarn": false
40
- },
41
- "scripts": {
42
- "dev": "vite",
43
- "build": "npm run clean && vue-tsc --noEmit && vite build",
44
- "clean": "rimraf ./dist",
45
- "lint": "run-s lint:eslint lint:stylelint lint:prettier",
46
- "lint:eslint": "eslint \"{src,extension,scripts}/**/*.{js,cjs,ts,tsx,vue}\" *.{js,cjs,ts} --fix --cache",
47
- "lint:stylelint": "stylelint \"{src,extension,scripts}/**/*.{css,scss,less,html}\" --fix --cache",
48
- "lint:prettier": "prettier --write .",
49
- "prepare": "husky"
50
- },
51
- "dependencies": {
52
- "@vscode/webview-ui-toolkit": "^1.4.0",
53
- "vue": "^3.4.27"
54
- },
55
- "devDependencies": {
56
- "@commitlint/cli": "^19.3.0",
57
- "@tomjs/commitlint": "^3.0.0",
58
- "@tomjs/eslint": "^2.3.0",
59
- "@tomjs/prettier": "^1.3.0",
60
- "@tomjs/stylelint": "^2.3.0",
61
- "@tomjs/tsconfig": "^1.5.0",
62
- "@tomjs/vite-plugin-vscode": "^2.2.0",
63
- "@types/node": "^18.19.33",
64
- "@types/vscode": "^1.75.0",
65
- "@types/vscode-webview": "^1.57.5",
66
- "@vitejs/plugin-vue": "^5.0.4",
67
- "cross-env": "^7.0.3",
68
- "eslint": "^8.57.0",
69
- "husky": "^9.0.11",
70
- "lint-staged": "^15.2.2",
71
- "npm-run-all": "^4.1.5",
72
- "prettier": "^3.2.5",
73
- "rimraf": "^5.0.7",
74
- "stylelint": "^16.5.0",
75
- "tsx": "^4.10.2",
76
- "typescript": "~5.4.5",
77
- "vite": "^5.2.11",
78
- "vue-tsc": "^2.0.17"
79
- }
80
- }
@@ -1,4 +0,0 @@
1
- {
2
- "displayName": "VSCode Extension",
3
- "description": "This is a VSCode Extension"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "displayName": "VSCode 扩展",
3
- "description": "这是一个 VSCode 扩展"
4
- }
@@ -1,58 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref } from 'vue';
3
- import { allComponents, provideVSCodeDesignSystem } from '@vscode/webview-ui-toolkit';
4
- import { vscode } from './utils';
5
-
6
- provideVSCodeDesignSystem().register(allComponents);
7
-
8
- function onPostMessage() {
9
- vscode.postMessage({
10
- command: 'hello',
11
- text: 'Hey there partner! 🤠',
12
- });
13
- }
14
-
15
- const message = ref('');
16
- const state = ref('');
17
-
18
- const onSetState = () => {
19
- vscode.setState(state.value);
20
- };
21
-
22
- const onGetState = () => {
23
- state.value = vscode.getState() as string;
24
- };
25
- </script>
26
-
27
- <template>
28
- <main>
29
- <h1>Hello Vue!</h1>
30
- <vscode-button @click="onPostMessage">Test VSCode Message</vscode-button>
31
- <div>
32
- <vscode-text-field :value="message" @input="e => (message = e.target.value)">
33
- Please enter a message
34
- </vscode-text-field>
35
- <div>Message is: {{ message }}</div>
36
- </div>
37
- <div>
38
- <vscode-text-field :value="state" @input="e => (state = e.target.value)">
39
- Please enter a state
40
- </vscode-text-field>
41
- <div>State is: {{ state }}</div>
42
- <div>
43
- <vscode-button @click="onSetState">setState</vscode-button>
44
- <vscode-button style="margin-left: 8px" @click="onGetState">getState</vscode-button>
45
- </div>
46
- </div>
47
- </main>
48
- </template>
49
-
50
- <style>
51
- main {
52
- display: flex;
53
- flex-direction: column;
54
- align-items: flex-start;
55
- justify-content: center;
56
- height: 100%;
57
- }
58
- </style>
@@ -1,4 +0,0 @@
1
- import { createApp } from 'vue';
2
- import App from './App.vue';
3
-
4
- createApp(App).mount('#app');
@@ -1 +0,0 @@
1
- export * from './vscode';
@@ -1,83 +0,0 @@
1
- import type { WebviewApi } from 'vscode-webview';
2
-
3
- /**
4
- * A utility wrapper around the acquireVsCodeApi() function, which enables
5
- * message passing and state management between the webview and extension
6
- * contexts.
7
- *
8
- * This utility also enables webview code to be run in a web browser-based
9
- * dev server by using native web browser features that mock the functionality
10
- * enabled by acquireVsCodeApi.
11
- */
12
- class VSCodeAPIWrapper {
13
- private readonly vsCodeApi: WebviewApi<unknown> | undefined;
14
-
15
- constructor() {
16
- // Check if the acquireVsCodeApi function exists in the current development
17
- // context (i.e. VS Code development window or web browser)
18
- if (typeof acquireVsCodeApi === 'function') {
19
- this.vsCodeApi = acquireVsCodeApi();
20
- }
21
- }
22
-
23
- // private init() {
24
- // // TODO 环境变量判断
25
- // }
26
-
27
- /**
28
- * Post a message (i.e. send arbitrary data) to the owner of the webview.
29
- *
30
- * @remarks When running webview code inside a web browser, postMessage will instead
31
- * log the given message to the console.
32
- *
33
- * @param message Abitrary data (must be JSON serializable) to send to the extension context.
34
- */
35
- public postMessage(message: unknown) {
36
- if (this.vsCodeApi) {
37
- this.vsCodeApi.postMessage(message);
38
- } else {
39
- window.parent.postMessage({ type: 'page:message', data: message }, '*');
40
- console.log(message);
41
- }
42
- }
43
-
44
- /**
45
- * Get the persistent state stored for this webview.
46
- *
47
- * @remarks When running webview source code inside a web browser, getState will retrieve state
48
- * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
49
- *
50
- * @return The current state or `undefined` if no state has been set.
51
- */
52
- public getState(): unknown | undefined {
53
- if (this.vsCodeApi) {
54
- return this.vsCodeApi.getState();
55
- } else {
56
- const state = localStorage.getItem('vscodeState');
57
- return state ? JSON.parse(state) : undefined;
58
- }
59
- }
60
-
61
- /**
62
- * Set the persistent state stored for this webview.
63
- *
64
- * @remarks When running webview source code inside a web browser, setState will set the given
65
- * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
66
- *
67
- * @param newState New persisted state. This must be a JSON serializable object. Can be retrieved
68
- * using {@link getState}.
69
- *
70
- * @return The new state.
71
- */
72
- public setState<T extends unknown | undefined>(newState: T): T {
73
- if (this.vsCodeApi) {
74
- return this.vsCodeApi.setState(newState);
75
- } else {
76
- localStorage.setItem('vscodeState', JSON.stringify(newState));
77
- return newState;
78
- }
79
- }
80
- }
81
-
82
- // Exports class singleton to prevent multiple invocations of acquireVsCodeApi.
83
- export const vscode = new VSCodeAPIWrapper();
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@tomjs/tsconfig/vue-dom.json",
3
- "compilerOptions": {},
4
- "include": ["src"],
5
- "references": [
6
- {
7
- "path": "./tsconfig.node.json"
8
- }
9
- ]
10
- }