@hydranium/glsp-client-theia 1.0.0-next.19 → 1.0.0-next.192
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/README.md +36 -13
- package/lib/browser/action-dispatcher.d.ts.map +1 -1
- package/lib/browser/action-dispatcher.js.map +1 -1
- package/lib/browser/client-contribution.d.ts +82 -25
- package/lib/browser/client-contribution.d.ts.map +1 -1
- package/lib/browser/client-contribution.js +218 -53
- package/lib/browser/client-contribution.js.map +1 -1
- package/lib/browser/diagram-loader.d.ts +15 -6
- package/lib/browser/diagram-loader.d.ts.map +1 -1
- package/lib/browser/diagram-loader.js +17 -9
- package/lib/browser/diagram-loader.js.map +1 -1
- package/lib/browser/diagram-only-marker-manager.d.ts.map +1 -1
- package/lib/browser/diagram-only-marker-manager.js.map +1 -1
- package/lib/browser/diagram-widget.d.ts +31 -24
- package/lib/browser/diagram-widget.d.ts.map +1 -1
- package/lib/browser/diagram-widget.js +50 -24
- package/lib/browser/diagram-widget.js.map +1 -1
- package/lib/browser/glsp-client-theia-module.d.ts.map +1 -1
- package/lib/browser/glsp-client-theia-module.js +2 -0
- package/lib/browser/glsp-client-theia-module.js.map +1 -1
- package/lib/browser/glsp-client.d.ts +17 -0
- package/lib/browser/glsp-client.d.ts.map +1 -0
- package/lib/browser/glsp-client.js +23 -0
- package/lib/browser/glsp-client.js.map +1 -0
- package/lib/browser/glsp-diagram-manager.d.ts +44 -0
- package/lib/browser/glsp-diagram-manager.d.ts.map +1 -1
- package/lib/browser/glsp-diagram-manager.js +99 -0
- package/lib/browser/glsp-diagram-manager.js.map +1 -1
- package/lib/browser/glsp-message-service.d.ts +8 -0
- package/lib/browser/glsp-message-service.d.ts.map +1 -1
- package/lib/browser/glsp-message-service.js +8 -0
- package/lib/browser/glsp-message-service.js.map +1 -1
- package/lib/browser/glsp-saveable.d.ts +66 -0
- package/lib/browser/glsp-saveable.d.ts.map +1 -0
- package/lib/browser/glsp-saveable.js +109 -0
- package/lib/browser/glsp-saveable.js.map +1 -0
- package/lib/browser/glsp-theia-frontend-module.d.ts.map +1 -1
- package/lib/browser/glsp-theia-frontend-module.js +1 -0
- package/lib/browser/glsp-theia-frontend-module.js.map +1 -1
- package/lib/browser/hidden-bounds-updater.d.ts +2 -4
- package/lib/browser/hidden-bounds-updater.d.ts.map +1 -1
- package/lib/browser/hidden-bounds-updater.js +7 -3
- package/lib/browser/hidden-bounds-updater.js.map +1 -1
- package/lib/browser/hydranium-glsp-diagram-configuration.d.ts.map +1 -1
- package/lib/browser/hydranium-glsp-diagram-configuration.js.map +1 -1
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +3 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/status-overlay.d.ts +23 -0
- package/lib/browser/status-overlay.d.ts.map +1 -0
- package/lib/browser/status-overlay.js +52 -0
- package/lib/browser/status-overlay.js.map +1 -0
- package/lib/node/connection-container-module.js.map +1 -1
- package/lib/node/glsp-server-connection-handler.d.ts +11 -10
- package/lib/node/glsp-server-connection-handler.d.ts.map +1 -1
- package/lib/node/glsp-server-connection-handler.js +12 -15
- package/lib/node/glsp-server-connection-handler.js.map +1 -1
- package/lib/testing/bind-recorder.js.map +1 -1
- package/package.json +28 -26
- package/src/browser/client-contribution.ts +243 -54
- package/src/browser/diagram-loader.ts +18 -11
- package/src/browser/diagram-widget.ts +58 -27
- package/src/browser/glsp-client-theia-module.ts +3 -1
- package/src/browser/glsp-client.ts +20 -0
- package/src/browser/glsp-diagram-manager.ts +113 -1
- package/src/browser/glsp-message-service.ts +8 -0
- package/src/browser/glsp-saveable.ts +110 -0
- package/src/browser/glsp-theia-frontend-module.ts +2 -1
- package/src/browser/hidden-bounds-updater.ts +5 -6
- package/src/browser/index.ts +8 -0
- package/src/browser/status-overlay.ts +43 -0
- package/src/node/glsp-server-connection-handler.ts +12 -14
- package/style/diagram-loading.css +2 -5
|
@@ -22,38 +22,35 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.GlspServerConnectionHandler = void 0;
|
|
24
24
|
const common_1 = require("@eclipse-glsp/theia-integration/lib/common");
|
|
25
|
-
const node_1 = require("@
|
|
26
|
-
const node_2 = require("@hydranium/client-theia/lib/node");
|
|
25
|
+
const node_1 = require("@hydranium/client-theia/lib/node");
|
|
27
26
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
28
27
|
/**
|
|
29
28
|
* Bridges a Theia browser-frontend channel to a GLSP server's TCP socket.
|
|
30
29
|
*
|
|
31
|
-
* The port
|
|
32
|
-
* on the cross-head
|
|
33
|
-
*
|
|
30
|
+
* The port discovery, the buffer-and-replay race fix, the connect orchestration
|
|
31
|
+
* and the byte forwarder live on the cross-head
|
|
32
|
+
* {@link AbstractSocketForwardingConnectionHandler} base; this subclass supplies
|
|
33
|
+
* only the GLSP specifics — the per-language servicePath
|
|
34
34
|
* (`GLSPContribution.servicePath + '/' + languageContributionId`), the port
|
|
35
|
-
* command, the log labels
|
|
36
|
-
*
|
|
37
|
-
* language ids or command names subclass with a one-line `super({...})` call.
|
|
38
|
-
* Sibling of `@hydranium/data-client-theia`'s `DataServerConnectionHandler`,
|
|
39
|
-
* which subclasses the same base with its own GLSP-free forwarder.
|
|
35
|
+
* command, the log labels. Adopters with different language ids or command
|
|
36
|
+
* names subclass with a one-line `super({...})` call.
|
|
40
37
|
*/
|
|
41
|
-
let GlspServerConnectionHandler = class GlspServerConnectionHandler extends
|
|
38
|
+
let GlspServerConnectionHandler = class GlspServerConnectionHandler extends node_1.AbstractSocketForwardingConnectionHandler {
|
|
42
39
|
constructor(options) {
|
|
43
40
|
super({
|
|
44
41
|
path: common_1.GLSPContribution.servicePath + '/' + options.languageContributionId,
|
|
45
42
|
portCommand: options.portCommand,
|
|
46
43
|
logComponent: 'GLSP',
|
|
47
|
-
serverName: '
|
|
44
|
+
serverName: options.serverName ?? 'Diagram Server',
|
|
48
45
|
findPortTimeout: options.findPortTimeout,
|
|
49
46
|
findPortAttempts: options.findPortAttempts,
|
|
50
47
|
connectTimeoutMs: options.connectTimeoutMs,
|
|
51
48
|
onSocketCreated: options.onSocketCreated
|
|
52
49
|
});
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
51
|
+
/** Logged only: the frontend contribution reports the failed start, and a
|
|
52
|
+
* second notification would duplicate it. */
|
|
53
|
+
reportConnectFailure() { }
|
|
57
54
|
};
|
|
58
55
|
exports.GlspServerConnectionHandler = GlspServerConnectionHandler;
|
|
59
56
|
exports.GlspServerConnectionHandler = GlspServerConnectionHandler = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-server-connection-handler.js","sourceRoot":"","sources":["../../src/node/glsp-server-connection-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;AAElF,uEAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"glsp-server-connection-handler.js","sourceRoot":"","sources":["../../src/node/glsp-server-connection-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;AAElF,uEAA8E;AAC9E,2DAA6F;AAC7F,4DAAqE;AA0BrE;;;;;;;;;;GAUG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,gDAAyC;IACvF,YAAyB,OAA2C;QACjE,KAAK,CAAC;YACH,IAAI,EAAE,yBAAgB,CAAC,WAAW,GAAG,GAAG,GAAG,OAAO,CAAC,sBAAsB;YACzE,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,MAAM;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,gBAAgB;YAClD,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,eAAe,EAAE,OAAO,CAAC,eAAe;SAC1C,CAAC,CAAC;IACN,CAAC;IAED;kDAC8C;IAC3B,oBAAoB,KAAU,CAAC;CACpD,CAAA;;sCAjBY,2BAA2B;IADvC,IAAA,sBAAU,GAAE;IAEG,WAAA,IAAA,qBAAS,GAAE,CAAA;;GADd,2BAA2B,CAiBvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-recorder.js","sourceRoot":"","sources":["../../src/testing/bind-recorder.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"bind-recorder.js","sourceRoot":"","sources":["../../src/testing/bind-recorder.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAqDlF,+EAA+E;AAC/E,MAAM,sBAAsB,GAAG;IAC5B,QAAQ;IACR,IAAI;IACJ,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,cAAc;IACd,gBAAgB;CACT,CAAC;AAEX;;;;;;;;;GASG;AACH,0BAAiC,OAAO,GAAwB,EAAE;IAC/D,MAAM,QAAQ,GAAwB,EAAE,CAAC;IAEzC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE;QAC7C,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAC/B,OAAO,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC;QACpC,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,CAAC,IAAuB,EAAE,KAAc,EAAW,EAAE;QACrE,MAAM,KAAK,GAAsB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QAC5D,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,KAAK,GAAoD,EAAE,CAAC;QAClE,KAAK,MAAM,MAAM,IAAI,sBAAsB,EAAE,CAAC;YAC3C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAe,EAAW,EAAE;gBAC7C,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACpE,OAAO,KAAK,CAAC;YAChB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAoB,CAAC;IAChF,MAAM,MAAM,GAAG,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAsB,CAAC;IACtF,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,SAAS,CAAiC,CAAC;IACjE,MAAM,OAAO,GAAG,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAuB,CAAC;IACzG,MAAM,IAAI,GAAG,CAAC,IAAuB,EAAE,KAAc,EAAiC,EAAE,CACrF,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IAExE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/glsp-client-theia",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.192",
|
|
4
4
|
"description": "Theia-coupled client primitives for GLSP heads built on @hydranium/glsp-server. Provides the action dispatcher, channel logger, and connection-handler bases that Theia-based adopters extend; companion of @hydranium/glsp-server.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"diagram",
|
|
7
|
+
"glsp",
|
|
6
8
|
"hydranium",
|
|
7
9
|
"langium",
|
|
8
10
|
"language-server",
|
|
9
11
|
"lsp",
|
|
10
|
-
"glsp",
|
|
11
|
-
"diagram",
|
|
12
12
|
"theia"
|
|
13
13
|
],
|
|
14
14
|
"homepage": "https://github.com/eclipse-emfcloud/hydranium/tree/main/packages/glsp-client-theia",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/eclipse-emfcloud/hydranium/issues"
|
|
17
17
|
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Hydranium Team"
|
|
21
|
+
},
|
|
18
22
|
"repository": {
|
|
19
23
|
"type": "git",
|
|
20
24
|
"url": "https://github.com/eclipse-emfcloud/hydranium.git",
|
|
21
25
|
"directory": "packages/glsp-client-theia"
|
|
22
26
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
+
"files": [
|
|
28
|
+
"lib",
|
|
29
|
+
"src",
|
|
30
|
+
"style",
|
|
31
|
+
"!lib/**/*.tsbuildinfo"
|
|
32
|
+
],
|
|
27
33
|
"sideEffects": [
|
|
28
34
|
"**/*.css"
|
|
29
35
|
],
|
|
36
|
+
"main": "lib/index.js",
|
|
37
|
+
"types": "lib/index.d.ts",
|
|
30
38
|
"exports": {
|
|
31
39
|
".": {
|
|
32
40
|
"types": "./lib/index.d.ts",
|
|
@@ -58,18 +66,13 @@
|
|
|
58
66
|
},
|
|
59
67
|
"./style/diagram-loading.css": "./style/diagram-loading.css"
|
|
60
68
|
},
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"lib",
|
|
65
|
-
"src",
|
|
66
|
-
"style",
|
|
67
|
-
"!lib/**/*.tsbuildinfo"
|
|
68
|
-
],
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
69
72
|
"scripts": {
|
|
70
73
|
"build": "tsc -b",
|
|
71
74
|
"clean": "rimraf lib tsconfig.tsbuildinfo",
|
|
72
|
-
"lint": "
|
|
75
|
+
"lint": "oxlint --format stylish --config ../../oxlint.config.cjs src test --max-warnings 0",
|
|
73
76
|
"prepack": "node -e \"const m=require('./package.json'),fs=require('node:fs');const missing=[m.main,...Object.values(m.bin||{})].filter(entry=>entry&&!fs.existsSync(entry));if(missing.length){console.error('prepack '+m.name+': not built ('+missing.join(', ')+' missing). Run the build before packing: a files entry that matches nothing is skipped silently, so the tarball would ship src only.');process.exit(1);}\"",
|
|
74
77
|
"test": "npm run typecheck:test && vitest run",
|
|
75
78
|
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
|
|
@@ -77,26 +80,28 @@
|
|
|
77
80
|
},
|
|
78
81
|
"devDependencies": {
|
|
79
82
|
"@eclipse-glsp/client": "2.7.0",
|
|
83
|
+
"@eclipse-glsp/server": "2.7.0",
|
|
80
84
|
"@eclipse-glsp/theia-integration": "2.7.0",
|
|
81
|
-
"@hydranium/client-theia": "1.0.0-next.
|
|
82
|
-
"@hydranium/
|
|
85
|
+
"@hydranium/client-theia": "1.0.0-next.192",
|
|
86
|
+
"@hydranium/core": "1.0.0-next.192",
|
|
87
|
+
"@hydranium/glsp-server": "1.0.0-next.192",
|
|
88
|
+
"@hydranium/protocol": "1.0.0-next.192",
|
|
83
89
|
"@theia/core": "^1.70.0",
|
|
84
|
-
"@theia/output": "^1.70.0",
|
|
85
90
|
"@theia/process": "^1.70.0",
|
|
86
91
|
"@theia/workspace": "^1.70.0",
|
|
87
92
|
"@types/node": "^22.0.0",
|
|
88
93
|
"inversify": "6.2.2",
|
|
94
|
+
"reflect-metadata": "0.2.2",
|
|
89
95
|
"rimraf": "^5.0.0",
|
|
90
96
|
"snabbdom": "3.5.1",
|
|
91
|
-
"typescript": "^
|
|
97
|
+
"typescript": "^7.0.2"
|
|
92
98
|
},
|
|
93
99
|
"peerDependencies": {
|
|
94
100
|
"@eclipse-glsp/client": "^2.6.0",
|
|
95
101
|
"@eclipse-glsp/theia-integration": "^2.6.0",
|
|
96
|
-
"@hydranium/client-theia": "1.0.0-next.
|
|
97
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
102
|
+
"@hydranium/client-theia": "1.0.0-next.192",
|
|
103
|
+
"@hydranium/protocol": "1.0.0-next.192",
|
|
98
104
|
"@theia/core": "^1.70.0",
|
|
99
|
-
"@theia/output": "^1.70.0",
|
|
100
105
|
"@theia/process": "^1.70.0",
|
|
101
106
|
"@theia/workspace": "^1.70.0",
|
|
102
107
|
"inversify": "^6.0.0",
|
|
@@ -105,9 +110,6 @@
|
|
|
105
110
|
"engines": {
|
|
106
111
|
"node": ">=22.13"
|
|
107
112
|
},
|
|
108
|
-
"publishConfig": {
|
|
109
|
-
"access": "public"
|
|
110
|
-
},
|
|
111
113
|
"//exports": "The stylesheet key is an ASSET entry, not a module subpath, and it is spelled as the exact filename rather than `./style/*` so nothing becomes reachable automatically — the same no-wildcard property every other key here has. It exists because the widget's own import is package-RELATIVE, which `exports` does not gate, so the map's silence broke nobody inside the package while blocking every adopter who wants to `@import` the sheet, re-bundle it or override it by specifier; that failure reads as \"not exported under the conditions\" rather than as a missing entry. It has NO `./lib/style/...` twin, and must not grow one: the twin rule exists so a bare subpath is reachable from a node10 MODULE resolver, `tsc` emits no assets so there is no `lib/style/` to point at, and a bundler — which is what resolves a stylesheet — reads the map. `check:exports` carves out exactly this shape and asserts instead that the target file exists and is covered by `files`, which is the pair of mistakes an asset key can actually make.",
|
|
112
114
|
"//prepack": "The publish guard, and it deliberately is NOT a `prepare`: npm runs a workspace `prepare` BEFORE the root `postinstall` that applies patches/vscode-jsonrpc+9.0.1.patch, so building there fails on a cold clone and npm rolls the entire install back. `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. It FAILS rather than rebuilds, because the rebuild is exactly the part that ordering defeats. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error.",
|
|
113
115
|
"//sideEffects": "A stylesheet IS the side effect: `style/diagram-loading.css` is pulled in by a bare import in `browser/diagram-widget.js`, and a CSS module exports nothing, so under a blanket `false` a bundler drops the import as unused and the diagram loading overlay renders unstyled. Nothing fails at build time. The glob rather than the importing module, so a second stylesheet is covered without another edit; the widget itself is reached through its exported class and needs no flag."
|
|
@@ -7,94 +7,283 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import { type GLSPClient } from '@eclipse-glsp/client';
|
|
10
|
+
import { ClientState, type GLSPClient, type InitializeResult } from '@eclipse-glsp/client';
|
|
11
11
|
import { BaseGLSPClientContribution } from '@eclipse-glsp/theia-integration';
|
|
12
|
+
import { createChannelConnection, GLSPContribution } from '@eclipse-glsp/theia-integration/lib/common';
|
|
13
|
+
import { ChannelLogger, ConnectionReporter, type ConnectionTarget } from '@hydranium/client-theia/lib/browser';
|
|
14
|
+
import { type Channel, Disposable, Emitter, Event, nls } from '@theia/core';
|
|
12
15
|
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
13
16
|
import { inject, injectable, unmanaged } from '@theia/core/shared/inversify';
|
|
14
|
-
import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
|
|
15
17
|
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
18
|
+
import { HydraniumGlspClient } from './glsp-client';
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* "the GLSP server is accepting client connections". */
|
|
20
|
+
export const DEFAULT_GLSP_CLIENT_STARTUP_TIMEOUT_MS = 30_000;
|
|
21
|
+
|
|
22
|
+
/** Options for `HydraniumGlspClientContribution`. */
|
|
21
23
|
export interface ClientContributionOptions {
|
|
22
24
|
readonly languageContributionId: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
/** How long a start may take, from the workspace opening to the server
|
|
26
|
+
* answering `initializeServer`, before it fails; `0` or less waits for good. */
|
|
27
|
+
readonly startupTimeoutMs?: number;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Theia GLSP client contribution for adopters whose GLSP server runs in a
|
|
29
32
|
* sideloaded VS Code extension process (or any other deferred-start setup).
|
|
30
|
-
* The behaviours adopters reliably need are lifted:
|
|
31
33
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* "connecting" progress spinner) from firing prematurely.
|
|
34
|
+
* The client starts once a workspace is open and sends its first request at
|
|
35
|
+
* once; the backend handler holds it until its socket to the server is up. A
|
|
36
|
+
* start that fails, and a connection lost after one succeeded, start a fresh
|
|
37
|
+
* client after a backoff, for as long as the contribution lives. Each start is
|
|
38
|
+
* reported through the {@link ConnectionReporter}, and announced through
|
|
39
|
+
* {@link onDidStartClient} and {@link onDidLoseClient}.
|
|
39
40
|
*
|
|
40
41
|
* A `GLSPClient` override filtering inbound messages by clientId is
|
|
41
42
|
* deliberately NOT provided: upstream's `BaseJsonrpcGLSPClient.onActionMessage`
|
|
42
|
-
* already filters by clientId
|
|
43
|
-
* `BaseGLSPClientContribution.createGLSPClient` is correct as-is.
|
|
43
|
+
* already filters by clientId.
|
|
44
44
|
*/
|
|
45
45
|
@injectable()
|
|
46
46
|
export class HydraniumGlspClientContribution extends BaseGLSPClientContribution {
|
|
47
|
-
@inject(OutputChannelManager) protected outputChannelManager!: OutputChannelManager;
|
|
48
47
|
@inject(WorkspaceService) protected readonly workspaceService!: WorkspaceService;
|
|
48
|
+
@inject(ConnectionReporter) protected readonly connectionReporter!: ConnectionReporter;
|
|
49
|
+
@inject(ChannelLogger) protected readonly logger!: ChannelLogger;
|
|
49
50
|
|
|
50
51
|
readonly id: string;
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
/** Delay before the restart following each consecutive failed start or lost
|
|
54
|
+
* client; the last repeats. */
|
|
55
|
+
protected readonly restartDelaysMs: readonly number[] = [1_000, 2_000, 4_000, 8_000];
|
|
56
|
+
/** How long a client must stay up before the restart delays start over, so
|
|
57
|
+
* a server that fails right after starting is not restarted at once. */
|
|
58
|
+
protected readonly restartEscalationResetMs: number = 30_000;
|
|
59
|
+
protected consecutiveFailures = 0;
|
|
60
|
+
protected restartTimer?: ReturnType<typeof setTimeout>;
|
|
61
|
+
/** When the current client started; `0` once a restart has taken it into account. */
|
|
62
|
+
protected startedAt = 0;
|
|
63
|
+
/** Clients started so far, which numbers them in the log: they share {@link id}. */
|
|
64
|
+
protected startedClients = 0;
|
|
65
|
+
/** The attempt waiting for a channel, if any. */
|
|
66
|
+
protected channelRequest?: Deferred<Channel>;
|
|
67
|
+
protected disposed = false;
|
|
68
|
+
protected readonly clientStartedEmitter = new Emitter<GLSPClient>();
|
|
69
|
+
protected readonly clientLostEmitter = new Emitter<void>();
|
|
70
|
+
|
|
71
|
+
/** Fires with each client once it has started and its server has answered. */
|
|
72
|
+
readonly onDidStartClient: Event<GLSPClient> = this.clientStartedEmitter.event;
|
|
73
|
+
/** Fires when the started client stops; {@link glspClient} already waits
|
|
74
|
+
* for its replacement then. */
|
|
75
|
+
readonly onDidLoseClient: Event<void> = this.clientLostEmitter.event;
|
|
53
76
|
|
|
54
77
|
constructor(@unmanaged() options: ClientContributionOptions) {
|
|
55
78
|
super();
|
|
56
79
|
this.id = options.languageContributionId;
|
|
57
|
-
this.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
this.glspClientStartupTimeout = options.startupTimeoutMs ?? DEFAULT_GLSP_CLIENT_STARTUP_TIMEOUT_MS;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The client every diagram load awaits; after a failed start, a fresh one. */
|
|
84
|
+
override get glspClient(): Promise<GLSPClient> {
|
|
85
|
+
return this.glspClientDeferred.state === 'rejected' ? this.restart() : this.glspClientDeferred.promise;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Start a fresh client over a fresh channel at once, if the last start failed. */
|
|
89
|
+
restart(): Promise<GLSPClient> {
|
|
90
|
+
if (!this.disposed && this.glspClientDeferred.state === 'rejected') {
|
|
91
|
+
this.replaceClient();
|
|
92
|
+
void this.activateClient();
|
|
93
|
+
}
|
|
94
|
+
return this.glspClientDeferred.promise;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Point {@link glspClient} at a fresh client still to start, and tear down
|
|
98
|
+
* the old one's channel. */
|
|
99
|
+
protected replaceClient(): void {
|
|
100
|
+
clearTimeout(this.restartTimer);
|
|
101
|
+
// Replaced before the old channel goes, so the old client stopping is
|
|
102
|
+
// not taken for a loss of the new one.
|
|
103
|
+
this.glspClientDeferred = new Deferred<GLSPClient>();
|
|
104
|
+
this.toDispose.dispose();
|
|
105
|
+
// Upstream refuses to open a channel while the collection is disposed.
|
|
106
|
+
this.toDispose.push(Disposable.NULL);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Settles the promise current when it began, so a start a restart overtook
|
|
110
|
+
* cannot settle its successor. */
|
|
111
|
+
protected override async activateClient(): Promise<void> {
|
|
112
|
+
const pending = this.glspClientDeferred;
|
|
113
|
+
await this.workspaceOpened();
|
|
114
|
+
if (this.disposed) {
|
|
69
115
|
return;
|
|
70
116
|
}
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
117
|
+
const attempt = this.connectionReporter.connecting(this.connectionTarget);
|
|
118
|
+
const timeout =
|
|
119
|
+
this.glspClientStartupTimeout > 0
|
|
120
|
+
? setTimeout(() => pending.reject(new Error(this.startupTimeoutMessage())), this.glspClientStartupTimeout)
|
|
121
|
+
: undefined;
|
|
122
|
+
pending.promise.then(
|
|
123
|
+
client => {
|
|
124
|
+
clearTimeout(timeout);
|
|
125
|
+
attempt.connected();
|
|
126
|
+
this.startedAt = Date.now();
|
|
127
|
+
this.logger.info(`[${this.id}] Diagram client ${++this.startedClients} started.`);
|
|
128
|
+
this.clientStartedEmitter.fire(client);
|
|
129
|
+
this.restartOnLoss(client);
|
|
130
|
+
},
|
|
131
|
+
(error: unknown) => {
|
|
132
|
+
clearTimeout(timeout);
|
|
133
|
+
if (this.disposed) {
|
|
134
|
+
attempt.cancelled();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
attempt.failed(error instanceof Error ? error.message : String(error), () => void this.restart());
|
|
138
|
+
this.scheduleRestart(() => {
|
|
139
|
+
if (this.glspClientDeferred === pending) {
|
|
140
|
+
void this.restart();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
try {
|
|
146
|
+
const connection = await this.createConnection();
|
|
147
|
+
// Ahead of the client's own listener, whose teardown rejects with a
|
|
148
|
+
// transport message instead.
|
|
149
|
+
connection.onClose(() => pending.reject(new Error(this.unreachableMessage())));
|
|
150
|
+
const client = await this.createGLSPClient(connection);
|
|
151
|
+
connection.onDispose(() => client.stop());
|
|
152
|
+
await this.start(client);
|
|
153
|
+
pending.resolve(client);
|
|
154
|
+
} catch (error: unknown) {
|
|
155
|
+
pending.reject(error);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Run `restart` after the delay for the failures so far, and return that delay. */
|
|
160
|
+
protected scheduleRestart(restart: () => void): number {
|
|
161
|
+
if (this.startedAt > 0 && Date.now() - this.startedAt >= this.restartEscalationResetMs) {
|
|
162
|
+
this.consecutiveFailures = 0;
|
|
163
|
+
}
|
|
164
|
+
this.startedAt = 0;
|
|
165
|
+
const delay = this.restartDelaysMs[Math.min(this.consecutiveFailures, this.restartDelaysMs.length - 1)];
|
|
166
|
+
this.consecutiveFailures++;
|
|
167
|
+
clearTimeout(this.restartTimer);
|
|
168
|
+
this.restartTimer = setTimeout(restart, delay);
|
|
169
|
+
return delay;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Once `client` stops, replace it and start its replacement after the
|
|
173
|
+
* restart delay, unless a dispose stopped it. */
|
|
174
|
+
protected restartOnLoss(client: GLSPClient): void {
|
|
175
|
+
const listener = client.onCurrentStateChanged(state => {
|
|
176
|
+
if (state !== ClientState.ServerError && state !== ClientState.Stopped) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
listener.dispose();
|
|
180
|
+
if (!this.disposed) {
|
|
181
|
+
this.replaceClient();
|
|
182
|
+
this.clientLostEmitter.fire();
|
|
183
|
+
const delay = this.scheduleRestart(() => void this.activateClient());
|
|
184
|
+
// Upstream's client has just logged that it will not be restarted, which holds for it alone.
|
|
185
|
+
this.logger.info(`[${this.id}] Diagram client ${this.startedClients} lost; starting a fresh one in ${delay} ms.`);
|
|
77
186
|
}
|
|
78
187
|
});
|
|
79
|
-
return deferred.promise;
|
|
80
188
|
}
|
|
81
189
|
|
|
190
|
+
/** Start the client and initialize its server, rejecting on failure; the
|
|
191
|
+
* caller settles {@link glspClient}. */
|
|
82
192
|
protected override async start(glspClient: GLSPClient): Promise<void> {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
193
|
+
await glspClient.start();
|
|
194
|
+
await this.initialize(glspClient);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Without upstream's own error notification, which would duplicate the reporter's. */
|
|
198
|
+
protected override async initialize(glspClient: GLSPClient): Promise<InitializeResult> {
|
|
199
|
+
return glspClient.initializeServer(await this.createInitializeParameters());
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Upstream's base client, without the notifications of its Theia subclass,
|
|
203
|
+
* which would duplicate the reporter's. */
|
|
204
|
+
protected override async createGLSPClient(
|
|
205
|
+
connectionProvider: Parameters<BaseGLSPClientContribution['createGLSPClient']>[0]
|
|
206
|
+
): Promise<GLSPClient> {
|
|
207
|
+
return new HydraniumGlspClient({ id: this.id, connectionProvider });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Whichever channel arrives goes to the attempt waiting now, and one that
|
|
212
|
+
* arrives with none waiting is closed. Theia holds each open until its
|
|
213
|
+
* websocket is back, and after an outage every held open past the first
|
|
214
|
+
* throws "already open" without reaching its handler, so the first to arrive
|
|
215
|
+
* has to serve the latest attempt. Without Theia's replay, which would be a
|
|
216
|
+
* second opener of the same path.
|
|
217
|
+
*/
|
|
218
|
+
protected override async createChannelConnection(): ReturnType<BaseGLSPClientContribution['createChannelConnection']> {
|
|
219
|
+
this.channelRequest?.reject(new Error('A newer start took over the channel request.'));
|
|
220
|
+
const request = new Deferred<Channel>();
|
|
221
|
+
this.channelRequest = request;
|
|
222
|
+
this.connectionProvider.listen(
|
|
223
|
+
GLSPContribution.getPath(this),
|
|
224
|
+
(_path, channel) => {
|
|
225
|
+
const waiting = this.channelRequest;
|
|
226
|
+
this.channelRequest = undefined;
|
|
227
|
+
if (waiting && !this.disposed) {
|
|
228
|
+
waiting.resolve(channel);
|
|
229
|
+
} else {
|
|
230
|
+
channel.close();
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
false
|
|
234
|
+
);
|
|
235
|
+
const channel = await request.promise;
|
|
236
|
+
const connection = createChannelConnection(channel);
|
|
237
|
+
this.toDispose.push(Disposable.create(() => this.disposeChannel(connection, channel)));
|
|
238
|
+
return connection;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Also closes the channel: upstream leaves a Theia channel open, and the
|
|
242
|
+
* next one on the same path then cannot open. */
|
|
243
|
+
protected override async disposeChannel(
|
|
244
|
+
connection: Parameters<BaseGLSPClientContribution['disposeChannel']>[0],
|
|
245
|
+
channel: Channel
|
|
246
|
+
): Promise<void> {
|
|
247
|
+
await super.disposeChannel(connection, channel);
|
|
248
|
+
channel.close();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Also fails a start in flight, so nothing reports it after this. */
|
|
252
|
+
override dispose(): void {
|
|
253
|
+
this.disposed = true;
|
|
254
|
+
clearTimeout(this.restartTimer);
|
|
255
|
+
this.glspClientDeferred.promise.catch(() => undefined);
|
|
256
|
+
this.glspClientDeferred.reject(new Error('The diagram client was disposed.'));
|
|
257
|
+
this.clientStartedEmitter.dispose();
|
|
258
|
+
this.clientLostEmitter.dispose();
|
|
259
|
+
super.dispose();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
protected async workspaceOpened(): Promise<void> {
|
|
86
263
|
const roots = this.workspaceService.tryGetRoots();
|
|
87
|
-
if (
|
|
88
|
-
await
|
|
89
|
-
const disposable = this.workspaceService.onWorkspaceChanged(changedRoots => {
|
|
90
|
-
if (changedRoots && changedRoots.length > 0) {
|
|
91
|
-
disposable.dispose();
|
|
92
|
-
resolve();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
264
|
+
if (roots.length === 0) {
|
|
265
|
+
await Event.toPromise(Event.filter(this.workspaceService.onWorkspaceChanged, changedRoots => changedRoots.length > 0));
|
|
96
266
|
}
|
|
97
|
-
|
|
98
|
-
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
protected get connectionTarget(): ConnectionTarget {
|
|
270
|
+
return (this.cachedConnectionTarget ??= {
|
|
271
|
+
connectingMessage: nls.localize('hydranium/glsp-client-theia/diagram-server-connecting', 'Connecting to the diagram server…'),
|
|
272
|
+
connectedMessage: nls.localize('hydranium/glsp-client-theia/diagram-server-connected', 'Connected to the diagram server.')
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/** One object per contribution: the reporter keys what it has shown on it. */
|
|
276
|
+
protected cachedConnectionTarget?: ConnectionTarget;
|
|
277
|
+
|
|
278
|
+
protected unreachableMessage(): string {
|
|
279
|
+
return nls.localize('hydranium/glsp-client-theia/diagram-server-unreachable', 'Could not connect to the diagram server.');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
protected startupTimeoutMessage(): string {
|
|
283
|
+
return nls.localize(
|
|
284
|
+
'hydranium/glsp-client-theia/diagram-server-timeout',
|
|
285
|
+
'The diagram server did not answer within {0} seconds.',
|
|
286
|
+
String(Math.round(this.glspClientStartupTimeout / 1000))
|
|
287
|
+
);
|
|
99
288
|
}
|
|
100
289
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { DiagramLoader, type DiagramLoadingOptions, StatusAction } from '@eclipse-glsp/client';
|
|
11
11
|
import { ChannelLogger } from '@hydranium/client-theia/lib/browser';
|
|
12
12
|
import { Deferred } from '@hydranium/protocol';
|
|
13
|
+
import { nls } from '@theia/core';
|
|
13
14
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -31,8 +32,7 @@ export interface DiagramLoadFailure {
|
|
|
31
32
|
readonly error: unknown;
|
|
32
33
|
/**
|
|
33
34
|
* Whether the `severity: 'ERROR'` {@link StatusAction} reached the action
|
|
34
|
-
* dispatcher
|
|
35
|
-
* failure.
|
|
35
|
+
* dispatcher. It says nothing about whether a status overlay shows it.
|
|
36
36
|
*
|
|
37
37
|
* `false` means the report itself failed, which happens when the action
|
|
38
38
|
* dispatcher is the thing that could not initialize. A consumer that covers
|
|
@@ -101,10 +101,7 @@ export class HydraniumDiagramLoader extends DiagramLoader {
|
|
|
101
101
|
await super.load(options);
|
|
102
102
|
this.settle({ status: 'loaded' });
|
|
103
103
|
} catch (err) {
|
|
104
|
-
// Report first, settle second, and carry whether the report landed
|
|
105
|
-
// consumer that uncovers the canvas on settle then finds the error
|
|
106
|
-
// already on the status overlay — or learns that it has to render the
|
|
107
|
-
// failure itself because nothing else can.
|
|
104
|
+
// Report first, settle second, and carry whether the report landed.
|
|
108
105
|
const surfaced = await this.reportLoadFailure(err);
|
|
109
106
|
this.settle({ status: 'failed', error: err, surfaced });
|
|
110
107
|
}
|
|
@@ -156,13 +153,23 @@ export class HydraniumDiagramLoader extends DiagramLoader {
|
|
|
156
153
|
|
|
157
154
|
/**
|
|
158
155
|
* The sentence a failed load is reported with, on every surface that reports
|
|
159
|
-
* it
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
156
|
+
* it. Public because the canvas overlay is one of those surfaces and lives in
|
|
157
|
+
* another class, where a second copy of the sentence would drift.
|
|
158
|
+
*
|
|
159
|
+
* **The seam and the catalogue key answer different questions, so it carries
|
|
160
|
+
* both.** Overriding this method changes the WORDING for every user of one
|
|
161
|
+
* adopter's product; the key is what gives a reader the sentence in their own
|
|
162
|
+
* language, and no override can supply that without an adopter writing a
|
|
163
|
+
* subclass per locale — which is the thing a catalogue exists to avoid. Two
|
|
164
|
+
* of the three surfaces this reaches are user-visible, so the audience
|
|
165
|
+
* triage answers it: a host-bound string a user sees takes an inline key.
|
|
166
|
+
*
|
|
167
|
+
* The Output-channel line is therefore localized too, which is deliberate
|
|
168
|
+
* rather than overlooked — the alternative is a second English copy of one
|
|
169
|
+
* sentence, and the reason for a single source here has not changed.
|
|
163
170
|
*/
|
|
164
171
|
loadFailureLabel(err: unknown): string {
|
|
165
|
-
return
|
|
172
|
+
return nls.localize('hydranium/glsp-client-theia/diagram-load-failed', 'Diagram failed to load: {0}', this.formatError(err));
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
/** Render a thrown value as a message. Shared so the channel line, the status
|