@theia/core 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.
Files changed (34) hide show
  1. package/lib/browser/catalog.json +27 -3
  2. package/lib/browser/saveable-service.d.ts +9 -2
  3. package/lib/browser/saveable-service.d.ts.map +1 -1
  4. package/lib/browser/saveable-service.js +34 -25
  5. package/lib/browser/saveable-service.js.map +1 -1
  6. package/lib/browser/window/browser-window-module.d.ts.map +1 -1
  7. package/lib/browser/window/browser-window-module.js +2 -0
  8. package/lib/browser/window/browser-window-module.js.map +1 -1
  9. package/lib/browser/window/default-secondary-window-service.d.ts +2 -0
  10. package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
  11. package/lib/browser/window/default-secondary-window-service.js +7 -0
  12. package/lib/browser/window/default-secondary-window-service.js.map +1 -1
  13. package/lib/browser/window/window-focus-service.d.ts +71 -0
  14. package/lib/browser/window/window-focus-service.d.ts.map +1 -0
  15. package/lib/browser/window/window-focus-service.js +173 -0
  16. package/lib/browser/window/window-focus-service.js.map +1 -0
  17. package/lib/electron-browser/window/electron-window-module.d.ts.map +1 -1
  18. package/lib/electron-browser/window/electron-window-module.js +2 -0
  19. package/lib/electron-browser/window/electron-window-module.js.map +1 -1
  20. package/lib/node/messaging/default-messaging-service.d.ts.map +1 -1
  21. package/lib/node/messaging/default-messaging-service.js +1 -0
  22. package/lib/node/messaging/default-messaging-service.js.map +1 -1
  23. package/lib/node/messaging/test/default-messaging-service.spec.d.ts +2 -0
  24. package/lib/node/messaging/test/default-messaging-service.spec.d.ts.map +1 -0
  25. package/lib/node/messaging/test/default-messaging-service.spec.js +81 -0
  26. package/lib/node/messaging/test/default-messaging-service.spec.js.map +1 -0
  27. package/package.json +4 -4
  28. package/src/browser/saveable-service.ts +34 -27
  29. package/src/browser/window/browser-window-module.ts +2 -0
  30. package/src/browser/window/default-secondary-window-service.ts +6 -0
  31. package/src/browser/window/window-focus-service.ts +187 -0
  32. package/src/electron-browser/window/electron-window-module.ts +2 -0
  33. package/src/node/messaging/default-messaging-service.ts +1 -0
  34. package/src/node/messaging/test/default-messaging-service.spec.ts +85 -0
@@ -0,0 +1,85 @@
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 { expect } from 'chai';
18
+ import { Container, injectable, preDestroy } from 'inversify';
19
+ import { ConnectionHandler, bindContributionProvider, servicesPath } from '../../../common';
20
+ import { BasicChannel, Channel } from '../../../common/message-rpc/channel';
21
+ import { Uint8ArrayWriteBuffer } from '../../../common/message-rpc/uint8-array-message-buffer';
22
+ import { ConnectionContainerModule } from '../connection-container-module';
23
+ import { DefaultMessagingService, MessagingContainer } from '../default-messaging-service';
24
+ import { FrontendConnectionService } from '../frontend-connection-service';
25
+ import { MessagingService } from '../messaging-service';
26
+
27
+ describe('DefaultMessagingService', () => {
28
+
29
+ describe('when a frontend connection closes', () => {
30
+
31
+ it('disposes the connection-scoped child container, invoking @preDestroy on bound singleton services', async () => {
32
+ let canaryDisposed = false;
33
+
34
+ @injectable()
35
+ class CanaryConnectionHandler implements ConnectionHandler {
36
+ readonly path = 'canary';
37
+ onConnection(_channel: Channel): void { /* not relevant for this test */ }
38
+
39
+ @preDestroy()
40
+ protected onPreDestroy(): void {
41
+ canaryDisposed = true;
42
+ }
43
+ }
44
+
45
+ const canaryModule = ConnectionContainerModule.create(({ bind }) => {
46
+ bind(CanaryConnectionHandler).toSelf().inSingletonScope();
47
+ bind(ConnectionHandler).toService(CanaryConnectionHandler);
48
+ });
49
+
50
+ const container = new Container();
51
+ container.bind(MessagingContainer).toConstantValue(container);
52
+ container.bind(DefaultMessagingService).toSelf().inSingletonScope();
53
+ container.bind(ConnectionContainerModule).toConstantValue(canaryModule);
54
+ bindContributionProvider(container, ConnectionContainerModule);
55
+ bindContributionProvider(container, MessagingService.Contribution);
56
+
57
+ let serviceHandler: ((params: MessagingService.PathParams, mainChannel: Channel) => void) | undefined;
58
+ const frontendConnectionService: FrontendConnectionService = {
59
+ registerConnectionHandler(path, callback): void {
60
+ if (path === servicesPath) {
61
+ serviceHandler = callback;
62
+ }
63
+ }
64
+ };
65
+ container.bind(FrontendConnectionService).toConstantValue(frontendConnectionService);
66
+
67
+ const messagingService = container.get(DefaultMessagingService);
68
+ messagingService.initialize();
69
+
70
+ expect(serviceHandler, 'connection handler not registered on the services path').to.not.be.undefined;
71
+
72
+ const mainChannel = new BasicChannel(() => new Uint8ArrayWriteBuffer());
73
+ serviceHandler!({}, mainChannel);
74
+
75
+ expect(canaryDisposed, 'canary should not be disposed before the channel is closed').to.be.false;
76
+
77
+ mainChannel.onCloseEmitter.fire({ reason: 'frontend connection closed' });
78
+ await new Promise<void>(resolve => setImmediate(resolve));
79
+
80
+ expect(canaryDisposed, 'canary @preDestroy was not invoked').to.be.true;
81
+ });
82
+
83
+ });
84
+
85
+ });