@ws-ui/vite-plugins 1.0.1 → 1.0.4
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/esbuild-plugin-import-meta-url/index.js +18 -12
- package/dist/vite-plugin-load-vscode-css/index.d.ts +3 -0
- package/dist/vite-plugin-load-vscode-css/index.js +15 -0
- package/dist/vite-plugin-monaco-editor/index.js +17 -17
- package/dist/vite-plugin-monaco-editor/languageWork.js +1 -1
- package/dist/vite-plugin-monaco-editor/utils.js +1 -1
- package/dist/vite-plugin-monaco-editor/workerMiddleware.js +1 -2
- package/package.json +6 -6
|
@@ -9,19 +9,25 @@ const importMetaUrlPlugin = {
|
|
|
9
9
|
if (/node_modules(\/|\\)(mime-types|mime-db)/.test(args.path)) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
try {
|
|
13
|
+
const code = readFileSync(args.path, 'utf8');
|
|
14
|
+
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g;
|
|
15
|
+
let i = 0;
|
|
16
|
+
let newCode = '';
|
|
17
|
+
for (let match = assetImportMetaUrlRE.exec(code); match != null; match = assetImportMetaUrlRE.exec(code)) {
|
|
18
|
+
newCode += code.slice(i, match.index);
|
|
19
|
+
const path = match[1].slice(1, -1);
|
|
20
|
+
const resolved = resolve(path, pathToFileURL(args.path).toString());
|
|
21
|
+
newCode += `new URL(${JSON.stringify(fileURLToPath(resolved))}, import.meta.url)`;
|
|
22
|
+
i = assetImportMetaUrlRE.lastIndex;
|
|
23
|
+
}
|
|
24
|
+
newCode += code.slice(i);
|
|
25
|
+
return { contents: newCode };
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
// proceed
|
|
29
|
+
return;
|
|
22
30
|
}
|
|
23
|
-
newCode += code.slice(i);
|
|
24
|
-
return { contents: newCode };
|
|
25
31
|
});
|
|
26
32
|
},
|
|
27
33
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const loadVscodeCssPlugin = {
|
|
2
|
+
name: 'load-vscode-css-as-string',
|
|
3
|
+
enforce: 'pre',
|
|
4
|
+
async resolveId(source, importer, options) {
|
|
5
|
+
const resolved = (await this.resolve(source, importer, options));
|
|
6
|
+
if (resolved.id.match(/node_modules\/(@codingame\/monaco-vscode|vscode|monaco-editor).*\.css$/)) {
|
|
7
|
+
return {
|
|
8
|
+
...resolved,
|
|
9
|
+
id: resolved.id + '?inline',
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default loadVscodeCssPlugin;
|
|
@@ -35,23 +35,23 @@ export default function monacoEditorPlugin(options = {}) {
|
|
|
35
35
|
const works = getWorks(options);
|
|
36
36
|
const workerPaths = getWorkPath(works, options, resolvedConfig);
|
|
37
37
|
const globals = {
|
|
38
|
-
MonacoEnvironment: `(function (paths) {
|
|
39
|
-
return {
|
|
40
|
-
globalAPI: ${globalAPI},
|
|
41
|
-
getWorkerUrl : function (moduleId, label) {
|
|
42
|
-
var result = paths[label];
|
|
43
|
-
if (/^((http:)|(https:)|(file:)|(\\/\\/))/.test(result)) {
|
|
44
|
-
var currentUrl = String(window.location);
|
|
45
|
-
var currentOrigin = currentUrl.substr(0, currentUrl.length - window.location.hash.length - window.location.search.length - window.location.pathname.length);
|
|
46
|
-
if (result.substring(0, currentOrigin.length) !== currentOrigin) {
|
|
47
|
-
var js = '/*' + label + '*/importScripts("' + result + '");';
|
|
48
|
-
var blob = new Blob([js], { type: 'application/javascript' });
|
|
49
|
-
return URL.createObjectURL(blob);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
38
|
+
MonacoEnvironment: `(function (paths) {
|
|
39
|
+
return {
|
|
40
|
+
globalAPI: ${globalAPI},
|
|
41
|
+
getWorkerUrl : function (moduleId, label) {
|
|
42
|
+
var result = paths[label];
|
|
43
|
+
if (/^((http:)|(https:)|(file:)|(\\/\\/))/.test(result)) {
|
|
44
|
+
var currentUrl = String(window.location);
|
|
45
|
+
var currentOrigin = currentUrl.substr(0, currentUrl.length - window.location.hash.length - window.location.search.length - window.location.pathname.length);
|
|
46
|
+
if (result.substring(0, currentOrigin.length) !== currentOrigin) {
|
|
47
|
+
var js = '/*' + label + '*/importScripts("' + result + '");';
|
|
48
|
+
var blob = new Blob([js], { type: 'application/javascript' });
|
|
49
|
+
return URL.createObjectURL(blob);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
55
|
})(${JSON.stringify(workerPaths, null, 2)})`,
|
|
56
56
|
};
|
|
57
57
|
const descriptor = [
|
|
@@ -5,7 +5,7 @@ import { languageWorksByLabel } from './languageWork.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export function resolveMonacoPath(filePath) {
|
|
7
7
|
try {
|
|
8
|
-
return path.resolve(
|
|
8
|
+
return path.resolve(process.cwd(), '..', '..', 'node_modules', filePath);
|
|
9
9
|
}
|
|
10
10
|
catch (err) {
|
|
11
11
|
return path.resolve(filePath);
|
|
@@ -15,8 +15,7 @@ export function getWorkPath(works, options, config) {
|
|
|
15
15
|
for (const work of works) {
|
|
16
16
|
const filename = getFilename(work);
|
|
17
17
|
if (options.publicPath && isCDN(options.publicPath)) {
|
|
18
|
-
workerPaths[work.label] =
|
|
19
|
-
options.publicPath + '/' + filename;
|
|
18
|
+
workerPaths[work.label] = options.publicPath + '/' + filename;
|
|
20
19
|
}
|
|
21
20
|
else {
|
|
22
21
|
workerPaths[work.label] =
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ws-ui/vite-plugins",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.0.1",
|
|
3
|
+
"version": "1.0.4",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"main": "./dist/index.js",
|
|
7
6
|
"module": "./dist/index.js",
|
|
@@ -10,14 +9,15 @@
|
|
|
10
9
|
"dist"
|
|
11
10
|
],
|
|
12
11
|
"scripts": {
|
|
13
|
-
"build": "tsc"
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"publish": "npm publish --ignore-scripts --access public"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^20.14.9",
|
|
17
|
-
"typescript": "^5.
|
|
18
|
-
"vite": "^
|
|
17
|
+
"typescript": "^5.8.3",
|
|
18
|
+
"vite": "^6.2.1"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"import-meta-resolve": "^4.
|
|
21
|
+
"import-meta-resolve": "^4.1.0"
|
|
22
22
|
}
|
|
23
23
|
}
|