@adaas/are-html 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/browser/index.d.mts +161 -5
  2. package/dist/browser/index.mjs +357 -55
  3. package/dist/browser/index.mjs.map +1 -1
  4. package/dist/node/directives/AreDirectiveFor.directive.d.mts +7 -0
  5. package/dist/node/directives/AreDirectiveFor.directive.d.ts +7 -0
  6. package/dist/node/directives/AreDirectiveFor.directive.js +17 -2
  7. package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
  8. package/dist/node/directives/AreDirectiveFor.directive.mjs +17 -2
  9. package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
  10. package/dist/node/directives/AreDirectiveShow.directive.d.mts +32 -0
  11. package/dist/node/directives/AreDirectiveShow.directive.d.ts +32 -0
  12. package/dist/node/directives/AreDirectiveShow.directive.js +81 -0
  13. package/dist/node/directives/AreDirectiveShow.directive.js.map +1 -0
  14. package/dist/node/directives/AreDirectiveShow.directive.mjs +71 -0
  15. package/dist/node/directives/AreDirectiveShow.directive.mjs.map +1 -0
  16. package/dist/node/engine/AreHTML.engine.d.mts +2 -1
  17. package/dist/node/engine/AreHTML.engine.d.ts +2 -1
  18. package/dist/node/engine/AreHTML.engine.js +8 -2
  19. package/dist/node/engine/AreHTML.engine.js.map +1 -1
  20. package/dist/node/engine/AreHTML.engine.mjs +8 -2
  21. package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
  22. package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
  23. package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
  24. package/dist/node/engine/AreHTML.interpreter.js +29 -0
  25. package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
  26. package/dist/node/engine/AreHTML.interpreter.mjs +29 -0
  27. package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
  28. package/dist/node/index.d.mts +4 -1
  29. package/dist/node/index.d.ts +4 -1
  30. package/dist/node/index.js +21 -0
  31. package/dist/node/index.mjs +3 -0
  32. package/dist/node/instructions/AreHTML.instructions.constants.d.mts +1 -0
  33. package/dist/node/instructions/AreHTML.instructions.constants.d.ts +1 -0
  34. package/dist/node/instructions/AreHTML.instructions.constants.js +2 -1
  35. package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -1
  36. package/dist/node/instructions/AreHTML.instructions.constants.mjs +2 -1
  37. package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -1
  38. package/dist/node/instructions/AreHTML.instructions.types.d.mts +9 -1
  39. package/dist/node/instructions/AreHTML.instructions.types.d.ts +9 -1
  40. package/dist/node/instructions/HideElement.instruction.d.mts +13 -0
  41. package/dist/node/instructions/HideElement.instruction.d.ts +13 -0
  42. package/dist/node/instructions/HideElement.instruction.js +31 -0
  43. package/dist/node/instructions/HideElement.instruction.js.map +1 -0
  44. package/dist/node/instructions/HideElement.instruction.mjs +24 -0
  45. package/dist/node/instructions/HideElement.instruction.mjs.map +1 -0
  46. package/dist/node/lib/AreRoot/AreRoot.component.d.mts +57 -3
  47. package/dist/node/lib/AreRoot/AreRoot.component.d.ts +57 -3
  48. package/dist/node/lib/AreRoot/AreRoot.component.js +137 -48
  49. package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
  50. package/dist/node/lib/AreRoot/AreRoot.component.mjs +139 -50
  51. package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
  52. package/dist/node/lib/AreRoot/AreRootCache.context.d.mts +58 -0
  53. package/dist/node/lib/AreRoot/AreRootCache.context.d.ts +58 -0
  54. package/dist/node/lib/AreRoot/AreRootCache.context.js +106 -0
  55. package/dist/node/lib/AreRoot/AreRootCache.context.js.map +1 -0
  56. package/dist/node/lib/AreRoot/AreRootCache.context.mjs +99 -0
  57. package/dist/node/lib/AreRoot/AreRootCache.context.mjs.map +1 -0
  58. package/examples/jumpstart/dist/index.html +1 -1
  59. package/examples/jumpstart/dist/{mq1a0fv0-ccgtz6.js → mq7hqrxy-4kus50.js} +629 -433
  60. package/examples/signal-routing/dist/index.html +1 -1
  61. package/examples/signal-routing/dist/{mq1bzrik-4lec86.js → mq7k53th-qiwy4x.js} +903 -486
  62. package/examples/signal-routing/src/components/SettingsPage.component.ts +39 -0
  63. package/examples/signal-routing/src/concept.ts +2 -0
  64. package/package.json +9 -9
  65. package/src/directives/AreDirectiveFor.directive.ts +44 -2
  66. package/src/directives/AreDirectiveShow.directive.ts +127 -0
  67. package/src/engine/AreHTML.engine.ts +11 -1
  68. package/src/engine/AreHTML.interpreter.ts +50 -0
  69. package/src/index.ts +3 -0
  70. package/src/instructions/AreHTML.instructions.constants.ts +1 -0
  71. package/src/instructions/AreHTML.instructions.types.ts +9 -0
  72. package/src/instructions/HideElement.instruction.ts +29 -0
  73. package/src/lib/AreRoot/AreRoot.component.ts +201 -71
  74. package/src/lib/AreRoot/AreRootCache.context.ts +133 -0
