@lushly-dev/fast-element 3.0.1-preview.0 → 3.0.1-preview.2

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 (250) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/command/command.api.json +7857 -0
  3. package/dist/context/context.api.json +1084 -0
  4. package/dist/declarative/declarative.api.json +8130 -0
  5. package/dist/definition-schema/definition-schema.api.json +2689 -0
  6. package/dist/di/di.api.json +4945 -0
  7. package/dist/dts/arrays.d.ts +2 -0
  8. package/dist/dts/binding/binding.d.ts +59 -0
  9. package/dist/dts/binding/exports.d.ts +9 -0
  10. package/dist/dts/binding/normalize.d.ts +9 -0
  11. package/dist/dts/binding/one-time.d.ts +11 -0
  12. package/dist/dts/binding/one-way.d.ts +20 -0
  13. package/dist/dts/binding/signal.d.ts +36 -0
  14. package/dist/dts/binding/two-way.d.ts +44 -0
  15. package/dist/dts/command/behavior.d.ts +94 -0
  16. package/dist/dts/command/behaviors/confirm-behavior.d.ts +139 -0
  17. package/dist/dts/command/behaviors/undo-behavior.d.ts +178 -0
  18. package/dist/dts/command/command.d.ts +79 -0
  19. package/dist/dts/command/component-registry.d.ts +50 -0
  20. package/dist/dts/command/components/confirm-dialog.d.ts +117 -0
  21. package/dist/dts/command/index.d.ts +21 -0
  22. package/dist/dts/command/registry.d.ts +201 -0
  23. package/dist/dts/command/schema-validation.d.ts +45 -0
  24. package/dist/dts/command/types.d.ts +332 -0
  25. package/dist/dts/command/validation.d.ts +116 -0
  26. package/dist/dts/command/weak-ref.d.ts +11 -0
  27. package/dist/dts/components/attributes.d.ts +153 -0
  28. package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
  29. package/dist/dts/components/element-controller.d.ts +349 -0
  30. package/dist/dts/components/element-hydration.d.ts +2 -0
  31. package/dist/dts/components/enable-hydration.d.ts +66 -0
  32. package/dist/dts/components/fast-definitions.d.ts +211 -0
  33. package/dist/dts/components/fast-element-registry.d.ts +23 -0
  34. package/dist/dts/components/fast-element.d.ts +91 -0
  35. package/dist/dts/components/hydration-tracker.d.ts +110 -0
  36. package/dist/dts/components/hydration.d.ts +52 -0
  37. package/dist/dts/components/schema.d.ts +205 -0
  38. package/dist/dts/context.d.ts +171 -0
  39. package/dist/dts/debug.d.ts +5 -0
  40. package/dist/dts/declarative/attribute-map.d.ts +58 -0
  41. package/dist/dts/declarative/debug.d.ts +4 -0
  42. package/dist/dts/declarative/index.d.ts +14 -0
  43. package/dist/dts/declarative/interfaces.d.ts +8 -0
  44. package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
  45. package/dist/dts/declarative/observer-map.d.ts +89 -0
  46. package/dist/dts/declarative/runtime.d.ts +5 -0
  47. package/dist/dts/declarative/syntax.d.ts +21 -0
  48. package/dist/dts/declarative/template-bridge.d.ts +33 -0
  49. package/dist/dts/declarative/template-parser.d.ts +98 -0
  50. package/dist/dts/declarative/template.d.ts +9 -0
  51. package/dist/dts/declarative/utilities.d.ts +358 -0
  52. package/dist/dts/definition-schema/api.d.ts +42 -0
  53. package/dist/dts/definition-schema/cem.d.ts +78 -0
  54. package/dist/dts/definition-schema/extension.d.ts +18 -0
  55. package/dist/dts/definition-schema/extract.d.ts +38 -0
  56. package/dist/dts/definition-schema/index.d.ts +9 -0
  57. package/dist/dts/definition-schema/storage.d.ts +35 -0
  58. package/dist/dts/definition-schema/types.d.ts +176 -0
  59. package/dist/dts/dev-mode.d.ts +13 -0
  60. package/dist/dts/di/di.d.ts +894 -0
  61. package/dist/dts/dom-policy.d.ts +101 -0
  62. package/dist/dts/dom.d.ts +88 -0
  63. package/dist/dts/hydration/diagnostics.d.ts +93 -0
  64. package/dist/dts/hydration/exports.d.ts +18 -0
  65. package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
  66. package/dist/dts/hydration/messages.d.ts +62 -0
  67. package/dist/dts/hydration/runtime.d.ts +7 -0
  68. package/dist/dts/hydration/target-builder.d.ts +107 -0
  69. package/dist/dts/index.d.ts +51 -0
  70. package/dist/dts/index.debug.d.ts +1 -0
  71. package/dist/dts/index.rollup.d.ts +1 -0
  72. package/dist/dts/index.rollup.debug.d.ts +1 -0
  73. package/dist/dts/interfaces.d.ts +106 -0
  74. package/dist/dts/metadata.d.ts +26 -0
  75. package/dist/dts/observation/arrays.d.ts +248 -0
  76. package/dist/dts/observation/notifier.d.ts +127 -0
  77. package/dist/dts/observation/observable.d.ts +276 -0
  78. package/dist/dts/observation/update-queue.d.ts +40 -0
  79. package/dist/dts/observation/volatile.d.ts +9 -0
  80. package/dist/dts/platform.d.ts +87 -0
  81. package/dist/dts/registry.d.ts +2 -0
  82. package/dist/dts/render.d.ts +7 -0
  83. package/dist/dts/schema.d.ts +1 -0
  84. package/dist/dts/scoped/detection.d.ts +55 -0
  85. package/dist/dts/scoped/index.d.ts +68 -0
  86. package/dist/dts/scoped/mixin.d.ts +118 -0
  87. package/dist/dts/scoped/registry.d.ts +76 -0
  88. package/dist/dts/scoped/types.d.ts +48 -0
  89. package/dist/dts/state/exports.d.ts +3 -0
  90. package/dist/dts/state/reactive.d.ts +8 -0
  91. package/dist/dts/state/state.d.ts +141 -0
  92. package/dist/dts/state/visitor.d.ts +6 -0
  93. package/dist/dts/state/watch.d.ts +10 -0
  94. package/dist/dts/styles/css-directive.d.ts +50 -0
  95. package/dist/dts/styles/css.d.ts +34 -0
  96. package/dist/dts/styles/element-styles.d.ts +61 -0
  97. package/dist/dts/styles/host.d.ts +65 -0
  98. package/dist/dts/styles/style-strategy.d.ts +42 -0
  99. package/dist/dts/templating/children.d.ts +62 -0
  100. package/dist/dts/templating/compiler.d.ts +54 -0
  101. package/dist/dts/templating/html-binding-directive.d.ts +155 -0
  102. package/dist/dts/templating/html-directive.d.ts +218 -0
  103. package/dist/dts/templating/html.d.ts +1 -0
  104. package/dist/dts/templating/hydration-view.d.ts +130 -0
  105. package/dist/dts/templating/markup.d.ts +48 -0
  106. package/dist/dts/templating/node-observation.d.ts +99 -0
  107. package/dist/dts/templating/ref.d.ts +23 -0
  108. package/dist/dts/templating/render.d.ts +318 -0
  109. package/dist/dts/templating/repeat.d.ts +131 -0
  110. package/dist/dts/templating/slotted.d.ts +38 -0
  111. package/dist/dts/templating/template.d.ts +221 -0
  112. package/dist/dts/templating/view.d.ts +268 -0
  113. package/dist/dts/templating/when.d.ts +12 -0
  114. package/dist/dts/testing/exports.d.ts +3 -0
  115. package/dist/dts/testing/fakes.d.ts +16 -0
  116. package/dist/dts/testing/fixture.d.ts +84 -0
  117. package/dist/dts/testing/models.d.ts +20 -0
  118. package/dist/dts/testing/timeout.d.ts +7 -0
  119. package/dist/dts/trust/index.d.ts +8 -0
  120. package/dist/dts/trust/types.d.ts +48 -0
  121. package/dist/dts/trust/utils.d.ts +26 -0
  122. package/dist/dts/tsdoc-metadata.json +11 -0
  123. package/dist/dts/utilities.d.ts +76 -0
  124. package/dist/esm/arrays.js +1 -0
  125. package/dist/esm/binding/binding.js +18 -0
  126. package/dist/esm/binding/exports.js +6 -0
  127. package/dist/esm/binding/normalize.js +17 -0
  128. package/dist/esm/binding/one-time.js +21 -0
  129. package/dist/esm/binding/one-way.js +30 -0
  130. package/dist/esm/binding/signal.js +99 -0
  131. package/dist/esm/binding/two-way.js +109 -0
  132. package/dist/esm/command/behavior.js +155 -0
  133. package/dist/esm/command/behaviors/confirm-behavior.js +225 -0
  134. package/dist/esm/command/behaviors/undo-behavior.js +313 -0
  135. package/dist/esm/command/command.js +104 -0
  136. package/dist/esm/command/component-registry.js +107 -0
  137. package/dist/esm/command/components/confirm-dialog.js +370 -0
  138. package/dist/esm/command/index.js +22 -0
  139. package/dist/esm/command/registry.js +755 -0
  140. package/dist/esm/command/schema-validation.js +194 -0
  141. package/dist/esm/command/types.js +86 -0
  142. package/dist/esm/command/validation.js +508 -0
  143. package/dist/esm/command/weak-ref.js +5 -0
  144. package/dist/esm/components/attributes.js +219 -0
  145. package/dist/esm/components/definition-schema-transforms.js +23 -0
  146. package/dist/esm/components/element-controller.js +840 -0
  147. package/dist/esm/components/element-hydration.js +2 -0
  148. package/dist/esm/components/enable-hydration.js +123 -0
  149. package/dist/esm/components/fast-definitions.js +294 -0
  150. package/dist/esm/components/fast-element-registry.js +67 -0
  151. package/dist/esm/components/fast-element.js +82 -0
  152. package/dist/esm/components/hydration-tracker.js +211 -0
  153. package/dist/esm/components/hydration.js +187 -0
  154. package/dist/esm/components/schema.js +253 -0
  155. package/dist/esm/context.js +185 -0
  156. package/dist/esm/debug.js +71 -0
  157. package/dist/esm/declarative/attribute-map.js +122 -0
  158. package/dist/esm/declarative/debug.js +4 -0
  159. package/dist/esm/declarative/index.js +10 -0
  160. package/dist/esm/declarative/interfaces.js +9 -0
  161. package/dist/esm/declarative/observer-map-utilities.js +565 -0
  162. package/dist/esm/declarative/observer-map.js +216 -0
  163. package/dist/esm/declarative/runtime.js +14 -0
  164. package/dist/esm/declarative/syntax.js +36 -0
  165. package/dist/esm/declarative/template-bridge.js +160 -0
  166. package/dist/esm/declarative/template-parser.js +306 -0
  167. package/dist/esm/declarative/template.js +116 -0
  168. package/dist/esm/declarative/utilities.js +1069 -0
  169. package/dist/esm/definition-schema/api.js +129 -0
  170. package/dist/esm/definition-schema/cem.js +89 -0
  171. package/dist/esm/definition-schema/extension.js +53 -0
  172. package/dist/esm/definition-schema/extract.js +167 -0
  173. package/dist/esm/definition-schema/index.js +8 -0
  174. package/dist/esm/definition-schema/storage.js +58 -0
  175. package/dist/esm/definition-schema/types.js +8 -0
  176. package/dist/esm/dev-mode.js +22 -0
  177. package/dist/esm/di/di.js +1441 -0
  178. package/dist/esm/dom-policy.js +374 -0
  179. package/dist/esm/dom.js +101 -0
  180. package/dist/esm/hydration/diagnostics.js +50 -0
  181. package/dist/esm/hydration/exports.js +6 -0
  182. package/dist/esm/hydration/hydration-debugger.js +112 -0
  183. package/dist/esm/hydration/messages.js +84 -0
  184. package/dist/esm/hydration/runtime.js +33 -0
  185. package/dist/esm/hydration/target-builder.js +264 -0
  186. package/dist/esm/index.debug.js +3 -0
  187. package/dist/esm/index.js +49 -0
  188. package/dist/esm/index.rollup.debug.js +6 -0
  189. package/dist/esm/index.rollup.js +4 -0
  190. package/dist/esm/interfaces.js +55 -0
  191. package/dist/esm/metadata.js +57 -0
  192. package/dist/esm/observation/arrays.js +661 -0
  193. package/dist/esm/observation/notifier.js +162 -0
  194. package/dist/esm/observation/observable.js +324 -0
  195. package/dist/esm/observation/update-queue.js +56 -0
  196. package/dist/esm/observation/volatile.js +16 -0
  197. package/dist/esm/platform.js +98 -0
  198. package/dist/esm/registry.js +2 -0
  199. package/dist/esm/render.js +1 -0
  200. package/dist/esm/schema.js +1 -0
  201. package/dist/esm/scoped/detection.js +102 -0
  202. package/dist/esm/scoped/index.js +69 -0
  203. package/dist/esm/scoped/mixin.js +127 -0
  204. package/dist/esm/scoped/registry.js +125 -0
  205. package/dist/esm/scoped/types.js +4 -0
  206. package/dist/esm/state/exports.js +3 -0
  207. package/dist/esm/state/reactive.js +34 -0
  208. package/dist/esm/state/state.js +148 -0
  209. package/dist/esm/state/visitor.js +28 -0
  210. package/dist/esm/state/watch.js +36 -0
  211. package/dist/esm/styles/css-directive.js +36 -0
  212. package/dist/esm/styles/css.js +56 -0
  213. package/dist/esm/styles/element-styles.js +144 -0
  214. package/dist/esm/styles/host.js +1 -0
  215. package/dist/esm/styles/style-strategy.js +1 -0
  216. package/dist/esm/templating/children.js +67 -0
  217. package/dist/esm/templating/compiler.js +359 -0
  218. package/dist/esm/templating/html-binding-directive.js +288 -0
  219. package/dist/esm/templating/html-directive.js +113 -0
  220. package/dist/esm/templating/html.js +1 -0
  221. package/dist/esm/templating/hydration-view.js +228 -0
  222. package/dist/esm/templating/markup.js +83 -0
  223. package/dist/esm/templating/node-observation.js +84 -0
  224. package/dist/esm/templating/ref.js +21 -0
  225. package/dist/esm/templating/render.js +468 -0
  226. package/dist/esm/templating/repeat.js +434 -0
  227. package/dist/esm/templating/slotted.js +49 -0
  228. package/dist/esm/templating/template.js +206 -0
  229. package/dist/esm/templating/view.js +298 -0
  230. package/dist/esm/templating/when.js +22 -0
  231. package/dist/esm/testing/exports.js +3 -0
  232. package/dist/esm/testing/fakes.js +107 -0
  233. package/dist/esm/testing/fixture.js +86 -0
  234. package/dist/esm/testing/models.js +58 -0
  235. package/dist/esm/testing/timeout.js +24 -0
  236. package/dist/esm/trust/index.js +7 -0
  237. package/dist/esm/trust/types.js +6 -0
  238. package/dist/esm/trust/utils.js +126 -0
  239. package/dist/esm/utilities.js +140 -0
  240. package/dist/fast-element.api.json +26798 -0
  241. package/dist/fast-element.d.ts +3985 -0
  242. package/dist/fast-element.debug.js +7604 -0
  243. package/dist/fast-element.debug.min.js +3 -0
  244. package/dist/fast-element.js +7603 -0
  245. package/dist/fast-element.min.js +3 -0
  246. package/dist/fast-element.untrimmed.d.ts +4103 -0
  247. package/dist/observation/arrays/arrays.api.json +2621 -0
  248. package/dist/scoped/scoped.api.json +891 -0
  249. package/dist/trust/trust.api.json +629 -0
  250. package/package.json +21 -23
