@hydranium/protocol 1.0.0-next.187 → 1.0.0-next.188
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/client/data-connection.js +2 -2
- package/lib/client/data-connection.js.map +1 -1
- package/lib/client/data-port.d.ts +1 -1
- package/lib/client/data-session.d.ts +39 -21
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +69 -43
- package/lib/client/data-session.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +2 -4
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +11 -5
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +4 -4
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/errors.d.ts +31 -25
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +58 -23
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/messages/index.d.ts +2 -2
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +3 -2
- package/lib/messages/index.js.map +1 -1
- package/lib/model-service/base-version.d.ts +64 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/{based-on.js → base-version.js} +21 -15
- package/lib/model-service/base-version.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -1
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +2 -2
- package/lib/model-service/index.js.map +1 -1
- package/lib/patch-merge.d.ts +11 -9
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +2 -2
- package/lib/patch-merge.js.map +1 -1
- package/lib/reconcile-write.d.ts +65 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +67 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/create-rpc-proxy.d.ts +3 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/transfer-document.d.ts +59 -61
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +15 -20
- package/lib/transfer-document.js.map +1 -1
- package/lib/util.d.ts +1 -1
- package/lib/util.js +1 -1
- package/package.json +1 -1
- package/src/client/data-connection.ts +2 -2
- package/src/client/data-port.ts +1 -1
- package/src/client/data-session.ts +89 -51
- package/src/data/data-server-protocol.ts +2 -4
- package/src/data/events.ts +11 -5
- package/src/data/requests.ts +4 -4
- package/src/errors.ts +71 -31
- package/src/index.ts +1 -0
- package/src/messages/index.ts +2 -2
- package/src/model-service/base-version.ts +72 -0
- package/src/model-service/index.ts +2 -2
- package/src/patch-merge.ts +11 -9
- package/src/reconcile-write.ts +124 -0
- package/src/rpc/create-rpc-proxy.ts +6 -1
- package/src/transfer-document.ts +70 -65
- package/src/util.ts +1 -1
- package/lib/model-service/based-on.d.ts +0 -57
- package/lib/model-service/based-on.d.ts.map +0 -1
- package/lib/model-service/based-on.js.map +0 -1
- package/src/model-service/based-on.ts +0 -63
|
@@ -77,10 +77,8 @@ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiag
|
|
|
77
77
|
* as every document request here does. The document is read from disk
|
|
78
78
|
* unless a client has it open already, so the request carries no
|
|
79
79
|
* `languageId`, `version` or `text` seed. Returns the document at
|
|
80
|
-
* the server's configured target phase
|
|
81
|
-
*
|
|
82
|
-
* text-document store so the caller's first `basedOn` write cannot
|
|
83
|
-
* self-conflict. A repeat open changes nothing.
|
|
80
|
+
* the server's configured target phase, as {@link getModelDocument} does.
|
|
81
|
+
* A repeat open changes nothing.
|
|
84
82
|
*
|
|
85
83
|
* Pair with {@link watchModelDocument} to receive subsequent build-phase
|
|
86
84
|
* events (open returns a one-shot snapshot; later validation diagnostics
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-server-protocol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zF;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACxD;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB,CAAC,SAAS,SAAS,eAAe,EAAE,WAAW,SAAS,kBAAkB,GAAG,kBAAkB;IACnI;;;;OAIG;IACH,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;IAErF;;;;;;;;;OASG;IACH,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;IAEjF;;;;;;;;OAQG;IACH,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,GAAG,IAAI,CAAC;IAEvE;;;;;;;;;OASG;IACH,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAE7D;;;;;;;OAOG;IACH,gBAAgB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC7D;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACtE;;;;;;;;OAQG;IACH,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;CACjE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAChC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,QAAQ,SAAS,OAAO,GAAG,OAAO,CAElC,SAAQ,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC;CAAG"}
|
package/lib/data/events.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
10
10
|
import type { TransferElement } from '../transfer-element';
|
|
11
11
|
import type { Project } from '../project';
|
|
12
|
-
import type { TransferDocument } from '../transfer-document';
|
|
12
|
+
import type { TextState, TransferDocument } from '../transfer-document';
|
|
13
13
|
/**
|
|
14
14
|
* Why an update event fired. Subscribers filter on reason for behaviour
|
|
15
15
|
* decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
|
|
@@ -87,14 +87,20 @@ export type TransferDocumentSavedListener<TTransfer extends TransferElement, TDi
|
|
|
87
87
|
/**
|
|
88
88
|
* Delivered on the data-server when a watched document's text starts or stops
|
|
89
89
|
* differing from its file, as the server last knew the file. The current
|
|
90
|
-
* answer rides on every transfer document the server sends as `dirty`;
|
|
91
|
-
* carries only its changes, so a client that follows it needs no rebuild
|
|
92
|
-
* learn of a save.
|
|
90
|
+
* answer rides on every transfer document the server sends as `text.dirty`;
|
|
91
|
+
* this carries only its changes, so a client that follows it needs no rebuild
|
|
92
|
+
* to learn of a save.
|
|
93
93
|
*/
|
|
94
94
|
export interface TransferDocumentDirtyChangedEvent {
|
|
95
95
|
/** Canonical URI, keyed as the subscription is. */
|
|
96
96
|
readonly uri: string;
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* The text the answer was decided on. It is sent before that text is
|
|
99
|
+
* built, so a `text.version` ahead of the model a client holds means an
|
|
100
|
+
* update at this version or a later one follows. Absent when the document
|
|
101
|
+
* no longer exists, or when the build that follows its release failed.
|
|
102
|
+
*/
|
|
103
|
+
readonly text?: TextState;
|
|
98
104
|
}
|
|
99
105
|
/** Callback shape for `DataClientProtocol.onDocumentDirtyChanged`. */
|
|
100
106
|
export type TransferDocumentDirtyChangedListener = (event: TransferDocumentDirtyChangedEvent) => void;
|
package/lib/data/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK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mB,CAAC;CACvC;AAED,iEAAiE;AACjE,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC"}
|
package/lib/data/requests.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import type {
|
|
9
|
+
import type { BaseVersion } from '../model-service/base-version';
|
|
10
10
|
/** Get the current state of a single document. The server returns the latest built version. */
|
|
11
11
|
export interface GetModelDocumentArgs {
|
|
12
12
|
/** Document URI. */
|
|
@@ -49,16 +49,16 @@ export interface TransferUpdateDocumentArgs<TTransfer> {
|
|
|
49
49
|
/** The whole structured model root, or its serialised textual form. */
|
|
50
50
|
model: TTransfer | string;
|
|
51
51
|
/**
|
|
52
|
-
* What this write was authored against. A `
|
|
52
|
+
* What this write was authored against. A `ModelVersion` is compared
|
|
53
53
|
* against the server's current text-document version for `uri` and throws
|
|
54
|
-
* `ConflictError` on mismatch; `'
|
|
54
|
+
* `ConflictError` on mismatch; `'any'` writes unconditionally.
|
|
55
55
|
*
|
|
56
56
|
* **Required so that an ungated write is a decision rather than an
|
|
57
57
|
* omission.** An optional gate is indistinguishable from a forgotten one at
|
|
58
58
|
* the call site, and a file of twenty writes hides the one that lost the
|
|
59
59
|
* field. Nothing else here can see that, since the defect is an absence.
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
baseVersion: BaseVersion;
|
|
62
62
|
}
|
|
63
63
|
/** Update a document the session `clientId` has open, then persist it to disk. */
|
|
64
64
|
export interface TransferSaveDocumentArgs<TTransfer> extends TransferUpdateDocumentArgs<TTransfer> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/data/requests.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AA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;;GAIG;AACH,MAAM,WAAW,2BAA2B,CAAC,SAAS;IACnD,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC,0BAA0B,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,EAAE,CAAC;CACrE;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAsB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;CACnB"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { ResponseError } from 'vscode-jsonrpc';
|
|
10
10
|
import { type HydraniumMessageData } from './messages/primitives';
|
|
11
|
+
import { type ModelVersion, type TextVersion } from './model-service/base-version';
|
|
11
12
|
/**
|
|
12
13
|
* The catalogue declaration behind {@link ConflictError}'s sentence. It words
|
|
13
14
|
* the version mismatch rather than stating it: the two numbers mean nothing to
|
|
@@ -18,7 +19,7 @@ import { type HydraniumMessageData } from './messages/primitives';
|
|
|
18
19
|
* That tier only ever works untranslated, which is why it is the last resort
|
|
19
20
|
* behind the numeric code rather than the primary check.
|
|
20
21
|
*/
|
|
21
|
-
export declare const
|
|
22
|
+
export declare const STALE_BASE_VERSION_UPDATE: import("./messages/primitives").MessageDefinition<"The edit to {uri} was not applied: it was made to an older version of the document.">;
|
|
22
23
|
/**
|
|
23
24
|
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
24
25
|
* the error it identifies.
|
|
@@ -49,34 +50,30 @@ export declare const HYDRANIUM_ERROR_CODES: {
|
|
|
49
50
|
* not.
|
|
50
51
|
*/
|
|
51
52
|
export declare const CONFLICT_ERROR_CODE: 42001;
|
|
52
|
-
/**
|
|
53
|
-
* Structured payload carried in {@link ConflictError.data}, and the only place
|
|
54
|
-
* a post-RPC caller can read the version mismatch from.
|
|
55
|
-
*/
|
|
53
|
+
/** Structured payload carried in {@link ConflictError.data}. */
|
|
56
54
|
export interface ConflictErrorData extends HydraniumMessageData {
|
|
57
55
|
readonly uri: string;
|
|
58
|
-
/** The
|
|
59
|
-
readonly
|
|
56
|
+
/** The base version the caller authored against. */
|
|
57
|
+
readonly baseVersion: ModelVersion;
|
|
60
58
|
/** The server's current text-document version at the time of the throw. */
|
|
61
|
-
readonly actualVersion:
|
|
59
|
+
readonly actualVersion: TextVersion;
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* Thrown by a client session's `update` / `save` when the caller-
|
|
65
|
-
* supplied
|
|
63
|
+
* supplied base version no longer matches the server's current text-
|
|
66
64
|
* document version for the same URI — i.e. the snapshot the caller
|
|
67
65
|
* authored against has been superseded by an intervening edit.
|
|
68
66
|
*
|
|
69
67
|
* Extends vscode-jsonrpc's {@link ResponseError} so the typed
|
|
70
68
|
* {@link ConflictErrorData} payload rides on the standard JSON-RPC
|
|
71
69
|
* error envelope (`code`, `message`, `data`) — all three fields are
|
|
72
|
-
* preserved by RPC reconstruction.
|
|
73
|
-
* the receiving side
|
|
74
|
-
* `err.data`
|
|
75
|
-
* `ResponseError`, so subclass getters / fields do not survive).
|
|
70
|
+
* preserved by RPC reconstruction. `createRpcProxy` revives it into
|
|
71
|
+
* this class on the receiving side; a path that does not leaves a
|
|
72
|
+
* plain `ResponseError`, readable through `err.data` only.
|
|
76
73
|
*
|
|
77
|
-
* Detection is driven by the required `
|
|
78
|
-
* request; a caller with no meaningful
|
|
79
|
-
* `'
|
|
74
|
+
* Detection is driven by the required `baseVersion` field of every write
|
|
75
|
+
* request; a caller with no meaningful base version passes
|
|
76
|
+
* `'any'` and gets no gating.
|
|
80
77
|
*
|
|
81
78
|
* Three reasonable adopter recovery strategies:
|
|
82
79
|
*
|
|
@@ -90,19 +87,19 @@ export interface ConflictErrorData extends HydraniumMessageData {
|
|
|
90
87
|
* No auto-retry or auto-merge ships by default.
|
|
91
88
|
*/
|
|
92
89
|
export declare class ConflictError extends ResponseError<ConflictErrorData> {
|
|
93
|
-
constructor(uri: string,
|
|
90
|
+
constructor(uri: string, baseVersion: ModelVersion, actualVersion: TextVersion);
|
|
94
91
|
get uri(): string;
|
|
95
92
|
/**
|
|
96
|
-
* The
|
|
93
|
+
* The base version the caller authored against.
|
|
97
94
|
*
|
|
98
95
|
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
99
96
|
* reporter reads an error carrying both as an assertion failure, and
|
|
100
97
|
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
101
98
|
* replaces the real failure with a `TypeError`.
|
|
102
99
|
*/
|
|
103
|
-
get
|
|
104
|
-
/** The server's version at the time of the throw. Not `actual` — see {@link
|
|
105
|
-
get actualVersion():
|
|
100
|
+
get baseVersion(): ModelVersion;
|
|
101
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link baseVersion}. */
|
|
102
|
+
get actualVersion(): TextVersion;
|
|
106
103
|
}
|
|
107
104
|
/**
|
|
108
105
|
* JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
|
|
@@ -199,9 +196,18 @@ export declare class ReservedClientIdError extends ResponseError<{
|
|
|
199
196
|
constructor(clientId: string);
|
|
200
197
|
get clientId(): string;
|
|
201
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* `error` as an instance of the typed error class its code names, with its
|
|
201
|
+
* message, data and stack kept, or `error` itself when its code names none or
|
|
202
|
+
* its data lacks the fields that class reads.
|
|
203
|
+
* An RPC reconstructs every rejection as a plain `ResponseError`, which has
|
|
204
|
+
* none of the class getters.
|
|
205
|
+
*/
|
|
206
|
+
export declare function reviveProtocolError(error: unknown): unknown;
|
|
202
207
|
/**
|
|
203
208
|
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
204
|
-
*
|
|
209
|
+
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
210
|
+
* {@link reviveProtocolError revive} it.
|
|
205
211
|
*/
|
|
206
212
|
export declare function isSessionClosedError(error: unknown): error is SessionClosedError;
|
|
207
213
|
/** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
|
|
@@ -219,12 +225,12 @@ export declare function isReservedClientIdError(error: unknown): error is Reserv
|
|
|
219
225
|
* canonical wire-side check; the JSON-RPC `code` field is preserved
|
|
220
226
|
* across reconstruction, so any adopter catching after an RPC call
|
|
221
227
|
* hits this branch.
|
|
222
|
-
* 3. `error.message` contains the marker {@link
|
|
228
|
+
* 3. `error.message` contains the marker {@link STALE_BASE_VERSION_UPDATE}'s
|
|
223
229
|
* English carries — fallback for transports that re-wrap the message
|
|
224
230
|
* and drop the code (rare).
|
|
225
231
|
*
|
|
226
|
-
* `instanceof ConflictError` alone
|
|
227
|
-
*
|
|
232
|
+
* `instanceof ConflictError` alone returns `false` on a rejection that was
|
|
233
|
+
* not {@link reviveProtocolError revived}, so callers do not use it.
|
|
228
234
|
*/
|
|
229
235
|
export declare function isConflictError(error: unknown): error is ConflictError;
|
|
230
236
|
//# sourceMappingURL=errors.d.ts.map
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAiB,KAAK,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAiB,KAAK,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAcnG;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,0IAGrC,CAAC;AAEF;;;;;;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OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF;AAED,6FAA6F;AAC7F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAExF;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAEtF;AAWD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAYtE"}
|
package/lib/errors.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES = exports.
|
|
11
|
+
exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES = exports.STALE_BASE_VERSION_UPDATE = void 0;
|
|
12
|
+
exports.reviveProtocolError = reviveProtocolError;
|
|
12
13
|
exports.isSessionClosedError = isSessionClosedError;
|
|
13
14
|
exports.isDocumentNotOpenError = isDocumentNotOpenError;
|
|
14
15
|
exports.isDuplicateClientIdError = isDuplicateClientIdError;
|
|
@@ -16,6 +17,7 @@ exports.isReservedClientIdError = isReservedClientIdError;
|
|
|
16
17
|
exports.isConflictError = isConflictError;
|
|
17
18
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
18
19
|
const primitives_1 = require("./messages/primitives");
|
|
20
|
+
const base_version_1 = require("./model-service/base-version");
|
|
19
21
|
/*
|
|
20
22
|
* Every error here is a typed error: a caller reacts to it, so it has a class,
|
|
21
23
|
* a JSON-RPC code and an `is*` guard, and an English message. A typed error
|
|
@@ -37,7 +39,7 @@ const primitives_1 = require("./messages/primitives");
|
|
|
37
39
|
* That tier only ever works untranslated, which is why it is the last resort
|
|
38
40
|
* behind the numeric code rather than the primary check.
|
|
39
41
|
*/
|
|
40
|
-
exports.
|
|
42
|
+
exports.STALE_BASE_VERSION_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-base-version-update', 'The edit to {uri} was not applied: it was made to an older version of the document.');
|
|
41
43
|
/**
|
|
42
44
|
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
43
45
|
* the error it identifies.
|
|
@@ -70,21 +72,20 @@ exports.HYDRANIUM_ERROR_CODES = {
|
|
|
70
72
|
exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.conflict;
|
|
71
73
|
/**
|
|
72
74
|
* Thrown by a client session's `update` / `save` when the caller-
|
|
73
|
-
* supplied
|
|
75
|
+
* supplied base version no longer matches the server's current text-
|
|
74
76
|
* document version for the same URI — i.e. the snapshot the caller
|
|
75
77
|
* authored against has been superseded by an intervening edit.
|
|
76
78
|
*
|
|
77
79
|
* Extends vscode-jsonrpc's {@link ResponseError} so the typed
|
|
78
80
|
* {@link ConflictErrorData} payload rides on the standard JSON-RPC
|
|
79
81
|
* error envelope (`code`, `message`, `data`) — all three fields are
|
|
80
|
-
* preserved by RPC reconstruction.
|
|
81
|
-
* the receiving side
|
|
82
|
-
* `err.data`
|
|
83
|
-
* `ResponseError`, so subclass getters / fields do not survive).
|
|
82
|
+
* preserved by RPC reconstruction. `createRpcProxy` revives it into
|
|
83
|
+
* this class on the receiving side; a path that does not leaves a
|
|
84
|
+
* plain `ResponseError`, readable through `err.data` only.
|
|
84
85
|
*
|
|
85
|
-
* Detection is driven by the required `
|
|
86
|
-
* request; a caller with no meaningful
|
|
87
|
-
* `'
|
|
86
|
+
* Detection is driven by the required `baseVersion` field of every write
|
|
87
|
+
* request; a caller with no meaningful base version passes
|
|
88
|
+
* `'any'` and gets no gating.
|
|
88
89
|
*
|
|
89
90
|
* Three reasonable adopter recovery strategies:
|
|
90
91
|
*
|
|
@@ -98,22 +99,22 @@ exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.conflict;
|
|
|
98
99
|
* No auto-retry or auto-merge ships by default.
|
|
99
100
|
*/
|
|
100
101
|
class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
101
|
-
constructor(uri,
|
|
102
|
+
constructor(uri, baseVersion, actualVersion) {
|
|
102
103
|
// The identity rides alongside the typed payload rather than replacing
|
|
103
104
|
// it: `isConflictError`'s name check is surface an adopter may bind, so
|
|
104
105
|
// adding the identity widens the payload rather than reshaping it.
|
|
105
|
-
super(exports.CONFLICT_ERROR_CODE, exports.
|
|
106
|
+
super(exports.CONFLICT_ERROR_CODE, exports.STALE_BASE_VERSION_UPDATE.format({ uri }), {
|
|
106
107
|
uri,
|
|
107
|
-
|
|
108
|
+
baseVersion,
|
|
108
109
|
actualVersion,
|
|
109
|
-
...(0, primitives_1.messageData)(exports.
|
|
110
|
+
...(0, primitives_1.messageData)(exports.STALE_BASE_VERSION_UPDATE, { uri })
|
|
110
111
|
});
|
|
111
112
|
this.name = 'ConflictError';
|
|
112
113
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
113
114
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
114
115
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
115
116
|
// ConflictError-specific getters. Restore the prototype here so
|
|
116
|
-
// `err.uri` / `.
|
|
117
|
+
// `err.uri` / `.baseVersion` / `.actualVersion` resolve through this
|
|
117
118
|
// class.
|
|
118
119
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
119
120
|
}
|
|
@@ -121,17 +122,17 @@ class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
|
121
122
|
return this.data.uri;
|
|
122
123
|
}
|
|
123
124
|
/**
|
|
124
|
-
* The
|
|
125
|
+
* The base version the caller authored against.
|
|
125
126
|
*
|
|
126
127
|
* Must not be renamed to `expected`, nor its sibling to `actual`: a test
|
|
127
128
|
* reporter reads an error carrying both as an assertion failure, and
|
|
128
129
|
* vitest's formatter then ASSIGNS to them, which throws on an accessor and
|
|
129
130
|
* replaces the real failure with a `TypeError`.
|
|
130
131
|
*/
|
|
131
|
-
get
|
|
132
|
-
return this.data.
|
|
132
|
+
get baseVersion() {
|
|
133
|
+
return this.data.baseVersion;
|
|
133
134
|
}
|
|
134
|
-
/** The server's version at the time of the throw. Not `actual` — see {@link
|
|
135
|
+
/** The server's version at the time of the throw. Not `actual` — see {@link baseVersion}. */
|
|
135
136
|
get actualVersion() {
|
|
136
137
|
return this.data.actualVersion;
|
|
137
138
|
}
|
|
@@ -252,9 +253,43 @@ class ReservedClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
exports.ReservedClientIdError = ReservedClientIdError;
|
|
256
|
+
/** One entry per typed error class, keyed by its code; a class without one reaches a caller as a plain `ResponseError`. */
|
|
257
|
+
const PROTOCOL_ERROR_REVIVERS = new Map([
|
|
258
|
+
[
|
|
259
|
+
exports.CONFLICT_ERROR_CODE,
|
|
260
|
+
({ uri, baseVersion, actualVersion }) => typeof uri === 'string' && typeof baseVersion === 'number' && typeof actualVersion === 'number'
|
|
261
|
+
? new ConflictError(uri, (0, base_version_1.asModelVersion)(baseVersion), actualVersion)
|
|
262
|
+
: undefined
|
|
263
|
+
],
|
|
264
|
+
[exports.SESSION_CLOSED_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new SessionClosedError(clientId) : undefined)],
|
|
265
|
+
[
|
|
266
|
+
exports.DOCUMENT_NOT_OPEN_ERROR_CODE,
|
|
267
|
+
({ uri, clientId }) => (typeof uri === 'string' && typeof clientId === 'string' ? new DocumentNotOpenError(uri, clientId) : undefined)
|
|
268
|
+
],
|
|
269
|
+
[exports.DUPLICATE_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new DuplicateClientIdError(clientId) : undefined)],
|
|
270
|
+
[exports.RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)]
|
|
271
|
+
]);
|
|
272
|
+
/**
|
|
273
|
+
* `error` as an instance of the typed error class its code names, with its
|
|
274
|
+
* message, data and stack kept, or `error` itself when its code names none or
|
|
275
|
+
* its data lacks the fields that class reads.
|
|
276
|
+
* An RPC reconstructs every rejection as a plain `ResponseError`, which has
|
|
277
|
+
* none of the class getters.
|
|
278
|
+
*/
|
|
279
|
+
function reviveProtocolError(error) {
|
|
280
|
+
if (!(error instanceof vscode_jsonrpc_1.ResponseError) || error.data === null || typeof error.data !== 'object') {
|
|
281
|
+
return error;
|
|
282
|
+
}
|
|
283
|
+
const revived = PROTOCOL_ERROR_REVIVERS.get(error.code)?.(error.data);
|
|
284
|
+
if (!revived) {
|
|
285
|
+
return error;
|
|
286
|
+
}
|
|
287
|
+
return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
|
|
288
|
+
}
|
|
255
289
|
/**
|
|
256
290
|
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
257
|
-
*
|
|
291
|
+
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
292
|
+
* {@link reviveProtocolError revive} it.
|
|
258
293
|
*/
|
|
259
294
|
function isSessionClosedError(error) {
|
|
260
295
|
return hasErrorIdentity(error, 'SessionClosedError', exports.SESSION_CLOSED_ERROR_CODE);
|
|
@@ -287,12 +322,12 @@ const CONFLICT_ERROR_MESSAGE_MARKER = ': it was made to an older version of the
|
|
|
287
322
|
* canonical wire-side check; the JSON-RPC `code` field is preserved
|
|
288
323
|
* across reconstruction, so any adopter catching after an RPC call
|
|
289
324
|
* hits this branch.
|
|
290
|
-
* 3. `error.message` contains the marker {@link
|
|
325
|
+
* 3. `error.message` contains the marker {@link STALE_BASE_VERSION_UPDATE}'s
|
|
291
326
|
* English carries — fallback for transports that re-wrap the message
|
|
292
327
|
* and drop the code (rare).
|
|
293
328
|
*
|
|
294
|
-
* `instanceof ConflictError` alone
|
|
295
|
-
*
|
|
329
|
+
* `instanceof ConflictError` alone returns `false` on a rejection that was
|
|
330
|
+
* not {@link reviveProtocolError revived}, so callers do not use it.
|
|
296
331
|
*/
|
|
297
332
|
function isConflictError(error) {
|
|
298
333
|
if (!(error instanceof Error)) {
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;AAElF,mDAA+C;AAC/C,sDAA8F;AAC9F,+DAAmG;AAEnG;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AACU,QAAA,yBAAyB,GAAG,IAAA,0BAAa,EACnD,8CAA8C,EAC9C,qFAAqF,CACvF,CAAC;AAEF;;;;;;;;;;;GAWG;AACU,QAAA,qBAAqB,GAAG;IAClC,QAAQ,EAAE,KAAK;IACf,e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G,mDAAmD,CAAC;AAE1F;;;;;;;;;;;;;;;GAeG;AACH,yBAAgC,KAAc;IAC3C,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAI,KAAyC,CAAC,IAAI,CAAC;IAC7D,IAAI,IAAI,KAAK,QAAA,mBAAmB,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrG,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './logger';
|
|
|
20
20
|
export * from './latency-collector';
|
|
21
21
|
export * from './messages/primitives';
|
|
22
22
|
export * from './patch-merge';
|
|
23
|
+
export * from './reconcile-write';
|
|
23
24
|
export * from './noop-logger';
|
|
24
25
|
export * from './observable-value';
|
|
25
26
|
export * from './profile-session';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AASlF,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AAIpC,cAAc,uBAAuB,CAAC;AACtC,cAAc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HANGED
|
@@ -45,6 +45,7 @@ __exportStar(require("./latency-collector"), exports);
|
|
|
45
45
|
// the modules that raise them.
|
|
46
46
|
__exportStar(require("./messages/primitives"), exports);
|
|
47
47
|
__exportStar(require("./patch-merge"), exports);
|
|
48
|
+
__exportStar(require("./reconcile-write"), exports);
|
|
48
49
|
__exportStar(require("./noop-logger"), exports);
|
|
49
50
|
__exportStar(require("./observable-value"), exports);
|
|
50
51
|
__exportStar(require("./profile-session"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,kFAAkF;AAClF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,iDAAiD;AAEjD,oDAAkC;AAClC,2CAAyB;AACzB,+CAA6B;AAC7B,0CAAwB;AACxB,yCAAuB;AACvB,oDAAkC;AAClC,8CAA4B;AAC5B,4DAA0C;AAC1C,2CAAyB;AACzB,qDAAmC;AACnC,2CAAyB;AACzB,sDAAoC;AACpC,6EAA6E;AAC7E,+EAA+E;AAC/E,+BAA+B;AAC/B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,qDAAmC;AACnC,oDAAkC;AAClC,8CAA4B;AAC5B,2CAAyB;AACzB,wDAAsC;AACtC,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,iDAA+B;AAC/B,4CAA0B;AAC1B,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,kFAAkF;AAClF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,iDAAiD;AAEjD,oDAAkC;AAClC,2CAAyB;AACzB,+CAA6B;AAC7B,0CAAwB;AACxB,yCAAuB;AACvB,oDAAkC;AAClC,8CAA4B;AAC5B,4DAA0C;AAC1C,2CAAyB;AACzB,qDAAmC;AACnC,2CAAyB;AACzB,sDAAoC;AACpC,6EAA6E;AAC7E,+EAA+E;AAC/E,+BAA+B;AAC/B,wDAAsC;AACtC,gDAA8B;AAC9B,oDAAkC;AAClC,gDAA8B;AAC9B,qDAAmC;AACnC,oDAAkC;AAClC,8CAA4B;AAC5B,2CAAyB;AACzB,wDAAsC;AACtC,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,iDAA+B;AAC/B,4CAA0B;AAC1B,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB"}
|
package/lib/messages/index.d.ts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* The English is a fallback, not a contract; the code is the contract.
|
|
23
23
|
*/
|
|
24
24
|
export * from './primitives';
|
|
25
|
-
export { DOCUMENT_NOT_OPEN, DUPLICATE_CLIENT_ID, SESSION_CLOSED,
|
|
25
|
+
export { DOCUMENT_NOT_OPEN, DUPLICATE_CLIENT_ID, SESSION_CLOSED, STALE_BASE_VERSION_UPDATE } from '../errors';
|
|
26
26
|
export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
|
|
27
|
-
export { DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
|
|
27
|
+
export { DATA_SESSION_ANSWER_WITHOUT_MODEL, DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
|
|
28
28
|
export { RELAY_REPLAY_FAILED, RELAY_TRANSPORT_OPEN_FAILED, RELAY_TRANSPORT_READ_FAILED, RELAY_TRANSPORT_WRITE_FAILED } from '../client/message-relay';
|
|
29
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,iCAAiC,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnI,OAAO,EACJ,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,yBAAyB,CAAC"}
|
package/lib/messages/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
22
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = exports.RELAY_REPLAY_FAILED = exports.DATA_SESSION_UNSAVED_LOST = exports.DATA_SESSION_RESTORE_FAILED = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = exports.
|
|
25
|
+
exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = exports.RELAY_REPLAY_FAILED = exports.DATA_SESSION_UNSAVED_LOST = exports.DATA_SESSION_RESTORE_FAILED = exports.DATA_SESSION_ANSWER_WITHOUT_MODEL = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = exports.STALE_BASE_VERSION_UPDATE = exports.SESSION_CLOSED = exports.DUPLICATE_CLIENT_ID = exports.DOCUMENT_NOT_OPEN = void 0;
|
|
26
26
|
/**
|
|
27
27
|
* The message-externalization mechanism, plus every user-facing message
|
|
28
28
|
* `@hydranium/protocol` itself raises.
|
|
@@ -43,11 +43,12 @@ var errors_1 = require("../errors");
|
|
|
43
43
|
Object.defineProperty(exports, "DOCUMENT_NOT_OPEN", { enumerable: true, get: function () { return errors_1.DOCUMENT_NOT_OPEN; } });
|
|
44
44
|
Object.defineProperty(exports, "DUPLICATE_CLIENT_ID", { enumerable: true, get: function () { return errors_1.DUPLICATE_CLIENT_ID; } });
|
|
45
45
|
Object.defineProperty(exports, "SESSION_CLOSED", { enumerable: true, get: function () { return errors_1.SESSION_CLOSED; } });
|
|
46
|
-
Object.defineProperty(exports, "
|
|
46
|
+
Object.defineProperty(exports, "STALE_BASE_VERSION_UPDATE", { enumerable: true, get: function () { return errors_1.STALE_BASE_VERSION_UPDATE; } });
|
|
47
47
|
var rpc_connection_1 = require("../client/rpc-connection");
|
|
48
48
|
Object.defineProperty(exports, "DATA_SERVER_CONNECT_FAILED", { enumerable: true, get: function () { return rpc_connection_1.DATA_SERVER_CONNECT_FAILED; } });
|
|
49
49
|
Object.defineProperty(exports, "DATA_SERVER_NOT_READY", { enumerable: true, get: function () { return rpc_connection_1.DATA_SERVER_NOT_READY; } });
|
|
50
50
|
var data_session_1 = require("../client/data-session");
|
|
51
|
+
Object.defineProperty(exports, "DATA_SESSION_ANSWER_WITHOUT_MODEL", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_ANSWER_WITHOUT_MODEL; } });
|
|
51
52
|
Object.defineProperty(exports, "DATA_SESSION_RESTORE_FAILED", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_RESTORE_FAILED; } });
|
|
52
53
|
Object.defineProperty(exports, "DATA_SESSION_UNSAVED_LOST", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_UNSAVED_LOST; } });
|
|
53
54
|
var message_relay_1 = require("../client/message-relay");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;GAcG;AAEH,+CAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;GAcG;AAEH,+CAA6B;AAE7B,oCAA8G;AAArG,2GAAA,iBAAiB,OAAA;AAAE,6GAAA,mBAAmB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,mHAAA,yBAAyB,OAAA;AAC1F,2DAA6F;AAApF,4HAAA,0BAA0B,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AAC1D,uDAAmI;AAA1H,iIAAA,iCAAiC,OAAA;AAAE,2HAAA,2BAA2B,OAAA;AAAE,yHAAA,yBAAyB,OAAA;AAClG,yDAKiC;AAJ9B,oHAAA,mBAAmB,OAAA;AACnB,4HAAA,2BAA2B,OAAA;AAC3B,4HAAA,2BAA2B,OAAA;AAC3B,6HAAA,4BAA4B,OAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
declare const snapshotMarker: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* The version of the text a model was parsed from: a snapshot of the store's
|
|
12
|
+
* {@link TextVersion}, not a counter of its own. A document envelope carries
|
|
13
|
+
* it, and it cannot move once the envelope exists.
|
|
14
|
+
*
|
|
15
|
+
* A plain number at runtime, usable anywhere a number is, and it travels the
|
|
16
|
+
* wire as one. The marker exists only so the compiler can tell it apart from a
|
|
17
|
+
* version read off a LIVE document, which is the same number type and is the
|
|
18
|
+
* defect the conflict gate exists to prevent: read at write time it is whatever
|
|
19
|
+
* the server is at now, which is the number the gate is about to compare it
|
|
20
|
+
* against, so the gate passes unconditionally and a concurrent edit is
|
|
21
|
+
* overwritten with nothing logged.
|
|
22
|
+
*/
|
|
23
|
+
export type ModelVersion = number & {
|
|
24
|
+
readonly [snapshotMarker]: true;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The store's version of a document's text, which moves with every change of it.
|
|
28
|
+
* Unbranded, so a write refuses it as `baseVersion`: it can name text newer than
|
|
29
|
+
* the caller's model, and a write based on it would pass the gate with older content.
|
|
30
|
+
*/
|
|
31
|
+
export type TextVersion = number;
|
|
32
|
+
/**
|
|
33
|
+
* The version a write was authored against, from a snapshot read, or `'any'`: a
|
|
34
|
+
* precondition that always holds, so the write overwrites whatever the server has.
|
|
35
|
+
* `'any'` is a lie for a write authored against a document a read handed over.
|
|
36
|
+
*/
|
|
37
|
+
export type BaseVersion = ModelVersion | 'any';
|
|
38
|
+
/** Whether `baseVersion` names a version, and so arms the gate. */
|
|
39
|
+
export declare function isModelVersion(baseVersion: BaseVersion): baseVersion is ModelVersion;
|
|
40
|
+
/**
|
|
41
|
+
* Mark a version as having come from a snapshot read.
|
|
42
|
+
*
|
|
43
|
+
* **For the envelope constructors, not for callers.** Every door that builds a
|
|
44
|
+
* document envelope applies it on the way in, so anything a read returns
|
|
45
|
+
* already carries it and a writer never needs this. A caller reaching for it is
|
|
46
|
+
* asserting a provenance the compiler was about to deny — the read-late defect
|
|
47
|
+
* written out where a reviewer can see it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function asModelVersion(version: number): ModelVersion;
|
|
50
|
+
/**
|
|
51
|
+
* The model version of a root no document factory path built, so nothing
|
|
52
|
+
* records the text it came from. No write matches it, so a write based on it
|
|
53
|
+
* conflicts.
|
|
54
|
+
*/
|
|
55
|
+
export declare const UNRECORDED_VERSION: ModelVersion;
|
|
56
|
+
/**
|
|
57
|
+
* The model version of a root parsed from text the store holds under no
|
|
58
|
+
* version: the file, read while the store held the document open with other
|
|
59
|
+
* text. Below every text version, so the model reads as behind and a write
|
|
60
|
+
* based on it conflicts.
|
|
61
|
+
*/
|
|
62
|
+
export declare const STALE_VERSION: ModelVersion;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=base-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-version.d.ts","sourceRoot":"","sources":["../../src/model-service/base-version.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,KAAK,CAAC;AAE/C,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,YAAY,CAEpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAE5D;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAAiC,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,YAAiC,CAAC"}
|