@theia/plugin-ext-vscode 1.72.0-next.5 → 1.72.0-next.52

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.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-init.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,uBAAuB,EAAyC,MAAM,mBAAmB,CAAC;AAWnG,eAAO,MAAM,gBAAgB,EAAE,uBAS9B,CAAC"}
1
+ {"version":3,"file":"plugin-vscode-init.d.ts","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,uBAAuB,EAAyC,MAAM,mBAAmB,CAAC;AAWnG,eAAO,MAAM,gBAAgB,EAAE,uBAS9B,CAAC"}
@@ -16,6 +16,8 @@
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.doInitialization = void 0;
19
+ /* eslint-disable @typescript-eslint/no-explicit-any */
20
+ const node_module_1 = require("node:module");
19
21
  const plugin_ext_1 = require("@theia/plugin-ext");
20
22
  const plugin_vscode_types_1 = require("../common/plugin-vscode-types");
21
23
  process.env['VSCODE_PID'] = process.env['THEIA_PARENT_PID'];
@@ -62,8 +64,71 @@ function overrideInternalLoad() {
62
64
  }
63
65
  return defaultApi;
64
66
  };
67
+ registerESMLoaderHook();
65
68
  }
66
69
  function findPlugin(filePath) {
67
70
  return plugins.find(plugin => filePath.startsWith(plugin.pluginFolder));
68
71
  }
72
+ /**
73
+ * Register an ESM loader hook so that `import 'vscode'` from an ESM plugin
74
+ * resolves through the same `module._load` patch above.
75
+ *
76
+ * The hook emits a unique synthetic CommonJS module per importing parent.
77
+ * The synthetic source:
78
+ * - looks up the plugin API via `Module._load('vscode', { filename: <parent path> })`,
79
+ * reusing the existing `findPlugin(parent.filename)` lookup, and
80
+ * - copies the API's top-level namespace into `exports.<name> = __api.<name>` so
81
+ * `cjs-module-lexer` exposes them as ESM named exports (required by VS Code
82
+ * extensions that do e.g. `import { commands, window } from 'vscode'`).
83
+ *
84
+ * Making the synthetic URL unique per importing parent gives each ESM plugin its
85
+ * own Node module-cache entry, so each plugin receives ITS OWN API rather than
86
+ * the first plugin's API being captured forever.
87
+ */
88
+ function registerESMLoaderHook() {
89
+ const sampleApi = plugins.length > 0 ? pluginsApiImpl.get(plugins[0].model.id) : undefined;
90
+ const apiKeys = sampleApi ? Object.keys(sampleApi) : [];
91
+ const loaderSource = `
92
+ import { fileURLToPath } from 'node:url';
93
+ const SHIM_URL_PREFIX = 'theia-vscode-shim:///vscode.cjs?parent=';
94
+ const API_KEYS = ${JSON.stringify(apiKeys)};
95
+
96
+ export async function resolve(specifier, context, nextResolve) {
97
+ if (specifier === 'vscode' && context.parentURL && context.parentURL.startsWith('file:')) {
98
+ return {
99
+ shortCircuit: true,
100
+ url: SHIM_URL_PREFIX + encodeURIComponent(context.parentURL),
101
+ format: 'commonjs'
102
+ };
103
+ }
104
+ return nextResolve(specifier, context);
105
+ }
106
+
107
+ export async function load(url, context, nextLoad) {
108
+ if (url.startsWith(SHIM_URL_PREFIX)) {
109
+ const parentURL = decodeURIComponent(url.slice(SHIM_URL_PREFIX.length));
110
+ let parentPath = '';
111
+ if (parentURL.startsWith('file:')) {
112
+ try { parentPath = fileURLToPath(parentURL); } catch { parentPath = ''; }
113
+ }
114
+ const namedExports = API_KEYS
115
+ .map(k => 'exports[' + JSON.stringify(k) + '] = __api[' + JSON.stringify(k) + '];')
116
+ .join('\\n');
117
+ const source =
118
+ "const Module = require('module');\\n" +
119
+ "const __api = Module._load('vscode', { filename: " + JSON.stringify(parentPath) + " }, false);\\n" +
120
+ namedExports;
121
+ return { format: 'commonjs', shortCircuit: true, source };
122
+ }
123
+ return nextLoad(url, context);
124
+ }
125
+ `;
126
+ try {
127
+ const dataUrl = 'data:text/javascript;base64,' + Buffer.from(loaderSource, 'utf8').toString('base64');
128
+ (0, node_module_1.register)(dataUrl);
129
+ }
130
+ catch (e) {
131
+ console.error('Failed to register VS Code ESM loader hook; ESM plugins will not load:', e);
132
+ }
133
+ }
69
134
  //# sourceMappingURL=plugin-vscode-init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-vscode-init.js","sourceRoot":"","sources":["../../src/node/plugin-vscode-init.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,wCAAwC;AACxC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAKhF,kDAAmG;AACnG,uEAA2E;AAE3E,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAE5D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAwB,CAAC;AACvD,MAAM,OAAO,GAAG,IAAI,KAAK,EAAU,CAAC;AACpC,IAAI,UAAwB,CAAC;AAC7B,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,gBAAkC,CAAC;AAEhC,MAAM,gBAAgB,GAA4B,CAAC,UAA4B,EAAE,MAAc,EAAE,EAAE;IACtG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,gBAAgB,GAAG,UAAU,CAAC;IAE9B,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,oBAAoB,EAAE,CAAC;QACvB,cAAc,GAAG,IAAI,CAAC;IAC1B,CAAC;AACL,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B;AAEF,SAAS,eAAe,CAAC,UAA4B,EAAE,MAAc;IACjE,MAAM,M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CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG;;;mBAGN,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BzC,CAAC;IACE,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,8BAA8B,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtG,IAAA,sBAAQ,EAAC,OAAO,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,wEAAwE,EAAE,CAAC,CAAC,CAAC;IAC/F,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@theia/plugin-ext-vscode",
