@repobit/dex-store-elements 1.7.3 → 2.0.0
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/CHANGELOG.md +5 -913
- package/README.md +9 -7
- package/dist/src/actions/action.adapter.d.ts +36 -0
- package/dist/src/actions/action.adapter.js +183 -0
- package/dist/src/actions/action.adapter.js.map +1 -0
- package/dist/src/actions/action.attributes.d.ts +15 -0
- package/dist/src/actions/action.attributes.js +137 -0
- package/dist/src/actions/action.attributes.js.map +1 -0
- package/dist/src/actions/action.registry.d.ts +4 -0
- package/dist/src/actions/action.registry.js +119 -0
- package/dist/src/actions/action.registry.js.map +1 -0
- package/dist/src/actions/index.d.ts +3 -2
- package/dist/src/actions/index.js +3 -80
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/compute/compute.expand.d.ts +70 -0
- package/dist/src/compute/compute.expand.js +319 -0
- package/dist/src/compute/compute.expand.js.map +1 -0
- package/dist/src/compute/compute.scan.d.ts +54 -0
- package/dist/src/compute/compute.scan.js +160 -0
- package/dist/src/compute/compute.scan.js.map +1 -0
- package/dist/src/compute/option-resolver.d.ts +31 -0
- package/dist/src/compute/option-resolver.js +147 -0
- package/dist/src/compute/option-resolver.js.map +1 -0
- package/dist/src/contexts/context.compute.d.ts +12 -0
- package/dist/src/contexts/context.compute.js +4 -0
- package/dist/src/contexts/context.compute.js.map +1 -0
- package/dist/src/contexts/context.scope.d.ts +139 -0
- package/dist/src/contexts/context.scope.js +48 -0
- package/dist/src/contexts/context.scope.js.map +1 -0
- package/dist/src/controllers/controller.action-resolve.d.ts +110 -0
- package/dist/src/controllers/controller.action-resolve.js +203 -0
- package/dist/src/controllers/controller.action-resolve.js.map +1 -0
- package/dist/src/controllers/controller.action-topology.d.ts +59 -0
- package/dist/src/controllers/controller.action-topology.js +130 -0
- package/dist/src/controllers/controller.action-topology.js.map +1 -0
- package/dist/src/controllers/controller.compute.d.ts +72 -0
- package/dist/src/controllers/controller.compute.js +110 -0
- package/dist/src/controllers/controller.compute.js.map +1 -0
- package/dist/src/controllers/controller.resolve.d.ts +78 -0
- package/dist/src/controllers/controller.resolve.js +205 -0
- package/dist/src/controllers/controller.resolve.js.map +1 -0
- package/dist/src/core/action-topology.d.ts +62 -0
- package/dist/src/core/action-topology.js +67 -0
- package/dist/src/core/action-topology.js.map +1 -0
- package/dist/src/core/actions.d.ts +64 -0
- package/dist/src/core/actions.js +47 -0
- package/dist/src/core/actions.js.map +1 -0
- package/dist/src/core/node.element.d.ts +179 -0
- package/dist/src/core/node.element.js +573 -0
- package/dist/src/core/node.element.js.map +1 -0
- package/dist/src/core/node.scope.d.ts +374 -0
- package/dist/src/core/node.scope.js +558 -0
- package/dist/src/core/node.scope.js.map +1 -0
- package/dist/src/core/option-update.d.ts +11 -0
- package/dist/src/core/option-update.js +59 -0
- package/dist/src/core/option-update.js.map +1 -0
- package/dist/src/dsl/compilers/array/compiler.js +13 -14
- package/dist/src/dsl/compilers/array/compiler.js.map +1 -1
- package/dist/src/dsl/compilers/boolean/compiler.d.ts +1 -1
- package/dist/src/dsl/compilers/boolean/compiler.js +14 -27
- package/dist/src/dsl/compilers/boolean/compiler.js.map +1 -1
- package/dist/src/dsl/compilers/enum/compiler.js +7 -10
- package/dist/src/dsl/compilers/enum/compiler.js.map +1 -1
- package/dist/src/dsl/compilers/index.d.ts +1 -1
- package/dist/src/dsl/compilers/index.js +5 -5
- package/dist/src/dsl/compilers/index.js.map +1 -1
- package/dist/src/dsl/utilty.d.ts +0 -4
- package/dist/src/dsl/utilty.js +3 -30
- package/dist/src/dsl/utilty.js.map +1 -1
- package/dist/src/eta/batch.d.ts +123 -0
- package/dist/src/eta/batch.js +162 -0
- package/dist/src/eta/batch.js.map +1 -0
- package/dist/src/eta/batcher.d.ts +184 -0
- package/dist/src/eta/batcher.js +335 -0
- package/dist/src/eta/batcher.js.map +1 -0
- package/dist/src/eta/cache.d.ts +36 -0
- package/dist/src/eta/cache.js +56 -0
- package/dist/src/eta/cache.js.map +1 -0
- package/dist/src/eta/controller.d.ts +608 -0
- package/dist/src/eta/controller.js +1036 -0
- package/dist/src/eta/controller.js.map +1 -0
- package/dist/src/eta/factory.d.ts +74 -0
- package/dist/src/eta/factory.js +121 -0
- package/dist/src/eta/factory.js.map +1 -0
- package/dist/src/eta/idle.d.ts +39 -0
- package/dist/src/eta/idle.js +52 -0
- package/dist/src/eta/idle.js.map +1 -0
- package/dist/src/eta/index.d.ts +52 -0
- package/dist/src/eta/index.js +13 -0
- package/dist/src/eta/index.js.map +1 -0
- package/dist/src/eta/observer.d.ts +263 -0
- package/dist/src/eta/observer.js +263 -0
- package/dist/src/eta/observer.js.map +1 -0
- package/dist/src/eta/operations.d.ts +41 -0
- package/dist/src/eta/operations.js +59 -0
- package/dist/src/eta/operations.js.map +1 -0
- package/dist/src/eta/source-registry.d.ts +198 -0
- package/dist/src/eta/source-registry.js +267 -0
- package/dist/src/eta/source-registry.js.map +1 -0
- package/dist/src/eta/template-index.d.ts +285 -0
- package/dist/src/eta/template-index.js +642 -0
- package/dist/src/eta/template-index.js.map +1 -0
- package/dist/src/eta/types.d.ts +529 -0
- package/dist/src/eta/types.js +2 -0
- package/dist/src/eta/types.js.map +1 -0
- package/dist/src/index.d.ts +21 -9
- package/dist/src/index.js +22 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/nodes/node.context.d.ts +5 -3
- package/dist/src/nodes/node.context.js +48 -3
- package/dist/src/nodes/node.context.js.map +1 -1
- package/dist/src/nodes/node.option.d.ts +11 -31
- package/dist/src/nodes/node.option.js +158 -222
- package/dist/src/nodes/node.option.js.map +1 -1
- package/dist/src/nodes/node.product.d.ts +7 -11
- package/dist/src/nodes/node.product.js +85 -64
- package/dist/src/nodes/node.product.js.map +1 -1
- package/dist/src/renders/attributes/buyLink.d.ts +2 -2
- package/dist/src/renders/attributes/buyLink.js +14 -11
- package/dist/src/renders/attributes/buyLink.js.map +1 -1
- package/dist/src/renders/attributes/devices.d.ts +2 -2
- package/dist/src/renders/attributes/devices.js +9 -19
- package/dist/src/renders/attributes/devices.js.map +1 -1
- package/dist/src/renders/attributes/discount.d.ts +2 -2
- package/dist/src/renders/attributes/discount.js +56 -44
- package/dist/src/renders/attributes/discount.js.map +1 -1
- package/dist/src/renders/attributes/hide.d.ts +2 -2
- package/dist/src/renders/attributes/hide.js +49 -14
- package/dist/src/renders/attributes/hide.js.map +1 -1
- package/dist/src/renders/attributes/index.d.ts +3 -3
- package/dist/src/renders/attributes/index.js +2 -4
- package/dist/src/renders/attributes/index.js.map +1 -1
- package/dist/src/renders/attributes/price.d.ts +2 -2
- package/dist/src/renders/attributes/price.js +30 -44
- package/dist/src/renders/attributes/price.js.map +1 -1
- package/dist/src/renders/attributes/subscription.d.ts +2 -2
- package/dist/src/renders/attributes/subscription.js +14 -20
- package/dist/src/renders/attributes/subscription.js.map +1 -1
- package/dist/src/renders/attributes/utilty.d.ts +2 -0
- package/dist/src/renders/attributes/utilty.js +17 -4
- package/dist/src/renders/attributes/utilty.js.map +1 -1
- package/dist/src/renders/context.d.ts +122 -10
- package/dist/src/renders/context.js +140 -80
- package/dist/src/renders/context.js.map +1 -1
- package/dist/src/renders/format.js +2 -2
- package/dist/src/renders/format.js.map +1 -1
- package/dist/src/renders/index.d.ts +6 -2
- package/dist/src/renders/index.js +67 -29
- package/dist/src/renders/index.js.map +1 -1
- package/dist/src/renders/observe.d.ts +1 -4
- package/dist/src/renders/observe.js +10 -24
- package/dist/src/renders/observe.js.map +1 -1
- package/dist/src/renders/render.wrapper.d.ts +37 -0
- package/dist/src/renders/render.wrapper.js +147 -0
- package/dist/src/renders/render.wrapper.js.map +1 -0
- package/dist/src/templating/eta.js +1 -4
- package/dist/src/templating/eta.js.map +1 -1
- package/package.json +4 -5
- package/dist/src/actions/action.button.d.ts +0 -2
- package/dist/src/actions/action.button.js +0 -8
- package/dist/src/actions/action.button.js.map +0 -1
- package/dist/src/actions/action.input.d.ts +0 -2
- package/dist/src/actions/action.input.js +0 -43
- package/dist/src/actions/action.input.js.map +0 -1
- package/dist/src/actions/action.select.d.ts +0 -2
- package/dist/src/actions/action.select.js +0 -14
- package/dist/src/actions/action.select.js.map +0 -1
- package/dist/src/actions/utilty.d.ts +0 -16
- package/dist/src/actions/utilty.js +0 -149
- package/dist/src/actions/utilty.js.map +0 -1
- package/dist/src/contexts/context.datalayer.d.ts +0 -9
- package/dist/src/contexts/context.datalayer.js +0 -3
- package/dist/src/contexts/context.datalayer.js.map +0 -1
- package/dist/src/contexts/context.derived.d.ts +0 -12
- package/dist/src/contexts/context.derived.js +0 -3
- package/dist/src/contexts/context.derived.js.map +0 -1
- package/dist/src/contexts/context.option.d.ts +0 -5
- package/dist/src/contexts/context.option.js +0 -3
- package/dist/src/contexts/context.option.js.map +0 -1
- package/dist/src/contexts/context.product.d.ts +0 -5
- package/dist/src/contexts/context.product.js +0 -3
- package/dist/src/contexts/context.product.js.map +0 -1
- package/dist/src/contexts/context.state.d.ts +0 -28
- package/dist/src/contexts/context.state.js +0 -3
- package/dist/src/contexts/context.state.js.map +0 -1
- package/dist/src/contexts/context.store.d.ts +0 -5
- package/dist/src/contexts/context.store.js +0 -3
- package/dist/src/contexts/context.store.js.map +0 -1
- package/dist/src/controllers/collect-controller.d.ts +0 -39
- package/dist/src/controllers/collect-controller.js +0 -161
- package/dist/src/controllers/collect-controller.js.map +0 -1
- package/dist/src/controllers/compute-controller.d.ts +0 -55
- package/dist/src/controllers/compute-controller.js +0 -350
- package/dist/src/controllers/compute-controller.js.map +0 -1
- package/dist/src/controllers/eta-renderer/eta-dom-renderer.d.ts +0 -25
- package/dist/src/controllers/eta-renderer/eta-dom-renderer.js +0 -192
- package/dist/src/controllers/eta-renderer/eta-dom-renderer.js.map +0 -1
- package/dist/src/controllers/eta-renderer/eta-mutation-observer.d.ts +0 -28
- package/dist/src/controllers/eta-renderer/eta-mutation-observer.js +0 -206
- package/dist/src/controllers/eta-renderer/eta-mutation-observer.js.map +0 -1
- package/dist/src/controllers/eta-renderer/eta-renderer.d.ts +0 -21
- package/dist/src/controllers/eta-renderer/eta-renderer.js +0 -77
- package/dist/src/controllers/eta-renderer/eta-renderer.js.map +0 -1
- package/dist/src/controllers/eta-renderer/eta-template-cache.d.ts +0 -24
- package/dist/src/controllers/eta-renderer/eta-template-cache.js +0 -61
- package/dist/src/controllers/eta-renderer/eta-template-cache.js.map +0 -1
- package/dist/src/controllers/eta-renderer/eta-types.d.ts +0 -11
- package/dist/src/controllers/eta-renderer/eta-types.js +0 -1
- package/dist/src/controllers/eta-renderer/eta-types.js.map +0 -1
- package/dist/src/controllers/eta-renderer/index.d.ts +0 -2
- package/dist/src/controllers/eta-renderer/index.js +0 -2
- package/dist/src/controllers/eta-renderer/index.js.map +0 -1
- package/dist/src/controllers/event-pipeline-controller.d.ts +0 -28
- package/dist/src/controllers/event-pipeline-controller.js +0 -72
- package/dist/src/controllers/event-pipeline-controller.js.map +0 -1
- package/dist/src/events/events.d.ts +0 -75
- package/dist/src/events/events.js +0 -78
- package/dist/src/events/events.js.map +0 -1
- package/dist/src/nodes/node.root.d.ts +0 -16
- package/dist/src/nodes/node.root.js +0 -49
- package/dist/src/nodes/node.root.js.map +0 -1
- package/dist/src/nodes/node.state.d.ts +0 -88
- package/dist/src/nodes/node.state.js +0 -330
- package/dist/src/nodes/node.state.js.map +0 -1
- package/dist/src/renders/utility.d.ts +0 -32
- package/dist/src/renders/utility.js +0 -191
- package/dist/src/renders/utility.js.map +0 -1
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type { EtaTemplateIndexOptions, TemplateIndexMutation, TemplateIndexSink, TemplateOperation, TemplateOperationFactory } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The EtaTemplateIndex maintains the set of renderable operations for a
|
|
4
|
+
* scoped boundary.
|
|
5
|
+
*
|
|
6
|
+
* It is Eta-agnostic. Discovery is delegated to a TemplateOperationFactory
|
|
7
|
+
* which returns either an operation or `undefined`. The index simply stores
|
|
8
|
+
* whatever the factory produces and looks it up by node for incremental
|
|
9
|
+
* updates.
|
|
10
|
+
*
|
|
11
|
+
* Three views of the data are kept in sync:
|
|
12
|
+
*
|
|
13
|
+
* - `operations` — a flat Set of operations iterated during render.
|
|
14
|
+
* - `nodeIndex` — a WeakMap from owning node (Element or Text) to the
|
|
15
|
+
* operations that own it, used for O(1) removal.
|
|
16
|
+
* - `attrOps` — a WeakMap from Element to a Map of `attributeName` to the
|
|
17
|
+
* single operation that targets that attribute. Needed because Attr
|
|
18
|
+
* identity is unstable across `setAttribute` calls — looking up by the
|
|
19
|
+
* current Attr reference would never find the previous operation.
|
|
20
|
+
*
|
|
21
|
+
* Boundary handling is configurable through an injected predicate
|
|
22
|
+
* (`EtaTemplateIndexOptions.isBoundaryElement`). The index itself does
|
|
23
|
+
* not own boundary semantics — it asks the host/controller for a
|
|
24
|
+
* decision. That makes boundary detection work consistently across
|
|
25
|
+
* controllers that share the same root but own different indices.
|
|
26
|
+
*
|
|
27
|
+
* Source preservation is delegated to an
|
|
28
|
+
* `EtaTemplateSourceRegistry` so the factory can re-read original
|
|
29
|
+
* template sources after a render has overwritten the DOM value.
|
|
30
|
+
*
|
|
31
|
+
* **Cross-scope source registry limitation.** Each `EtaTemplateIndex`
|
|
32
|
+
* owns the source registry it created in its constructor
|
|
33
|
+
* (`createEtaTemplateSourceRegistry()`). Moving a rendered
|
|
34
|
+
* template node from one scope to another loses the original
|
|
35
|
+
* template source — the destination index's registry has no
|
|
36
|
+
* record of it, so the factory falls back to the live DOM value,
|
|
37
|
+
* which now holds the rendered string rather than the template
|
|
38
|
+
* literal. The destination index cannot recreate the operation
|
|
39
|
+
* without discovering the new template content externally.
|
|
40
|
+
*
|
|
41
|
+
* Applications that need to reparent rendered template nodes
|
|
42
|
+
* across scopes should share a single
|
|
43
|
+
* `EtaTemplateSourceRegistry` between the affected indices.
|
|
44
|
+
* Because the factory is stateless at the call site (the
|
|
45
|
+
* registry is threaded through every call via
|
|
46
|
+
* `TemplateOperationContext`), two indices can share one factory
|
|
47
|
+
* safely — each just passes the shared registry as the
|
|
48
|
+
* `sources` field on every call. The v4 review recommends
|
|
49
|
+
* keeping this limitation documented unless cross-scope DOM
|
|
50
|
+
* moves become a real use case — at which point the
|
|
51
|
+
* index/controller can grow a `sourceRegistry` option that
|
|
52
|
+
* overrides the per-index `createEtaTemplateSourceRegistry()`
|
|
53
|
+
* default.
|
|
54
|
+
*/
|
|
55
|
+
export declare class EtaTemplateIndex<TContext = object> implements Iterable<TemplateOperation<TContext>>, TemplateIndexSink {
|
|
56
|
+
private readonly _operations;
|
|
57
|
+
/**
|
|
58
|
+
* Per-node operation lookup.
|
|
59
|
+
*
|
|
60
|
+
* Reassignable so `clear()` can fully reset the index even though
|
|
61
|
+
* `WeakMap` cannot be cleared. The old map is reclaimed by the GC
|
|
62
|
+
* as soon as no caller holds it.
|
|
63
|
+
*/
|
|
64
|
+
private _nodeIndex;
|
|
65
|
+
/**
|
|
66
|
+
* Per-element, per-attribute-name operation lookup.
|
|
67
|
+
*
|
|
68
|
+
* `Attr` identity is not stable across DOM mutations (`setAttribute`
|
|
69
|
+
* removes the old Attr and inserts a new one), so we cannot key attribute
|
|
70
|
+
* operations by their Attr reference. Instead we key by the owning
|
|
71
|
+
* element + the attribute's qualified name. Each (element, name) pair
|
|
72
|
+
* owns at most one operation because the factory only ever produces one
|
|
73
|
+
* AttributeOperation per attribute.
|
|
74
|
+
*/
|
|
75
|
+
private _attrOps;
|
|
76
|
+
/**
|
|
77
|
+
* Tracks nodes that have at least one operation associated with them.
|
|
78
|
+
*
|
|
79
|
+
* `WeakSet` cannot be iterated and cannot be cleared, so it is
|
|
80
|
+
* reassigned by `clear()`. It only needs `add` / `has` / `delete`,
|
|
81
|
+
* which `WeakSet` supports.
|
|
82
|
+
*/
|
|
83
|
+
private _indexedNodes;
|
|
84
|
+
private readonly factory;
|
|
85
|
+
private readonly options;
|
|
86
|
+
private readonly sources;
|
|
87
|
+
constructor(factory: TemplateOperationFactory<TContext>, options?: EtaTemplateIndexOptions);
|
|
88
|
+
/**
|
|
89
|
+
* Walks the subtree of `root` and indexes every node that contains a
|
|
90
|
+
* template.
|
|
91
|
+
*
|
|
92
|
+
* The walk is implemented by `_addNode`, which descends into
|
|
93
|
+
* descendants and respects the `isBoundaryElement` predicate. The
|
|
94
|
+
* root element is added first so a root element's own attribute
|
|
95
|
+
* templates are indexed even when it has no child nodes.
|
|
96
|
+
*
|
|
97
|
+
* Boundary semantics:
|
|
98
|
+
*
|
|
99
|
+
* - If `root` itself matches `isBoundaryElement`, it is still
|
|
100
|
+
* indexed as the local boundary. Its own attribute templates and
|
|
101
|
+
* its owned descendants are collected.
|
|
102
|
+
* - If a nested element matches `isBoundaryElement`, the walk
|
|
103
|
+
* neither collects the foreign boundary's own attributes nor
|
|
104
|
+
* descends into the foreign boundary's subtree. Outer
|
|
105
|
+
* controllers leave that subtree entirely to the boundary's
|
|
106
|
+
* own controller.
|
|
107
|
+
*
|
|
108
|
+
* ⚠️ **Stable-on-raw-DOM invariant for nested boundaries.**
|
|
109
|
+
* When `initialize` encounters a nested boundary element, the
|
|
110
|
+
* `isBoundaryElement` predicate MUST classify it as a foreign
|
|
111
|
+
* boundary **without** relying on prototype-side state such as
|
|
112
|
+
* `instanceof BdScopedElement` or a runtime brand. The parent
|
|
113
|
+
* index may scan a subtree before a nested custom element has
|
|
114
|
+
* upgraded; in that window the nested element has not yet been
|
|
115
|
+
* augmented with the brand, and a brand-only predicate would
|
|
116
|
+
* fail to classify it as a boundary. No DOM mutation fires when
|
|
117
|
+
* the upgrade completes, so the parent index would keep the
|
|
118
|
+
* wrong operations for the lifetime of the page. Prefer
|
|
119
|
+
* tag-name or marker-attribute checks so the classification is
|
|
120
|
+
* stable from the moment the element is parsed. See
|
|
121
|
+
* `EtaTemplateIndexOptions.isBoundaryElement` for full
|
|
122
|
+
* rationale and example patterns.
|
|
123
|
+
*
|
|
124
|
+
* ⚠️ **Source preservation trust boundary.** `initialize()`
|
|
125
|
+
* assumes external DOM edits have been observed while the
|
|
126
|
+
* index was online. During normal operation the
|
|
127
|
+
* `MutationObserver` keeps the `EtaTemplateSourceRegistry` in
|
|
128
|
+
* sync via `syncTextSource()` / `syncAttributeSource()`. If
|
|
129
|
+
* external code mutates already-rendered template nodes while
|
|
130
|
+
* the controller is disconnected or the index has been cleared
|
|
131
|
+
* (for example between two `clear()` / `initialize()` cycles),
|
|
132
|
+
* the registry can hand back a stale preserved source and the
|
|
133
|
+
* next render will re-emit the old template literal instead of
|
|
134
|
+
* the new DOM value. Callers in that situation should `reset()`
|
|
135
|
+
* (which also clears the source registry) before
|
|
136
|
+
* re-initializing, or otherwise clear the registry themselves.
|
|
137
|
+
*/
|
|
138
|
+
initialize(root: ParentNode): void;
|
|
139
|
+
/**
|
|
140
|
+
* Applies a single mutation to the index.
|
|
141
|
+
*
|
|
142
|
+
* Returns `true` when the index actually changed as a result of
|
|
143
|
+
* the mutation (an operation was added, replaced, or removed);
|
|
144
|
+
* `false` when the mutation was a no-op for this index because
|
|
145
|
+
* the node was outside the root, inside a foreign boundary, or
|
|
146
|
+
* did not contain a template.
|
|
147
|
+
*
|
|
148
|
+
* Mutation semantics:
|
|
149
|
+
*
|
|
150
|
+
* - `add` walks the node and its descendants.
|
|
151
|
+
* - `remove` drops every operation whose owner is the node or one of its
|
|
152
|
+
* descendants.
|
|
153
|
+
* - `attribute` re-runs attribute discovery on a single attribute of an
|
|
154
|
+
* element that is already part of the index.
|
|
155
|
+
* - `text` re-runs text discovery on a text node that is already part
|
|
156
|
+
* of the index.
|
|
157
|
+
*/
|
|
158
|
+
apply(mutation: TemplateIndexMutation): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Drops every operation from the index and forgets every node.
|
|
161
|
+
*
|
|
162
|
+
* Every internal structure — including the `WeakMap` / `WeakSet`
|
|
163
|
+
* instances — is reassigned so the index returns to a fully empty
|
|
164
|
+
* state. The old `WeakMap` / `WeakSet` references become unreachable
|
|
165
|
+
* as soon as `clear()` returns and the GC reclaims them.
|
|
166
|
+
*
|
|
167
|
+
* **Source registry is intentionally preserved.** The
|
|
168
|
+
* `EtaTemplateSourceRegistry` keeps the original template source
|
|
169
|
+
* strings for the live DOM nodes so the factory can re-render the
|
|
170
|
+
* same nodes after a render has overwritten their text / attribute
|
|
171
|
+
* values. Clearing the registry here would make
|
|
172
|
+
* `clear()` + `initialize()` destructive on already-rendered
|
|
173
|
+
* DOM — the next render would see plain text instead of the
|
|
174
|
+
* original template literal. Callers that explicitly want a
|
|
175
|
+
* fully destructive reset should use `reset()` instead, which
|
|
176
|
+
* also clears the source registry.
|
|
177
|
+
*/
|
|
178
|
+
clear(): void;
|
|
179
|
+
/**
|
|
180
|
+
* Fully destructive reset — equivalent to `clear()` plus clearing
|
|
181
|
+
* the `EtaTemplateSourceRegistry`.
|
|
182
|
+
*
|
|
183
|
+
* Use this when the live DOM no longer reflects the original
|
|
184
|
+
* template sources (for example, because external code mutated
|
|
185
|
+
* already-rendered nodes while the index was offline, or the
|
|
186
|
+
* caller is switching to a completely different template set).
|
|
187
|
+
*
|
|
188
|
+
* After `reset()`, the next `initialize(root)` walks the subtree
|
|
189
|
+
* from scratch using whatever is in the DOM at that moment —
|
|
190
|
+
* the registry will not serve a stale preserved source.
|
|
191
|
+
*
|
|
192
|
+
* For normal `clear()` + `initialize()` cycles where the source
|
|
193
|
+
* strings are still valid, prefer `clear()` so the registry
|
|
194
|
+
* survives re-indexing.
|
|
195
|
+
*/
|
|
196
|
+
reset(): void;
|
|
197
|
+
[Symbol.iterator](): Iterator<TemplateOperation<TContext>>;
|
|
198
|
+
/**
|
|
199
|
+
* Number of operations currently held by the index.
|
|
200
|
+
*
|
|
201
|
+
* Useful for tests and diagnostics. The renderer iterates operations
|
|
202
|
+
* directly and does not need this.
|
|
203
|
+
*/
|
|
204
|
+
get size(): number;
|
|
205
|
+
/**
|
|
206
|
+
* Whether the given node has any operation associated with it.
|
|
207
|
+
*
|
|
208
|
+
* Used by the controller to decide if a mutation is interesting.
|
|
209
|
+
*
|
|
210
|
+
* For text nodes this checks whether any operation is keyed on the node.
|
|
211
|
+
* For elements this returns true if the element owns any operation
|
|
212
|
+
* directly (e.g. its attributes) — `hasNode(element)` does NOT imply
|
|
213
|
+
* "this element has been fully indexed", only "this element owns at
|
|
214
|
+
* least one operation".
|
|
215
|
+
*/
|
|
216
|
+
hasNode(node: Node): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Disposes every operation currently held by the index.
|
|
219
|
+
*
|
|
220
|
+
* The default operations are no-ops for dispose, but custom
|
|
221
|
+
* operations may need to release observers. Calling this from the
|
|
222
|
+
* controller's teardown keeps the lifecycle clean.
|
|
223
|
+
*
|
|
224
|
+
* Delegates to `clear()` so disposal and reset happen through one
|
|
225
|
+
* well-defined code path; this also avoids disposing each
|
|
226
|
+
* operation twice.
|
|
227
|
+
*/
|
|
228
|
+
disposeAll(): void;
|
|
229
|
+
/**
|
|
230
|
+
* Returns `true` when `element` matches the configured
|
|
231
|
+
* `isBoundaryElement` predicate AND is a foreign boundary (i.e. is
|
|
232
|
+
* not the index's own root).
|
|
233
|
+
*
|
|
234
|
+
* The root itself is always walked; only nested boundaries stop the
|
|
235
|
+
* traversal.
|
|
236
|
+
*/
|
|
237
|
+
private _isForeignBoundary;
|
|
238
|
+
/**
|
|
239
|
+
* Returns `true` when `node` belongs to this index's root.
|
|
240
|
+
*
|
|
241
|
+
* The walk climbs ancestors looking for either `root` or a foreign
|
|
242
|
+
* boundary. If the walk reaches `root` without hitting a foreign
|
|
243
|
+
* boundary, the node is owned. If the walk hits a foreign boundary
|
|
244
|
+
* first, the node is not owned.
|
|
245
|
+
*
|
|
246
|
+
* When `root` is not configured, the index accepts every mutation
|
|
247
|
+
* it receives — callers that wire a parent observer MUST set
|
|
248
|
+
* `root` to prevent nested-scope leakage.
|
|
249
|
+
*
|
|
250
|
+
* Foreign-boundary element itself: when the target `node` is a
|
|
251
|
+
* boundary element other than the index's own `root`, it is owned
|
|
252
|
+
* by another controller. The check is performed up-front so the
|
|
253
|
+
* ancestor loop only handles descendants and the `current !==
|
|
254
|
+
* node` guard it used to need can go away.
|
|
255
|
+
*/
|
|
256
|
+
private _ownsNode;
|
|
257
|
+
private _addNode;
|
|
258
|
+
private _isIndexed;
|
|
259
|
+
private _collectAttributes;
|
|
260
|
+
/**
|
|
261
|
+
* Removes every operation that targets `node` or one of its descendants.
|
|
262
|
+
*
|
|
263
|
+
* The walk mirrors `_addNode` but does not need to consult the factory.
|
|
264
|
+
* Returns `true` when at least one operation was disposed by the
|
|
265
|
+
* call.
|
|
266
|
+
*/
|
|
267
|
+
private _removeNode;
|
|
268
|
+
private _updateAttribute;
|
|
269
|
+
private _updateText;
|
|
270
|
+
private _addTextOperation;
|
|
271
|
+
private _addAttributeOperation;
|
|
272
|
+
private _removeAttributeOperation;
|
|
273
|
+
/**
|
|
274
|
+
* Removes `operation` from the live `_operations` set and calls its
|
|
275
|
+
* `dispose()` hook.
|
|
276
|
+
*
|
|
277
|
+
* Returns `true` when the operation was actually present and
|
|
278
|
+
* removed, `false` when it had already been removed by a previous
|
|
279
|
+
* path (idempotent removal).
|
|
280
|
+
*
|
|
281
|
+
* Single entry point used by every removal path so the disposal
|
|
282
|
+
* contract is honoured uniformly.
|
|
283
|
+
*/
|
|
284
|
+
private _deleteOperation;
|
|
285
|
+
}
|