@hydranium/protocol 1.0.0-next.19 → 1.0.0-next.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +157 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +236 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +13 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +21 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +24 -22
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +461 -81
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +725 -108
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +14 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +14 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +9 -3
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +11 -5
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +149 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +202 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +38 -0
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/data/data-protocol-methods.d.ts +4 -4
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +11 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +117 -36
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +110 -15
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +67 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +181 -29
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +261 -29
- package/lib/errors.js.map +1 -1
- package/lib/glsp-save-model-actions.d.ts +50 -0
- package/lib/glsp-save-model-actions.d.ts.map +1 -0
- package/lib/glsp-save-model-actions.js +28 -0
- package/lib/glsp-save-model-actions.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +8 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js.map +1 -1
- package/lib/logger.d.ts +22 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +31 -3
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +29 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +59 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +188 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +161 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +60 -13
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.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/base-version.js +43 -0
- 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 +4 -5
- 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/noop-logger.d.ts.map +1 -1
- package/lib/noop-logger.js.map +1 -1
- package/lib/observable-value.js.map +1 -1
- package/lib/patch-merge.d.ts +35 -32
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +67 -23
- package/lib/patch-merge.js.map +1 -1
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.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/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +10 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +12 -2
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/rpc/wire-prefix.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +13 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +19 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +9 -1
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +54 -45
- package/lib/testing/fake-clock.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +5 -2
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +59 -32
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +17 -9
- package/lib/transfer-document.js.map +1 -1
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -0
- package/lib/util.js.map +1 -1
- package/package.json +27 -18
- package/src/client/data-connection.ts +314 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +25 -23
- package/src/client/data-session.ts +922 -126
- package/src/client/index.ts +14 -9
- package/src/client/message-relay.ts +29 -7
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +268 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +56 -0
- package/src/data/data-protocol-methods.ts +12 -4
- package/src/data/data-server-protocol.ts +140 -36
- package/src/data/events.ts +116 -15
- package/src/data/requests.ts +71 -11
- package/src/errors.ts +311 -36
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +7 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +28 -2
- package/src/messages/index.ts +36 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +63 -18
- package/src/model-service/base-version.ts +72 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/patch-merge.ts +97 -42
- package/src/profile-session.ts +9 -4
- package/src/reconcile-write.ts +124 -0
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +20 -2
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +42 -17
- package/src/testing/fake-clock.ts +62 -47
- package/src/testing/index.ts +5 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/transfer-diagnostic.ts +40 -0
- package/src/transfer-document.ts +74 -34
- package/src/util.ts +33 -0
- package/lib/model-service/args.d.ts +0 -64
- package/lib/model-service/args.d.ts.map +0 -1
- package/lib/model-service/args.js +0 -11
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 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.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';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Mark a version as having come from a snapshot read.
|
|
20
|
+
*
|
|
21
|
+
* **For the envelope constructors, not for callers.** Every door that builds a
|
|
22
|
+
* document envelope applies it on the way in, so anything a read returns
|
|
23
|
+
* already carries it and a writer never needs this. A caller reaching for it is
|
|
24
|
+
* asserting a provenance the compiler was about to deny — the read-late defect
|
|
25
|
+
* written out where a reviewer can see it.
|
|
26
|
+
*/
|
|
27
|
+
function asModelVersion(version) {
|
|
28
|
+
return version;
|
|
29
|
+
}
|
|
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;
|
|
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,10 +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
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
__exportStar(require("./args"), exports);
|
|
25
|
+
// Generic payload types the data protocol shares with core: the base
|
|
26
|
+
// version, which the server's model service checks writes against, and the
|
|
27
|
+
// reference candidates, which core's scope and completion code produce.
|
|
28
|
+
__exportStar(require("./base-version"), exports);
|
|
30
29
|
__exportStar(require("./reference-candidate"), exports);
|
|
31
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/noop-logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noop-logger.d.ts","sourceRoot":"","sources":["../src/noop-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,cAAe,YAAW,MAAM;IAC7D,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"noop-logger.d.ts","sourceRoot":"","sources":["../src/noop-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,cAAe,YAAW,MAAM;IAC7D,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAElG;IAEQ,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGnC;IAED,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGxC;CACH"}
|
package/lib/noop-logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noop-logger.js","sourceRoot":"","sources":["../src/noop-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,uDAAmD;AAGnD;;;;;;;;GAQG;AACH,
|
|
1
|
+
{"version":3,"file":"noop-logger.js","sourceRoot":"","sources":["../src/noop-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,uDAAmD;AAGnD;;;;;;;;GAQG;AACH,gBAAwB,SAAQ,gCAAc;IACjC,IAAI,CAAC,MAAgB,EAAE,MAAc,EAAE,QAAgB,EAAE,KAAyB;QACzF,qCAAqC;IACxC,CAAC;IAEQ,OAAO,CAAC,IAAY;QAC1B,qEAAqE;QACrE,OAAO,IAAI,CAAC;IACf,CAAC;IAES,MAAM,CAAC,SAAiB;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAA+C,CAAC;QACtE,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observable-value.js","sourceRoot":"","sources":["../src/observable-value.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"observable-value.js","sourceRoot":"","sources":["../src/observable-value.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AA6ClF,MAAM,eAAe,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;AAEhF,6EAA6E;AAC7E,MAAM,WAAW,GAAiB,GAAG,EAAE,CAAC,eAAe,CAAC;AAExD;;;;;GAKG;AACH,2BAAqC,KAA8B;IAChE,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,KAAoC,CAAC;IACvD,OAAO,OAAO,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC;AAC3E,CAAC;AAED,IAAiB,eAAe,CAoB/B;AApBD,WAAiB,eAAe;IAC7B;;;;;OAKG;IACH,SAAgB,EAAE,CAAI,KAAQ;QAC3B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAuB,EAAE,CAAC;IACvD,CAAC;IAFe,gBAAA,EAAE,KAEjB,CAAA;IAED;;;;;OAKG;IACH,SAAgB,IAAI,CAAI,KAA8B;QACnD,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IAFe,gBAAA,IAAI,OAEnB,CAAA;AACJ,CAAC,EApBgB,eAAe,aAAf,eAAe,GAAf,eAAe,QAoB/B"}
|
package/lib/patch-merge.d.ts
CHANGED
|
@@ -8,58 +8,60 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Operation as JsonPatchOperation } from 'fast-json-patch';
|
|
10
10
|
/**
|
|
11
|
-
* Augment a user-intent JSON patch (computed `
|
|
11
|
+
* Augment a user-intent JSON patch (computed `base → ours`) with
|
|
12
12
|
* `test` ops so a strict `applyPatch` against freshly-fetched server state
|
|
13
13
|
* fails loudly when a foreign writer changed a path the user also changed.
|
|
14
14
|
*
|
|
15
15
|
* `fast-json-patch`'s `validateOperation: true` validates op structure and
|
|
16
16
|
* path resolvability but NOT the pre-existing value — a plain `replace` /
|
|
17
17
|
* `remove` silently overwrites whatever the foreign writer put there. For each
|
|
18
|
-
* `replace` / `remove` op we prepend a `test` op carrying the
|
|
18
|
+
* `replace` / `remove` op we prepend a `test` op carrying the base value at
|
|
19
19
|
* that path, so a same-path divergence becomes a `TEST_OPERATION_FAILED` throw.
|
|
20
20
|
* The caller treats that as a real field-level conflict (drop + refetch) rather
|
|
21
21
|
* than silently clobbering the foreign edit.
|
|
22
22
|
*
|
|
23
|
-
* `add` ops
|
|
24
|
-
* to test
|
|
23
|
+
* `add` ops get no `test` op: the path is new, so there is no base value
|
|
24
|
+
* to test. {@link reconcileByPatchReplay} checks them against theirs
|
|
25
|
+
* instead; a caller applying this patch itself does not get that check.
|
|
25
26
|
*
|
|
26
27
|
* Used behind the framework's `ConflictError` contract by every reconcile
|
|
27
28
|
* path — the GLSP recording command's undo/redo and forward-write, via
|
|
28
29
|
* {@link ReconcilingConflictResolver}, and an adopter's form-widget save — so
|
|
29
30
|
* they share one collision-detection rule.
|
|
30
31
|
*/
|
|
31
|
-
export declare function augmentWithTestOps(
|
|
32
|
+
export declare function augmentWithTestOps(base: object, userPatch: ReadonlyArray<JsonPatchOperation>): JsonPatchOperation[];
|
|
32
33
|
/**
|
|
33
|
-
* Outcome of {@link reconcileByPatchReplay}. The caller persists
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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
|
+
* catches up with the server on `no-op`, and decides its own fallback (e.g.
|
|
37
|
+
* force-retry) on `unavailable`.
|
|
36
38
|
*/
|
|
37
39
|
export type ReconcileOutcome<T> = {
|
|
38
40
|
/** The replay succeeded: the foreign writer touched no path the user did. */
|
|
39
41
|
status: 'merged';
|
|
40
42
|
/**
|
|
41
|
-
* A
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* had.
|
|
43
|
+
* A new root built on theirs, carrying both intents. It is NOT the
|
|
44
|
+
* caller's `ours` root — take this value as the new base, or the next
|
|
45
|
+
* write diffs against state the server never had.
|
|
45
46
|
*/
|
|
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
|
} | {
|
|
55
|
-
/**
|
|
57
|
+
/** User and foreign writer changed one path, or both added the same element or key. */
|
|
56
58
|
status: 'conflict';
|
|
57
59
|
/**
|
|
58
60
|
* The server's current root, refetched and unmodified — the user's
|
|
59
61
|
* intent was NOT applied to it. Surface it and drop the write; treating
|
|
60
62
|
* it as a merge result silently discards what the user typed.
|
|
61
63
|
*/
|
|
62
|
-
|
|
64
|
+
theirs: T;
|
|
63
65
|
} | {
|
|
64
66
|
/**
|
|
65
67
|
* The refetch produced nothing, so reconciliation could not be
|
|
@@ -70,22 +72,23 @@ export type ReconcileOutcome<T> = {
|
|
|
70
72
|
};
|
|
71
73
|
/**
|
|
72
74
|
* Shared three-way reconcile for a `ConflictError`: diff the user's intent
|
|
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
|
|
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.
|
|
81
|
-
* - `conflict` — a same-path divergence tripped a `test` op
|
|
82
|
-
* write and
|
|
83
|
+
* - `conflict` — a same-path divergence tripped a `test` op, or an `add`
|
|
84
|
+
* collides with one the foreign writer made; caller drops the write and
|
|
85
|
+
* surfaces `theirs`.
|
|
83
86
|
*
|
|
84
87
|
* I/O is the caller's: `refetch` supplies the current root, and applying the
|
|
85
|
-
* `merged` result (update vs save,
|
|
88
|
+
* `merged` result (update vs save, new base, UI refresh) stays at the call
|
|
86
89
|
* site so form and GLSP paths keep their own persistence semantics.
|
|
87
90
|
*/
|
|
88
|
-
export declare function reconcileByPatchReplay<T extends object>(
|
|
91
|
+
export declare function reconcileByPatchReplay<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
89
92
|
/**
|
|
90
93
|
* Strategy for resolving a write that raced a foreign edit. One declarative
|
|
91
94
|
* choice covers every conflict site — `execute` forward-write `(before,
|
|
@@ -95,12 +98,12 @@ export declare function reconcileByPatchReplay<T extends object>(baseline: T, at
|
|
|
95
98
|
*/
|
|
96
99
|
export interface ConflictResolver {
|
|
97
100
|
/**
|
|
98
|
-
* Reconcile the user's `
|
|
99
|
-
* server state (`refetch`), returning a {@link ReconcileOutcome} the caller
|
|
100
|
-
* acts on (persist `merged`, drop on `conflict`,
|
|
101
|
-
* `unavailable`).
|
|
101
|
+
* Reconcile the user's `base → ours` intent against the current
|
|
102
|
+
* server state (theirs, from `refetch`), returning a {@link ReconcileOutcome} the caller
|
|
103
|
+
* acts on (persist `merged`, drop on `conflict`, catch up on `no-op`, fall
|
|
104
|
+
* back on `unavailable`).
|
|
102
105
|
*/
|
|
103
|
-
resolve<T extends object>(
|
|
106
|
+
resolve<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
106
109
|
* Default {@link ConflictResolver}: field-level three-way merge via
|
|
@@ -109,15 +112,15 @@ export interface ConflictResolver {
|
|
|
109
112
|
* clobbered.
|
|
110
113
|
*/
|
|
111
114
|
export declare class ReconcilingConflictResolver implements ConflictResolver {
|
|
112
|
-
resolve<T extends object>(
|
|
115
|
+
resolve<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
113
116
|
}
|
|
114
117
|
/**
|
|
115
|
-
* Last-writer-wins {@link ConflictResolver}: always reports the `
|
|
118
|
+
* Last-writer-wins {@link ConflictResolver}: always reports the `ours`
|
|
116
119
|
* state as merged, without refetching or guarding. Suitable for single-client
|
|
117
120
|
* tools or always-regenerated artifacts where a concurrent foreign edit may be
|
|
118
121
|
* overwritten. A foreign edit to any field is clobbered.
|
|
119
122
|
*/
|
|
120
123
|
export declare class ForceConflictResolver implements ConflictResolver {
|
|
121
|
-
resolve<T extends object>(
|
|
124
|
+
resolve<T extends object>(_base: T, ours: T, _refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
122
125
|
}
|
|
123
126
|
//# sourceMappingURL=patch-merge.d.ts.map
|
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;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"patch-merge.d.ts","sourceRoot":"","sources":["../src/patch-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAMJ,KAAK,SAAS,IAAI,kBAAkB,EAEtC,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,EAAE,CASnH;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IACzB;IACG,6EAA6E;IAC7E,MAAM,EAAE,QAAQ,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,CAAC,CAAC;CACZ,GACD;IACG;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC;CAClB,GACD;IACG,uFAAuF;IACvF,MAAM,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,MAAM,EAAE,CAAC,CAAC;CACZ,GACD;IACG;;;;OAIG;IACH,MAAM,EAAE,aAAa,CAAC;CACxB,CAAC;AAEP;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAC1D,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAkB9B;AA2CD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;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
|
@@ -13,31 +13,32 @@ exports.augmentWithTestOps = augmentWithTestOps;
|
|
|
13
13
|
exports.reconcileByPatchReplay = reconcileByPatchReplay;
|
|
14
14
|
const fast_json_patch_1 = require("fast-json-patch");
|
|
15
15
|
/**
|
|
16
|
-
* Augment a user-intent JSON patch (computed `
|
|
16
|
+
* Augment a user-intent JSON patch (computed `base → ours`) with
|
|
17
17
|
* `test` ops so a strict `applyPatch` against freshly-fetched server state
|
|
18
18
|
* fails loudly when a foreign writer changed a path the user also changed.
|
|
19
19
|
*
|
|
20
20
|
* `fast-json-patch`'s `validateOperation: true` validates op structure and
|
|
21
21
|
* path resolvability but NOT the pre-existing value — a plain `replace` /
|
|
22
22
|
* `remove` silently overwrites whatever the foreign writer put there. For each
|
|
23
|
-
* `replace` / `remove` op we prepend a `test` op carrying the
|
|
23
|
+
* `replace` / `remove` op we prepend a `test` op carrying the base value at
|
|
24
24
|
* that path, so a same-path divergence becomes a `TEST_OPERATION_FAILED` throw.
|
|
25
25
|
* The caller treats that as a real field-level conflict (drop + refetch) rather
|
|
26
26
|
* than silently clobbering the foreign edit.
|
|
27
27
|
*
|
|
28
|
-
* `add` ops
|
|
29
|
-
* to test
|
|
28
|
+
* `add` ops get no `test` op: the path is new, so there is no base value
|
|
29
|
+
* to test. {@link reconcileByPatchReplay} checks them against theirs
|
|
30
|
+
* instead; a caller applying this patch itself does not get that check.
|
|
30
31
|
*
|
|
31
32
|
* Used behind the framework's `ConflictError` contract by every reconcile
|
|
32
33
|
* path — the GLSP recording command's undo/redo and forward-write, via
|
|
33
34
|
* {@link ReconcilingConflictResolver}, and an adopter's form-widget save — so
|
|
34
35
|
* they share one collision-detection rule.
|
|
35
36
|
*/
|
|
36
|
-
function augmentWithTestOps(
|
|
37
|
+
function augmentWithTestOps(base, userPatch) {
|
|
37
38
|
const augmented = [];
|
|
38
39
|
for (const op of userPatch) {
|
|
39
40
|
if (op.op === 'replace' || op.op === 'remove') {
|
|
40
|
-
augmented.push({ op: 'test', path: op.path, value: (0, fast_json_patch_1.getValueByPointer)(
|
|
41
|
+
augmented.push({ op: 'test', path: op.path, value: (0, fast_json_patch_1.getValueByPointer)(base, op.path) });
|
|
41
42
|
}
|
|
42
43
|
augmented.push(op);
|
|
43
44
|
}
|
|
@@ -45,36 +46,79 @@ function augmentWithTestOps(baseline, userPatch) {
|
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Shared three-way reconcile for a `ConflictError`: diff the user's intent
|
|
48
|
-
* (`
|
|
49
|
+
* (`base → ours`), refetch the server's current root (theirs), and replay the
|
|
49
50
|
* intent on top under strict, {@link augmentWithTestOps}-guarded `applyPatch`.
|
|
50
51
|
*
|
|
51
|
-
* - `no-op` — the user's root equals the
|
|
52
|
-
*
|
|
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.
|
|
53
54
|
* - `unavailable` — the refetch produced nothing; caller falls back.
|
|
54
55
|
* - `merged` — the foreign writer touched only paths the user did not; the
|
|
55
56
|
* merged root carries both intents.
|
|
56
|
-
* - `conflict` — a same-path divergence tripped a `test` op
|
|
57
|
-
* write and
|
|
57
|
+
* - `conflict` — a same-path divergence tripped a `test` op, or an `add`
|
|
58
|
+
* collides with one the foreign writer made; caller drops the write and
|
|
59
|
+
* surfaces `theirs`.
|
|
58
60
|
*
|
|
59
61
|
* I/O is the caller's: `refetch` supplies the current root, and applying the
|
|
60
|
-
* `merged` result (update vs save,
|
|
62
|
+
* `merged` result (update vs save, new base, UI refresh) stays at the call
|
|
61
63
|
* site so form and GLSP paths keep their own persistence semantics.
|
|
62
64
|
*/
|
|
63
|
-
async function reconcileByPatchReplay(
|
|
64
|
-
const userPatch = (0, fast_json_patch_1.compare)(
|
|
65
|
+
async function reconcileByPatchReplay(base, ours, refetch) {
|
|
66
|
+
const userPatch = (0, fast_json_patch_1.compare)(base, ours);
|
|
65
67
|
if (userPatch.length === 0) {
|
|
66
68
|
return { status: 'no-op' };
|
|
67
69
|
}
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
+
const theirs = await refetch();
|
|
71
|
+
if (!theirs) {
|
|
70
72
|
return { status: 'unavailable' };
|
|
71
73
|
}
|
|
74
|
+
if (addsCollide(base, theirs, userPatch)) {
|
|
75
|
+
return { status: 'conflict', theirs };
|
|
76
|
+
}
|
|
72
77
|
try {
|
|
73
|
-
const merged = (0, fast_json_patch_1.applyPatch)((0, fast_json_patch_1.deepClone)(
|
|
78
|
+
const merged = (0, fast_json_patch_1.applyPatch)((0, fast_json_patch_1.deepClone)(theirs), augmentWithTestOps(base, userPatch), true).newDocument;
|
|
74
79
|
return { status: 'merged', merged };
|
|
75
80
|
}
|
|
76
81
|
catch {
|
|
77
|
-
return { status: 'conflict',
|
|
82
|
+
return { status: 'conflict', theirs };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether an `add` of `userPatch` collides with one the foreign writer made:
|
|
87
|
+
* it inserts a value into an array that `theirs` holds more often than
|
|
88
|
+
* `base` did, or it adds an object key that `theirs` already holds.
|
|
89
|
+
*
|
|
90
|
+
* Replayed, the first inserts the value a second time and the second replaces
|
|
91
|
+
* the foreign value. Identical values conflict rather than being skipped:
|
|
92
|
+
* skipping drops one of two additions that merely happen to be equal.
|
|
93
|
+
*/
|
|
94
|
+
function addsCollide(base, theirs, userPatch) {
|
|
95
|
+
// Through JSON, as `compare` clones the add values: an undefined-valued key
|
|
96
|
+
// in `theirs` would otherwise make an equal element count as another.
|
|
97
|
+
const comparable = JSON.parse(JSON.stringify(theirs));
|
|
98
|
+
return userPatch.some(op => {
|
|
99
|
+
if (op.op !== 'add') {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const cut = op.path.lastIndexOf('/');
|
|
103
|
+
const before = valueAt(base, op.path.slice(0, cut));
|
|
104
|
+
const now = valueAt(comparable, op.path.slice(0, cut));
|
|
105
|
+
if (Array.isArray(before)) {
|
|
106
|
+
return Array.isArray(now) && occurrences(now, op.value) > occurrences(before, op.value);
|
|
107
|
+
}
|
|
108
|
+
return typeof now === 'object' && now !== null && Object.hasOwn(now, (0, fast_json_patch_1.unescapePathComponent)(op.path.slice(cut + 1)));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** How many elements of `array` deeply equal `value`, whatever their key order. */
|
|
112
|
+
function occurrences(array, value) {
|
|
113
|
+
return array.filter(element => (0, fast_json_patch_1._areEquals)(element, value)).length;
|
|
114
|
+
}
|
|
115
|
+
/** The value at `pointer`, or `undefined` when a step of it is missing. */
|
|
116
|
+
function valueAt(document, pointer) {
|
|
117
|
+
try {
|
|
118
|
+
return (0, fast_json_patch_1.getValueByPointer)(document, pointer);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return undefined;
|
|
78
122
|
}
|
|
79
123
|
}
|
|
80
124
|
/**
|
|
@@ -84,20 +128,20 @@ async function reconcileByPatchReplay(baseline, attempted, refetch) {
|
|
|
84
128
|
* clobbered.
|
|
85
129
|
*/
|
|
86
130
|
class ReconcilingConflictResolver {
|
|
87
|
-
resolve(
|
|
88
|
-
return reconcileByPatchReplay(
|
|
131
|
+
resolve(base, ours, refetch) {
|
|
132
|
+
return reconcileByPatchReplay(base, ours, refetch);
|
|
89
133
|
}
|
|
90
134
|
}
|
|
91
135
|
exports.ReconcilingConflictResolver = ReconcilingConflictResolver;
|
|
92
136
|
/**
|
|
93
|
-
* Last-writer-wins {@link ConflictResolver}: always reports the `
|
|
137
|
+
* Last-writer-wins {@link ConflictResolver}: always reports the `ours`
|
|
94
138
|
* state as merged, without refetching or guarding. Suitable for single-client
|
|
95
139
|
* tools or always-regenerated artifacts where a concurrent foreign edit may be
|
|
96
140
|
* overwritten. A foreign edit to any field is clobbered.
|
|
97
141
|
*/
|
|
98
142
|
class ForceConflictResolver {
|
|
99
|
-
async resolve(
|
|
100
|
-
return { status: 'merged', merged:
|
|
143
|
+
async resolve(_base, ours, _refetch) {
|
|
144
|
+
return { status: 'merged', merged: ours };
|
|
101
145
|
}
|
|
102
146
|
}
|
|
103
147
|
exports.ForceConflictResolver = ForceConflictResolver;
|
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
|
|
1
|
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AO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAA,uCAAqB,EAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvH,CAAC,CAAC,CAAC;AACN,CAAC;AAED,mFAAmF;AACnF,SAAS,WAAW,CAAC,KAAyB,EAAE,KAAc;IAC3D,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAA,4BAAU,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACrE,CAAC;AAED,2EAA2E;AAC3E,SAAS,OAAO,CAAC,QAAgB,EAAE,OAAe;IAC/C,IAAI,CAAC;QACF,OAAO,IAAA,mCAAiB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAAC,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"}
|
package/lib/profile-session.d.ts
CHANGED
|
@@ -56,7 +56,12 @@ export interface ProfileSession {
|
|
|
56
56
|
/** The same aggregate as structured records, for tests / programmatic use. */
|
|
57
57
|
records(): readonly ProfileRecord[];
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* One in-flight {@link ProfileSession.scope} call. Held on the `protected`
|
|
61
|
+
* {@link DefaultProfileSession.stack} and named by
|
|
62
|
+
* {@link DefaultProfileSession.closeFrame}, so a subclass has to name it too.
|
|
63
|
+
*/
|
|
64
|
+
export interface ProfileScopeFrame {
|
|
60
65
|
readonly id: string;
|
|
61
66
|
/** Session-stopwatch reading when this scope began. */
|
|
62
67
|
readonly start: number;
|
|
@@ -73,15 +78,14 @@ export declare class DefaultProfileSession implements ProfileSession {
|
|
|
73
78
|
protected readonly identifier: string;
|
|
74
79
|
/** Single monotonic timeline for the whole session; per-scope readings are deltas off it. */
|
|
75
80
|
protected readonly sessionStopwatch: Stopwatch;
|
|
76
|
-
protected readonly stack:
|
|
81
|
+
protected readonly stack: ProfileScopeFrame[];
|
|
77
82
|
protected readonly entries: Map<string, number[]>;
|
|
78
83
|
constructor(logger: Logger, clock: Clock, identifier: string);
|
|
79
84
|
scope<T>(id: string, fn: () => Promise<T>): Promise<T>;
|
|
80
85
|
scope<T>(id: string, fn: () => T): T;
|
|
81
86
|
/** Pop `frame`, charge its full duration to the parent, and record its self-time. */
|
|
82
|
-
protected closeFrame(frame:
|
|
87
|
+
protected closeFrame(frame: ProfileScopeFrame): void;
|
|
83
88
|
records(): readonly ProfileRecord[];
|
|
84
89
|
report(logLevel?: LogThreshold): void;
|
|
85
90
|
}
|
|
86
|
-
export {};
|
|
87
91
|
//# sourceMappingURL=profile-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.d.ts","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC3B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;
|
|
1
|
+
{"version":3,"file":"profile-session.js","sourceRoot":"","sources":["../src/profile-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAGlF,qCAA6D;AAmE7D;;;;GAIG;AACH;IAOyB,MAAM;IAEN,UAAU;IARhC,6FAA6F;IAC1E,gBAAgB,CAAY;IAC5B,KAAK,GAAwB,EAAE,CAAC;IAChC,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEzD,YACsB,MAAc,EACjC,KAAY,EACO,UAAkB;sBAFlB,MAAM;0BAEN,UAAU;QAE7B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7C,CAAC;IAID,KAAK,CAAI,EAAU,EAAE,EAAwB;QAC1C,MAAM,KAAK,GAAsB,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAC5F,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,IAAI,MAAsB,CAAC;QAC3B,IAAI,CAAC;YACF,MAAM,GAAG,EAAE,EAAE,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACvB,MAAM,KAAK,CAAC;QACf,CAAC;QACD,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,IAAI,CACf,KAAK,CAAC,EAAE;gBACL,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO,KAAK,CAAC;YAChB,CAAC,EACD,KAAK,CAAC,EAAE;gBACL,IAAI,CAAC,UAAU,CAAC,KAAK,CAA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aAAa,IAAI,GAAG,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,mBAAmB,GAAG,KAAK,eAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;IACJ,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,MA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