@hydranium/glsp-server 1.0.0-next.12 → 1.0.0-next.123
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 +13 -2
- package/lib/command/hydranium-glsp-recording-command.d.ts +22 -22
- package/lib/command/hydranium-glsp-recording-command.d.ts.map +1 -1
- package/lib/command/hydranium-glsp-recording-command.js +25 -26
- package/lib/command/hydranium-glsp-recording-command.js.map +1 -1
- package/lib/launcher/hydranium-glsp-server.d.ts +4 -3
- package/lib/launcher/hydranium-glsp-server.d.ts.map +1 -1
- package/lib/launcher/hydranium-glsp-server.js +4 -3
- package/lib/launcher/hydranium-glsp-server.js.map +1 -1
- package/lib/messages/index.d.ts +24 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +24 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/node/start-glsp-server.js +1 -1
- package/lib/node/start-glsp-server.js.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.d.ts +110 -43
- package/lib/state/abstract-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/abstract-hydranium-glsp-state.js +130 -41
- package/lib/state/abstract-hydranium-glsp-state.js.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.d.ts +6 -6
- package/lib/state/full-text-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/full-text-hydranium-glsp-state.js +6 -10
- package/lib/state/full-text-hydranium-glsp-state.js.map +1 -1
- package/lib/state/reconcile-source-model-write.d.ts +9 -8
- package/lib/state/reconcile-source-model-write.d.ts.map +1 -1
- package/lib/state/reconcile-source-model-write.js +8 -8
- package/lib/state/reconcile-source-model-write.js.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.d.ts +59 -59
- package/lib/state/reconciling-multi-document-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-multi-document-glsp-state.js +84 -82
- package/lib/state/reconciling-multi-document-glsp-state.js.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts +19 -18
- package/lib/state/reconciling-transfer-hydranium-glsp-state.d.ts.map +1 -1
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js +26 -30
- package/lib/state/reconciling-transfer-hydranium-glsp-state.js.map +1 -1
- package/lib/storage/hydranium-glsp-storage.d.ts +271 -76
- package/lib/storage/hydranium-glsp-storage.d.ts.map +1 -1
- package/lib/storage/hydranium-glsp-storage.js +383 -87
- package/lib/storage/hydranium-glsp-storage.js.map +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +1 -1
- package/lib/storage/save-delivery-policy.d.ts +46 -0
- package/lib/storage/save-delivery-policy.d.ts.map +1 -0
- package/lib/storage/{save-conflict-policy.js → save-delivery-policy.js} +7 -8
- package/lib/storage/save-delivery-policy.js.map +1 -0
- package/lib/validation/diagnostic-markers.d.ts +2 -2
- package/lib/validation/diagnostic-markers.d.ts.map +1 -1
- package/lib/validation/diagnostic-markers.js +7 -0
- package/lib/validation/diagnostic-markers.js.map +1 -1
- package/lib/validation/hydranium-glsp-model-validator.d.ts.map +1 -1
- package/lib/validation/hydranium-glsp-model-validator.js +1 -1
- package/lib/validation/hydranium-glsp-model-validator.js.map +1 -1
- package/package.json +17 -8
- package/src/command/hydranium-glsp-recording-command.ts +26 -26
- package/src/launcher/hydranium-glsp-server.ts +4 -3
- package/src/messages/index.ts +30 -0
- package/src/node/start-glsp-server.ts +1 -1
- package/src/state/abstract-hydranium-glsp-state.ts +162 -51
- package/src/state/full-text-hydranium-glsp-state.ts +7 -11
- package/src/state/reconcile-source-model-write.ts +18 -15
- package/src/state/reconciling-multi-document-glsp-state.ts +86 -83
- package/src/state/reconciling-transfer-hydranium-glsp-state.ts +27 -31
- package/src/storage/hydranium-glsp-storage.ts +445 -97
- package/src/storage/index.ts +1 -1
- package/src/storage/save-delivery-policy.ts +44 -0
- package/src/validation/diagnostic-markers.ts +10 -3
- package/src/validation/hydranium-glsp-model-validator.ts +3 -3
- package/lib/storage/save-conflict-policy.d.ts +0 -56
- package/lib/storage/save-conflict-policy.d.ts.map +0 -1
- package/lib/storage/save-conflict-policy.js.map +0 -1
- package/src/storage/save-conflict-policy.ts +0 -52
package/src/storage/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How `HydraniumGlspStorage.saveSourceModel` delivers its result: whether the
|
|
12
|
+
* GLSP save action awaits the write, and what happens on failure.
|
|
13
|
+
*
|
|
14
|
+
* The two are not independent — fire-and-forget plus rethrow would leave an
|
|
15
|
+
* unhandled rejection — so each arm bundles them into one coherent, nameable
|
|
16
|
+
* policy an adopter selects whole. It is a *selection of configuration*,
|
|
17
|
+
* delivered as a bound option (see the {@link SaveDeliveryPolicy} symbol) rather
|
|
18
|
+
* than a behaviour hook.
|
|
19
|
+
*
|
|
20
|
+
* **Neither arm guards on a based-on version.** A save flushes the store's
|
|
21
|
+
* settled text rather than authoring from the diagram's captured model, and the
|
|
22
|
+
* store already holds every other client's change — so a guard here refuses a
|
|
23
|
+
* write whose content is already correct. The gate that does exist sits on the
|
|
24
|
+
* update path, per operation, where the diagram authors.
|
|
25
|
+
*/
|
|
26
|
+
export type SaveDeliveryPolicy =
|
|
27
|
+
/** Await the write and propagate any failure to the GLSP save action. The default. */
|
|
28
|
+
| { kind: 'await' }
|
|
29
|
+
/**
|
|
30
|
+
* Fire-and-forget, logging and swallowing every failure. Correct when a
|
|
31
|
+
* failed diagram save must neither block the action nor surface as an error.
|
|
32
|
+
*/
|
|
33
|
+
| { kind: 'fire-and-forget' };
|
|
34
|
+
|
|
35
|
+
/** The policy applied when no {@link SaveDeliveryPolicy} option is bound. */
|
|
36
|
+
export const DEFAULT_SAVE_DELIVERY_POLICY: SaveDeliveryPolicy = { kind: 'await' };
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* DI token for the {@link SaveDeliveryPolicy} option. Bind a constant value in a
|
|
40
|
+
* `DiagramModule` to select a non-default policy; left unbound,
|
|
41
|
+
* `HydraniumGlspStorage` falls back to {@link DEFAULT_SAVE_DELIVERY_POLICY}.
|
|
42
|
+
* Shares its name with the type, the way a `class` is both a value and a type.
|
|
43
|
+
*/
|
|
44
|
+
export const SaveDeliveryPolicy = Symbol('SaveDeliveryPolicy');
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { type Marker, MarkerKind } from '@eclipse-glsp/protocol';
|
|
11
11
|
import { type AstNode } from '@hydranium/langium';
|
|
12
12
|
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-types';
|
|
13
|
-
import { type
|
|
13
|
+
import { type AstDiagnostic } from '@hydranium/core';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The model-shaped lookups the diagnostic→marker translation needs, injected so
|
|
@@ -48,7 +48,7 @@ export interface DiagnosticMarkerLookups {
|
|
|
48
48
|
* `MarkersReason` so a fresh `SetMarkersAction` replaces the previous markers
|
|
49
49
|
* (an empty result clears them when all errors are fixed).
|
|
50
50
|
*/
|
|
51
|
-
export function diagnosticsToMarkers(diagnostics: readonly
|
|
51
|
+
export function diagnosticsToMarkers(diagnostics: readonly AstDiagnostic[], lookups: DiagnosticMarkerLookups): Marker[] {
|
|
52
52
|
const markers: Marker[] = [];
|
|
53
53
|
for (const diagnostic of diagnostics) {
|
|
54
54
|
const kind = markerKind(diagnostic.severity);
|
|
@@ -65,8 +65,15 @@ export function diagnosticsToMarkers(diagnostics: readonly TransferLspDiagnostic
|
|
|
65
65
|
* The ids of the elements drawn on this diagram for the diagnostic's target,
|
|
66
66
|
* starting at the node it points at and walking up its containers; empty when
|
|
67
67
|
* the path does not resolve or nothing on the chain is rendered.
|
|
68
|
+
*
|
|
69
|
+
* @param elementPath absent for a lexer or parser error, which Langium pushes
|
|
70
|
+
* onto the document without one — such a diagnostic points at text no node
|
|
71
|
+
* was built from, so it marks nothing.
|
|
68
72
|
*/
|
|
69
|
-
function renderedElementIds(elementPath: string, lookups: DiagnosticMarkerLookups): readonly string[] {
|
|
73
|
+
function renderedElementIds(elementPath: string | undefined, lookups: DiagnosticMarkerLookups): readonly string[] {
|
|
74
|
+
if (elementPath === undefined) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
70
77
|
let node: AstNode | undefined = lookups.resolveElement(elementPath);
|
|
71
78
|
while (node !== undefined) {
|
|
72
79
|
const ids = lookups.renderedIdsFor(node);
|
|
@@ -12,7 +12,7 @@ import { type GModelElement, ModelState, type ModelValidator } from '@eclipse-gl
|
|
|
12
12
|
import { inject, injectable } from 'inversify';
|
|
13
13
|
import { type AstNode } from '@hydranium/langium';
|
|
14
14
|
import { URI } from '@hydranium/langium';
|
|
15
|
-
import { type ServerSharedServices, type
|
|
15
|
+
import { type ServerSharedServices, type AstDiagnostic } from '@hydranium/core';
|
|
16
16
|
import { type AbstractHydraniumGlspState } from '../state/abstract-hydranium-glsp-state.js';
|
|
17
17
|
import { HydraniumTypes } from '../state/hydranium-shared-core-services.js';
|
|
18
18
|
import { type DiagnosticMarkerLookups, diagnosticsToMarkers } from './diagnostic-markers.js';
|
|
@@ -75,9 +75,9 @@ export class HydraniumGlspModelValidator<TRoot extends AstNode = AstNode> implem
|
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
77
|
// Diagnostics are produced by the framework's `HydraniumDocumentValidator`,
|
|
78
|
-
// which emits `
|
|
78
|
+
// which emits `AstDiagnostic` (LSP `Diagnostic` + `element` path).
|
|
79
79
|
// Parser/lexer diagnostics carry no `element`; the lookup drops them.
|
|
80
|
-
const diagnostics = document.diagnostics as
|
|
80
|
+
const diagnostics = document.diagnostics as AstDiagnostic[] | undefined;
|
|
81
81
|
if (!diagnostics || diagnostics.length === 0) {
|
|
82
82
|
continue;
|
|
83
83
|
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the MIT License which is available in the project root.
|
|
6
|
-
*
|
|
7
|
-
* SPDX-License-Identifier: MIT
|
|
8
|
-
********************************************************************************/
|
|
9
|
-
/**
|
|
10
|
-
* How `HydraniumGlspStorage.saveSourceModel` reacts when a concurrent edit has
|
|
11
|
-
* advanced the document past the version this diagram was last captured at.
|
|
12
|
-
*
|
|
13
|
-
* A save spans otherwise-independent choices — whether to guard on the captured
|
|
14
|
-
* based-on version, whether the GLSP save action awaits the persist, and what
|
|
15
|
-
* happens on failure. Each arm bundles those into one coherent, nameable policy
|
|
16
|
-
* so an adopter selects a whole behaviour rather than assembling an incoherent
|
|
17
|
-
* mix: fire-and-forget plus rethrow would leave an unhandled rejection. It is a
|
|
18
|
-
* *selection of configuration*, delivered as a bound option (see the
|
|
19
|
-
* {@link SaveConflictPolicy} symbol) rather than a behaviour hook.
|
|
20
|
-
*/
|
|
21
|
-
export type SaveConflictPolicy =
|
|
22
|
-
/**
|
|
23
|
-
* Last-write-wins: no based-on guard, await the persist, propagate any
|
|
24
|
-
* failure to the GLSP save action. The default; correct for a single-editor
|
|
25
|
-
* head where nothing races the save.
|
|
26
|
-
*/
|
|
27
|
-
{
|
|
28
|
-
kind: 'overwrite';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Guard on the captured version, await the persist, and surface a
|
|
32
|
-
* `ConflictError` (and any other failure) to the GLSP save action.
|
|
33
|
-
*/
|
|
34
|
-
| {
|
|
35
|
-
kind: 'reject';
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Guard on the captured version, fire-and-forget, and log + swallow every
|
|
39
|
-
* failure. Correct when another editor of the same document may already have
|
|
40
|
-
* written the truth, so a stale diagram save is benign and must neither
|
|
41
|
-
* block the action nor surface as an error.
|
|
42
|
-
*/
|
|
43
|
-
| {
|
|
44
|
-
kind: 'drop-and-log';
|
|
45
|
-
};
|
|
46
|
-
/** The policy applied when no {@link SaveConflictPolicy} option is bound. */
|
|
47
|
-
export declare const DEFAULT_SAVE_CONFLICT_POLICY: SaveConflictPolicy;
|
|
48
|
-
/**
|
|
49
|
-
* DI token for the {@link SaveConflictPolicy} option. Bind a constant value in a
|
|
50
|
-
* `DiagramModule` to select a non-default policy; left unbound,
|
|
51
|
-
* `HydraniumGlspStorage` falls back to
|
|
52
|
-
* {@link DEFAULT_SAVE_CONFLICT_POLICY}. Shares its name with the type, the way a
|
|
53
|
-
* `class` is both a value and a type.
|
|
54
|
-
*/
|
|
55
|
-
export declare const SaveConflictPolicy: unique symbol;
|
|
56
|
-
//# sourceMappingURL=save-conflict-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"save-conflict-policy.d.ts","sourceRoot":"","sources":["../../src/storage/save-conflict-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB;AAC3B;;;;GAIG;AACD;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE;AACvB;;;GAGG;GACD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE;AACpB;;;;;GAKG;GACD;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAE9B,6EAA6E;AAC7E,eAAO,MAAM,4BAA4B,EAAE,kBAA0C,CAAC;AAEtF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"save-conflict-policy.js","sourceRoot":"","sources":["../../src/storage/save-conflict-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAkClF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,4BAA4B,GAAuB,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the MIT License which is available in the project root.
|
|
6
|
-
*
|
|
7
|
-
* SPDX-License-Identifier: MIT
|
|
8
|
-
********************************************************************************/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* How `HydraniumGlspStorage.saveSourceModel` reacts when a concurrent edit has
|
|
12
|
-
* advanced the document past the version this diagram was last captured at.
|
|
13
|
-
*
|
|
14
|
-
* A save spans otherwise-independent choices — whether to guard on the captured
|
|
15
|
-
* based-on version, whether the GLSP save action awaits the persist, and what
|
|
16
|
-
* happens on failure. Each arm bundles those into one coherent, nameable policy
|
|
17
|
-
* so an adopter selects a whole behaviour rather than assembling an incoherent
|
|
18
|
-
* mix: fire-and-forget plus rethrow would leave an unhandled rejection. It is a
|
|
19
|
-
* *selection of configuration*, delivered as a bound option (see the
|
|
20
|
-
* {@link SaveConflictPolicy} symbol) rather than a behaviour hook.
|
|
21
|
-
*/
|
|
22
|
-
export type SaveConflictPolicy =
|
|
23
|
-
/**
|
|
24
|
-
* Last-write-wins: no based-on guard, await the persist, propagate any
|
|
25
|
-
* failure to the GLSP save action. The default; correct for a single-editor
|
|
26
|
-
* head where nothing races the save.
|
|
27
|
-
*/
|
|
28
|
-
| { kind: 'overwrite' }
|
|
29
|
-
/**
|
|
30
|
-
* Guard on the captured version, await the persist, and surface a
|
|
31
|
-
* `ConflictError` (and any other failure) to the GLSP save action.
|
|
32
|
-
*/
|
|
33
|
-
| { kind: 'reject' }
|
|
34
|
-
/**
|
|
35
|
-
* Guard on the captured version, fire-and-forget, and log + swallow every
|
|
36
|
-
* failure. Correct when another editor of the same document may already have
|
|
37
|
-
* written the truth, so a stale diagram save is benign and must neither
|
|
38
|
-
* block the action nor surface as an error.
|
|
39
|
-
*/
|
|
40
|
-
| { kind: 'drop-and-log' };
|
|
41
|
-
|
|
42
|
-
/** The policy applied when no {@link SaveConflictPolicy} option is bound. */
|
|
43
|
-
export const DEFAULT_SAVE_CONFLICT_POLICY: SaveConflictPolicy = { kind: 'overwrite' };
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* DI token for the {@link SaveConflictPolicy} option. Bind a constant value in a
|
|
47
|
-
* `DiagramModule` to select a non-default policy; left unbound,
|
|
48
|
-
* `HydraniumGlspStorage` falls back to
|
|
49
|
-
* {@link DEFAULT_SAVE_CONFLICT_POLICY}. Shares its name with the type, the way a
|
|
50
|
-
* `class` is both a value and a type.
|
|
51
|
-
*/
|
|
52
|
-
export const SaveConflictPolicy = Symbol('SaveConflictPolicy');
|