@tomjs/vite-plugin-vscode 3.1.0 → 3.2.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.
- package/dist/client.global.js +25 -0
- package/dist/index.js +4 -2
- package/dist/index.mjs +4 -2
- package/dist/webview.d.mts +2 -2
- package/dist/webview.d.ts +2 -2
- package/dist/webview.js +13 -3
- package/dist/webview.mjs +13 -3
- package/package.json +2 -2
package/dist/client.global.js
CHANGED
|
@@ -72,6 +72,31 @@
|
|
|
72
72
|
}
|
|
73
73
|
patchInitData(data);
|
|
74
74
|
});
|
|
75
|
+
var KEYBOARD_EVENT_TYPE = "[vscode:client]:commands";
|
|
76
|
+
var isMac = navigator.userAgent.indexOf("Macintosh") >= 0;
|
|
77
|
+
document.addEventListener("keydown", (e) => {
|
|
78
|
+
console.log(e);
|
|
79
|
+
const { metaKey, shiftKey, ctrlKey, altKey, key } = e;
|
|
80
|
+
if (key === "F1") {
|
|
81
|
+
window.parent.postMessage({ type: KEYBOARD_EVENT_TYPE, data: "F1" }, "*");
|
|
82
|
+
} else if (isMac && metaKey && !altKey && !ctrlKey) {
|
|
83
|
+
if (shiftKey) {
|
|
84
|
+
if (key === "z") {
|
|
85
|
+
document.execCommand("redo");
|
|
86
|
+
}
|
|
87
|
+
} else if (key === "a") {
|
|
88
|
+
document.execCommand("selectAll");
|
|
89
|
+
} else if (key === "c") {
|
|
90
|
+
document.execCommand("copy");
|
|
91
|
+
} else if (key === "v") {
|
|
92
|
+
document.execCommand("paste");
|
|
93
|
+
} else if (key === "x") {
|
|
94
|
+
document.execCommand("cut");
|
|
95
|
+
} else if (key === "z") {
|
|
96
|
+
document.execCommand("undo");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
75
100
|
}
|
|
76
101
|
});
|
|
77
102
|
require_client();
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,7 @@ function useVSCodePlugin(options) {
|
|
|
256
256
|
}
|
|
257
257
|
let resolvedConfig;
|
|
258
258
|
const prodHtmlCache = {};
|
|
259
|
+
let devtoolsFlag = false;
|
|
259
260
|
return [
|
|
260
261
|
{
|
|
261
262
|
name: "@tomjs:vscode",
|
|
@@ -335,8 +336,9 @@ function useVSCodePlugin(options) {
|
|
|
335
336
|
/<head>/i,
|
|
336
337
|
`<head><script src="http://localhost:${port}"></script>`
|
|
337
338
|
);
|
|
338
|
-
} else {
|
|
339
|
-
|
|
339
|
+
} else if (!devtoolsFlag) {
|
|
340
|
+
devtoolsFlag = true;
|
|
341
|
+
logger.warn("Only support react-devtools and vue-devtools!");
|
|
340
342
|
}
|
|
341
343
|
}
|
|
342
344
|
return html.replace(/<\/title>/i, `</title><script>${devWebviewClient}</script>`);
|
package/dist/index.mjs
CHANGED
|
@@ -263,6 +263,7 @@ function useVSCodePlugin(options) {
|
|
|
263
263
|
}
|
|
264
264
|
let resolvedConfig;
|
|
265
265
|
const prodHtmlCache = {};
|
|
266
|
+
let devtoolsFlag = false;
|
|
266
267
|
return [
|
|
267
268
|
{
|
|
268
269
|
name: "@tomjs:vscode",
|
|
@@ -342,8 +343,9 @@ function useVSCodePlugin(options) {
|
|
|
342
343
|
/<head>/i,
|
|
343
344
|
`<head><script src="http://localhost:${port}"></script>`
|
|
344
345
|
);
|
|
345
|
-
} else {
|
|
346
|
-
|
|
346
|
+
} else if (!devtoolsFlag) {
|
|
347
|
+
devtoolsFlag = true;
|
|
348
|
+
logger.warn("Only support react-devtools and vue-devtools!");
|
|
347
349
|
}
|
|
348
350
|
}
|
|
349
351
|
return html.replace(/<\/title>/i, `</title><script>${devWebviewClient}</script>`);
|
package/dist/webview.d.mts
CHANGED
|
@@ -8,6 +8,6 @@ interface WebviewHtmlDevOptions {
|
|
|
8
8
|
*
|
|
9
9
|
* @param options serverUrl string or object options
|
|
10
10
|
*/
|
|
11
|
-
declare function
|
|
11
|
+
declare function getWebviewHtml(options: string | WebviewHtmlDevOptions): string;
|
|
12
12
|
|
|
13
|
-
export { WebviewHtmlDevOptions,
|
|
13
|
+
export { WebviewHtmlDevOptions, getWebviewHtml as default, getWebviewHtml };
|
package/dist/webview.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ interface WebviewHtmlDevOptions {
|
|
|
8
8
|
*
|
|
9
9
|
* @param options serverUrl string or object options
|
|
10
10
|
*/
|
|
11
|
-
declare function
|
|
11
|
+
declare function getWebviewHtml(options: string | WebviewHtmlDevOptions): string;
|
|
12
12
|
|
|
13
|
-
export { WebviewHtmlDevOptions,
|
|
13
|
+
export { WebviewHtmlDevOptions, getWebviewHtml as default, getWebviewHtml };
|
package/dist/webview.js
CHANGED
|
@@ -102,6 +102,16 @@ var template_default = `<!doctype html>
|
|
|
102
102
|
console.log(TAG + ' received:', e.data);
|
|
103
103
|
if (type === '[vscode:client]:postMessage') {
|
|
104
104
|
getApi().postMessage(data);
|
|
105
|
+
} else if (type === '[vscode:client]:commands') {
|
|
106
|
+
if (data === 'F1') {
|
|
107
|
+
window.dispatchEvent(
|
|
108
|
+
new KeyboardEvent('keydown', {
|
|
109
|
+
key: 'F1',
|
|
110
|
+
keyCode: 112,
|
|
111
|
+
code: 'F1',
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
117
|
}
|
|
@@ -179,7 +189,7 @@ var template_default = `<!doctype html>
|
|
|
179
189
|
`;
|
|
180
190
|
|
|
181
191
|
// src/webview/webview.ts
|
|
182
|
-
function
|
|
192
|
+
function getWebviewHtml(options) {
|
|
183
193
|
const opts = {
|
|
184
194
|
serverUrl: ""
|
|
185
195
|
};
|
|
@@ -190,8 +200,8 @@ function getHtml(options) {
|
|
|
190
200
|
}
|
|
191
201
|
return template_default.replace(new RegExp("{{serverUrl}}", "g"), opts.serverUrl);
|
|
192
202
|
}
|
|
193
|
-
var webview_default =
|
|
203
|
+
var webview_default = getWebviewHtml;
|
|
194
204
|
|
|
195
205
|
|
|
196
206
|
|
|
197
|
-
exports.default = webview_default; exports.
|
|
207
|
+
exports.default = webview_default; exports.getWebviewHtml = getWebviewHtml;
|
package/dist/webview.mjs
CHANGED
|
@@ -102,6 +102,16 @@ var template_default = `<!doctype html>
|
|
|
102
102
|
console.log(TAG + ' received:', e.data);
|
|
103
103
|
if (type === '[vscode:client]:postMessage') {
|
|
104
104
|
getApi().postMessage(data);
|
|
105
|
+
} else if (type === '[vscode:client]:commands') {
|
|
106
|
+
if (data === 'F1') {
|
|
107
|
+
window.dispatchEvent(
|
|
108
|
+
new KeyboardEvent('keydown', {
|
|
109
|
+
key: 'F1',
|
|
110
|
+
keyCode: 112,
|
|
111
|
+
code: 'F1',
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
117
|
}
|
|
@@ -179,7 +189,7 @@ var template_default = `<!doctype html>
|
|
|
179
189
|
`;
|
|
180
190
|
|
|
181
191
|
// src/webview/webview.ts
|
|
182
|
-
function
|
|
192
|
+
function getWebviewHtml(options) {
|
|
183
193
|
const opts = {
|
|
184
194
|
serverUrl: ""
|
|
185
195
|
};
|
|
@@ -190,8 +200,8 @@ function getHtml(options) {
|
|
|
190
200
|
}
|
|
191
201
|
return template_default.replace(new RegExp("{{serverUrl}}", "g"), opts.serverUrl);
|
|
192
202
|
}
|
|
193
|
-
var webview_default =
|
|
203
|
+
var webview_default = getWebviewHtml;
|
|
194
204
|
export {
|
|
195
205
|
webview_default as default,
|
|
196
|
-
|
|
206
|
+
getWebviewHtml
|
|
197
207
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/vite-plugin-vscode",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Use vue/react to develop 'vscode extension webview', supporting esm/cjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"build": "pnpm clean && tsup",
|
|
101
101
|
"clean": "rimraf ./dist",
|
|
102
102
|
"lint": "run-s lint:eslint lint:stylelint lint:prettier",
|
|
103
|
-
"lint:eslint": "eslint \"{src,scripts,examples}/**/*.ts\" *.{
|
|
103
|
+
"lint:eslint": "eslint \"{src,scripts,examples}/**/*.ts\" *.{cjs,ts} --fix --cache",
|
|
104
104
|
"lint:stylelint": "stylelint \"examples/**/*.{css,scss,less,vue,html}\" --fix --cache",
|
|
105
105
|
"lint:prettier": "prettier --write ."
|
|
106
106
|
}
|