@hydranium/protocol 1.0.0-next.19 → 1.0.0-next.193

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.
Files changed (205) hide show
  1. package/README.md +35 -1
  2. package/lib/abstract-logger.d.ts.map +1 -1
  3. package/lib/abstract-logger.js.map +1 -1
  4. package/lib/client/data-connection.d.ts +157 -0
  5. package/lib/client/data-connection.d.ts.map +1 -0
  6. package/lib/client/data-connection.js +236 -0
  7. package/lib/client/data-connection.js.map +1 -0
  8. package/lib/client/data-events.d.ts +13 -1
  9. package/lib/client/data-events.d.ts.map +1 -1
  10. package/lib/client/data-events.js +21 -0
  11. package/lib/client/data-events.js.map +1 -1
  12. package/lib/client/data-port.d.ts +24 -22
  13. package/lib/client/data-port.d.ts.map +1 -1
  14. package/lib/client/data-session.d.ts +471 -81
  15. package/lib/client/data-session.d.ts.map +1 -1
  16. package/lib/client/data-session.js +737 -108
  17. package/lib/client/data-session.js.map +1 -1
  18. package/lib/client/index.d.ts +14 -9
  19. package/lib/client/index.d.ts.map +1 -1
  20. package/lib/client/index.js +14 -9
  21. package/lib/client/index.js.map +1 -1
  22. package/lib/client/message-relay.d.ts +9 -3
  23. package/lib/client/message-relay.d.ts.map +1 -1
  24. package/lib/client/message-relay.js +11 -5
  25. package/lib/client/message-relay.js.map +1 -1
  26. package/lib/client/post-message-transport.d.ts +64 -3
  27. package/lib/client/post-message-transport.d.ts.map +1 -1
  28. package/lib/client/post-message-transport.js +175 -1
  29. package/lib/client/post-message-transport.js.map +1 -1
  30. package/lib/client/rpc-connection.d.ts +149 -0
  31. package/lib/client/rpc-connection.d.ts.map +1 -0
  32. package/lib/client/rpc-connection.js +202 -0
  33. package/lib/client/rpc-connection.js.map +1 -0
  34. package/lib/client-ids.d.ts +45 -0
  35. package/lib/client-ids.d.ts.map +1 -0
  36. package/lib/client-ids.js +48 -0
  37. package/lib/client-ids.js.map +1 -0
  38. package/lib/clock.d.ts +38 -0
  39. package/lib/clock.d.ts.map +1 -1
  40. package/lib/clock.js +36 -1
  41. package/lib/clock.js.map +1 -1
  42. package/lib/data/data-protocol-methods.d.ts +4 -4
  43. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  44. package/lib/data/data-protocol-methods.js +12 -1
  45. package/lib/data/data-protocol-methods.js.map +1 -1
  46. package/lib/data/data-server-protocol.d.ts +131 -41
  47. package/lib/data/data-server-protocol.d.ts.map +1 -1
  48. package/lib/data/events.d.ts +117 -21
  49. package/lib/data/events.d.ts.map +1 -1
  50. package/lib/data/requests.d.ts +69 -11
  51. package/lib/data/requests.d.ts.map +1 -1
  52. package/lib/debouncer.d.ts.map +1 -1
  53. package/lib/debouncer.js.map +1 -1
  54. package/lib/errors.d.ts +181 -29
  55. package/lib/errors.d.ts.map +1 -1
  56. package/lib/errors.js +261 -29
  57. package/lib/errors.js.map +1 -1
  58. package/lib/glsp-save-model-actions.d.ts +50 -0
  59. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  60. package/lib/glsp-save-model-actions.js +28 -0
  61. package/lib/glsp-save-model-actions.js.map +1 -0
  62. package/lib/index.d.ts +4 -0
  63. package/lib/index.d.ts.map +1 -1
  64. package/lib/index.js +7 -0
  65. package/lib/index.js.map +1 -1
  66. package/lib/latency-collector.d.ts +8 -4
  67. package/lib/latency-collector.d.ts.map +1 -1
  68. package/lib/latency-collector.js.map +1 -1
  69. package/lib/logger.d.ts +22 -1
  70. package/lib/logger.d.ts.map +1 -1
  71. package/lib/logger.js +31 -3
  72. package/lib/logger.js.map +1 -1
  73. package/lib/messages/index.d.ts +29 -0
  74. package/lib/messages/index.d.ts.map +1 -0
  75. package/lib/messages/index.js +59 -0
  76. package/lib/messages/index.js.map +1 -0
  77. package/lib/messages/primitives.d.ts +188 -0
  78. package/lib/messages/primitives.d.ts.map +1 -0
  79. package/lib/messages/primitives.js +161 -0
  80. package/lib/messages/primitives.js.map +1 -0
  81. package/lib/model-server.d.ts +60 -13
  82. package/lib/model-server.d.ts.map +1 -1
  83. package/lib/model-server.js +4 -2
  84. package/lib/model-server.js.map +1 -1
  85. package/lib/model-service/base-version.d.ts +64 -0
  86. package/lib/model-service/base-version.d.ts.map +1 -0
  87. package/lib/model-service/base-version.js +43 -0
  88. package/lib/model-service/base-version.js.map +1 -0
  89. package/lib/model-service/index.d.ts +1 -1
  90. package/lib/model-service/index.d.ts.map +1 -1
  91. package/lib/model-service/index.js +4 -5
  92. package/lib/model-service/index.js.map +1 -1
  93. package/lib/model-service/reference-candidate.d.ts +5 -3
  94. package/lib/model-service/reference-candidate.d.ts.map +1 -1
  95. package/lib/noop-logger.d.ts.map +1 -1
  96. package/lib/noop-logger.js.map +1 -1
  97. package/lib/observable-value.js.map +1 -1
  98. package/lib/patch-merge.d.ts +35 -32
  99. package/lib/patch-merge.d.ts.map +1 -1
  100. package/lib/patch-merge.js +67 -23
  101. package/lib/patch-merge.js.map +1 -1
  102. package/lib/profile-session.d.ts +8 -4
  103. package/lib/profile-session.d.ts.map +1 -1
  104. package/lib/profile-session.js.map +1 -1
  105. package/lib/reconcile-write.d.ts +65 -0
  106. package/lib/reconcile-write.d.ts.map +1 -0
  107. package/lib/reconcile-write.js +67 -0
  108. package/lib/reconcile-write.js.map +1 -0
  109. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  110. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  111. package/lib/rpc/bind-rpc-methods.js +22 -3
  112. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  113. package/lib/rpc/create-rpc-proxy.d.ts +10 -0
  114. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  115. package/lib/rpc/create-rpc-proxy.js +12 -2
  116. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  117. package/lib/rpc/wire-prefix.js.map +1 -1
  118. package/lib/testing/catalogue-audit.d.ts +80 -0
  119. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  120. package/lib/testing/catalogue-audit.js +94 -0
  121. package/lib/testing/catalogue-audit.js.map +1 -0
  122. package/lib/testing/data-doubles.d.ts +13 -12
  123. package/lib/testing/data-doubles.d.ts.map +1 -1
  124. package/lib/testing/data-doubles.js +19 -5
  125. package/lib/testing/data-doubles.js.map +1 -1
  126. package/lib/testing/fake-clock.d.ts +9 -1
  127. package/lib/testing/fake-clock.d.ts.map +1 -1
  128. package/lib/testing/fake-clock.js +54 -45
  129. package/lib/testing/fake-clock.js.map +1 -1
  130. package/lib/testing/index.d.ts +1 -0
  131. package/lib/testing/index.d.ts.map +1 -1
  132. package/lib/testing/index.js +5 -2
  133. package/lib/testing/index.js.map +1 -1
  134. package/lib/testing/node/duplex-connection.js.map +1 -1
  135. package/lib/testing/node/duplex-stream.js.map +1 -1
  136. package/lib/testing/node/index.d.ts +1 -0
  137. package/lib/testing/node/index.d.ts.map +1 -1
  138. package/lib/testing/node/index.js +2 -2
  139. package/lib/testing/node/index.js.map +1 -1
  140. package/lib/testing/node/message-port-pair.d.ts +25 -0
  141. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  142. package/lib/testing/node/message-port-pair.js +26 -0
  143. package/lib/testing/node/message-port-pair.js.map +1 -0
  144. package/lib/testing/wait-for.js.map +1 -1
  145. package/lib/tracer.d.ts.map +1 -1
  146. package/lib/tracer.js.map +1 -1
  147. package/lib/transfer-diagnostic.d.ts +33 -0
  148. package/lib/transfer-diagnostic.d.ts.map +1 -1
  149. package/lib/transfer-diagnostic.js +23 -0
  150. package/lib/transfer-diagnostic.js.map +1 -1
  151. package/lib/transfer-document.d.ts +70 -32
  152. package/lib/transfer-document.d.ts.map +1 -1
  153. package/lib/transfer-document.js +17 -9
  154. package/lib/transfer-document.js.map +1 -1
  155. package/lib/uri.d.ts.map +1 -1
  156. package/lib/uri.js.map +1 -1
  157. package/lib/util.d.ts +8 -0
  158. package/lib/util.d.ts.map +1 -1
  159. package/lib/util.js +32 -0
  160. package/lib/util.js.map +1 -1
  161. package/package.json +27 -18
  162. package/src/client/data-connection.ts +314 -0
  163. package/src/client/data-events.ts +33 -1
  164. package/src/client/data-port.ts +25 -23
  165. package/src/client/data-session.ts +945 -126
  166. package/src/client/index.ts +14 -9
  167. package/src/client/message-relay.ts +29 -7
  168. package/src/client/post-message-transport.ts +219 -4
  169. package/src/client/rpc-connection.ts +268 -0
  170. package/src/client-ids.ts +49 -0
  171. package/src/clock.ts +56 -0
  172. package/src/data/data-protocol-methods.ts +13 -4
  173. package/src/data/data-server-protocol.ts +156 -41
  174. package/src/data/events.ts +123 -21
  175. package/src/data/requests.ts +74 -11
  176. package/src/errors.ts +311 -36
  177. package/src/glsp-save-model-actions.ts +59 -0
  178. package/src/index.ts +7 -0
  179. package/src/latency-collector.ts +8 -3
  180. package/src/logger.ts +28 -2
  181. package/src/messages/index.ts +36 -0
  182. package/src/messages/primitives.ts +271 -0
  183. package/src/model-server.ts +63 -18
  184. package/src/model-service/base-version.ts +72 -0
  185. package/src/model-service/index.ts +4 -5
  186. package/src/model-service/reference-candidate.ts +5 -3
  187. package/src/patch-merge.ts +97 -42
  188. package/src/profile-session.ts +9 -4
  189. package/src/reconcile-write.ts +124 -0
  190. package/src/rpc/bind-rpc-methods.ts +49 -4
  191. package/src/rpc/create-rpc-proxy.ts +20 -2
  192. package/src/testing/catalogue-audit.ts +111 -0
  193. package/src/testing/data-doubles.ts +42 -17
  194. package/src/testing/fake-clock.ts +62 -47
  195. package/src/testing/index.ts +5 -2
  196. package/src/testing/node/index.ts +2 -2
  197. package/src/testing/node/message-port-pair.ts +40 -0
  198. package/src/transfer-diagnostic.ts +40 -0
  199. package/src/transfer-document.ts +87 -34
  200. package/src/util.ts +33 -0
  201. package/lib/model-service/args.d.ts +0 -64
  202. package/lib/model-service/args.d.ts.map +0 -1
  203. package/lib/model-service/args.js +0 -11
  204. package/lib/model-service/args.js.map +0 -1
  205. 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
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1C,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;;;;;;;;;;;;;;AAElF,mDAA+C;AAgD/C;;;;;GAKG;AACH,u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EAnBgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QAmBhC;AAED;;;;GAIG;AACH,gCAAuC,OAAwB,EAAE,YAA+B;IAC7F,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;AAC1E,CAAC;AAED,mCAA0C,KAA6B;IACpE,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACxG,CAAC;AAED;;;;;GAKG;AACH,uBAA8B,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,8BAAqC,KAAc;IAChD,MAAM,SAAS,GAAG,KAAoE,CAAC;IACvF,OAAO,CACJ,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,KAAK,IAAI;QAClB,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,MAAM,KAAK,UAAU,CACxC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,yBAAgC,MAAc;IAC3C,OAAQ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAe,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAC5E,CAAC"}
@@ -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,19 +41,43 @@ 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
- * is a no-op, so passing `text` for one silently changes nothing. Write
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 {
45
59
  }