3
- "version": "1.72.0-next.5+b7e4c26e2",
3
+ "version": "1.72.0-next.52+726081b2a",
4
4
  "description": "Theia - Plugin Extension for VsCode",
5
5
  "dependencies": {
6
- "@theia/callhierarchy": "1.72.0-next.5+b7e4c26e2",
7
- "@theia/core": "1.72.0-next.5+b7e4c26e2",
8
- "@theia/editor": "1.72.0-next.5+b7e4c26e2",
9
- "@theia/filesystem": "1.72.0-next.5+b7e4c26e2",
10
- "@theia/monaco": "1.72.0-next.5+b7e4c26e2",
6
+ "@theia/callhierarchy": "1.72.0-next.52+726081b2a",
7
+ "@theia/core": "1.72.0-next.52+726081b2a",
8
+ "@theia/editor": "1.72.0-next.52+726081b2a",
9
+ "@theia/filesystem": "1.72.0-next.52+726081b2a",
10
+ "@theia/monaco": "1.72.0-next.52+726081b2a",
11
11
  "@theia/monaco-editor-core": "1.108.201",
12
- "@theia/navigator": "1.72.0-next.5+b7e4c26e2",
13
- "@theia/outline-view": "1.72.0-next.5+b7e4c26e2",
14
- "@theia/plugin": "1.72.0-next.5+b7e4c26e2",
15
- "@theia/plugin-ext": "1.72.0-next.5+b7e4c26e2",
16
- "@theia/scm": "1.72.0-next.5+b7e4c26e2",
17
- "@theia/terminal": "1.72.0-next.5+b7e4c26e2",
18
- "@theia/typehierarchy": "1.72.0-next.5+b7e4c26e2",
19
- "@theia/userstorage": "1.72.0-next.5+b7e4c26e2",
20
- "@theia/workspace": "1.72.0-next.5+b7e4c26e2",
12
+ "@theia/navigator": "1.72.0-next.52+726081b2a",
13
+ "@theia/outline-view": "1.72.0-next.52+726081b2a",
14
+ "@theia/plugin": "1.72.0-next.52+726081b2a",
15
+ "@theia/plugin-ext": "1.72.0-next.52+726081b2a",
16
+ "@theia/scm": "1.72.0-next.52+726081b2a",
17
+ "@theia/terminal": "1.72.0-next.52+726081b2a",
18
+ "@theia/typehierarchy": "1.72.0-next.52+726081b2a",
19
+ "@theia/userstorage": "1.72.0-next.52+726081b2a",
20
+ "@theia/workspace": "1.72.0-next.52+726081b2a",
21
21
  "decompress": "^4.2.1",
22
22
  "filenamify": "^4.3.0",
23
- "tslib": "^2.6.2"
23
+ "tslib": "^2.8.1"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public"
@@ -61,5 +61,5 @@
61
61
  "nyc": {
62
62
  "extends": "../../configs/nyc.json"
63
63
  },
64
- "gitHead": "b7e4c26e21017756fe8bc06e8e77998477da3443"
64
+ "gitHead": "726081b2aa03827611ba4a323da1a6aaf0e9a9b9"
65
65
  }
