@atscript/core 0.1.63 → 0.1.65

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/dist/index.cjs CHANGED
@@ -3473,16 +3473,19 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3473
3473
  * Parents are merged left-to-right, then own props overlay on top (own takes priority).
3474
3474
  * Only merges props and their annotations; interface-level annotations are NOT inherited.
3475
3475
  *
3476
- * Mutating `annotate <Parent> { @x field }` blocks contribute to the merged view, so
3477
- * inherited fields carry annotate-block metadata in the child's flat prop view. Two
3478
- * sources are consulted per parent: the parent's own document (using the parent's
3479
- * declaration name) and the child's document (using the local extends token, which may
3480
- * differ from the canonical name due to import aliasing).
3481
- */ resolveInterfaceExtends(node, _visited) {
3476
+ * Mutating `annotate <Ancestor> { @x field }` blocks contribute to the merged view, so
3477
+ * inherited fields carry annotate-block metadata in the child's flat prop view. At each
3478
+ * level of the chain we consult: (1) the immediate parent's own document and (2) the
3479
+ * `_originDoc` — the document that started the resolution (typically the leaf child).
3480
+ * Threading `_originDoc` is what lets `annotate <Grandparent> { ... }` blocks living in
3481
+ * the child's file apply to grandparent-inherited fields, even when the chain crosses
3482
+ * package boundaries (child → mid → grandparent, all in different .as files).
3483
+ */ resolveInterfaceExtends(node, _visited, _originDoc) {
3482
3484
  if (!node.hasExtends) return undefined;
3483
3485
  const visited = _visited || new Set();
3484
3486
  if (node.id && visited.has(node.id)) return undefined;
3485
3487
  if (node.id) visited.add(node.id);
3488
+ const originDoc = _originDoc ?? this;
3486
3489
  let mergedStruct;
3487
3490
  for (const extendsToken of node.extendsTokens) {
3488
3491
  const unwound = this.unwindType(extendsToken.text);
@@ -3490,17 +3493,18 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3490
3493
  let parentDef = unwound.def;
3491
3494
  const parentDeclName = unwound.node?.id ?? parentDef.id;
3492
3495
  if (isInterface(parentDef) && parentDef.hasExtends) {
3493
- const resolved = unwound.doc.resolveInterfaceExtends(parentDef, visited);
3496
+ const resolved = unwound.doc.resolveInterfaceExtends(parentDef, visited, originDoc);
3494
3497
  parentDef = resolved || parentDef.getDefinition() || parentDef;
3495
3498
  } else if (isInterface(parentDef)) parentDef = parentDef.getDefinition() || parentDef;
3496
3499
  parentDef = this.mergeIntersection(parentDef);
3497
3500
  const annotateNodes = [];
3498
- if (parentDeclName) {
3499
- for (const n of unwound.doc.getAnnotateNodesFor(parentDeclName)) if (n.isMutating) annotateNodes.push(n);
3500
- }
3501
- if (this !== unwound.doc) {
3502
- for (const n of this.getAnnotateNodesFor(extendsToken.text)) if (n.isMutating) annotateNodes.push(n);
3503
- }
3501
+ const collect = (doc, name) => {
3502
+ if (!name) return;
3503
+ for (const n of doc.getAnnotateNodesFor(name)) if (n.isMutating) annotateNodes.push(n);
3504
+ };
3505
+ collect(unwound.doc, parentDeclName);
3506
+ if (this !== unwound.doc) collect(this, extendsToken.text);
3507
+ if (originDoc !== this && originDoc !== unwound.doc) collect(originDoc, parentDeclName);
3504
3508
  if (annotateNodes.length > 0) parentDef = this.applyAnnotateBlocksToStructure(parentDef, annotateNodes);
3505
3509
  if (!mergedStruct) mergedStruct = parentDef;
3506
3510
  else {
package/dist/index.d.ts CHANGED
@@ -535,13 +535,15 @@ declare class AtscriptDoc {
535
535
  * Parents are merged left-to-right, then own props overlay on top (own takes priority).
536
536
  * Only merges props and their annotations; interface-level annotations are NOT inherited.
537
537
  *
538
- * Mutating `annotate <Parent> { @x field }` blocks contribute to the merged view, so
539
- * inherited fields carry annotate-block metadata in the child's flat prop view. Two
540
- * sources are consulted per parent: the parent's own document (using the parent's
541
- * declaration name) and the child's document (using the local extends token, which may
542
- * differ from the canonical name due to import aliasing).
538
+ * Mutating `annotate <Ancestor> { @x field }` blocks contribute to the merged view, so
539
+ * inherited fields carry annotate-block metadata in the child's flat prop view. At each
540
+ * level of the chain we consult: (1) the immediate parent's own document and (2) the
541
+ * `_originDoc` — the document that started the resolution (typically the leaf child).
542
+ * Threading `_originDoc` is what lets `annotate <Grandparent> { ... }` blocks living in
543
+ * the child's file apply to grandparent-inherited fields, even when the chain crosses
544
+ * package boundaries (child → mid → grandparent, all in different .as files).
543
545
  */
544
- resolveInterfaceExtends(node: SemanticInterfaceNode, _visited?: Set<string>): SemanticNode | undefined;
546
+ resolveInterfaceExtends(node: SemanticInterfaceNode, _visited?: Set<string>, _originDoc?: AtscriptDoc): SemanticNode | undefined;
545
547
  /**
546
548
  * Returns a structure equivalent to `struct` with annotate-block contributions
547
549
  * folded into matching props' annotation arrays. Skips chained entries
package/dist/index.mjs CHANGED
@@ -3449,16 +3449,19 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3449
3449
  * Parents are merged left-to-right, then own props overlay on top (own takes priority).
3450
3450
  * Only merges props and their annotations; interface-level annotations are NOT inherited.
3451
3451
  *
3452
- * Mutating `annotate <Parent> { @x field }` blocks contribute to the merged view, so
3453
- * inherited fields carry annotate-block metadata in the child's flat prop view. Two
3454
- * sources are consulted per parent: the parent's own document (using the parent's
3455
- * declaration name) and the child's document (using the local extends token, which may
3456
- * differ from the canonical name due to import aliasing).
3457
- */ resolveInterfaceExtends(node, _visited) {
3452
+ * Mutating `annotate <Ancestor> { @x field }` blocks contribute to the merged view, so
3453
+ * inherited fields carry annotate-block metadata in the child's flat prop view. At each
3454
+ * level of the chain we consult: (1) the immediate parent's own document and (2) the
3455
+ * `_originDoc` — the document that started the resolution (typically the leaf child).
3456
+ * Threading `_originDoc` is what lets `annotate <Grandparent> { ... }` blocks living in
3457
+ * the child's file apply to grandparent-inherited fields, even when the chain crosses
3458
+ * package boundaries (child → mid → grandparent, all in different .as files).
3459
+ */ resolveInterfaceExtends(node, _visited, _originDoc) {
3458
3460
  if (!node.hasExtends) return undefined;
3459
3461
  const visited = _visited || new Set();
3460
3462
  if (node.id && visited.has(node.id)) return undefined;
3461
3463
  if (node.id) visited.add(node.id);
3464
+ const originDoc = _originDoc ?? this;
3462
3465
  let mergedStruct;
3463
3466
  for (const extendsToken of node.extendsTokens) {
3464
3467
  const unwound = this.unwindType(extendsToken.text);
@@ -3466,17 +3469,18 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3466
3469
  let parentDef = unwound.def;
3467
3470
  const parentDeclName = unwound.node?.id ?? parentDef.id;
3468
3471
  if (isInterface(parentDef) && parentDef.hasExtends) {
3469
- const resolved = unwound.doc.resolveInterfaceExtends(parentDef, visited);
3472
+ const resolved = unwound.doc.resolveInterfaceExtends(parentDef, visited, originDoc);
3470
3473
  parentDef = resolved || parentDef.getDefinition() || parentDef;
3471
3474
  } else if (isInterface(parentDef)) parentDef = parentDef.getDefinition() || parentDef;
3472
3475
  parentDef = this.mergeIntersection(parentDef);
3473
3476
  const annotateNodes = [];
3474
- if (parentDeclName) {
3475
- for (const n of unwound.doc.getAnnotateNodesFor(parentDeclName)) if (n.isMutating) annotateNodes.push(n);
3476
- }
3477
- if (this !== unwound.doc) {
3478
- for (const n of this.getAnnotateNodesFor(extendsToken.text)) if (n.isMutating) annotateNodes.push(n);
3479
- }
3477
+ const collect = (doc, name) => {
3478
+ if (!name) return;
3479
+ for (const n of doc.getAnnotateNodesFor(name)) if (n.isMutating) annotateNodes.push(n);
3480
+ };
3481
+ collect(unwound.doc, parentDeclName);
3482
+ if (this !== unwound.doc) collect(this, extendsToken.text);
3483
+ if (originDoc !== this && originDoc !== unwound.doc) collect(originDoc, parentDeclName);
3480
3484
  if (annotateNodes.length > 0) parentDef = this.applyAnnotateBlocksToStructure(parentDef, annotateNodes);
3481
3485
  if (!mergedStruct) mergedStruct = parentDef;
3482
3486
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/core",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
4
4
  "description": "Core library for Atscript parsing and file generation.",
5
5
  "keywords": [
6
6
  "annotations",