mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 05:50:11 +01:00
amd progress
This commit is contained in:
parent
f420968fc9
commit
967982e245
20 changed files with 283 additions and 111 deletions
|
|
@ -4,8 +4,8 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import glob from 'glob';
|
import glob from 'glob';
|
||||||
import { runTsc, massageAndCopyDts, buildESM, buildAMD } from './utils';
|
import { runTsc, massageAndCopyDts, buildESM } from './utils';
|
||||||
import { copyFile, removeDir } from './fs';
|
import { removeDir } from './fs';
|
||||||
|
|
||||||
removeDir(`out/languages`);
|
removeDir(`out/languages`);
|
||||||
|
|
||||||
|
|
@ -47,23 +47,24 @@ buildESM({
|
||||||
],
|
],
|
||||||
external: ['monaco-editor-core', '*/cssMode', '*/monaco.contribution']
|
external: ['monaco-editor-core', '*/cssMode', '*/monaco.contribution']
|
||||||
});
|
});
|
||||||
buildAMD({
|
|
||||||
base: 'language/css',
|
// buildAMD({
|
||||||
entryPoint: 'src/language/css/monaco.contribution.ts',
|
// base: 'language/css',
|
||||||
amdModuleId: 'vs/language/css/monaco.contribution',
|
// entryPoint: 'src/language/css/monaco.contribution.ts',
|
||||||
amdDependencies: ['vs/editor/editor.api']
|
// amdModuleId: 'vs/language/css/monaco.contribution',
|
||||||
});
|
// amdDependencies: ['vs/editor/editor.api']
|
||||||
buildAMD({
|
// });
|
||||||
base: 'language/css',
|
// buildAMD({
|
||||||
entryPoint: 'src/language/css/cssMode.ts',
|
// base: 'language/css',
|
||||||
amdModuleId: 'vs/language/css/cssMode',
|
// entryPoint: 'src/language/css/cssMode.ts',
|
||||||
external: ['*/monaco.contribution']
|
// amdModuleId: 'vs/language/css/cssMode',
|
||||||
});
|
// external: ['*/monaco.contribution']
|
||||||
buildAMD({
|
// });
|
||||||
base: 'language/css',
|
// buildAMD({
|
||||||
entryPoint: 'src/language/css/cssWorker.ts',
|
// base: 'language/css',
|
||||||
amdModuleId: 'vs/language/css/cssWorker'
|
// entryPoint: 'src/language/css/cssWorker.ts',
|
||||||
});
|
// amdModuleId: 'vs/language/css/cssWorker'
|
||||||
|
// });
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
@ -78,23 +79,23 @@ buildESM({
|
||||||
],
|
],
|
||||||
external: ['monaco-editor-core', '*/htmlMode', '*/monaco.contribution']
|
external: ['monaco-editor-core', '*/htmlMode', '*/monaco.contribution']
|
||||||
});
|
});
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/html',
|
// base: 'language/html',
|
||||||
entryPoint: 'src/language/html/monaco.contribution.ts',
|
// entryPoint: 'src/language/html/monaco.contribution.ts',
|
||||||
amdModuleId: 'vs/language/html/monaco.contribution',
|
// amdModuleId: 'vs/language/html/monaco.contribution',
|
||||||
amdDependencies: ['vs/editor/editor.api']
|
// amdDependencies: ['vs/editor/editor.api']
|
||||||
});
|
// });
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/html',
|
// base: 'language/html',
|
||||||
entryPoint: 'src/language/html/htmlMode.ts',
|
// entryPoint: 'src/language/html/htmlMode.ts',
|
||||||
amdModuleId: 'vs/language/html/htmlMode',
|
// amdModuleId: 'vs/language/html/htmlMode',
|
||||||
external: ['*/monaco.contribution']
|
// external: ['*/monaco.contribution']
|
||||||
});
|
// });
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/html',
|
// base: 'language/html',
|
||||||
entryPoint: 'src/language/html/htmlWorker.ts',
|
// entryPoint: 'src/language/html/htmlWorker.ts',
|
||||||
amdModuleId: 'vs/language/html/htmlWorker'
|
// amdModuleId: 'vs/language/html/htmlWorker'
|
||||||
});
|
// });
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
@ -109,23 +110,23 @@ buildESM({
|
||||||
],
|
],
|
||||||
external: ['monaco-editor-core', '*/jsonMode', '*/monaco.contribution']
|
external: ['monaco-editor-core', '*/jsonMode', '*/monaco.contribution']
|
||||||
});
|
});
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/json',
|
// base: 'language/json',
|
||||||
entryPoint: 'src/language/json/monaco.contribution.ts',
|
// entryPoint: 'src/language/json/monaco.contribution.ts',
|
||||||
amdModuleId: 'vs/language/json/monaco.contribution',
|
// amdModuleId: 'vs/language/json/monaco.contribution',
|
||||||
amdDependencies: ['vs/editor/editor.api']
|
// amdDependencies: ['vs/editor/editor.api']
|
||||||
});
|
// });
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/json',
|
// base: 'language/json',
|
||||||
entryPoint: 'src/language/json/jsonMode.ts',
|
// entryPoint: 'src/language/json/jsonMode.ts',
|
||||||
amdModuleId: 'vs/language/json/jsonMode',
|
// amdModuleId: 'vs/language/json/jsonMode',
|
||||||
external: ['*/monaco.contribution']
|
// external: ['*/monaco.contribution']
|
||||||
});
|
// });
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/json',
|
// base: 'language/json',
|
||||||
entryPoint: 'src/language/json/jsonWorker.ts',
|
// entryPoint: 'src/language/json/jsonWorker.ts',
|
||||||
amdModuleId: 'vs/language/json/jsonWorker'
|
// amdModuleId: 'vs/language/json/jsonWorker'
|
||||||
});
|
// });
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
@ -140,23 +141,23 @@ buildESM({
|
||||||
],
|
],
|
||||||
external: ['monaco-editor-core', '*/tsMode', '*/monaco.contribution']
|
external: ['monaco-editor-core', '*/tsMode', '*/monaco.contribution']
|
||||||
});
|
});
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/typescript',
|
// base: 'language/typescript',
|
||||||
entryPoint: 'src/language/typescript/monaco.contribution.ts',
|
// entryPoint: 'src/language/typescript/monaco.contribution.ts',
|
||||||
amdModuleId: 'vs/language/typescript/monaco.contribution',
|
// amdModuleId: 'vs/language/typescript/monaco.contribution',
|
||||||
amdDependencies: ['vs/editor/editor.api']
|
// amdDependencies: ['vs/editor/editor.api']
|
||||||
});
|
// });
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/typescript',
|
// base: 'language/typescript',
|
||||||
entryPoint: 'src/language/typescript/tsMode.ts',
|
// entryPoint: 'src/language/typescript/tsMode.ts',
|
||||||
amdModuleId: 'vs/language/typescript/tsMode',
|
// amdModuleId: 'vs/language/typescript/tsMode',
|
||||||
external: ['*/monaco.contribution']
|
// external: ['*/monaco.contribution']
|
||||||
});
|
// });
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'language/typescript',
|
// base: 'language/typescript',
|
||||||
entryPoint: 'src/language/typescript/tsWorker.ts',
|
// entryPoint: 'src/language/typescript/tsWorker.ts',
|
||||||
amdModuleId: 'vs/language/typescript/tsWorker'
|
// amdModuleId: 'vs/language/typescript/tsWorker'
|
||||||
});
|
// });
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
@ -192,21 +193,21 @@ glob('../src/basic-languages/*/*.contribution.ts', { cwd: __dirname }, function
|
||||||
}
|
}
|
||||||
|
|
||||||
// AMD
|
// AMD
|
||||||
{
|
// {
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'basic-languages',
|
// base: 'basic-languages',
|
||||||
entryPoint: 'src/basic-languages/monaco.contribution.ts',
|
// entryPoint: 'src/basic-languages/monaco.contribution.ts',
|
||||||
amdModuleId: 'vs/basic-languages/monaco.contribution',
|
// amdModuleId: 'vs/basic-languages/monaco.contribution',
|
||||||
amdDependencies: ['vs/editor/editor.api']
|
// amdDependencies: ['vs/editor/editor.api']
|
||||||
});
|
// });
|
||||||
for (const language of languages) {
|
// for (const language of languages) {
|
||||||
buildAMD({
|
// buildAMD({
|
||||||
base: 'basic-languages',
|
// base: 'basic-languages',
|
||||||
entryPoint: `src/basic-languages/${language}/${language}.ts`,
|
// entryPoint: `src/basic-languages/${language}/${language}.ts`,
|
||||||
amdModuleId: `vs/basic-languages/${language}/${language}`
|
// amdModuleId: `vs/basic-languages/${language}/${language}`
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ import path = require('path');
|
||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import { REPO_ROOT, readFiles, writeFiles, IFile, readFile } from '../build/utils';
|
import { REPO_ROOT, readFiles, writeFiles, IFile, readFile } from '../build/utils';
|
||||||
import { removeDir } from '../build/fs';
|
import { removeDir } from '../build/fs';
|
||||||
import ts = require('typescript');
|
|
||||||
import { generateMetadata } from './releaseMetadata';
|
import { generateMetadata } from './releaseMetadata';
|
||||||
|
import ts = require('typescript');
|
||||||
|
|
||||||
removeDir(`out/monaco-editor`);
|
removeDir(`out/monaco-editor`);
|
||||||
|
|
||||||
// dev folder
|
// // dev folder
|
||||||
AMD_releaseOne('dev');
|
// AMD_releaseOne('dev');
|
||||||
|
|
||||||
// min folder
|
// // min folder
|
||||||
AMD_releaseOne('min');
|
// AMD_releaseOne('min');
|
||||||
|
|
||||||
// esm folder
|
// esm folder
|
||||||
ESM_release();
|
ESM_release();
|
||||||
|
|
|
||||||
13
package-lock.json
generated
13
package-lock.json
generated
|
|
@ -9,6 +9,9 @@
|
||||||
"version": "0.52.0",
|
"version": "0.52.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/trusted-types": "^1.0.6"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/mocha": "^9.1.0",
|
"@types/mocha": "^9.1.0",
|
||||||
"@types/shelljs": "^0.8.11",
|
"@types/shelljs": "^0.8.11",
|
||||||
|
|
@ -2308,6 +2311,11 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/trusted-types": {
|
||||||
|
"version": "1.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-1.0.6.tgz",
|
||||||
|
"integrity": "sha512-230RC8sFeHoT6sSUlRO6a8cAnclO06eeiq1QDfiv2FGCLWFvvERWgwIQD4FWqD9A69BN7Lzee4OXwoMVnnsWDw=="
|
||||||
|
},
|
||||||
"node_modules/@typescript/vfs": {
|
"node_modules/@typescript/vfs": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz",
|
||||||
|
|
@ -9011,6 +9019,11 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/trusted-types": {
|
||||||
|
"version": "1.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-1.0.6.tgz",
|
||||||
|
"integrity": "sha512-230RC8sFeHoT6sSUlRO6a8cAnclO06eeiq1QDfiv2FGCLWFvvERWgwIQD4FWqD9A69BN7Lzee4OXwoMVnnsWDw=="
|
||||||
|
},
|
||||||
"@typescript/vfs": {
|
"@typescript/vfs": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.3.5.tgz",
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,8 @@
|
||||||
"alias": {
|
"alias": {
|
||||||
"process": false,
|
"process": false,
|
||||||
"buffer": false
|
"buffer": false
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/trusted-types": "^1.0.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@
|
||||||
// Resolves with the global monaco API
|
// Resolves with the global monaco API
|
||||||
|
|
||||||
/// <reference path="./editor.api.d.ts" />
|
/// <reference path="./editor.api.d.ts" />
|
||||||
import * as api from 'vs/editor/editor.api';
|
|
||||||
|
|
||||||
export = api;
|
// export = api;
|
||||||
|
export * from 'monaco-editor-core';
|
||||||
|
|
|
||||||
7
src/language/common/initialize.ts
Normal file
7
src/language/common/initialize.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import * as worker from 'monaco-editor-core/esm/vs/editor/editor.worker.start';
|
||||||
|
|
||||||
|
export function initialize(callback: (ctx: any, createData: any) => any): void {
|
||||||
|
self.onmessage = (m) => {
|
||||||
|
worker.start((ctx) => callback(ctx, m.data));
|
||||||
|
};
|
||||||
|
}
|
||||||
134
src/language/common/workers.ts
Normal file
134
src/language/common/workers.ts
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
import { editor } from '../../fillers/monaco-editor-core';
|
||||||
|
|
||||||
|
export function createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||||
|
policyName: string,
|
||||||
|
policyOptions?: Options
|
||||||
|
):
|
||||||
|
| undefined
|
||||||
|
| Pick<
|
||||||
|
TrustedTypePolicy<Options>,
|
||||||
|
'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>
|
||||||
|
> {
|
||||||
|
interface IMonacoEnvironment {
|
||||||
|
createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||||
|
policyName: string,
|
||||||
|
policyOptions?: Options
|
||||||
|
):
|
||||||
|
| undefined
|
||||||
|
| Pick<
|
||||||
|
TrustedTypePolicy<Options>,
|
||||||
|
'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>
|
||||||
|
>;
|
||||||
|
}
|
||||||
|
const monacoEnvironment: IMonacoEnvironment | undefined = (globalThis as any).MonacoEnvironment;
|
||||||
|
|
||||||
|
if (monacoEnvironment?.createTrustedTypesPolicy) {
|
||||||
|
try {
|
||||||
|
return monacoEnvironment.createTrustedTypesPolicy(policyName, policyOptions);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return (globalThis as any).trustedTypes?.createPolicy(policyName, policyOptions);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let ttPolicy: ReturnType<typeof createTrustedTypesPolicy>;
|
||||||
|
if (
|
||||||
|
typeof self === 'object' &&
|
||||||
|
self.constructor &&
|
||||||
|
self.constructor.name === 'DedicatedWorkerGlobalScope' &&
|
||||||
|
(globalThis as any).workerttPolicy !== undefined
|
||||||
|
) {
|
||||||
|
ttPolicy = (globalThis as any).workerttPolicy;
|
||||||
|
} else {
|
||||||
|
ttPolicy = createTrustedTypesPolicy('defaultWorkerFactory', {
|
||||||
|
createScriptURL: (value) => value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getWorker(descriptor: {
|
||||||
|
label: string;
|
||||||
|
moduleId: string;
|
||||||
|
}): Worker | Promise<Worker> {
|
||||||
|
const label = descriptor.label;
|
||||||
|
// Option for hosts to overwrite the worker script (used in the standalone editor)
|
||||||
|
interface IMonacoEnvironment {
|
||||||
|
getWorker?(moduleId: string, label: string): Worker | Promise<Worker>;
|
||||||
|
getWorkerUrl?(moduleId: string, label: string): string;
|
||||||
|
}
|
||||||
|
const monacoEnvironment: IMonacoEnvironment | undefined = (globalThis as any).MonacoEnvironment;
|
||||||
|
if (monacoEnvironment) {
|
||||||
|
if (typeof monacoEnvironment.getWorker === 'function') {
|
||||||
|
return monacoEnvironment.getWorker('workerMain.js', label);
|
||||||
|
}
|
||||||
|
if (typeof monacoEnvironment.getWorkerUrl === 'function') {
|
||||||
|
const workerUrl = monacoEnvironment.getWorkerUrl('workerMain.js', label);
|
||||||
|
return new Worker(
|
||||||
|
ttPolicy ? (ttPolicy.createScriptURL(workerUrl) as unknown as string) : workerUrl,
|
||||||
|
{ name: label, type: 'module' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// const esmWorkerLocation = descriptor.esmModuleLocation;
|
||||||
|
// if (esmWorkerLocation) {
|
||||||
|
// const workerUrl = getWorkerBootstrapUrl(label, esmWorkerLocation.toString(true));
|
||||||
|
// const worker = new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label, type: 'module' });
|
||||||
|
// return whenESMWorkerReady(worker);
|
||||||
|
// }
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
`You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createWebWorker<T extends object>(
|
||||||
|
opts: IWebWorkerOptions
|
||||||
|
): editor.MonacoWebWorker<T> {
|
||||||
|
const worker = Promise.resolve(
|
||||||
|
getWorker({
|
||||||
|
label: opts.label ?? 'monaco-editor-worker',
|
||||||
|
moduleId: opts.moduleId
|
||||||
|
})
|
||||||
|
).then((w) => {
|
||||||
|
w.postMessage('ignore');
|
||||||
|
w.postMessage(opts.createData);
|
||||||
|
return w;
|
||||||
|
});
|
||||||
|
return editor.createWebWorker<T>({
|
||||||
|
worker,
|
||||||
|
host: opts.host,
|
||||||
|
keepIdleModels: opts.keepIdleModels
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IWebWorkerOptions {
|
||||||
|
/**
|
||||||
|
* The AMD moduleId to load.
|
||||||
|
* It should export a function `create` that should return the exported proxy.
|
||||||
|
*/
|
||||||
|
moduleId: string;
|
||||||
|
/**
|
||||||
|
* The data to send over when calling create on the module.
|
||||||
|
*/
|
||||||
|
createData?: any;
|
||||||
|
/**
|
||||||
|
* A label to be used to identify the web worker for debugging purposes.
|
||||||
|
*/
|
||||||
|
label?: string;
|
||||||
|
/**
|
||||||
|
* An object that can be used by the web worker to make calls back to the main thread.
|
||||||
|
*/
|
||||||
|
host?: any;
|
||||||
|
/**
|
||||||
|
* Keep idle models.
|
||||||
|
* Defaults to false, which means that idle models will stop syncing after a while.
|
||||||
|
*/
|
||||||
|
keepIdleModels?: boolean;
|
||||||
|
}
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as worker from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
import { initialize } from '../common/initialize';
|
||||||
import { CSSWorker } from './cssWorker';
|
import { CSSWorker } from './cssWorker';
|
||||||
|
|
||||||
self.onmessage = () => {
|
self.onmessage = () => {
|
||||||
// ignore the first message
|
// ignore the first message
|
||||||
worker.initialize((ctx, createData) => {
|
initialize((ctx, createData) => {
|
||||||
return new CSSWorker(ctx, createData);
|
return new CSSWorker(ctx, createData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||||
import type { CSSWorker } from './cssWorker';
|
import type { CSSWorker } from './cssWorker';
|
||||||
import { editor, IDisposable, Uri } from '../../fillers/monaco-editor-core';
|
import { editor, IDisposable, Uri } from '../../fillers/monaco-editor-core';
|
||||||
|
import { createWebWorker } from '../common/workers';
|
||||||
|
|
||||||
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ export class WorkerManager {
|
||||||
this._lastUsedTime = Date.now();
|
this._lastUsedTime = Date.now();
|
||||||
|
|
||||||
if (!this._client) {
|
if (!this._client) {
|
||||||
this._worker = editor.createWebWorker<CSSWorker>({
|
this._worker = createWebWorker<CSSWorker>({
|
||||||
// module that exports the create() method and returns a `CSSWorker` instance
|
// module that exports the create() method and returns a `CSSWorker` instance
|
||||||
moduleId: 'vs/language/css/cssWorker',
|
moduleId: 'vs/language/css/cssWorker',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as worker from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
import * as worker from '../common/initialize';
|
||||||
import { HTMLWorker } from './htmlWorker';
|
import { HTMLWorker } from './htmlWorker';
|
||||||
|
|
||||||
self.onmessage = () => {
|
self.onmessage = () => {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||||
import type { HTMLWorker } from './htmlWorker';
|
import type { HTMLWorker } from './htmlWorker';
|
||||||
import { Uri, IDisposable, editor } from '../../fillers/monaco-editor-core';
|
import { Uri, IDisposable, editor } from '../../fillers/monaco-editor-core';
|
||||||
|
import { createWebWorker } from '../common/workers';
|
||||||
|
|
||||||
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ export class WorkerManager {
|
||||||
this._lastUsedTime = Date.now();
|
this._lastUsedTime = Date.now();
|
||||||
|
|
||||||
if (!this._client) {
|
if (!this._client) {
|
||||||
this._worker = editor.createWebWorker<HTMLWorker>({
|
this._worker = createWebWorker<HTMLWorker>({
|
||||||
// module that exports the create() method and returns a `HTMLWorker` instance
|
// module that exports the create() method and returns a `HTMLWorker` instance
|
||||||
moduleId: 'vs/language/html/htmlWorker',
|
moduleId: 'vs/language/html/htmlWorker',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as worker from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
import * as worker from '../common/initialize';
|
||||||
import { JSONWorker } from './jsonWorker';
|
import { JSONWorker } from './jsonWorker';
|
||||||
|
|
||||||
self.onmessage = () => {
|
self.onmessage = () => {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||||
import type { JSONWorker } from './jsonWorker';
|
import type { JSONWorker } from './jsonWorker';
|
||||||
import { IDisposable, Uri, editor } from '../../fillers/monaco-editor-core';
|
import { IDisposable, Uri, editor } from '../../fillers/monaco-editor-core';
|
||||||
|
import { createWebWorker } from '../common/workers';
|
||||||
|
|
||||||
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ export class WorkerManager {
|
||||||
this._lastUsedTime = Date.now();
|
this._lastUsedTime = Date.now();
|
||||||
|
|
||||||
if (!this._client) {
|
if (!this._client) {
|
||||||
this._worker = editor.createWebWorker<JSONWorker>({
|
this._worker = createWebWorker<JSONWorker>({
|
||||||
// module that exports the create() method and returns a `JSONWorker` instance
|
// module that exports the create() method and returns a `JSONWorker` instance
|
||||||
moduleId: 'vs/language/json/jsonWorker',
|
moduleId: 'vs/language/json/jsonWorker',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
declare module 'monaco-editor-core/esm/vs/editor/editor.worker' {
|
declare module 'monaco-editor-core/esm/vs/editor/editor.worker.start' {
|
||||||
export function initialize(callback: (ctx: any, createData: any) => any): void;
|
import type { worker } from 'monaco-editor-core';
|
||||||
}
|
|
||||||
|
export function start<THost extends object, TClient extends object>(createClient: (ctx: worker.IWorkerContext<THost>) => TClient): TClient;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { initialize } from 'monaco-editor-core/esm/vs/editor/editor.worker';
|
import { initialize } from '../common/initialize';
|
||||||
import * as ts from './lib/typescriptServices';
|
import * as ts from './lib/typescriptServices';
|
||||||
import { ICreateData, TypeScriptWorker, create } from './tsWorker';
|
import { ICreateData, TypeScriptWorker, create } from './tsWorker';
|
||||||
import { worker } from '../../fillers/monaco-editor-core';
|
import { worker } from '../../fillers/monaco-editor-core';
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||||
import type { TypeScriptWorker } from './tsWorker';
|
import type { TypeScriptWorker } from './tsWorker';
|
||||||
import { editor, Uri, IDisposable } from '../../fillers/monaco-editor-core';
|
import { editor, Uri, IDisposable } from '../../fillers/monaco-editor-core';
|
||||||
|
import { createWebWorker } from '../common/workers';
|
||||||
|
|
||||||
export class WorkerManager {
|
export class WorkerManager {
|
||||||
private _configChangeListener: IDisposable;
|
private _configChangeListener: IDisposable;
|
||||||
|
|
@ -58,7 +59,7 @@ export class WorkerManager {
|
||||||
private _getClient(): Promise<TypeScriptWorker> {
|
private _getClient(): Promise<TypeScriptWorker> {
|
||||||
if (!this._client) {
|
if (!this._client) {
|
||||||
this._client = (async () => {
|
this._client = (async () => {
|
||||||
this._worker = editor.createWebWorker<TypeScriptWorker>({
|
this._worker = createWebWorker<TypeScriptWorker>({
|
||||||
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
// module that exports the create() method and returns a `TypeScriptWorker` instance
|
||||||
moduleId: 'vs/language/typescript/tsWorker',
|
moduleId: 'vs/language/typescript/tsWorker',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"],
|
"lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"],
|
||||||
"module": "amd",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"outDir": "../out/languages/amd-tsc",
|
"outDir": "../out/languages/amd-tsc",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,14 @@ self.MonacoEnvironment = {
|
||||||
if (label === 'typescript' || label === 'javascript') {
|
if (label === 'typescript' || label === 'javascript') {
|
||||||
return './out/vs/language/typescript/ts.worker.js';
|
return './out/vs/language/typescript/ts.worker.js';
|
||||||
}
|
}
|
||||||
return './out/vs/editor/editor.worker.js';
|
//return './out/vs/editor/editor.worker.js';
|
||||||
|
return './out/vs/editor/common/services/editorWebWorkerMain.js';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.monacoAPI = monaco;
|
window.monacoAPI = monaco;
|
||||||
|
|
||||||
|
window.ed = monacoAPI.editor.create(document.getElementById('editor-container'), {
|
||||||
|
value: '.test { color: blue; }',
|
||||||
|
language: 'javascript'
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ const workerEntryPoints = [
|
||||||
'vs/language/css/css.worker.js',
|
'vs/language/css/css.worker.js',
|
||||||
'vs/language/html/html.worker.js',
|
'vs/language/html/html.worker.js',
|
||||||
'vs/language/typescript/ts.worker.js',
|
'vs/language/typescript/ts.worker.js',
|
||||||
'vs/editor/editor.worker.js'
|
//'vs/editor/editor.worker.js'
|
||||||
|
'vs/editor/common/services/editorWebWorkerMain.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
build({
|
build({
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,14 @@ async function runTests() {
|
||||||
// uncomment to shortcircuit and run a specific combo
|
// uncomment to shortcircuit and run a specific combo
|
||||||
// await runTest('webpack', 'chromium'); return;
|
// await runTest('webpack', 'chromium'); return;
|
||||||
/** @type {PackagerKind[]} */
|
/** @type {PackagerKind[]} */
|
||||||
const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
|
//const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
|
||||||
|
const testTypes = ['esbuild'];
|
||||||
// TODO: add parcel! (this currently fails because parcel replaces process with {})
|
// TODO: add parcel! (this currently fails because parcel replaces process with {})
|
||||||
|
|
||||||
for (const type of testTypes) {
|
for (const type of testTypes) {
|
||||||
await runTest(type, 'chromium');
|
await runTest(type, 'chromium');
|
||||||
await runTest(type, 'firefox');
|
// await runTest(type, 'firefox');
|
||||||
await runTest(type, 'webkit');
|
// await runTest(type, 'webkit');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ function runTest(packager, browser) {
|
||||||
path.join(REPO_ROOT, 'node_modules/mocha/bin/mocha'),
|
path.join(REPO_ROOT, 'node_modules/mocha/bin/mocha'),
|
||||||
'test/smoke/*.test.js',
|
'test/smoke/*.test.js',
|
||||||
'--no-delay',
|
'--no-delay',
|
||||||
'--headless',
|
//'--headless',
|
||||||
'--timeout',
|
'--timeout',
|
||||||
'20000'
|
'20000'
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue