class DefineCall {
constructor(
public readonly dependencies: string[] | null | undefined,
public readonly callback: any
) { }
}
Frontier kind: Code frontier
unlabeled · c_37f2b56b8c08
60 tests · 6264 LOC · 31 files · introduces 0 tests · 90 LOC · 1 file
The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.
Introduced files, introduced tests, and structurally relevant concept specialization
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.
Every exact file and test below is linked only from the concept that introduces it.
mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel emoji input|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel wide input (Korean)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text With wrapping Fish ghost text in long line with wrapped content|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text With wrapping Pwsh ghost text in long line with wrapped content|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel cursor navigation|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel trailing whitespace whitespace preservation in cursor calculation|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text trailing whitespace|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel trailing whitespace cursor index calculation with whitespace|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text no ghost text when background color matches earlier text|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text no ghost text when earlier text has the same bold style|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text no ghost text when earlier text has the same strikethrough style|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text no ghost text when earlier text has the same underline style|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text no ghost text when foreground color matches earlier text|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel trailing whitespace cursor index should not exceed command line length|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text basic ghost text|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text ghost text with cursor navigation|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text basic ghost text one word|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test|title=PromptInputModel ghost text ghost text detected when italic style is unique at the end|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/textfile/test/node/encoding/encoding.test|title=Encoding autoGuessEncoding (CP1252)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/textfile/test/node/encoding/encoding.test|title=Encoding autoGuessEncoding (ShiftJIS)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/textfile/test/node/encoding/encoding.test|title=Encoding autoGuessEncoding (UTF8)|occurrence=1Every collected test enters the hierarchy at exactly one concept.
No tests are introduced at this concept. Its intent tests are introduced by other concepts.
Every collected source range enters the hierarchy at exactly one concept.
1 file ranked by introduced lines: 90 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.
class DefineCall {
constructor(
public readonly dependencies: string[] | null | undefined,
public readonly callback: any
) { }
}
private _initialize(): void {
if (globalThis.define) {
this._state = AMDModuleImporterState.InitializedExternal;
return;
}
return;
}
this._state = AMDModuleImporterState.InitializedInternal;
globalThis.define = (id: any, dependencies: any, callback: any) => {
if (typeof id !== 'string') {
callback = dependencies;
dependencies = id;
id = null;
}
if (typeof dependencies !== 'object' || !Array.isArray(dependencies)) {
callback = dependencies;
dependencies = null;
}
// dependencies = ['require', 'exports', 'module'];
// }
this._defineCalls.push(new DefineCall(id, dependencies, callback));
};
globalThis.define.amd = true;
if (this._isRenderer) {
this._amdPolicy = globalThis._VSCODE_WEB_PACKAGE_TTP ?? window.trustedTypes?.createPolicy('amdLoader', {
createScriptURL(value: any) {
}
});
this._amdPolicy = globalThis._VSCODE_WEB_PACKAGE_TTP ?? globalThis.trustedTypes?.createPolicy('amdLoader', {
createScriptURL(value: string) {
});
}
const defineCall = await (this._isWebWorker ? this._workerLoadScript(scriptSrc) : this._isRenderer ? this._rendererLoadScript(scriptSrc) : this._nodeJSLoadScript(scriptSrc));
if (!defineCall) {
console.warn(`Did not receive a define call from script ${scriptSrc}`);
return <T>undefined;
}
const exports = {};
const dependencyObjs: any[] = [];
const dependencyModules: string[] = [];
if (Array.isArray(defineCall.dependencies)) {
for (const mod of defineCall.dependencies) {
if (mod === 'exports') {
dependencyObjs.push(exports);
}
}
if (dependencyModules.length > 0) {
throw new Error(`Cannot resolve dependencies for script ${scriptSrc}. The dependencies are: ${dependencyModules.join(', ')}`);
}
return defineCall.callback(...dependencyObjs) ?? exports;
} else {
return defineCall.callback;
}
private _rendererLoadScript(scriptSrc: string): Promise<DefineCall | undefined> {
private async _nodeJSLoadScript(scriptSrc: string): Promise<DefineCall | undefined> {
// `import('module')` is not remapped (only `fs` is), so it yields the real
// `module` builtin. We use its `createRequire` to obtain `fs`/`vm`: the ESM
// resolution hook maps `import('fs')` to the ASAR-unaware `original-fs`, but
// `scriptSrc` may point inside the `node_modules.asar` archive. The `fs`
// returned by `require` stays ASAR-aware in Electron, so it can read module
// files from within the archive.
const module = (await import(/* webpackIgnore: true */ /* @vite-ignore */ `${'module'}`)).default;
const nodeRequire = module.createRequire(import.meta.url);
const fs = nodeRequire('fs');
const vm = nodeRequire('vm');
const filePath = URI.parse(scriptSrc).fsPath;
const content = fs.readFileSync(filePath).toString();
const scriptSource = module.wrap(content.replace(/^#!.*/, ''));
const script = new vm.Script(scriptSource);
const compileWrapper = script.runInThisContext();
compileWrapper.apply();
return this._defineCalls.pop();
} catch (error) {
throw error;
}
}
* e.g. pass in `vscode-textmate/release/main.js`
*/
export async function importAMDNodeModule<T>(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean): Promise<T> {
amdX.ts
if (isBuilt === undefined) {
const product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration;
isBuilt = Boolean((product ?? globalThis.vscode?.context?.configuration()?.product)?.commit);
}
const nodeModulePath = pathInsideNodeModule ? `${nodeModuleName}/${pathInsideNodeModule}` : nodeModuleName;
if (cache.has(nodeModulePath)) {
return cache.get(nodeModulePath)!;
}
if (/^\w[\w\d+.-]*:\/\//.test(nodeModulePath)) {
// looks like a URL
// bit of a special case for: src/vs/workbench/services/languageDetection/browser/languageDetectionWebWorker.ts
scriptSrc = nodeModulePath;
const useASAR = (isBuilt && (platform.isElectron || (platform.isWebWorker && platform.hasElectronUserAgent)));
const actualNodeModulesPath = (useASAR ? nodeModulesAsarPath : nodeModulesPath);
const resourcePath: AppResourcePath = `${actualNodeModulesPath}/${nodeModulePath}`;
scriptSrc = FileAccess.asBrowserUri(resourcePath).toString(true);
}
const result = AMDModuleImporter.INSTANCE.load<T>(scriptSrc);
cache.set(nodeModulePath, result);
return result;
}
export function resolveAmdNodeModulePath(nodeModuleName: string, pathInsideNodeModule: string): string {