@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 +17 -13
- package/dist/index.d.ts +8 -6
- package/dist/index.mjs +17 -13
- package/package.json +1 -1
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 <
|
|
3477
|
-
* inherited fields carry annotate-block metadata in the child's flat prop view.
|
|
3478
|
-
*
|
|
3479
|
-
*
|
|
3480
|
-
*
|
|
3481
|
-
|
|
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
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
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 <
|
|
539
|
-
* inherited fields carry annotate-block metadata in the child's flat prop view.
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
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
|
|
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 <
|
|
3453
|
-
* inherited fields carry annotate-block metadata in the child's flat prop view.
|
|
3454
|
-
*
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
|
|
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
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
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 {
|