@hydranium/protocol 1.0.0-next.12 → 1.0.0-next.127
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/client/data-connection.d.ts +145 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +205 -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 +17 -22
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +301 -80
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +425 -107
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +13 -8
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +13 -8
- 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 +179 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +41 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +44 -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 +110 -31
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +84 -3
- 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/errors.d.ts +102 -12
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +136 -18
- 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 +3 -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/messages/index.d.ts +29 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +56 -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 +44 -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/based-on.d.ts +57 -0
- package/lib/model-service/based-on.d.ts.map +1 -0
- package/lib/model-service/based-on.js +37 -0
- package/lib/model-service/based-on.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/patch-merge.d.ts +28 -27
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +66 -22
- 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/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 +7 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/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 +4 -1
- package/lib/testing/index.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/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 +22 -5
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +14 -1
- package/lib/transfer-document.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +282 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +17 -23
- package/src/client/data-session.ts +549 -126
- package/src/client/index.ts +13 -8
- package/src/client/message-relay.ts +29 -7
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +244 -0
- package/src/client-ids.ts +45 -0
- package/src/clock.ts +56 -0
- package/src/data/data-protocol-methods.ts +11 -3
- package/src/data/data-server-protocol.ts +131 -31
- package/src/data/events.ts +90 -3
- package/src/data/requests.ts +71 -11
- package/src/errors.ts +154 -20
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +6 -0
- package/src/latency-collector.ts +8 -3
- package/src/messages/index.ts +36 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +47 -18
- package/src/model-service/based-on.ts +63 -0
- package/src/model-service/index.ts +4 -5
- package/src/patch-merge.ts +90 -37
- package/src/profile-session.ts +9 -4
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- 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 +4 -1
- 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 +29 -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 +0 -11
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -0,0 +1,188 @@
|
|
|
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 { ResponseError } from 'vscode-jsonrpc';
|
|
10
|
+
/**
|
|
11
|
+
* The framework externalizes user-facing strings and SELECTS no locale: it
|
|
12
|
+
* relays the one its client declared and renders with whatever templates the
|
|
13
|
+
* adopter installed, defaulting to its English. Every such string carries a
|
|
14
|
+
* stable code beside that English, and exactly one side renders it — the side
|
|
15
|
+
* that knows the reading user's language.
|
|
16
|
+
*
|
|
17
|
+
* Which side that is depends on the message, not on the package. A server
|
|
18
|
+
* message is rendered by the server, at the one seam every carrier passes
|
|
19
|
+
* through, in the locale it was handed at init. A message the client tier raises
|
|
20
|
+
* is rendered there, because those fire when the server is unreachable. Nothing
|
|
21
|
+
* is rendered twice: two renders of one sentence are two authorities over it,
|
|
22
|
+
* and they diverge on the first reword.
|
|
23
|
+
*
|
|
24
|
+
* Codes are `hydranium/<unscoped-package>/<name>`. The package segment locates
|
|
25
|
+
* the declaration, so a message is declared in the package that raises it and a
|
|
26
|
+
* code never names a package it does not live in. `.` and `:` are forbidden in a
|
|
27
|
+
* segment: they are i18next's default key and namespace separators, where either
|
|
28
|
+
* silently becomes a nested lookup that misses.
|
|
29
|
+
*/
|
|
30
|
+
export type MessageParams = Readonly<Record<string, string | number>>;
|
|
31
|
+
type Placeholder<S extends string> = S extends `${string}{${infer Name}}${infer Rest}` ? Name | Placeholder<Rest> : never;
|
|
32
|
+
export type ParamsOf<S extends string> = [Placeholder<S>] extends [never] ? Record<never, never> : Readonly<Record<Placeholder<S>, string | number>>;
|
|
33
|
+
/** Required exactly when the text has placeholders, absent when it does not. */
|
|
34
|
+
export type ParamsArg<S extends string> = [Placeholder<S>] extends [never] ? [] : [params: ParamsOf<S>];
|
|
35
|
+
/**
|
|
36
|
+
* Rejects a text argument already widened to `string`. Load-bearing rather than
|
|
37
|
+
* defensive: the whole compile-time guarantee is conditional on `S` inferring a
|
|
38
|
+
* literal, and for a concatenated or pre-widened text the placeholder set
|
|
39
|
+
* silently becomes empty, `format()` accepts no arguments, and the missing
|
|
40
|
+
* substitution surfaces only at runtime.
|
|
41
|
+
*/
|
|
42
|
+
export type LiteralText<S extends string> = string extends S ? never : S;
|
|
43
|
+
export interface MessageDefinition<S extends string> {
|
|
44
|
+
readonly code: string;
|
|
45
|
+
readonly text: S;
|
|
46
|
+
format(...args: ParamsArg<S>): string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Declare a message. Placeholder names are inferred from `text` rather than
|
|
50
|
+
* declared again in a type argument: a second spelling of every name is the
|
|
51
|
+
* repetition that drifts, since adding a placeholder to the sentence and not to
|
|
52
|
+
* the type compiles.
|
|
53
|
+
*/
|
|
54
|
+
export declare function defineMessage<S extends string>(code: string, text: LiteralText<S>): MessageDefinition<S>;
|
|
55
|
+
/**
|
|
56
|
+
* Substitute `{name}` tokens, leaving an unfilled token in place.
|
|
57
|
+
*
|
|
58
|
+
* It must not throw. This runs over an adopter's translation as well as our own
|
|
59
|
+
* text, so a typo in a foreign catalogue has to degrade to a slightly wrong
|
|
60
|
+
* sentence rather than raise inside a toast render. Re-scanning the result to
|
|
61
|
+
* detect an unfilled token is what an earlier form did, and it cannot work:
|
|
62
|
+
* `String.replace` does not rescan replacement text, so the check could not tell
|
|
63
|
+
* an unfilled placeholder from user data shaped like one — an element literally
|
|
64
|
+
* named `{separator}` crashed at the authoring site.
|
|
65
|
+
*/
|
|
66
|
+
export declare function interpolate(template: string, params: MessageParams): string;
|
|
67
|
+
export interface MessageIdentity {
|
|
68
|
+
readonly code: string;
|
|
69
|
+
readonly params: MessageParams;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Envelope for a protocol `data` field. Namespaced under one key so it co-exists
|
|
73
|
+
* with a carrier's own `data` conventions rather than occupying `data` itself.
|
|
74
|
+
*/
|
|
75
|
+
export interface HydraniumMessageData {
|
|
76
|
+
readonly hydranium: MessageIdentity;
|
|
77
|
+
}
|
|
78
|
+
/** An identity plus its resolved English — everything a renderer needs, on any carrier. */
|
|
79
|
+
export interface ResolvedMessage extends MessageIdentity {
|
|
80
|
+
readonly text: string;
|
|
81
|
+
}
|
|
82
|
+
export declare function messageData<S extends string>(message: MessageDefinition<S>, ...args: ParamsArg<S>): HydraniumMessageData;
|
|
83
|
+
/**
|
|
84
|
+
* Identity plus resolved English, for a hand-off carrying a value rather than a
|
|
85
|
+
* protocol field. The result is structured-clone safe, so it survives a process
|
|
86
|
+
* hop where one intervenes and costs nothing where none does.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolve<S extends string>(message: MessageDefinition<S>, ...args: ParamsArg<S>): ResolvedMessage;
|
|
89
|
+
/**
|
|
90
|
+
* Validates every field {@link MessageIdentity} declares, `params` included.
|
|
91
|
+
* A guard over foreign input that checks only `code` while declaring `params`
|
|
92
|
+
* non-optional hands `undefined` to the renderer, which fails with the worst
|
|
93
|
+
* polarity available: invisible in English, crashing only once a translation is
|
|
94
|
+
* loaded.
|
|
95
|
+
*/
|
|
96
|
+
export declare function hasMessageIdentity(data: unknown): data is HydraniumMessageData;
|
|
97
|
+
/**
|
|
98
|
+
* A type alias rather than a subclass. Only `code`, `message` and `data` cross
|
|
99
|
+
* the wire, so a subclass buys nothing there: `instanceof` does not survive
|
|
100
|
+
* reconstruction, and the subclass costs an `Object.setPrototypeOf` in every
|
|
101
|
+
* constructor purely to undo what `ResponseError`'s own constructor does.
|
|
102
|
+
*/
|
|
103
|
+
export type HydraniumResponseError = ResponseError<HydraniumMessageData>;
|
|
104
|
+
/**
|
|
105
|
+
* The numeric `code` and the message's catalogue code are unrelated and both are
|
|
106
|
+
* needed: `ResponseError.code` is an `integer`, so it cannot hold a
|
|
107
|
+
* `hydranium/…` key, and it is what a caller switches on after reconstruction.
|
|
108
|
+
*/
|
|
109
|
+
export declare function messageError<S extends string>(code: number, message: MessageDefinition<S>, ...params: ParamsArg<S>): HydraniumResponseError;
|
|
110
|
+
/**
|
|
111
|
+
* The reading user's language, as the tag a client declared.
|
|
112
|
+
*
|
|
113
|
+
* Neither validated nor normalised anywhere: rejecting an unfamiliar tag would
|
|
114
|
+
* be selecting a locale, which the framework does not do.
|
|
115
|
+
*
|
|
116
|
+
* NOT a Langium language id, which names a grammar. The two are strings of the
|
|
117
|
+
* same shape reachable from the same services, so one used where the other
|
|
118
|
+
* belongs misses every lookup rather than failing.
|
|
119
|
+
*/
|
|
120
|
+
export type Locale = string;
|
|
121
|
+
/**
|
|
122
|
+
* A host's templates for one locale, keyed by the whole message code.
|
|
123
|
+
*
|
|
124
|
+
* **Flat, not nested.** A code is one key here, `/` separators included; a host
|
|
125
|
+
* whose own catalogue format nests — Theia's does — flattens on the way in. A
|
|
126
|
+
* map that nests instead misses every lookup while type-checking, because the
|
|
127
|
+
* value this is indexed by is `ResolvedMessage.code`.
|
|
128
|
+
*
|
|
129
|
+
* **Partial by nature rather than by convention.** A code with no entry renders
|
|
130
|
+
* its English default, so a catalogue covering none of a package's codes is a
|
|
131
|
+
* valid catalogue and not a broken one — which is what lets an adopter translate
|
|
132
|
+
* as much or as little as they like.
|
|
133
|
+
*
|
|
134
|
+
* Deliberately NOT narrowed to the codes that exist, and a `Code extends string`
|
|
135
|
+
* parameter would not buy what it appears to: a catalogue is loaded as JSON, so
|
|
136
|
+
* it reaches a checked position as a variable rather than as an object literal,
|
|
137
|
+
* and excess-property checking — the only thing that would reject a mistyped
|
|
138
|
+
* key — does not run there. The gain is a compile error for a catalogue with no
|
|
139
|
+
* correct key at all; the cost is a code union to maintain by hand, since a
|
|
140
|
+
* declaration does not carry its code as a literal type.
|
|
141
|
+
*/
|
|
142
|
+
export type MessageCatalogue = Readonly<Record<string, string>>;
|
|
143
|
+
export declare namespace MessageCatalogue {
|
|
144
|
+
/**
|
|
145
|
+
* One catalogue from several, for a renderer whose override supplies entries
|
|
146
|
+
* over the ones it inherits.
|
|
147
|
+
*
|
|
148
|
+
* **Later wins**, so a caller passes the inherited answer before its own.
|
|
149
|
+
*
|
|
150
|
+
* **No source at all answers `undefined`, not `{}`.** A renderer holds that
|
|
151
|
+
* answer as the locale having no catalogue and renders straight through; an
|
|
152
|
+
* empty object is a catalogue that misses every lookup, so returning one
|
|
153
|
+
* turns the opt-out into a per-message search that yields the same English.
|
|
154
|
+
*/
|
|
155
|
+
function merge(...catalogues: ReadonlyArray<MessageCatalogue | undefined>): MessageCatalogue | undefined;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Render on the side that knows the reading user's locale. Omitting
|
|
159
|
+
* `translations` is how an adopter without i18n opts out, and yields the
|
|
160
|
+
* English.
|
|
161
|
+
*/
|
|
162
|
+
export declare function renderFrameworkMessage(message: ResolvedMessage, translations?: MessageCatalogue): string;
|
|
163
|
+
export declare function resolvedFromResponseError(error: ResponseError<unknown>): ResolvedMessage | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* The detail half of a `{detail}` placeholder. A technical error string is safe
|
|
166
|
+
* to pass as a parameter for the same reason a number is: it is not itself
|
|
167
|
+
* translatable text, so it needs no code of its own. A PROSE fragment is not,
|
|
168
|
+
* and must become one code per value instead.
|
|
169
|
+
*/
|
|
170
|
+
export declare function describeError(error: unknown): string;
|
|
171
|
+
/**
|
|
172
|
+
* Recognises a declaration among a barrel's exports. The `format` check is what
|
|
173
|
+
* discriminates: a `code` + `text` pair alone admits any object that happens to
|
|
174
|
+
* carry both.
|
|
175
|
+
*/
|
|
176
|
+
export declare function isMessageDeclaration(value: unknown): value is MessageDefinition<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Every declaration a `./messages` barrel exports.
|
|
179
|
+
*
|
|
180
|
+
* A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
|
|
181
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
182
|
+
* `filter` will not narrow a function type down to a `MessageDefinition`, so the
|
|
183
|
+
* result stays the union and reading `.code` off it does not compile. Taking the
|
|
184
|
+
* barrel as an opaque object is what makes the one-liner work.
|
|
185
|
+
*/
|
|
186
|
+
export declare function collectMessages(barrel: object): MessageDefinition<string>[];
|
|
187
|
+
export {};
|
|
188
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/messages/primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEtE,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI,EAAE,GAAG,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAE1H,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACpE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GACpB,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEvD,gFAAgF;AAChF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAExG;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,SAAS,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAEzE,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;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wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC7B,GAAG,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GACvB,sBAAsB,CAExB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhE,yBAAiB,gBAAgB,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,SAAgB,KAAK,CAAC,GAAG,UAAU,EAAE,aAAa,CAAC,gBAAgB,GAAG,SAAS,CAAC,GAAG,gBAAgB,GAAG,SAAS,CAM9G;CACH;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAGxG;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,SAAS,CAEpG;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAAC,MAAM,CAAC,CASvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAE3E"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.MessageCatalogue = void 0;
|
|
12
|
+
exports.defineMessage = defineMessage;
|
|
13
|
+
exports.interpolate = interpolate;
|
|
14
|
+
exports.messageData = messageData;
|
|
15
|
+
exports.resolve = resolve;
|
|
16
|
+
exports.hasMessageIdentity = hasMessageIdentity;
|
|
17
|
+
exports.messageError = messageError;
|
|
18
|
+
exports.renderFrameworkMessage = renderFrameworkMessage;
|
|
19
|
+
exports.resolvedFromResponseError = resolvedFromResponseError;
|
|
20
|
+
exports.describeError = describeError;
|
|
21
|
+
exports.isMessageDeclaration = isMessageDeclaration;
|
|
22
|
+
exports.collectMessages = collectMessages;
|
|
23
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
24
|
+
/**
|
|
25
|
+
* Declare a message. Placeholder names are inferred from `text` rather than
|
|
26
|
+
* declared again in a type argument: a second spelling of every name is the
|
|
27
|
+
* repetition that drifts, since adding a placeholder to the sentence and not to
|
|
28
|
+
* the type compiles.
|
|
29
|
+
*/
|
|
30
|
+
function defineMessage(code, text) {
|
|
31
|
+
const literal = text;
|
|
32
|
+
return { code, text: literal, format: (...args) => interpolate(literal, args[0] ?? {}) };
|
|
33
|
+
}
|
|
34
|
+
const PLACEHOLDER = /\{([^}]+)\}/g;
|
|
35
|
+
/**
|
|
36
|
+
* Substitute `{name}` tokens, leaving an unfilled token in place.
|
|
37
|
+
*
|
|
38
|
+
* It must not throw. This runs over an adopter's translation as well as our own
|
|
39
|
+
* text, so a typo in a foreign catalogue has to degrade to a slightly wrong
|
|
40
|
+
* sentence rather than raise inside a toast render. Re-scanning the result to
|
|
41
|
+
* detect an unfilled token is what an earlier form did, and it cannot work:
|
|
42
|
+
* `String.replace` does not rescan replacement text, so the check could not tell
|
|
43
|
+
* an unfilled placeholder from user data shaped like one — an element literally
|
|
44
|
+
* named `{separator}` crashed at the authoring site.
|
|
45
|
+
*/
|
|
46
|
+
function interpolate(template, params) {
|
|
47
|
+
// Indexed rather than `key in params`: a hand-built or version-skewed
|
|
48
|
+
// identity can arrive with no params at all, and `in` throws on a non-object
|
|
49
|
+
// where a lookup degrades.
|
|
50
|
+
const lookup = params;
|
|
51
|
+
return template.replace(PLACEHOLDER, (match, key) => {
|
|
52
|
+
const value = lookup?.[key];
|
|
53
|
+
return value === undefined ? match : String(value);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function messageData(message, ...args) {
|
|
57
|
+
return { hydranium: { code: message.code, params: args[0] ?? {} } };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Identity plus resolved English, for a hand-off carrying a value rather than a
|
|
61
|
+
* protocol field. The result is structured-clone safe, so it survives a process
|
|
62
|
+
* hop where one intervenes and costs nothing where none does.
|
|
63
|
+
*/
|
|
64
|
+
function resolve(message, ...args) {
|
|
65
|
+
return { code: message.code, text: message.format(...args), params: args[0] ?? {} };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Validates every field {@link MessageIdentity} declares, `params` included.
|
|
69
|
+
* A guard over foreign input that checks only `code` while declaring `params`
|
|
70
|
+
* non-optional hands `undefined` to the renderer, which fails with the worst
|
|
71
|
+
* polarity available: invisible in English, crashing only once a translation is
|
|
72
|
+
* loaded.
|
|
73
|
+
*/
|
|
74
|
+
function hasMessageIdentity(data) {
|
|
75
|
+
if (typeof data !== 'object' || data === null || Array.isArray(data) || !('hydranium' in data)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const identity = data.hydranium;
|
|
79
|
+
if (typeof identity !== 'object' || identity === null || Array.isArray(identity)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const candidate = identity;
|
|
83
|
+
return typeof candidate.code === 'string' && typeof candidate.params === 'object' && candidate.params !== null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The numeric `code` and the message's catalogue code are unrelated and both are
|
|
87
|
+
* needed: `ResponseError.code` is an `integer`, so it cannot hold a
|
|
88
|
+
* `hydranium/…` key, and it is what a caller switches on after reconstruction.
|
|
89
|
+
*/
|
|
90
|
+
function messageError(code, message, ...params) {
|
|
91
|
+
return new vscode_jsonrpc_1.ResponseError(code, message.format(...params), messageData(message, ...params));
|
|
92
|
+
}
|
|
93
|
+
var MessageCatalogue;
|
|
94
|
+
(function (MessageCatalogue) {
|
|
95
|
+
/**
|
|
96
|
+
* One catalogue from several, for a renderer whose override supplies entries
|
|
97
|
+
* over the ones it inherits.
|
|
98
|
+
*
|
|
99
|
+
* **Later wins**, so a caller passes the inherited answer before its own.
|
|
100
|
+
*
|
|
101
|
+
* **No source at all answers `undefined`, not `{}`.** A renderer holds that
|
|
102
|
+
* answer as the locale having no catalogue and renders straight through; an
|
|
103
|
+
* empty object is a catalogue that misses every lookup, so returning one
|
|
104
|
+
* turns the opt-out into a per-message search that yields the same English.
|
|
105
|
+
*/
|
|
106
|
+
function merge(...catalogues) {
|
|
107
|
+
const present = catalogues.filter((catalogue) => catalogue !== undefined);
|
|
108
|
+
if (present.length <= 1) {
|
|
109
|
+
return present[0];
|
|
110
|
+
}
|
|
111
|
+
return Object.assign({}, ...present);
|
|
112
|
+
}
|
|
113
|
+
MessageCatalogue.merge = merge;
|
|
114
|
+
})(MessageCatalogue || (exports.MessageCatalogue = MessageCatalogue = {}));
|
|
115
|
+
/**
|
|
116
|
+
* Render on the side that knows the reading user's locale. Omitting
|
|
117
|
+
* `translations` is how an adopter without i18n opts out, and yields the
|
|
118
|
+
* English.
|
|
119
|
+
*/
|
|
120
|
+
function renderFrameworkMessage(message, translations) {
|
|
121
|
+
const template = translations?.[message.code];
|
|
122
|
+
return template ? interpolate(template, message.params) : message.text;
|
|
123
|
+
}
|
|
124
|
+
function resolvedFromResponseError(error) {
|
|
125
|
+
return hasMessageIdentity(error.data) ? { ...error.data.hydranium, text: error.message } : undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The detail half of a `{detail}` placeholder. A technical error string is safe
|
|
129
|
+
* to pass as a parameter for the same reason a number is: it is not itself
|
|
130
|
+
* translatable text, so it needs no code of its own. A PROSE fragment is not,
|
|
131
|
+
* and must become one code per value instead.
|
|
132
|
+
*/
|
|
133
|
+
function describeError(error) {
|
|
134
|
+
return error instanceof Error ? error.message : String(error);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Recognises a declaration among a barrel's exports. The `format` check is what
|
|
138
|
+
* discriminates: a `code` + `text` pair alone admits any object that happens to
|
|
139
|
+
* carry both.
|
|
140
|
+
*/
|
|
141
|
+
function isMessageDeclaration(value) {
|
|
142
|
+
const candidate = value;
|
|
143
|
+
return (typeof candidate === 'object' &&
|
|
144
|
+
candidate !== null &&
|
|
145
|
+
typeof candidate.code === 'string' &&
|
|
146
|
+
typeof candidate.text === 'string' &&
|
|
147
|
+
typeof candidate.format === 'function');
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Every declaration a `./messages` barrel exports.
|
|
151
|
+
*
|
|
152
|
+
* A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
|
|
153
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
154
|
+
* `filter` will not narrow a function type down to a `MessageDefinition`, so the
|
|
155
|
+
* result stays the union and reading `.code` off it does not compile. Taking the
|
|
156
|
+
* barrel as an opaque object is what makes the one-liner work.
|
|
157
|
+
*/
|
|
158
|
+
function collectMessages(barrel) {
|
|
159
|
+
return Object.values(barrel).filter(isMessageDeclaration);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/messages/primitives.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAwDlF,sCAGC;AAeD,kCASC;AAoBD,kCAEC;AAOD,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AED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC3C,OAAQ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAe,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAC5E,CAAC"}
|
package/lib/model-server.d.ts
CHANGED
|
@@ -12,8 +12,14 @@
|
|
|
12
12
|
* language identifier — consumers parameterise the document/root types
|
|
13
13
|
* over `TRoot`.
|
|
14
14
|
*/
|
|
15
|
-
import type { TransferClientArgs } from './model-service/args';
|
|
16
15
|
import type { ReferenceCandidate } from './model-service/reference-candidate';
|
|
16
|
+
/** Identifies a client-document binding. */
|
|
17
|
+
export interface TransferClientArgs {
|
|
18
|
+
/** Document URI. */
|
|
19
|
+
uri: string;
|
|
20
|
+
/** Stable identifier for the client invoking the operation. */
|
|
21
|
+
clientId: string;
|
|
22
|
+
}
|
|
17
23
|
/** Open a document on behalf of a client. */
|
|
18
24
|
export interface OpenModelArgs extends TransferClientArgs {
|
|
19
25
|
/**
|
|
@@ -35,10 +41,18 @@ export interface OpenModelArgs extends TransferClientArgs {
|
|
|
35
41
|
* means read from the filesystem, which is the normal case.
|
|
36
42
|
*
|
|
37
43
|
* Honoured only on the first open of a URI: opening an already-open document
|
|
38
|
-
*
|
|
39
|
-
* through the update path instead.
|
|
44
|
+
* attaches the caller to the existing shared entry and does not replace its
|
|
45
|
+
* content with this seed. Write through the update path instead. The open
|
|
46
|
+
* response reads the current shared content after registration; a textual
|
|
47
|
+
* `didOpen` attach may separately refresh the build.
|
|
40
48
|
*/
|
|
41
49
|
text?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Kept on the server for this client's open until it closes, for the
|
|
52
|
+
* server's own open path to read. Only a client session's open keeps them,
|
|
53
|
+
* and a repeat open keeps the first open's.
|
|
54
|
+
*/
|
|
55
|
+
options?: object;
|
|
42
56
|
}
|
|
43
57
|
/** Close a previously-opened document for the client. */
|
|
44
58
|
export interface CloseModelArgs extends TransferClientArgs {
|
|
@@ -46,8 +60,8 @@ export interface CloseModelArgs extends TransferClientArgs {
|
|
|
46
60
|
export interface TransferUpdatedEvent<TDocument> {
|
|
47
61
|
document: TDocument;
|
|
48
62
|
sourceClientId: string;
|
|
49
|
-
/** See `
|
|
50
|
-
reason: 'changed' | '
|
|
63
|
+
/** See `TransferDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
|
|
64
|
+
reason: 'changed' | 'rebuilt' | 'saved';
|
|
51
65
|
}
|
|
52
66
|
export interface TransferSavedEvent<TDocument> {
|
|
53
67
|
/** The document as persisted — the state that reached disk, not the state at request time. */
|
|
@@ -114,10 +128,10 @@ export declare function isElementSource(object: unknown): object is ElementSourc
|
|
|
114
128
|
/** An element of a document that does not yet exist on disk — used during element creation flows. */
|
|
115
129
|
export interface SyntheticSource {
|
|
116
130
|
/**
|
|
117
|
-
* The document the element would belong to.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
131
|
+
* The document the element would belong to. It need not be loaded, or
|
|
132
|
+
* exist — an unloaded URI materialises a transient empty document, so a
|
|
133
|
+
* folder is a valid anchor. A URI that IS loaded contributes that
|
|
134
|
+
* document's parse root as the container, putting its contents in scope.
|
|
121
135
|
*/
|
|
122
136
|
uri: string;
|
|
123
137
|
/**
|
|
@@ -126,6 +140,16 @@ export interface SyntheticSource {
|
|
|
126
140
|
* it is what scoping filters candidates against.
|
|
127
141
|
*/
|
|
128
142
|
type: string;
|
|
143
|
+
/**
|
|
144
|
+
* The grammar the element will belong to, as a language id.
|
|
145
|
+
*
|
|
146
|
+
* Optional because `uri` and `type` each answer on their own when
|
|
147
|
+
* unambiguous. Set it when neither is: a URI naming no file carries no
|
|
148
|
+
* extension to route on, and a `type` two grammars can produce identifies
|
|
149
|
+
* neither. Unset, such a source reaches the server's own policy, which
|
|
150
|
+
* answers the same way for every caller.
|
|
151
|
+
*/
|
|
152
|
+
language?: string;
|
|
129
153
|
}
|
|
130
154
|
export declare function isSyntheticSource(object: unknown): object is SyntheticSource;
|
|
131
155
|
/**
|
|
@@ -135,7 +159,7 @@ export declare function isSyntheticSource(object: unknown): object is SyntheticS
|
|
|
135
159
|
export declare namespace ReferenceSource {
|
|
136
160
|
function document(uri: string): DocumentSource;
|
|
137
161
|
function element(name: string, type?: string): ElementSource;
|
|
138
|
-
function synthetic(uri: string, type: string): SyntheticSource;
|
|
162
|
+
function synthetic(uri: string, type: string, language?: string): SyntheticSource;
|
|
139
163
|
}
|
|
140
164
|
/**
|
|
141
165
|
* One step in a synthetic navigation path from a {@link ReferenceSource}
|
|
@@ -329,9 +353,10 @@ export interface FindNextNameArgs {
|
|
|
329
353
|
*/
|
|
330
354
|
uri: string;
|
|
331
355
|
/**
|
|
332
|
-
* The AST `$type` of the element being named. Collisions are
|
|
333
|
-
* among elements of that
|
|
334
|
-
*
|
|
356
|
+
* The AST `$type` of the element being named. Collisions are looked for
|
|
357
|
+
* among elements of that type and of any subtype of it, so a supertype
|
|
358
|
+
* names a uniqueness scope its concrete types share; the returned name may
|
|
359
|
+
* still be taken by an element outside that hierarchy.
|
|
335
360
|
*/
|
|
336
361
|
type: string;
|
|
337
362
|
/**
|
|
@@ -348,5 +373,11 @@ export interface FindNextNameArgs {
|
|
|
348
373
|
* See {@link NameTier} for what each tier covers.
|
|
349
374
|
*/
|
|
350
375
|
tier?: NameTier;
|
|
376
|
+
/**
|
|
377
|
+
* The grammar to name under, routed as {@link SyntheticSource.language} —
|
|
378
|
+
* this call builds one. A caller that sets it there must set it here, or
|
|
379
|
+
* candidates and the name it proposes come from different grammars.
|
|
380
|
+
*/
|
|
381
|
+
language?: string;
|
|
351
382
|
}
|
|
352
383
|
//# sourceMappingURL=model-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-server.d.ts","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+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AW,0BAA0B;IACxC,KAAK,IAAI,gBAAgB,CAAC;CAC5B;AAED,oGAAoG;AACpG,MAAM,WAAW,0BAA0B;IACxC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,0BAA0B,CAAC;CACnD;AAED,4CAA4C;AAC5C,MAAM,WAAW,0BAA0B;IACxC,KAAK,IAAI,gBAAgB,CAAC;CAC5B;AA8BD,yBAAiB,gBAAgB,CAAC;IAC/B,oEAAoE;IACpE,SAAgB,OAAO,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAE1E;CACH;AAED,yBAAiB,gBAAgB,CAAC;IAC/B,6EAA6E;IAC7E,SAAgB,OAAO,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAI1E;IAED;;;;;;OAMG;IACH,SAAgB,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,kBAAkB,GAAG,gBAAgB,CAE/F;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtD,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC9B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/lib/model-server.js
CHANGED
|
@@ -47,8 +47,10 @@ var ReferenceSource;
|
|
|
47
47
|
return { name, type };
|
|
48
48
|
}
|
|
49
49
|
ReferenceSource.element = element;
|
|
50
|
-
function synthetic(uri, type) {
|
|
51
|
-
|
|
50
|
+
function synthetic(uri, type, language) {
|
|
51
|
+
// The key is omitted rather than set to `undefined`, so a source built
|
|
52
|
+
// without a language stays deep-equal to the two-argument form.
|
|
53
|
+
return language === undefined ? { uri, type } : { uri, type, language };
|
|
52
54
|
}
|
|
53
55
|
ReferenceSource.synthetic = synthetic;
|
|
54
56
|
})(ReferenceSource || (exports.ReferenceSource = ReferenceSource = {}));
|
package/lib/model-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-server.js","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"model-server.js","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAmHlF,4CAEC;AA4BD,0CAEC;AA6BD,8CASC;AAoED,0CASC;AAyDD,gDAQC;AAzND;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,MAAe;IAC7C,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC;AACtG,CAAC;AA4BD,SAAgB,eAAe,CAAC,MAAe;IAC5C,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AACxG,CAAC;AA6BD,SAAgB,iBAAiB,CAAC,MAAe;IAC9C,OAAO,CACJ,CAAC,CAAC,MAAM;QACR,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,IAAI,MAAM;QACf,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;QAC9B,MAAM,IAAI,MAAM;QAChB,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CACjC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,IAAiB,eAAe,CAY/B;AAZD,WAAiB,eAAe;IAC7B,SAAgB,QAAQ,CAAC,GAAW;QACjC,OAAO,EAAE,GAAG,EAAE,CAAC;IAClB,CAAC;IAFe,wBAAQ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SAAgB,OAAO;QACpB,OAAO,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAFe,wBAAO,UAEtB,CAAA;AACJ,CAAC,EALgB,gBAAgB,gCAAhB,gBAAgB,QAKhC;AAED,IAAiB,gBAAgB,CAkBhC;AAlBD,WAAiB,gBAAgB;IAC9B,6EAA6E;IAC7E,SAAgB,OAAO;QACpB,OAAO,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACjC,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;SACtE,CAAC,CAAC,CAAC;IACP,CAAC;IAJe,wBAAO,UAItB,CAAA;IAED;;;;;;OAMG;IACH,SAAgB,IAAI,CAAC,OAAyB,EAAE,SAA6B;QAC1E,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAFe,qBAAI,OAEnB,CAAA;AACJ,CAAC,EAlBgB,gBAAgB,gCAAhB,gBAAgB,QAkBhC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
declare const snapshotMarker: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* A text-document version that came out of a SNAPSHOT read: a document
|
|
12
|
+
* envelope's `version`, which cannot move once the envelope exists.
|
|
13
|
+
*
|
|
14
|
+
* A plain number at runtime, usable anywhere a number is, and it travels the
|
|
15
|
+
* wire as one. The marker exists only so the compiler can tell it apart from a
|
|
16
|
+
* version read off a LIVE document, which is the same number type and is the
|
|
17
|
+
* defect the conflict gate exists to prevent: read at write time it is whatever
|
|
18
|
+
* the server is at now, which is the number the gate is about to compare it
|
|
19
|
+
* against, so the gate passes unconditionally and a concurrent edit is
|
|
20
|
+
* overwritten with nothing logged.
|
|
21
|
+
*/
|
|
22
|
+
export type SnapshotVersion = number & {
|
|
23
|
+
readonly [snapshotMarker]: true;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* What a write declares it was based on: a version from a snapshot read, or
|
|
27
|
+
* `'anything'`.
|
|
28
|
+
*
|
|
29
|
+
* `'anything'` is a precondition that always holds — the write accepts whatever
|
|
30
|
+
* the server currently has, and therefore overwrites it. It is the honest
|
|
31
|
+
* answer wherever the write was authored against no particular server version,
|
|
32
|
+
* and a lie anywhere a reader handed the writer a document. The field carrying
|
|
33
|
+
* it is required, so an ungated write is a word someone chose rather than a
|
|
34
|
+
* field someone forgot.
|
|
35
|
+
*/
|
|
36
|
+
export type BasedOn = SnapshotVersion | 'anything';
|
|
37
|
+
/**
|
|
38
|
+
* Whether `basedOn` names a version, and so arms the gate.
|
|
39
|
+
*
|
|
40
|
+
* Branch on this rather than on `basedOn !== 'anything'`, which reads as "not
|
|
41
|
+
* based on anything" — the opposite of what the branch tests.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSnapshotVersion(basedOn: BasedOn): basedOn is SnapshotVersion;
|
|
44
|
+
/**
|
|
45
|
+
* Mark a version as having come from a snapshot read.
|
|
46
|
+
*
|
|
47
|
+
* **For the envelope constructors, not for callers.** Every door that builds a
|
|
48
|
+
* document envelope applies it on the way in, so anything a read returns
|
|
49
|
+
* already carries it and a writer never needs this. A caller reaching for it is
|
|
50
|
+
* asserting a provenance the compiler was about to deny — the read-late defect
|
|
51
|
+
* written out where a reviewer can see it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function asSnapshotVersion(version: number): SnapshotVersion;
|
|
54
|
+
/** A snapshot version no write can match, so a write based on it conflicts. */
|
|
55
|
+
export declare const NO_MATCHING_VERSION: SnapshotVersion;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=based-on.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"based-on.d.ts","sourceRoot":"","sources":["../../src/model-service/based-on.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,MAAM,MAAM,OAAO,GAAG,eAAe,GAAG,UAAU,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,eAAe,CAE9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAElE;AAED,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,EAAE,eAAuC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.NO_MATCHING_VERSION = void 0;
|
|
12
|
+
exports.isSnapshotVersion = isSnapshotVersion;
|
|
13
|
+
exports.asSnapshotVersion = asSnapshotVersion;
|
|
14
|
+
/**
|
|
15
|
+
* Whether `basedOn` names a version, and so arms the gate.
|
|
16
|
+
*
|
|
17
|
+
* Branch on this rather than on `basedOn !== 'anything'`, which reads as "not
|
|
18
|
+
* based on anything" — the opposite of what the branch tests.
|
|
19
|
+
*/
|
|
20
|
+
function isSnapshotVersion(basedOn) {
|
|
21
|
+
return typeof basedOn === 'number';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mark a version as having come from a snapshot read.
|
|
25
|
+
*
|
|
26
|
+
* **For the envelope constructors, not for callers.** Every door that builds a
|
|
27
|
+
* document envelope applies it on the way in, so anything a read returns
|
|
28
|
+
* already carries it and a writer never needs this. A caller reaching for it is
|
|
29
|
+
* asserting a provenance the compiler was about to deny — the read-late defect
|
|
30
|
+
* written out where a reviewer can see it.
|
|
31
|
+
*/
|
|
32
|
+
function asSnapshotVersion(version) {
|
|
33
|
+
return version;
|
|
34
|
+
}
|
|
35
|
+
/** A snapshot version no write can match, so a write based on it conflicts. */
|
|
36
|
+
exports.NO_MATCHING_VERSION = asSnapshotVersion(-1);
|
|
37
|
+
//# sourceMappingURL=based-on.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"based-on.js","sourceRoot":"","sources":["../../src/model-service/based-on.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAqClF,8CAEC;AAWD,8CAEC;AArBD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,OAAgB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC;AACtC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC9C,OAAO,OAA0B,CAAC;AACrC,CAAC;AAED,+EAA+E;AAClE,QAAA,mBAAmB,GAAoB,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC"}
|