@adaas/are-html 0.0.20 → 0.0.22

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 (109) hide show
  1. package/.conf/tsconfig.base.json +1 -0
  2. package/.conf/tsconfig.browser.json +1 -0
  3. package/.conf/tsconfig.node.json +1 -0
  4. package/dist/browser/index.d.mts +206 -7
  5. package/dist/browser/index.mjs +527 -65
  6. package/dist/browser/index.mjs.map +1 -1
  7. package/dist/node/directives/AreDirectiveFor.directive.d.mts +44 -1
  8. package/dist/node/directives/AreDirectiveFor.directive.d.ts +44 -1
  9. package/dist/node/directives/AreDirectiveFor.directive.js +102 -6
  10. package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
  11. package/dist/node/directives/AreDirectiveFor.directive.mjs +102 -6
  12. package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
  13. package/dist/node/directives/AreDirectiveShow.directive.d.mts +32 -0
  14. package/dist/node/directives/AreDirectiveShow.directive.d.ts +32 -0
  15. package/dist/node/directives/AreDirectiveShow.directive.js +81 -0
  16. package/dist/node/directives/AreDirectiveShow.directive.js.map +1 -0
  17. package/dist/node/directives/AreDirectiveShow.directive.mjs +71 -0
  18. package/dist/node/directives/AreDirectiveShow.directive.mjs.map +1 -0
  19. package/dist/node/engine/AreHTML.engine.d.mts +2 -1
  20. package/dist/node/engine/AreHTML.engine.d.ts +2 -1
  21. package/dist/node/engine/AreHTML.engine.js +8 -2
  22. package/dist/node/engine/AreHTML.engine.js.map +1 -1
  23. package/dist/node/engine/AreHTML.engine.mjs +8 -2
  24. package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
  25. package/dist/node/engine/AreHTML.interpreter.d.mts +3 -0
  26. package/dist/node/engine/AreHTML.interpreter.d.ts +3 -0
  27. package/dist/node/engine/AreHTML.interpreter.js +29 -0
  28. package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
  29. package/dist/node/engine/AreHTML.interpreter.mjs +29 -0
  30. package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
  31. package/dist/node/engine/AreHTML.lifecycle.d.mts +8 -1
  32. package/dist/node/engine/AreHTML.lifecycle.d.ts +8 -1
  33. package/dist/node/engine/AreHTML.lifecycle.js +46 -3
  34. package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
  35. package/dist/node/engine/AreHTML.lifecycle.mjs +46 -3
  36. package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
  37. package/dist/node/helpers/AreScheduler.helper.d.mts +39 -0
  38. package/dist/node/helpers/AreScheduler.helper.d.ts +39 -0
  39. package/dist/node/helpers/AreScheduler.helper.js +40 -0
  40. package/dist/node/helpers/AreScheduler.helper.js.map +1 -0
  41. package/dist/node/helpers/AreScheduler.helper.mjs +40 -0
  42. package/dist/node/helpers/AreScheduler.helper.mjs.map +1 -0
  43. package/dist/node/index.d.mts +4 -1
  44. package/dist/node/index.d.ts +4 -1
  45. package/dist/node/index.js +21 -0
  46. package/dist/node/index.mjs +3 -0
  47. package/dist/node/instructions/AreHTML.instructions.constants.d.mts +1 -0
  48. package/dist/node/instructions/AreHTML.instructions.constants.d.ts +1 -0
  49. package/dist/node/instructions/AreHTML.instructions.constants.js +2 -1
  50. package/dist/node/instructions/AreHTML.instructions.constants.js.map +1 -1
  51. package/dist/node/instructions/AreHTML.instructions.constants.mjs +2 -1
  52. package/dist/node/instructions/AreHTML.instructions.constants.mjs.map +1 -1
  53. package/dist/node/instructions/AreHTML.instructions.types.d.mts +9 -1
  54. package/dist/node/instructions/AreHTML.instructions.types.d.ts +9 -1
  55. package/dist/node/instructions/HideElement.instruction.d.mts +13 -0
  56. package/dist/node/instructions/HideElement.instruction.d.ts +13 -0
  57. package/dist/node/instructions/HideElement.instruction.js +31 -0
  58. package/dist/node/instructions/HideElement.instruction.js.map +1 -0
  59. package/dist/node/instructions/HideElement.instruction.mjs +24 -0
  60. package/dist/node/instructions/HideElement.instruction.mjs.map +1 -0
  61. package/dist/node/lib/AreRoot/AreRoot.component.d.mts +57 -3
  62. package/dist/node/lib/AreRoot/AreRoot.component.d.ts +57 -3
  63. package/dist/node/lib/AreRoot/AreRoot.component.js +138 -49
  64. package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
  65. package/dist/node/lib/AreRoot/AreRoot.component.mjs +140 -51
  66. package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
  67. package/dist/node/lib/AreRoot/AreRootCache.context.d.mts +58 -0
  68. package/dist/node/lib/AreRoot/AreRootCache.context.d.ts +58 -0
  69. package/dist/node/lib/AreRoot/AreRootCache.context.js +106 -0
  70. package/dist/node/lib/AreRoot/AreRootCache.context.js.map +1 -0
  71. package/dist/node/lib/AreRoot/AreRootCache.context.mjs +99 -0
  72. package/dist/node/lib/AreRoot/AreRootCache.context.mjs.map +1 -0
  73. package/examples/dashboard/dist/index.html +1 -1
  74. package/examples/dashboard/dist/{mq19zxz4-mnlgmd.js → mqh9ryml-xat335.js} +1922 -1316
  75. package/examples/dashboard/src/concept.ts +3 -2
  76. package/examples/for-perf/concept.ts +45 -0
  77. package/examples/for-perf/containers/UI.container.ts +161 -0
  78. package/examples/for-perf/dist/index.html +270 -0
  79. package/examples/for-perf/dist/mqh9ryde-m243t8.js +15223 -0
  80. package/examples/for-perf/dist/mqh9ryfo-6a8d0o.js +15223 -0
  81. package/examples/for-perf/dist/mqh9ryfq-4pf5cv.js +15223 -0
  82. package/examples/for-perf/public/index.html +270 -0
  83. package/examples/for-perf/src/components/PerfApp.component.ts +37 -0
  84. package/examples/for-perf/src/components/PerfControls.component.ts +34 -0
  85. package/examples/for-perf/src/components/PerfGrid.component.ts +225 -0
  86. package/examples/for-perf/src/components/PerfHeader.component.ts +34 -0
  87. package/examples/for-perf/src/components/PerfStats.component.ts +43 -0
  88. package/examples/for-perf/src/concept.ts +94 -0
  89. package/examples/jumpstart/dist/index.html +1 -1
  90. package/examples/jumpstart/dist/{mq1a0fv0-ccgtz6.js → mq7mgf58-vbf07e.js} +895 -521
  91. package/examples/signal-routing/dist/index.html +1 -1
  92. package/examples/signal-routing/dist/{mq1bzrik-4lec86.js → mqh9ryc9-dkcbkx.js} +2024 -1300
  93. package/examples/signal-routing/src/components/SettingsPage.component.ts +39 -0
  94. package/examples/signal-routing/src/concept.ts +2 -0
  95. package/jest.config.ts +1 -0
  96. package/package.json +10 -9
  97. package/src/directives/AreDirectiveFor.directive.ts +185 -12
  98. package/src/directives/AreDirectiveShow.directive.ts +127 -0
  99. package/src/engine/AreHTML.engine.ts +11 -1
  100. package/src/engine/AreHTML.interpreter.ts +50 -0
  101. package/src/engine/AreHTML.lifecycle.ts +83 -6
  102. package/src/helpers/AreScheduler.helper.ts +61 -0
  103. package/src/index.ts +3 -0
  104. package/src/instructions/AreHTML.instructions.constants.ts +1 -0
  105. package/src/instructions/AreHTML.instructions.types.ts +9 -0
  106. package/src/instructions/HideElement.instruction.ts +29 -0
  107. package/src/lib/AreRoot/AreRoot.component.ts +205 -72
  108. package/src/lib/AreRoot/AreRootCache.context.ts +133 -0
  109. package/tsconfig.json +1 -0