46
60
  export interface TransferUpdatedEvent<TDocument> {
47
61
  document: TDocument;
62
+ /**
63
+ * The client whose write this event echoes: the author of the version on a
64
+ * `'changed'`, and the unknown-client id on a `'rebuilt'`, which echoes no
65
+ * write. A recipient compares it against its own id to recognise its echo.
66
+ */
48
67
  sourceClientId: string;
49
- /** See `ModelDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
50
- reason: 'changed' | 'deleted' | 'rebuilt' | 'saved';
68
+ /** See `TransferDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
69
+ reason: 'changed' | 'rebuilt' | 'saved';
70
+ /**
71
+ * The client whose write caused the build that produced this event, or the
72
+ * unknown-client id when no single client's did. On a `'changed'` it is the
73
+ * version's author. A `'rebuilt'` names the writer of another document, so
74
+ * it is a cause, never an echo: its diagnostics and references are new to
75
+ * that writer too.
76
+ *
77
+ * In-process only: the data head does not send it, and an event built
78
+ * elsewhere may leave it out, which a reader takes as "not known".
79
+ */
80
+ causedBy?: string;
51
81
  }
52
82
  export interface TransferSavedEvent<TDocument> {
53
83
  /** The document as persisted — the state that reached disk, not the state at request time. */
@@ -114,10 +144,10 @@ export declare function isElementSource(object: unknown): object is ElementSourc
114
144
  /** An element of a document that does not yet exist on disk — used during element creation flows. */
115
145
  export interface SyntheticSource {
116
146
  /**
117
- * The document the element would belong to. That document must already be
118
- * LOADED — the default resolution takes its parse root as the synthetic
119
- * node's container and answers `undefined` when it is not, so a URI for a
120
- * file that exists on disk but was never opened resolves to nothing.
147
+ * The document the element would belong to. It need not be loaded, or
148
+ * exist — an unloaded URI materialises a transient empty document, so a
149
+ * folder is a valid anchor. A URI that IS loaded contributes that
150
+ * document's parse root as the container, putting its contents in scope.
121
151
  */
122
152
  uri: string;
123
153
  /**
@@ -126,6 +156,16 @@ export interface SyntheticSource {
126
156
  * it is what scoping filters candidates against.
127
157
  */
128
158
  type: string;
159
+ /**
160
+ * The grammar the element will belong to, as a language id.
161
+ *
162
+ * Optional because `uri` and `type` each answer on their own when
163
+ * unambiguous. Set it when neither is: a URI naming no file carries no
164
+ * extension to route on, and a `type` two grammars can produce identifies
165
+ * neither. Unset, such a source reaches the server's own policy, which
166
+ * answers the same way for every caller.
167
+ */
168
+ language?: string;
129
169
  }
130
170
  export declare function isSyntheticSource(object: unknown): object is SyntheticSource;
131
171
  /**
@@ -135,7 +175,7 @@ export declare function isSyntheticSource(object: unknown): object is SyntheticS
135
175
  export declare namespace ReferenceSource {
136
176
  function document(uri: string): DocumentSource;
137
177
  function element(name: string, type?: string): ElementSource;
138
- function synthetic(uri: string, type: string): SyntheticSource;
178
+ function synthetic(uri: string, type: string, language?: string): SyntheticSource;
139
179
  }
140
180
  /**
141
181
  * One step in a synthetic navigation path from a {@link ReferenceSource}
@@ -329,9 +369,10 @@ export interface FindNextNameArgs {
329
369
  */
330
370
  uri: string;
331
371
  /**
332
- * The AST `$type` of the element being named. Collisions are only looked for
333
- * among elements of that same type, so the returned name may still be taken
334
- * by an element of another type.
372
+ * The AST `$type` of the element being named. Collisions are looked for
373
+ * among elements of that type and of any subtype of it, so a supertype
374
+ * names a uniqueness scope its concrete types share; the returned name may
375
+ * still be taken by an element outside that hierarchy.
335
376
  */
336
377
  type: string;
337
378
  /**
@@ -348,5 +389,11 @@ export interface FindNextNameArgs {
348
389
  * See {@link NameTier} for what each tier covers.
349
390
  */
350
391
  tier?: NameTier;
392
+ /**
393
+ * The grammar to name under, routed as {@link SyntheticSource.language} —
394
+ * this call builds one. A caller that sets it there must set it here, or
395
+ * candidates and the name it proposes come from different grammars.
396
+ */
397
+ language?: string;
351
398
  }
352
399
  //# 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,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAW9E,6CAA6C;AAC7C,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACtD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AAEzD,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAM7D,MAAM,WAAW,oBAAoB,CAAC,SAAS;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,mGAAmG;IACnG,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;CACtD;AAED,MAAM,WAAW,kBA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GAAG,cAAc,CAAC;CAC7C;AAED,2EAA2E;AAC3E,MAAM,WAAW,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"}
@@ -47,8 +47,10 @@ var ReferenceSource;
47
47
  return { name, type };
48
48
  }
49
49
  ReferenceSource.element = element;
50
- function synthetic(uri, type) {
51
- return { uri, type };
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 = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"model-server.js","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAyGlF,4CAEC;AA4BD,0CAEC;AAmBD,8CASC;AAkED,0CASC;AAyDD,gDAQC;AA7MD;;;;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;AAmBD,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,CAU/B;AAVD,WAAiB,eAAe;IAC7B,SAAgB,QAAQ,CAAC,GAAW;QACjC,OAAO,EAAE,GAAG,EAAE,CAAC;IAClB,CAAC;IAFe,wBAAQ,WAEvB,CAAA;IACD,SAAgB,OAAO,CAAC,IAAY,EAAE,IAAa;QAChD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IAFe,uBAAO,UAEtB,CAAA;IACD,SAAgB,SAAS,CAAC,GAAW,EAAE,IA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GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KAC3D,CAAC;AACL,CAAC;AAED,IAAiB,gBAAgB,CAKhC;AALD,WAAiB,gBAAgB;IAC9B,oEAAoE;IACpE,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,iBAAA,OAAO,UAEtB,CAAA;AACJ,CAAC,EALgB,gBAAgB,aAAhB,gBAAgB,GAAhB,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,iBAAA,OAAO,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,iBAAA,IAAI,OAEnB,CAAA;AACJ,CAAC,EAlBgB,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QAkBhC"}
@@ -0,0 +1,64 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the MIT License which is available in the project root.
6
+ *
7
+ * SPDX-License-Identifier: MIT
8
+ ********************************************************************************/
9
+ declare const snapshotMarker: unique symbol;
10
+ /**
11
+ * The version of the text a model was parsed from: a snapshot of the store's
12
+ * {@link TextVersion}, not a counter of its own. A document envelope carries
13
+ * it, and it cannot move once the envelope exists.
14
+ *
15
+ * A plain number at runtime, usable anywhere a number is, and it travels the
16
+ * wire as one. The marker exists only so the compiler can tell it apart from a
17
+ * version read off a LIVE document, which is the same number type and is the
18
+ * defect the conflict gate exists to prevent: read at write time it is whatever
19
+ * the server is at now, which is the number the gate is about to compare it
20
+ * against, so the gate passes unconditionally and a concurrent edit is
21
+ * overwritten with nothing logged.
22
+ */
23
+ export type ModelVersion = number & {
24
+ readonly [snapshotMarker]: true;
25
+ };
26
+ /**
27
+ * The store's version of a document's text, which moves with every change of it.
28
+ * Unbranded, so a write refuses it as `baseVersion`: it can name text newer than
29
+ * the caller's model, and a write based on it would pass the gate with older content.
30
+ */
31
+ export type TextVersion = number;
32
+ /**
33
+ * The version a write was authored against, from a snapshot read, or `'any'`: a
34
+ * precondition that always holds, so the write overwrites whatever the server has.
35
+ * `'any'` is a lie for a write authored against a document a read handed over.
36
+ */
37
+ export type BaseVersion = ModelVersion | 'any';
38
+ /** Whether `baseVersion` names a version, and so arms the gate. */
39
+ export declare function isModelVersion(baseVersion: BaseVersion): baseVersion is ModelVersion;
40
+ /**
41
+ * Mark a version as having come from a snapshot read.
42
+ *
43
+ * **For the envelope constructors, not for callers.** Every door that builds a
44
+ * document envelope applies it on the way in, so anything a read returns
45
+ * already carries it and a writer never needs this. A caller reaching for it is
46
+ * asserting a provenance the compiler was about to deny — the read-late defect
47
+ * written out where a reviewer can see it.
48
+ */
49
+ export declare function asModelVersion(version: number): ModelVersion;
50
+ /**
51
+ * The model version of a root no document factory path built, so nothing
52
+ * records the text it came from. No write matches it, so a write based on it
53
+ * conflicts.
54
+ */
55
+ export declare const UNRECORDED_VERSION: ModelVersion;
56
+ /**
57
+ * The model version of a root parsed from text the store holds under no
58
+ * version: the file, read while the store held the document open with other
59
+ * text. Below every text version, so the model reads as behind and a write
60
+ * based on it conflicts.
61
+ */
62
+ export declare const STALE_VERSION: ModelVersion;
63
+ export {};
64
+ //# sourceMappingURL=base-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-version.d.ts","sourceRoot":"","sources":["../../src/model-service/base-version.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,KAAK,CAAC;AAE/C,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,YAAY,CAEpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAE5D;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAAiC,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,YAAiC,CAAC"}