@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,91 @@
1
+ import { type Constructable } from "../interfaces.js";
2
+ import type { TrustEmitOptions } from "../trust/types.js";
3
+ import { ElementController } from "./element-controller.js";
4
+ import { type FASTElementExtension, type PartialFASTElementDefinition } from "./fast-definitions.js";
5
+ /**
6
+ * Represents a custom element based on the FASTElement infrastructure.
7
+ * @public
8
+ */
9
+ export interface FASTElement extends HTMLElement {
10
+ /**
11
+ * The underlying controller that handles the lifecycle and rendering of
12
+ * this FASTElement.
13
+ */
14
+ readonly $fastController: ElementController;
15
+ /**
16
+ * Emits a custom HTML event.
17
+ * @param type - The type name of the event.
18
+ * @param detail - The event detail object to send with the event.
19
+ * @param options - The event options. By default bubbles and composed.
20
+ * @remarks
21
+ * Only emits events if the element is connected.
22
+ */
23
+ $emit(type: string, detail?: any, options?: TrustEmitOptions): boolean | void;
24
+ /**
25
+ * The connected callback for this FASTElement.
26
+ * @remarks
27
+ * This method is invoked by the platform whenever this FASTElement
28
+ * becomes connected to the document.
29
+ */
30
+ connectedCallback(): void;
31
+ /**
32
+ * The disconnected callback for this FASTElement.
33
+ * @remarks
34
+ * This method is invoked by the platform whenever this FASTElement
35
+ * becomes disconnected from the document.
36
+ */
37
+ disconnectedCallback(): void;
38
+ /**
39
+ * The attribute changed callback for this FASTElement.
40
+ * @param name - The name of the attribute that changed.
41
+ * @param oldValue - The previous value of the attribute.
42
+ * @param newValue - The new value of the attribute.
43
+ * @remarks
44
+ * This method is invoked by the platform whenever an observed
45
+ * attribute of FASTElement has a value change.
46
+ */
47
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
48
+ }
49
+ /**
50
+ * The FASTElement constructor and static registration helpers.
51
+ * @public
52
+ */
53
+ export interface FASTElementConstructor {
54
+ /**
55
+ * Creates a FASTElement instance.
56
+ */
57
+ new (): FASTElement;
58
+ /**
59
+ * Defines a platform custom element based on the provided type and definition.
60
+ * @param nameOrDef - The name of the element to define or a definition object.
61
+ * @param extensions - Optional callbacks to run before registration.
62
+ */
63
+ define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition<TType>, extensions?: FASTElementExtension[]): Promise<TType>;
64
+ /**
65
+ * Defines a platform custom element based on the provided type and definition.
66
+ * @param type - The custom element type to define.
67
+ * @param nameOrDef - The name of the element to define or a definition object.
68
+ * @param extensions - Optional callbacks to run before registration.
69
+ */
70
+ define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition<TType>, extensions?: FASTElementExtension[]): Promise<TType>;
71
+ /**
72
+ * Creates a new FASTElement base class inherited from the provided base type.
73
+ * @param BaseType - The base element type to inherit from.
74
+ */
75
+ from<TBase extends typeof HTMLElement>(BaseType: TBase): {
76
+ new (): InstanceType<TBase> & FASTElement;
77
+ };
78
+ }
79
+ /**
80
+ * A minimal base class for FASTElements that also provides
81
+ * static helpers for working with FASTElements.
82
+ * @public
83
+ */
84
+ export declare const FASTElement: FASTElementConstructor;
85
+ /**
86
+ * Decorator: Defines a platform custom element based on `FASTElement`.
87
+ * @param nameOrDef - The name of the element to define or a definition object
88
+ * that describes the element to define.
89
+ * @public
90
+ */
91
+ export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
@@ -0,0 +1,110 @@
1
+ import type { HydrationDebugger } from "../hydration/hydration-debugger.js";
2
+ /**
3
+ * Describes when FAST should stop hydrating newly connected prerendered elements.
4
+ * @public
5
+ */
6
+ export declare const StopHydration: Readonly<{
7
+ /**
8
+ * Stop hydrating new prerendered elements after the active hydration batch completes.
9
+ */
10
+ readonly hydrationComplete: "hydration-complete";
11
+ /**
12
+ * Keep the hydration hook active for later prerendered elements.
13
+ */
14
+ readonly never: "never";
15
+ }>;
16
+ /**
17
+ * Describes when FAST should stop hydrating newly connected prerendered elements.
18
+ * @public
19
+ */
20
+ export type StopHydration = (typeof StopHydration)[keyof typeof StopHydration];
21
+ /**
22
+ * Options for configuring hydration behavior.
23
+ * @public
24
+ */
25
+ export interface HydrationOptions {
26
+ /**
27
+ * Indicates when the hydration hook should stop handling new
28
+ * prerendered elements.
29
+ *
30
+ * @defaultValue StopHydration.hydrationComplete
31
+ */
32
+ stopHydration?: StopHydration;
33
+ /**
34
+ * Optional opt-in debugger that swaps the default minimal hydration
35
+ * mismatch error message for a rich "Expected … / Received …" report
36
+ * including an HTML snippet of the SSR DOM and structured
37
+ * `expected`/`received` fields on `HydrationBindingError` /
38
+ * `HydrationTargetElementError`. Obtained via
39
+ * `hydrationDebugger()` from `@lushly-dev/fast-element/hydration.js`.
40
+ */
41
+ debugger?: HydrationDebugger;
42
+ }
43
+ /**
44
+ * The controller returned by `enableHydration()`.
45
+ * @public
46
+ */
47
+ export interface HydrationController {
48
+ /**
49
+ * Resolves when the active hydration batch completes, or when hydration work
50
+ * for the specified tag name completes.
51
+ * @param tagName - The optional custom element tag name to observe.
52
+ * @remarks
53
+ * If hydration is configured with `stopHydration: StopHydration.never`, the
54
+ * global promise intentionally remains pending because hydration never
55
+ * reaches a global completion point.
56
+ */
57
+ whenHydrated(tagName?: string): Promise<void>;
58
+ }
59
+ /**
60
+ * Tracks prerendered elements through the hydration lifecycle and
61
+ * exposes the active global hydration completion promise.
62
+ *
63
+ * @public
64
+ */
65
+ export declare class HydrationTracker implements HydrationController {
66
+ private elements;
67
+ private elementTags;
68
+ private tagHydrationStates;
69
+ private started;
70
+ private completed;
71
+ private checkTimer;
72
+ private stopHydration;
73
+ private _whenHydrated;
74
+ private resolveWhenHydrated;
75
+ constructor(options: HydrationOptions);
76
+ /**
77
+ * Resolves when the active hydration batch completes, or when hydration work
78
+ * for the specified tag name completes.
79
+ */
80
+ whenHydrated(tagName?: string): Promise<void>;
81
+ /**
82
+ * Indicates whether the hydration hook should attempt to hydrate
83
+ * prerendered elements.
84
+ */
85
+ get shouldHydrate(): boolean;
86
+ /**
87
+ * Registers an element as pending hydration.
88
+ */
89
+ add(element: HTMLElement): void;
90
+ /**
91
+ * Removes an element from the pending set and schedules
92
+ * a debounced completion check.
93
+ */
94
+ remove(element: HTMLElement): void;
95
+ /**
96
+ * Merges additional options into the tracker.
97
+ */
98
+ mergeOptions(incoming: HydrationOptions): void;
99
+ private prepareHydrationPromise;
100
+ private getTagHydrationPromise;
101
+ private addTagHydration;
102
+ private removeTagHydration;
103
+ private getTagHydrationState;
104
+ private createTagHydrationState;
105
+ private prepareTagHydrationState;
106
+ private resolveTagHydrationState;
107
+ private scheduleTagHydrationResolution;
108
+ private resolveTagHydrationPromises;
109
+ private resolveHydrationPromise;
110
+ }
@@ -0,0 +1,52 @@
1
+ import type { ContentTemplate, HydratableContentTemplate } from "../templating/html-binding-directive.js";
2
+ import type { ViewController } from "../templating/html-directive.js";
3
+ import type { HydratableViewController } from "../templating/hydration-view.js";
4
+ import type { ElementViewTemplate, HydratableElementViewTemplate, HydratableSyntheticViewTemplate, SyntheticViewTemplate } from "../templating/template.js";
5
+ /**
6
+ * Markup utilities to aid in template hydration.
7
+ * @internal
8
+ */
9
+ export declare const HydrationMarkup: Readonly<{
10
+ attributeMarkerName: "data-fe";
11
+ legacyAttributeMarkerName: "data-fe-b";
12
+ legacyCompactAttributeMarkerName: "data-fe-c";
13
+ contentBindingStartMarker(): string;
14
+ contentBindingEndMarker(): string;
15
+ repeatStartMarker(): string;
16
+ repeatEndMarker(): string;
17
+ elementBoundaryStartMarker(): string;
18
+ elementBoundaryEndMarker(): string;
19
+ isContentBindingStartMarker(data: string): boolean;
20
+ isContentBindingEndMarker(data: string): boolean;
21
+ isRepeatViewStartMarker(data: string): boolean;
22
+ isRepeatViewEndMarker(data: string): boolean;
23
+ isElementBoundaryStartMarker(node: Node): boolean;
24
+ isElementBoundaryEndMarker(node: Node): boolean;
25
+ /**
26
+ * Returns the count of attribute bindings on the element, or null
27
+ * if no attribute binding marker is present.
28
+ *
29
+ * Parses the `data-fe="N"` attribute format where N is the count
30
+ * of attribute binding factories targeting this element.
31
+ */
32
+ parseAttributeBindingCount(node: Element): number | null;
33
+ parseLegacyAttributeBindingIndices(node: Element): number[] | null;
34
+ removeLegacyAttributeBindingMarkers(node: Element): void;
35
+ parseLegacyContentBindingStartIndex(data: string): number | null;
36
+ }>;
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare const Hydratable: unique symbol;
41
+ /**
42
+ * Tests if a template or ViewController is hydratable.
43
+ *
44
+ * @beta
45
+ */
46
+ export declare function isHydratable(view: ViewController): view is HydratableViewController;
47
+ /** @beta */
48
+ export declare function isHydratable<TSource = any, TParent = any>(template: SyntheticViewTemplate<TSource, TParent>): template is HydratableSyntheticViewTemplate<TSource, TParent>;
49
+ /** @beta */
50
+ export declare function isHydratable<TSource = any, TParent = any>(template: ElementViewTemplate<TSource, TParent>): template is HydratableElementViewTemplate<TSource, TParent>;
51
+ /** @beta */
52
+ export declare function isHydratable(template: ContentTemplate): template is HydratableContentTemplate;
@@ -0,0 +1,205 @@
1
+ type FastContextMetaData = "$fast_context";
2
+ type FastContextsMetaData = "$fast_parent_contexts";
3
+ /**
4
+ * Describes a child custom element binding referenced by a schema path.
5
+ * @public
6
+ */
7
+ export interface ChildrenMap {
8
+ customElementName: string;
9
+ attributeName: string;
10
+ }
11
+ /**
12
+ * A reusable JSON schema definition.
13
+ * @public
14
+ */
15
+ export interface JSONSchemaDefinition extends JSONSchemaCommon {
16
+ $fast_context: string;
17
+ $fast_parent_contexts: Array<string>;
18
+ }
19
+ /**
20
+ * Common properties shared by schema nodes.
21
+ * @public
22
+ */
23
+ export interface JSONSchemaCommon {
24
+ type?: string;
25
+ properties?: any;
26
+ items?: any;
27
+ anyOf?: Array<any>;
28
+ $ref?: string;
29
+ /**
30
+ * Stamped by `applyConfigToSchema` when an `ObserverMapConfig` excludes
31
+ * this path. When `false`, the proxy system skips observation for this
32
+ * node and (if all descendants are also `false`) its subtree.
33
+ */
34
+ $observe?: boolean;
35
+ }
36
+ /**
37
+ * A JSON schema describing a root property.
38
+ * @public
39
+ */
40
+ export interface JSONSchema extends JSONSchemaCommon {
41
+ $schema: string;
42
+ $id: string;
43
+ $defs?: Record<string, JSONSchemaDefinition>;
44
+ }
45
+ /**
46
+ * Common metadata for paths cached while parsing a template.
47
+ * @public
48
+ */
49
+ export interface CachedPathCommon {
50
+ parentContext: string | null;
51
+ currentContext: string | null;
52
+ path: string;
53
+ }
54
+ /**
55
+ * A path discovered from an access expression.
56
+ * @public
57
+ */
58
+ export interface AccessCachedPath extends CachedPathCommon {
59
+ type: "access";
60
+ }
61
+ /**
62
+ * A path discovered from a default binding.
63
+ * @public
64
+ */
65
+ export interface DefaultCachedPath extends CachedPathCommon {
66
+ type: "default";
67
+ }
68
+ /**
69
+ * A path discovered from an event binding.
70
+ * @public
71
+ */
72
+ export interface EventCachedPath extends CachedPathCommon {
73
+ type: "event";
74
+ }
75
+ /**
76
+ * A path discovered from a repeat directive.
77
+ * @public
78
+ */
79
+ export interface RepeatCachedPath extends CachedPathCommon {
80
+ type: "repeat";
81
+ }
82
+ /**
83
+ * A path discovered while parsing a template.
84
+ * @public
85
+ */
86
+ export type CachedPath = DefaultCachedPath | RepeatCachedPath | AccessCachedPath | EventCachedPath;
87
+ /**
88
+ * A map from element names and root properties to JSON schemas.
89
+ * @public
90
+ */
91
+ export type CachedPathMap = Map<string, Map<string, JSONSchema>>;
92
+ /**
93
+ * Configuration for registering a path with a schema.
94
+ * @public
95
+ */
96
+ export interface RegisterPathConfig {
97
+ rootPropertyName: string;
98
+ pathConfig: CachedPath;
99
+ childrenMap: ChildrenMap | null;
100
+ }
101
+ export declare const fastContextMetaData: FastContextMetaData;
102
+ export declare const fastContextsMetaData: FastContextsMetaData;
103
+ export declare const defsPropertyName = "$defs";
104
+ export declare const refPropertyName = "$ref";
105
+ /**
106
+ * Module-level registry that maps custom element names to their schema maps.
107
+ * Used for cross-element `$ref` resolution (e.g. nested element schemas).
108
+ * Each Schema instance registers itself here on construction.
109
+ * @public
110
+ */
111
+ export declare const schemaRegistry: CachedPathMap;
112
+ /**
113
+ * A constructed JSON schema from a template
114
+ * @public
115
+ */
116
+ export declare class Schema {
117
+ /**
118
+ * The name of the custom element
119
+ */
120
+ private customElementName;
121
+ /**
122
+ * Instance-level JSON schema map describing each root property
123
+ */
124
+ private schemaMap;
125
+ constructor(name: string);
126
+ /**
127
+ * Add a path to a schema
128
+ * @param config - The path registration configuration.
129
+ */
130
+ addPath(config: RegisterPathConfig): void;
131
+ /**
132
+ * Gets the JSON schema for a property name
133
+ * @param rootPropertyName - the root property the JSON schema is mapped to
134
+ * @returns The JSON schema for the root property
135
+ */
136
+ getSchema(rootPropertyName: string): JSONSchema | null;
137
+ /**
138
+ * Gets root properties
139
+ * @returns IterableIterator<string>
140
+ */
141
+ getRootProperties(): IterableIterator<string>;
142
+ /**
143
+ * Get a path split into property names
144
+ * @param path - The dot syntax path, e.g. `a.b.c`.
145
+ * @returns An array of items in the path
146
+ */
147
+ private getSplitPath;
148
+ /**
149
+ * Gets the path to the $def
150
+ * @param context - The context name. For example, `item in items` creates the `item` context.
151
+ * @returns A string to use as a $ref
152
+ */
153
+ private getDefsPath;
154
+ /**
155
+ * Get the schema $id
156
+ * @param customElementName - The custom element name
157
+ * @param propertyName - The property name
158
+ * @returns The ID that can be used in the JSON schema as $id
159
+ */
160
+ private getSchemaId;
161
+ /**
162
+ * Add a new JSON schema to the JSON schema map
163
+ * @param propertyName - The name of the property to assign this JSON schema to.
164
+ */
165
+ private addNewSchema;
166
+ /**
167
+ * Add properties to a context
168
+ * @param schema - The schema to add the properties to.
169
+ * @param splitPath - The path split into property/context names.
170
+ * @param context - The path context.
171
+ */
172
+ private addPropertiesToAContext;
173
+ /**
174
+ * Add properties to an object
175
+ * @param schema - The schema to add the properties to.
176
+ * @param splitPath - The path split into property/context names.
177
+ * @param context - The path context.
178
+ * @param type - The data type (see JSON schema for details).
179
+ */
180
+ private addPropertiesToAnObject;
181
+ /**
182
+ * Add an array to an object property
183
+ * @param schema - The schema to add the properties to.
184
+ * @param context - The name of the context.
185
+ */
186
+ private addArrayToAnObject;
187
+ /**
188
+ * Add a context to the $defs property
189
+ * @param schema - The schema to use.
190
+ * @param propertyName - The name of the property the context belongs to.
191
+ * @param currentContext - The current context.
192
+ * @param parentContext - The parent context.
193
+ * @returns
194
+ */
195
+ private addContext;
196
+ /**
197
+ * Get parent contexts
198
+ * @param schema - The schema to use.
199
+ * @param parentContext - The parent context.
200
+ * @param contexts - A list of parent contexts.
201
+ * @returns
202
+ */
203
+ private getParentContexts;
204
+ }
205
+ export {};
@@ -0,0 +1,171 @@
1
+ import { type Constructable, type ParameterDecorator } from "./interfaces.js";
2
+ /**
3
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
4
+ * @public
5
+ */
6
+ export type Context<T> = {
7
+ readonly name: string;
8
+ readonly initialValue?: T;
9
+ };
10
+ /**
11
+ * A constant key that can be used to represent a Context dependency.
12
+ * The key can be used for context or DI but also doubles as a decorator for
13
+ * resolving the associated dependency.
14
+ * @public
15
+ */
16
+ export type ContextDecorator<T = any> = Readonly<Context<T>> & PropertyDecorator & ParameterDecorator;
17
+ /**
18
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
19
+ * The FASTContext can also be used as a decorator to declare context dependencies or as a key for DI.
20
+ * @public
21
+ */
22
+ export type FASTContext<T> = ContextDecorator<T> & {
23
+ get(target: EventTarget): T;
24
+ provide(target: EventTarget, value: T): void;
25
+ request(target: EventTarget, callback: ContextCallback<T>, multiple?: boolean): void;
26
+ handle(target: EventTarget, callback: (event: ContextEvent<FASTContext<T>>) => void): void;
27
+ };
28
+ /**
29
+ * A strategy that controls how all Context.request API calls are handled.
30
+ * @remarks
31
+ * By default this is handled via Context.dispatch, which dispatches a ContextEvent.
32
+ * @public
33
+ */
34
+ export type FASTContextRequestStrategy = <T extends UnknownContext>(target: EventTarget, context: T, callback: ContextCallback<ContextType<T>>, multiple: any) => void;
35
+ declare const contextEventType = "context-request";
36
+ /**
37
+ * Enables using:
38
+ * {@link https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md | W3C Community Context protocol.}
39
+ * @public
40
+ */
41
+ export declare const Context: Readonly<{
42
+ /**
43
+ * The event type used for W3C Context Protocol requests.
44
+ */
45
+ eventType: "context-request";
46
+ /**
47
+ * Returns a FASTContext object from the global context registry matching the given name if found.
48
+ * Otherwise, returns a new FASTContext with this name.
49
+ * @param name - The name of the FASTContext to get or create.
50
+ * @returns A FASTContext object.
51
+ */
52
+ for<T = unknown>(name: string): FASTContext<T>;
53
+ /**
54
+ * Creates a W3C Community Protocol-based Context object to use in requesting/providing
55
+ * context through the DOM.
56
+ * @param name - The name to use for the connext. Useful in debugging.
57
+ * @param initialValue - An optional initial value to use if a context handler isn't found.
58
+ */
59
+ create<T = unknown>(name: string, initialValue?: T): FASTContext<T>;
60
+ /**
61
+ * Sets the strategy used by all FAST-specific context requests made through the
62
+ * Context.request, Context.get, Context.defineProperty, and ContextDecorator APIs.
63
+ * @param strategy - The strategy to use. By default, the strategy is Context.dispatch.
64
+ */
65
+ setDefaultRequestStrategy(strategy: FASTContextRequestStrategy): void;
66
+ /**
67
+ * Gets the context value for the target node or returns the initial value if
68
+ * a context handler is not found.
69
+ * @param target - The target to get the context for.
70
+ * @param context - The context to locate.
71
+ * @returns The context value.
72
+ * @remarks
73
+ * Uses the default request strategy to locate the context. If no context is found
74
+ * then the initial value of the context is returned.
75
+ */
76
+ get<T extends UnknownContext>(target: EventTarget, context: T): ContextType<T>;
77
+ /**
78
+ * Requests the context value for the target node.
79
+ * @param target - The target to request the context for.
80
+ * @param context - The context to locate.
81
+ * @param callback - A callback to invoke with the context value.
82
+ * @param multiple - Whether the context requestor expects to handle updates
83
+ * to the context value after the initial request.
84
+ * @remarks
85
+ * Uses the default request strategy to locate the context.
86
+ */
87
+ request<T extends UnknownContext>(target: EventTarget, context: T, callback: ContextCallback<ContextType<T>>, multiple?: boolean): void;
88
+ /**
89
+ *
90
+ * @param target - The target to dispatch the context event on.
91
+ * @param context - The context to locate.
92
+ * @param callback - The callback to invoke with the context value.
93
+ * @param multiple - Whether the context requestor expects to handle updates
94
+ * to the context value after the initial request.
95
+ * @remarks
96
+ * This API does NOT use the default request strategy. It always dispatches
97
+ * an event through the DOM.
98
+ */
99
+ dispatch<T extends UnknownContext>(target: EventTarget, context: T, callback: ContextCallback<ContextType<T>>, multiple?: boolean): void;
100
+ /**
101
+ * Enables an event target to provide a context value.
102
+ * @param target - The target to provide the context value for.
103
+ * @param context - The context to provide the value for.
104
+ * @param value - The value to provide for the context.
105
+ */
106
+ provide<T extends UnknownContext>(target: EventTarget, context: T, value: ContextType<T>): void;
107
+ /**
108
+ *
109
+ * @param target - The target on which to handle context requests.
110
+ * @param callback - The callback to invoke when a context request is received.
111
+ * @param context - The context to handle requests for.
112
+ * @remarks
113
+ * If a context is not provided then the callback will be invoked for all context
114
+ * requests that are received on the target.
115
+ */
116
+ handle<T extends UnknownContext>(target: EventTarget, callback: (event: ContextEvent<T>) => void, context?: T): void;
117
+ /**
118
+ * Defines a getter-only property on the target that will return the context
119
+ * value for the target.
120
+ * @param target - The target to define the property on.
121
+ * @param propertyName - The name of the property to define.
122
+ * @param context - The context that will be used to retrieve the property value.
123
+ * @remarks
124
+ * Uses the default request strategy to locate the context and will return the
125
+ * initialValue if the context isn't handled.
126
+ */
127
+ defineProperty<T extends UnknownContext>(target: Constructable<EventTarget> | EventTarget, propertyName: string, context: T): void;
128
+ }>;
129
+ /**
130
+ * An unknown context type.
131
+ * @public
132
+ */
133
+ export type UnknownContext = Context<unknown>;
134
+ /**
135
+ * A helper type which can extract a Context value type from a Context type
136
+ * @public
137
+ */
138
+ export type ContextType<T extends UnknownContext> = T extends Context<infer Y> ? Y : never;
139
+ /**
140
+ * A callback which is provided by a context requester and is called with the value satisfying the request.
141
+ * This callback can be called multiple times by context providers as the requested value is changed.
142
+ * @public
143
+ */
144
+ export type ContextCallback<ValueType> = (value: ValueType, dispose?: () => void) => void;
145
+ /**
146
+ * An event fired by a context requester to signal it desires a named context.
147
+ *
148
+ * A provider should inspect the `context` property of the event to determine if it has a value that can
149
+ * satisfy the request, calling the `callback` with the requested value if so.
150
+ *
151
+ * If the requested context event contains a truthy `multiple` value, then a provider can call the callback
152
+ * multiple times if the value is changed, if this is the case the provider should pass a `dispose`
153
+ * method to the callback which requesters can invoke to indicate they no longer wish to receive these updates.
154
+ * @public
155
+ */
156
+ export declare class ContextEvent<T extends UnknownContext> extends Event {
157
+ readonly context: T;
158
+ readonly callback: ContextCallback<ContextType<T>>;
159
+ readonly multiple?: boolean | undefined;
160
+ constructor(context: T, callback: ContextCallback<ContextType<T>>, multiple?: boolean | undefined);
161
+ }
162
+ declare global {
163
+ interface HTMLElementEventMap {
164
+ /**
165
+ * A 'context-request' event can be emitted by any element which desires
166
+ * a context value to be injected by an external provider.
167
+ */
168
+ [contextEventType]: ContextEvent<UnknownContext>;
169
+ }
170
+ }
171
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Enables human-readable FAST debug messages.
3
+ * @public
4
+ */
5
+ export declare function enableDebug(): void;