@@ -0,0 +1,133 @@
1
+ import { A_Fragment } from "@adaas/a-concept";
2
+ import { A_Frame } from "@adaas/a-frame/core";
3
+ import { AreNode } from "@adaas/are";
4
+
5
+
6
+ /**
7
+ * A single cached, detached component subtree for an are-root outlet.
8
+ *
9
+ * `node` is fully compiled and its scene plan is intact (it was `unmount()`ed,
10
+ * not destroyed), so it can be re-mounted instantly without re-tokenizing,
11
+ * re-loading, transforming or compiling. `subscribers` records the exact set of
12
+ * nodes inside the subtree that were subscribed to the signal bus at the moment
13
+ * of stashing — they are unsubscribed while cached (so the detached DOM never
14
+ * reacts to signals) and re-subscribed verbatim on restore.
15
+ */
16
+ export type AreRootCacheEntry = {
17
+ node: AreNode;
18
+ subscribers: AreNode[];
19
+ };
20
+
21
+
22
+ @A_Frame.Define({
23
+ namespace: 'a-are-html',
24
+ description: 'AreRootCache is a fragment that keeps a small per-root LRU of previously rendered are-root subtrees. When an are-root swaps the component it displays, the outgoing subtree is stashed here (unmounted + detached, but not destroyed) so that routing back to it can re-inject the preserved scene instantly instead of rebuilding from scratch.'
25
+ })
26
+ export class AreRootCache extends A_Fragment {
27
+
28
+ /**
29
+ * rootId -> (component tag -> cache entry). The inner Map preserves
30
+ * insertion order which is used as the LRU recency order: the first key is
31
+ * the least-recently-used entry, the last key the most-recently-used.
32
+ */
33
+ protected _cache: Map<string, Map<string, AreRootCacheEntry>> = new Map();
34
+
35
+ /**
36
+ * Maximum number of cached subtrees kept per root. Older entries beyond this
37
+ * limit are evicted (and returned to the caller so it can destroy them).
38
+ */
39
+ protected _limit: number;
40
+
41
+ constructor(limit: number = 10) {
42
+ super({ name: 'AreRootCache' });
43
+ this._limit = Math.max(0, Math.floor(limit));
44
+ }
45
+
46
+ /**
47
+ * Maximum number of cached subtrees kept per root.
48
+ */
49
+ get limit(): number {
50
+ return this._limit;
51
+ }
52
+
53
+ protected bucket(rootId: string): Map<string, AreRootCacheEntry> {
54
+ let bucket = this._cache.get(rootId);
55
+ if (!bucket) {
56
+ bucket = new Map();
57
+ this._cache.set(rootId, bucket);
58
+ }
59
+ return bucket;
60
+ }
61
+
62
+ /**
63
+ * Whether a subtree for the given component tag is currently cached.
64
+ */
65
+ has(rootId: string, tag: string): boolean {
66
+ return this.bucket(rootId).has(tag);
67
+ }
68
+
69
+ /**
70
+ * Retrieve AND remove a cached subtree so it can become live again. Returns
71
+ * `undefined` on a cache miss.
72
+ */
73
+ take(rootId: string, tag: string): AreRootCacheEntry | undefined {
74
+ const bucket = this.bucket(rootId);
75
+ const entry = bucket.get(tag);
76
+ if (entry) {
77
+ bucket.delete(tag);
78
+ }
79
+ return entry;
80
+ }
81
+
82
+ /**
83
+ * Stash a detached subtree under the given component tag. Returns any entries
84
+ * that were evicted to honour the LRU limit (or replaced for the same tag) so
85
+ * the caller can `destroy()` them.
86
+ */
87
+ put(rootId: string, tag: string, entry: AreRootCacheEntry): AreRootCacheEntry[] {
88
+ const bucket = this.bucket(rootId);
89
+ const evicted: AreRootCacheEntry[] = [];
90
+
91
+ // Replace any stale entry for the same tag (should not normally happen,
92
+ // since a displayed tag is never simultaneously cached) and surface it
93
+ // for destruction so it does not leak.
94
+ const existing = bucket.get(tag);
95
+ if (existing) {
96
+ bucket.delete(tag);
97
+ if (existing.node !== entry.node) {
98
+ evicted.push(existing);
99
+ }
100
+ }
101
+
102
+ // A limit of 0 disables caching: the freshly added entry is evicted
103
+ // immediately so the caller tears it down.
104
+ bucket.set(tag, entry);
105
+
106
+ while (bucket.size > this._limit) {
107
+ const oldestKey = bucket.keys().next().value as string | undefined;
108
+ if (oldestKey === undefined) {
109
+ break;
110
+ }
111
+ const oldest = bucket.get(oldestKey)!;
112
+ bucket.delete(oldestKey);
113
+ evicted.push(oldest);
114
+ }
115
+
116
+ return evicted;
117
+ }
118
+
119
+ /**
120
+ * Remove and return every cached entry for a root (e.g. on teardown) so the
121
+ * caller can destroy them.
122
+ */
123
+ clear(rootId: string): AreRootCacheEntry[] {
124
+ const bucket = this._cache.get(rootId);
125
+ if (!bucket) {
126
+ return [];
127
+ }
128
+ const entries = [...bucket.values()];
129
+ bucket.clear();
130
+ this._cache.delete(rootId);
131
+ return entries;
132
+ }
133
+ }
package/tsconfig.json CHANGED
@@ -15,6 +15,7 @@
15
15
  "@adaas/are-html/instructions/*": ["src/instructions/*"],
16
16
  "@adaas/are-html/watchers/*": ["src/watchers/*"],
17
17
  "@adaas/are-html/signals/*": ["src/signals/*"],
18
+ "@adaas/are-html/helpers/*": ["src/helpers/*"],
18
19
  // Custom Lib Exports
19
20
  "@adaas/are-html/style/*": ["src/lib/AreStyle/*"],
20
21
  "@adaas/are-html/directive/*": ["src/lib/AreDirective/*"],