@@ -0,0 +1,155 @@
1
+ import type { Binding, BindingDirective } from "../binding/binding.js";
2
+ import { DOMAspect } from "../dom.js";
3
+ import type { DOMPolicy } from "../dom-policy.js";
4
+ import { ExecutionContext, type Expression, type ExpressionObserver } from "../observation/observable.js";
5
+ import { type AddViewBehaviorFactory, type Aspected, HTMLDirective, type ViewBehavior, type ViewBehaviorFactory, type ViewController } from "./html-directive.js";
6
+ /**
7
+ * A simple View that can be interpolated into HTML content.
8
+ * @public
9
+ */
10
+ export interface ContentView {
11
+ readonly context: ExecutionContext;
12
+ /**
13
+ * Binds a view's behaviors to its binding source.
14
+ * @param source - The binding source for the view's binding behaviors.
15
+ * @param context - The execution context to run the view within.
16
+ */
17
+ bind(source: any, context?: ExecutionContext): void;
18
+ /**
19
+ * Unbinds a view's behaviors from its binding source and context.
20
+ */
21
+ unbind(): void;
22
+ /**
23
+ * Inserts the view's DOM nodes before the referenced node.
24
+ * @param node - The node to insert the view's DOM before.
25
+ */
26
+ insertBefore(node: Node): void;
27
+ /**
28
+ * Removes the view's DOM nodes.
29
+ * The nodes are not disposed and the view can later be re-inserted.
30
+ */
31
+ remove(): void;
32
+ }
33
+ /**
34
+ * A simple template that can create ContentView instances.
35
+ * @public
36
+ */
37
+ export interface ContentTemplate {
38
+ /**
39
+ * Creates a simple content view instance.
40
+ */
41
+ create(): ContentView;
42
+ }
43
+ /**
44
+ * A template capable of hydrating content from existing DOM nodes.
45
+ * @beta
46
+ */
47
+ export interface HydratableContentTemplate extends ContentTemplate {
48
+ /**
49
+ * Hydrates a content view from first/last nodes.
50
+ */
51
+ hydrate(first: Node, last: Node): ContentView;
52
+ }
53
+ /**
54
+ * The central binding directive that bridges data expressions and DOM updates.
55
+ *
56
+ * HTMLBindingDirective fulfills three roles simultaneously:
57
+ * - **HTMLDirective**: Produces placeholder HTML via createHTML() during template authoring.
58
+ * - **ViewBehaviorFactory**: Creates behaviors (returns itself) during view creation.
59
+ * - **ViewBehavior / EventListener**: Attaches to a DOM node during bind, manages
60
+ * expression observers for reactive updates, and handles DOM events directly.
61
+ *
62
+ * The aspectType (set by HTMLDirective.assignAspect during template processing)
63
+ * determines which DOM "sink" function is used to apply values — e.g.,
64
+ * setAttribute for attributes, addEventListener for events, textContent for content.
65
+ *
66
+ * @public
67
+ */
68
+ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective {
69
+ private data;
70
+ private updateTarget;
71
+ /**
72
+ * The unique id of the factory.
73
+ */
74
+ id: string;
75
+ /**
76
+ * The structural id of the DOM node to which the created behavior will apply.
77
+ */
78
+ targetNodeId: string;
79
+ /**
80
+ * The tagname associated with the target node.
81
+ */
82
+ targetTagName: string | null;
83
+ /**
84
+ * The policy that the created behavior must run under.
85
+ */
86
+ policy: DOMPolicy;
87
+ /**
88
+ * The original source aspect exactly as represented in markup.
89
+ */
90
+ sourceAspect: string;
91
+ /**
92
+ * The evaluated target aspect, determined after processing the source.
93
+ */
94
+ targetAspect: string;
95
+ /**
96
+ * The type of aspect to target.
97
+ */
98
+ aspectType: DOMAspect;
99
+ /**
100
+ * The binding configuration to apply.
101
+ */
102
+ dataBinding: Binding;
103
+ /**
104
+ * Creates an instance of HTMLBindingDirective.
105
+ * @param dataBinding - The binding configuration to apply.
106
+ */
107
+ constructor(dataBinding: Binding);
108
+ /**
109
+ * Creates HTML to be used within a template.
110
+ * @param add - Can be used to add behavior factories to a template.
111
+ */
112
+ createHTML(add: AddViewBehaviorFactory): string;
113
+ /**
114
+ * Creates a behavior.
115
+ */
116
+ createBehavior(): ViewBehavior;
117
+ /**
118
+ * Attaches this binding to its target DOM node.
119
+ * - For events: stores the controller reference on the target element and registers
120
+ * this directive as the EventListener via addEventListener. The directive's
121
+ * handleEvent() method will be called when the event fires.
122
+ * - For content bindings: registers an unbind handler, then falls through to the
123
+ * default path.
124
+ * - For all non-event bindings: creates (or reuses) an ExpressionObserver, evaluates
125
+ * the binding expression, and applies the result to the DOM via the updateTarget
126
+ * sink function. The observer will call handleChange() on future data changes.
127
+ * @internal
128
+ */
129
+ bind(controller: ViewController): void;
130
+ /** @internal */
131
+ unbind(controller: ViewController): void;
132
+ /**
133
+ * Implements the EventListener interface. When a DOM event fires on the target
134
+ * element, this method retrieves the ViewController stored on the element,
135
+ * sets the event on the ExecutionContext so `c.event` is available to the
136
+ * binding expression, and evaluates the expression. If the expression returns
137
+ * anything other than `true`, the event's default action is prevented.
138
+ * @internal
139
+ */
140
+ handleEvent(event: Event): void;
141
+ /**
142
+ * Called by the ExpressionObserver when a tracked dependency changes.
143
+ * Re-evaluates the binding expression via observer.bind() and pushes
144
+ * the new value to the DOM through the updateTarget sink function.
145
+ * This is the reactive update path that keeps the DOM in sync with data.
146
+ *
147
+ * Guards against stale notifications: when a view is unbound (e.g., after
148
+ * a parent `when` directive tears down a child element), coupled-lifetime
149
+ * observers may still hold active subscriptions. If a property change fires
150
+ * on the source element while the view is inactive, this guard prevents
151
+ * the binding expression from evaluating with a null source.
152
+ * @internal
153
+ */
154
+ handleChange(binding: Expression, observer: ExpressionObserver): void;
155
+ }
@@ -0,0 +1,218 @@
1
+ import type { Binding } from "../binding/binding.js";
2
+ import { DOMAspect } from "../dom.js";
3
+ import type { DOMPolicy } from "../dom-policy.js";
4
+ import type { Constructable } from "../interfaces.js";
5
+ import type { ExpressionController } from "../observation/observable.js";
6
+ /**
7
+ * The target nodes available to a behavior.
8
+ * @public
9
+ */
10
+ export type ViewBehaviorTargets = {
11
+ [id: string]: Node;
12
+ };
13
+ /**
14
+ * Controls the lifecycle of a view and provides relevant context.
15
+ * @public
16
+ */
17
+ export interface ViewController<TSource = any, TParent = any> extends ExpressionController<TSource, TParent> {
18
+ /**
19
+ * The parts of the view that are targeted by view behaviors.
20
+ */
21
+ readonly targets: ViewBehaviorTargets;
22
+ /**
23
+ * When true, directives skip attribute/booleanAttribute DOM
24
+ * updates during bind(). This is an internal flag set only
25
+ * during the prerendered bind window.
26
+ * @internal
27
+ */
28
+ readonly _skipAttrUpdates?: boolean;
29
+ /**
30
+ * The shadow root whose scoped custom element registry the view's elements
31
+ * were created against. Directives pass it on when they create child views.
32
+ * @internal
33
+ */
34
+ readonly _scope?: ShadowRoot;
35
+ /**
36
+ * Resolves `true` when the view's host element had prerendered
37
+ * content (existing shadow root).
38
+ */
39
+ readonly isPrerendered?: Promise<boolean>;
40
+ /**
41
+ * Resolves `true` after prerendered content has been hydrated,
42
+ * `false` when client-side rendered or hydration not enabled.
43
+ */
44
+ readonly isHydrated?: Promise<boolean>;
45
+ }
46
+ /**
47
+ * Represents an object that can contribute behavior to a view.
48
+ * @public
49
+ */
50
+ export interface ViewBehavior<TSource = any, TParent = any> {
51
+ /**
52
+ * Bind this behavior.
53
+ * @param controller - The view controller that manages the lifecycle of this behavior.
54
+ */
55
+ bind(controller: ViewController<TSource, TParent>): void;
56
+ }
57
+ /**
58
+ * A factory that can create a {@link ViewBehavior} associated with a particular
59
+ * location within a DOM fragment.
60
+ * @public
61
+ */
62
+ export interface ViewBehaviorFactory {
63
+ /**
64
+ * The unique id of the factory.
65
+ */
66
+ id?: string;
67
+ /**
68
+ * The structural id of the DOM node to which the created behavior will apply.
69
+ */
70
+ targetNodeId?: string;
71
+ /**
72
+ * The tag name of the DOM node to which the created behavior will apply.
73
+ */
74
+ targetTagName?: string | null;
75
+ /**
76
+ * The policy that the created behavior must run under.
77
+ */
78
+ policy?: DOMPolicy;
79
+ /**
80
+ * Creates a behavior.
81
+ */
82
+ createBehavior(): ViewBehavior;
83
+ }
84
+ /**
85
+ * Represents a ViewBehaviorFactory after the compilation process has completed.
86
+ * @public
87
+ */
88
+ export type CompiledViewBehaviorFactory = Required<ViewBehaviorFactory>;
89
+ /**
90
+ * Used to add behavior factories when constructing templates.
91
+ * @public
92
+ */
93
+ export type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
94
+ /**
95
+ * Instructs the template engine to apply behavior to a node.
96
+ * @public
97
+ */
98
+ export interface HTMLDirective {
99
+ /**
100
+ * Creates HTML to be used within a template.
101
+ * @param add - Can be used to add behavior factories to a template.
102
+ */
103
+ createHTML(add: AddViewBehaviorFactory): string;
104
+ }
105
+ /**
106
+ * Represents something that applies to a specific aspect of the DOM.
107
+ * @public
108
+ */
109
+ export interface Aspected {
110
+ /**
111
+ * The original source aspect exactly as represented in markup.
112
+ */
113
+ sourceAspect: string;
114
+ /**
115
+ * The evaluated target aspect, determined after processing the source.
116
+ */
117
+ targetAspect: string;
118
+ /**
119
+ * The type of aspect to target.
120
+ */
121
+ aspectType: DOMAspect;
122
+ /**
123
+ * A binding if one is associated with the aspect.
124
+ */
125
+ dataBinding?: Binding;
126
+ }
127
+ /**
128
+ * Represents metadata configuration for an HTMLDirective.
129
+ * @public
130
+ */
131
+ export interface PartialHTMLDirectiveDefinition {
132
+ /**
133
+ * Indicates whether the directive needs access to template contextual information
134
+ * such as the sourceAspect, targetAspect, and aspectType.
135
+ */
136
+ aspected?: boolean;
137
+ }
138
+ /**
139
+ * Defines metadata for an HTMLDirective.
140
+ * @public
141
+ */
142
+ export interface HTMLDirectiveDefinition<TType extends Constructable<HTMLDirective> = Constructable<HTMLDirective>> extends Required<PartialHTMLDirectiveDefinition> {
143
+ /**
144
+ * The type that the definition provides metadata for.
145
+ */
146
+ readonly type: TType;
147
+ }
148
+ /**
149
+ * Instructs the template engine to apply behavior to a node.
150
+ * @public
151
+ */
152
+ export declare const HTMLDirective: Readonly<{
153
+ /**
154
+ * Gets the directive definition associated with the instance.
155
+ * @param instance - The directive instance to retrieve the definition for.
156
+ */
157
+ getForInstance: (object: any) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
158
+ /**
159
+ * Gets the directive definition associated with the specified type.
160
+ * @param type - The directive type to retrieve the definition for.
161
+ */
162
+ getByType: (key: Function) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
163
+ /**
164
+ * Defines an HTMLDirective based on the options.
165
+ * @param type - The type to define as a directive.
166
+ * @param options - Options that specify the directive's application.
167
+ */
168
+ define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
169
+ /**
170
+ * Determines the DOM aspect type for a directive based on attribute name prefix.
171
+ * The prefix convention maps to aspect types as follows:
172
+ * - No prefix (e.g. "class") → DOMAspect.attribute
173
+ * - ":" prefix (e.g. ":value") → DOMAspect.property (":classList" → DOMAspect.tokenList)
174
+ * - "?" prefix (e.g. "?disabled") → DOMAspect.booleanAttribute
175
+ * - `@` prefix (e.g. `@click`) → DOMAspect.event
176
+ * - Falsy or absent value → DOMAspect.content (see remarks)
177
+ * @param directive - The directive to assign the aspect to.
178
+ * @param value - The value to base the aspect determination on.
179
+ * @remarks
180
+ * If a falsy value is provided, then the content aspect will be assigned.
181
+ */
182
+ assignAspect(directive: Aspected, value?: string): void;
183
+ }>;
184
+ /**
185
+ * Decorator: Defines an HTMLDirective.
186
+ * @param options - Provides options that specify the directive's application.
187
+ * @public
188
+ */
189
+ export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
190
+ /**
191
+ * A base class used for attribute directives that don't need internal state.
192
+ * @public
193
+ */
194
+ export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
195
+ protected options: TOptions;
196
+ /**
197
+ * Creates an instance of RefDirective.
198
+ * @param options - The options to use in configuring the directive.
199
+ */
200
+ constructor(options: TOptions);
201
+ /**
202
+ * Creates a placeholder string based on the directive's index within the template.
203
+ * @param index - The index of the directive within the template.
204
+ * @remarks
205
+ * Creates a custom attribute placeholder.
206
+ */
207
+ createHTML(add: AddViewBehaviorFactory): string;
208
+ /**
209
+ * Creates a behavior.
210
+ * @param targets - The targets available for behaviors to be attached to.
211
+ */
212
+ createBehavior(): ViewBehavior;
213
+ /**
214
+ * Bind this behavior.
215
+ * @param controller - The view controller that manages the lifecycle of this behavior.
216
+ */
217
+ abstract bind(controller: ViewController): void;
218
+ }
@@ -0,0 +1 @@
1
+ export { html } from "./template.js";
@@ -0,0 +1,130 @@
1
+ import { Hydratable } from "../components/hydration.js";
2
+ import { type HydrationMismatchActual, type HydrationMismatchExpectation } from "../hydration/diagnostics.js";
3
+ import { type ViewBehaviorBoundaries } from "../hydration/target-builder.js";
4
+ import { type ExecutionContext, SourceLifetime } from "../observation/observable.js";
5
+ import type { ViewTemplate } from "../templating/template.js";
6
+ import type { ViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
7
+ import { DefaultExecutionContext, type ElementView, type SyntheticView } from "./view.js";
8
+ /** @public */
9
+ export interface HydratableView<TSource = any, TParent = any> extends ElementView<TSource, TParent>, SyntheticView<TSource, TParent>, DefaultExecutionContext<TParent> {
10
+ [Hydratable]: symbol;
11
+ readonly bindingViewBoundaries: Record<string, ViewNodes>;
12
+ readonly hydrationStage: keyof typeof HydrationStage;
13
+ }
14
+ /**
15
+ * A view controller that can hydrate existing DOM nodes.
16
+ * @beta
17
+ */
18
+ export type HydratableViewController<TSource = any, TParent = any> = HydratableView<TSource, TParent> & ViewController<TSource, TParent>;
19
+ /** @public */
20
+ export interface ViewNodes {
21
+ first: Node;
22
+ last: Node;
23
+ }
24
+ /** @public */
25
+ export declare const HydrationStage: {
26
+ readonly unhydrated: "unhydrated";
27
+ readonly hydrating: "hydrating";
28
+ readonly hydrated: "hydrated";
29
+ };
30
+ /** @public */
31
+ export declare class HydrationBindingError extends Error {
32
+ /**
33
+ * The factory that was unable to be bound
34
+ */
35
+ readonly factory: ViewBehaviorFactory;
36
+ /**
37
+ * A DocumentFragment containing a clone of the
38
+ * view's Nodes.
39
+ */
40
+ readonly fragment: DocumentFragment;
41
+ /**
42
+ * String representation of the HTML in the template that
43
+ * threw the binding error.
44
+ */
45
+ readonly templateString: string;
46
+ /**
47
+ * Structured description of the binding the hydration walk was
48
+ * attempting to apply when the mismatch was detected.
49
+ */
50
+ readonly expected?: HydrationMismatchExpectation | undefined;
51
+ /**
52
+ * Structured description of the server-rendered DOM that was
53
+ * encountered at the mismatch point.
54
+ */
55
+ readonly received?: HydrationMismatchActual | undefined;
56
+ constructor(
57
+ /**
58
+ * The error message
59
+ */
60
+ message: string | undefined,
61
+ /**
62
+ * The factory that was unable to be bound
63
+ */
64
+ factory: ViewBehaviorFactory,
65
+ /**
66
+ * A DocumentFragment containing a clone of the
67
+ * view's Nodes.
68
+ */
69
+ fragment: DocumentFragment,
70
+ /**
71
+ * String representation of the HTML in the template that
72
+ * threw the binding error.
73
+ */
74
+ templateString: string,
75
+ /**
76
+ * Structured description of the binding the hydration walk was
77
+ * attempting to apply when the mismatch was detected.
78
+ */
79
+ expected?: HydrationMismatchExpectation | undefined,
80
+ /**
81
+ * Structured description of the server-rendered DOM that was
82
+ * encountered at the mismatch point.
83
+ */
84
+ received?: HydrationMismatchActual | undefined);
85
+ }
86
+ export declare class HydrationView<TSource = any, TParent = any> extends DefaultExecutionContext<TParent> implements HydratableView {
87
+ readonly firstChild: Node;
88
+ readonly lastChild: Node;
89
+ private sourceTemplate;
90
+ private hostBindingTarget?;
91
+ [Hydratable]: symbol;
92
+ context: ExecutionContext<any>;
93
+ source: TSource | null;
94
+ isBound: boolean;
95
+ get hydrationStage(): "hydrated" | "hydrating" | "unhydrated";
96
+ get targets(): ViewBehaviorTargets;
97
+ get bindingViewBoundaries(): ViewBehaviorBoundaries;
98
+ readonly sourceLifetime: SourceLifetime;
99
+ private unbindables;
100
+ private fragment;
101
+ private behaviors;
102
+ private factories;
103
+ private _hydrationStage;
104
+ private _bindingViewBoundaries;
105
+ private _targets;
106
+ constructor(firstChild: Node, lastChild: Node, sourceTemplate: ViewTemplate, hostBindingTarget?: Element | undefined);
107
+ /**
108
+ * no-op. Hydrated views are don't need to be moved from a documentFragment
109
+ * to the target node.
110
+ */
111
+ insertBefore(node: Node): void;
112
+ /**
113
+ * Appends the view to a node. In cases where this is called before the
114
+ * view has been removed, the method will no-op.
115
+ * @param node - the node to append the view to.
116
+ */
117
+ appendTo(node: Node): void;
118
+ remove(): void;
119
+ bind(source: TSource, context?: ExecutionContext<any>): void;
120
+ unbind(): void;
121
+ /**
122
+ * Removes the view and unbinds its behaviors, disposing of DOM nodes afterward.
123
+ * Once a view has been disposed, it cannot be inserted or bound again.
124
+ */
125
+ dispose(): void;
126
+ onUnbind(behavior: {
127
+ unbind(controller: ViewController<TSource, TParent>): void;
128
+ }): void;
129
+ private evaluateUnbindables;
130
+ }
@@ -0,0 +1,48 @@
1
+ import type { ViewBehaviorFactory } from "./html-directive.js";
2
+ /** @internal */
3
+ export declare const nextId: () => string;
4
+ /**
5
+ * Common APIs related to markup generation.
6
+ * @public
7
+ */
8
+ export declare const Markup: Readonly<{
9
+ /**
10
+ * Creates a placeholder string suitable for marking out a location *within*
11
+ * an attribute value or HTML content.
12
+ * @param index - The directive index to create the placeholder for.
13
+ * @remarks
14
+ * Used internally by binding directives.
15
+ */
16
+ interpolation: (id: string) => string;
17
+ /**
18
+ * Creates a placeholder that manifests itself as an attribute on an
19
+ * element.
20
+ * @param attributeName - The name of the custom attribute.
21
+ * @param index - The directive index to create the placeholder for.
22
+ * @remarks
23
+ * Used internally by attribute directives such as `ref`, `slotted`, and `children`.
24
+ */
25
+ attribute: (id: string) => string;
26
+ /**
27
+ * Creates a placeholder that manifests itself as a marker within the DOM structure.
28
+ * @param index - The directive index to create the placeholder for.
29
+ * @remarks
30
+ * Used internally by structural directives such as `repeat`.
31
+ */
32
+ comment: (id: string) => string;
33
+ }>;
34
+ /**
35
+ * Common APIs related to content parsing.
36
+ * @public
37
+ */
38
+ export declare const Parser: Readonly<{
39
+ /**
40
+ * Parses text content or HTML attribute content, separating out the static strings
41
+ * from the directives.
42
+ * @param value - The content or attribute string to parse.
43
+ * @param factories - A list of directives to search for in the string.
44
+ * @returns A heterogeneous array of static strings interspersed with
45
+ * directives or null if no directives are found in the string.
46
+ */
47
+ parse(value: string, factories: Record<string, ViewBehaviorFactory>): (string | ViewBehaviorFactory)[] | null;
48
+ }>;
@@ -0,0 +1,99 @@
1
+ import { StatelessAttachedAttributeDirective, type ViewController } from "./html-directive.js";
2
+ /**
3
+ * Options for configuring node observation behavior.
4
+ * @public
5
+ */
6
+ export interface NodeBehaviorOptions<T = any> {
7
+ /**
8
+ * The property to assign the observed nodes to.
9
+ */
10
+ property: T;
11
+ /**
12
+ * Filters nodes that are synced with the property.
13
+ * Called one time for each element in the array.
14
+ * @param value - The Node that is being inspected.
15
+ * @param index - The index of the node within the array.
16
+ * @param array - The Node array that is being filtered.
17
+ */
18
+ filter?: ElementsFilter;
19
+ }
20
+ /**
21
+ * Elements filter function type.
22
+ *
23
+ * @public
24
+ */
25
+ export type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
26
+ /**
27
+ * Creates a function that can be used to filter a Node array, selecting only elements.
28
+ * @param selector - An optional selector to restrict the filter to.
29
+ * @public
30
+ */
31
+ export declare const elements: (selector?: string) => ElementsFilter;
32
+ /**
33
+ * A base class for node observation.
34
+ * @public
35
+ * @remarks
36
+ * Internally used by the SlottedDirective and the ChildrenDirective.
37
+ */
38
+ export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
39
+ private _id;
40
+ private _controllerProperty;
41
+ /**
42
+ * The unique id of the factory.
43
+ */
44
+ get id(): string;
45
+ set id(value: string);
46
+ /**
47
+ * The structural id of the DOM node to which the created behavior will apply.
48
+ */
49
+ targetNodeId: string;
50
+ /**
51
+ * Bind this behavior to the source.
52
+ * @param source - The source to bind to.
53
+ * @param context - The execution context that the binding is operating within.
54
+ * @param targets - The targets that behaviors in a view can attach to.
55
+ */
56
+ bind(controller: ViewController): void;
57
+ /**
58
+ * Unbinds this behavior from the source.
59
+ * @param source - The source to unbind from.
60
+ * @param context - The execution context that the binding is operating within.
61
+ * @param targets - The targets that behaviors in a view can attach to.
62
+ */
63
+ unbind(controller: ViewController): void;
64
+ /**
65
+ * Gets the data source for the target.
66
+ * @param target - The target to get the source for.
67
+ * @returns The source.
68
+ */
69
+ protected getSource(target: Node): any;
70
+ /**
71
+ * Updates the source property with the computed nodes.
72
+ * @param source - The source object to assign the nodes property to.
73
+ * @param value - The nodes to assign to the source object property.
74
+ */
75
+ protected updateTarget(source: any, value: ReadonlyArray<any>): void;
76
+ /**
77
+ * Computes the set of nodes that should be assigned to the source property.
78
+ * @param target - The target to compute the nodes for.
79
+ * @returns The computed nodes.
80
+ * @remarks
81
+ * Applies filters if provided.
82
+ */
83
+ protected computeNodes(target: any): Node[];
84
+ /**
85
+ * Begins observation of the nodes.
86
+ * @param target - The target to observe.
87
+ */
88
+ protected abstract observe(target: any): void;
89
+ /**
90
+ * Disconnects observation of the nodes.
91
+ * @param target - The target to unobserve.
92
+ */
93
+ protected abstract disconnect(target: any): void;
94
+ /**
95
+ * Retrieves the raw nodes that should be assigned to the source property.
96
+ * @param target - The target to get the node to.
97
+ */
98
+ protected abstract getNodes(target: any): Node[];
99
+ }
@@ -0,0 +1,23 @@
1
+ import { StatelessAttachedAttributeDirective, type ViewController } from "./html-directive.js";
2
+ import type { CaptureType } from "./template.js";
3
+ /**
4
+ * The runtime behavior for template references.
5
+ * @public
6
+ */
7
+ export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
8
+ /**
9
+ * The structural id of the DOM node to which the created behavior will apply.
10
+ */
11
+ targetNodeId: string;
12
+ /**
13
+ * Bind this behavior.
14
+ * @param controller - The view controller that manages the lifecycle of this behavior.
15
+ */
16
+ bind(controller: ViewController): void;
17
+ }
18
+ /**
19
+ * A directive that observes the updates a property with a reference to the element.
20
+ * @param propertyName - The name of the property to assign the reference to.
21
+ * @public
22
+ */
23
+ export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;