@eclipse-glsp/server 2.6.0-next.3 → 2.7.0-next.10
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/lib/browser/di/app-module.d.ts +1 -1
- package/lib/browser/di/app-module.d.ts.map +1 -1
- package/lib/browser/di/app-module.js +5 -1
- package/lib/browser/di/app-module.js.map +1 -1
- package/lib/browser/di/browser-action-dispatch-scope.d.ts +39 -0
- package/lib/browser/di/browser-action-dispatch-scope.d.ts.map +1 -0
- package/lib/browser/di/browser-action-dispatch-scope.js +77 -0
- package/lib/browser/di/browser-action-dispatch-scope.js.map +1 -0
- package/lib/browser/index.d.ts +2 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +2 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/common/actions/action-dispatcher.d.ts +107 -5
- package/lib/common/actions/action-dispatcher.d.ts.map +1 -1
- package/lib/common/actions/action-dispatcher.js +205 -26
- package/lib/common/actions/action-dispatcher.js.map +1 -1
- package/lib/common/actions/client-action-handler.d.ts +1 -1
- package/lib/common/actions/client-action-handler.js +2 -2
- package/lib/common/actions/client-action-handler.js.map +1 -1
- package/lib/common/actions/global-action-provider.d.ts.map +1 -1
- package/lib/common/actions/global-action-provider.js +2 -3
- package/lib/common/actions/global-action-provider.js.map +1 -1
- package/lib/common/di/client-session-module.d.ts +8 -1
- package/lib/common/di/client-session-module.d.ts.map +1 -1
- package/lib/common/di/client-session-module.js +9 -1
- package/lib/common/di/client-session-module.js.map +1 -1
- package/lib/common/di/server-module.d.ts +3 -2
- package/lib/common/di/server-module.d.ts.map +1 -1
- package/lib/common/di/server-module.js +5 -1
- package/lib/common/di/server-module.js.map +1 -1
- package/lib/common/di/service-identifiers.d.ts +1 -1
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.d.ts +1 -1
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js +1 -2
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +6 -4
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +7 -5
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/request-model-action-handler.d.ts +1 -1
- package/lib/common/features/model/request-model-action-handler.js +1 -1
- package/lib/common/features/progress/progress-service.js +1 -1
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +3 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.d.ts +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.js +4 -1
- package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
- package/lib/common/operations/create-operation-handler.d.ts +8 -2
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/create-operation-handler.js +16 -2
- package/lib/common/operations/create-operation-handler.js.map +1 -1
- package/lib/common/protocol/glsp-server.d.ts +10 -3
- package/lib/common/protocol/glsp-server.d.ts.map +1 -1
- package/lib/common/protocol/glsp-server.js +58 -6
- package/lib/common/protocol/glsp-server.js.map +1 -1
- package/lib/common/session/client-session-manager.d.ts +8 -1
- package/lib/common/session/client-session-manager.d.ts.map +1 -1
- package/lib/common/session/client-session-manager.js +4 -1
- package/lib/common/session/client-session-manager.js.map +1 -1
- package/lib/common/utils/action-queue.d.ts +58 -0
- package/lib/common/utils/action-queue.d.ts.map +1 -0
- package/lib/common/utils/action-queue.js +99 -0
- package/lib/common/utils/action-queue.js.map +1 -0
- package/lib/common/utils/promise-queue.d.ts +5 -1
- package/lib/common/utils/promise-queue.d.ts.map +1 -1
- package/lib/common/utils/promise-queue.js +5 -1
- package/lib/common/utils/promise-queue.js.map +1 -1
- package/lib/node/di/app-module.d.ts +1 -1
- package/lib/node/di/app-module.d.ts.map +1 -1
- package/lib/node/di/app-module.js +2 -0
- package/lib/node/di/app-module.js.map +1 -1
- package/lib/node/di/node-action-dispatch-scope.d.ts +26 -0
- package/lib/node/di/node-action-dispatch-scope.d.ts.map +1 -0
- package/lib/node/di/node-action-dispatch-scope.js +45 -0
- package/lib/node/di/node-action-dispatch-scope.js.map +1 -0
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -1
- package/lib/node/index.js.map +1 -1
- package/package.json +4 -4
- package/src/browser/di/app-module.ts +6 -2
- package/src/browser/di/browser-action-dispatch-scope.spec.ts +75 -0
- package/src/browser/di/browser-action-dispatch-scope.ts +67 -0
- package/src/browser/index.ts +2 -1
- package/src/common/actions/action-dispatcher.ts +298 -25
- package/src/common/actions/client-action-handler.ts +2 -2
- package/src/common/actions/global-action-provider.ts +3 -4
- package/src/common/command/recording-command.spec.ts +1 -2
- package/src/common/di/client-session-module.ts +9 -1
- package/src/common/di/server-module.ts +9 -2
- package/src/common/di/service-identifiers.ts +1 -1
- package/src/common/features/clipboard/request-clipboard-data-action-handler.ts +2 -2
- package/src/common/features/contextactions/context-actions-provider-registry.spec.ts +2 -2
- package/src/common/features/layout/computed-bounds-action-handler.ts +6 -3
- package/src/common/features/model/model-submission-handler.ts +8 -5
- package/src/common/features/model/request-model-action-handler.ts +1 -1
- package/src/common/features/progress/progress-service.ts +1 -1
- package/src/common/index.ts +3 -1
- package/src/common/launch/jsonrpc-server-launcher.ts +4 -1
- package/src/common/operations/create-operation-handler.ts +16 -3
- package/src/common/protocol/glsp-server.ts +64 -3
- package/src/common/session/client-session-manager.ts +12 -1
- package/src/common/test/mock-util.ts +21 -3
- package/src/common/utils/action-queue.spec.ts +133 -0
- package/src/common/utils/action-queue.ts +107 -0
- package/src/common/utils/promise-queue.spec.ts +6 -2
- package/src/common/utils/promise-queue.ts +5 -1
- package/src/node/actions/action-dispatcher.spec.ts +678 -0
- package/src/node/di/app-module.ts +4 -2
- package/src/node/di/node-action-dispatch-scope.ts +35 -0
- package/src/node/index.ts +2 -1
- package/src/common/actions/action-dispatcher.spec.ts +0 -291
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-module.d.ts","sourceRoot":"","sources":["../../../src/browser/di/app-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"app-module.d.ts","sourceRoot":"","sources":["../../../src/browser/di/app-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAqD,mBAAmB,EAA0B,MAAM,eAAe,CAAC;AAG/H,wBAAgB,eAAe,CAAC,OAAO,GAAE,mBAAwB,GAAG,eAAe,CAUlF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2022-
|
|
3
|
+
* Copyright (c) 2022-2026 EclipseSource and others.
|
|
4
4
|
*
|
|
5
5
|
* This program and the accompanying materials are made available under the
|
|
6
6
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -18,10 +18,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.createAppModule = createAppModule;
|
|
19
19
|
const inversify_1 = require("inversify");
|
|
20
20
|
const common_1 = require("../../common/");
|
|
21
|
+
const browser_action_dispatch_scope_1 = require("./browser-action-dispatch-scope");
|
|
21
22
|
function createAppModule(options = {}) {
|
|
22
23
|
const resolvedOptions = { consoleLog: true, logLevel: common_1.LogLevel.info, ...options };
|
|
23
24
|
return new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
|
|
24
25
|
bind(common_1.InjectionContainer).toDynamicValue(dynamicContext => dynamicContext.container);
|
|
26
|
+
// Transient on purpose: a singleton at the server-container level would be shared across
|
|
27
|
+
// sessions and leak the browser flag between them.
|
|
28
|
+
bind(common_1.ActionDispatchScope).to(browser_action_dispatch_scope_1.BrowserActionDispatchScope);
|
|
25
29
|
const context = { bind, unbind, isBound, rebind };
|
|
26
30
|
(0, common_1.configureConsoleLogger)(context, resolvedOptions);
|
|
27
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-module.js","sourceRoot":"","sources":["../../../src/browser/di/app-module.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;
|
|
1
|
+
{"version":3,"file":"app-module.js","sourceRoot":"","sources":["../../../src/browser/di/app-module.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;AAMlF,0CAUC;AAdD,yCAA4C;AAC5C,0CAA+H;AAC/H,mFAA6E;AAE7E,SAAgB,eAAe,CAAC,UAA+B,EAAE;IAC7D,MAAM,eAAe,GAAwB,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAQ,CAAC,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IACvG,OAAO,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QACzD,IAAI,CAAC,2BAAkB,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACpF,yFAAyF;QACzF,mDAAmD;QACnD,IAAI,CAAC,4BAAmB,CAAC,CAAC,EAAE,CAAC,0DAA0B,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAClD,IAAA,+BAAsB,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Action } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { ActionDispatchScope } from '../../common/actions/action-dispatcher';
|
|
18
|
+
/**
|
|
19
|
+
* Browser-compatible {@link ActionDispatchScope} backed by a single boolean flag, used because
|
|
20
|
+
* available `AsyncLocalStorage` polyfills do not work reliably across browser engines (e.g. V8).
|
|
21
|
+
*
|
|
22
|
+
* The flag cannot distinguish "still inside the handler's async continuation" from "unrelated
|
|
23
|
+
* event fired during the handler's await". Any dispatch arriving in such a gap is observed as
|
|
24
|
+
* reentrant and routed inline. Client-originated actions are explicitly treated as non-reentrant
|
|
25
|
+
* to cover the dominant case, but server-side dispatches from non-handler contexts (timer
|
|
26
|
+
* callbacks, event listeners, adopter code) cannot be filtered this way and may interleave with
|
|
27
|
+
* the in-flight handler.
|
|
28
|
+
*
|
|
29
|
+
* The dispatcher normally serializes handler execution; the inline interleaving breaks that
|
|
30
|
+
* guarantee. A handler that pauses on `await` may resume to find that another handler has mutated
|
|
31
|
+
* state in between (model state, command stack, caches), leading to unexpected behavior.
|
|
32
|
+
* Avoid dispatching from non-handler contexts where possible.
|
|
33
|
+
*/
|
|
34
|
+
export declare class BrowserActionDispatchScope implements ActionDispatchScope {
|
|
35
|
+
protected active: boolean;
|
|
36
|
+
enter<R>(callback: () => R): R;
|
|
37
|
+
isReentrant(action: Action): boolean;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=browser-action-dispatch-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-action-dispatch-scope.d.ts","sourceRoot":"","sources":["../../../src/browser/di/browser-action-dispatch-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAG7E;;;;;;;;;;;;;;;GAeG;AACH,qBACa,0BAA2B,YAAW,mBAAmB;IAClE,SAAS,CAAC,MAAM,UAAS;IAIzB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC;IAoB9B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAGvC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.BrowserActionDispatchScope = void 0;
|
|
25
|
+
const inversify_1 = require("inversify");
|
|
26
|
+
const client_action_1 = require("../../common/protocol/client-action");
|
|
27
|
+
/**
|
|
28
|
+
* Browser-compatible {@link ActionDispatchScope} backed by a single boolean flag, used because
|
|
29
|
+
* available `AsyncLocalStorage` polyfills do not work reliably across browser engines (e.g. V8).
|
|
30
|
+
*
|
|
31
|
+
* The flag cannot distinguish "still inside the handler's async continuation" from "unrelated
|
|
32
|
+
* event fired during the handler's await". Any dispatch arriving in such a gap is observed as
|
|
33
|
+
* reentrant and routed inline. Client-originated actions are explicitly treated as non-reentrant
|
|
34
|
+
* to cover the dominant case, but server-side dispatches from non-handler contexts (timer
|
|
35
|
+
* callbacks, event listeners, adopter code) cannot be filtered this way and may interleave with
|
|
36
|
+
* the in-flight handler.
|
|
37
|
+
*
|
|
38
|
+
* The dispatcher normally serializes handler execution; the inline interleaving breaks that
|
|
39
|
+
* guarantee. A handler that pauses on `await` may resume to find that another handler has mutated
|
|
40
|
+
* state in between (model state, command stack, caches), leading to unexpected behavior.
|
|
41
|
+
* Avoid dispatching from non-handler contexts where possible.
|
|
42
|
+
*/
|
|
43
|
+
let BrowserActionDispatchScope = class BrowserActionDispatchScope {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.active = false;
|
|
46
|
+
}
|
|
47
|
+
// Assumes serial invocation by the dispatcher's queue processor; concurrent enter() calls
|
|
48
|
+
// would corrupt the prior-restore logic and leave the flag stuck.
|
|
49
|
+
enter(callback) {
|
|
50
|
+
const prior = this.active;
|
|
51
|
+
this.active = true;
|
|
52
|
+
let result;
|
|
53
|
+
try {
|
|
54
|
+
result = callback();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.active = prior;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
if (result instanceof Promise) {
|
|
61
|
+
// Cast required because TS cannot prove the .finally() result matches the generic R.
|
|
62
|
+
return result.finally(() => {
|
|
63
|
+
this.active = prior;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
this.active = prior;
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
isReentrant(action) {
|
|
70
|
+
return this.active && !client_action_1.ClientAction.is(action);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.BrowserActionDispatchScope = BrowserActionDispatchScope;
|
|
74
|
+
exports.BrowserActionDispatchScope = BrowserActionDispatchScope = __decorate([
|
|
75
|
+
(0, inversify_1.injectable)()
|
|
76
|
+
], BrowserActionDispatchScope);
|
|
77
|
+
//# sourceMappingURL=browser-action-dispatch-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-action-dispatch-scope.js","sourceRoot":"","sources":["../../../src/browser/di/browser-action-dispatch-scope.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAGlF,yCAAuC;AAEvC,uEAAmE;AAEnE;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QACO,WAAM,GAAG,KAAK,CAAC;IA2B7B,CAAC;IAzBG,0FAA0F;IAC1F,kEAAkE;IAClE,KAAK,CAAI,QAAiB;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,MAAS,CAAC;QACd,IAAI,CAAC;YACD,MAAM,GAAG,QAAQ,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,MAAM,KAAK,CAAC;QAChB,CAAC;QACD,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC5B,qFAAqF;YACrF,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;gBACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACxB,CAAC,CAAiB,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,WAAW,CAAC,MAAc;QACtB,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,4BAAY,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AA5BY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,sBAAU,GAAE;GACA,0BAA0B,CA4BtC"}
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
export * from './di/app-module';
|
|
17
|
+
export * from './di/browser-action-dispatch-scope';
|
|
17
18
|
export * from './launch/worker-server-launcher';
|
|
18
19
|
export * from './reexport';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,YAAY,CAAC"}
|
package/lib/browser/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
/********************************************************************************
|
|
18
|
-
* Copyright (c) 2022-
|
|
18
|
+
* Copyright (c) 2022-2026 EclipseSource and others.
|
|
19
19
|
*
|
|
20
20
|
* This program and the accompanying materials are made available under the
|
|
21
21
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
31
31
|
********************************************************************************/
|
|
32
32
|
__exportStar(require("./di/app-module"), exports);
|
|
33
|
+
__exportStar(require("./di/browser-action-dispatch-scope"), exports);
|
|
33
34
|
__exportStar(require("./launch/worker-server-launcher"), exports);
|
|
34
35
|
__exportStar(require("./reexport"), exports);
|
|
35
36
|
//# sourceMappingURL=index.js.map
|
package/lib/browser/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,kDAAgC;AAChC,kEAAgD;AAChD,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,kDAAgC;AAChC,qEAAmD;AACnD,kEAAgD;AAChD,6CAA2B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2026 STMicroelectronics and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action, Disposable, MaybeArray } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { Action, Deferred, Disposable, MaybeArray, RequestAction, ResponseAction } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { ActionQueue } from '../utils/action-queue';
|
|
17
18
|
import { Logger } from '../utils/logger';
|
|
18
|
-
import { PromiseQueue } from '../utils/promise-queue';
|
|
19
19
|
import { ActionHandler } from './action-handler';
|
|
20
20
|
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
21
21
|
import { ClientActionForwarder } from './client-action-handler';
|
|
@@ -27,6 +27,8 @@ export declare const ActionDispatcher: unique symbol;
|
|
|
27
27
|
export interface ActionDispatcher {
|
|
28
28
|
/**
|
|
29
29
|
* Processes the given action by dispatching it to all registered handlers.
|
|
30
|
+
* Responses matching a pending {@link request} short-circuit and resolve that
|
|
31
|
+
* request without being passed to handlers.
|
|
30
32
|
*
|
|
31
33
|
* @param action The action that should be dispatched.
|
|
32
34
|
* @returns A promise indicating when the action processing is complete.
|
|
@@ -49,20 +51,120 @@ export interface ActionDispatcher {
|
|
|
49
51
|
*/
|
|
50
52
|
dispatchAfterNextUpdate(actions: Action[]): void;
|
|
51
53
|
dispatchAfterNextUpdate(...actions: Action[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* Dispatches a request action and returns a promise that resolves when a matching response
|
|
56
|
+
* action is dispatched or rejects if the response is a {@link RejectAction}. The response is
|
|
57
|
+
* _not_ passed to the registered action handlers. Instead, it is the responsibility of the
|
|
58
|
+
* caller of this method to handle the response properly.
|
|
59
|
+
*
|
|
60
|
+
* If the request's `kind` is registered in `ClientActionKinds`, it is forwarded to the client
|
|
61
|
+
* via {@link ClientActionForwarder}. If server-side handlers are registered, they are also
|
|
62
|
+
* executed.
|
|
63
|
+
*
|
|
64
|
+
* Only the first matching response resolves the request. Any additional or late responses
|
|
65
|
+
* are dispatched as normal actions.
|
|
66
|
+
*
|
|
67
|
+
* The promise waits indefinitely until a response arrives or the dispatcher is disposed.
|
|
68
|
+
* Use {@link requestUntil} if a timeout is needed.
|
|
69
|
+
*
|
|
70
|
+
* Note: mutates `action.requestId` (if unset) and `action.timeout`.
|
|
71
|
+
*
|
|
72
|
+
* @param action The request action to dispatch.
|
|
73
|
+
* @returns A promise that resolves with the matching response action.
|
|
74
|
+
*/
|
|
75
|
+
request<Res extends ResponseAction>(action: RequestAction<Res>): Promise<Res>;
|
|
76
|
+
/**
|
|
77
|
+
* Dispatches a request and waits for a response until the timeout given in `timeoutMs` has
|
|
78
|
+
* been reached. The returned promise is resolved when a response with a matching identifier
|
|
79
|
+
* is dispatched or when the timeout has been reached. That response is _not_ passed to the
|
|
80
|
+
* registered action handlers. Instead, it is the responsibility of the caller of this method
|
|
81
|
+
* to handle the response properly.
|
|
82
|
+
* If `rejectOnTimeout` is set to `false` (default) the returned promise will be resolved with
|
|
83
|
+
* no value, otherwise it will be rejected.
|
|
84
|
+
*
|
|
85
|
+
* Note: mutates `action.requestId` (if unset) and `action.timeout`.
|
|
86
|
+
*
|
|
87
|
+
* @param action The request action to dispatch.
|
|
88
|
+
* @param timeoutMs Maximum wait time in milliseconds. Defaults to
|
|
89
|
+
* {@link RequestAction.timeout} if set, otherwise 2000 ms.
|
|
90
|
+
* @param rejectOnTimeout Whether to reject the promise on timeout.
|
|
91
|
+
* @returns The matching response, or `undefined` on soft timeout.
|
|
92
|
+
*/
|
|
93
|
+
requestUntil<Res extends ResponseAction>(action: RequestAction<Res>, timeoutMs?: number, rejectOnTimeout?: boolean): Promise<Res | undefined>;
|
|
52
94
|
}
|
|
95
|
+
export declare const ActionDispatchScope: unique symbol;
|
|
96
|
+
/**
|
|
97
|
+
* Scope marker that lets the {@link ActionDispatcher} know whether a call to `dispatch()`
|
|
98
|
+
* originates from inside a running handler (reentrant) or from outside (external).
|
|
99
|
+
*
|
|
100
|
+
* The {@link DefaultActionDispatcher.processActionQueue} loop wraps each action in {@link enter}
|
|
101
|
+
* so that reentrant `dispatch()` calls (handler responses, injected dispatcher calls) can be
|
|
102
|
+
* recognized via {@link isReentrant} and executed inline instead of being queued.
|
|
103
|
+
*
|
|
104
|
+
* Used by the {@link DefaultActionDispatcher} implementation.
|
|
105
|
+
*/
|
|
106
|
+
export interface ActionDispatchScope {
|
|
107
|
+
/**
|
|
108
|
+
* Executes the callback inside the dispatch scope. While the callback (and its full async
|
|
109
|
+
* continuation) is running, {@link isReentrant} returns `true` for reentrant calls.
|
|
110
|
+
*/
|
|
111
|
+
enter<R>(callback: () => R): R;
|
|
112
|
+
/**
|
|
113
|
+
* Returns `true` if the given dispatch is reentrant — i.e. it originates from within a
|
|
114
|
+
* running {@link enter} callback (handler response or injected dispatcher call) and should
|
|
115
|
+
* run inline rather than being queued.
|
|
116
|
+
*
|
|
117
|
+
* Implementations may inspect the action to apply additional guards, e.g. to ensure
|
|
118
|
+
* client-originated actions are always queued regardless of scope state.
|
|
119
|
+
*/
|
|
120
|
+
isReentrant(action: Action): boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Default {@link ActionDispatcher}. External dispatches are queued and processed one at a
|
|
124
|
+
* time; dispatches made from within a running handler run inline with the containing action.
|
|
125
|
+
*/
|
|
53
126
|
export declare class DefaultActionDispatcher implements ActionDispatcher, Disposable {
|
|
127
|
+
protected static readonly STALE_TIMEOUT_GRACE_MS = 30000;
|
|
54
128
|
protected actionHandlerRegistry: ActionHandlerRegistry;
|
|
55
129
|
protected clientActionForwarder: ClientActionForwarder;
|
|
56
130
|
protected logger: Logger;
|
|
57
131
|
protected clientId: string;
|
|
58
|
-
protected
|
|
132
|
+
protected dispatchScope: ActionDispatchScope;
|
|
133
|
+
protected actionQueue: ActionQueue<Action>;
|
|
59
134
|
protected postUpdateQueue: Action[];
|
|
135
|
+
protected readonly pendingRequests: Map<string, Deferred<ResponseAction | undefined>>;
|
|
136
|
+
protected readonly requestTimeouts: Map<string, NodeJS.Timeout>;
|
|
137
|
+
protected nextRequestId: number;
|
|
138
|
+
protected initialize(): void;
|
|
139
|
+
protected generateRequestId(): string;
|
|
60
140
|
dispatch(action: Action): Promise<void>;
|
|
141
|
+
protected processActionQueue(): Promise<void>;
|
|
61
142
|
protected doDispatch(action: Action): Promise<void>;
|
|
62
|
-
protected executeHandler(handler: ActionHandler,
|
|
143
|
+
protected executeHandler(handler: ActionHandler, action: Action): Promise<Action[]>;
|
|
63
144
|
protected dispatchResponses(actions: Action[]): Promise<void>;
|
|
64
145
|
dispatchAll(...actions: MaybeArray<Action>[]): Promise<void>;
|
|
65
146
|
dispatchAfterNextUpdate(...actions: MaybeArray<Action>[]): void;
|
|
147
|
+
request<Res extends ResponseAction>(action: RequestAction<Res>): Promise<Res>;
|
|
148
|
+
requestUntil<Res extends ResponseAction>(action: RequestAction<Res>, timeoutMs?: number, rejectOnTimeout?: boolean): Promise<Res | undefined>;
|
|
149
|
+
protected doRequest<Res extends ResponseAction>(action: RequestAction<Res>, timeoutMs: number | undefined, rejectOnTimeout: boolean): Promise<Res | undefined>;
|
|
150
|
+
/**
|
|
151
|
+
* If the given action is a {@link SetModelAction} or {@link UpdateModelAction} and there are actions
|
|
152
|
+
* queued via {@link dispatchAfterNextUpdate}, drain and return them.
|
|
153
|
+
*
|
|
154
|
+
* @returns The drained actions, or an empty array if nothing to drain.
|
|
155
|
+
*/
|
|
156
|
+
protected drainPostUpdateQueue(action: Action): Action[];
|
|
157
|
+
/**
|
|
158
|
+
* Checks whether the given action is a response matching a pending {@link request} or
|
|
159
|
+
* {@link requestUntil} call. If matched, resolves (or rejects) the corresponding deferred
|
|
160
|
+
* and returns `true` so the caller can short-circuit normal dispatch.
|
|
161
|
+
*
|
|
162
|
+
* For responses with a valid `responseId` but no matching pending request, checks for a stale
|
|
163
|
+
* timeout entry (timed-out request) and clears the `responseId` so the action is not forwarded
|
|
164
|
+
* by {@link ClientActionForwarder}. If no stale entry exists, the `responseId` is left intact
|
|
165
|
+
* for normal forwarding.
|
|
166
|
+
*/
|
|
167
|
+
protected interceptPendingResponse(action: Action): boolean;
|
|
66
168
|
dispose(): void;
|
|
67
169
|
}
|
|
68
170
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-dispatcher.d.ts","sourceRoot":"","sources":["../../../src/common/actions/action-dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,EACN,UAAU,EACV,UAAU,
|
|
1
|
+
{"version":3,"file":"action-dispatcher.d.ts","sourceRoot":"","sources":["../../../src/common/actions/action-dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,E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