@adaas/are-html 0.0.22 → 0.0.23
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/browser/index.d.mts +176 -8
- package/dist/browser/index.mjs +661 -235
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/{AreBinding.attribute-doUvtOjc.d.mts → AreBinding.attribute-BWzEIw6H.d.mts} +45 -0
- package/dist/node/{AreBinding.attribute-Bm5LlOyE.d.ts → AreBinding.attribute-GpT-5Qmf.d.ts} +45 -0
- package/dist/node/attributes/AreBinding.attribute.d.mts +1 -1
- package/dist/node/attributes/AreBinding.attribute.d.ts +1 -1
- package/dist/node/attributes/AreDirective.attribute.d.mts +1 -1
- package/dist/node/attributes/AreDirective.attribute.d.ts +1 -1
- package/dist/node/attributes/AreEvent.attribute.d.mts +1 -1
- package/dist/node/attributes/AreEvent.attribute.d.ts +1 -1
- package/dist/node/attributes/AreStatic.attribute.d.mts +1 -1
- package/dist/node/attributes/AreStatic.attribute.d.ts +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.mts +18 -1
- package/dist/node/directives/AreDirectiveFor.directive.d.ts +18 -1
- package/dist/node/directives/AreDirectiveFor.directive.js +57 -9
- package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.mjs +57 -9
- package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.mts +1 -1
- package/dist/node/directives/AreDirectiveIf.directive.d.ts +1 -1
- package/dist/node/directives/AreDirectiveShow.directive.d.mts +1 -1
- package/dist/node/directives/AreDirectiveShow.directive.d.ts +1 -1
- package/dist/node/engine/AreHTML.compiler.d.mts +1 -1
- package/dist/node/engine/AreHTML.compiler.d.ts +1 -1
- package/dist/node/engine/AreHTML.compiler.js +4 -0
- package/dist/node/engine/AreHTML.compiler.js.map +1 -1
- package/dist/node/engine/AreHTML.compiler.mjs +4 -0
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
- package/dist/node/engine/AreHTML.constants.d.mts +33 -1
- package/dist/node/engine/AreHTML.constants.d.ts +33 -1
- package/dist/node/engine/AreHTML.constants.js +166 -0
- package/dist/node/engine/AreHTML.constants.js.map +1 -1
- package/dist/node/engine/AreHTML.constants.mjs +165 -1
- package/dist/node/engine/AreHTML.constants.mjs.map +1 -1
- package/dist/node/engine/AreHTML.context.d.mts +66 -0
- package/dist/node/engine/AreHTML.context.d.ts +66 -0
- package/dist/node/engine/AreHTML.context.js +98 -0
- package/dist/node/engine/AreHTML.context.js.map +1 -1
- package/dist/node/engine/AreHTML.context.mjs +98 -0
- package/dist/node/engine/AreHTML.context.mjs.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
- package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
- package/dist/node/engine/AreHTML.interpreter.js +66 -10
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.mjs +66 -10
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.d.mts +1 -8
- package/dist/node/engine/AreHTML.lifecycle.d.ts +1 -8
- package/dist/node/engine/AreHTML.lifecycle.js +29 -44
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs +29 -44
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.d.mts +1 -1
- package/dist/node/engine/AreHTML.tokenizer.d.ts +1 -1
- package/dist/node/engine/AreHTML.tokenizer.js +7 -1
- package/dist/node/engine/AreHTML.tokenizer.js.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.mjs +7 -1
- package/dist/node/engine/AreHTML.tokenizer.mjs.map +1 -1
- package/dist/node/engine/AreHTML.transformer.d.mts +1 -1
- package/dist/node/engine/AreHTML.transformer.d.ts +1 -1
- package/dist/node/index.d.mts +4 -3
- package/dist/node/index.d.ts +4 -3
- package/dist/node/index.js +7 -0
- package/dist/node/index.mjs +1 -0
- package/dist/node/instructions/AddStaticHTML.instruction.d.mts +8 -0
- package/dist/node/instructions/AddStaticHTML.instruction.d.ts +8 -0
- package/dist/node/instructions/AddStaticHTML.instruction.js +31 -0
- package/dist/node/instructions/AddStaticHTML.instruction.js.map +1 -0
- package/dist/node/instructions/AddStaticHTML.instruction.mjs +24 -0
- package/dist/node/instructions/AddStaticHTML.instruction.mjs.map +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.d.mts +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.d.ts +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.js +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -1
- package/dist/node/instructions/AreHTML.instructions.constants.mjs +1 -0
- package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -1
- package/dist/node/instructions/AreHTML.instructions.types.d.mts +9 -1
- package/dist/node/instructions/AreHTML.instructions.types.d.ts +9 -1
- package/dist/node/lib/AreDirective/AreDirective.component.d.mts +1 -1
- package/dist/node/lib/AreDirective/AreDirective.component.d.ts +1 -1
- package/dist/node/lib/AreDirective/AreDirective.types.d.mts +1 -1
- package/dist/node/lib/AreDirective/AreDirective.types.d.ts +1 -1
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.mts +1 -1
- package/dist/node/lib/AreHTML/AreHTML.tokenizer.d.ts +1 -1
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.mts +1 -1
- package/dist/node/lib/AreHTMLAttribute/AreHTML.attribute.d.ts +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.mts +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.d.ts +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js +51 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.js.map +1 -1
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs +51 -0
- package/dist/node/lib/AreHTMLNode/AreHTMLNode.mjs.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
- package/dist/node/nodes/AreComment.d.mts +1 -1
- package/dist/node/nodes/AreComment.d.ts +1 -1
- package/dist/node/nodes/AreComponent.d.mts +1 -1
- package/dist/node/nodes/AreComponent.d.ts +1 -1
- package/dist/node/nodes/AreInterpolation.d.mts +1 -1
- package/dist/node/nodes/AreInterpolation.d.ts +1 -1
- package/dist/node/nodes/AreRoot.d.mts +1 -1
- package/dist/node/nodes/AreRoot.d.ts +1 -1
- package/dist/node/nodes/AreText.d.mts +1 -1
- package/dist/node/nodes/AreText.d.ts +1 -1
- package/examples/dashboard/concept.ts +1 -1
- package/examples/dashboard/dist/index.html +1 -1
- package/examples/dashboard/dist/{mqh9ryml-xat335.js → mqiw5sqa-ypckmj.js} +403 -57
- package/examples/for-perf/dist/index.html +1 -1
- package/examples/for-perf/dist/{mqh9ryfo-6a8d0o.js → mqj1mpf2-z4aokv.js} +558 -117
- package/examples/for-perf/dist/{mqh9ryfq-4pf5cv.js → mqj1mpff-4fr7mw.js} +558 -117
- package/examples/signal-routing/dist/index.html +1 -1
- package/examples/signal-routing/dist/{mqh9ryc9-dkcbkx.js → mqiwo23h-bhcolu.js} +413 -60
- package/package.json +5 -5
- package/src/directives/AreDirectiveFor.directive.ts +99 -16
- package/src/engine/AreHTML.compiler.ts +13 -0
- package/src/engine/AreHTML.constants.ts +142 -0
- package/src/engine/AreHTML.context.ts +112 -0
- package/src/engine/AreHTML.interpreter.ts +114 -13
- package/src/engine/AreHTML.lifecycle.ts +81 -74
- package/src/engine/AreHTML.tokenizer.ts +30 -1
- package/src/index.ts +1 -0
- package/src/instructions/AddStaticHTML.instruction.ts +23 -0
- package/src/instructions/AreHTML.instructions.constants.ts +1 -0
- package/src/instructions/AreHTML.instructions.types.ts +9 -0
- package/src/lib/AreHTMLNode/AreHTMLNode.ts +74 -0
- package/src/lib/AreRoot/AreRoot.component.ts +3 -3
- package/tests/StaticIsland.test.ts +115 -0
- package/examples/for-perf/dist/mqh9ryde-m243t8.js +0 -15223
|
@@ -6,6 +6,7 @@ declare const AreHTMLInstructions: {
|
|
|
6
6
|
readonly AddListener: "_AreHTML_AddListener";
|
|
7
7
|
readonly AddInterpolation: "_AreHTML_AddInterpolation";
|
|
8
8
|
readonly AddComment: "_AreHTML_AddComment";
|
|
9
|
+
readonly AddStaticHTML: "_AreHTML_AddStaticHTML";
|
|
9
10
|
readonly HideElement: "_AreHTML_HideElement";
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/instructions/AreHTML.instructions.constants.ts"],"names":[],"mappings":";;AAEO,MAAM,mBAAA,GAAsB;AAAA,EAC/B,UAAA,EAAY,qBAAA;AAAA,EACZ,OAAA,EAAS,kBAAA;AAAA,EACT,YAAA,EAAc,uBAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,WAAA,EAAa,sBAAA;AAAA,EACb,gBAAA,EAAkB,2BAAA;AAAA,EAClB,UAAA,EAAY,qBAAA;AAAA,EACZ,WAAA,EAAa;AACjB","file":"AreHTML.instructions.constants.js","sourcesContent":["\n\nexport const AreHTMLInstructions = {\n AddElement: '_AreHTML_AddElement',\n AddText: '_AreHTML_AddText',\n AddAttribute: '_AreHTML_AddAttribute',\n AddStyle: '_AreHTML_AddStyle',\n AddListener: '_AreHTML_AddListener',\n AddInterpolation: '_AreHTML_AddInterpolation',\n AddComment: '_AreHTML_AddComment',\n HideElement: '_AreHTML_HideElement',\n} as const"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/instructions/AreHTML.instructions.constants.ts"],"names":[],"mappings":";;AAEO,MAAM,mBAAA,GAAsB;AAAA,EAC/B,UAAA,EAAY,qBAAA;AAAA,EACZ,OAAA,EAAS,kBAAA;AAAA,EACT,YAAA,EAAc,uBAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,WAAA,EAAa,sBAAA;AAAA,EACb,gBAAA,EAAkB,2BAAA;AAAA,EAClB,UAAA,EAAY,qBAAA;AAAA,EACZ,aAAA,EAAe,wBAAA;AAAA,EACf,WAAA,EAAa;AACjB","file":"AreHTML.instructions.constants.js","sourcesContent":["\n\nexport const AreHTMLInstructions = {\n AddElement: '_AreHTML_AddElement',\n AddText: '_AreHTML_AddText',\n AddAttribute: '_AreHTML_AddAttribute',\n AddStyle: '_AreHTML_AddStyle',\n AddListener: '_AreHTML_AddListener',\n AddInterpolation: '_AreHTML_AddInterpolation',\n AddComment: '_AreHTML_AddComment',\n AddStaticHTML: '_AreHTML_AddStaticHTML',\n HideElement: '_AreHTML_HideElement',\n} as const"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/instructions/AreHTML.instructions.constants.ts"],"names":[],"mappings":";;AAEO,MAAM,mBAAA,GAAsB;AAAA,EAC/B,UAAA,EAAY,qBAAA;AAAA,EACZ,OAAA,EAAS,kBAAA;AAAA,EACT,YAAA,EAAc,uBAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,WAAA,EAAa,sBAAA;AAAA,EACb,gBAAA,EAAkB,2BAAA;AAAA,EAClB,UAAA,EAAY,qBAAA;AAAA,EACZ,WAAA,EAAa;AACjB","file":"AreHTML.instructions.constants.mjs","sourcesContent":["\n\nexport const AreHTMLInstructions = {\n AddElement: '_AreHTML_AddElement',\n AddText: '_AreHTML_AddText',\n AddAttribute: '_AreHTML_AddAttribute',\n AddStyle: '_AreHTML_AddStyle',\n AddListener: '_AreHTML_AddListener',\n AddInterpolation: '_AreHTML_AddInterpolation',\n AddComment: '_AreHTML_AddComment',\n HideElement: '_AreHTML_HideElement',\n} as const"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/instructions/AreHTML.instructions.constants.ts"],"names":[],"mappings":";;AAEO,MAAM,mBAAA,GAAsB;AAAA,EAC/B,UAAA,EAAY,qBAAA;AAAA,EACZ,OAAA,EAAS,kBAAA;AAAA,EACT,YAAA,EAAc,uBAAA;AAAA,EACd,QAAA,EAAU,mBAAA;AAAA,EACV,WAAA,EAAa,sBAAA;AAAA,EACb,gBAAA,EAAkB,2BAAA;AAAA,EAClB,UAAA,EAAY,qBAAA;AAAA,EACZ,aAAA,EAAe,wBAAA;AAAA,EACf,WAAA,EAAa;AACjB","file":"AreHTML.instructions.constants.mjs","sourcesContent":["\n\nexport const AreHTMLInstructions = {\n AddElement: '_AreHTML_AddElement',\n AddText: '_AreHTML_AddText',\n AddAttribute: '_AreHTML_AddAttribute',\n AddStyle: '_AreHTML_AddStyle',\n AddListener: '_AreHTML_AddListener',\n AddInterpolation: '_AreHTML_AddInterpolation',\n AddComment: '_AreHTML_AddComment',\n AddStaticHTML: '_AreHTML_AddStaticHTML',\n HideElement: '_AreHTML_HideElement',\n} as const"]}
|
|
@@ -28,6 +28,14 @@ type AreHtmlAddStyleInstructionPayload = {
|
|
|
28
28
|
/** Full CSS string to inject as a <style> block scoped to the component. Applied to the document head and reverted on unmount. */
|
|
29
29
|
styles: string;
|
|
30
30
|
};
|
|
31
|
+
type AreHtmlAddStaticHTMLInstructionPayload = {
|
|
32
|
+
/**
|
|
33
|
+
* Verbatim inner markup of a static island, materialised on the parent
|
|
34
|
+
* element in a single pass (browser-parsed `innerHTML` / cached `<template>`
|
|
35
|
+
* clone). Decodes HTML entities (e.g. ` `) for free via the parser.
|
|
36
|
+
*/
|
|
37
|
+
html: string;
|
|
38
|
+
};
|
|
31
39
|
type AreHtmlHideInstructionPayload = {
|
|
32
40
|
/**
|
|
33
41
|
* Optional explicit display value to restore when the element becomes
|
|
@@ -49,4 +57,4 @@ type AreHtmlAddInterpolationInstructionPayload = {
|
|
|
49
57
|
content: (...args: any[]) => string;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
|
-
export type { AreHtmlAddAttributeInstructionPayload, AreHtmlAddCommentInstructionPayload, AreHtmlAddElementInstructionPayload, AreHtmlAddInterpolationInstructionPayload, AreHtmlAddListenerInstructionPayload, AreHtmlAddStyleInstructionPayload, AreHtmlAddTextInstructionPayload, AreHtmlHideInstructionPayload };
|
|
60
|
+
export type { AreHtmlAddAttributeInstructionPayload, AreHtmlAddCommentInstructionPayload, AreHtmlAddElementInstructionPayload, AreHtmlAddInterpolationInstructionPayload, AreHtmlAddListenerInstructionPayload, AreHtmlAddStaticHTMLInstructionPayload, AreHtmlAddStyleInstructionPayload, AreHtmlAddTextInstructionPayload, AreHtmlHideInstructionPayload };
|
|
@@ -28,6 +28,14 @@ type AreHtmlAddStyleInstructionPayload = {
|
|
|
28
28
|
/** Full CSS string to inject as a <style> block scoped to the component. Applied to the document head and reverted on unmount. */
|
|
29
29
|
styles: string;
|
|
30
30
|
};
|
|
31
|
+
type AreHtmlAddStaticHTMLInstructionPayload = {
|
|
32
|
+
/**
|
|
33
|
+
* Verbatim inner markup of a static island, materialised on the parent
|
|
34
|
+
* element in a single pass (browser-parsed `innerHTML` / cached `<template>`
|
|
35
|
+
* clone). Decodes HTML entities (e.g. ` `) for free via the parser.
|
|
36
|
+
*/
|
|
37
|
+
html: string;
|
|
38
|
+
};
|
|
31
39
|
type AreHtmlHideInstructionPayload = {
|
|
32
40
|
/**
|
|
33
41
|
* Optional explicit display value to restore when the element becomes
|
|
@@ -49,4 +57,4 @@ type AreHtmlAddInterpolationInstructionPayload = {
|
|
|
49
57
|
content: (...args: any[]) => string;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
|
-
export type { AreHtmlAddAttributeInstructionPayload, AreHtmlAddCommentInstructionPayload, AreHtmlAddElementInstructionPayload, AreHtmlAddInterpolationInstructionPayload, AreHtmlAddListenerInstructionPayload, AreHtmlAddStyleInstructionPayload, AreHtmlAddTextInstructionPayload, AreHtmlHideInstructionPayload };
|
|
60
|
+
export type { AreHtmlAddAttributeInstructionPayload, AreHtmlAddCommentInstructionPayload, AreHtmlAddElementInstructionPayload, AreHtmlAddInterpolationInstructionPayload, AreHtmlAddListenerInstructionPayload, AreHtmlAddStaticHTMLInstructionPayload, AreHtmlAddStyleInstructionPayload, AreHtmlAddTextInstructionPayload, AreHtmlHideInstructionPayload };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A_TYPES__Ctor } from '@adaas/a-concept';
|
|
2
|
-
import { a as AreDirective } from '../../AreBinding.attribute-
|
|
2
|
+
import { a as AreDirective } from '../../AreBinding.attribute-BWzEIw6H.mjs';
|
|
3
3
|
import '@adaas/are';
|
|
4
4
|
import '../AreStyle/AreStyle.context.mjs';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A_TYPES__Ctor } from '@adaas/a-concept';
|
|
2
|
-
import { a as AreDirective } from '../../AreBinding.attribute-
|
|
2
|
+
import { a as AreDirective } from '../../AreBinding.attribute-GpT-5Qmf.js';
|
|
3
3
|
import '@adaas/are';
|
|
4
4
|
import '../AreStyle/AreStyle.context.js';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AreTokenizer, AreNode, AreContext } from '@adaas/are';
|
|
2
2
|
import { A_Logger } from '@adaas/a-utils/a-logger';
|
|
3
|
-
import { d as AreHTMLAttribute } from '../../AreBinding.attribute-
|
|
3
|
+
import { d as AreHTMLAttribute } from '../../AreBinding.attribute-BWzEIw6H.mjs';
|
|
4
4
|
import '@adaas/a-concept';
|
|
5
5
|
import '../AreStyle/AreStyle.context.mjs';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AreTokenizer, AreNode, AreContext } from '@adaas/are';
|
|
2
2
|
import { A_Logger } from '@adaas/a-utils/a-logger';
|
|
3
|
-
import { d as AreHTMLAttribute } from '../../AreBinding.attribute-
|
|
3
|
+
import { d as AreHTMLAttribute } from '../../AreBinding.attribute-GpT-5Qmf.js';
|
|
4
4
|
import '@adaas/a-concept';
|
|
5
5
|
import '../AreStyle/AreStyle.context.js';
|
|
6
6
|
|
|
@@ -25,6 +25,57 @@ exports.AreHTMLNode = class AreHTMLNode extends are.AreNode {
|
|
|
25
25
|
get tag() {
|
|
26
26
|
return this.aseid.entity;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The verbatim inner markup captured when this node was identified as a
|
|
30
|
+
* static island, or `undefined` for ordinary (per-node) nodes.
|
|
31
|
+
*/
|
|
32
|
+
get staticInnerHTML() {
|
|
33
|
+
return this._staticInnerHTML;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Whether this node is a static-island root (see `_staticInnerHTML`).
|
|
37
|
+
*/
|
|
38
|
+
get isStaticIsland() {
|
|
39
|
+
return this._staticInnerHTML !== void 0;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Marks this node as a static-island root, capturing the verbatim inner
|
|
43
|
+
* markup to be materialised in one shot by the interpreter. Called by the
|
|
44
|
+
* tokenizer when the node's inner content is detected to be fully static.
|
|
45
|
+
*/
|
|
46
|
+
markStatic(innerHTML) {
|
|
47
|
+
this._staticInnerHTML = innerHTML;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Deep-clone the node. Overridden to carry over the static-island marker
|
|
51
|
+
* (`_staticInnerHTML`), which lives on AreHTMLNode and is therefore NOT
|
|
52
|
+
* copied by the base AreNode.clone(). Without this, cloning a directive
|
|
53
|
+
* template ($if/$for) that wraps a static island (e.g. `<span $if>★</span>`)
|
|
54
|
+
* would drop the captured inner markup and render an empty element. The
|
|
55
|
+
* base clone() recurses via each child's polymorphic clone(), so nested
|
|
56
|
+
* island children are preserved automatically through this override.
|
|
57
|
+
*/
|
|
58
|
+
clone() {
|
|
59
|
+
const cloned = super.clone();
|
|
60
|
+
const self = this;
|
|
61
|
+
if (self._staticInnerHTML !== void 0)
|
|
62
|
+
cloned.markStatic(self._staticInnerHTML);
|
|
63
|
+
return cloned;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Clone the node while transferring its existing scope to the clone (used by
|
|
67
|
+
* the $if/$for directives to turn the original node into a lightweight group
|
|
68
|
+
* container). Overridden for the same reason as `clone()`: the static-island
|
|
69
|
+
* marker must survive so a directive applied to an island root keeps its
|
|
70
|
+
* inner markup.
|
|
71
|
+
*/
|
|
72
|
+
cloneWithScope() {
|
|
73
|
+
const cloned = super.cloneWithScope();
|
|
74
|
+
const self = this;
|
|
75
|
+
if (self._staticInnerHTML !== void 0)
|
|
76
|
+
cloned.markStatic(self._staticInnerHTML);
|
|
77
|
+
return cloned;
|
|
78
|
+
}
|
|
28
79
|
/**
|
|
29
80
|
* The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.
|
|
30
81
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts"],"names":["AreHTMLNode","AreNode","AreStaticAttribute","AreBindingAttribute","AreDirectiveAttribute","A_Context","AreEventAttribute","AreStyle","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBaA,mBAAA,GAAN,0BAA0BC,WAAA,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,IAAI,GAAA,GAAc;AACd,IAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAA,GAAyC;AACzC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAmCC,sCAAkB,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAAA,GAAkC;AAClC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAoCC,wCAAmB,CAAA;AAAA,EAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAA,GAAsC;AAItC,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,KAAA,C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,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYR,mBAAA,CAAA","file":"AreHTMLNode.js","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'AreHTMLNode represents a node in the HTML structure. It extends the base AreNode and includes properties and methods specific to HTML nodes, such as handling attributes, directives, events, and styles.'\n})\nexport class AreHTMLNode extends AreNode {\n /**\n * Actual node type. \n * By default it's a tag name\n */\n get tag(): string {\n return this.aseid.entity;\n }\n /**\n * The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.\n * \n * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n */\n get staticAttributes(): AreStaticAttribute[] {\n return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n }\n /**\n * The binding attributes defined for the node, which are typically used to represent dynamic properties or characteristics of the node that can change based on the context or state. These attributes are usually defined in the template with a specific syntax (e.g., `:prop=\"value\"` or `v-bind:prop=\"value\"`) and are reactive, meaning that they will update automatically when the underlying data changes.\n * \n * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n */\n get bindings(): AreBindingAttribute[] {\n return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n }\n /**\n * The directive attributes defined for the node, which are typically used to represent special instructions or behaviors that should be applied to the node. These attributes are usually defined in the template with a specific syntax (e.g., `v-if=\"condition\"` or `v-for=\"item in list\"`) and are processed by the rendering engine to apply the corresponding logic or behavior to the node.\n * \n * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n */\n get directives(): AreDirectiveAttribute[] {\n /**\n * 1. get all registered directives for the node\n */\n const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n /**\n * 2. Order them in the way that defined in the meta\n * \n * Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n */\n\n return directives.filter(d => d.component).sort((a, b) => {\n const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n const aPriority = aMeta.priority ?? 0;\n const bPriority = bMeta.priority ?? 0;\n\n return bPriority - aPriority;\n });\n }\n /**\n * The event attributes defined for the node, which are typically used to represent event listeners or handlers that should be attached to the node. These attributes are usually defined in the template with a specific syntax (e.g., `@click=\"handleClick\"` or `v-on:click=\"handleClick\"`) and are processed by the rendering engine to attach the corresponding event listeners to the node.\n * \n * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n */\n get events(): AreEventAttribute[] {\n return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n }\n /**\n * The styles defined for the node, which can include inline styles or styles defined in a separate stylesheet that are applied to the node. These styles can be used to control the visual appearance of the node and can be defined using standard CSS syntax.\n */\n get styles(): AreStyle {\n return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n }\n\n /**\n * Registers or updates the component-scoped CSS string for this node.\n * Called by the @Are.Styles-decorated method on the associated component.\n * A new AreStyle fragment is registered in scope on first call; subsequent\n * calls update the existing fragment in-place.\n */\n setStyles(css: string): void {\n const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n if (existing) {\n existing.styles = css;\n } else {\n this.scope.register(new AreStyle(css, this.aseid.toString()));\n }\n }\n\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts"],"names":["AreHTMLNode","AreNode","AreStaticAttribute","AreBindingAttribute","AreDirectiveAttribute","A_Context","AreEventAttribute","AreStyle","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBaA,mBAAA,GAAN,0BAA0BC,WAAA,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBrC,IAAI,GAAA,GAAc;AACd,IAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,eAAA,GAAsC;AACtC,IAAA,OAAO,IAAA,CAAK,gBAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,cAAA,GAA0B;AAC1B,IAAA,OAAO,KAAK,gBAAA,KAAqB,MAAA;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAW,SAAA,EAAyB;AAChC,IAAA,IAAA,CAAK,gBAAA,GAAmB,SAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,KAAA,GAA+C;AAC3C,IAAA,MAAM,MAAA,GAAS,MAAM,KAAA,EAAM;AAC3B,IAAA,MAAM,IAAA,GAAO,IAAA;AAEb,IAAA,IAAI,KAAK,gBAAA,KAAqB,MAAA;AAC1B,MAAA,MAAA,CAAO,UAAA,CAAW,KAAK,gBAAgB,CAAA;AAE3C,IAAA,OAAO,MAAA;AAAA,EACX;AAAA;AAAA;AAAA;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A,GAA8B;AAC9B,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAkCC,oCAAiB,CAAA;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,MAAA,GAAmB;AACnB,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsBC,yBAAQ,CAAA;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UAAU,GAAA,EAAmB;AACzB,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsBA,yBAAQ,CAAA;AAC1D,IAAA,IAAI,QAAA,EAAU;AACV,MAAA,QAAA,CAAS,MAAA,GAAS,GAAA;AAAA,IACtB,CAAA,MAAO;AACH,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,IAAIA,yBAAA,CAAS,KAAK,IAAA,CAAK,KAAA,CAAM,QAAA,EAAU,CAAC,CAAA;AAAA,IAChE;AAAA,EACJ;AAEJ;AA1JaP,mBAAA,GAAN,eAAA,CAAA;AAAA,EAJNQ,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYR,mBAAA,CAAA","file":"AreHTMLNode.js","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'AreHTMLNode represents a node in the HTML structure. It extends the base AreNode and includes properties and methods specific to HTML nodes, such as handling attributes, directives, events, and styles.'\n})\nexport class AreHTMLNode extends AreNode {\n /**\n * When set, this node is a *static island* root: its entire inner subtree\n * was detected (at tokenize time) to contain no ARE-reactive constructs —\n * no interpolations, no dynamic attributes and only standard HTML tags.\n *\n * Instead of being exploded into one child AreNode per element/text node,\n * the inner markup is preserved verbatim here and materialised in a single\n * pass by the interpreter (browser-parsed `innerHTML` / cached `<template>`\n * clone). The node's OWN attributes (including any dynamic `:`/`@`/`$` on\n * the island root) still compile and stay reactive as usual.\n */\n protected _staticInnerHTML?: string;\n\n /**\n * Actual node type. \n * By default it's a tag name\n */\n get tag(): string {\n return this.aseid.entity;\n }\n\n /**\n * The verbatim inner markup captured when this node was identified as a\n * static island, or `undefined` for ordinary (per-node) nodes.\n */\n get staticInnerHTML(): string | undefined {\n return this._staticInnerHTML;\n }\n\n /**\n * Whether this node is a static-island root (see `_staticInnerHTML`).\n */\n get isStaticIsland(): boolean {\n return this._staticInnerHTML !== undefined;\n }\n\n /**\n * Marks this node as a static-island root, capturing the verbatim inner\n * markup to be materialised in one shot by the interpreter. Called by the\n * tokenizer when the node's inner content is detected to be fully static.\n */\n markStatic(innerHTML: string): void {\n this._staticInnerHTML = innerHTML;\n }\n\n /**\n * Deep-clone the node. Overridden to carry over the static-island marker\n * (`_staticInnerHTML`), which lives on AreHTMLNode and is therefore NOT\n * copied by the base AreNode.clone(). Without this, cloning a directive\n * template ($if/$for) that wraps a static island (e.g. `<span $if>★</span>`)\n * would drop the captured inner markup and render an empty element. The\n * base clone() recurses via each child's polymorphic clone(), so nested\n * island children are preserved automatically through this override.\n */\n clone<T extends AreNode = AreNode>(this: T): T {\n const cloned = super.clone() as unknown as AreHTMLNode;\n const self = this as unknown as AreHTMLNode;\n\n if (self._staticInnerHTML !== undefined)\n cloned.markStatic(self._staticInnerHTML);\n\n return cloned as unknown as T;\n }\n\n /**\n * Clone the node while transferring its existing scope to the clone (used by\n * the $if/$for directives to turn the original node into a lightweight group\n * container). Overridden for the same reason as `clone()`: the static-island\n * marker must survive so a directive applied to an island root keeps its\n * inner markup.\n */\n cloneWithScope<T extends AreNode = AreNode>(this: T): T {\n const cloned = super.cloneWithScope() as unknown as AreHTMLNode;\n const self = this as unknown as AreHTMLNode;\n\n if (self._staticInnerHTML !== undefined)\n cloned.markStatic(self._staticInnerHTML);\n\n return cloned as unknown as T;\n }\n\n /**\n * The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.\n * \n * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n */\n get staticAttributes(): AreStaticAttribute[] {\n return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n }\n /**\n * The binding attributes defined for the node, which are typically used to represent dynamic properties or characteristics of the node that can change based on the context or state. These attributes are usually defined in the template with a specific syntax (e.g., `:prop=\"value\"` or `v-bind:prop=\"value\"`) and are reactive, meaning that they will update automatically when the underlying data changes.\n * \n * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n */\n get bindings(): AreBindingAttribute[] {\n return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n }\n /**\n * The directive attributes defined for the node, which are typically used to represent special instructions or behaviors that should be applied to the node. These attributes are usually defined in the template with a specific syntax (e.g., `v-if=\"condition\"` or `v-for=\"item in list\"`) and are processed by the rendering engine to apply the corresponding logic or behavior to the node.\n * \n * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n */\n get directives(): AreDirectiveAttribute[] {\n /**\n * 1. get all registered directives for the node\n */\n const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n /**\n * 2. Order them in the way that defined in the meta\n * \n * Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n */\n\n return directives.filter(d => d.component).sort((a, b) => {\n const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n const aPriority = aMeta.priority ?? 0;\n const bPriority = bMeta.priority ?? 0;\n\n return bPriority - aPriority;\n });\n }\n /**\n * The event attributes defined for the node, which are typically used to represent event listeners or handlers that should be attached to the node. These attributes are usually defined in the template with a specific syntax (e.g., `@click=\"handleClick\"` or `v-on:click=\"handleClick\"`) and are processed by the rendering engine to attach the corresponding event listeners to the node.\n * \n * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n */\n get events(): AreEventAttribute[] {\n return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n }\n /**\n * The styles defined for the node, which can include inline styles or styles defined in a separate stylesheet that are applied to the node. These styles can be used to control the visual appearance of the node and can be defined using standard CSS syntax.\n */\n get styles(): AreStyle {\n return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n }\n\n /**\n * Registers or updates the component-scoped CSS string for this node.\n * Called by the @Are.Styles-decorated method on the associated component.\n * A new AreStyle fragment is registered in scope on first call; subsequent\n * calls update the existing fragment in-place.\n */\n setStyles(css: string): void {\n const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n if (existing) {\n existing.styles = css;\n } else {\n this.scope.register(new AreStyle(css, this.aseid.toString()));\n }\n }\n\n}"]}
|
|
@@ -16,6 +16,57 @@ let AreHTMLNode = class extends AreNode {
|
|
|
16
16
|
get tag() {
|
|
17
17
|
return this.aseid.entity;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The verbatim inner markup captured when this node was identified as a
|
|
21
|
+
* static island, or `undefined` for ordinary (per-node) nodes.
|
|
22
|
+
*/
|
|
23
|
+
get staticInnerHTML() {
|
|
24
|
+
return this._staticInnerHTML;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether this node is a static-island root (see `_staticInnerHTML`).
|
|
28
|
+
*/
|
|
29
|
+
get isStaticIsland() {
|
|
30
|
+
return this._staticInnerHTML !== void 0;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Marks this node as a static-island root, capturing the verbatim inner
|
|
34
|
+
* markup to be materialised in one shot by the interpreter. Called by the
|
|
35
|
+
* tokenizer when the node's inner content is detected to be fully static.
|
|
36
|
+
*/
|
|
37
|
+
markStatic(innerHTML) {
|
|
38
|
+
this._staticInnerHTML = innerHTML;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Deep-clone the node. Overridden to carry over the static-island marker
|
|
42
|
+
* (`_staticInnerHTML`), which lives on AreHTMLNode and is therefore NOT
|
|
43
|
+
* copied by the base AreNode.clone(). Without this, cloning a directive
|
|
44
|
+
* template ($if/$for) that wraps a static island (e.g. `<span $if>★</span>`)
|
|
45
|
+
* would drop the captured inner markup and render an empty element. The
|
|
46
|
+
* base clone() recurses via each child's polymorphic clone(), so nested
|
|
47
|
+
* island children are preserved automatically through this override.
|
|
48
|
+
*/
|
|
49
|
+
clone() {
|
|
50
|
+
const cloned = super.clone();
|
|
51
|
+
const self = this;
|
|
52
|
+
if (self._staticInnerHTML !== void 0)
|
|
53
|
+
cloned.markStatic(self._staticInnerHTML);
|
|
54
|
+
return cloned;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Clone the node while transferring its existing scope to the clone (used by
|
|
58
|
+
* the $if/$for directives to turn the original node into a lightweight group
|
|
59
|
+
* container). Overridden for the same reason as `clone()`: the static-island
|
|
60
|
+
* marker must survive so a directive applied to an island root keeps its
|
|
61
|
+
* inner markup.
|
|
62
|
+
*/
|
|
63
|
+
cloneWithScope() {
|
|
64
|
+
const cloned = super.cloneWithScope();
|
|
65
|
+
const self = this;
|
|
66
|
+
if (self._staticInnerHTML !== void 0)
|
|
67
|
+
cloned.markStatic(self._staticInnerHTML);
|
|
68
|
+
return cloned;
|
|
69
|
+
}
|
|
19
70
|
/**
|
|
20
71
|
* The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.
|
|
21
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts"],"names":[],"mappings":";;;;;;;;;;AAiBO,IAAM,WAAA,GAAN,cAA0B,OAAA,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrC,IAAI,GAAA,GAAc;AACd,IAAA,OAAO,KAAK,KAAA,CAAM,MAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAA,GAAyC;AACzC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAmC,kBAAkB,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAAA,GAAkC;AAClC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAoC,mBAAmB,CAAA;AAAA,EAC7E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,UAAA,GAAsC;AAItC,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,KAAA,CAAM,cAAA,CAAsC,qBAAqB,CAAA;AAOzF,IAAA,OAAO,UAAA,CAAW,OAAO,CAAA,CAAA,KAAK,CAAA,CAAE,SAAS,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM;AACtD,MAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,IAAA,CAAqC,CAAA,CAAE,SAAU,CAAA;AACzE,MAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,IAAA,CAAqC,CAAA,CAAE,SAAU,CAAA;AAEzE,MAAA,MAAM,SAAA,GAAY,MAAM,QAAA,IAAY,CAAA;AACpC,MAAA,MAAM,SAAA,GAAY,MAAM,QAAA,IAAY,CAAA;AAEpC,MAAA,OAAO,SAAA,GAAY,SAAA;AAAA,IACvB,CAAC,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,MAAA,GAA8B;AAC9B,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,cAAA,CAAkC,iBAAiB,CAAA;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,MAAA,GAAmB;AACnB,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsB,QAAQ,CAAA;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UAAU,GAAA,EAAmB;AACzB,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,WAAA,CAAsB,QAAQ,CAAA;AAC1D,IAAA,IAAI,QAAA,EAAU;AACV,MAAA,QAAA,CAAS,MAAA,GAAS,GAAA;AAAA,IACtB,CAAA,MAAO;AACH,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,IAAI,QAAA,CAAS,KAAK,IAAA,CAAK,KAAA,CAAM,QAAA,EAAU,CAAC,CAAA;AAAA,IAChE;AAAA,EACJ;AAEJ;AAhFa,WAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,WAAA,CAAA","file":"AreHTMLNode.mjs","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'AreHTMLNode represents a node in the HTML structure. It extends the base AreNode and includes properties and methods specific to HTML nodes, such as handling attributes, directives, events, and styles.'\n})\nexport class AreHTMLNode extends AreNode {\n /**\n * Actual node type. \n * By default it's a tag name\n */\n get tag(): string {\n return this.aseid.entity;\n }\n /**\n * The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.\n * \n * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n */\n get staticAttributes(): AreStaticAttribute[] {\n return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n }\n /**\n * The binding attributes defined for the node, which are typically used to represent dynamic properties or characteristics of the node that can change based on the context or state. These attributes are usually defined in the template with a specific syntax (e.g., `:prop=\"value\"` or `v-bind:prop=\"value\"`) and are reactive, meaning that they will update automatically when the underlying data changes.\n * \n * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n */\n get bindings(): AreBindingAttribute[] {\n return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n }\n /**\n * The directive attributes defined for the node, which are typically used to represent special instructions or behaviors that should be applied to the node. These attributes are usually defined in the template with a specific syntax (e.g., `v-if=\"condition\"` or `v-for=\"item in list\"`) and are processed by the rendering engine to apply the corresponding logic or behavior to the node.\n * \n * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n */\n get directives(): AreDirectiveAttribute[] {\n /**\n * 1. get all registered directives for the node\n */\n const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n /**\n * 2. Order them in the way that defined in the meta\n * \n * Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n */\n\n return directives.filter(d => d.component).sort((a, b) => {\n const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n const aPriority = aMeta.priority ?? 0;\n const bPriority = bMeta.priority ?? 0;\n\n return bPriority - aPriority;\n });\n }\n /**\n * The event attributes defined for the node, which are typically used to represent event listeners or handlers that should be attached to the node. These attributes are usually defined in the template with a specific syntax (e.g., `@click=\"handleClick\"` or `v-on:click=\"handleClick\"`) and are processed by the rendering engine to attach the corresponding event listeners to the node.\n * \n * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n */\n get events(): AreEventAttribute[] {\n return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n }\n /**\n * The styles defined for the node, which can include inline styles or styles defined in a separate stylesheet that are applied to the node. These styles can be used to control the visual appearance of the node and can be defined using standard CSS syntax.\n */\n get styles(): AreStyle {\n return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n }\n\n /**\n * Registers or updates the component-scoped CSS string for this node.\n * Called by the @Are.Styles-decorated method on the associated component.\n * A new AreStyle fragment is registered in scope on first call; subsequent\n * calls update the existing fragment in-place.\n */\n setStyles(css: string): void {\n const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n if (existing) {\n existing.styles = css;\n } else {\n this.scope.register(new AreStyle(css, this.aseid.toString()));\n }\n }\n\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreHTMLNode/AreHTMLNode.ts"],"names":[],"mappings":";;;;;;;;;;AAiBO,IAAM,WAAA,G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ACtB,CAAA,MAAO;AACH,MAAA,IAAA,CAAK,KAAA,CAAM,SAAS,IAAI,QAAA,CAAS,KAAK,IAAA,CAAK,KAAA,CAAM,QAAA,EAAU,CAAC,CAAA;AAAA,IAChE;AAAA,EACJ;AAEJ;AA1Ja,WAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,WAAA,CAAA","file":"AreHTMLNode.mjs","sourcesContent":["import { A_Context, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreNode} from \"@adaas/are\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreStyle } from \"@adaas/are-html/style/AreStyle.context\";\nimport { AreDirective } from \"@adaas/are-html/directive/AreDirective.component\";\nimport { AreDirectiveMeta } from \"@adaas/are-html/directive/AreDirective.meta\";\n\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'AreHTMLNode represents a node in the HTML structure. It extends the base AreNode and includes properties and methods specific to HTML nodes, such as handling attributes, directives, events, and styles.'\n})\nexport class AreHTMLNode extends AreNode {\n /**\n * When set, this node is a *static island* root: its entire inner subtree\n * was detected (at tokenize time) to contain no ARE-reactive constructs —\n * no interpolations, no dynamic attributes and only standard HTML tags.\n *\n * Instead of being exploded into one child AreNode per element/text node,\n * the inner markup is preserved verbatim here and materialised in a single\n * pass by the interpreter (browser-parsed `innerHTML` / cached `<template>`\n * clone). The node's OWN attributes (including any dynamic `:`/`@`/`$` on\n * the island root) still compile and stay reactive as usual.\n */\n protected _staticInnerHTML?: string;\n\n /**\n * Actual node type. \n * By default it's a tag name\n */\n get tag(): string {\n return this.aseid.entity;\n }\n\n /**\n * The verbatim inner markup captured when this node was identified as a\n * static island, or `undefined` for ordinary (per-node) nodes.\n */\n get staticInnerHTML(): string | undefined {\n return this._staticInnerHTML;\n }\n\n /**\n * Whether this node is a static-island root (see `_staticInnerHTML`).\n */\n get isStaticIsland(): boolean {\n return this._staticInnerHTML !== undefined;\n }\n\n /**\n * Marks this node as a static-island root, capturing the verbatim inner\n * markup to be materialised in one shot by the interpreter. Called by the\n * tokenizer when the node's inner content is detected to be fully static.\n */\n markStatic(innerHTML: string): void {\n this._staticInnerHTML = innerHTML;\n }\n\n /**\n * Deep-clone the node. Overridden to carry over the static-island marker\n * (`_staticInnerHTML`), which lives on AreHTMLNode and is therefore NOT\n * copied by the base AreNode.clone(). Without this, cloning a directive\n * template ($if/$for) that wraps a static island (e.g. `<span $if>★</span>`)\n * would drop the captured inner markup and render an empty element. The\n * base clone() recurses via each child's polymorphic clone(), so nested\n * island children are preserved automatically through this override.\n */\n clone<T extends AreNode = AreNode>(this: T): T {\n const cloned = super.clone() as unknown as AreHTMLNode;\n const self = this as unknown as AreHTMLNode;\n\n if (self._staticInnerHTML !== undefined)\n cloned.markStatic(self._staticInnerHTML);\n\n return cloned as unknown as T;\n }\n\n /**\n * Clone the node while transferring its existing scope to the clone (used by\n * the $if/$for directives to turn the original node into a lightweight group\n * container). Overridden for the same reason as `clone()`: the static-island\n * marker must survive so a directive applied to an island root keeps its\n * inner markup.\n */\n cloneWithScope<T extends AreNode = AreNode>(this: T): T {\n const cloned = super.cloneWithScope() as unknown as AreHTMLNode;\n const self = this as unknown as AreHTMLNode;\n\n if (self._staticInnerHTML !== undefined)\n cloned.markStatic(self._staticInnerHTML);\n\n return cloned as unknown as T;\n }\n\n /**\n * The static attributes defined for the node, which are typically used to represent static properties or characteristics of the node that do not change based on the context or state. These attributes are usually defined in the template and are not reactive.\n * \n * Example: For a node defined as `<div class=\"static-class\">`, the static attribute would be `class=\"static-class\"`.\n */\n get staticAttributes(): AreStaticAttribute[] {\n return this.scope.resolveFlatAll<AreStaticAttribute>(AreStaticAttribute);\n }\n /**\n * The binding attributes defined for the node, which are typically used to represent dynamic properties or characteristics of the node that can change based on the context or state. These attributes are usually defined in the template with a specific syntax (e.g., `:prop=\"value\"` or `v-bind:prop=\"value\"`) and are reactive, meaning that they will update automatically when the underlying data changes.\n * \n * Example: For a node defined as `<div :class=\"dynamicClass\">`, the binding attribute would be `:class=\"dynamicClass\"`.\n */\n get bindings(): AreBindingAttribute[] {\n return this.scope.resolveFlatAll<AreBindingAttribute>(AreBindingAttribute);\n }\n /**\n * The directive attributes defined for the node, which are typically used to represent special instructions or behaviors that should be applied to the node. These attributes are usually defined in the template with a specific syntax (e.g., `v-if=\"condition\"` or `v-for=\"item in list\"`) and are processed by the rendering engine to apply the corresponding logic or behavior to the node.\n * \n * Example: For a node defined as `<div v-if=\"isVisible\">`, the directive attribute would be `v-if=\"isVisible\"`.\n */\n get directives(): AreDirectiveAttribute[] {\n /**\n * 1. get all registered directives for the node\n */\n const directives = this.scope.resolveFlatAll<AreDirectiveAttribute>(AreDirectiveAttribute)!;\n /**\n * 2. Order them in the way that defined in the meta\n * \n * Each meta has a prioprity of order that may impact the way how directives are compiled and rendered. For example, a directive with higher priority may need to be compiled before other directives to ensure that its logic is applied correctly before other directives are processed. By ordering the directives based on their defined priority in the meta, we can ensure that the compilation and rendering process follows the intended logic and behavior as defined by the directive implementations.\n */\n\n return directives.filter(d => d.component).sort((a, b) => {\n const aMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(a.component!);\n const bMeta = A_Context.meta<AreDirectiveMeta, AreDirective>(b.component!);\n\n const aPriority = aMeta.priority ?? 0;\n const bPriority = bMeta.priority ?? 0;\n\n return bPriority - aPriority;\n });\n }\n /**\n * The event attributes defined for the node, which are typically used to represent event listeners or handlers that should be attached to the node. These attributes are usually defined in the template with a specific syntax (e.g., `@click=\"handleClick\"` or `v-on:click=\"handleClick\"`) and are processed by the rendering engine to attach the corresponding event listeners to the node.\n * \n * Example: For a node defined as `<button @click=\"handleClick\">`, the event attribute would be `@click=\"handleClick\"`.\n */\n get events(): AreEventAttribute[] {\n return this.scope.resolveFlatAll<AreEventAttribute>(AreEventAttribute)!;\n }\n /**\n * The styles defined for the node, which can include inline styles or styles defined in a separate stylesheet that are applied to the node. These styles can be used to control the visual appearance of the node and can be defined using standard CSS syntax.\n */\n get styles(): AreStyle {\n return this.scope.resolveFlat<AreStyle>(AreStyle)!;\n }\n\n /**\n * Registers or updates the component-scoped CSS string for this node.\n * Called by the @Are.Styles-decorated method on the associated component.\n * A new AreStyle fragment is registered in scope on first call; subsequent\n * calls update the existing fragment in-place.\n */\n setStyles(css: string): void {\n const existing = this.scope.resolveFlat<AreStyle>(AreStyle);\n if (existing) {\n existing.styles = css;\n } else {\n this.scope.register(new AreStyle(css, this.aseid.toString()));\n }\n }\n\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":["AreRoot","Are","A_FormatterHelper","A_Context","AreSignals","AreRoute","A_SignalVector","A_Caller","A_Logger","AreSignalsContext","A_SignalState","AreRootCache","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,CAAA;AACzC,Q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,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAClC;AACA,IAAA,OAAO,MAAA;AAAA,EACX;AACJ;AA3TU,eAAA,CAAA;AAAA,EADLL,OAAA,CAAI,QAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASC,qBAAa,CAAA;AAAA,CAAA,EAPlBV,eAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADLC,OAAA,CAAI,MAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASD,sBAAc,CAAA,CAAA;AAAA,EACvB,qCAASE,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASE,iCAAY,CAAA;AAAA,CAAA,EA7EjBX,eAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEGA,eAAA,GAAN,eAAA,CAAA;AAAA,EAJNY,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYZ,eAAA,CAAA","file":"AreRoot.component.js","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, A_TYPES__Ctor } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Signal, A_SignalState, A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\nimport { AreRootCache, AreRootCacheEntry } from \"./AreRootCache.context\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions.'\n})\nexport class AreRoot extends Are {\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_SignalState) signalState?: A_SignalState,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n // Select from the ACCUMULATED signal state (every signal dispatched so\n // far), not just the current URL route. Outlets keyed on domain signals\n // (e.g. a primary-display selector) must reflect the live vector the\n // moment they mount — even when they mount AFTER the routing signal was\n // dispatched (a nested outlet inside a just-rendered parent). Using the\n // same vector + lookup as onSignal keeps initial render and subsequent\n // updates consistent.\n const initialVector = this.buildInitialVector(signalState);\n const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);\n\n let componentName: string | undefined = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : undefined;\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(AreRootCache) cache?: AreRootCache,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // Resolve the target component for the incoming vector using the SAME\n // lookup the initial template render uses (root-id conditions first,\n // then the global pool-filtered meta map).\n const renderTarget = this.matchComponent(rootId, vector, signalsContext);\n\n const def = signalsContext?.getDefault(rootId);\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : def?.name\n ? A_FormatterHelper.toKebabCase(def.name)\n : undefined;\n\n // No matching condition for this signal vector and no default — clear the outlet.\n if (!componentName) {\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n root.setContent('');\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n // Stash the currently displayed children so routing back to them can be\n // re-injected instantly from the cache (they are unmounted + detached but\n // NOT destroyed). Falls back to full teardown when no cache is available.\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Fast path: a previously rendered subtree for this component is cached —\n // re-attach it and re-mount from the preserved scene plan, skipping the\n // expensive tokenize/init/load/transform/compile pipeline.\n const cached = cache?.take(root.id, componentName);\n if (cached) {\n this.restoreChild(root, cached, signalsContext);\n return;\n }\n\n // Slow path: build the component subtree from scratch.\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n // The HTML engine time-slices large initial mounts; await so a heavy\n // routed component renders in yielding chunks instead of freezing the\n // main thread on first entry. Small subtrees resolve synchronously.\n await child.mount();\n }\n }\n\n /**\n * Resolves the component a vector should render for the given root, mirroring\n * the priority used everywhere in the routing system:\n * 1. Root-specific conditions registered on AreSignalsContext.\n * 2. The global AreSignalsMeta map, restricted to this outlet's pool.\n *\n * Passing the pool *into* the meta lookup is critical: without it, the first\n * globally matching component wins and may belong to a different outlet\n * (e.g. AisRequirementsPanel for the meta-outlet matching\n * AisEditorCursorScope) — the pool check would then reject it and the outlet\n * would fall back to its default, hiding a valid in-pool match (e.g.\n * AisDiagramTab matching AisSetPrimaryDisplay).\n *\n * Returns `undefined` when nothing matches — callers decide whether to use a\n * configured default, body content, or clear the outlet.\n */\n protected matchComponent(\n rootId: string,\n vector: A_SignalVector | undefined,\n signalsContext?: AreSignalsContext,\n ): A_TYPES__Ctor<Are> | undefined {\n if (!vector) return undefined;\n\n // 1. Root-specific conditions.\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Global pool-filtered meta map.\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n vector,\n pool?.length ? pool : undefined,\n rootId,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n return renderTarget as A_TYPES__Ctor<Are> | undefined;\n }\n\n /**\n * Builds the vector used for the INITIAL render. It is seeded from the\n * accumulated signal state (every signal dispatched on the bus so far) so a\n * freshly-mounted outlet reflects the live application state immediately,\n * not just on the next signal tick. The current URL route is appended when\n * no AreRoute is already present in the state, so route-driven outlets still\n * resolve on the very first paint (before AreRouteWatcher has dispatched).\n */\n protected buildInitialVector(signalState?: A_SignalState): A_SignalVector {\n const signals: A_Signal[] = [];\n\n if (signalState) {\n for (const signal of signalState.toVector()) {\n if (signal) signals.push(signal);\n }\n }\n\n if (!signals.some(signal => signal instanceof AreRoute)) {\n try {\n const currentRoute = AreRoute.default();\n if (currentRoute) signals.push(currentRoute);\n } catch {\n // Non-browser environment (no document) — route is simply absent.\n }\n }\n\n return new A_SignalVector(signals);\n }\n\n /**\n * Detach a displayed child subtree from the outlet and stash it in the cache\n * for fast re-injection later. The subtree is unmounted (its scene plan is\n * preserved) and deregistered from the root scope, but NOT destroyed. The\n * nodes that were subscribed to the signal bus are unsubscribed while cached\n * so the detached DOM never reacts to signals, and recorded so they can be\n * re-subscribed verbatim on restore.\n *\n * When no cache is available, or the LRU evicts an entry, the affected\n * subtree is fully destroyed.\n */\n protected stashChild(\n root: AreNode,\n child: AreNode,\n signalsContext: AreSignalsContext | undefined,\n cache: AreRootCache | undefined,\n ): void {\n const tag = child.type;\n\n child.unmount();\n\n // Collect exactly the nodes that are currently subscribed within this\n // subtree, then unsubscribe them. Without this, AreSignals keeps\n // delivering vectors to a detached subtree that would update reverted\n // DOM (unmount does not deactivate the scene).\n const subscribers = signalsContext\n ? this.collectSubscribers(child, signalsContext)\n : [];\n for (const node of subscribers) {\n signalsContext?.unsubscribe(node);\n }\n\n // Deregister from the root scope (the \"deregister node from parent\").\n root.removeChild(child);\n\n if (!cache) {\n void child.destroy();\n return;\n }\n\n const evicted = cache.put(root.id, tag, { node: child, subscribers });\n for (const entry of evicted) {\n // Evicted entries are already unmounted + unsubscribed + detached.\n void entry.node.destroy();\n }\n }\n\n /**\n * Re-attach a cached subtree to the outlet and re-mount it from its preserved\n * scene plan, re-subscribing exactly the nodes that were subscribed before it\n * was cached.\n */\n protected restoreChild(\n root: AreNode,\n entry: AreRootCacheEntry,\n signalsContext: AreSignalsContext | undefined,\n ): void {\n const child = entry.node;\n\n root.addChild(child);\n\n for (const node of entry.subscribers) {\n signalsContext?.subscribe(node);\n }\n\n child.mount();\n }\n\n /**\n * Walk a subtree and collect the nodes currently registered as signal\n * subscribers. Mirrors the subscription performed at init time in\n * AreHTMLLifecycle (component nodes and root nodes) without depending on the\n * concrete node classes — it simply intersects the subtree with the live\n * subscriber registry.\n */\n protected collectSubscribers(\n node: AreNode,\n signalsContext: AreSignalsContext,\n ): AreNode[] {\n const result: AreNode[] = [];\n const queue: AreNode[] = [node];\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (signalsContext.subscribers.has(current)) {\n result.push(current);\n }\n queue.push(...current.children);\n }\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":["AreRoot","Are","A_FormatterHelper","A_Context","AreSignals","AreRoute","A_SignalVector","A_Caller","A_Logger","AreSignalsContext","A_SignalState","AreRootCache","A_Frame"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaaA,eAAA,GAAN,sBAAsBC,OAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,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AA,MACvB;AACA,MAAA,KAAA,CAAM,IAAA,CAAK,GAAG,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAClC;AACA,IAAA,OAAO,MAAA;AAAA,EACX;AACJ;AA3TU,eAAA,CAAA;AAAA,EADLL,OAAA,CAAI,QAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASC,qBAAa,CAAA;AAAA,CAAA,EAPlBV,eAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADLC,OAAA,CAAI,MAAA;AAAA,EAEA,qCAASM,iBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASD,sBAAc,CAAA,CAAA;AAAA,EACvB,qCAASE,gBAAQ,CAAA,CAAA;AAAA,EACjB,qCAASC,qBAAiB,CAAA,CAAA;AAAA,EAC1B,qCAASE,iCAAY,CAAA;AAAA,CAAA,EA7EjBX,eAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEGA,eAAA,GAAN,eAAA,CAAA;AAAA,EAJNY,aAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACYZ,eAAA,CAAA","file":"AreRoot.component.js","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, A_TYPES__Ctor } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Signal, A_SignalState, A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\nimport { AreRootCache, AreRootCacheEntry } from \"./AreRootCache.context\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions.'\n})\nexport class AreRoot extends Are {\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_SignalState) signalState?: A_SignalState,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n // Select from the ACCUMULATED signal state (every signal dispatched so\n // far), not just the current URL route. Outlets keyed on domain signals\n // (e.g. a primary-display selector) must reflect the live vector the\n // moment they mount — even when they mount AFTER the routing signal was\n // dispatched (a nested outlet inside a just-rendered parent). Using the\n // same vector + lookup as onSignal keeps initial render and subsequent\n // updates consistent.\n const initialVector = this.buildInitialVector(signalState);\n const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);\n\n let componentName: string | undefined = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : undefined;\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(AreRootCache) cache?: AreRootCache,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // Resolve the target component for the incoming vector using the SAME\n // lookup the initial template render uses (root-id conditions first,\n // then the global pool-filtered meta map).\n const renderTarget = this.matchComponent(rootId, vector, signalsContext);\n\n const def = signalsContext?.getDefault(rootId);\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : def?.name\n ? A_FormatterHelper.toKebabCase(def.name)\n : undefined;\n\n // No matching condition for this signal vector and no default — clear the outlet.\n if (!componentName) {\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n root.setContent('');\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n // Stash the currently displayed children so routing back to them can be\n // re-injected instantly from the cache (they are unmounted + detached but\n // NOT destroyed). Falls back to full teardown when no cache is available.\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Fast path: a previously rendered subtree for this component is cached —\n // re-attach it and re-mount from the preserved scene plan, skipping the\n // expensive tokenize/init/load/transform/compile pipeline.\n const cached = cache?.take(root.id, componentName);\n if (cached) {\n this.restoreChild(root, cached, signalsContext);\n return;\n }\n\n // Slow path: build the component subtree from scratch.\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n // The initial mount is atomic (synchronous): the routed subtree is\n // rendered in one uninterrupted pass so no update can observe a\n // partially mounted tree. The await is a harmless no-op here.\n await child.mount();\n }\n }\n\n /**\n * Resolves the component a vector should render for the given root, mirroring\n * the priority used everywhere in the routing system:\n * 1. Root-specific conditions registered on AreSignalsContext.\n * 2. The global AreSignalsMeta map, restricted to this outlet's pool.\n *\n * Passing the pool *into* the meta lookup is critical: without it, the first\n * globally matching component wins and may belong to a different outlet\n * (e.g. AisRequirementsPanel for the meta-outlet matching\n * AisEditorCursorScope) — the pool check would then reject it and the outlet\n * would fall back to its default, hiding a valid in-pool match (e.g.\n * AisDiagramTab matching AisSetPrimaryDisplay).\n *\n * Returns `undefined` when nothing matches — callers decide whether to use a\n * configured default, body content, or clear the outlet.\n */\n protected matchComponent(\n rootId: string,\n vector: A_SignalVector | undefined,\n signalsContext?: AreSignalsContext,\n ): A_TYPES__Ctor<Are> | undefined {\n if (!vector) return undefined;\n\n // 1. Root-specific conditions.\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Global pool-filtered meta map.\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n vector,\n pool?.length ? pool : undefined,\n rootId,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n return renderTarget as A_TYPES__Ctor<Are> | undefined;\n }\n\n /**\n * Builds the vector used for the INITIAL render. It is seeded from the\n * accumulated signal state (every signal dispatched on the bus so far) so a\n * freshly-mounted outlet reflects the live application state immediately,\n * not just on the next signal tick. The current URL route is appended when\n * no AreRoute is already present in the state, so route-driven outlets still\n * resolve on the very first paint (before AreRouteWatcher has dispatched).\n */\n protected buildInitialVector(signalState?: A_SignalState): A_SignalVector {\n const signals: A_Signal[] = [];\n\n if (signalState) {\n for (const signal of signalState.toVector()) {\n if (signal) signals.push(signal);\n }\n }\n\n if (!signals.some(signal => signal instanceof AreRoute)) {\n try {\n const currentRoute = AreRoute.default();\n if (currentRoute) signals.push(currentRoute);\n } catch {\n // Non-browser environment (no document) — route is simply absent.\n }\n }\n\n return new A_SignalVector(signals);\n }\n\n /**\n * Detach a displayed child subtree from the outlet and stash it in the cache\n * for fast re-injection later. The subtree is unmounted (its scene plan is\n * preserved) and deregistered from the root scope, but NOT destroyed. The\n * nodes that were subscribed to the signal bus are unsubscribed while cached\n * so the detached DOM never reacts to signals, and recorded so they can be\n * re-subscribed verbatim on restore.\n *\n * When no cache is available, or the LRU evicts an entry, the affected\n * subtree is fully destroyed.\n */\n protected stashChild(\n root: AreNode,\n child: AreNode,\n signalsContext: AreSignalsContext | undefined,\n cache: AreRootCache | undefined,\n ): void {\n const tag = child.type;\n\n child.unmount();\n\n // Collect exactly the nodes that are currently subscribed within this\n // subtree, then unsubscribe them. Without this, AreSignals keeps\n // delivering vectors to a detached subtree that would update reverted\n // DOM (unmount does not deactivate the scene).\n const subscribers = signalsContext\n ? this.collectSubscribers(child, signalsContext)\n : [];\n for (const node of subscribers) {\n signalsContext?.unsubscribe(node);\n }\n\n // Deregister from the root scope (the \"deregister node from parent\").\n root.removeChild(child);\n\n if (!cache) {\n void child.destroy();\n return;\n }\n\n const evicted = cache.put(root.id, tag, { node: child, subscribers });\n for (const entry of evicted) {\n // Evicted entries are already unmounted + unsubscribed + detached.\n void entry.node.destroy();\n }\n }\n\n /**\n * Re-attach a cached subtree to the outlet and re-mount it from its preserved\n * scene plan, re-subscribing exactly the nodes that were subscribed before it\n * was cached.\n */\n protected restoreChild(\n root: AreNode,\n entry: AreRootCacheEntry,\n signalsContext: AreSignalsContext | undefined,\n ): void {\n const child = entry.node;\n\n root.addChild(child);\n\n for (const node of entry.subscribers) {\n signalsContext?.subscribe(node);\n }\n\n child.mount();\n }\n\n /**\n * Walk a subtree and collect the nodes currently registered as signal\n * subscribers. Mirrors the subscription performed at init time in\n * AreHTMLLifecycle (component nodes and root nodes) without depending on the\n * concrete node classes — it simply intersects the subtree with the live\n * subscriber registry.\n */\n protected collectSubscribers(\n node: AreNode,\n signalsContext: AreSignalsContext,\n ): AreNode[] {\n const result: AreNode[] = [];\n const queue: AreNode[] = [node];\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (signalsContext.subscribers.has(current)) {\n result.push(current);\n }\n queue.push(...current.children);\n }\n return result;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;;;AAaO,IAAM,OAAA,GAAN,cAAsB,GAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,CAAA;AACzC,QAAA,IAAI,gBAAA,EAAkB;AAClB,UAAA,IAAA,CAAK,UAAA,CAAW,CAAA,C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A,OAAO,MAAA;AAAA,EACX;AACJ;AA3TU,eAAA,CAAA;AAAA,EADL,GAAA,CAAI,QAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,4BAAS,aAAa,CAAA;AAAA,CAAA,EAPlB,OAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADL,GAAA,CAAI,MAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,cAAc,CAAA,CAAA;AAAA,EACvB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,4BAAS,YAAY,CAAA;AAAA,CAAA,EA7EjB,OAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEG,OAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,OAAA,CAAA","file":"AreRoot.component.mjs","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, A_TYPES__Ctor } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Signal, A_SignalState, A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\nimport { AreRootCache, AreRootCacheEntry } from \"./AreRootCache.context\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions.'\n})\nexport class AreRoot extends Are {\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_SignalState) signalState?: A_SignalState,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n // Select from the ACCUMULATED signal state (every signal dispatched so\n // far), not just the current URL route. Outlets keyed on domain signals\n // (e.g. a primary-display selector) must reflect the live vector the\n // moment they mount — even when they mount AFTER the routing signal was\n // dispatched (a nested outlet inside a just-rendered parent). Using the\n // same vector + lookup as onSignal keeps initial render and subsequent\n // updates consistent.\n const initialVector = this.buildInitialVector(signalState);\n const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);\n\n let componentName: string | undefined = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : undefined;\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(AreRootCache) cache?: AreRootCache,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // Resolve the target component for the incoming vector using the SAME\n // lookup the initial template render uses (root-id conditions first,\n // then the global pool-filtered meta map).\n const renderTarget = this.matchComponent(rootId, vector, signalsContext);\n\n const def = signalsContext?.getDefault(rootId);\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : def?.name\n ? A_FormatterHelper.toKebabCase(def.name)\n : undefined;\n\n // No matching condition for this signal vector and no default — clear the outlet.\n if (!componentName) {\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n root.setContent('');\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n // Stash the currently displayed children so routing back to them can be\n // re-injected instantly from the cache (they are unmounted + detached but\n // NOT destroyed). Falls back to full teardown when no cache is available.\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Fast path: a previously rendered subtree for this component is cached —\n // re-attach it and re-mount from the preserved scene plan, skipping the\n // expensive tokenize/init/load/transform/compile pipeline.\n const cached = cache?.take(root.id, componentName);\n if (cached) {\n this.restoreChild(root, cached, signalsContext);\n return;\n }\n\n // Slow path: build the component subtree from scratch.\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n // The HTML engine time-slices large initial mounts; await so a heavy\n // routed component renders in yielding chunks instead of freezing the\n // main thread on first entry. Small subtrees resolve synchronously.\n await child.mount();\n }\n }\n\n /**\n * Resolves the component a vector should render for the given root, mirroring\n * the priority used everywhere in the routing system:\n * 1. Root-specific conditions registered on AreSignalsContext.\n * 2. The global AreSignalsMeta map, restricted to this outlet's pool.\n *\n * Passing the pool *into* the meta lookup is critical: without it, the first\n * globally matching component wins and may belong to a different outlet\n * (e.g. AisRequirementsPanel for the meta-outlet matching\n * AisEditorCursorScope) — the pool check would then reject it and the outlet\n * would fall back to its default, hiding a valid in-pool match (e.g.\n * AisDiagramTab matching AisSetPrimaryDisplay).\n *\n * Returns `undefined` when nothing matches — callers decide whether to use a\n * configured default, body content, or clear the outlet.\n */\n protected matchComponent(\n rootId: string,\n vector: A_SignalVector | undefined,\n signalsContext?: AreSignalsContext,\n ): A_TYPES__Ctor<Are> | undefined {\n if (!vector) return undefined;\n\n // 1. Root-specific conditions.\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Global pool-filtered meta map.\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n vector,\n pool?.length ? pool : undefined,\n rootId,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n return renderTarget as A_TYPES__Ctor<Are> | undefined;\n }\n\n /**\n * Builds the vector used for the INITIAL render. It is seeded from the\n * accumulated signal state (every signal dispatched on the bus so far) so a\n * freshly-mounted outlet reflects the live application state immediately,\n * not just on the next signal tick. The current URL route is appended when\n * no AreRoute is already present in the state, so route-driven outlets still\n * resolve on the very first paint (before AreRouteWatcher has dispatched).\n */\n protected buildInitialVector(signalState?: A_SignalState): A_SignalVector {\n const signals: A_Signal[] = [];\n\n if (signalState) {\n for (const signal of signalState.toVector()) {\n if (signal) signals.push(signal);\n }\n }\n\n if (!signals.some(signal => signal instanceof AreRoute)) {\n try {\n const currentRoute = AreRoute.default();\n if (currentRoute) signals.push(currentRoute);\n } catch {\n // Non-browser environment (no document) — route is simply absent.\n }\n }\n\n return new A_SignalVector(signals);\n }\n\n /**\n * Detach a displayed child subtree from the outlet and stash it in the cache\n * for fast re-injection later. The subtree is unmounted (its scene plan is\n * preserved) and deregistered from the root scope, but NOT destroyed. The\n * nodes that were subscribed to the signal bus are unsubscribed while cached\n * so the detached DOM never reacts to signals, and recorded so they can be\n * re-subscribed verbatim on restore.\n *\n * When no cache is available, or the LRU evicts an entry, the affected\n * subtree is fully destroyed.\n */\n protected stashChild(\n root: AreNode,\n child: AreNode,\n signalsContext: AreSignalsContext | undefined,\n cache: AreRootCache | undefined,\n ): void {\n const tag = child.type;\n\n child.unmount();\n\n // Collect exactly the nodes that are currently subscribed within this\n // subtree, then unsubscribe them. Without this, AreSignals keeps\n // delivering vectors to a detached subtree that would update reverted\n // DOM (unmount does not deactivate the scene).\n const subscribers = signalsContext\n ? this.collectSubscribers(child, signalsContext)\n : [];\n for (const node of subscribers) {\n signalsContext?.unsubscribe(node);\n }\n\n // Deregister from the root scope (the \"deregister node from parent\").\n root.removeChild(child);\n\n if (!cache) {\n void child.destroy();\n return;\n }\n\n const evicted = cache.put(root.id, tag, { node: child, subscribers });\n for (const entry of evicted) {\n // Evicted entries are already unmounted + unsubscribed + detached.\n void entry.node.destroy();\n }\n }\n\n /**\n * Re-attach a cached subtree to the outlet and re-mount it from its preserved\n * scene plan, re-subscribing exactly the nodes that were subscribed before it\n * was cached.\n */\n protected restoreChild(\n root: AreNode,\n entry: AreRootCacheEntry,\n signalsContext: AreSignalsContext | undefined,\n ): void {\n const child = entry.node;\n\n root.addChild(child);\n\n for (const node of entry.subscribers) {\n signalsContext?.subscribe(node);\n }\n\n child.mount();\n }\n\n /**\n * Walk a subtree and collect the nodes currently registered as signal\n * subscribers. Mirrors the subscription performed at init time in\n * AreHTMLLifecycle (component nodes and root nodes) without depending on the\n * concrete node classes — it simply intersects the subtree with the live\n * subscriber registry.\n */\n protected collectSubscribers(\n node: AreNode,\n signalsContext: AreSignalsContext,\n ): AreNode[] {\n const result: AreNode[] = [];\n const queue: AreNode[] = [node];\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (signalsContext.subscribers.has(current)) {\n result.push(current);\n }\n queue.push(...current.children);\n }\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/AreRoot/AreRoot.component.ts"],"names":[],"mappings":";;;;;;;;;AAaO,IAAM,OAAA,GAAN,cAAsB,GAAA,CAAI;AAAA,EAG7B,MAAM,QAAA,CACkB,IAAA,EACA,MAAA,EACS,gBACJ,WAAA,EAC3B;AAEE,IAAA,MAAM,SAAS,IAAA,CAAK,EAAA;AAIpB,IAAA,IAAI,cAAA,IAAkB,CAAC,cAAA,CAAe,OAAA,CAAQ,MAAM,CAAA,EAAG;AACnD,MAAA,IAAI,CAAC,IAAA,CAAK,OAAA,EAAS,IAAA,EAAK,EAAG;AAEvB,QAAA,MAAM,YAAA,GAAe,IAAA,CAAK,MAAA,EAAQ,KAAA,CAAM,4BAA4B,CAAA;AACpE,QAAA,MAAM,gBAAA,GAAmB,eAAe,CAAC,CAAA;AACzC,QAAA,IAAI,gBAAA,EAAkB;AAClB,UAAA,IAAA,CAAK,UAAA,CAAW,CAAA,CAAA,EAAI,gBAAgB,CAAA,GAAA,EAAM,gBAAgB,CAAA,CAAA,CAAG,CAAA;AAAA,QACjE;AAAA,MACJ;AAEA,MAAA;AAAA,IACJ;AASA,IAAA,MAA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AAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,4BAAS,aAAa,CAAA;AAAA,CAAA,EAPlB,OAAA,CAGH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAqEA,eAAA,CAAA;AAAA,EADL,GAAA,CAAI,MAAA;AAAA,EAEA,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,cAAc,CAAA,CAAA;AAAA,EACvB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,iBAAiB,CAAA,CAAA;AAAA,EAC1B,4BAAS,YAAY,CAAA;AAAA,CAAA,EA7EjB,OAAA,CAwEH,SAAA,EAAA,UAAA,EAAA,CAAA,CAAA;AAxEG,OAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,OAAA,CAAA","file":"AreRoot.component.mjs","sourcesContent":["import { A_Caller, A_Context, A_FormatterHelper, A_Inject, A_TYPES__Ctor } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Signal, A_SignalState, A_SignalVector } from \"@adaas/a-utils/a-signal\";\nimport { Are, AreNode, AreSignals, AreSignalsMeta, AreSignalsContext } from \"@adaas/are\";\nimport { AreRoute } from \"@adaas/are-html/signals/AreRoute.signal\";\nimport { AreRootCache, AreRootCacheEntry } from \"./AreRootCache.context\";\n\n\n@A_Frame.Define({\n namespace: 'a-are-html',\n description: 'The AreRoot component serves as the foundational entry point for the A-Concept Rendering Engine (ARE). It is responsible for initializing the rendering process, managing the root node of the component tree, and handling signal-based rendering logic. The AreRoot component processes incoming signals to determine which child components to render, allowing for dynamic and responsive UI updates based on application state and user interactions.'\n})\nexport class AreRoot extends Are {\n\n @Are.Template\n async template(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(A_SignalState) signalState?: A_SignalState,\n ) {\n\n const rootId = root.id;\n\n // No routing config for this root — but still honour body content or\n // a 'default' attribute if one is present on the markup.\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n if (!root.content?.trim()) {\n // Fallback: legacy default= attribute\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n const defaultComponent = defaultMatch?.[1];\n if (defaultComponent) {\n root.setContent(`<${defaultComponent}></${defaultComponent}>`);\n }\n }\n // Body content (or none) — tokenizer picks it up without intervention\n return;\n }\n\n // Select from the ACCUMULATED signal state (every signal dispatched so\n // far), not just the current URL route. Outlets keyed on domain signals\n // (e.g. a primary-display selector) must reflect the live vector the\n // moment they mount — even when they mount AFTER the routing signal was\n // dispatched (a nested outlet inside a just-rendered parent). Using the\n // same vector + lookup as onSignal keeps initial render and subsequent\n // updates consistent.\n const initialVector = this.buildInitialVector(signalState);\n const renderTarget = this.matchComponent(rootId, initialVector, signalsContext);\n\n let componentName: string | undefined = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : undefined;\n\n // 3. Fall back to body content (the nodes already placed inside the\n // <are-root> tag act as the default). No setContent() call needed —\n // the tokenizer will process root.content as-is.\n if (!componentName) {\n if (root.content?.trim()) {\n return;\n }\n }\n // 3.5. Fall back to AreSignalsContext default component for this root.\n if (!componentName) {\n const defaultComp = signalsContext?.getDefault(rootId);\n if (defaultComp?.name) {\n componentName = A_FormatterHelper.toKebabCase(defaultComp.name);\n }\n }\n // 4. Last resort: legacy default= attribute on the markup.\n if (!componentName) {\n const defaultMatch = root.markup?.match(/\\bdefault=[\"']([^\"']*)[\"']/);\n componentName = defaultMatch?.[1];\n }\n\n if (!componentName) {\n logger.warning('AreRoot: No component found for initial render. Provide body content, a route condition, or a \"default\" attribute.');\n return;\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n }\n\n\n @Are.Signal\n async onSignal(\n @A_Inject(A_Caller) root: AreNode,\n @A_Inject(A_SignalVector) vector: A_SignalVector,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,\n @A_Inject(AreRootCache) cache?: AreRootCache,\n ) {\n const rootId = root.id;\n\n // No routing config for this root — signals do not affect its content\n if (signalsContext && !signalsContext.hasRoot(rootId)) {\n return;\n }\n\n // Resolve the target component for the incoming vector using the SAME\n // lookup the initial template render uses (root-id conditions first,\n // then the global pool-filtered meta map).\n const renderTarget = this.matchComponent(rootId, vector, signalsContext);\n\n const def = signalsContext?.getDefault(rootId);\n const componentName = renderTarget?.name\n ? A_FormatterHelper.toKebabCase(renderTarget.name)\n : def?.name\n ? A_FormatterHelper.toKebabCase(def.name)\n : undefined;\n\n // No matching condition for this signal vector and no default — clear the outlet.\n if (!componentName) {\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n root.setContent('');\n return;\n }\n\n // Guard: if the outlet already shows the same component, do nothing.\n // Prevents infinite remount loops when a non-routing signal carries a\n // stale routing signal in the accumulated A_SignalState vector.\n // node.type is the kebab-case tag name — the most direct and reliable\n // identifier (no constructor-name resolution, no proxy wrapping issues).\n const currentChild = root.children[0] as AreNode | undefined;\n if (currentChild?.type === componentName) {\n return;\n }\n\n // Stash the currently displayed children so routing back to them can be\n // re-injected instantly from the cache (they are unmounted + detached but\n // NOT destroyed). Falls back to full teardown when no cache is available.\n for (const child of [...root.children]) {\n this.stashChild(root, child, signalsContext, cache);\n }\n\n root.setContent(`<${componentName}></${componentName}>`);\n\n // Fast path: a previously rendered subtree for this component is cached —\n // re-attach it and re-mount from the preserved scene plan, skipping the\n // expensive tokenize/init/load/transform/compile pipeline.\n const cached = cache?.take(root.id, componentName);\n if (cached) {\n this.restoreChild(root, cached, signalsContext);\n return;\n }\n\n // Slow path: build the component subtree from scratch.\n root.tokenize();\n\n for (let i = 0; i < root.children.length; i++) {\n const child = root.children[i];\n child.init();\n\n const res = child.load();\n if (res instanceof Promise) {\n await res;\n }\n child.transform();\n\n child.compile();\n // The initial mount is atomic (synchronous): the routed subtree is\n // rendered in one uninterrupted pass so no update can observe a\n // partially mounted tree. The await is a harmless no-op here.\n await child.mount();\n }\n }\n\n /**\n * Resolves the component a vector should render for the given root, mirroring\n * the priority used everywhere in the routing system:\n * 1. Root-specific conditions registered on AreSignalsContext.\n * 2. The global AreSignalsMeta map, restricted to this outlet's pool.\n *\n * Passing the pool *into* the meta lookup is critical: without it, the first\n * globally matching component wins and may belong to a different outlet\n * (e.g. AisRequirementsPanel for the meta-outlet matching\n * AisEditorCursorScope) — the pool check would then reject it and the outlet\n * would fall back to its default, hiding a valid in-pool match (e.g.\n * AisDiagramTab matching AisSetPrimaryDisplay).\n *\n * Returns `undefined` when nothing matches — callers decide whether to use a\n * configured default, body content, or clear the outlet.\n */\n protected matchComponent(\n rootId: string,\n vector: A_SignalVector | undefined,\n signalsContext?: AreSignalsContext,\n ): A_TYPES__Ctor<Are> | undefined {\n if (!vector) return undefined;\n\n // 1. Root-specific conditions.\n let renderTarget = signalsContext?.findComponentByVector(rootId, vector);\n\n // 2. Global pool-filtered meta map.\n if (!renderTarget) {\n const signalsMeta = A_Context.meta<AreSignalsMeta>(AreSignals);\n const pool = signalsContext?.getComponentById(rootId);\n const metaTarget = signalsMeta?.findComponentByVector(\n vector,\n pool?.length ? pool : undefined,\n rootId,\n );\n if (metaTarget && (!pool?.length || pool.includes(metaTarget))) {\n renderTarget = metaTarget;\n }\n }\n\n return renderTarget as A_TYPES__Ctor<Are> | undefined;\n }\n\n /**\n * Builds the vector used for the INITIAL render. It is seeded from the\n * accumulated signal state (every signal dispatched on the bus so far) so a\n * freshly-mounted outlet reflects the live application state immediately,\n * not just on the next signal tick. The current URL route is appended when\n * no AreRoute is already present in the state, so route-driven outlets still\n * resolve on the very first paint (before AreRouteWatcher has dispatched).\n */\n protected buildInitialVector(signalState?: A_SignalState): A_SignalVector {\n const signals: A_Signal[] = [];\n\n if (signalState) {\n for (const signal of signalState.toVector()) {\n if (signal) signals.push(signal);\n }\n }\n\n if (!signals.some(signal => signal instanceof AreRoute)) {\n try {\n const currentRoute = AreRoute.default();\n if (currentRoute) signals.push(currentRoute);\n } catch {\n // Non-browser environment (no document) — route is simply absent.\n }\n }\n\n return new A_SignalVector(signals);\n }\n\n /**\n * Detach a displayed child subtree from the outlet and stash it in the cache\n * for fast re-injection later. The subtree is unmounted (its scene plan is\n * preserved) and deregistered from the root scope, but NOT destroyed. The\n * nodes that were subscribed to the signal bus are unsubscribed while cached\n * so the detached DOM never reacts to signals, and recorded so they can be\n * re-subscribed verbatim on restore.\n *\n * When no cache is available, or the LRU evicts an entry, the affected\n * subtree is fully destroyed.\n */\n protected stashChild(\n root: AreNode,\n child: AreNode,\n signalsContext: AreSignalsContext | undefined,\n cache: AreRootCache | undefined,\n ): void {\n const tag = child.type;\n\n child.unmount();\n\n // Collect exactly the nodes that are currently subscribed within this\n // subtree, then unsubscribe them. Without this, AreSignals keeps\n // delivering vectors to a detached subtree that would update reverted\n // DOM (unmount does not deactivate the scene).\n const subscribers = signalsContext\n ? this.collectSubscribers(child, signalsContext)\n : [];\n for (const node of subscribers) {\n signalsContext?.unsubscribe(node);\n }\n\n // Deregister from the root scope (the \"deregister node from parent\").\n root.removeChild(child);\n\n if (!cache) {\n void child.destroy();\n return;\n }\n\n const evicted = cache.put(root.id, tag, { node: child, subscribers });\n for (const entry of evicted) {\n // Evicted entries are already unmounted + unsubscribed + detached.\n void entry.node.destroy();\n }\n }\n\n /**\n * Re-attach a cached subtree to the outlet and re-mount it from its preserved\n * scene plan, re-subscribing exactly the nodes that were subscribed before it\n * was cached.\n */\n protected restoreChild(\n root: AreNode,\n entry: AreRootCacheEntry,\n signalsContext: AreSignalsContext | undefined,\n ): void {\n const child = entry.node;\n\n root.addChild(child);\n\n for (const node of entry.subscribers) {\n signalsContext?.subscribe(node);\n }\n\n child.mount();\n }\n\n /**\n * Walk a subtree and collect the nodes currently registered as signal\n * subscribers. Mirrors the subscription performed at init time in\n * AreHTMLLifecycle (component nodes and root nodes) without depending on the\n * concrete node classes — it simply intersects the subtree with the live\n * subscriber registry.\n */\n protected collectSubscribers(\n node: AreNode,\n signalsContext: AreSignalsContext,\n ): AreNode[] {\n const result: AreNode[] = [];\n const queue: AreNode[] = [node];\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (signalsContext.subscribers.has(current)) {\n result.push(current);\n }\n queue.push(...current.children);\n }\n return result;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-BWzEIw6H.mjs';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.mjs';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AreNodeNewProps } from '@adaas/are';
|
|
2
|
-
import { e as AreHTMLNode } from '../AreBinding.attribute-
|
|
2
|
+
import { e as AreHTMLNode } from '../AreBinding.attribute-GpT-5Qmf.js';
|
|
3
3
|
import '@adaas/a-concept';
|
|
4
4
|
import '../lib/AreStyle/AreStyle.context.js';
|
|
5
5
|
|