@hydranium/core 1.0.0-next.77 → 1.0.0-next.79

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.
@@ -20,11 +20,13 @@ import { type TransferLspDiagnostic } from '../validation/document-validator.js'
20
20
  * including AST-extension-derived computed scalars and synthetic child
21
21
  * mirrors. This is the wire shape clients consume, and the default.
22
22
  * - `'grammar'` — only the grammar-declared properties, per
23
- * `AstReflection.getTypeMetaData($type).properties`. Excludes every
24
- * computed / synthetic property by construction (no naming convention,
25
- * no registration). Yields the authored state a serializer round-trips —
26
- * a diffable, acyclic baseline for field-level recording / forward-write
27
- * reconcile.
23
+ * `AstReflection.getTypeMetaData($type).properties`, each carrying the
24
+ * node's own authored value. Excludes every computed / synthetic property
25
+ * by construction (no naming convention, no registration) and bypasses the
26
+ * `resolvePropertyValue` substitution hook, so neither a computed KEY nor a
27
+ * computed VALUE can reach this shape. Yields the authored state a
28
+ * serializer round-trips — a diffable, acyclic baseline for field-level
29
+ * recording / forward-write reconcile.
28
30
  */
29
31
  export type TransferMode = 'full' | 'grammar';
30
32
  /**
@@ -129,7 +131,8 @@ export interface TransferEncoder<TDiagnostic extends TransferDiagnostic = Transf
129
131
  * - {@link propertyKeys} — which property names the walk visits.
130
132
  * - {@link shouldEmitProperty} — per-key filter on top of the default
131
133
  * `$`-internals strip.
132
- * - {@link resolvePropertyValue} — value substitution per property.
134
+ * - {@link resolvePropertyValue} — value substitution per property, `'full'`
135
+ * mode only (see there for why `'grammar'` bypasses it).
133
136
  * - {@link finalizeTransferNode} — post-decoration per encoded node.
134
137
  * - {@link toTransferValue} — recursion seam per property value. Override
135
138
  * to special-case reference encoding or to drop specific value shapes.
@@ -222,8 +225,17 @@ export declare class DefaultTransferEncoder<TTransferMap = Record<string, Transf
222
225
  */
223
226
  protected shouldEmitProperty(_ast: AstNode, key: string, _context: EncodeContext): boolean;
224
227
  /**
225
- * Which value the walk emits under `key`. Default: the node's own value.
226
- * Override to substitute a derived value under a grammar property name.
228
+ * Which value the walk emits under `key`, in `'full'` mode ONLY. Default:
229
+ * the node's own value.
230
+ *
231
+ * Override to substitute a derived value under a grammar property name — an
232
+ * inheritance-resolved field, a preference-dependent label. `'grammar'`
233
+ * bypasses this hook and reads the node directly: that mode's contract is
234
+ * the authored state a serializer round-trips, and a substituted value is by
235
+ * construction not the one the document declared. An override that applied
236
+ * in both modes would leave the grammar shape carrying derived values under
237
+ * declared property names — diffable and acyclic still, but no longer
238
+ * authored, which is the property every consumer of that mode relies on.
227
239
  */
228
240
  protected resolvePropertyValue(ast: AstNode, key: string, _context: EncodeContext): unknown;
229
241
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"transfer-encoder.d.ts","sourceRoot":"","sources":["../../../src/langium/transfer/transfer-encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAEJ,KAAK,MAAM,EACX,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAY,KAAK,OAAO,EAAE,aAAa,EAAyC,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxI,OAAO,EAAE,UAAU,EAAsB,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5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AAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAI9G;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBAAkB,CAAC,IAAI,SAAS,OAAO,EACpC,eAAe,EAAE,eAAe,GAChC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC;IAerE;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,wBAAwB,CAAC,IAAI,SAAS,OAAO,EACpD,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAC3C,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,GACzC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC;IASrE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,6BAA6B,CAAC,IAAI,SAAS,OAAO,EAC/C,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,qBAAqB,CAAC,GAChE,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC;IAKrE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,WAAW;IA0BpE;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO;CAY5E"}
@@ -42,7 +42,8 @@ import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-protocol';
42
42
  * - {@link propertyKeys} — which property names the walk visits.
43
43
  * - {@link shouldEmitProperty} — per-key filter on top of the default
44
44
  * `$`-internals strip.
45
- * - {@link resolvePropertyValue} — value substitution per property.
45
+ * - {@link resolvePropertyValue} — value substitution per property, `'full'`
46
+ * mode only (see there for why `'grammar'` bypasses it).
46
47
  * - {@link finalizeTransferNode} — post-decoration per encoded node.
47
48
  * - {@link toTransferValue} — recursion seam per property value. Override
48
49
  * to special-case reference encoding or to drop specific value shapes.
@@ -142,7 +143,13 @@ export class DefaultTransferEncoder {
142
143
  if (!this.shouldEmitProperty(ast, key, context)) {
143
144
  continue;
144
145
  }
145
- const value = this.resolvePropertyValue(ast, key, context);
146
+ // `'grammar'` reads the authored value straight off the node rather than
147
+ // through `resolvePropertyValue`. The mode promises a shape the serializer
148
+ // round-trips, and a value-substitution hook cannot honour that: what it
149
+ // returns is by construction not what the document declared. Scoping the
150
+ // hook to `'full'` is what makes that guarantee structural instead of a
151
+ // rule every override has to remember.
152
+ const value = context.mode === 'grammar' ? ast[key] : this.resolvePropertyValue(ast, key, context);
146
153
  // `'grammar'` lists every declared property, including those absent on
147
154
  // this node; skip the absent ones. (`'full'` enumerates only own
148
155
  // properties, so absent properties never surface there.) Part of the
@@ -180,8 +187,17 @@ export class DefaultTransferEncoder {
180
187
  return !key.startsWith('$');
181
188
  }
182
189
  /**
183
- * Which value the walk emits under `key`. Default: the node's own value.
184
- * Override to substitute a derived value under a grammar property name.
190
+ * Which value the walk emits under `key`, in `'full'` mode ONLY. Default:
191
+ * the node's own value.
192
+ *
193
+ * Override to substitute a derived value under a grammar property name — an
194
+ * inheritance-resolved field, a preference-dependent label. `'grammar'`
195
+ * bypasses this hook and reads the node directly: that mode's contract is
196
+ * the authored state a serializer round-trips, and a substituted value is by
197
+ * construction not the one the document declared. An override that applied
198
+ * in both modes would leave the grammar shape carrying derived values under
199
+ * declared property names — diffable and acyclic still, but no longer
200
+ * authored, which is the property every consumer of that mode relies on.
185
201
  */
186
202
  resolvePropertyValue(ast, key, _context) {
187
203
  return ast[key];
@@ -1 +1 @@
1
- {"version":3,"file":"transfer-encoder.js","sourceRoot":"","sources":["../../../src/langium/transfer/transfer-encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,kBAAkB,EAMpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,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AC;QACF,OAAO,MAAqB,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACO,eAAe,CAAC,KAAc,EAAE,OAAsB;QAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC,QAAQ,CAAC;QACzB,CAAC;QACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,KAAK,CAAC;IAChB,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydranium/core",
3
- "version": "1.0.0-next.77",
3
+ "version": "1.0.0-next.79",
4
4
  "description": "Foundational runtime of the hydranium framework: AST coordination layer (services, integrity, AST extension, serialization, multi-client documents) plus the LSP textual head at the /lsp subpath. Consumed by protocol-head packages (@hydranium/data-server, @hydranium/glsp-server).",
5
5
  "keywords": [
6
6
  "hydranium",
@@ -104,8 +104,8 @@
104
104
  "diff": "^5.2.0"
105
105
  },
106
106
  "devDependencies": {
107
- "@hydranium/langium": "1.0.0-next.77",
108
- "@hydranium/protocol": "1.0.0-next.77",
107
+ "@hydranium/langium": "1.0.0-next.79",
108
+ "@hydranium/protocol": "1.0.0-next.79",
109
109
  "@playwright/test": "^1.40.0",
110
110
  "@types/diff": "^5.2.0",
111
111
  "rimraf": "^5.0.0",
@@ -117,8 +117,8 @@
117
117
  "vscode-languageserver-types": "^3.17.5"
118
118
  },
119
119
  "peerDependencies": {
120
- "@hydranium/langium": "1.0.0-next.77",
121
- "@hydranium/protocol": "1.0.0-next.77",
120
+ "@hydranium/langium": "1.0.0-next.79",
121
+ "@hydranium/protocol": "1.0.0-next.79",
122
122
  "@playwright/test": "^1.40.0",
123
123
  "vscode-jsonrpc": "9.0.1",
124
124
  "vscode-languageserver": "~10.0.1",
@@ -29,11 +29,13 @@ import { type TransferLspDiagnostic } from '../validation/document-validator.js'
29
29
  * including AST-extension-derived computed scalars and synthetic child
30
30
  * mirrors. This is the wire shape clients consume, and the default.
31
31
  * - `'grammar'` — only the grammar-declared properties, per
32
- * `AstReflection.getTypeMetaData($type).properties`. Excludes every
33
- * computed / synthetic property by construction (no naming convention,
34
- * no registration). Yields the authored state a serializer round-trips —
35
- * a diffable, acyclic baseline for field-level recording / forward-write
36
- * reconcile.
32
+ * `AstReflection.getTypeMetaData($type).properties`, each carrying the
33
+ * node's own authored value. Excludes every computed / synthetic property
34
+ * by construction (no naming convention, no registration) and bypasses the
35
+ * `resolvePropertyValue` substitution hook, so neither a computed KEY nor a
36
+ * computed VALUE can reach this shape. Yields the authored state a
37
+ * serializer round-trips — a diffable, acyclic baseline for field-level
38
+ * recording / forward-write reconcile.
37
39
  */
38
40
  export type TransferMode = 'full' | 'grammar';
39
41
 
@@ -144,7 +146,8 @@ export interface TransferEncoder<TDiagnostic extends TransferDiagnostic = Transf
144
146
  * - {@link propertyKeys} — which property names the walk visits.
145
147
  * - {@link shouldEmitProperty} — per-key filter on top of the default
146
148
  * `$`-internals strip.
147
- * - {@link resolvePropertyValue} — value substitution per property.
149
+ * - {@link resolvePropertyValue} — value substitution per property, `'full'`
150
+ * mode only (see there for why `'grammar'` bypasses it).
148
151
  * - {@link finalizeTransferNode} — post-decoration per encoded node.
149
152
  * - {@link toTransferValue} — recursion seam per property value. Override
150
153
  * to special-case reference encoding or to drop specific value shapes.
@@ -258,7 +261,14 @@ export class DefaultTransferEncoder<
258
261
  if (!this.shouldEmitProperty(ast, key, context)) {
259
262
  continue;
260
263
  }
261
- const value = this.resolvePropertyValue(ast, key, context);
264
+ // `'grammar'` reads the authored value straight off the node rather than
265
+ // through `resolvePropertyValue`. The mode promises a shape the serializer
266
+ // round-trips, and a value-substitution hook cannot honour that: what it
267
+ // returns is by construction not what the document declared. Scoping the
268
+ // hook to `'full'` is what makes that guarantee structural instead of a
269
+ // rule every override has to remember.
270
+ const value =
271
+ context.mode === 'grammar' ? (ast as unknown as Record<string, unknown>)[key] : this.resolvePropertyValue(ast, key, context);
262
272
  // `'grammar'` lists every declared property, including those absent on
263
273
  // this node; skip the absent ones. (`'full'` enumerates only own
264
274
  // properties, so absent properties never surface there.) Part of the
@@ -299,8 +309,17 @@ export class DefaultTransferEncoder<
299
309
  }
300
310
 
301
311
  /**
302
- * Which value the walk emits under `key`. Default: the node's own value.
303
- * Override to substitute a derived value under a grammar property name.
312
+ * Which value the walk emits under `key`, in `'full'` mode ONLY. Default:
313
+ * the node's own value.
314
+ *
315
+ * Override to substitute a derived value under a grammar property name — an
316
+ * inheritance-resolved field, a preference-dependent label. `'grammar'`
317
+ * bypasses this hook and reads the node directly: that mode's contract is
318
+ * the authored state a serializer round-trips, and a substituted value is by
319
+ * construction not the one the document declared. An override that applied
320
+ * in both modes would leave the grammar shape carrying derived values under
321
+ * declared property names — diffable and acyclic still, but no longer
322
+ * authored, which is the property every consumer of that mode relies on.
304
323
  */
305
324
  protected resolvePropertyValue(ast: AstNode, key: string, _context: EncodeContext): unknown {
306
325
  return (ast as unknown as Record<string, unknown>)[key];