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

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 +6 -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 +15 -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 +110 -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 +312 -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 +752 -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 +511 -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 +839 -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 +210 -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 +121 -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 +1440 -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 +63 -0
  192. package/dist/esm/observation/arrays.js +661 -0
  193. package/dist/esm/observation/notifier.js +164 -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 +7618 -0
  243. package/dist/fast-element.debug.min.js +3 -0
  244. package/dist/fast-element.js +7617 -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 +12 -12
@@ -0,0 +1,221 @@
1
+ import { Binding } from "../binding/binding.js";
2
+ import type { DOMPolicy } from "../dom-policy.js";
3
+ import type { Expression } from "../observation/observable.js";
4
+ import { type AddViewBehaviorFactory, type CompiledViewBehaviorFactory, HTMLDirective, type ViewBehaviorFactory } from "./html-directive.js";
5
+ import type { ElementView, HTMLView, SyntheticView } from "./view.js";
6
+ /**
7
+ * A template capable of creating views specifically for rendering custom elements.
8
+ * @public
9
+ */
10
+ export interface ElementViewTemplate<TSource = any, TParent = any> {
11
+ /**
12
+ * Creates an ElementView instance based on this template definition.
13
+ * @param hostBindingTarget - The element that host behaviors will be bound to.
14
+ * @param scope - The shadow root whose scoped custom element registry child
15
+ * elements should be created against, when it has one.
16
+ */
17
+ create(hostBindingTarget: Element, scope?: ShadowRoot): ElementView<TSource, TParent>;
18
+ /**
19
+ * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
20
+ * @param source - The data source to bind the template to.
21
+ * @param host - The Element where the template will be rendered.
22
+ * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
23
+ * host that the template is being attached to.
24
+ * @param scope - The shadow root whose scoped custom element registry child
25
+ * elements should be created against, when it has one.
26
+ */
27
+ render(source: TSource, host: Node, hostBindingTarget?: Element, scope?: ShadowRoot): ElementView<TSource, TParent>;
28
+ }
29
+ /**
30
+ * A template capable of hydrating an element view from existing DOM nodes.
31
+ * @beta
32
+ */
33
+ export interface HydratableElementViewTemplate<TSource = any, TParent = any> extends ElementViewTemplate<TSource, TParent> {
34
+ hydrate(firstChild: Node, lastChild: Node, hostBindingTarget?: Element): ElementView<TSource, TParent>;
35
+ }
36
+ /**
37
+ * A marker interface used to capture types when interpolating Directive helpers
38
+ * into templates.
39
+ * @public
40
+ */
41
+ export interface CaptureType<TSource = any, TParent = any> {
42
+ }
43
+ /**
44
+ * A template capable of rendering views not specifically connected to custom elements.
45
+ * @public
46
+ */
47
+ export interface SyntheticViewTemplate<TSource = any, TParent = any> {
48
+ /**
49
+ * Creates a SyntheticView instance based on this template definition.
50
+ */
51
+ create(): SyntheticView<TSource, TParent>;
52
+ /**
53
+ * Returns a directive that can inline the template.
54
+ */
55
+ inline(): CaptureType<TSource, TParent>;
56
+ }
57
+ /**
58
+ * A template capable of hydrating a synthetic view from existing DOM nodes.
59
+ * @beta
60
+ */
61
+ export interface HydratableSyntheticViewTemplate<TSource = any, TParent = any> extends SyntheticViewTemplate {
62
+ hydrate(firstChild: Node, lastChild: Node): SyntheticView<TSource, TParent>;
63
+ }
64
+ /**
65
+ * The result of a template compilation operation.
66
+ * @public
67
+ */
68
+ export interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
69
+ /**
70
+ * Creates a view instance.
71
+ * @param hostBindingTarget - The host binding target for the view.
72
+ * @param scope - The shadow root whose scoped custom element registry the view's
73
+ * elements should be created against, when it has one.
74
+ */
75
+ createView(hostBindingTarget?: Element, scope?: ShadowRoot): HTMLView<TSource, TParent>;
76
+ readonly factories: CompiledViewBehaviorFactory[];
77
+ }
78
+ /**
79
+ * Represents the types of values that can be interpolated into a template.
80
+ * @public
81
+ */
82
+ export type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
83
+ /**
84
+ * Inlines a template into another template.
85
+ * @public
86
+ */
87
+ export declare class InlineTemplateDirective implements HTMLDirective {
88
+ private html;
89
+ private factories;
90
+ /**
91
+ * An empty template partial.
92
+ */
93
+ static readonly empty: InlineTemplateDirective;
94
+ /**
95
+ * Creates an instance of InlineTemplateDirective.
96
+ * @param template - The template to inline.
97
+ */
98
+ constructor(html: string, factories?: Record<string, ViewBehaviorFactory>);
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
+ * A template capable of creating HTMLView instances or rendering directly to DOM.
107
+ * @public
108
+ */
109
+ export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
110
+ private policy?;
111
+ private result;
112
+ /**
113
+ * The html representing what this template will
114
+ * instantiate, including placeholders for directives.
115
+ */
116
+ readonly html: string | HTMLTemplateElement;
117
+ /**
118
+ * The directives that will be connected to placeholders in the html.
119
+ */
120
+ readonly factories: Record<string, ViewBehaviorFactory>;
121
+ /**
122
+ * Creates an instance of ViewTemplate.
123
+ * @param html - The html representing what this template will instantiate, including placeholders for directives.
124
+ * @param factories - The directives that will be connected to placeholders in the html.
125
+ * @param policy - The security policy to use when compiling this template.
126
+ */
127
+ constructor(html: string | HTMLTemplateElement, factories?: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy | undefined);
128
+ /**
129
+ * @internal
130
+ */
131
+ compile(): HTMLTemplateCompilationResult<TSource, TParent>;
132
+ /**
133
+ * Returns a directive that can inline the template.
134
+ */
135
+ inline(): CaptureType<TSource, TParent>;
136
+ /**
137
+ * Sets the DOMPolicy for this template.
138
+ * @param policy - The policy to associated with this template.
139
+ * @returns The modified template instance.
140
+ * @remarks
141
+ * The DOMPolicy can only be set once for a template and cannot be
142
+ * set after the template is compiled.
143
+ */
144
+ withPolicy(policy: DOMPolicy): this;
145
+ /**
146
+ * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
147
+ * @param source - The data source to bind the template to.
148
+ * @param host - The Element where the template will be rendered.
149
+ * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
150
+ * host that the template is being attached to.
151
+ * @param scope - The shadow root whose scoped custom element registry child
152
+ * elements should be created against, when it has one.
153
+ */
154
+ render(source: TSource, host: Node, hostBindingTarget?: Element, scope?: ShadowRoot): HTMLView<TSource, TParent>;
155
+ /**
156
+ * Creates an HTMLView instance based on this template definition.
157
+ * @param hostBindingTarget - The element that host behaviors will be bound to.
158
+ * @param scope - The shadow root whose scoped custom element registry child
159
+ * elements should be created against, when it has one.
160
+ */
161
+ create(hostBindingTarget?: Element, scope?: ShadowRoot): HTMLView<TSource, TParent>;
162
+ /**
163
+ * Processes the tagged template literal's static strings and interpolated values and
164
+ * creates a ViewTemplate.
165
+ *
166
+ * For each interpolated value:
167
+ * 1. Functions (binding expressions, e.g., `x => x.name`) → wrapped in a one-way HTMLBindingDirective
168
+ * 2. Binding instances → wrapped in an HTMLBindingDirective
169
+ * 3. HTMLDirective instances → used as-is
170
+ * 4. Static values (strings, numbers) → wrapped in a one-time HTMLBindingDirective
171
+ *
172
+ * Each directive's createHTML() is called with an `add` callback that registers
173
+ * the factory in the factories record under a unique ID and returns that ID.
174
+ * The directive inserts a placeholder marker (e.g., `fast-abc123{0}fast-abc123`) into
175
+ * the HTML string so the compiler can later find and associate it with the factory.
176
+ *
177
+ * Aspect detection happens here too: the `lastAttributeNameRegex` checks whether
178
+ * the placeholder appears inside an attribute value, and if so, assignAspect()
179
+ * sets the correct DOMAspect (attribute, property, event, etc.) based on the
180
+ * attribute name prefix.
181
+ *
182
+ * @param strings - The static strings to create the template with.
183
+ * @param values - The dynamic values to create the template with.
184
+ * @param policy - The DOMPolicy to associated with the template.
185
+ * @returns A ViewTemplate.
186
+ * @remarks
187
+ * This API should not be used directly under normal circumstances because constructing
188
+ * a template in this way, if not done properly, can open up the application to XSS
189
+ * attacks. When using this API, provide a strong DOMPolicy that can properly sanitize
190
+ * and also be sure to manually sanitize all static strings particularly if they can
191
+ * come from user input.
192
+ */
193
+ static create<TSource = any, TParent = any>(strings: string[], values: TemplateValue<TSource, TParent>[], policy?: DOMPolicy): ViewTemplate<TSource, TParent>;
194
+ }
195
+ /**
196
+ * Transforms a template literal string into a ViewTemplate.
197
+ * @param strings - The string fragments that are interpolated with the values.
198
+ * @param values - The values that are interpolated with the string fragments.
199
+ * @remarks
200
+ * The html helper supports interpolation of strings, numbers, binding expressions,
201
+ * other template instances, and Directive instances.
202
+ * @public
203
+ */
204
+ export type HTMLTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]) => ViewTemplate<TSource, TParent>) & {
205
+ /**
206
+ * Transforms a template literal string into partial HTML.
207
+ * @param html - The HTML string fragment to interpolate.
208
+ * @public
209
+ */
210
+ partial(html: string): InlineTemplateDirective;
211
+ };
212
+ /**
213
+ * Transforms a template literal string into a ViewTemplate.
214
+ * @param strings - The string fragments that are interpolated with the values.
215
+ * @param values - The values that are interpolated with the string fragments.
216
+ * @remarks
217
+ * The html helper supports interpolation of strings, numbers, binding expressions,
218
+ * other template instances, and Directive instances.
219
+ * @public
220
+ */
221
+ export declare const html: HTMLTemplateTag;
@@ -0,0 +1,268 @@
1
+ import type { Disposable } from "../interfaces.js";
2
+ import { ExecutionContext, SourceLifetime } from "../observation/observable.js";
3
+ import type { CompiledViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
4
+ /**
5
+ * Represents a collection of DOM nodes which can be bound to a data source.
6
+ * @public
7
+ */
8
+ export interface View<TSource = any, TParent = any> extends Disposable {
9
+ /**
10
+ * The execution context the view is running within.
11
+ */
12
+ readonly context: ExecutionContext<TParent>;
13
+ /**
14
+ * The data that the view is bound to.
15
+ */
16
+ readonly source: TSource | null;
17
+ /**
18
+ * Indicates whether the controller is bound.
19
+ */
20
+ readonly isBound: boolean;
21
+ /**
22
+ * Binds a view's behaviors to its binding source.
23
+ * @param source - The binding source for the view's binding behaviors.
24
+ */
25
+ bind(source: TSource, context?: ExecutionContext<TParent>): void;
26
+ /**
27
+ * Unbinds a view's behaviors from its binding source and context.
28
+ */
29
+ unbind(): void;
30
+ }
31
+ /**
32
+ * A View representing DOM nodes specifically for rendering the view of a custom element.
33
+ * @public
34
+ */
35
+ export interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent> {
36
+ /**
37
+ * Indicates how the source's lifetime relates to the controller's lifetime.
38
+ */
39
+ readonly sourceLifetime?: SourceLifetime;
40
+ /**
41
+ * Registers an unbind handler with the controller.
42
+ * @param behavior - An object to call when the controller unbinds.
43
+ */
44
+ onUnbind(behavior: {
45
+ unbind(controller: ViewController<TSource, TParent>): any;
46
+ }): void;
47
+ /**
48
+ * Appends the view's DOM nodes to the referenced node.
49
+ * @param node - The parent node to append the view's DOM nodes to.
50
+ */
51
+ appendTo(node: Node): void;
52
+ }
53
+ /**
54
+ * A view representing a range of DOM nodes which can be added/removed ad hoc.
55
+ * @public
56
+ */
57
+ export interface SyntheticView<TSource = any, TParent = any> extends View<TSource, TParent> {
58
+ /**
59
+ * The first DOM node in the range of nodes that make up the view.
60
+ */
61
+ readonly firstChild: Node;
62
+ /**
63
+ * The last DOM node in the range of nodes that make up the view.
64
+ */
65
+ readonly lastChild: Node;
66
+ /**
67
+ * Inserts the view's DOM nodes before the referenced node.
68
+ * @param node - The node to insert the view's DOM before.
69
+ */
70
+ insertBefore(node: Node): void;
71
+ /**
72
+ * Removes the view's DOM nodes.
73
+ * The nodes are not disposed and the view can later be re-inserted.
74
+ */
75
+ remove(): void;
76
+ }
77
+ /**
78
+ * Creates a child view from a template on behalf of a directive, carrying over the
79
+ * scoped custom element registry scope of the parent view (if it has one).
80
+ * For views without a scope this is exactly `template.create()`.
81
+ * @internal
82
+ */
83
+ export declare function createChildView<TView>(template: {
84
+ create(): TView;
85
+ }, controller: {
86
+ readonly _scope?: ShadowRoot;
87
+ }): TView;
88
+ export declare function removeNodeSequence(firstNode: Node, lastNode: Node): void;
89
+ /**
90
+ * The default execution context for template views.
91
+ * @public
92
+ */
93
+ export declare class DefaultExecutionContext<TParent> implements ExecutionContext<TParent> {
94
+ /**
95
+ * The index of the current item within a repeat context.
96
+ */
97
+ index: number;
98
+ /**
99
+ * The length of the current collection within a repeat context.
100
+ */
101
+ length: number;
102
+ /**
103
+ * The parent data source within a nested context.
104
+ */
105
+ readonly parent: TParent;
106
+ /**
107
+ * The parent execution context when in nested context scenarios.
108
+ */
109
+ readonly parentContext: ExecutionContext<TParent>;
110
+ /**
111
+ * The current event within an event handler.
112
+ */
113
+ get event(): Event;
114
+ /**
115
+ * Indicates whether the current item within a repeat context
116
+ * has an even index.
117
+ */
118
+ get isEven(): boolean;
119
+ /**
120
+ * Indicates whether the current item within a repeat context
121
+ * has an odd index.
122
+ */
123
+ get isOdd(): boolean;
124
+ /**
125
+ * Indicates whether the current item within a repeat context
126
+ * is the first item in the collection.
127
+ */
128
+ get isFirst(): boolean;
129
+ /**
130
+ * Indicates whether the current item within a repeat context
131
+ * is somewhere in the middle of the collection.
132
+ */
133
+ get isInMiddle(): boolean;
134
+ /**
135
+ * Indicates whether the current item within a repeat context
136
+ * is the last item in the collection.
137
+ */
138
+ get isLast(): boolean;
139
+ /**
140
+ * Returns the typed event detail of a custom event.
141
+ */
142
+ eventDetail<TDetail>(): TDetail;
143
+ /**
144
+ * Returns the typed event target of the event.
145
+ */
146
+ eventTarget<TTarget extends EventTarget>(): TTarget;
147
+ }
148
+ /**
149
+ * The standard View implementation, which also implements ElementView and SyntheticView.
150
+ * @public
151
+ */
152
+ export declare class HTMLView<TSource = any, TParent = any> extends DefaultExecutionContext<TParent> implements ElementView<TSource, TParent>, SyntheticView<TSource, TParent>, ExecutionContext<TParent> {
153
+ private fragment;
154
+ private factories;
155
+ readonly targets: ViewBehaviorTargets;
156
+ /**
157
+ * The shadow root whose scoped custom element registry this view's
158
+ * elements were created against, if any. Child views inherit it.
159
+ * @internal
160
+ */
161
+ readonly _scope?: ShadowRoot | undefined;
162
+ private behaviors;
163
+ private unbindables;
164
+ /**
165
+ * The data that the view is bound to.
166
+ */
167
+ source: TSource | null;
168
+ /**
169
+ * Indicates whether the controller is bound.
170
+ */
171
+ isBound: boolean;
172
+ /**
173
+ * Indicates how the source's lifetime relates to the controller's lifetime.
174
+ */
175
+ readonly sourceLifetime: SourceLifetime;
176
+ /**
177
+ * When true, directives skip attribute/booleanAttribute DOM
178
+ * updates during bind(). Set only during the prerendered bind
179
+ * window and cleared immediately after.
180
+ * @internal
181
+ */
182
+ _skipAttrUpdates: boolean;
183
+ /**
184
+ * A promise that resolves with `true` after prerendered content
185
+ * has been hydrated, or `false` when the view is client-side
186
+ * rendered. Resolves once the first bind completes.
187
+ */
188
+ isPrerendered: Promise<boolean>;
189
+ /**
190
+ * Resolves `true` after prerendered content has been hydrated,
191
+ * `false` when client-side rendered or hydration not enabled.
192
+ */
193
+ isHydrated: Promise<boolean>;
194
+ /**
195
+ * The execution context the view is running within.
196
+ */
197
+ context: ExecutionContext<TParent>;
198
+ /**
199
+ * The first DOM node in the range of nodes that make up the view.
200
+ */
201
+ firstChild: Node;
202
+ /**
203
+ * The last DOM node in the range of nodes that make up the view.
204
+ */
205
+ lastChild: Node;
206
+ /**
207
+ * Constructs an instance of HTMLView.
208
+ * @param fragment - The html fragment that contains the nodes for this view.
209
+ * @param behaviors - The behaviors to be applied to this view.
210
+ */
211
+ constructor(fragment: DocumentFragment, factories: ReadonlyArray<CompiledViewBehaviorFactory>, targets: ViewBehaviorTargets,
212
+ /**
213
+ * The shadow root whose scoped custom element registry this view's
214
+ * elements were created against, if any. Child views inherit it.
215
+ * @internal
216
+ */
217
+ _scope?: ShadowRoot | undefined);
218
+ /**
219
+ * Appends the view's DOM nodes to the referenced node.
220
+ * @param node - The parent node to append the view's DOM nodes to.
221
+ */
222
+ appendTo(node: Node): void;
223
+ /**
224
+ * Inserts the view's DOM nodes before the referenced node.
225
+ * @param node - The node to insert the view's DOM before.
226
+ */
227
+ insertBefore(node: Node): void;
228
+ /**
229
+ * Removes the view's DOM nodes.
230
+ * The nodes are not disposed and the view can later be re-inserted.
231
+ */
232
+ remove(): void;
233
+ /**
234
+ * Removes the view and unbinds its behaviors, disposing of DOM nodes afterward.
235
+ * Once a view has been disposed, it cannot be inserted or bound again.
236
+ */
237
+ dispose(): void;
238
+ onUnbind(behavior: {
239
+ unbind(controller: ViewController<TSource, TParent>): void;
240
+ }): void;
241
+ /**
242
+ * Binds a view's behaviors to its binding source.
243
+ *
244
+ * On the first call, this iterates through all compiled factories, calling
245
+ * createBehavior() on each to produce a ViewBehavior instance (e.g., an
246
+ * HTMLBindingDirective), and then immediately binds it. This is where event
247
+ * listeners are registered, expression observers are created, and initial
248
+ * DOM values are set.
249
+ *
250
+ * On subsequent calls with a new source, existing behaviors are re-bound
251
+ * to the new data source, which re-evaluates all binding expressions and
252
+ * updates the DOM accordingly.
253
+ *
254
+ * @param source - The binding source for the view's binding behaviors.
255
+ * @param context - The execution context to run the behaviors within.
256
+ */
257
+ bind(source: TSource, context?: ExecutionContext<TParent>): void;
258
+ /**
259
+ * Unbinds a view's behaviors from its binding source.
260
+ */
261
+ unbind(): void;
262
+ private evaluateUnbindables;
263
+ /**
264
+ * Efficiently disposes of a contiguous range of synthetic view instances.
265
+ * @param views - A contiguous range of views to be disposed.
266
+ */
267
+ static disposeContiguousBatch(views: SyntheticView[]): void;
268
+ }
@@ -0,0 +1,12 @@
1
+ import type { Expression } from "../observation/observable.js";
2
+ import type { CaptureType, SyntheticViewTemplate } from "./template.js";
3
+ /**
4
+ * A directive that enables basic conditional rendering in a template.
5
+ * @param condition - The condition to test for rendering.
6
+ * @param templateOrTemplateBinding - The template or a binding that gets
7
+ * the template to render when the condition is true.
8
+ * @param elseTemplateOrTemplateBinding - Optional template or binding that that
9
+ * gets the template to render when the conditional is false.
10
+ * @public
11
+ */
12
+ export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>, elseTemplateOrTemplateBinding?: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;
@@ -0,0 +1,3 @@
1
+ export * from "./fakes.js";
2
+ export * from "./fixture.js";
3
+ export { timeout } from "./timeout.js";
@@ -0,0 +1,15 @@
1
+ import { ExecutionContext } from "../observation/observable.js";
2
+ import type { ViewBehavior, ViewBehaviorTargets } from "../templating/html-directive.js";
3
+ export declare const Fake: Readonly<{
4
+ executionContext<TParent = any>(parent?: TParent, parentContext?: ExecutionContext<TParent>): ExecutionContext<TParent>;
5
+ viewController<TSource = any, TParent = any>(targets?: ViewBehaviorTargets, ...behaviors: ViewBehavior<TSource, TParent>[]): {
6
+ isBound: boolean;
7
+ context: ExecutionContext<TParent>;
8
+ onUnbind(object: any): void;
9
+ source: TSource;
10
+ targets: ViewBehaviorTargets;
11
+ toJSON: () => undefined;
12
+ bind(source: TSource, context?: ExecutionContext<TParent>): void;
13
+ unbind(): void;
14
+ };
15
+ }>;
@@ -0,0 +1,84 @@
1
+ import type { Constructable } from "../interfaces.js";
2
+ import { ViewTemplate } from "../templating/template.js";
3
+ import type { HTMLView } from "../templating/view.js";
4
+ /**
5
+ * Options used to customize the creation of the test fixture.
6
+ * @public
7
+ */
8
+ export interface FixtureOptions {
9
+ /**
10
+ * The document to run the fixture in.
11
+ * @defaultValue `globalThis.document`
12
+ */
13
+ document?: Document;
14
+ /**
15
+ * The parent element to append the fixture to.
16
+ * @defaultValue An instance of `HTMLDivElement`.
17
+ */
18
+ parent?: HTMLElement;
19
+ /**
20
+ * The data source to bind the HTML to.
21
+ * @defaultValue An empty object.
22
+ */
23
+ source?: any;
24
+ }
25
+ /**
26
+ * A test fixture.
27
+ * @public
28
+ */
29
+ export interface Fixture<TElement = HTMLElement> {
30
+ /**
31
+ * The document the fixture is running in.
32
+ */
33
+ document: Document;
34
+ /**
35
+ * The template the fixture was created from.
36
+ */
37
+ template: ViewTemplate;
38
+ /**
39
+ * The view that was created from the fixture's template.
40
+ */
41
+ view: HTMLView;
42
+ /**
43
+ * The parent element that the view was appended to.
44
+ * @remarks
45
+ * This element will be appended to the DOM only
46
+ * after {@link Fixture.connect} has been called.
47
+ */
48
+ parent: HTMLElement;
49
+ /**
50
+ * The first element in the {@link Fixture.view}.
51
+ */
52
+ element: TElement;
53
+ /**
54
+ * Adds the {@link Fixture.parent} to the DOM, causing the
55
+ * connect lifecycle to begin.
56
+ * @remarks
57
+ * Yields control to the caller one Microtask later, in order to
58
+ * ensure that the DOM has settled.
59
+ */
60
+ connect: () => Promise<void>;
61
+ /**
62
+ * Removes the {@link Fixture.parent} from the DOM, causing the
63
+ * disconnect lifecycle to begin.
64
+ * @remarks
65
+ * Yields control to the caller one Microtask later, in order to
66
+ * ensure that the DOM has settled.
67
+ */
68
+ disconnect: () => Promise<void>;
69
+ }
70
+ /**
71
+ * Creates a random, unique name suitable for use as a Custom Element name.
72
+ * @public
73
+ */
74
+ export declare function uniqueElementName(prefix?: string): string;
75
+ /**
76
+ * Creates a test fixture suitable for testing custom elements, templates, and bindings.
77
+ * @param templateNameOrType An HTML template or single element name to create the fixture for.
78
+ * @param options Enables customizing fixture creation behavior.
79
+ * @remarks
80
+ * Yields control to the caller one Microtask later, in order to
81
+ * ensure that the DOM has settled.
82
+ * @public
83
+ */
84
+ export declare function fixture<TElement = HTMLElement>(templateNameOrType: ViewTemplate | string | Constructable<TElement>, options?: FixtureOptions): Promise<Fixture<TElement>>;
@@ -0,0 +1,20 @@
1
+ declare class ChildModel {
2
+ value: string;
3
+ }
4
+ declare class Model {
5
+ childChangedCalled: boolean;
6
+ trigger: number;
7
+ value: number;
8
+ child: ChildModel;
9
+ child2: ChildModel;
10
+ childChanged(): void;
11
+ incrementTrigger(): void;
12
+ decrementTrigger(): void;
13
+ get ifConditional(): number;
14
+ }
15
+ declare class DerivedModel extends Model {
16
+ child2ChangedCalled: boolean;
17
+ child2Changed(): void;
18
+ derivedChild: ChildModel;
19
+ }
20
+ export { ChildModel, DerivedModel, Model };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A timeout helper for use in tests.
3
+ * @param timeout The length of the timeout.
4
+ * @returns A promise that resolves once the configured time has elapsed.
5
+ * @public
6
+ */
7
+ export declare function timeout(timeout?: number): Promise<void>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Trust Events - AFD trust signals for component events.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export type { TrustEmitOptions, TrustSignals, Warning, WarningSeverity, } from "./types.js";
7
+ export { TRUST_KEY } from "./types.js";
8
+ export { getTrustSignals, hasTrustSignals } from "./utils.js";