@theia/monaco 1.71.0-next.44 → 1.71.0-next.51

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":"monaco-init.d.ts","sourceRoot":"","sources":["../../src/browser/monaco-init.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAiCzD,eAAO,MAAM,yBAAyB,oEAAoC,CAAC;AAwH3E,yBAAiB,UAAU,CAAC;IACxB,SAAgB,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CA8D/C;CACJ"}
1
+ {"version":3,"file":"monaco-init.d.ts","sourceRoot":"","sources":["../../src/browser/monaco-init.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAmCzD,eAAO,MAAM,yBAAyB,oEAAoC,CAAC;AAwH3E,yBAAiB,UAAU,CAAC;IACxB,SAAgB,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CA+C/C;CACJ"}
@@ -37,6 +37,8 @@ const codeEditorService_1 = require("@theia/monaco-editor-core/esm/vs/editor/bro
37
37
  const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
38
38
  const descriptors_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/descriptors");
39
39
  const instantiation_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation");
40
+ const instantiationService_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiationService");
41
+ const serviceCollection_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection");
40
42
  const monaco_editor_service_1 = require("./monaco-editor-service");
41
43
  const configuration_1 = require("@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration");
42
44
  const resolverService_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/services/resolverService");
@@ -63,6 +65,7 @@ const layoutService_1 = require("@theia/monaco-editor-core/esm/vs/platform/layou
63
65
  const event_1 = require("@theia/monaco-editor-core/esm/vs/base/common/event");
64
66
  const dom = require("@theia/monaco-editor-core/esm/vs/base/browser/dom");
65
67
  const window_1 = require("@theia/monaco-editor-core/esm/vs/base/browser/window");
68
+ const core_1 = require("@theia/core");
66
69
  exports.contentHoverWidgetPatcher = (0, content_hover_widget_patcher_1.createContentHoverWidgetPatcher)();
67
70
  let MonacoEditorServiceConstructor = class MonacoEditorServiceConstructor {
68
71
  /**
@@ -183,45 +186,32 @@ var MonacoInit;
183
186
  [workspace_1.IWorkspaceContextService.toString()]: new descriptors_1.SyncDescriptor(MonacoWorkspaceContextServiceConstructor, [container]),
184
187
  [layoutService_1.ILayoutService.toString()]: new descriptors_1.SyncDescriptor(MonacoLayoutServiceConstructor, [])
185
188
  };
189
+ // Detect whether StandaloneServices was already initialized before we get a chance to
190
+ // apply our overrides. `withServices` calls the callback synchronously when `initialized`
191
+ // is already `true`, so the flag will be set before we proceed. If it remains `false`,
192
+ // our `initialize(overrides)` call below will be the first and our descriptors will be
193
+ // applied normally.
194
+ // @monaco-uplift: verify that `withServices` still calls the callback synchronously when
195
+ // already initialized — if this changes, the premature-initialization detection will break.
196
+ let isInitialized = false;
197
+ standaloneServices_1.StandaloneServices.withServices(() => {
198
+ isInitialized = true;
199
+ return core_1.Disposable.NULL;
200
+ });
201
+ const servicesInitializedBeforeOverrides = isInitialized;
186
202
  // Try the standard initialization path first.
187
203
  standaloneServices_1.StandaloneServices.initialize(overrides);
188
204
  // If StandaloneServices was already initialized (e.g., by a premature StandaloneServices.get() call
189
205
  // triggered as a side-effect during module loading), the call above is a no-op and our overrides are
190
206
  // silently dropped. Detect this situation, warn about it, and inject our service descriptors directly
191
207
  // into the internal service collection so that they are used when the services are next resolved.
192
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
193
- const instantiationService = standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
194
- const serviceCollection = instantiationService?._services;
195
- if (serviceCollection) {
196
- const patchedServices = [];
197
- const alreadyInstantiatedServices = [];
198
- for (const serviceId of Object.keys(overrides)) {
199
- const serviceIdentifier = (0, instantiation_1.createDecorator)(serviceId);
200
- const existing = serviceCollection.get(serviceIdentifier);
201
- if (existing instanceof descriptors_1.SyncDescriptor && existing !== overrides[serviceId]) {
202
- // The override was not applied by initialize() – patch it in manually.
203
- serviceCollection.set(serviceIdentifier, overrides[serviceId]);
204
- patchedServices.push(serviceId);
205
- }
206
- else if (existing !== undefined && !(existing instanceof descriptors_1.SyncDescriptor) && existing !== overrides[serviceId]) {
207
- // The service was already instantiated – we cannot override it anymore.
208
- alreadyInstantiatedServices.push(serviceId);
209
- }
210
- }
211
- if (patchedServices.length > 0) {
212
- console.warn('StandaloneServices was already initialized before MonacoInit.init() was called. '
213
- + 'This typically happens when a StandaloneServices.get() call is triggered as a side-effect during module loading. '
214
- + 'The following Theia service overrides had to be patched in after the fact: '
215
- + patchedServices.join(', ')
216
- + '. Investigate the module loading order to prevent premature initialization.');
217
- }
218
- if (alreadyInstantiatedServices.length > 0) {
219
- console.error('StandaloneServices was already initialized and the following services were already instantiated '
220
- + 'before MonacoInit.init() could apply Theia overrides: '
221
- + alreadyInstantiatedServices.join(', ')
222
- + '. These services are using the default Monaco implementations instead of Theia\'s. '
223
- + 'This may cause unexpected behavior. Investigate which code triggers premature service resolution.');
224
- }
208
+ //
209
+ // We only need this fallback when initialize() was a no-op. On the normal startup path,
210
+ // initialize() succeeds and any services that get instantiated during that call (e.g. as
211
+ // dependencies of editor features) are created from *our* Theia descriptors — not the
212
+ // Monaco defaults — so they are perfectly fine and must not be flagged.
213
+ if (servicesInitializedBeforeOverrides) {
214
+ patchServices(overrides);
225
215
  }
226
216
  // Make sure the global base hover delegate is initialized as otherwise the quick input will throw an error and not update correctly
227
217
  // in case no Monaco editor was constructed before and items with keybindings are shown. See #15042.
@@ -229,4 +219,54 @@ var MonacoInit;
229
219
  }
230
220
  MonacoInit.init = init;
231
221
  })(MonacoInit || (exports.MonacoInit = MonacoInit = {}));
222
+ // @monaco-uplift: verify that the concrete InstantiationService class still exposes a
223
+ // private `_services: ServiceCollection` property. See monaco-init.spec.ts for a CI
224
+ // guard that will flag a mismatch after a Monaco version bump.
225
+ function patchServices(overrides) {
226
+ const instantiationService = standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
227
+ if (!(instantiationService instanceof instantiationService_1.InstantiationService)) {
228
+ console.error('StandaloneServices returned an IInstantiationService that is not an instance of InstantiationService. '
229
+ + 'Theia service overrides cannot be patched in after premature initialization. '
230
+ + 'Investigate whether Monaco\'s internal InstantiationService class has been refactored.');
231
+ return;
232
+ }
233
+ const serviceCollection = instantiationService['_services'];
234
+ if (!(serviceCollection instanceof serviceCollection_1.ServiceCollection)) {
235
+ console.error('InstantiationService._services is not a ServiceCollection (got '
236
+ + (serviceCollection === undefined ? 'undefined' : typeof serviceCollection)
237
+ + '). Theia service overrides cannot be patched in after premature initialization. '
238
+ + 'Investigate whether Monaco\'s InstantiationService internals have changed.');
239
+ return;
240
+ }
241
+ const patchedServices = [];
242
+ const alreadyInstantiatedServices = [];
243
+ for (const serviceId of Object.keys(overrides)) {
244
+ const serviceIdentifier = (0, instantiation_1.createDecorator)(serviceId);
245
+ const existing = serviceCollection.get(serviceIdentifier);
246
+ if (existing instanceof descriptors_1.SyncDescriptor && existing !== overrides[serviceId]) {
247
+ // The override was not applied by initialize() – patch it in manually.
248
+ serviceCollection.set(serviceIdentifier, overrides[serviceId]);
249
+ patchedServices.push(serviceId);
250
+ }
251
+ else if (existing !== undefined && !(existing instanceof descriptors_1.SyncDescriptor)) {
252
+ // The service was already instantiated from the default Monaco
253
+ // implementation – we cannot override it anymore.
254
+ alreadyInstantiatedServices.push(serviceId);
255
+ }
256
+ }
257
+ if (patchedServices.length > 0) {
258
+ console.warn('StandaloneServices was already initialized before MonacoInit.init() was called. '
259
+ + 'This typically happens when a StandaloneServices.get() call is triggered as a side-effect during module loading. '
260
+ + 'The following Theia service overrides had to be patched in after the fact: '
261
+ + patchedServices.join(', ')
262
+ + '. Investigate the module loading order to prevent premature initialization.');
263
+ }
264
+ if (alreadyInstantiatedServices.length > 0) {
265
+ console.error('StandaloneServices was already initialized and the following services were already instantiated '
266
+ + 'before MonacoInit.init() could apply Theia overrides: '
267
+ + alreadyInstantiatedServices.join(', ')
268
+ + '. These services are using the default Monaco implementations instead of Theia\'s. '
269
+ + 'This may cause unexpected behavior. Investigate which code triggers premature service resolution.');
270
+ }
271
+ }
232
272
  //# sourceMappingURL=monaco-init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"monaco-init.js","sourceRoot":"","sources":["../../src/browser/monaco-init.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,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;;;;AAEhF;;;;;;;;;;;GAWG;AAEH,6EAA6E;AAC7E,uFAAuF;AACvF,wDAAwD;AAExD,4DAAyD;AACzD,kHAAgH;AAChH,sHAAmH;AACnH,4GAA4G;AAC5G,gHAAsI;AAEtI,mEAAqG;AACrG,gHAAqH;AACrH,6GAA4G;AAC5G,qEAAsE;AACtE,2EAAqE;AACrE,+DAAiE;AACjE,2GAAgH;AAChH,uGAA4G;AAC5G,sGAAoG;AACpG,yEAAmE;AACnE,qEAAgE;AAChE,8GAA4G;AAC5G,iGAAqG;AACrG,6EAA8E;AAC9E,uGAA4G;AAC5G,+GAAoH;AACpH,uFAAiF;AACjF,iFAAiF;AACjF,yFAA8F;AAC9F,0GAAkH;AAClH,oGAAgH;AAChH,yFAAmF;AACnF,0GAAwG;AACxG,8EAA2E;AAC3E,yEAAyE;AACzE,iFAAkF;AAErE,QAAA,yBAAyB,GAAG,IAAA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A2B,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzC,OAAO,CAAC,KAAK,CACT,kGAAkG;sBAChG,wDAAwD;sBACxD,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC;sBACtC,qFAAqF;sBACrF,mGAAmG,CACxG,CAAC;YACN,CAAC;QACL,CAAC;QAED,oIAAoI;QACpI,oGAAoG;QACpG,IAAA,0CAAyB,EAAC,uCAAkB,CAAC,GAAG,CAAC,qBAAa,CAAC,CAAC,CAAC;IACrE,CAAC;IA9De,eAAI,OA8DnB,CAAA;AACL,CAAC,EAhEgB,UAAU,0BAAV,UAAU,QAgE1B"}
1
+ {"version":3,"file":"monaco-init.js","sourceRoot":"","sources":["../../src/browser/monaco-init.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,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;;;;AAEhF;;;;;;;;;;;GAWG;AAEH,6EAA6E;AAC7E,uFAAuF;AACvF,wDAAwD;AAExD,4DAAyD;AACzD,kHAAgH;AAChH,sHAAmH;AACnH,4GAA4G;AAC5G,gHAAsI;AACtI,8HAA2H;AAC3H,wHAAqH;AACrH,mEAAqG;AACrG,gHAAqH;AACrH,6GAA4G;AAC5G,qEAAsE;AACtE,2EAAqE;AACrE,+DAAiE;AACjE,2GAAgH;AAChH,uGAA4G;AAC5G,sGAAoG;AACpG,yEAAmE;AACnE,qEAAgE;AAChE,8GAA4G;AAC5G,iGAAqG;AACrG,6EAA8E;AAC9E,uGAA4G;AAC5G,+GAAoH;AACpH,uFAAiF;AACjF,iFAAiF;AACjF,yFAA8F;AAC9F,0GAAkH;AAClH,oGAAgH;AAChH,yFAAmF;AACnF,0GAAwG;AACxG,8EAA2E;AAC3E,yEAAyE;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D,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC;cACtC,qFAAqF;cACrF,mGAAmG,CACxG,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=monaco-init.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monaco-init.spec.d.ts","sourceRoot":"","sources":["../../src/browser/monaco-init.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 EclipseSource and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
19
+ let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
+ const chai_1 = require("chai");
21
+ const core_1 = require("@theia/core");
22
+ const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
23
+ const instantiation_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation");
24
+ const instantiationService_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiationService");
25
+ const serviceCollection_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection");
26
+ disableJSDOM();
27
+ /**
28
+ * @monaco-uplift
29
+ *
30
+ * These tests guard internal assumptions that `monaco-init.ts` makes about
31
+ * Monaco's `StandaloneServices`. Specifically:
32
+ *
33
+ * 1. `StandaloneServices.get(IInstantiationService)` returns an instance of the
34
+ * concrete {@link InstantiationService} class.
35
+ * 2. That class exposes a private `_services` field of type {@link ServiceCollection}.
36
+ * 3. `StandaloneServices.withServices` calls its callback **synchronously** when
37
+ * services are already initialized (used to detect premature initialization).
38
+ *
39
+ * Because these rely on private implementation details of Monaco, they may break
40
+ * in a future release. If any of these tests fail after a Monaco version bump,
41
+ * the corresponding code in `monaco-init.ts` must be updated to match.
42
+ */
43
+ describe('Monaco InstantiationService internals', () => {
44
+ before(() => disableJSDOM = (0, jsdom_1.enableJSDOM)());
45
+ after(() => disableJSDOM());
46
+ it('StandaloneServices.get(IInstantiationService) should be an instance of InstantiationService', () => {
47
+ const instantiationService = standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
48
+ (0, chai_1.expect)(instantiationService).to.be.an.instanceOf(instantiationService_1.InstantiationService);
49
+ });
50
+ it('StandaloneServices.get(IInstantiationService) should have a _services property that is a ServiceCollection', () => {
51
+ const instantiationService = standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ const services = instantiationService['_services'];
54
+ (0, chai_1.expect)(services).to.not.be.undefined;
55
+ (0, chai_1.expect)(services).to.be.an.instanceOf(serviceCollection_1.ServiceCollection);
56
+ });
57
+ // MonacoInit.init() uses withServices to detect whether StandaloneServices
58
+ // was already initialized: it passes a callback that sets a flag, then reads
59
+ // the flag immediately afterwards. This only works if withServices calls
60
+ // the callback synchronously when services are already initialized.
61
+ it('StandaloneServices.withServices should call the callback synchronously when already initialized', () => {
62
+ // Ensure services are initialized (get triggers initialization if needed).
63
+ standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
64
+ let called = false;
65
+ standaloneServices_1.StandaloneServices.withServices(() => {
66
+ called = true;
67
+ return core_1.Disposable.NULL;
68
+ });
69
+ (0, chai_1.expect)(called).to.be.true;
70
+ });
71
+ });
72
+ //# sourceMappingURL=monaco-init.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monaco-init.spec.js","sourceRoot":"","sources":["../../src/browser/monaco-init.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,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;;AAEhF,8DAAiE;AACjE,IAAI,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AAEjC,+BAA8B;AAC9B,sCAAyC;AACzC,sHAAmH;AACnH,gHAAqH;AACrH,8HAA2H;AAC3H,wHAAqH;AAErH,YAAY,EAAE,CAAC;AAEf;;;;;;;;;;;;;;;GAeG;AACH,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IAEnD,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC,CAAC;IAC3C,KAAK,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;IAE5B,EAAE,CAAC,6FAA6F,EAAE,GAAG,EAAE;QACnG,MAAM,oBAAoB,GAAG,uCAAkB,CAAC,GAAG,CAAC,qCAAqB,CAAC,CAAC;QAC3E,IAAA,aAAM,EAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,2CAAoB,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4GAA4G,EAAE,GAAG,EAAE;QAClH,MAAM,oBAAoB,GAAG,uCAAkB,CAAC,GAAG,CAAC,qCAAqB,CAAC,CAAC;QAC3E,8DAA8D;QAC9D,MAAM,QAAQ,GAAI,oBAA4B,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACrC,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,qCAAiB,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,6EAA6E;IAC7E,0EAA0E;IAC1E,oEAAoE;IACpE,EAAE,CAAC,iGAAiG,EAAE,GAAG,EAAE;QACvG,2EAA2E;QAC3E,uCAAkB,CAAC,GAAG,CAAC,qCAAqB,CAAC,CAAC;QAE9C,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,uCAAkB,CAAC,YAAY,CAAC,GAAG,EAAE;YACjC,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,iBAAU,CAAC,IAAI,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@theia/monaco",
3
- "version": "1.71.0-next.44+631e361db",
3
+ "version": "1.71.0-next.51+fdb38abfd",
4
4
  "description": "Theia - Monaco Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.71.0-next.44+631e361db",
7
- "@theia/editor": "1.71.0-next.44+631e361db",
8
- "@theia/filesystem": "1.71.0-next.44+631e361db",
9
- "@theia/markers": "1.71.0-next.44+631e361db",
6
+ "@theia/core": "1.71.0-next.51+fdb38abfd",
7
+ "@theia/editor": "1.71.0-next.51+fdb38abfd",
8
+ "@theia/filesystem": "1.71.0-next.51+fdb38abfd",
9
+ "@theia/markers": "1.71.0-next.51+fdb38abfd",
10
10
  "@theia/monaco-editor-core": "1.108.201",
11
- "@theia/outline-view": "1.71.0-next.44+631e361db",
12
- "@theia/workspace": "1.71.0-next.44+631e361db",
11
+ "@theia/outline-view": "1.71.0-next.51+fdb38abfd",
12
+ "@theia/workspace": "1.71.0-next.51+fdb38abfd",
13
13
  "fast-plist": "^0.1.3",
14
14
  "idb": "^4.0.5",
15
15
  "jsonc-parser": "^2.3.1",
@@ -57,5 +57,5 @@
57
57
  "nyc": {
58
58
  "extends": "../../configs/nyc.json"
59
59
  },
60
- "gitHead": "631e361dbd0ab7ec2da64be1f24ec5769125b838"
60
+ "gitHead": "fdb38abfdd1ce0f547a16ec9f5b9251d789b4074"
61
61
  }
@@ -0,0 +1,78 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
+ let disableJSDOM = enableJSDOM();
19
+
20
+ import { expect } from 'chai';
21
+ import { Disposable } from '@theia/core';
22
+ import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
23
+ import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
24
+ import { InstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiationService';
25
+ import { ServiceCollection } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection';
26
+
27
+ disableJSDOM();
28
+
29
+ /**
30
+ * @monaco-uplift
31
+ *
32
+ * These tests guard internal assumptions that `monaco-init.ts` makes about
33
+ * Monaco's `StandaloneServices`. Specifically:
34
+ *
35
+ * 1. `StandaloneServices.get(IInstantiationService)` returns an instance of the
36
+ * concrete {@link InstantiationService} class.
37
+ * 2. That class exposes a private `_services` field of type {@link ServiceCollection}.
38
+ * 3. `StandaloneServices.withServices` calls its callback **synchronously** when
39
+ * services are already initialized (used to detect premature initialization).
40
+ *
41
+ * Because these rely on private implementation details of Monaco, they may break
42
+ * in a future release. If any of these tests fail after a Monaco version bump,
43
+ * the corresponding code in `monaco-init.ts` must be updated to match.
44
+ */
45
+ describe('Monaco InstantiationService internals', () => {
46
+
47
+ before(() => disableJSDOM = enableJSDOM());
48
+ after(() => disableJSDOM());
49
+
50
+ it('StandaloneServices.get(IInstantiationService) should be an instance of InstantiationService', () => {
51
+ const instantiationService = StandaloneServices.get(IInstantiationService);
52
+ expect(instantiationService).to.be.an.instanceOf(InstantiationService);
53
+ });
54
+
55
+ it('StandaloneServices.get(IInstantiationService) should have a _services property that is a ServiceCollection', () => {
56
+ const instantiationService = StandaloneServices.get(IInstantiationService);
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ const services = (instantiationService as any)['_services'];
59
+ expect(services).to.not.be.undefined;
60
+ expect(services).to.be.an.instanceOf(ServiceCollection);
61
+ });
62
+
63
+ // MonacoInit.init() uses withServices to detect whether StandaloneServices
64
+ // was already initialized: it passes a callback that sets a flag, then reads
65
+ // the flag immediately afterwards. This only works if withServices calls
66
+ // the callback synchronously when services are already initialized.
67
+ it('StandaloneServices.withServices should call the callback synchronously when already initialized', () => {
68
+ // Ensure services are initialized (get triggers initialization if needed).
69
+ StandaloneServices.get(IInstantiationService);
70
+
71
+ let called = false;
72
+ StandaloneServices.withServices(() => {
73
+ called = true;
74
+ return Disposable.NULL;
75
+ });
76
+ expect(called).to.be.true;
77
+ });
78
+ });
@@ -36,6 +36,7 @@ import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/brow
36
36
  import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
37
37
  import { SyncDescriptor } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/descriptors';
38
38
  import { IInstantiationService, createDecorator } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
39
+ import { InstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiationService';
39
40
  import { ServiceCollection } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection';
40
41
  import { MonacoEditorServiceFactory, MonacoEditorServiceFactoryType } from './monaco-editor-service';
41
42
  import { IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
@@ -63,6 +64,7 @@ import { ILayoutService } from '@theia/monaco-editor-core/esm/vs/platform/layout
63
64
  import { Event } from '@theia/monaco-editor-core/esm/vs/base/common/event';
64
65
  import * as dom from '@theia/monaco-editor-core/esm/vs/base/browser/dom';
65
66
  import { mainWindow } from '@theia/monaco-editor-core/esm/vs/base/browser/window';
67
+ import { Disposable } from '@theia/core';
66
68
 
67
69
  export const contentHoverWidgetPatcher = createContentHoverWidgetPatcher();
68
70
 
@@ -199,6 +201,20 @@ export namespace MonacoInit {
199
201
  [ILayoutService.toString()]: new SyncDescriptor(MonacoLayoutServiceConstructor, [])
200
202
  };
201
203
 
204
+ // Detect whether StandaloneServices was already initialized before we get a chance to
205
+ // apply our overrides. `withServices` calls the callback synchronously when `initialized`
206
+ // is already `true`, so the flag will be set before we proceed. If it remains `false`,
207
+ // our `initialize(overrides)` call below will be the first and our descriptors will be
208
+ // applied normally.
209
+ // @monaco-uplift: verify that `withServices` still calls the callback synchronously when
210
+ // already initialized — if this changes, the premature-initialization detection will break.
211
+ let isInitialized = false;
212
+ StandaloneServices.withServices(() => {
213
+ isInitialized = true;
214
+ return Disposable.NULL;
215
+ });
216
+ const servicesInitializedBeforeOverrides = isInitialized;
217
+
202
218
  // Try the standard initialization path first.
203
219
  StandaloneServices.initialize(overrides);
204
220
 
@@ -206,42 +222,13 @@ export namespace MonacoInit {
206
222
  // triggered as a side-effect during module loading), the call above is a no-op and our overrides are
207
223
  // silently dropped. Detect this situation, warn about it, and inject our service descriptors directly
208
224
  // into the internal service collection so that they are used when the services are next resolved.
209
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
210
- const instantiationService = StandaloneServices.get(IInstantiationService) as any;
211
- const serviceCollection: ServiceCollection | undefined = instantiationService?._services;
212
- if (serviceCollection) {
213
- const patchedServices: string[] = [];
214
- const alreadyInstantiatedServices: string[] = [];
215
- for (const serviceId of Object.keys(overrides)) {
216
- const serviceIdentifier = createDecorator(serviceId);
217
- const existing = serviceCollection.get(serviceIdentifier);
218
- if (existing instanceof SyncDescriptor && existing !== overrides[serviceId]) {
219
- // The override was not applied by initialize() – patch it in manually.
220
- serviceCollection.set(serviceIdentifier, overrides[serviceId]);
221
- patchedServices.push(serviceId);
222
- } else if (existing !== undefined && !(existing instanceof SyncDescriptor) && existing !== overrides[serviceId]) {
223
- // The service was already instantiated – we cannot override it anymore.
224
- alreadyInstantiatedServices.push(serviceId);
225
- }
226
- }
227
- if (patchedServices.length > 0) {
228
- console.warn(
229
- 'StandaloneServices was already initialized before MonacoInit.init() was called. '
230
- + 'This typically happens when a StandaloneServices.get() call is triggered as a side-effect during module loading. '
231
- + 'The following Theia service overrides had to be patched in after the fact: '
232
- + patchedServices.join(', ')
233
- + '. Investigate the module loading order to prevent premature initialization.'
234
- );
235
- }
236
- if (alreadyInstantiatedServices.length > 0) {
237
- console.error(
238
- 'StandaloneServices was already initialized and the following services were already instantiated '
239
- + 'before MonacoInit.init() could apply Theia overrides: '
240
- + alreadyInstantiatedServices.join(', ')
241
- + '. These services are using the default Monaco implementations instead of Theia\'s. '
242
- + 'This may cause unexpected behavior. Investigate which code triggers premature service resolution.'
243
- );
244
- }
225
+ //
226
+ // We only need this fallback when initialize() was a no-op. On the normal startup path,
227
+ // initialize() succeeds and any services that get instantiated during that call (e.g. as
228
+ // dependencies of editor features) are created from *our* Theia descriptors — not the
229
+ // Monaco defaults so they are perfectly fine and must not be flagged.
230
+ if (servicesInitializedBeforeOverrides) {
231
+ patchServices(overrides);
245
232
  }
246
233
 
247
234
  // Make sure the global base hover delegate is initialized as otherwise the quick input will throw an error and not update correctly
@@ -249,3 +236,61 @@ export namespace MonacoInit {
249
236
  setBaseLayerHoverDelegate(StandaloneServices.get(IHoverService));
250
237
  }
251
238
  }
239
+
240
+ // @monaco-uplift: verify that the concrete InstantiationService class still exposes a
241
+ // private `_services: ServiceCollection` property. See monaco-init.spec.ts for a CI
242
+ // guard that will flag a mismatch after a Monaco version bump.
243
+ function patchServices(overrides: Record<string, SyncDescriptor<unknown>>): void {
244
+ const instantiationService = StandaloneServices.get(IInstantiationService);
245
+ if (!(instantiationService instanceof InstantiationService)) {
246
+ console.error(
247
+ 'StandaloneServices returned an IInstantiationService that is not an instance of InstantiationService. '
248
+ + 'Theia service overrides cannot be patched in after premature initialization. '
249
+ + 'Investigate whether Monaco\'s internal InstantiationService class has been refactored.'
250
+ );
251
+ return;
252
+ }
253
+ const serviceCollection = instantiationService['_services'];
254
+ if (!(serviceCollection instanceof ServiceCollection)) {
255
+ console.error(
256
+ 'InstantiationService._services is not a ServiceCollection (got '
257
+ + (serviceCollection === undefined ? 'undefined' : typeof serviceCollection)
258
+ + '). Theia service overrides cannot be patched in after premature initialization. '
259
+ + 'Investigate whether Monaco\'s InstantiationService internals have changed.'
260
+ );
261
+ return;
262
+ }
263
+ const patchedServices: string[] = [];
264
+ const alreadyInstantiatedServices: string[] = [];
265
+ for (const serviceId of Object.keys(overrides)) {
266
+ const serviceIdentifier = createDecorator(serviceId);
267
+ const existing = serviceCollection.get(serviceIdentifier);
268
+ if (existing instanceof SyncDescriptor && existing !== overrides[serviceId]) {
269
+ // The override was not applied by initialize() – patch it in manually.
270
+ serviceCollection.set(serviceIdentifier, overrides[serviceId]);
271
+ patchedServices.push(serviceId);
272
+ } else if (existing !== undefined && !(existing instanceof SyncDescriptor)) {
273
+ // The service was already instantiated from the default Monaco
274
+ // implementation – we cannot override it anymore.
275
+ alreadyInstantiatedServices.push(serviceId);
276
+ }
277
+ }
278
+ if (patchedServices.length > 0) {
279
+ console.warn(
280
+ 'StandaloneServices was already initialized before MonacoInit.init() was called. '
281
+ + 'This typically happens when a StandaloneServices.get() call is triggered as a side-effect during module loading. '
282
+ + 'The following Theia service overrides had to be patched in after the fact: '
283
+ + patchedServices.join(', ')
284
+ + '. Investigate the module loading order to prevent premature initialization.'
285
+ );
286
+ }
287
+ if (alreadyInstantiatedServices.length > 0) {
288
+ console.error(
289
+ 'StandaloneServices was already initialized and the following services were already instantiated '
290
+ + 'before MonacoInit.init() could apply Theia overrides: '
291
+ + alreadyInstantiatedServices.join(', ')
292
+ + '. These services are using the default Monaco implementations instead of Theia\'s. '
293
+ + 'This may cause unexpected behavior. Investigate which code triggers premature service resolution.'
294
+ );
295
+ }
296
+ }