@codingame/monaco-vscode-9a934394-0cf8-512d-939b-77e71f69cebb-common 20.0.0 → 20.1.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/package.json +2 -2
- package/vscode/src/vs/amdX.d.ts +0 -3
- package/vscode/src/vs/amdX.js +0 -196
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@codingame/monaco-vscode-9a934394-0cf8-512d-939b-77e71f69cebb-common",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.1.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - common package (chat, interactive, notebook, search, textmate, theme, treesitter)",
|
6
6
|
"keywords": [],
|
@@ -15,7 +15,7 @@
|
|
15
15
|
},
|
16
16
|
"type": "module",
|
17
17
|
"dependencies": {
|
18
|
-
"@codingame/monaco-vscode-api": "20.
|
18
|
+
"@codingame/monaco-vscode-api": "20.1.0"
|
19
19
|
},
|
20
20
|
"exports": {
|
21
21
|
".": {
|
package/vscode/src/vs/amdX.d.ts
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
export declare const canASAR = false;
|
2
|
-
export declare function importAMDNodeModule<T>(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean): Promise<T>;
|
3
|
-
export declare function resolveAmdNodeModulePath(nodeModuleName: string, pathInsideNodeModule: string): string;
|
package/vscode/src/vs/amdX.js
DELETED
@@ -1,196 +0,0 @@
|
|
1
|
-
|
2
|
-
import { Schemas, VSCODE_AUTHORITY, nodeModulesPath, FileAccess } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
3
|
-
import '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
4
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
5
|
-
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
6
|
-
|
7
|
-
class DefineCall {
|
8
|
-
constructor(id, dependencies, callback) {
|
9
|
-
this.id = id;
|
10
|
-
this.dependencies = dependencies;
|
11
|
-
this.callback = callback;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
var AMDModuleImporterState;
|
15
|
-
(function (AMDModuleImporterState) {
|
16
|
-
AMDModuleImporterState[AMDModuleImporterState["Uninitialized"] = 1] = "Uninitialized";
|
17
|
-
AMDModuleImporterState[AMDModuleImporterState["InitializedInternal"] = 2] = "InitializedInternal";
|
18
|
-
AMDModuleImporterState[AMDModuleImporterState["InitializedExternal"] = 3] = "InitializedExternal";
|
19
|
-
})(AMDModuleImporterState || (AMDModuleImporterState = {}));
|
20
|
-
class AMDModuleImporter {
|
21
|
-
static { this.INSTANCE = ( new AMDModuleImporter()); }
|
22
|
-
constructor() {
|
23
|
-
this._isWebWorker = (typeof self === 'object' && self.constructor && self.constructor.name === 'DedicatedWorkerGlobalScope');
|
24
|
-
this._isRenderer = typeof document === 'object';
|
25
|
-
this._defineCalls = [];
|
26
|
-
this._state = AMDModuleImporterState.Uninitialized;
|
27
|
-
}
|
28
|
-
_initialize() {
|
29
|
-
if (this._state === AMDModuleImporterState.Uninitialized) {
|
30
|
-
if (globalThis.define) {
|
31
|
-
this._state = AMDModuleImporterState.InitializedExternal;
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
return;
|
37
|
-
}
|
38
|
-
this._state = AMDModuleImporterState.InitializedInternal;
|
39
|
-
globalThis.define = (id, dependencies, callback) => {
|
40
|
-
if (typeof id !== 'string') {
|
41
|
-
callback = dependencies;
|
42
|
-
dependencies = id;
|
43
|
-
id = null;
|
44
|
-
}
|
45
|
-
if (typeof dependencies !== 'object' || !Array.isArray(dependencies)) {
|
46
|
-
callback = dependencies;
|
47
|
-
dependencies = null;
|
48
|
-
}
|
49
|
-
this._defineCalls.push(( new DefineCall(id, dependencies, callback)));
|
50
|
-
};
|
51
|
-
globalThis.define.amd = true;
|
52
|
-
if (this._isRenderer) {
|
53
|
-
this._amdPolicy = globalThis._VSCODE_WEB_PACKAGE_TTP ?? window.trustedTypes?.createPolicy('amdLoader', {
|
54
|
-
createScriptURL(value) {
|
55
|
-
if (value.startsWith(window.location.origin)) {
|
56
|
-
return value;
|
57
|
-
}
|
58
|
-
if (value.startsWith(`${Schemas.vscodeFileResource}://${VSCODE_AUTHORITY}`)) {
|
59
|
-
return value;
|
60
|
-
}
|
61
|
-
throw ( new Error(`[trusted_script_src] Invalid script url: ${value}`));
|
62
|
-
}
|
63
|
-
});
|
64
|
-
}
|
65
|
-
else if (this._isWebWorker) {
|
66
|
-
this._amdPolicy = globalThis._VSCODE_WEB_PACKAGE_TTP ?? globalThis.trustedTypes?.createPolicy('amdLoader', {
|
67
|
-
createScriptURL(value) {
|
68
|
-
return value;
|
69
|
-
}
|
70
|
-
});
|
71
|
-
}
|
72
|
-
}
|
73
|
-
async load(scriptSrc) {
|
74
|
-
this._initialize();
|
75
|
-
if (this._state === AMDModuleImporterState.InitializedExternal) {
|
76
|
-
return ( new Promise(resolve => {
|
77
|
-
const tmpModuleId = generateUuid();
|
78
|
-
globalThis.define(tmpModuleId, [scriptSrc], function (moduleResult) {
|
79
|
-
resolve(moduleResult);
|
80
|
-
});
|
81
|
-
}));
|
82
|
-
}
|
83
|
-
const defineCall = await (this._isWebWorker ? this._workerLoadScript(scriptSrc) : this._isRenderer ? this._rendererLoadScript(scriptSrc) : this._nodeJSLoadScript(scriptSrc));
|
84
|
-
if (!defineCall) {
|
85
|
-
console.warn(`Did not receive a define call from script ${scriptSrc}`);
|
86
|
-
return undefined;
|
87
|
-
}
|
88
|
-
const exports = {};
|
89
|
-
const dependencyObjs = [];
|
90
|
-
const dependencyModules = [];
|
91
|
-
if (Array.isArray(defineCall.dependencies)) {
|
92
|
-
for (const mod of defineCall.dependencies) {
|
93
|
-
if (mod === 'exports') {
|
94
|
-
dependencyObjs.push(exports);
|
95
|
-
}
|
96
|
-
else {
|
97
|
-
dependencyModules.push(mod);
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
if (dependencyModules.length > 0) {
|
102
|
-
throw ( new Error(
|
103
|
-
`Cannot resolve dependencies for script ${scriptSrc}. The dependencies are: ${dependencyModules.join(', ')}`
|
104
|
-
));
|
105
|
-
}
|
106
|
-
if (typeof defineCall.callback === 'function') {
|
107
|
-
return defineCall.callback(...dependencyObjs) ?? exports;
|
108
|
-
}
|
109
|
-
else {
|
110
|
-
return defineCall.callback;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
_rendererLoadScript(scriptSrc) {
|
114
|
-
return ( new Promise((resolve, reject) => {
|
115
|
-
const scriptElement = document.createElement('script');
|
116
|
-
scriptElement.setAttribute('async', 'async');
|
117
|
-
scriptElement.setAttribute('type', 'text/javascript');
|
118
|
-
const unbind = () => {
|
119
|
-
scriptElement.removeEventListener('load', loadEventListener);
|
120
|
-
scriptElement.removeEventListener('error', errorEventListener);
|
121
|
-
};
|
122
|
-
const loadEventListener = (e) => {
|
123
|
-
unbind();
|
124
|
-
resolve(this._defineCalls.pop());
|
125
|
-
};
|
126
|
-
const errorEventListener = (e) => {
|
127
|
-
unbind();
|
128
|
-
reject(e);
|
129
|
-
};
|
130
|
-
scriptElement.addEventListener('load', loadEventListener);
|
131
|
-
scriptElement.addEventListener('error', errorEventListener);
|
132
|
-
if (this._amdPolicy) {
|
133
|
-
scriptSrc = this._amdPolicy.createScriptURL(scriptSrc);
|
134
|
-
}
|
135
|
-
scriptElement.setAttribute('src', scriptSrc);
|
136
|
-
window.document.getElementsByTagName('head')[0].appendChild(scriptElement);
|
137
|
-
}));
|
138
|
-
}
|
139
|
-
async _workerLoadScript(scriptSrc) {
|
140
|
-
if (this._amdPolicy) {
|
141
|
-
scriptSrc = this._amdPolicy.createScriptURL(scriptSrc);
|
142
|
-
}
|
143
|
-
await import(scriptSrc).then(module => module.default ?? module);
|
144
|
-
return this._defineCalls.pop();
|
145
|
-
}
|
146
|
-
async _nodeJSLoadScript(scriptSrc) {
|
147
|
-
try {
|
148
|
-
const fs = (await import(`${'fs'}`).then(module => module.default ?? module)).default;
|
149
|
-
const vm = (await import(`${'vm'}`).then(module => module.default ?? module)).default;
|
150
|
-
const module = (await import(`${'module'}`).then(module => module.default ?? module)).default;
|
151
|
-
const filePath = ( URI.parse(scriptSrc)).fsPath;
|
152
|
-
const content = ( fs.readFileSync(filePath).toString());
|
153
|
-
const scriptSource = module.wrap(content.replace(/^#!.*/, ''));
|
154
|
-
const script = new vm.Script(scriptSource);
|
155
|
-
const compileWrapper = script.runInThisContext();
|
156
|
-
compileWrapper.apply();
|
157
|
-
return this._defineCalls.pop();
|
158
|
-
}
|
159
|
-
catch (error) {
|
160
|
-
throw error;
|
161
|
-
}
|
162
|
-
}
|
163
|
-
}
|
164
|
-
const cache = ( new Map());
|
165
|
-
async function importAMDNodeModule(nodeModuleName, pathInsideNodeModule, isBuilt) {
|
166
|
-
if (isBuilt === undefined) {
|
167
|
-
const product = globalThis._VSCODE_PRODUCT_JSON;
|
168
|
-
isBuilt = Boolean((product ?? globalThis.vscode?.context?.configuration()?.product)?.commit);
|
169
|
-
}
|
170
|
-
const nodeModulePath = pathInsideNodeModule ? `${nodeModuleName}/${pathInsideNodeModule}` : nodeModuleName;
|
171
|
-
if (( cache.has(nodeModulePath))) {
|
172
|
-
return cache.get(nodeModulePath);
|
173
|
-
}
|
174
|
-
let scriptSrc;
|
175
|
-
if (/^\w[\w\d+.-]*:\/\//.test(nodeModulePath)) {
|
176
|
-
scriptSrc = nodeModulePath;
|
177
|
-
}
|
178
|
-
else {
|
179
|
-
const actualNodeModulesPath = (nodeModulesPath);
|
180
|
-
const resourcePath = `${actualNodeModulesPath}/${nodeModulePath}`;
|
181
|
-
scriptSrc = ( ( FileAccess.asBrowserUri(resourcePath)).toString(true));
|
182
|
-
}
|
183
|
-
const result = AMDModuleImporter.INSTANCE.load(scriptSrc);
|
184
|
-
cache.set(nodeModulePath, result);
|
185
|
-
return result;
|
186
|
-
}
|
187
|
-
function resolveAmdNodeModulePath(nodeModuleName, pathInsideNodeModule) {
|
188
|
-
const product = globalThis._VSCODE_PRODUCT_JSON;
|
189
|
-
Boolean((product ?? globalThis.vscode?.context?.configuration()?.product)?.commit);
|
190
|
-
const nodeModulePath = `${nodeModuleName}/${pathInsideNodeModule}`;
|
191
|
-
const actualNodeModulesPath = (nodeModulesPath);
|
192
|
-
const resourcePath = `${actualNodeModulesPath}/${nodeModulePath}`;
|
193
|
-
return ( ( FileAccess.asBrowserUri(resourcePath)).toString(true));
|
194
|
-
}
|
195
|
-
|
196
|
-
export { importAMDNodeModule, resolveAmdNodeModulePath };
|