@@ -3,7 +3,7 @@ import { A_Component, A_TYPES__Ctor, A_Fragment, ASEID, A_Scope, A_Feature, A_Co
3
3
  import { A_Logger } from '@adaas/a-utils/a-logger';
4
4
  import { A_ExecutionContext } from '@adaas/a-utils/a-execution';
5
5
  import { A_Route } from '@adaas/a-utils/a-route';
6
- import { A_Signal, A_SignalVector } from '@adaas/a-utils/a-signal';
6
+ import { A_Signal, A_SignalState, A_SignalVector } from '@adaas/a-utils/a-signal';
7
7
 
8
8
  declare class AreDirective extends A_Component {
9
9
  /**
@@ -126,6 +126,13 @@ declare class AreDirectiveFor extends AreDirective {
126
126
  transform(attribute: AreDirectiveAttribute, scope: A_Scope, store: AreStore, scene: AreScene, logger: A_Logger, ...args: any[]): void;
127
127
  compile(attribute: AreDirectiveAttribute, store: AreStore, scene: AreScene, ...args: any[]): void;
128
128
  update(attribute: AreDirectiveAttribute, store: AreStore, scene: AreScene, ...args: any[]): void;
129
+ /**
130
+ * Walks the node's ancestor chain (inclusive) and reports whether the
131
+ * whole path is currently active — i.e. the subtree is actually rendered
132
+ * into the DOM. A single inactive ancestor scene (e.g. a `$if` whose
133
+ * condition is false) means the subtree is detached.
134
+ */
135
+ private isAttached;
129
136
  /**
130
137
  * Build a key-function that derives a stable identity from each item.
131
138
  * If the user provided a `track <expr>` clause, evaluate it as a path on
@@ -193,6 +200,29 @@ declare class AreDirectiveIf extends AreDirective {
193
200
  update(attribute: AreDirectiveAttribute, store: AreStore, scope: A_Scope, syntax: AreSyntax, scene: AreScene, ...args: any[]): void;
194
201
  }
195
202
 
203
+ /**
204
+ * `$show` directive — conditionally toggles an element's visibility.
205
+ *
206
+ * Unlike `$if`, `$show` keeps the element fully mounted at all times and only
207
+ * flips its inline `display` (Vue `v-show` semantics). The element's subtree,
208
+ * event listeners and scene state are preserved across toggles, which makes it
209
+ * far cheaper than `$if` for things that flip on/off frequently. Use `$if` when
210
+ * the hidden branch is expensive and rarely shown; use `$show` when it toggles
211
+ * often.
212
+ *
213
+ * ⚠️ Known limitations:
214
+ * - Do NOT combine `$show` with `$if`/`$for` on the SAME element — they share
215
+ * an owner node and would fight over its host instruction. Wrap one in a
216
+ * parent element instead.
217
+ * - `$show` forces inline `display:none`, which beats stylesheet rules but will
218
+ * NOT override the element's own inline `:style="display:..."` binding.
219
+ */
220
+ declare class AreDirectiveShow extends AreDirective {
221
+ transform(attribute: AreDirectiveAttribute, logger: A_Logger, ...args: any[]): void;
222
+ compile(attribute: AreDirectiveAttribute, store: AreStore, scene: AreScene, syntax: AreSyntax, directiveContext?: AreDirectiveContext, ...args: any[]): void;
223
+ update(attribute: AreDirectiveAttribute, store: AreStore, scene: AreScene, syntax: AreSyntax, directiveContext?: AreDirectiveContext, ...args: any[]): void;
224
+ }
225
+
196
226
  type AreHtmlAddAttributeInstructionPayload = {
197
227
  name: string;
198
228
  content: string;
@@ -223,6 +253,14 @@ type AreHtmlAddStyleInstructionPayload = {
223
253
  /** Full CSS string to inject as a <style> block scoped to the component. Applied to the document head and reverted on unmount. */
224
254
  styles: string;
225
255
  };
256
+ type AreHtmlHideInstructionPayload = {
257
+ /**
258
+ * Optional explicit display value to restore when the element becomes
259
+ * visible again. When omitted, the interpreter caches and restores the
260
+ * element's own prior inline `display` value (Vue `v-show` semantics).
261
+ */
262
+ display?: string;
263
+ };
226
264
  type AreHtmlAddListenerInstructionPayload = {
227
265
  /** DOM event name (e.g. "click", "input", "submit") */
228
266
  name: string;
@@ -261,6 +299,15 @@ declare class AddTextInstruction extends AreDeclaration<AreHtmlAddTextInstructio
261
299
  constructor(props: AreHtmlAddTextInstructionPayload | AreInstructionSerialized<AreHtmlAddTextInstructionPayload>);
262
300
  }
263
301
 
302
+ declare class HideElementInstruction extends AreMutation<AreHtmlHideInstructionPayload> {
303
+ /**
304
+ * Caches the element's inline `display` value captured at apply time so it
305
+ * can be restored verbatim on revert (mirrors Vue `v-show`).
306
+ */
307
+ cache?: string;
308
+ constructor(parent: AreDeclaration, props: AreHtmlHideInstructionPayload | AreInstructionSerialized<AreHtmlHideInstructionPayload>);
309
+ }
310
+
264
311
  declare const AreHTMLInstructions: {
265
312
  readonly AddElement: "_AreHTML_AddElement";
266
313
  readonly AddText: "_AreHTML_AddText";
@@ -269,6 +316,7 @@ declare const AreHTMLInstructions: {
269
316
  readonly AddListener: "_AreHTML_AddListener";
270
317
  readonly AddInterpolation: "_AreHTML_AddInterpolation";
271
318
  readonly AddComment: "_AreHTML_AddComment";
319
+ readonly HideElement: "_AreHTML_HideElement";
272
320
  };
273
321
 
274
322
  declare class AreComment extends AreHTMLNode {
@@ -523,6 +571,60 @@ declare class AreHTMLCompiler extends AreCompiler {
523
571
  compileBindingAttribute(attribute: AreBindingAttribute, scene: AreScene, parentStore: AreStore, store: AreStore, syntax: AreSyntax, ...args: any[]): void;
524
572
  }
525
573
 
574
+ /**
575
+ * A single cached, detached component subtree for an are-root outlet.
576
+ *
577
+ * `node` is fully compiled and its scene plan is intact (it was `unmount()`ed,
578
+ * not destroyed), so it can be re-mounted instantly without re-tokenizing,
579
+ * re-loading, transforming or compiling. `subscribers` records the exact set of
580
+ * nodes inside the subtree that were subscribed to the signal bus at the moment
581
+ * of stashing — they are unsubscribed while cached (so the detached DOM never
582
+ * reacts to signals) and re-subscribed verbatim on restore.
583
+ */
584
+ type AreRootCacheEntry = {
585
+ node: AreNode;
586
+ subscribers: AreNode[];
587
+ };
588
+ declare class AreRootCache extends A_Fragment {
589
+ /**
590
+ * rootId -> (component tag -> cache entry). The inner Map preserves
591
+ * insertion order which is used as the LRU recency order: the first key is
592
+ * the least-recently-used entry, the last key the most-recently-used.
593
+ */
594
+ protected _cache: Map<string, Map<string, AreRootCacheEntry>>;
595
+ /**
596
+ * Maximum number of cached subtrees kept per root. Older entries beyond this
597
+ * limit are evicted (and returned to the caller so it can destroy them).
598
+ */
599
+ protected _limit: number;
600
+ constructor(limit?: number);
601
+ /**
602
+ * Maximum number of cached subtrees kept per root.
603
+ */
604
+ get limit(): number;
605
+ protected bucket(rootId: string): Map<string, AreRootCacheEntry>;
606
+ /**
607
+ * Whether a subtree for the given component tag is currently cached.
608
+ */
609
+ has(rootId: string, tag: string): boolean;
610
+ /**
611
+ * Retrieve AND remove a cached subtree so it can become live again. Returns
612
+ * `undefined` on a cache miss.
613
+ */
614
+ take(rootId: string, tag: string): AreRootCacheEntry | undefined;
615
+ /**
616
+ * Stash a detached subtree under the given component tag. Returns any entries
617
+ * that were evicted to honour the LRU limit (or replaced for the same tag) so
618
+ * the caller can `destroy()` them.
619
+ */
620
+ put(rootId: string, tag: string, entry: AreRootCacheEntry): AreRootCacheEntry[];
621
+ /**
622
+ * Remove and return every cached entry for a root (e.g. on teardown) so the
623
+ * caller can destroy them.
624
+ */
625
+ clear(rootId: string): AreRootCacheEntry[];
626
+ }
627
+
526
628
  declare class AreHTMLEngine extends AreEngine {
527
629
  get DefaultSyntax(): AreSyntax;
528
630
  /**
@@ -530,7 +632,7 @@ declare class AreHTMLEngine extends AreEngine {
530
632
  *
531
633
  * @param container
532
634
  */
533
- init(scope: A_Scope, signalContext?: AreSignalsContext): Promise<void>;
635
+ init(scope: A_Scope, signalContext?: AreSignalsContext, rootCache?: AreRootCache): Promise<void>;
534
636
  protected rootElementMatcher(source: string, from: number, to: number, build: (raw: string, content: string, position: number, closing: string) => AreSyntaxTokenMatch): AreSyntaxTokenMatch | null;
535
637
  protected htmlElementMatcher(source: string, from: number, to: number, build: (raw: string, content: string, position: number, closing: string) => AreSyntaxTokenMatch): AreSyntaxTokenMatch | null;
536
638
  /**
@@ -550,6 +652,8 @@ declare class AreHTMLInterpreter extends AreInterpreter {
550
652
  removeElement(declaration: AddElementInstruction, context: AreHTMLEngineContext): void;
551
653
  addAttribute(mutation: AddAttributeInstruction, context: AreHTMLEngineContext, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, logger?: A_Logger): void;
552
654
  removeAttribute(mutation: AddAttributeInstruction, context: AreHTMLEngineContext): void;
655
+ hideElement(mutation: HideElementInstruction, context: AreHTMLEngineContext): void;
656
+ showElement(mutation: HideElementInstruction, context: AreHTMLEngineContext): void;
553
657
  addEventListener(mutation: AddListenerInstruction, context: AreHTMLEngineContext, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, logger?: A_Logger): void;
554
658
  removeEventListener(mutation: AddListenerInstruction, context: AreHTMLEngineContext): void;
555
659
  addText(declaration: AddTextInstruction, context: AreHTMLEngineContext, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, logger?: A_Logger): void;
@@ -624,8 +728,60 @@ type AreDirectiveOrderDecoratorParameters = {
624
728
  };
625
729
 
626
730
  declare class AreRoot extends Are {
627
- template(root: AreNode, logger: A_Logger, signalsContext?: AreSignalsContext): Promise<void>;
628
- onSignal(root: AreNode, vector: A_SignalVector, logger: A_Logger, signalsContext?: AreSignalsContext): Promise<void>;
731
+ template(root: AreNode, logger: A_Logger, signalsContext?: AreSignalsContext, signalState?: A_SignalState): Promise<void>;
732
+ onSignal(root: AreNode, vector: A_SignalVector, logger: A_Logger, signalsContext?: AreSignalsContext, cache?: AreRootCache): Promise<void>;
733
+ /**
734
+ * Resolves the component a vector should render for the given root, mirroring
735
+ * the priority used everywhere in the routing system:
736
+ * 1. Root-specific conditions registered on AreSignalsContext.
737
+ * 2. The global AreSignalsMeta map, restricted to this outlet's pool.
738
+ *
739
+ * Passing the pool *into* the meta lookup is critical: without it, the first
740
+ * globally matching component wins and may belong to a different outlet
741
+ * (e.g. AisRequirementsPanel for the meta-outlet matching
742
+ * AisEditorCursorScope) — the pool check would then reject it and the outlet
743
+ * would fall back to its default, hiding a valid in-pool match (e.g.
744
+ * AisDiagramTab matching AisSetPrimaryDisplay).
745
+ *
746
+ * Returns `undefined` when nothing matches — callers decide whether to use a
747
+ * configured default, body content, or clear the outlet.
748
+ */
749
+ protected matchComponent(rootId: string, vector: A_SignalVector | undefined, signalsContext?: AreSignalsContext): A_TYPES__Ctor<Are> | undefined;
750
+ /**
751
+ * Builds the vector used for the INITIAL render. It is seeded from the
752
+ * accumulated signal state (every signal dispatched on the bus so far) so a
753
+ * freshly-mounted outlet reflects the live application state immediately,
754
+ * not just on the next signal tick. The current URL route is appended when
755
+ * no AreRoute is already present in the state, so route-driven outlets still
756
+ * resolve on the very first paint (before AreRouteWatcher has dispatched).
757
+ */
758
+ protected buildInitialVector(signalState?: A_SignalState): A_SignalVector;
759
+ /**
760
+ * Detach a displayed child subtree from the outlet and stash it in the cache
761
+ * for fast re-injection later. The subtree is unmounted (its scene plan is
762
+ * preserved) and deregistered from the root scope, but NOT destroyed. The
763
+ * nodes that were subscribed to the signal bus are unsubscribed while cached
764
+ * so the detached DOM never reacts to signals, and recorded so they can be
765
+ * re-subscribed verbatim on restore.
766
+ *
767
+ * When no cache is available, or the LRU evicts an entry, the affected
768
+ * subtree is fully destroyed.
769
+ */
770
+ protected stashChild(root: AreNode, child: AreNode, signalsContext: AreSignalsContext | undefined, cache: AreRootCache | undefined): void;
771
+ /**
772
+ * Re-attach a cached subtree to the outlet and re-mount it from its preserved
773
+ * scene plan, re-subscribing exactly the nodes that were subscribed before it
774
+ * was cached.
775
+ */
776
+ protected restoreChild(root: AreNode, entry: AreRootCacheEntry, signalsContext: AreSignalsContext | undefined): void;
777
+ /**
778
+ * Walk a subtree and collect the nodes currently registered as signal
779
+ * subscribers. Mirrors the subscription performed at init time in
780
+ * AreHTMLLifecycle (component nodes and root nodes) without depending on the
781
+ * concrete node classes — it simply intersects the subtree with the live
782
+ * subscriber registry.
783
+ */
784
+ protected collectSubscribers(node: AreNode, signalsContext: AreSignalsContext): AreNode[];
629
785
  }
630
786
 
631
787
  declare class AreRouteWatcher extends A_Component {
@@ -643,4 +799,4 @@ declare class AreRouteWatcher extends A_Component {
643
799
  private notify;
644
800
  }
645
801
 
646
- export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, type AreDirectiveOrderDecoratorParameters, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, type AreHTMLContextConstructor, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, type AreHtmlAddAttributeInstructionPayload, type AreHtmlAddCommentInstructionPayload, type AreHtmlAddElementInstructionPayload, type AreHtmlAddInterpolationInstructionPayload, type AreHtmlAddListenerInstructionPayload, type AreHtmlAddStyleInstructionPayload, type AreHtmlAddTextInstructionPayload, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
802
+ export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, type AreDirectiveOrderDecoratorParameters, AreDirectiveShow, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, type AreHTMLContextConstructor, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, type AreHtmlAddAttributeInstructionPayload, type AreHtmlAddCommentInstructionPayload, type AreHtmlAddElementInstructionPayload, type AreHtmlAddInterpolationInstructionPayload, type AreHtmlAddListenerInstructionPayload, type AreHtmlAddStyleInstructionPayload, type AreHtmlAddTextInstructionPayload, type AreHtmlHideInstructionPayload, AreInterpolation, AreRoot, AreRootCache, type AreRootCacheEntry, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, HideElementInstruction, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };