@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,349 @@
1
+ import type { Notifier, Subscriber } from "../observation/notifier.js";
2
+ import { ExecutionContext, type ExpressionController, SourceLifetime } from "../observation/observable.js";
3
+ import { ElementStyles } from "../styles/element-styles.js";
4
+ import type { HostBehavior, HostController } from "../styles/host.js";
5
+ import type { StyleStrategy, StyleTarget } from "../styles/style-strategy.js";
6
+ import type { ElementViewTemplate } from "../templating/template.js";
7
+ import type { ElementView } from "../templating/view.js";
8
+ import type { TrustEmitOptions } from "../trust/types.js";
9
+ import { FASTElementDefinition, type ShadowRootOptions } from "./fast-definitions.js";
10
+ /**
11
+ * Creates an optional behavior for a newly constructed element controller.
12
+ * @internal
13
+ */
14
+ export type ElementControllerBehaviorFactory = (element: HTMLElement) => HostBehavior<HTMLElement> | undefined;
15
+ /**
16
+ * Registers a focused integration hook for optional element behaviors.
17
+ * @param factory - Factory invoked for each new element controller.
18
+ * @returns A callback that removes the factory.
19
+ * @internal
20
+ */
21
+ export declare function registerElementControllerBehaviorFactory(factory: ElementControllerBehaviorFactory): () => void;
22
+ /**
23
+ * A type that instantiates an ElementController
24
+ * @public
25
+ */
26
+ export interface ElementControllerStrategy {
27
+ new (element: HTMLElement, definition: FASTElementDefinition): ElementController;
28
+ }
29
+ /**
30
+ * The various lifecycle stages of an ElementController.
31
+ * @public
32
+ */
33
+ export declare const enum Stages {
34
+ /** The element is in the process of connecting. */
35
+ connecting = 0,
36
+ /** The element is connected. */
37
+ connected = 1,
38
+ /** The element is in the process of disconnecting. */
39
+ disconnecting = 2,
40
+ /** The element is disconnected. */
41
+ disconnected = 3
42
+ }
43
+ /**
44
+ * Controls the lifecycle and rendering of a `FASTElement`.
45
+ * @public
46
+ */
47
+ export declare class ElementController<TElement extends HTMLElement = HTMLElement> implements Notifier, HostController<TElement> {
48
+ /**
49
+ * Internal notifier used to delegate subscriber management.
50
+ */
51
+ private _notifier;
52
+ /**
53
+ * A map of observable properties that were set on the element before upgrade.
54
+ */
55
+ private boundObservables;
56
+ /**
57
+ * Indicates whether the controller needs to perform initial rendering.
58
+ */
59
+ protected needsInitialization: boolean;
60
+ /**
61
+ * Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
62
+ */
63
+ protected hasExistingShadowRoot: boolean;
64
+ /**
65
+ * Resolves the isPrerendered promise.
66
+ */
67
+ private _resolvePrerendered;
68
+ /**
69
+ * Resolves the isHydrated promise.
70
+ */
71
+ private _resolveHydrated;
72
+ /**
73
+ * Resolves `true` when the element had an existing shadow root
74
+ * (from SSR or declarative shadow DOM) at connect time, `false`
75
+ * otherwise.
76
+ */
77
+ readonly isPrerendered: Promise<boolean>;
78
+ /**
79
+ * Resolves `true` after prerendered content has been successfully
80
+ * hydrated, or `false` when the component is client-side rendered
81
+ * or hydration is not enabled.
82
+ */
83
+ readonly isHydrated: Promise<boolean>;
84
+ /**
85
+ * The template used to render the component.
86
+ */
87
+ private _template;
88
+ /**
89
+ * The shadow root options for the component.
90
+ */
91
+ private _shadowRootOptions;
92
+ /**
93
+ * The current lifecycle stage of the controller.
94
+ */
95
+ protected stage: Stages;
96
+ /**
97
+ * A guard against connecting behaviors multiple times
98
+ * during connect in scenarios where a behavior adds
99
+ * another behavior during it's connectedCallback
100
+ */
101
+ private guardBehaviorConnection;
102
+ /**
103
+ * The behaviors associated with the component.
104
+ */
105
+ protected behaviors: Map<HostBehavior<TElement>, number> | null;
106
+ /**
107
+ * Tracks whether behaviors are connected so that
108
+ * behaviors cant be connected multiple times
109
+ */
110
+ private behaviorsConnected;
111
+ /**
112
+ * The main set of styles used for the component, independent of any
113
+ * dynamically added styles.
114
+ */
115
+ private _mainStyles;
116
+ /**
117
+ * This allows Observable.getNotifier(...) to return the Controller
118
+ * when the notifier for the Controller itself is being requested. The
119
+ * result is that the Observable system does not need to create a separate
120
+ * instance of Notifier for observables on the Controller. The component and
121
+ * the controller will now share the same notifier, removing one-object construct
122
+ * per web component instance.
123
+ */
124
+ private readonly $fastController;
125
+ /**
126
+ * The element being controlled by this controller.
127
+ */
128
+ readonly source: TElement;
129
+ /**
130
+ * The element definition that instructs this controller
131
+ * in how to handle rendering and other platform integrations.
132
+ */
133
+ readonly definition: FASTElementDefinition;
134
+ /**
135
+ * The view associated with the custom element.
136
+ * @remarks
137
+ * If `null` then the element is managing its own rendering.
138
+ */
139
+ readonly view: ElementView<TElement> | null;
140
+ /**
141
+ * Indicates whether or not the custom element has been
142
+ * connected to the document.
143
+ */
144
+ get isConnected(): boolean;
145
+ /**
146
+ * The context the expression is evaluated against.
147
+ */
148
+ get context(): ExecutionContext;
149
+ /**
150
+ * Indicates whether the controller is bound.
151
+ */
152
+ get isBound(): boolean;
153
+ /**
154
+ * Indicates how the source's lifetime relates to the controller's lifetime.
155
+ */
156
+ get sourceLifetime(): SourceLifetime | undefined;
157
+ /**
158
+ * Gets/sets the template used to render the component.
159
+ * @remarks
160
+ * This value can only be accurately read after connect but can be set at any time.
161
+ */
162
+ get template(): ElementViewTemplate<TElement> | null;
163
+ set template(value: ElementViewTemplate<TElement> | null);
164
+ /**
165
+ * The shadow root options for the component.
166
+ */
167
+ get shadowOptions(): ShadowRootOptions | undefined;
168
+ set shadowOptions(value: ShadowRootOptions | undefined);
169
+ /**
170
+ * The main set of styles used for the component, independent
171
+ * of any dynamically added styles.
172
+ */
173
+ get mainStyles(): ElementStyles | null;
174
+ set mainStyles(value: ElementStyles | null);
175
+ /**
176
+ * Creates a Controller to control the specified element.
177
+ * @param element - The element to be controlled by this controller.
178
+ * @param definition - The element definition metadata that instructs this
179
+ * controller in how to handle rendering and other platform integrations.
180
+ * @internal
181
+ */
182
+ constructor(element: TElement, definition: FASTElementDefinition);
183
+ /**
184
+ * The subject that subscribers will receive notifications for.
185
+ */
186
+ get subject(): TElement;
187
+ /**
188
+ * Notifies all subscribers of a property change.
189
+ * @param args - The property name that changed.
190
+ */
191
+ notify(args: any): void;
192
+ /**
193
+ * Subscribes to notification of changes in the element's state.
194
+ * @param subscriber - The object that is subscribing for change notification.
195
+ * @param propertyToWatch - The name of the property to watch for changes.
196
+ */
197
+ subscribe(subscriber: Subscriber, propertyToWatch?: any): void;
198
+ /**
199
+ * Unsubscribes from notification of changes in the element's state.
200
+ * @param subscriber - The object that is unsubscribing from change notification.
201
+ * @param propertyToUnwatch - The name of the property to unsubscribe from.
202
+ */
203
+ unsubscribe(subscriber: Subscriber, propertyToUnwatch?: any): void;
204
+ /**
205
+ * Registers an unbind handler with the controller.
206
+ * @param behavior - An object to call when the controller unbinds.
207
+ */
208
+ onUnbind(behavior: {
209
+ unbind(controller: ExpressionController<TElement>): any;
210
+ }): void;
211
+ /**
212
+ * Adds the behavior to the component.
213
+ * @param behavior - The behavior to add.
214
+ */
215
+ addBehavior(behavior: HostBehavior<TElement>): void;
216
+ /**
217
+ * Removes the behavior from the component.
218
+ * @param behavior - The behavior to remove.
219
+ * @param force - Forces removal even if this behavior was added more than once.
220
+ */
221
+ removeBehavior(behavior: HostBehavior<TElement>, force?: boolean): void;
222
+ /**
223
+ * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
224
+ * @param styles - The styles to add.
225
+ */
226
+ addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
227
+ /**
228
+ * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
229
+ * @param styles - the styles to remove.
230
+ */
231
+ removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
232
+ /**
233
+ * Runs connected lifecycle behavior on the associated element.
234
+ */
235
+ connect(): void;
236
+ /**
237
+ * Binds any observables that were set before upgrade.
238
+ */
239
+ protected bindObservables(): void;
240
+ /**
241
+ * Captures public own-properties that shadow observable accessors on the
242
+ * prototype so they can be rebound through the accessor before rendering.
243
+ */
244
+ protected captureBoundObservables(): void;
245
+ /**
246
+ * Synchronizes late-defined attribute-map attributes from the live DOM to the
247
+ * associated property values before the initial render occurs.
248
+ */
249
+ protected syncLateAttributes(): void;
250
+ /**
251
+ * Observes late-defined attribute-map attributes that the platform does not
252
+ * surface through attributeChangedCallback because they were added after
253
+ * customElements.define() completed.
254
+ */
255
+ protected observeLateAttributes(): void;
256
+ /**
257
+ * Connects any existing behaviors on the associated element.
258
+ */
259
+ protected connectBehaviors(): void;
260
+ /**
261
+ * Disconnects any behaviors on the associated element.
262
+ */
263
+ protected disconnectBehaviors(): void;
264
+ /**
265
+ * Runs disconnected lifecycle behavior on the associated element.
266
+ */
267
+ disconnect(): void;
268
+ /**
269
+ * Runs the attribute changed callback for the associated element.
270
+ * @param name - The name of the attribute that changed.
271
+ * @param oldValue - The previous value of the attribute.
272
+ * @param newValue - The new value of the attribute.
273
+ */
274
+ onAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
275
+ /**
276
+ * Emits a custom HTML event.
277
+ * @param type - The type name of the event.
278
+ * @param detail - The event detail object to send with the event.
279
+ * @param options - The event options. By default bubbles and composed.
280
+ * @remarks
281
+ * Only emits events if connected.
282
+ */
283
+ emit(type: string, detail?: any, options?: TrustEmitOptions): void | boolean;
284
+ /**
285
+ * Renders the provided template to the element.
286
+ *
287
+ * @param template - The template to render.
288
+ * @remarks
289
+ * If `null` is provided, any existing view will be removed.
290
+ */
291
+ protected renderTemplate(template: ElementViewTemplate | null | undefined): void;
292
+ /**
293
+ * Standard client-side render: clears any stale content, clones the
294
+ * compiled fragment, binds, and appends to the host.
295
+ */
296
+ private renderClientSide;
297
+ /**
298
+ * Locates or creates a controller for the specified element.
299
+ * @param element - The element to return the controller for.
300
+ * @param override - Reset the controller even if one has been defined.
301
+ * @remarks
302
+ * The specified element must have a {@link FASTElementDefinition}
303
+ * registered either through the use of the {@link customElement}
304
+ * decorator or a call to `FASTElement.define`.
305
+ */
306
+ static forCustomElement(element: HTMLElement, override?: boolean): ElementController;
307
+ /**
308
+ * Sets the strategy that ElementController.forCustomElement uses to construct
309
+ * ElementController instances for an element.
310
+ * @param strategy - The strategy to use.
311
+ */
312
+ static setStrategy(strategy: ElementControllerStrategy): void;
313
+ /**
314
+ * A hook that, when set, handles prerendered content hydration.
315
+ * Called by renderTemplate when an existing shadow root is detected.
316
+ * Returns true if hydration was performed, false to fall back to client-side.
317
+ * @internal
318
+ */
319
+ private static hydrationHook;
320
+ /**
321
+ * Installs the hydration hook. Called by enableHydration().
322
+ * @internal
323
+ */
324
+ static installHydrationHook(hook: (controller: ElementController, template: ElementViewTemplate, element: HTMLElement, host: Node) => boolean): void;
325
+ }
326
+ /**
327
+ * https://wicg.github.io/construct-stylesheets/
328
+ * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
329
+ *
330
+ * @internal
331
+ */
332
+ export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
333
+ private static styleSheetCache;
334
+ /** @internal */
335
+ readonly sheets: CSSStyleSheet[];
336
+ constructor(styles: (string | CSSStyleSheet)[]);
337
+ addStylesTo(target: StyleTarget): void;
338
+ removeStylesFrom(target: StyleTarget): void;
339
+ }
340
+ /**
341
+ * @internal
342
+ */
343
+ export declare class StyleElementStrategy implements StyleStrategy {
344
+ private readonly styles;
345
+ private readonly styleClass;
346
+ constructor(styles: string[]);
347
+ addStylesTo(target: StyleTarget): void;
348
+ removeStylesFrom(target: StyleTarget): void;
349
+ }
@@ -0,0 +1,2 @@
1
+ export { ElementController } from "./element-controller.js";
2
+ export * from "./hydration.js";
@@ -0,0 +1,66 @@
1
+ import { type HydrationController, type HydrationOptions } from "./hydration-tracker.js";
2
+ export { StopHydration } from "./hydration-tracker.js";
3
+ export type { HydrationController, HydrationOptions };
4
+ /**
5
+ * Enables hydration support for prerendered FAST elements.
6
+ *
7
+ * @remarks
8
+ * Call this before any FAST elements connect to the DOM. Hydration
9
+ * logic is not active unless this function is called, keeping
10
+ * `FASTElement` lightweight for client-side-only applications.
11
+ *
12
+ * Safe to call multiple times — the hydration hook is installed once
13
+ * and subsequent calls merge their options into the shared tracker.
14
+ * By default, the hook stops hydrating new prerendered elements after
15
+ * the initial hydration batch completes. Await the returned controller's
16
+ * `whenHydrated()` promise to run code after the active hydration batch
17
+ * completes.
18
+ *
19
+ * Set `stopHydration` to `StopHydration.never` for streaming scenarios
20
+ * that append hydratable Declarative Shadow DOM after the initial batch.
21
+ * In this mode, `whenHydrated` intentionally remains pending because
22
+ * hydration never reaches a global completion point.
23
+ *
24
+ * Pass `debugger: hydrationDebugger()` to swap the default minimal
25
+ * hydration mismatch error message for a rich "Expected / Received"
26
+ * report including the SSR HTML snippet and structured
27
+ * `expected`/`received` fields on `HydrationBindingError` /
28
+ * `HydrationTargetElementError`. The debugger module is tree-shaken
29
+ * out of production hydration bundles unless explicitly imported.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { enableHydration } from "@lushly-dev/fast-element/hydration.js";
34
+ *
35
+ * const hydration = enableHydration();
36
+ *
37
+ * await hydration.whenHydrated();
38
+ * console.log("hydration complete");
39
+ * ```
40
+ *
41
+ * @example Streaming Declarative Shadow DOM
42
+ * ```ts
43
+ * import { enableHydration, StopHydration } from "@lushly-dev/fast-element/hydration.js";
44
+ *
45
+ * enableHydration({
46
+ * stopHydration: StopHydration.never,
47
+ * });
48
+ * ```
49
+ *
50
+ * @example Rich hydration mismatch diagnostics
51
+ * ```ts
52
+ * import { enableHydration, hydrationDebugger } from "@lushly-dev/fast-element/hydration.js";
53
+ *
54
+ * enableHydration({ debugger: hydrationDebugger() });
55
+ * ```
56
+ *
57
+ * @param options - Optional hydration behavior.
58
+ * @public
59
+ */
60
+ export declare function enableHydration(options?: HydrationOptions): HydrationController;
61
+ /**
62
+ * The attribute used to defer hydration of an element.
63
+ * Retained for intersection observer viewport hydration rendering.
64
+ * @beta
65
+ */
66
+ export declare const deferHydrationAttribute = "defer-hydration";
@@ -0,0 +1,211 @@
1
+ import { type Constructable } from "../interfaces.js";
2
+ import type { TypeDefinition, TypeRegistry } from "../platform.js";
3
+ import { type ComposableStyles, ElementStyles } from "../styles/element-styles.js";
4
+ import type { ElementViewTemplate } from "../templating/template.js";
5
+ import { type AttributeConfiguration, AttributeDefinition } from "./attributes.js";
6
+ import type { Schema } from "./schema.js";
7
+ export type { TypeDefinition, TypeRegistry };
8
+ /**
9
+ * Shadow root initialization options.
10
+ * @public
11
+ */
12
+ export interface ShadowRootOptions extends ShadowRootInit {
13
+ /**
14
+ * A registry that provides the custom elements visible
15
+ * from within this shadow root.
16
+ * @beta
17
+ */
18
+ registry?: CustomElementRegistry;
19
+ }
20
+ /**
21
+ * A callback that receives a FASTElementDefinition during element registration.
22
+ * Extensions are invoked before the element is registered with the platform,
23
+ * allowing plugins to inspect or act on the resolved definition.
24
+ * @public
25
+ */
26
+ export type FASTElementExtension = (definition: FASTElementDefinition, registry: CustomElementRegistry) => void;
27
+ /**
28
+ * Resolves an element template from a composed definition.
29
+ * @public
30
+ */
31
+ export type FASTElementTemplateResolver<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> = (definition: FASTElementDefinition<TType>) => ElementViewTemplate<InstanceType<TType>> | Promise<ElementViewTemplate<InstanceType<TType>>>;
32
+ /**
33
+ * Applies extension callbacks to a FAST element definition.
34
+ * @internal
35
+ */
36
+ export declare function applyFASTElementExtensions(definition: FASTElementDefinition, registry?: CustomElementRegistry, extensions?: FASTElementExtension[]): void;
37
+ /**
38
+ * Registers an extension that applies to every subsequently defined FAST element.
39
+ * @param extension - The extension to register.
40
+ * @returns A callback that removes the extension registration.
41
+ * @internal
42
+ */
43
+ export declare function registerFASTElementExtension(extension: FASTElementExtension): () => void;
44
+ /**
45
+ * Tracks attribute definitions that were added after the element was already
46
+ * registered with the platform and therefore are not covered by the browser's
47
+ * static observedAttributes snapshot.
48
+ * @internal
49
+ */
50
+ export declare function trackLateAttributeDefinition(definition: FASTElementDefinition, attribute: AttributeDefinition): void;
51
+ /**
52
+ * Gets the attribute definitions that were added after platform registration.
53
+ * @internal
54
+ */
55
+ export declare function getLateAttributeLookup(definition: FASTElementDefinition): Readonly<Record<string, AttributeDefinition>> | null;
56
+ /**
57
+ * Resolves the concrete template for a FAST element definition when the
58
+ * definition was composed with a template resolver.
59
+ * @internal
60
+ */
61
+ export declare function resolveFASTElementTemplate<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>): ElementViewTemplate<InstanceType<TType>> | Promise<ElementViewTemplate<InstanceType<TType>> | undefined> | undefined;
62
+ /**
63
+ * Indicates whether a definition still has a pending template resolver.
64
+ * @internal
65
+ */
66
+ export declare function hasFASTElementTemplateResolver<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>): boolean;
67
+ /**
68
+ * Gets any pending template resolution error for a FAST element definition.
69
+ * @internal
70
+ */
71
+ export declare function getFASTElementTemplateError<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>): unknown;
72
+ /**
73
+ * Sets or clears the template resolution error for a FAST element definition.
74
+ * @internal
75
+ */
76
+ export declare function setFASTElementTemplateError<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>, error?: unknown): void;
77
+ /**
78
+ * Represents metadata configuration for a custom element.
79
+ * @public
80
+ */
81
+ export interface PartialFASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
82
+ /**
83
+ * The name of the custom element.
84
+ */
85
+ readonly name: string;
86
+ /**
87
+ * The template, or template resolver, for the custom element.
88
+ */
89
+ readonly template?: ElementViewTemplate<InstanceType<TType>> | FASTElementTemplateResolver<TType>;
90
+ /**
91
+ * The styles to associate with the custom element.
92
+ */
93
+ readonly styles?: ComposableStyles | ComposableStyles[];
94
+ /**
95
+ * The custom attributes of the custom element.
96
+ */
97
+ readonly attributes?: (AttributeConfiguration | string)[];
98
+ /**
99
+ * Options controlling the creation of the custom element's shadow DOM.
100
+ * @remarks
101
+ * If not provided, defaults to an open shadow root. Provide null
102
+ * to render to the associated template to the light DOM instead.
103
+ */
104
+ readonly shadowOptions?: Partial<ShadowRootOptions> | null;
105
+ /**
106
+ * Options controlling how the custom element is defined with the platform.
107
+ */
108
+ readonly elementOptions?: ElementDefinitionOptions;
109
+ /**
110
+ * The registry to register this component in by default.
111
+ * @remarks
112
+ * If not provided, defaults to the global registry.
113
+ */
114
+ readonly registry?: CustomElementRegistry;
115
+ /**
116
+ * The optional schema associated with the custom element definition.
117
+ * Declarative templates assign this automatically during template resolution.
118
+ * Non-declarative callers can provide one for schema-driven extensions.
119
+ */
120
+ readonly schema?: Schema;
121
+ }
122
+ /**
123
+ * Defines metadata for a FASTElement.
124
+ * @public
125
+ */
126
+ export declare class FASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
127
+ private platformDefined;
128
+ /**
129
+ * The type this element definition describes.
130
+ */
131
+ readonly type: TType;
132
+ /**
133
+ * Indicates if this element has been defined in at least one registry.
134
+ */
135
+ get isDefined(): boolean;
136
+ /**
137
+ * The name of the custom element.
138
+ */
139
+ readonly name: string;
140
+ /**
141
+ * The custom attributes of the custom element.
142
+ */
143
+ readonly attributes: ReadonlyArray<AttributeDefinition>;
144
+ /**
145
+ * A map enabling lookup of attribute by associated property name.
146
+ */
147
+ readonly propertyLookup: Record<string, AttributeDefinition>;
148
+ /**
149
+ * A map enabling lookup of property by associated attribute name.
150
+ */
151
+ readonly attributeLookup: Record<string, AttributeDefinition>;
152
+ /**
153
+ * The template to render for the custom element.
154
+ */
155
+ template?: ElementViewTemplate<InstanceType<TType>>;
156
+ /**
157
+ * The styles to associate with the custom element.
158
+ */
159
+ readonly styles?: ElementStyles;
160
+ /**
161
+ * Options controlling the creation of the custom element's shadow DOM.
162
+ */
163
+ shadowOptions?: ShadowRootOptions;
164
+ /**
165
+ * Options controlling how the custom element is defined with the platform.
166
+ */
167
+ readonly elementOptions: ElementDefinitionOptions;
168
+ /**
169
+ * The registry to register this component in by default.
170
+ */
171
+ readonly registry: CustomElementRegistry;
172
+ /**
173
+ * The optional schema associated with the custom element definition.
174
+ * Declarative templates assign this automatically during template resolution.
175
+ * Non-declarative callers can provide one for schema-driven extensions.
176
+ */
177
+ schema?: Schema;
178
+ private constructor();
179
+ /**
180
+ * Defines a custom element based on this definition.
181
+ * @param registry - The element registry to define the element in.
182
+ * @param extensions - An optional array of extension callbacks to invoke
183
+ * with this definition before platform registration.
184
+ * @remarks
185
+ * This operation is idempotent per registry.
186
+ */
187
+ define(registry?: CustomElementRegistry, extensions?: FASTElementExtension[]): this;
188
+ /**
189
+ * Creates an instance of FASTElementDefinition.
190
+ * @param type - The type this definition is being created for.
191
+ * @param nameOrDef - The name of the element to define or a config object
192
+ * that describes the element to define.
193
+ */
194
+ static compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition<TType>): Promise<FASTElementDefinition<TType>>;
195
+ /**
196
+ * Registers a FASTElement base type.
197
+ * @param type - The type to register as a base type.
198
+ * @internal
199
+ */
200
+ static registerBaseType(type: Function): void;
201
+ /**
202
+ * Gets the element definition associated with the specified type.
203
+ * @param type - The custom element type to retrieve the definition for.
204
+ */
205
+ static readonly getByType: (key: Function) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
206
+ /**
207
+ * Gets the element definition associated with the instance.
208
+ * @param instance - The custom element instance to retrieve the definition for.
209
+ */
210
+ static readonly getForInstance: (object: any) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
211
+ }
@@ -0,0 +1,23 @@
1
+ import { type TypeRegistry } from "../platform.js";
2
+ import type { FASTElementDefinition } from "./fast-definitions.js";
3
+ /**
4
+ * The FAST custom element registry.
5
+ * @public
6
+ */
7
+ export interface FASTElementRegistry extends TypeRegistry<FASTElementDefinition> {
8
+ /**
9
+ * Resolves when a FAST element definition has been registered for the tag name.
10
+ * @param name - The custom element tag name.
11
+ * @param registry - The custom element registry to observe.
12
+ */
13
+ whenRegistered(name: string, registry?: CustomElementRegistry): Promise<FASTElementDefinition>;
14
+ }
15
+ /**
16
+ * The FAST custom element registry.
17
+ * @remarks
18
+ * This registry stores FAST element definitions by constructor so consumers can
19
+ * look up the `FASTElementDefinition` associated with an element type, instance,
20
+ * or registered tag name.
21
+ * @public
22
+ */
23
+ export declare const fastElementRegistry: FASTElementRegistry;