@hydranium/protocol 1.0.0-next.29 → 1.0.0-next.298
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 +44 -49
- package/lib/abstract-logger.d.ts +5 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +7 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +302 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +533 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +17 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +25 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +34 -24
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +657 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1113 -115
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +15 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +15 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +4 -4
- package/lib/client/message-relay.js +4 -4
- 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 +157 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +214 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +62 -0
- package/lib/client/worker-handshake.d.ts.map +1 -0
- package/lib/client/worker-handshake.js +41 -0
- package/lib/client/worker-handshake.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 +50 -10
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/console-logger.d.ts +23 -0
- package/lib/console-logger.d.ts.map +1 -0
- package/lib/console-logger.js +39 -0
- package/lib/console-logger.js.map +1 -0
- 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 +13 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +165 -48
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +137 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +71 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +3 -3
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +6 -9
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +175 -30
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +260 -32
- package/lib/errors.js.map +1 -1
- package/lib/glsp-request-model-args.d.ts +16 -0
- package/lib/glsp-request-model-args.d.ts.map +1 -0
- package/lib/glsp-request-model-args.js +19 -0
- package/lib/glsp-request-model-args.js.map +1 -0
- 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 +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -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 +38 -7
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +42 -4
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +4 -2
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +14 -4
- package/lib/messages/index.js.map +1 -1
- package/lib/messages/primitives.d.ts +71 -10
- package/lib/messages/primitives.d.ts.map +1 -1
- package/lib/messages/primitives.js +55 -3
- package/lib/messages/primitives.js.map +1 -1
- 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 +67 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +44 -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/{model-service/args.js → node/index.d.ts} +2 -3
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +29 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/process-memory.d.ts +66 -0
- package/lib/node/process-memory.d.ts.map +1 -0
- package/lib/node/process-memory.js +291 -0
- package/lib/node/process-memory.js.map +1 -0
- 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 +63 -35
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +171 -25
- 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/project.d.ts +4 -1
- package/lib/project.d.ts.map +1 -1
- package/lib/project.js.map +1 -1
- package/lib/random-uuid.d.ts +14 -0
- package/lib/random-uuid.d.ts.map +1 -0
- package/lib/random-uuid.js +24 -0
- package/lib/random-uuid.js.map +1 -0
- package/lib/reconcile-write.d.ts +67 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +69 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +33 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +32 -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/index.d.ts +1 -0
- package/lib/rpc/index.d.ts.map +1 -1
- package/lib/rpc/index.js +1 -0
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/send-by-method-name.d.ts +76 -0
- package/lib/rpc/send-by-method-name.d.ts.map +1 -0
- package/lib/rpc/send-by-method-name.js +120 -0
- package/lib/rpc/send-by-method-name.js.map +1 -0
- 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 +41 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +56 -8
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +17 -2
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +61 -46
- 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.d.ts.map +1 -1
- package/lib/testing/node/duplex-connection.js +3 -2
- 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.d.ts +9 -3
- package/lib/testing/wait-for.d.ts.map +1 -1
- package/lib/testing/wait-for.js +57 -11
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.js +5 -9
- package/lib/tracer.js.map +1 -1
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +95 -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 -2
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -4
- package/lib/util.js.map +1 -1
- package/package.json +24 -40
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +653 -0
- package/src/client/data-events.ts +37 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1427 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +4 -4
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client/worker-handshake.ts +83 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +68 -10
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +14 -4
- package/src/data/data-server-protocol.ts +192 -48
- package/src/data/events.ts +143 -21
- package/src/data/requests.ts +77 -11
- package/src/debouncer.ts +7 -10
- package/src/errors.ts +309 -40
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +6 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +44 -8
- package/src/messages/index.ts +4 -2
- package/src/messages/primitives.ts +102 -10
- package/src/model-server.ts +64 -19
- package/src/model-service/base-version.ts +75 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/node/index.ts +14 -0
- package/src/node/process-memory.ts +299 -0
- package/src/patch-merge.ts +230 -45
- package/src/profile-session.ts +9 -4
- package/src/project.ts +4 -1
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +128 -0
- package/src/rpc/README.md +6 -6
- package/src/rpc/bind-rpc-methods.ts +59 -4
- package/src/rpc/create-rpc-proxy.ts +20 -2
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +141 -19
- package/src/testing/fake-clock.ts +76 -48
- package/src/testing/index.ts +5 -2
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/testing/wait-for.ts +61 -13
- package/src/tracer.ts +5 -9
- package/src/transfer-document.ts +115 -34
- package/src/util.ts +33 -6
- 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.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
// Subpath barrel for `@hydranium/protocol/node` — the diagnostics helpers that
|
|
26
|
+
// need a Node runtime, kept out of the root barrel so the root stays
|
|
27
|
+
// bundleable for a browser.
|
|
28
|
+
__exportStar(require("./process-memory"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,+EAA+E;AAC/E,qEAAqE;AACrE,4BAA4B;AAE5B,mDAAiC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
/**
|
|
10
|
+
* Format a one-shot memory snapshot of the CURRENT process (heap, rss, external, V8 limit).
|
|
11
|
+
* Suited to a process that hosts no Langium documents (e.g. a host backend); for the
|
|
12
|
+
* language-server process with document counts, see `formatServerState`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatProcessMemory(label: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Compose an absolute artifact file path of the form `<prefix>[-<label>].<ext>` inside
|
|
17
|
+
* {@link directory} (e.g. the workspace folder, so it lands on the persistent volume in cloud and
|
|
18
|
+
* is visible in the file explorer), falling back to the OS temp dir when the directory is missing
|
|
19
|
+
* or does not exist. The {@link prefix} carries the origin-first stem (e.g. `server-cpu`) and, when
|
|
20
|
+
* a non-empty {@link label} is given (a named capture window), it is sanitised (non-word characters
|
|
21
|
+
* → `_`, truncated to 40 chars) and appended as `-<label>`; an empty label yields the bare
|
|
22
|
+
* `<prefix>.<ext>` so the manifest `kind` equals the filename stem. No timestamp — a fresh session
|
|
23
|
+
* directory per run keeps names stable and collision-free. Shared by the heap-snapshot writer and
|
|
24
|
+
* the sampled-profile capture so heap / CPU / allocation artefacts land identically, differing only
|
|
25
|
+
* by extension.
|
|
26
|
+
*/
|
|
27
|
+
export declare function snapshotFilePath(directory: string | undefined, label: string, prefix: string, ext: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Write a V8 heap snapshot of the CURRENT process to {@link directory}, falling back to the OS temp
|
|
30
|
+
* dir when it is missing (see {@link snapshotFilePath}). `v8.writeHeapSnapshot` runs a full GC first and
|
|
31
|
+
* briefly pauses the process; it also transiently inflates RSS while serialising. Returns the
|
|
32
|
+
* absolute file path. The {@link prefix} (default `server-heap`, the origin-first stem) and
|
|
33
|
+
* {@link label} are folded into the name.
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeHeapSnapshotToDir(directory: string | undefined, label: string, prefix?: string): string;
|
|
36
|
+
/** A readable role for a process, whether it belongs to the app, and whether exactly one is expected. */
|
|
37
|
+
export interface ProcessRole {
|
|
38
|
+
/** Human-readable role shown in the snapshot. */
|
|
39
|
+
role: string;
|
|
40
|
+
/** Whether this process is part of the application (vs. tooling/debugger), counted in the app total. */
|
|
41
|
+
isApp: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Set when at most one instance of this role should exist; `formatPodMemory` warns when more than
|
|
44
|
+
* one is found (e.g. a duplicated/ghost language server).
|
|
45
|
+
*/
|
|
46
|
+
singletonExpected?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Map a raw command line to a {@link ProcessRole}. A head supplies this to label its own processes. */
|
|
49
|
+
export type ProcessClassifier = (cmdline: string) => ProcessRole;
|
|
50
|
+
/** Options for {@link formatPodMemory}. */
|
|
51
|
+
export interface PodMemoryOptions {
|
|
52
|
+
/** Map a process command line to a readable role; lets a head label its own processes. */
|
|
53
|
+
classify?: ProcessClassifier;
|
|
54
|
+
/** Heading for the in-app process group (default `Application`). */
|
|
55
|
+
appLabel?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Format a pod/container-level memory snapshot read from the cgroup this process belongs to
|
|
59
|
+
* (cgroup v2 `memory.current`/`peak`/`max`/`stat`, falling back to cgroup v1). This is the figure
|
|
60
|
+
* the Kubernetes OOM-killer watches — it covers every process in the pod plus page cache and kernel
|
|
61
|
+
* memory, so it is higher than any single `process.memoryUsage().rss`. Also sums per-process RSS so
|
|
62
|
+
* the per-process split is visible. Explains itself when no cgroup memory controller is present
|
|
63
|
+
* (e.g. local dev outside a container).
|
|
64
|
+
*/
|
|
65
|
+
export declare function formatPodMemory(options?: PodMemoryOptions): string;
|
|
66
|
+
//# sourceMappingURL=process-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-memory.d.ts","sourceRoot":"","sources":["../../src/node/process-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAelF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKlH;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAgB,GAAG,MAAM,CAInH;AA8CD,yGAAyG;AACzG,MAAM,WAAW,WAAW;IACzB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wGAAwG;AACxG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC;AA2EjE,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC9B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CA6EtE"}
|
|
@@ -0,0 +1,291 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.formatProcessMemory = formatProcessMemory;
|
|
45
|
+
exports.snapshotFilePath = snapshotFilePath;
|
|
46
|
+
exports.writeHeapSnapshotToDir = writeHeapSnapshotToDir;
|
|
47
|
+
exports.formatPodMemory = formatPodMemory;
|
|
48
|
+
/*
|
|
49
|
+
* Node-only process- and pod-level memory introspection plus heap-snapshot
|
|
50
|
+
* writing. Everything here is generic OS-level code (V8 stats, cgroup v2/v1,
|
|
51
|
+
* `/proc`); the only host-specific part is naming the processes, which a head
|
|
52
|
+
* supplies through a `ProcessClassifier`.
|
|
53
|
+
*/
|
|
54
|
+
const fs = __importStar(require("node:fs"));
|
|
55
|
+
const os = __importStar(require("node:os"));
|
|
56
|
+
const path = __importStar(require("node:path"));
|
|
57
|
+
const v8 = __importStar(require("node:v8"));
|
|
58
|
+
const logger_1 = require("../logger");
|
|
59
|
+
/**
|
|
60
|
+
* Format a one-shot memory snapshot of the CURRENT process (heap, rss, external, V8 limit).
|
|
61
|
+
* Suited to a process that hosts no Langium documents (e.g. a host backend); for the
|
|
62
|
+
* language-server process with document counts, see `formatServerState`.
|
|
63
|
+
*/
|
|
64
|
+
function formatProcessMemory(label) {
|
|
65
|
+
const mem = process.memoryUsage();
|
|
66
|
+
const heap = v8.getHeapStatistics();
|
|
67
|
+
const heapPercent = Math.round((mem.heapUsed / heap.heap_size_limit) * 100);
|
|
68
|
+
return [
|
|
69
|
+
`${label}:`,
|
|
70
|
+
` heap ${logger_1.Format.bytes(mem.heapUsed)} used / ${logger_1.Format.bytes(mem.heapTotal)} total / ` +
|
|
71
|
+
`${logger_1.Format.bytes(heap.heap_size_limit)} limit (${heapPercent}% of limit)`,
|
|
72
|
+
` rss ${logger_1.Format.bytes(mem.rss)}, external ${logger_1.Format.bytes(mem.external)}, arrayBuffers ${logger_1.Format.bytes(mem.arrayBuffers)}`,
|
|
73
|
+
` uptime ${Math.round(process.uptime())}s, pid ${process.pid}`
|
|
74
|
+
].join('\n');
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Compose an absolute artifact file path of the form `<prefix>[-<label>].<ext>` inside
|
|
78
|
+
* {@link directory} (e.g. the workspace folder, so it lands on the persistent volume in cloud and
|
|
79
|
+
* is visible in the file explorer), falling back to the OS temp dir when the directory is missing
|
|
80
|
+
* or does not exist. The {@link prefix} carries the origin-first stem (e.g. `server-cpu`) and, when
|
|
81
|
+
* a non-empty {@link label} is given (a named capture window), it is sanitised (non-word characters
|
|
82
|
+
* → `_`, truncated to 40 chars) and appended as `-<label>`; an empty label yields the bare
|
|
83
|
+
* `<prefix>.<ext>` so the manifest `kind` equals the filename stem. No timestamp — a fresh session
|
|
84
|
+
* directory per run keeps names stable and collision-free. Shared by the heap-snapshot writer and
|
|
85
|
+
* the sampled-profile capture so heap / CPU / allocation artefacts land identically, differing only
|
|
86
|
+
* by extension.
|
|
87
|
+
*/
|
|
88
|
+
function snapshotFilePath(directory, label, prefix, ext) {
|
|
89
|
+
const safeLabel = label ? label.replace(/[^\w.-]+/g, '_').slice(0, 40) : '';
|
|
90
|
+
const dir = directory && fs.existsSync(directory) ? directory : os.tmpdir();
|
|
91
|
+
const stem = safeLabel ? `${prefix}-${safeLabel}` : prefix;
|
|
92
|
+
return path.join(dir, `${stem}.${ext}`);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Write a V8 heap snapshot of the CURRENT process to {@link directory}, falling back to the OS temp
|
|
96
|
+
* dir when it is missing (see {@link snapshotFilePath}). `v8.writeHeapSnapshot` runs a full GC first and
|
|
97
|
+
* briefly pauses the process; it also transiently inflates RSS while serialising. Returns the
|
|
98
|
+
* absolute file path. The {@link prefix} (default `server-heap`, the origin-first stem) and
|
|
99
|
+
* {@link label} are folded into the name.
|
|
100
|
+
*/
|
|
101
|
+
function writeHeapSnapshotToDir(directory, label, prefix = 'server-heap') {
|
|
102
|
+
const filePath = snapshotFilePath(directory, label, prefix, 'heapsnapshot');
|
|
103
|
+
v8.writeHeapSnapshot(filePath);
|
|
104
|
+
return filePath;
|
|
105
|
+
}
|
|
106
|
+
const CGROUP_ROOT = '/sys/fs/cgroup';
|
|
107
|
+
function readNumber(file) {
|
|
108
|
+
try {
|
|
109
|
+
const text = fs.readFileSync(file, 'utf8').trim();
|
|
110
|
+
if (text === 'max') {
|
|
111
|
+
return Number.POSITIVE_INFINITY;
|
|
112
|
+
}
|
|
113
|
+
const value = Number(text);
|
|
114
|
+
return Number.isFinite(value) ? value : undefined;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Parse a `key value` per-line file (cgroup memory.stat) into a map. */
|
|
121
|
+
function readKeyedBytes(file) {
|
|
122
|
+
const out = {};
|
|
123
|
+
try {
|
|
124
|
+
for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
|
|
125
|
+
const [key, value] = line.trim().split(/\s+/);
|
|
126
|
+
if (key && value !== undefined) {
|
|
127
|
+
const num = Number(value);
|
|
128
|
+
if (Number.isFinite(num)) {
|
|
129
|
+
out[key] = num;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// file absent or unreadable; caller handles the empty map.
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
/** Generic fallback: every process is shown under the app heading, labelled by its (truncated) command line. */
|
|
140
|
+
const defaultProcessClassifier = cmdline => ({ role: cmdline ? cmdline.slice(0, 60) : 'process', isApp: true });
|
|
141
|
+
/** Read /proc for every visible process: pid, ppid, RSS, and a command label. */
|
|
142
|
+
function readAllProcs() {
|
|
143
|
+
const procs = [];
|
|
144
|
+
let entries = [];
|
|
145
|
+
try {
|
|
146
|
+
entries = fs.readdirSync('/proc');
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return procs;
|
|
150
|
+
}
|
|
151
|
+
for (const entry of entries) {
|
|
152
|
+
if (!/^\d+$/.test(entry)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
let status = '';
|
|
156
|
+
try {
|
|
157
|
+
status = fs.readFileSync(`/proc/${entry}/status`, 'utf8');
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const rssMatch = status.match(/^VmRSS:\s+(\d+)\s+kB/m);
|
|
163
|
+
if (!rssMatch) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const ppid = Number(status.match(/^PPid:\s+(\d+)/m)?.[1] ?? 0);
|
|
167
|
+
let label = '';
|
|
168
|
+
try {
|
|
169
|
+
label = fs.readFileSync(`/proc/${entry}/cmdline`, 'utf8').replace(/\0/g, ' ').trim();
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
// fall back to the process name from status below.
|
|
173
|
+
}
|
|
174
|
+
if (!label) {
|
|
175
|
+
label = status.match(/^Name:\s+(.+)$/m)?.[1] ?? `pid ${entry}`;
|
|
176
|
+
}
|
|
177
|
+
procs.push({ pid: Number(entry), ppid, rssBytes: Number(rssMatch[1]) * 1024, label });
|
|
178
|
+
}
|
|
179
|
+
return procs;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Sum and list per-process RSS. When {@link rootPid} is given, restrict to that process and its
|
|
183
|
+
* descendants (the app's own process tree), which keeps the figure meaningful in local dev where
|
|
184
|
+
* /proc otherwise shows the whole machine. In a container's PID namespace the tree is effectively
|
|
185
|
+
* all the pod's processes anyway.
|
|
186
|
+
*/
|
|
187
|
+
function collectProcessRss(rootPid) {
|
|
188
|
+
const all = readAllProcs();
|
|
189
|
+
let selected = all;
|
|
190
|
+
let scoped = false;
|
|
191
|
+
if (rootPid !== undefined) {
|
|
192
|
+
const childrenByPpid = new Map();
|
|
193
|
+
for (const proc of all) {
|
|
194
|
+
(childrenByPpid.get(proc.ppid) ?? childrenByPpid.set(proc.ppid, []).get(proc.ppid)).push(proc);
|
|
195
|
+
}
|
|
196
|
+
const tree = [];
|
|
197
|
+
const queue = all.filter(proc => proc.pid === rootPid);
|
|
198
|
+
while (queue.length > 0) {
|
|
199
|
+
const proc = queue.shift();
|
|
200
|
+
tree.push(proc);
|
|
201
|
+
queue.push(...(childrenByPpid.get(proc.pid) ?? []));
|
|
202
|
+
}
|
|
203
|
+
if (tree.length > 0) {
|
|
204
|
+
selected = tree;
|
|
205
|
+
scoped = true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const total = selected.reduce((sum, proc) => sum + proc.rssBytes, 0);
|
|
209
|
+
selected.sort((a, b) => b.rssBytes - a.rssBytes);
|
|
210
|
+
return { total, processes: selected, scoped };
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Format a pod/container-level memory snapshot read from the cgroup this process belongs to
|
|
214
|
+
* (cgroup v2 `memory.current`/`peak`/`max`/`stat`, falling back to cgroup v1). This is the figure
|
|
215
|
+
* the Kubernetes OOM-killer watches — it covers every process in the pod plus page cache and kernel
|
|
216
|
+
* memory, so it is higher than any single `process.memoryUsage().rss`. Also sums per-process RSS so
|
|
217
|
+
* the per-process split is visible. Explains itself when no cgroup memory controller is present
|
|
218
|
+
* (e.g. local dev outside a container).
|
|
219
|
+
*/
|
|
220
|
+
function formatPodMemory(options = {}) {
|
|
221
|
+
const classify = options.classify ?? defaultProcessClassifier;
|
|
222
|
+
const appLabel = options.appLabel ?? 'Application';
|
|
223
|
+
const lines = ['Pod memory snapshot:'];
|
|
224
|
+
const v2Current = path.join(CGROUP_ROOT, 'memory.current');
|
|
225
|
+
const v1Usage = path.join(CGROUP_ROOT, 'memory', 'memory.usage_in_bytes');
|
|
226
|
+
if (fs.existsSync(v2Current)) {
|
|
227
|
+
const current = readNumber(v2Current);
|
|
228
|
+
const peak = readNumber(path.join(CGROUP_ROOT, 'memory.peak'));
|
|
229
|
+
const max = readNumber(path.join(CGROUP_ROOT, 'memory.max'));
|
|
230
|
+
const stat = readKeyedBytes(path.join(CGROUP_ROOT, 'memory.stat'));
|
|
231
|
+
lines.push(' cgroup v2');
|
|
232
|
+
lines.push(` current ${current !== undefined ? logger_1.Format.bytes(current) : 'n/a'}`);
|
|
233
|
+
lines.push(` peak ${peak !== undefined ? logger_1.Format.bytes(peak) : 'n/a (kernel too old for memory.peak)'}`);
|
|
234
|
+
lines.push(` limit ${max === Number.POSITIVE_INFINITY ? 'unlimited' : max !== undefined ? logger_1.Format.bytes(max) : 'n/a'}`);
|
|
235
|
+
if (Object.keys(stat).length > 0) {
|
|
236
|
+
lines.push(` breakdown anon ${logger_1.Format.bytes(stat.anon ?? 0)} (heaps/stacks), file ${logger_1.Format.bytes(stat.file ?? 0)} (page cache), ` +
|
|
237
|
+
`kernel ${logger_1.Format.bytes(stat.kernel ?? stat.slab ?? 0)}, sock ${logger_1.Format.bytes(stat.sock ?? 0)}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else if (fs.existsSync(v1Usage)) {
|
|
241
|
+
const v1 = path.join(CGROUP_ROOT, 'memory');
|
|
242
|
+
const current = readNumber(v1Usage);
|
|
243
|
+
const peak = readNumber(path.join(v1, 'memory.max_usage_in_bytes'));
|
|
244
|
+
const limit = readNumber(path.join(v1, 'memory.limit_in_bytes'));
|
|
245
|
+
const stat = readKeyedBytes(path.join(v1, 'memory.stat'));
|
|
246
|
+
lines.push(' cgroup v1');
|
|
247
|
+
lines.push(` current ${current !== undefined ? logger_1.Format.bytes(current) : 'n/a'}`);
|
|
248
|
+
lines.push(` peak ${peak !== undefined ? logger_1.Format.bytes(peak) : 'n/a'}`);
|
|
249
|
+
// v1 reports a huge sentinel for "unlimited"; treat anything >= 2^60 as unlimited.
|
|
250
|
+
lines.push(` limit ${limit !== undefined && limit < 2 ** 60 ? logger_1.Format.bytes(limit) : 'unlimited'}`);
|
|
251
|
+
if (Object.keys(stat).length > 0) {
|
|
252
|
+
lines.push(` breakdown rss ${logger_1.Format.bytes(stat.rss ?? 0)}, cache ${logger_1.Format.bytes(stat.cache ?? 0)} (page cache), ` +
|
|
253
|
+
`kernel ${logger_1.Format.bytes(stat.kernel ?? 0)}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
lines.push(' cgroup no memory controller under /sys/fs/cgroup (not running in a container?)');
|
|
258
|
+
}
|
|
259
|
+
// Root at this process so local dev reports only the app's tree, not the whole machine.
|
|
260
|
+
const { processes } = collectProcessRss(process.pid);
|
|
261
|
+
if (processes.length > 0) {
|
|
262
|
+
const classified = processes.map(proc => ({ ...proc, ...classify(proc.label) }));
|
|
263
|
+
const appProcs = classified.filter(proc => proc.isApp);
|
|
264
|
+
const otherProcs = classified.filter(proc => !proc.isApp);
|
|
265
|
+
const appTotal = appProcs.reduce((sum, proc) => sum + proc.rssBytes, 0);
|
|
266
|
+
lines.push('');
|
|
267
|
+
lines.push(` ${appLabel}: ${logger_1.Format.bytes(appTotal)} across ${appProcs.length} process(es)`);
|
|
268
|
+
for (const proc of appProcs) {
|
|
269
|
+
lines.push(` ${logger_1.Format.bytes(proc.rssBytes).padStart(10)} ${proc.role} (pid ${proc.pid})`);
|
|
270
|
+
}
|
|
271
|
+
const singletonCounts = new Map();
|
|
272
|
+
for (const proc of appProcs) {
|
|
273
|
+
if (proc.singletonExpected) {
|
|
274
|
+
singletonCounts.set(proc.role, (singletonCounts.get(proc.role) ?? 0) + 1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
for (const [role, count] of singletonCounts) {
|
|
278
|
+
if (count > 1) {
|
|
279
|
+
lines.push(` WARNING: ${count} instances of "${role}" running - likely ghost process(es); expected 1`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (otherProcs.length > 0) {
|
|
283
|
+
const otherTotal = otherProcs.reduce((sum, proc) => sum + proc.rssBytes, 0);
|
|
284
|
+
lines.push(` Other (tooling/debugger, not counted above): ${logger_1.Format.bytes(otherTotal)} across ${otherProcs.length} process(es)`);
|
|
285
|
+
}
|
|
286
|
+
lines.push(' Note: in a real pod the cgroup figure above is the OOM ceiling; this per-process');
|
|
287
|
+
lines.push(' split is for attribution. Local dev may include debugger processes (excluded here).');
|
|
288
|
+
}
|
|
289
|
+
return lines.join('\n');
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=process-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-memory.js","sourceRoot":"","sources":["../../src/node/process-memory.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElF;;;;;GAKG;AAEH,MAAY,EAAE,oCAAgB;AAC9B,MAAY,EAAE,oCAAgB;AAC9B,MAA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AAC;YAC3G,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAC5E,KAAK,CAAC,IAAI,CAAC,kDAAkD,eAAM,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,UAAU,CAAC,MAAM,cAAc,CAAC,CAAC;QACpI,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;QACjG,KAAK,CAAC,IAAI,CAAC,uFAAuF,CAAC,CAAC;IACvG,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
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,79 @@
|
|
|
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, takes `theirs` as the new base on
|
|
36
|
+
* `already-applied`, drops + surfaces the `theirs` root on `conflict`,
|
|
37
|
+
* catches up with the server on `no-op`, and decides its own fallback (e.g.
|
|
38
|
+
* force-retry) on `unavailable`.
|
|
36
39
|
*/
|
|
37
40
|
export type ReconcileOutcome<T> = {
|
|
38
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The replay succeeded: the foreign writer touched no path the user
|
|
43
|
+
* did, or wrote the user's value at one that runs through no array.
|
|
44
|
+
*/
|
|
39
45
|
status: 'merged';
|
|
40
46
|
/**
|
|
41
|
-
* A
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* had.
|
|
47
|
+
* A new root built on theirs, carrying both intents. It is NOT the
|
|
48
|
+
* caller's `ours` root — take this value as the new base, or the next
|
|
49
|
+
* write diffs against state the server never had.
|
|
45
50
|
*/
|
|
46
51
|
merged: T;
|
|
47
52
|
} | {
|
|
48
53
|
/**
|
|
49
|
-
* The user's root
|
|
50
|
-
*
|
|
51
|
-
*
|
|
54
|
+
* The user's root equalled the base, so the gate fired on another writer's
|
|
55
|
+
* change and the caller is behind the server (`ConflictError.actualVersion`).
|
|
56
|
+
* Nothing was refetched. Catch up from the update at that version or a later
|
|
57
|
+
* one, or refetch; forcing the write overwrites the other writer's change.
|
|
52
58
|
*/
|
|
53
59
|
status: 'no-op';
|
|
54
60
|
} | {
|
|
55
|
-
/**
|
|
61
|
+
/** The refetch already holds every path the user changed at the user's value: nothing is left to write. */
|
|
62
|
+
status: 'already-applied';
|
|
63
|
+
/**
|
|
64
|
+
* The server's current root, refetched and unmodified. Take it as the
|
|
65
|
+
* new base, not `ours`: it can also hold another writer's edit to a
|
|
66
|
+
* path the user did not change.
|
|
67
|
+
*/
|
|
68
|
+
theirs: T;
|
|
69
|
+
} | {
|
|
70
|
+
/**
|
|
71
|
+
* User and foreign writer changed one path to different values, or
|
|
72
|
+
* both changed one inside an array the refetch holds otherwise than
|
|
73
|
+
* the user, even to the same value; both inserted the same array
|
|
74
|
+
* element; or the foreign writer removed or replaced what the user
|
|
75
|
+
* edited inside.
|
|
76
|
+
*/
|
|
56
77
|
status: 'conflict';
|
|
57
78
|
/**
|
|
58
79
|
* The server's current root, refetched and unmodified — the user's
|
|
59
80
|
* intent was NOT applied to it. Surface it and drop the write; treating
|
|
60
81
|
* it as a merge result silently discards what the user typed.
|
|
61
82
|
*/
|
|
62
|
-
|
|
83
|
+
theirs: T;
|
|
63
84
|
} | {
|
|
64
85
|
/**
|
|
65
86
|
* The refetch produced nothing, so reconciliation could not be
|
|
@@ -70,22 +91,29 @@ export type ReconcileOutcome<T> = {
|
|
|
70
91
|
};
|
|
71
92
|
/**
|
|
72
93
|
* Shared three-way reconcile for a `ConflictError`: diff the user's intent
|
|
73
|
-
* (`
|
|
94
|
+
* (`base → ours`), refetch the server's current root (theirs), and replay the
|
|
74
95
|
* intent on top under strict, {@link augmentWithTestOps}-guarded `applyPatch`.
|
|
75
96
|
*
|
|
76
|
-
* - `no-op` — the user's root equals the
|
|
77
|
-
*
|
|
97
|
+
* - `no-op` — the user's root equals the base: nothing to replay, and no
|
|
98
|
+
* refetch; the caller's document is behind the server's.
|
|
78
99
|
* - `unavailable` — the refetch produced nothing; caller falls back.
|
|
79
|
-
* - `
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
100
|
+
* - `already-applied` — the refetch already holds the user's value at every
|
|
101
|
+
* path the user changed, and the user's whole array for a path through
|
|
102
|
+
* one; nothing is replayed.
|
|
103
|
+
* - `merged` — the foreign writer touched only paths the user did not, or
|
|
104
|
+
* made the user's change itself at a path through no array; the merged
|
|
105
|
+
* root carries both intents.
|
|
106
|
+
* - `conflict` — a same-path divergence tripped a `test` op, including the
|
|
107
|
+
* user's own value inside an array the refetch holds otherwise than the
|
|
108
|
+
* user; or an `add` collides with one the foreign writer made; or the
|
|
109
|
+
* foreign writer removed or replaced what the user edited inside. The
|
|
110
|
+
* caller drops the write and surfaces `theirs`.
|
|
83
111
|
*
|
|
84
112
|
* I/O is the caller's: `refetch` supplies the current root, and applying the
|
|
85
|
-
* `merged` result (update vs save,
|
|
113
|
+
* `merged` result (update vs save, new base, UI refresh) stays at the call
|
|
86
114
|
* site so form and GLSP paths keep their own persistence semantics.
|
|
87
115
|
*/
|
|
88
|
-
export declare function reconcileByPatchReplay<T extends object>(
|
|
116
|
+
export declare function reconcileByPatchReplay<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
89
117
|
/**
|
|
90
118
|
* Strategy for resolving a write that raced a foreign edit. One declarative
|
|
91
119
|
* choice covers every conflict site — `execute` forward-write `(before,
|
|
@@ -95,12 +123,12 @@ export declare function reconcileByPatchReplay<T extends object>(baseline: T, at
|
|
|
95
123
|
*/
|
|
96
124
|
export interface ConflictResolver {
|
|
97
125
|
/**
|
|
98
|
-
* Reconcile the user's `
|
|
99
|
-
* server state (`refetch`), returning a {@link ReconcileOutcome} the caller
|
|
100
|
-
* acts on (persist `merged`,
|
|
101
|
-
* `unavailable`).
|
|
126
|
+
* Reconcile the user's `base → ours` intent against the current
|
|
127
|
+
* server state (theirs, from `refetch`), returning a {@link ReconcileOutcome} the caller
|
|
128
|
+
* acts on (persist `merged`, write nothing on `already-applied`, drop on
|
|
129
|
+
* `conflict`, catch up on `no-op`, fall back on `unavailable`).
|
|
102
130
|
*/
|
|
103
|
-
resolve<T extends object>(
|
|
131
|
+
resolve<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
104
132
|
}
|
|
105
133
|
/**
|
|
106
134
|
* Default {@link ConflictResolver}: field-level three-way merge via
|
|
@@ -109,15 +137,15 @@ export interface ConflictResolver {
|
|
|
109
137
|
* clobbered.
|
|
110
138
|
*/
|
|
111
139
|
export declare class ReconcilingConflictResolver implements ConflictResolver {
|
|
112
|
-
resolve<T extends object>(
|
|
140
|
+
resolve<T extends object>(base: T, ours: T, refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
113
141
|
}
|
|
114
142
|
/**
|
|
115
|
-
* Last-writer-wins {@link ConflictResolver}: always reports the `
|
|
143
|
+
* Last-writer-wins {@link ConflictResolver}: always reports the `ours`
|
|
116
144
|
* state as merged, without refetching or guarding. Suitable for single-client
|
|
117
145
|
* tools or always-regenerated artifacts where a concurrent foreign edit may be
|
|
118
146
|
* overwritten. A foreign edit to any field is clobbered.
|
|
119
147
|
*/
|
|
120
148
|
export declare class ForceConflictResolver implements ConflictResolver {
|
|
121
|
-
resolve<T extends object>(
|
|
149
|
+
resolve<T extends object>(_base: T, ours: T, _refetch: () => Promise<T | undefined>): Promise<ReconcileOutcome<T>>;
|
|
122
150
|
}
|
|
123
151
|
//# 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;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IACzB;IACG;;;OAGG;IACH,MAAM,EAAE,QAAQ,CAAC;IACjB;;;;OAIG;IACH,MAAM,EAAE,CAAC,CAAC;CACZ,GACD;IACG;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC;CAClB,GACD;IACG,2GAA2G;IAC3G,MAAM,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,MAAM,EAAE,CAAC,CAAC;CACZ,GACD;IACG;;;;;;OAMG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,MAAM,EAAE,CAAC,CAAC;CACZ,GACD;IACG;;;;OAIG;IACH,MAAM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