@@ -16,6 +16,7 @@
16
16
 
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
 
19
+ import { register } from 'node:module';
19
20
  import * as theia from '@theia/plugin';
20
21
  import { BackendInitializationFn, PluginAPIFactory, Plugin, emptyPlugin } from '@theia/plugin-ext';
21
22
  import { VSCODE_DEFAULT_API_VERSION } from '../common/plugin-vscode-types';
@@ -73,8 +74,72 @@ function overrideInternalLoad(): void {
73
74
 
74
75
  return defaultApi;
75
76
  };
77
+
78
+ registerESMLoaderHook();
76
79
  }
77
80
 
78
81
  function findPlugin(filePath: string): Plugin | undefined {
79
82
  return plugins.find(plugin => filePath.startsWith(plugin.pluginFolder));
80
83
  }
84
+
85
+ /**
86
+ * Register an ESM loader hook so that `import 'vscode'` from an ESM plugin
87
+ * resolves through the same `module._load` patch above.
88
+ *
89
+ * The hook emits a unique synthetic CommonJS module per importing parent.
90
+ * The synthetic source:
91
+ * - looks up the plugin API via `Module._load('vscode', { filename: <parent path> })`,
92
+ * reusing the existing `findPlugin(parent.filename)` lookup, and
93
+ * - copies the API's top-level namespace into `exports.<name> = __api.<name>` so
94
+ * `cjs-module-lexer` exposes them as ESM named exports (required by VS Code
95
+ * extensions that do e.g. `import { commands, window } from 'vscode'`).
96
+ *
97
+ * Making the synthetic URL unique per importing parent gives each ESM plugin its
98
+ * own Node module-cache entry, so each plugin receives ITS OWN API rather than
99
+ * the first plugin's API being captured forever.
100
+ */
101
+ function registerESMLoaderHook(): void {
102
+ const sampleApi = plugins.length > 0 ? pluginsApiImpl.get(plugins[0].model.id) : undefined;
103
+ const apiKeys = sampleApi ? Object.keys(sampleApi) : [];
104
+ const loaderSource = `
105
+ import { fileURLToPath } from 'node:url';
106
+ const SHIM_URL_PREFIX = 'theia-vscode-shim:///vscode.cjs?parent=';
107
+ const API_KEYS = ${JSON.stringify(apiKeys)};
108
+
109
+ export async function resolve(specifier, context, nextResolve) {
110
+ if (specifier === 'vscode' && context.parentURL && context.parentURL.startsWith('file:')) {
111
+ return {
112
+ shortCircuit: true,
113
+ url: SHIM_URL_PREFIX + encodeURIComponent(context.parentURL),
114
+ format: 'commonjs'
115
+ };
116
+ }
117
+ return nextResolve(specifier, context);
118
+ }
119
+
120
+ export async function load(url, context, nextLoad) {
121
+ if (url.startsWith(SHIM_URL_PREFIX)) {
122
+ const parentURL = decodeURIComponent(url.slice(SHIM_URL_PREFIX.length));
123
+ let parentPath = '';
124
+ if (parentURL.startsWith('file:')) {
125
+ try { parentPath = fileURLToPath(parentURL); } catch { parentPath = ''; }
126
+ }
127
+ const namedExports = API_KEYS
128
+ .map(k => 'exports[' + JSON.stringify(k) + '] = __api[' + JSON.stringify(k) + '];')
129
+ .join('\\n');
130
+ const source =
131
+ "const Module = require('module');\\n" +
132
+ "const __api = Module._load('vscode', { filename: " + JSON.stringify(parentPath) + " }, false);\\n" +
133
+ namedExports;
134
+ return { format: 'commonjs', shortCircuit: true, source };
135
+ }
136
+ return nextLoad(url, context);
137
+ }
138
+ `;
139
+ try {
140
+ const dataUrl = 'data:text/javascript;base64,' + Buffer.from(loaderSource, 'utf8').toString('base64');
141
+ register(dataUrl);
142
+ } catch (e) {
143
+ console.error('Failed to register VS Code ESM loader hook; ESM plugins will not load:', e);
144
+ }
145
+ }