|
@@ -1,37 +1,58 @@
|
|
|
-import * as require_ from 'require';
|
|
|
+import * as require from 'require';
|
|
|
|
|
|
self.MonacoEnvironment = {
|
|
|
getWorker: function (_moduleId, label) {
|
|
|
- const require = require_;
|
|
|
- if (!require) {
|
|
|
- label = label; // NOOP
|
|
|
- }
|
|
|
if (label === 'json') {
|
|
|
- return new Worker(new URL('../../../src/language/json/json.worker.ts', import.meta.url), {
|
|
|
- type: 'module'
|
|
|
- });
|
|
|
+ return new Worker(
|
|
|
+ getWorkerBootstrapUrl(
|
|
|
+ new URL('../../../src/language/json/json.worker.ts?worker', import.meta.url)
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
if (label === 'css' || label === 'scss' || label === 'less') {
|
|
|
- return new Worker(new URL('../../../src/language/css/css.worker.ts', import.meta.url), {
|
|
|
- type: 'module'
|
|
|
- });
|
|
|
+ return new Worker(
|
|
|
+ getWorkerBootstrapUrl(
|
|
|
+ new URL('../../../src/language/css/css.worker.ts?worker', import.meta.url)
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
|
|
- return new Worker(new URL('../../../src/language/html/html.worker.ts', import.meta.url), {
|
|
|
- type: 'module'
|
|
|
- });
|
|
|
+ return new Worker(
|
|
|
+ getWorkerBootstrapUrl(
|
|
|
+ new URL('../../../src/language/html/html.worker.ts?worker', import.meta.url)
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
if (label === 'typescript' || label === 'javascript') {
|
|
|
- return new Worker(new URL('../../../src/language/typescript/ts.worker.ts', import.meta.url), {
|
|
|
- type: 'module'
|
|
|
- });
|
|
|
+ return new Worker(
|
|
|
+ getWorkerBootstrapUrl(
|
|
|
+ new URL('../../../src/language/typescript/ts.worker.ts?worker', import.meta.url)
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
- return new Worker(new URL('../../../src/editor/editor.worker.ts', import.meta.url), {
|
|
|
- type: 'module'
|
|
|
- });
|
|
|
+ return new Worker(
|
|
|
+ getWorkerBootstrapUrl(new URL('../../../src/editor/editor.worker.ts?worker', import.meta.url))
|
|
|
+ );
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+function getWorkerBootstrapUrl(workerScriptUrl) {
|
|
|
+ const blob = new Blob(
|
|
|
+ [
|
|
|
+ [
|
|
|
+ `const ttPolicy = globalThis.trustedTypes?.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });`,
|
|
|
+ `globalThis.workerttPolicy = ttPolicy;`,
|
|
|
+ `importScripts(ttPolicy?.createScriptURL(${JSON.stringify(
|
|
|
+ workerScriptUrl
|
|
|
+ )}) ?? ${JSON.stringify(workerScriptUrl)});`,
|
|
|
+ `globalThis.postMessage({ type: 'vscode-worker-ready' });`
|
|
|
+ ].join('')
|
|
|
+ ],
|
|
|
+ { type: 'application/javascript' }
|
|
|
+ );
|
|
|
+ return URL.createObjectURL(blob);
|
|
|
+}
|
|
|
+
|
|
|
import 'vs/nls.messages-loader!';
|
|
|
import '../../../src/basic-languages/monaco.contribution';
|
|
|
import '../../../src/language/css/monaco.contribution';
|
|
@@ -39,7 +60,7 @@ import '../../../src/language/html/monaco.contribution';
|
|
|
import '../../../src/language/json/monaco.contribution';
|
|
|
import '../../../src/language/typescript/monaco.contribution';
|
|
|
|
|
|
-const styleSheetUrl = require_.toUrl('vs/style.css');
|
|
|
+const styleSheetUrl = require.toUrl('vs/style.css');
|
|
|
|
|
|
const link = document.createElement('link');
|
|
|
link.rel = 'stylesheet';
|