@hydranium/protocol 1.0.0-next.187 → 1.0.0-next.189
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-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +10 -9
- 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/model-service/reference-candidate.d.ts +5 -3
- package/lib/model-service/reference-candidate.d.ts.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-protocol-methods.ts +1 -1
- package/src/data/data-server-protocol.ts +12 -9
- 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/model-service/reference-candidate.ts +5 -3
- 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
|
@@ -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"}
|
|
@@ -8,17 +8,12 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Branch on this rather than on `basedOn !== 'anything'`, which reads as "not
|
|
18
|
-
* based on anything" — the opposite of what the branch tests.
|
|
19
|
-
*/
|
|
20
|
-
function isSnapshotVersion(basedOn) {
|
|
21
|
-
return typeof basedOn === 'number';
|
|
11
|
+
exports.STALE_VERSION = exports.UNRECORDED_VERSION = void 0;
|
|
12
|
+
exports.isModelVersion = isModelVersion;
|
|
13
|
+
exports.asModelVersion = asModelVersion;
|
|
14
|
+
/** Whether `baseVersion` names a version, and so arms the gate. */
|
|
15
|
+
function isModelVersion(baseVersion) {
|
|
16
|
+
return typeof baseVersion === 'number';
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
24
19
|
* Mark a version as having come from a snapshot read.
|
|
@@ -29,9 +24,20 @@ function isSnapshotVersion(basedOn) {
|
|
|
29
24
|
* asserting a provenance the compiler was about to deny — the read-late defect
|
|
30
25
|
* written out where a reviewer can see it.
|
|
31
26
|
*/
|
|
32
|
-
function
|
|
27
|
+
function asModelVersion(version) {
|
|
33
28
|
return version;
|
|
34
29
|
}
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The model version of a root no document factory path built, so nothing
|
|
32
|
+
* records the text it came from. No write matches it, so a write based on it
|
|
33
|
+
* conflicts.
|
|
34
|
+
*/
|
|
35
|
+
exports.UNRECORDED_VERSION = asModelVersion(-2);
|
|
36
|
+
/**
|
|
37
|
+
* The model version of a root parsed from text the store holds under no
|
|
38
|
+
* version: the file, read while the store held the document open with other
|
|
39
|
+
* text. Below every text version, so the model reads as behind and a write
|
|
40
|
+
* based on it conflicts.
|
|
41
|
+
*/
|
|
42
|
+
exports.STALE_VERSION = asModelVersion(-1);
|
|
43
|
+
//# sourceMappingURL=base-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-version.js","sourceRoot":"","sources":["../../src/model-service/base-version.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAiClF,mEAAmE;AACnE,wBAA+B,WAAwB;IACpD,OAAO,OAAO,WAAW,KAAK,QAAQ,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,wBAA+B,OAAe;IAC3C,OAAO,OAAuB,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACU,QAAA,kBAAkB,GAAiB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE;;;;;GAKG;AACU,QAAA,aAAa,GAAiB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model-service/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAMlF,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model-service/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAMlF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
@@ -22,9 +22,9 @@ 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
|
-
// Generic payload types the data protocol shares with core: the
|
|
25
|
+
// Generic payload types the data protocol shares with core: the base
|
|
26
26
|
// version, which the server's model service checks writes against, and the
|
|
27
27
|
// reference candidates, which core's scope and completion code produce.
|
|
28
|
-
__exportStar(require("./
|
|
28
|
+
__exportStar(require("./base-version"), exports);
|
|
29
29
|
__exportStar(require("./reference-candidate"), exports);
|
|
30
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model-service/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model-service/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,qEAAqE;AACrE,2EAA2E;AAC3E,wEAAwE;AAExE,iDAA+B;AAC/B,wDAAsC"}
|
|
@@ -47,10 +47,12 @@ export interface ReferenceCandidate {
|
|
|
47
47
|
* node's subtree, NOT the whole document root — callers that want the full
|
|
48
48
|
* document fetch it via `getModelDocument(uri)`.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
50
|
+
* `TElement` is the type of the target node, not of a document root. A server
|
|
51
|
+
* answers with the structural base, since a reference can name any node; a
|
|
52
|
+
* caller that knows what the reference targets may narrow it.
|
|
51
53
|
*/
|
|
52
|
-
export interface ReferenceTarget<
|
|
54
|
+
export interface ReferenceTarget<TElement extends TransferElement = TransferElement> extends ReferenceCandidate {
|
|
53
55
|
/** The resolved target node, encoded as a transfer subtree. */
|
|
54
|
-
element:
|
|
56
|
+
element: TElement;
|
|
55
57
|
}
|
|
56
58
|
//# sourceMappingURL=reference-candidate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference-candidate.d.ts","sourceRoot":"","sources":["../../src/model-service/reference-candidate.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IAChC,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"reference-candidate.d.ts","sourceRoot":"","sources":["../../src/model-service/reference-candidate.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IAChC,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,kBAAkB;IAC5G,+DAA+D;IAC/D,OAAO,EAAE,QAAQ,CAAC;CACpB"}
|
package/lib/patch-merge.d.ts
CHANGED
|
@@ -32,8 +32,9 @@ import { type Operation as JsonPatchOperation } from 'fast-json-patch';
|
|
|
32
32
|
export declare function augmentWithTestOps(base: object, userPatch: ReadonlyArray<JsonPatchOperation>): JsonPatchOperation[];
|
|
33
33
|
/**
|
|
34
34
|
* Outcome of {@link reconcileByPatchReplay}. The caller persists `merged` and
|
|
35
|
-
* takes it as the new base, drops + surfaces the `theirs` root on `conflict`,
|
|
36
|
-
* decides its own fallback (e.g.
|
|
35
|
+
* takes it as the new base, drops + surfaces the `theirs` root on `conflict`,
|
|
36
|
+
* catches up with the server on `no-op`, and decides its own fallback (e.g.
|
|
37
|
+
* force-retry) on `unavailable`.
|
|
37
38
|
*/
|
|
38
39
|
export type ReconcileOutcome<T> = {
|
|
39
40
|
/** The replay succeeded: the foreign writer touched no path the user did. */
|
|
@@ -46,9 +47,10 @@ export type ReconcileOutcome<T> = {
|
|
|
46
47
|
merged: T;
|
|
47
48
|
} | {
|
|
48
49
|
/**
|
|
49
|
-
* The user's root
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* The user's root equalled the base, so the gate fired on another writer's
|
|
51
|
+
* change and the caller is behind the server (`ConflictError.actualVersion`).
|
|
52
|
+
* Nothing was refetched. Catch up from the update at that version or a later
|
|
53
|
+
* one, or refetch; forcing the write overwrites the other writer's change.
|
|
52
54
|
*/
|
|
53
55
|
status: 'no-op';
|
|
54
56
|
} | {
|
|
@@ -73,8 +75,8 @@ export type ReconcileOutcome<T> = {
|
|
|
73
75
|
* (`base → ours`), refetch the server's current root (theirs), and replay the
|
|
74
76
|
* intent on top under strict, {@link augmentWithTestOps}-guarded `applyPatch`.
|
|
75
77
|
*
|
|
76
|
-
* - `no-op` — the user's root equals the base
|
|
77
|
-
*
|
|
78
|
+
* - `no-op` — the user's root equals the base: nothing to replay, and no
|
|
79
|
+
* refetch; the caller's document is behind the server's.
|
|
78
80
|
* - `unavailable` — the refetch produced nothing; caller falls back.
|
|
79
81
|
* - `merged` — the foreign writer touched only paths the user did not; the
|
|
80
82
|
* merged root carries both intents.
|
|
@@ -98,8 +100,8 @@ export interface ConflictResolver {
|
|
|
98
100
|
/**
|
|
99
101
|
* Reconcile the user's `base → ours` intent against the current
|
|
100
102
|
* server state (theirs, from `refetch`), returning a {@link ReconcileOutcome} the caller
|
|
101
|
-
* acts on (persist `merged`, drop on `conflict`,
|
|
102
|
-
* `unavailable`).
|
|
103
|
+
* acts on (persist `merged`, drop on `conflict`, catch up on `no-op`, fall
|
|
104
|
+
* back on `unavailable`).
|
|
103
105
|
*/
|
|
104
106
|
resolve<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
105
107
|
}
|
package/lib/patch-merge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-merge.d.ts","sourceRoot":"","sources":["../src/patch-merge.ts"],"names":[],"mappings":"AAAA;;;;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gB;IAC9B;;;;;OAKG;IACH,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;CACnH;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,YAAW,gBAAgB;IACjE,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAE/G;CACH;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;IACrD,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAEvH;CACH"}
|
package/lib/patch-merge.js
CHANGED
|
@@ -49,8 +49,8 @@ function augmentWithTestOps(base, userPatch) {
|
|
|
49
49
|
* (`base → ours`), refetch the server's current root (theirs), and replay the
|
|
50
50
|
* intent on top under strict, {@link augmentWithTestOps}-guarded `applyPatch`.
|
|
51
51
|
*
|
|
52
|
-
* - `no-op` — the user's root equals the base
|
|
53
|
-
*
|
|
52
|
+
* - `no-op` — the user's root equals the base: nothing to replay, and no
|
|
53
|
+
* refetch; the caller's document is behind the server's.
|
|
54
54
|
* - `unavailable` — the refetch produced nothing; caller falls back.
|
|
55
55
|
* - `merged` — the foreign writer touched only paths the user did not; the
|
|
56
56
|
* merged root carries both intents.
|
package/lib/patch-merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-merge.js","sourceRoot":"","sources":["../src/patch-merge.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAElF,qDAQyB;AAEzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,4BAAmC,IAAY,EAAE,SAA4C;IAC1F,MAAM,SAAS,GAAyB,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,EAAE,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,mCAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"patch-merge.js","sourceRoot":"","sources":["../src/patch-merge.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAElF,qDAQyB;AAEzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,4BAAmC,IAAY,EAAE,SAA4C;IAC1F,MAAM,SAAS,GAAyB,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,EAAE,CAAC,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC7C,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,mCAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;QACD,SAAS,CAAC,I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C,MAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACpB,CAAC;AACJ,CAAC;AAmBD;;;;;GAKG;AACH;IACG,OAAO,CAAmB,IAAO,EAAE,IAAO,EAAE,OAAqC;QAC9E,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACH;;AAED;;;;;GAKG;AACH;IACG,KAAK,CAAC,OAAO,CAAmB,KAAQ,EAAE,IAAO,EAAE,QAAsC;QACtF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;CACH"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
import { type ConflictError } from './errors';
|
|
10
|
+
import { type BaseVersion, type ModelVersion } from './model-service/base-version';
|
|
11
|
+
import { type ConflictResolver } from './patch-merge';
|
|
12
|
+
/** A model and the version of the text it was read from, which a write based on it names. */
|
|
13
|
+
export interface VersionedModel<TModel> {
|
|
14
|
+
readonly model: TModel;
|
|
15
|
+
readonly baseVersion: ModelVersion;
|
|
16
|
+
}
|
|
17
|
+
/** The I/O and policy a {@link reconcileWrite} call needs. */
|
|
18
|
+
export interface ReconcileWriteHooks<TModel> {
|
|
19
|
+
/**
|
|
20
|
+
* Write `model`. Called with the caller's own `baseVersion` first, with the
|
|
21
|
+
* refetch's on a merged write, and with `'any'` for a merge that refetched
|
|
22
|
+
* nothing, where the resolver has already decided to win.
|
|
23
|
+
*/
|
|
24
|
+
persist(model: TModel, baseVersion: BaseVersion): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Current server-side model, or `undefined` when unavailable. Its version is
|
|
27
|
+
* read in the tick its text is: a later one lets a merged write overwrite an
|
|
28
|
+
* edit the merge never saw.
|
|
29
|
+
*/
|
|
30
|
+
refetch(): Promise<VersionedModel<TModel> | undefined>;
|
|
31
|
+
/** The last in-sync model the user's intent is measured against. */
|
|
32
|
+
readonly base: TModel;
|
|
33
|
+
readonly conflictResolver: ConflictResolver;
|
|
34
|
+
/** Writes, the first included, after which a still-conflicting edit is dropped; 3 when absent. */
|
|
35
|
+
readonly maxWrites?: number;
|
|
36
|
+
/** Runs when the refetch is unavailable; absent, the edit is left unwritten. */
|
|
37
|
+
onUnavailable?(model: TModel, conflict: ConflictError): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What {@link reconcileWrite} did. Every status but `persisted` follows a
|
|
41
|
+
* conflict, and carries the last one and the writes made, the first included.
|
|
42
|
+
*/
|
|
43
|
+
export type ReconcileWriteOutcome =
|
|
44
|
+
/** The first write landed. */
|
|
45
|
+
{
|
|
46
|
+
readonly status: 'persisted';
|
|
47
|
+
} | {
|
|
48
|
+
/**
|
|
49
|
+
* `merged`: a merged write landed. `unchanged`: the edit was empty, so the
|
|
50
|
+
* caller is behind the server. `conflict`: the resolver found a same-path
|
|
51
|
+
* collision. `dropped`: the writes ran out. `unavailable`: the refetch
|
|
52
|
+
* produced nothing and {@link ReconcileWriteHooks.onUnavailable} ran.
|
|
53
|
+
*/
|
|
54
|
+
readonly status: 'merged' | 'unchanged' | 'conflict' | 'dropped' | 'unavailable';
|
|
55
|
+
readonly conflict: ConflictError;
|
|
56
|
+
readonly writes: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Persist `model`, and on a `ConflictError` reconcile the user's `base → model`
|
|
60
|
+
* intent onto the refetched server model and write the merge, gated on the
|
|
61
|
+
* refetch's version, again on each conflict up to `maxWrites` writes. A
|
|
62
|
+
* non-conflict error is re-thrown.
|
|
63
|
+
*/
|
|
64
|
+
export declare function reconcileWrite<TModel extends object>(model: TModel, baseVersion: BaseVersion, hooks: ReconcileWriteHooks<TModel>): Promise<ReconcileWriteOutcome>;
|
|
65
|
+
//# sourceMappingURL=reconcile-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile-write.d.ts","sourceRoot":"","sources":["../src/reconcile-write.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,6FAA6F;AAC7F,MAAM,WAAW,cAAc,CAAC,MAAM;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;CACrC;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB,CAAC,MAAM;IACxC;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IACvD,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,kGAAkG;IAClG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB;AAC9B,8BAA8B;AAC5B;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAChC;IACG;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;IACjF,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEP;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,MAAM,SAAS,MAAM,EACvD,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAClC,OAAO,CAAC,qBAAqB,CAAC,CAiChC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.reconcileWrite = reconcileWrite;
|
|
12
|
+
const errors_1 = require("./errors");
|
|
13
|
+
const DEFAULT_MAX_WRITES = 3;
|
|
14
|
+
/**
|
|
15
|
+
* Persist `model`, and on a `ConflictError` reconcile the user's `base → model`
|
|
16
|
+
* intent onto the refetched server model and write the merge, gated on the
|
|
17
|
+
* refetch's version, again on each conflict up to `maxWrites` writes. A
|
|
18
|
+
* non-conflict error is re-thrown.
|
|
19
|
+
*/
|
|
20
|
+
async function reconcileWrite(model, baseVersion, hooks) {
|
|
21
|
+
let candidate = model;
|
|
22
|
+
let candidateBaseVersion = baseVersion;
|
|
23
|
+
let previous;
|
|
24
|
+
const maxWrites = hooks.maxWrites ?? DEFAULT_MAX_WRITES;
|
|
25
|
+
for (let writes = 1;; writes++) {
|
|
26
|
+
const conflict = await persistOrConflict(hooks, candidate, candidateBaseVersion);
|
|
27
|
+
if (!conflict) {
|
|
28
|
+
return previous ? { status: 'merged', conflict: previous, writes } : { status: 'persisted' };
|
|
29
|
+
}
|
|
30
|
+
previous = conflict;
|
|
31
|
+
if (writes >= maxWrites) {
|
|
32
|
+
return { status: 'dropped', conflict, writes };
|
|
33
|
+
}
|
|
34
|
+
let refetched;
|
|
35
|
+
const outcome = await hooks.conflictResolver.resolve(hooks.base, model, async () => {
|
|
36
|
+
refetched = await hooks.refetch();
|
|
37
|
+
return refetched?.model;
|
|
38
|
+
});
|
|
39
|
+
switch (outcome.status) {
|
|
40
|
+
case 'merged':
|
|
41
|
+
candidate = outcome.merged;
|
|
42
|
+
candidateBaseVersion = refetched?.baseVersion ?? 'any';
|
|
43
|
+
continue;
|
|
44
|
+
case 'no-op':
|
|
45
|
+
return { status: 'unchanged', conflict, writes };
|
|
46
|
+
case 'conflict':
|
|
47
|
+
return { status: 'conflict', conflict, writes };
|
|
48
|
+
case 'unavailable':
|
|
49
|
+
await hooks.onUnavailable?.(model, conflict);
|
|
50
|
+
return { status: 'unavailable', conflict, writes };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** The `ConflictError` the write raised, or `undefined` when it landed. */
|
|
55
|
+
async function persistOrConflict(hooks, model, baseVersion) {
|
|
56
|
+
try {
|
|
57
|
+
await hooks.persist(model, baseVersion);
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (!(0, errors_1.isConflictError)(err)) {
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
return err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=reconcile-write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile-write.js","sourceRoot":"","sources":["../src/reconcile-write.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;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AC;gBACvD,SAAS;YACZ,KAAK,OAAO;gBACT,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;YACpD,KAAK,UAAU;gBACZ,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;YACnD,KAAK,aAAa;gBACf,MAAM,KAAK,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAC7C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QACzD,CAAC;IACJ,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,KAAK,UAAU,iBAAiB,CAC7B,KAAkC,EAClC,KAAa,EACb,WAAwB;IAExB,IAAI,CAAC;QACF,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACxC,OAAO,SAAS,CAAC;IACpB,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACrB,IAAI,CAAC,IAAA,wBAAe,EAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,CAAC;QACb,CAAC;QACD,OAAO,GAAG,CAAC;IACd,CAAC;AACJ,CAAC"}
|
|
@@ -169,6 +169,9 @@ export declare function defaultIsNotification(methodName: string): boolean;
|
|
|
169
169
|
* params, results and errors, and a second layer here would double every
|
|
170
170
|
* traced line.
|
|
171
171
|
*
|
|
172
|
+
* A rejection whose code names one of the framework's typed errors is rethrown
|
|
173
|
+
* as that class, through {@link reviveProtocolError}.
|
|
174
|
+
*
|
|
172
175
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
173
176
|
* proxy methods called before the promise resolves queue until it does,
|
|
174
177
|
* then dispatch, so adopters can wire the proxy before its underlying
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-proxy.d.ts","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mapp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IAEpD;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;CAC5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEjE;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,EAC3E,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAC1D,OAAO,GAAE,qBAAqB,CAAC,MAAM,CAAM,GAC3C,QAAQ,CAAC,CAAC,CAAC,CAgFb"}
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.defaultIsNotification = defaultIsNotification;
|
|
12
12
|
exports.createRpcProxy = createRpcProxy;
|
|
13
13
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
|
+
const errors_1 = require("../errors");
|
|
14
15
|
const bind_rpc_methods_1 = require("./bind-rpc-methods");
|
|
15
16
|
const wire_prefix_1 = require("./wire-prefix");
|
|
16
17
|
/**
|
|
@@ -61,6 +62,9 @@ function assertSingleArg(wireName, args) {
|
|
|
61
62
|
* params, results and errors, and a second layer here would double every
|
|
62
63
|
* traced line.
|
|
63
64
|
*
|
|
65
|
+
* A rejection whose code names one of the framework's typed errors is rethrown
|
|
66
|
+
* as that class, through {@link reviveProtocolError}.
|
|
67
|
+
*
|
|
64
68
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
65
69
|
* proxy methods called before the promise resolves queue until it does,
|
|
66
70
|
* then dispatch, so adopters can wire the proxy before its underlying
|
|
@@ -150,7 +154,8 @@ function createRpcProxy(connection, options = {}) {
|
|
|
150
154
|
const capturedError = new Error(`RPC request '${wireName}' failed`);
|
|
151
155
|
return resolvedConnection
|
|
152
156
|
.then(connection => connection.sendRequest(wireName, args[0]))
|
|
153
|
-
.catch((
|
|
157
|
+
.catch((rejection) => {
|
|
158
|
+
const err = (0, errors_1.reviveProtocolError)(rejection);
|
|
154
159
|
if (err instanceof Error && capturedError.stack) {
|
|
155
160
|
err.stack = `${err.stack ?? err.message}\nCaused by request from:\n${capturedError.stack}`;
|
|
156
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-proxy.js","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AAElF,mDAA6E;AAC7E,yDAAgF;AAChF,+CAA2D;AAyI3D;;;;;;;;;;;;;;;GAeG;AACH,+BAAsC,UAAkB;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,IAAe;IACvD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACZ,eAAe,QAAQ,iBAAiB,IAAI,CAAC,MAAM,2DAA2D;YAC3G,uDAAuD,CAC5D,CAAC;IACL,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"create-rpc-proxy.js","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AAElF,mDAA6E;AAC7E,sCAAgD;AAChD,yDAAgF;AAChF,+CAA2D;AAyI3D;;;;;;;;;;;;;;;GAeG;AACH,+BAAsC,UAAkB;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,IAAe;IACvD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACZ,e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