@eclipse-glsp/layout-elk 2.8.0-next.0 → 2.8.0-next.1
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/di.config.d.ts +16 -0
- package/lib/di.config.d.ts.map +1 -1
- package/lib/di.config.js +28 -7
- package/lib/di.config.js.map +1 -1
- package/package.json +3 -3
- package/src/di.config.ts +29 -8
package/lib/di.config.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { BindingTarget, GLSPModule } from '@eclipse-glsp/server';
|
|
17
17
|
import { LayoutOptions } from 'elkjs/lib/elk.bundled';
|
|
18
|
+
import { ELK } from 'elkjs/lib/elk-api';
|
|
18
19
|
import { ContainerModule, interfaces } from 'inversify';
|
|
19
20
|
import { ElementFilter } from './element-filter';
|
|
20
21
|
import { ElkFactory, GlspElkLayoutEngine } from './glsp-elk-layout-engine';
|
|
@@ -70,6 +71,21 @@ export declare class ElkLayoutModule extends GLSPModule {
|
|
|
70
71
|
protected bindElementFilter(): BindingTarget<ElementFilter>;
|
|
71
72
|
protected bindLayoutConfigurator(): BindingTarget<LayoutConfigurator>;
|
|
72
73
|
protected bindElkFactory(): BindingTarget<ElkFactory>;
|
|
74
|
+
/** Creates the underlying elkjs {@link ELK} instance, see {@link createWebWorkerElk} for the web-worker case. */
|
|
75
|
+
protected createElk(options: {
|
|
76
|
+
algorithms: string[];
|
|
77
|
+
defaultLayoutOptions?: LayoutOptions;
|
|
78
|
+
}, isWebWorker?: boolean): ELK;
|
|
79
|
+
/**
|
|
80
|
+
* Creates an {@link ELK} instance for a web-worker server. elkjs only exposes its in-process fake worker when it
|
|
81
|
+
* doesn't detect a dedicated-worker scope (`self` present, `document` absent) — otherwise it hijacks
|
|
82
|
+
* `self.onmessage` and layout never runs. Briefly presenting a `document` during construction flips elkjs back to
|
|
83
|
+
* the in-process worker without touching the server's own `self.onmessage` handler.
|
|
84
|
+
*/
|
|
85
|
+
protected createWebWorkerElk(options: {
|
|
86
|
+
algorithms: string[];
|
|
87
|
+
defaultLayoutOptions?: LayoutOptions;
|
|
88
|
+
}): ELK;
|
|
73
89
|
protected bindGlspElkLayoutEngine(): BindingTarget<GlspElkLayoutEngine>;
|
|
74
90
|
/** Provide fallbacks so the module works standalone in tests/specs that don't preconfigure logging. */
|
|
75
91
|
protected bindLoggerFallbacks(bind: interfaces.Bind, isBound: interfaces.IsBound): void;
|
package/lib/di.config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../src/di.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,aAAa,EACb,UAAU,EAOb,MAAM,sBAAsB,CAAC;AAC9B,OAAuB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAc,UAAU,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAA8B,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEvF,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACrD;;;OAGG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IAC3C;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;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AwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAEnF"}
|
package/lib/di.config.js
CHANGED
|
@@ -72,15 +72,36 @@ let ElkLayoutModule = class ElkLayoutModule extends server_1.GLSPModule {
|
|
|
72
72
|
}
|
|
73
73
|
bindElkFactory() {
|
|
74
74
|
const { algorithms, defaultLayoutOptions, isWebWorker } = this.options;
|
|
75
|
-
const factory = () =>
|
|
76
|
-
algorithms,
|
|
77
|
-
defaultLayoutOptions,
|
|
78
|
-
// The node implementation relies on elkjs' `FakeWorker` to set the `workerFactory`. The required file is
|
|
79
|
-
// dynamically loaded and not available in a web-worker context, so it has to be mocked manually there.
|
|
80
|
-
workerFactory: isWebWorker ? () => ({ postMessage: () => { } }) : undefined
|
|
81
|
-
});
|
|
75
|
+
const factory = () => this.createElk({ algorithms, defaultLayoutOptions }, isWebWorker);
|
|
82
76
|
return { constantValue: factory };
|
|
83
77
|
}
|
|
78
|
+
/** Creates the underlying elkjs {@link ELK} instance, see {@link createWebWorkerElk} for the web-worker case. */
|
|
79
|
+
createElk(options, isWebWorker) {
|
|
80
|
+
return isWebWorker ? this.createWebWorkerElk(options) : new elk_bundled_1.default(options);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates an {@link ELK} instance for a web-worker server. elkjs only exposes its in-process fake worker when it
|
|
84
|
+
* doesn't detect a dedicated-worker scope (`self` present, `document` absent) — otherwise it hijacks
|
|
85
|
+
* `self.onmessage` and layout never runs. Briefly presenting a `document` during construction flips elkjs back to
|
|
86
|
+
* the in-process worker without touching the server's own `self.onmessage` handler.
|
|
87
|
+
*/
|
|
88
|
+
createWebWorkerElk(options) {
|
|
89
|
+
const globalScope = globalThis;
|
|
90
|
+
const hadDocument = 'document' in globalScope;
|
|
91
|
+
const previousDocument = globalScope.document;
|
|
92
|
+
globalScope.document = previousDocument !== null && previousDocument !== void 0 ? previousDocument : {};
|
|
93
|
+
try {
|
|
94
|
+
return new elk_bundled_1.default(options);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
if (hadDocument) {
|
|
98
|
+
globalScope.document = previousDocument;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
delete globalScope.document;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
84
105
|
bindGlspElkLayoutEngine() {
|
|
85
106
|
return {
|
|
86
107
|
dynamicValue: ctx => {
|
package/lib/di.config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.config.js","sourceRoot":"","sources":["../src/di.config.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"di.config.js","sourceRoot":"","sources":["../src/di.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAyKA,4DAEC;AA3KD;;;;;;;;;;;;;;kFAckF;AAClF,iDAS8B;AAC9B,uDAAsE;AAEtE,yCAAoE;AACpE,qDAAuE;AACvE,qEAA2E;AAC3E,+DAAuF;AAkCvF;;;;;;;;;;;;;GAaG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,mBAAU;IAC3C,YAA+B,OAAyB;QACpD,KAAK,EAAE,CAAC;QADmB,YAAO,GAAP,OAAO,CAAkB;IAExD,CAAC;IAES,SAAS,CAAC,IAAqB,EAAE,MAAyB,EAAE,OAA2B,EAAE,MAAyB;QACxH,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAClD,IAAA,2BAAkB,EAAC,OAAO,EAAE,8BAAa,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACxF,IAAA,2BAAkB,EAAC,OAAO,EAAE,wCAAkB,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAClG,IAAA,2BAAkB,EAAC,OAAO,EAAE,mCAAU,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QA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AC,sBAAa,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,MAAc,EAAE,EAAE;gBAC/D,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,eAAM,CAAC,CAAC;gBACpD,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;gBACvB,OAAO,MAAM,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACJ,CAAA;AApFY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,GAAE;;GACA,eAAe,CAoF3B;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,OAAyB;IAC9D,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/layout-elk",
|
|
3
|
-
"version": "2.8.0-next.
|
|
3
|
+
"version": "2.8.0-next.1+ab013b0",
|
|
4
4
|
"description": "Integration of ELK graph layout algorithms in GLSP Node Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"watch": "tsc -w"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@eclipse-glsp/server": "2.8.0-next.
|
|
52
|
+
"@eclipse-glsp/server": "2.8.0-next.1+ab013b0",
|
|
53
53
|
"elkjs": "^0.10.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "ab013b0c1f1fce1734182e324ea9f915d50f92a6"
|
|
62
62
|
}
|
package/src/di.config.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
applyBindingTarget
|
|
25
25
|
} from '@eclipse-glsp/server';
|
|
26
26
|
import ElkConstructor, { LayoutOptions } from 'elkjs/lib/elk.bundled';
|
|
27
|
+
import { ELK } from 'elkjs/lib/elk-api';
|
|
27
28
|
import { ContainerModule, injectable, interfaces } from 'inversify';
|
|
28
29
|
import { DefaultElementFilter, ElementFilter } from './element-filter';
|
|
29
30
|
import { ElkFactory, GlspElkLayoutEngine } from './glsp-elk-layout-engine';
|
|
@@ -104,17 +105,37 @@ export class ElkLayoutModule extends GLSPModule {
|
|
|
104
105
|
|
|
105
106
|
protected bindElkFactory(): BindingTarget<ElkFactory> {
|
|
106
107
|
const { algorithms, defaultLayoutOptions, isWebWorker } = this.options;
|
|
107
|
-
const factory: ElkFactory = () =>
|
|
108
|
-
new ElkConstructor({
|
|
109
|
-
algorithms,
|
|
110
|
-
defaultLayoutOptions,
|
|
111
|
-
// The node implementation relies on elkjs' `FakeWorker` to set the `workerFactory`. The required file is
|
|
112
|
-
// dynamically loaded and not available in a web-worker context, so it has to be mocked manually there.
|
|
113
|
-
workerFactory: isWebWorker ? () => ({ postMessage: () => {} }) as unknown as Worker : undefined
|
|
114
|
-
});
|
|
108
|
+
const factory: ElkFactory = () => this.createElk({ algorithms, defaultLayoutOptions }, isWebWorker);
|
|
115
109
|
return { constantValue: factory };
|
|
116
110
|
}
|
|
117
111
|
|
|
112
|
+
/** Creates the underlying elkjs {@link ELK} instance, see {@link createWebWorkerElk} for the web-worker case. */
|
|
113
|
+
protected createElk(options: { algorithms: string[]; defaultLayoutOptions?: LayoutOptions }, isWebWorker?: boolean): ELK {
|
|
114
|
+
return isWebWorker ? this.createWebWorkerElk(options) : new ElkConstructor(options);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Creates an {@link ELK} instance for a web-worker server. elkjs only exposes its in-process fake worker when it
|
|
119
|
+
* doesn't detect a dedicated-worker scope (`self` present, `document` absent) — otherwise it hijacks
|
|
120
|
+
* `self.onmessage` and layout never runs. Briefly presenting a `document` during construction flips elkjs back to
|
|
121
|
+
* the in-process worker without touching the server's own `self.onmessage` handler.
|
|
122
|
+
*/
|
|
123
|
+
protected createWebWorkerElk(options: { algorithms: string[]; defaultLayoutOptions?: LayoutOptions }): ELK {
|
|
124
|
+
const globalScope = globalThis as { document?: unknown };
|
|
125
|
+
const hadDocument = 'document' in globalScope;
|
|
126
|
+
const previousDocument = globalScope.document;
|
|
127
|
+
globalScope.document = previousDocument ?? {};
|
|
128
|
+
try {
|
|
129
|
+
return new ElkConstructor(options);
|
|
130
|
+
} finally {
|
|
131
|
+
if (hadDocument) {
|
|
132
|
+
globalScope.document = previousDocument;
|
|
133
|
+
} else {
|
|
134
|
+
delete globalScope.document;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
118
139
|
protected bindGlspElkLayoutEngine(): BindingTarget<GlspElkLayoutEngine> {
|
|
119
140
|
return {
|
|
120
141
|
dynamicValue: ctx => {
|