@microsoft/fast-element 2.10.4 → 3.0.0-rc.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 (211) hide show
  1. package/CHANGELOG.md +52 -2
  2. package/README.md +244 -1
  3. package/dist/arrays/arrays.api.json +2621 -0
  4. package/dist/context/context.api.json +13 -13
  5. package/dist/declarative/declarative.api.json +8483 -0
  6. package/dist/di/di.api.json +16 -16
  7. package/dist/dts/__test__/helpers.d.ts +6 -0
  8. package/dist/dts/array-observer.d.ts +2 -0
  9. package/dist/dts/arrays.d.ts +2 -0
  10. package/dist/dts/attr.d.ts +1 -0
  11. package/dist/dts/binding/binding.d.ts +15 -5
  12. package/dist/dts/binding/one-time.d.ts +1 -1
  13. package/dist/dts/binding/one-way.d.ts +1 -1
  14. package/dist/dts/binding/signal.d.ts +6 -6
  15. package/dist/dts/binding/two-way.d.ts +2 -1
  16. package/dist/dts/binding.d.ts +7 -0
  17. package/dist/dts/components/attributes.d.ts +1 -4
  18. package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
  19. package/dist/dts/components/element-controller.d.ts +80 -114
  20. package/dist/dts/components/element-hydration.d.ts +1 -1
  21. package/dist/dts/components/enable-hydration.d.ts +54 -0
  22. package/dist/dts/components/fast-definitions.d.ts +98 -46
  23. package/dist/dts/components/fast-element.d.ts +43 -16
  24. package/dist/dts/components/hydration-tracker.d.ts +83 -0
  25. package/dist/dts/components/hydration.d.ts +23 -53
  26. package/dist/dts/components/schema.d.ts +205 -0
  27. package/dist/dts/context.d.ts +13 -13
  28. package/dist/dts/css.d.ts +3 -0
  29. package/dist/dts/debug.d.ts +5 -1
  30. package/dist/dts/declarative/attribute-map.d.ts +58 -0
  31. package/dist/dts/declarative/debug.d.ts +4 -0
  32. package/dist/dts/declarative/index.d.ts +14 -0
  33. package/dist/dts/declarative/interfaces.d.ts +8 -0
  34. package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
  35. package/dist/dts/declarative/observer-map.d.ts +89 -0
  36. package/dist/dts/declarative/runtime.d.ts +5 -0
  37. package/dist/dts/declarative/syntax.d.ts +21 -0
  38. package/dist/dts/declarative/template-bridge.d.ts +33 -0
  39. package/dist/dts/declarative/template-parser.d.ts +98 -0
  40. package/dist/dts/declarative/template.d.ts +10 -0
  41. package/dist/dts/declarative/utilities.d.ts +358 -0
  42. package/dist/dts/di/di.d.ts +7 -7
  43. package/dist/dts/directives/children.d.ts +2 -0
  44. package/dist/dts/directives/node-observation.d.ts +2 -0
  45. package/dist/dts/directives/ref.d.ts +2 -0
  46. package/dist/dts/directives/repeat.d.ts +4 -0
  47. package/dist/dts/directives/slotted.d.ts +2 -0
  48. package/dist/dts/directives/when.d.ts +3 -0
  49. package/dist/dts/dom-policy.d.ts +23 -5
  50. package/dist/dts/dom.d.ts +4 -16
  51. package/dist/dts/html.d.ts +5 -0
  52. package/dist/dts/hydration/diagnostics.d.ts +93 -0
  53. package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
  54. package/dist/dts/hydration/messages.d.ts +62 -0
  55. package/dist/dts/hydration/runtime.d.ts +7 -0
  56. package/dist/dts/hydration/target-builder.d.ts +40 -12
  57. package/dist/dts/hydration.d.ts +18 -0
  58. package/dist/dts/index.d.ts +42 -42
  59. package/dist/dts/index.debug.d.ts +0 -1
  60. package/dist/dts/index.rollup.debug.d.ts +0 -1
  61. package/dist/dts/interfaces.d.ts +2 -49
  62. package/dist/dts/observable.d.ts +3 -6
  63. package/dist/dts/observation/arrays.d.ts +1 -1
  64. package/dist/dts/observation/observable.d.ts +3 -3
  65. package/dist/dts/observation/update-queue.d.ts +1 -1
  66. package/dist/dts/platform.d.ts +45 -8
  67. package/dist/dts/registry.d.ts +1 -0
  68. package/dist/dts/render.d.ts +7 -0
  69. package/dist/dts/schema.d.ts +1 -0
  70. package/dist/dts/state/exports.d.ts +1 -1
  71. package/dist/dts/state/state.d.ts +2 -2
  72. package/dist/dts/styles/css-directive.d.ts +5 -12
  73. package/dist/dts/styles/css.d.ts +5 -7
  74. package/dist/dts/styles/element-styles.d.ts +0 -10
  75. package/dist/dts/styles.d.ts +6 -0
  76. package/dist/dts/templating/compiler.d.ts +1 -1
  77. package/dist/dts/templating/html-binding-directive.d.ts +10 -2
  78. package/dist/dts/templating/html-directive.d.ts +19 -1
  79. package/dist/dts/templating/hydration-view.d.ts +130 -0
  80. package/dist/dts/templating/render.d.ts +1 -1
  81. package/dist/dts/templating/repeat.d.ts +1 -1
  82. package/dist/dts/templating/template.d.ts +15 -7
  83. package/dist/dts/templating/view.d.ts +25 -102
  84. package/dist/dts/templating.d.ts +10 -0
  85. package/dist/dts/testing/exports.d.ts +2 -2
  86. package/dist/dts/testing/fakes.d.ts +4 -4
  87. package/dist/dts/updates.d.ts +1 -0
  88. package/dist/dts/volatile.d.ts +2 -0
  89. package/dist/esm/__test__/helpers.js +22 -0
  90. package/dist/esm/__test__/setup-node.js +18 -0
  91. package/dist/esm/array-observer.js +1 -0
  92. package/dist/esm/arrays.js +1 -0
  93. package/dist/esm/attr.js +1 -0
  94. package/dist/esm/binding/normalize.js +1 -1
  95. package/dist/esm/binding/signal.js +4 -4
  96. package/dist/esm/binding/two-way.js +3 -3
  97. package/dist/esm/binding.js +4 -0
  98. package/dist/esm/components/attributes.js +18 -11
  99. package/dist/esm/components/definition-schema-transforms.js +23 -0
  100. package/dist/esm/components/element-controller.js +206 -270
  101. package/dist/esm/components/element-hydration.js +1 -1
  102. package/dist/esm/components/enable-hydration.js +124 -0
  103. package/dist/esm/components/fast-definitions.js +219 -56
  104. package/dist/esm/components/fast-element.js +18 -27
  105. package/dist/esm/components/hydration-tracker.js +122 -0
  106. package/dist/esm/components/hydration.js +137 -140
  107. package/dist/esm/components/schema.js +253 -0
  108. package/dist/esm/context.js +6 -6
  109. package/dist/esm/css.js +3 -0
  110. package/dist/esm/debug.js +27 -26
  111. package/dist/esm/declarative/attribute-map.js +122 -0
  112. package/dist/esm/declarative/debug.js +4 -0
  113. package/dist/esm/declarative/index.js +4 -0
  114. package/dist/esm/declarative/interfaces.js +9 -0
  115. package/dist/esm/declarative/observer-map-utilities.js +565 -0
  116. package/dist/esm/declarative/observer-map.js +216 -0
  117. package/dist/esm/declarative/runtime.js +14 -0
  118. package/dist/esm/declarative/syntax.js +36 -0
  119. package/dist/esm/declarative/template-bridge.js +160 -0
  120. package/dist/esm/declarative/template-parser.js +306 -0
  121. package/dist/esm/declarative/template.js +143 -0
  122. package/dist/esm/declarative/utilities.js +1069 -0
  123. package/dist/esm/di/di.js +8 -9
  124. package/dist/esm/directives/children.js +1 -0
  125. package/dist/esm/directives/node-observation.js +1 -0
  126. package/dist/esm/directives/ref.js +1 -0
  127. package/dist/esm/directives/repeat.js +1 -0
  128. package/dist/esm/directives/slotted.js +1 -0
  129. package/dist/esm/directives/when.js +1 -0
  130. package/dist/esm/dom-policy.js +35 -6
  131. package/dist/esm/dom.js +1 -1
  132. package/dist/esm/html.js +2 -0
  133. package/dist/esm/hydration/diagnostics.js +50 -0
  134. package/dist/esm/hydration/hydration-debugger.js +112 -0
  135. package/dist/esm/hydration/messages.js +84 -0
  136. package/dist/esm/hydration/runtime.js +33 -0
  137. package/dist/esm/hydration/target-builder.js +144 -91
  138. package/dist/esm/hydration.js +6 -0
  139. package/dist/esm/index.debug.js +2 -1
  140. package/dist/esm/index.js +38 -29
  141. package/dist/esm/index.rollup.debug.js +3 -2
  142. package/dist/esm/index.rollup.js +1 -1
  143. package/dist/esm/interfaces.js +2 -45
  144. package/dist/esm/metadata.js +2 -8
  145. package/dist/esm/observable.js +1 -4
  146. package/dist/esm/observation/arrays.js +1 -1
  147. package/dist/esm/observation/notifier.js +2 -4
  148. package/dist/esm/observation/observable.js +5 -5
  149. package/dist/esm/observation/update-queue.js +47 -58
  150. package/dist/esm/platform.js +31 -30
  151. package/dist/esm/registry.js +1 -0
  152. package/dist/esm/render.js +1 -0
  153. package/dist/esm/schema.js +1 -0
  154. package/dist/esm/state/exports.js +1 -1
  155. package/dist/esm/styles/css-directive.js +1 -2
  156. package/dist/esm/styles/css.js +15 -56
  157. package/dist/esm/styles/element-styles.js +69 -15
  158. package/dist/esm/styles.js +2 -0
  159. package/dist/esm/templating/html-binding-directive.js +11 -9
  160. package/dist/esm/templating/hydration-view.js +228 -0
  161. package/dist/esm/templating/render.js +39 -18
  162. package/dist/esm/templating/repeat.js +69 -33
  163. package/dist/esm/templating/template.js +7 -7
  164. package/dist/esm/templating/view.js +25 -234
  165. package/dist/esm/templating.js +7 -0
  166. package/dist/esm/testing/exports.js +2 -2
  167. package/dist/esm/testing/fixture.js +2 -2
  168. package/dist/esm/testing/timeout.js +2 -2
  169. package/dist/esm/updates.js +1 -0
  170. package/dist/esm/volatile.js +1 -0
  171. package/dist/fast-element.api.json +14389 -11138
  172. package/dist/fast-element.d.ts +3651 -809
  173. package/dist/fast-element.debug.js +5666 -4722
  174. package/dist/fast-element.debug.min.js +2 -2
  175. package/dist/fast-element.js +5394 -4381
  176. package/dist/fast-element.min.js +2 -2
  177. package/dist/fast-element.untrimmed.d.ts +923 -472
  178. package/dist/hydration/hydration.api.json +6460 -0
  179. package/dist/styles/styles.api.json +2672 -0
  180. package/package.json +165 -45
  181. package/ARCHITECTURE_FASTELEMENT.md +0 -63
  182. package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +0 -36
  183. package/ARCHITECTURE_INTRO.md +0 -10
  184. package/ARCHITECTURE_OVERVIEW.md +0 -52
  185. package/ARCHITECTURE_UPDATES.md +0 -11
  186. package/CHANGELOG.json +0 -2275
  187. package/DESIGN.md +0 -510
  188. package/api-extractor.context.json +0 -14
  189. package/api-extractor.di.json +0 -14
  190. package/biome.json +0 -4
  191. package/dist/dts/components/install-hydration.d.ts +0 -1
  192. package/dist/dts/pending-task.d.ts +0 -32
  193. package/dist/dts/styles/css-binding-directive.d.ts +0 -60
  194. package/dist/dts/templating/install-hydratable-view-templates.d.ts +0 -1
  195. package/dist/esm/components/install-hydration.js +0 -3
  196. package/dist/esm/pending-task.js +0 -28
  197. package/dist/esm/polyfills.js +0 -60
  198. package/dist/esm/styles/css-binding-directive.js +0 -76
  199. package/dist/esm/templating/install-hydratable-view-templates.js +0 -23
  200. package/docs/ACKNOWLEDGEMENTS.md +0 -12
  201. package/docs/api-report.api.md +0 -1122
  202. package/docs/context/api-report.api.md +0 -69
  203. package/docs/di/api-report.api.md +0 -315
  204. package/docs/fast-element-2-changes.md +0 -15
  205. package/playwright.config.ts +0 -26
  206. package/scripts/run-api-extractor.js +0 -51
  207. package/test/index.html +0 -11
  208. package/test/main.ts +0 -104
  209. package/test/vite.config.ts +0 -19
  210. package/tsconfig.api-extractor.json +0 -6
  211. /package/dist/dts/{polyfills.d.ts → __test__/setup-node.d.ts} +0 -0
@@ -39,7 +39,7 @@ export type State<T> = ReadonlyState<T> & {
39
39
  current: T;
40
40
  /**
41
41
  * Sets the current state value.
42
- * @param value The new state value.
42
+ * @param value - The new state value.
43
43
  */
44
44
  set(value: T): void;
45
45
  /**
@@ -121,7 +121,7 @@ export type ComputedBuilder = {
121
121
  on: {
122
122
  /**
123
123
  * Provides a setup callback for the computation.
124
- * @param callback The callback to run to setup the computation.
124
+ * @param callback - The callback to run to setup the computation.
125
125
  */
126
126
  setup(callback: ComputedSetupCallback): void;
127
127
  };
@@ -1,22 +1,16 @@
1
1
  import type { Constructable } from "../interfaces.js";
2
- import type { HostBehavior } from "./host.js";
3
2
  import type { ComposableStyles } from "./element-styles.js";
4
3
  /**
5
- * Used to add behaviors when constructing styles.
6
- * @public
7
- */
8
- export type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
9
- /**
10
- * Directive for use in {@link css}.
4
+ * Directive for use in CSS templates.
11
5
  *
12
6
  * @public
13
7
  */
14
8
  export interface CSSDirective {
15
9
  /**
16
- * Creates a CSS fragment to interpolate into the CSS document.
17
- * @returns - the string to interpolate into CSS
10
+ * Creates static styles to interpolate into the CSS document.
11
+ * @returns - the styles to interpolate into CSS
18
12
  */
19
- createCSS(add: AddBehavior): ComposableStyles;
13
+ createCSS(): ComposableStyles;
20
14
  }
21
15
  /**
22
16
  * Defines metadata for a CSSDirective.
@@ -29,8 +23,7 @@ export interface CSSDirectiveDefinition<TType extends Constructable<CSSDirective
29
23
  readonly type: TType;
30
24
  }
31
25
  /**
32
- * Instructs the css engine to provide dynamic styles or
33
- * associate behaviors with styles.
26
+ * Instructs the css engine to provide styles during CSS template composition.
34
27
  * @public
35
28
  */
36
29
  export declare const CSSDirective: Readonly<{
@@ -1,36 +1,34 @@
1
- import { Binding } from "../binding/binding.js";
2
- import type { Expression } from "../observation/observable.js";
3
1
  import { CSSDirective } from "./css-directive.js";
4
2
  import { type ComposableStyles, ElementStyles } from "./element-styles.js";
5
3
  /**
6
4
  * Represents the types of values that can be interpolated into a template.
7
5
  * @public
8
6
  */
9
- export type CSSValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | ComposableStyles | CSSDirective;
7
+ export type CSSValue = ComposableStyles | CSSDirective;
10
8
  /**
11
9
  * Transforms a template literal string into styles.
12
10
  * @param strings - The string fragments that are interpolated with the values.
13
11
  * @param values - The values that are interpolated with the string fragments.
14
12
  * @remarks
15
- * The css helper supports interpolation of strings and ElementStyle instances.
13
+ * The css helper supports interpolation of static composable styles and CSS directives.
16
14
  * Use the .partial method to create partial CSS fragments.
17
15
  * @public
18
16
  */
19
- export type CSSTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]) => ElementStyles) & {
17
+ export type CSSTemplateTag = ((strings: TemplateStringsArray, ...values: CSSValue[]) => ElementStyles) & {
20
18
  /**
21
19
  * Transforms a template literal string into partial CSS.
22
20
  * @param strings - The string fragments that are interpolated with the values.
23
21
  * @param values - The values that are interpolated with the string fragments.
24
22
  * @public
25
23
  */
26
- partial<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]): CSSDirective;
24
+ partial(strings: TemplateStringsArray, ...values: CSSValue[]): CSSDirective;
27
25
  };
28
26
  /**
29
27
  * Transforms a template literal string into styles.
30
28
  * @param strings - The string fragments that are interpolated with the values.
31
29
  * @param values - The values that are interpolated with the string fragments.
32
30
  * @remarks
33
- * The css helper supports interpolation of strings and ElementStyle instances.
31
+ * The css helper supports interpolation of static composable styles and CSS directives.
34
32
  * @public
35
33
  */
36
34
  export declare const css: CSSTemplateTag;
@@ -1,5 +1,4 @@
1
1
  import type { StyleStrategy, StyleTarget } from "./style-strategy.js";
2
- import type { HostBehavior } from "./host.js";
3
2
  /**
4
3
  * Represents styles that can be composed into the ShadowDOM of a custom element.
5
4
  * @public
@@ -24,10 +23,6 @@ export declare class ElementStyles {
24
23
  readonly styles: ReadonlyArray<ComposableStyles>;
25
24
  private targets;
26
25
  private _strategy;
27
- /**
28
- * The behaviors associated with this set of styles.
29
- */
30
- readonly behaviors: ReadonlyArray<HostBehavior<HTMLElement>> | null;
31
26
  /**
32
27
  * Gets the StyleStrategy associated with these element styles.
33
28
  */
@@ -43,11 +38,6 @@ export declare class ElementStyles {
43
38
  removeStylesFrom(target: StyleTarget): void;
44
39
  /** @internal */
45
40
  isAttachedTo(target: StyleTarget): boolean;
46
- /**
47
- * Associates behaviors with this set of styles.
48
- * @param behaviors - The behaviors to associate.
49
- */
50
- withBehaviors(...behaviors: HostBehavior<HTMLElement>[]): this;
51
41
  /**
52
42
  * Sets the strategy that handles adding/removing these styles for an element.
53
43
  * @param strategy - The strategy to use.
@@ -0,0 +1,6 @@
1
+ export type { Constructable } from "./interfaces.js";
2
+ export type { ExecutionContext, ExpressionController, SourceLifetime, } from "./observation/observable.js";
3
+ export { CSSDirective, type CSSDirectiveDefinition, cssDirective, } from "./styles/css-directive.js";
4
+ export { type ComposableStyles, type ConstructibleStyleStrategy, ElementStyles, } from "./styles/element-styles.js";
5
+ export type { HostBehavior, HostController } from "./styles/host.js";
6
+ export type { StyleStrategy, StyleTarget } from "./styles/style-strategy.js";
@@ -1,4 +1,4 @@
1
- import { type DOMPolicy } from "../dom.js";
1
+ import type { DOMPolicy } from "../dom-policy.js";
2
2
  import { type ViewBehaviorFactory } from "./html-directive.js";
3
3
  import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from "./template.js";
4
4
  /**
@@ -1,5 +1,6 @@
1
1
  import type { Binding, BindingDirective } from "../binding/binding.js";
2
- import { DOMAspect, type DOMPolicy } from "../dom.js";
2
+ import { DOMAspect } from "../dom.js";
3
+ import type { DOMPolicy } from "../dom-policy.js";
3
4
  import { ExecutionContext, type Expression, type ExpressionObserver } from "../observation/observable.js";
4
5
  import { type AddViewBehaviorFactory, type Aspected, HTMLDirective, type ViewBehavior, type ViewBehaviorFactory, type ViewController } from "./html-directive.js";
5
6
  /**
@@ -39,6 +40,10 @@ export interface ContentTemplate {
39
40
  */
40
41
  create(): ContentView;
41
42
  }
43
+ /**
44
+ * A template capable of hydrating content from existing DOM nodes.
45
+ * @beta
46
+ */
42
47
  export interface HydratableContentTemplate extends ContentTemplate {
43
48
  /**
44
49
  * Hydrates a content view from first/last nodes.
@@ -61,7 +66,6 @@ export interface HydratableContentTemplate extends ContentTemplate {
61
66
  * @public
62
67
  */
63
68
  export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective {
64
- dataBinding: Binding;
65
69
  private data;
66
70
  private updateTarget;
67
71
  /**
@@ -92,6 +96,10 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
92
96
  * The type of aspect to target.
93
97
  */
94
98
  aspectType: DOMAspect;
99
+ /**
100
+ * The binding configuration to apply.
101
+ */
102
+ dataBinding: Binding;
95
103
  /**
96
104
  * Creates an instance of HTMLBindingDirective.
97
105
  * @param dataBinding - The binding configuration to apply.
@@ -1,5 +1,6 @@
1
1
  import type { Binding } from "../binding/binding.js";
2
- import { DOMAspect, type DOMPolicy } from "../dom.js";
2
+ import { DOMAspect } from "../dom.js";
3
+ import type { DOMPolicy } from "../dom-policy.js";
3
4
  import type { Constructable } from "../interfaces.js";
4
5
  import type { ExpressionController } from "../observation/observable.js";
5
6
  /**
@@ -18,6 +19,23 @@ export interface ViewController<TSource = any, TParent = any> extends Expression
18
19
  * The parts of the view that are targeted by view behaviors.
19
20
  */
20
21
  readonly targets: ViewBehaviorTargets;
22
+ /**
23
+ * When true, directives skip attribute/booleanAttribute DOM
24
+ * updates during bind(). This is an internal flag set only
25
+ * during the prerendered bind window.
26
+ * @internal
27
+ */
28
+ readonly _skipAttrUpdates?: boolean;
29
+ /**
30
+ * Resolves `true` when the view's host element had prerendered
31
+ * content (existing shadow root).
32
+ */
33
+ readonly isPrerendered?: Promise<boolean>;
34
+ /**
35
+ * Resolves `true` after prerendered content has been hydrated,
36
+ * `false` when client-side rendered or hydration not enabled.
37
+ */
38
+ readonly isHydrated?: Promise<boolean>;
21
39
  }
22
40
  /**
23
41
  * Represents an object that can contribute behavior to a view.
@@ -0,0 +1,130 @@
1
+ import { Hydratable } from "../components/hydration.js";
2
+ import { type HydrationMismatchActual, type HydrationMismatchExpectation } from "../hydration/diagnostics.js";
3
+ import { type ViewBehaviorBoundaries } from "../hydration/target-builder.js";
4
+ import { type ExecutionContext, SourceLifetime } from "../observation/observable.js";
5
+ import type { ViewTemplate } from "../templating/template.js";
6
+ import type { ViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
7
+ import { DefaultExecutionContext, type ElementView, type SyntheticView } from "./view.js";
8
+ /** @public */
9
+ export interface HydratableView<TSource = any, TParent = any> extends ElementView<TSource, TParent>, SyntheticView<TSource, TParent>, DefaultExecutionContext<TParent> {
10
+ [Hydratable]: symbol;
11
+ readonly bindingViewBoundaries: Record<string, ViewNodes>;
12
+ readonly hydrationStage: keyof typeof HydrationStage;
13
+ }
14
+ /**
15
+ * A view controller that can hydrate existing DOM nodes.
16
+ * @beta
17
+ */
18
+ export type HydratableViewController<TSource = any, TParent = any> = HydratableView<TSource, TParent> & ViewController<TSource, TParent>;
19
+ /** @public */
20
+ export interface ViewNodes {
21
+ first: Node;
22
+ last: Node;
23
+ }
24
+ /** @public */
25
+ export declare const HydrationStage: {
26
+ readonly unhydrated: "unhydrated";
27
+ readonly hydrating: "hydrating";
28
+ readonly hydrated: "hydrated";
29
+ };
30
+ /** @public */
31
+ export declare class HydrationBindingError extends Error {
32
+ /**
33
+ * The factory that was unable to be bound
34
+ */
35
+ readonly factory: ViewBehaviorFactory;
36
+ /**
37
+ * A DocumentFragment containing a clone of the
38
+ * view's Nodes.
39
+ */
40
+ readonly fragment: DocumentFragment;
41
+ /**
42
+ * String representation of the HTML in the template that
43
+ * threw the binding error.
44
+ */
45
+ readonly templateString: string;
46
+ /**
47
+ * Structured description of the binding the hydration walk was
48
+ * attempting to apply when the mismatch was detected.
49
+ */
50
+ readonly expected?: HydrationMismatchExpectation | undefined;
51
+ /**
52
+ * Structured description of the server-rendered DOM that was
53
+ * encountered at the mismatch point.
54
+ */
55
+ readonly received?: HydrationMismatchActual | undefined;
56
+ constructor(
57
+ /**
58
+ * The error message
59
+ */
60
+ message: string | undefined,
61
+ /**
62
+ * The factory that was unable to be bound
63
+ */
64
+ factory: ViewBehaviorFactory,
65
+ /**
66
+ * A DocumentFragment containing a clone of the
67
+ * view's Nodes.
68
+ */
69
+ fragment: DocumentFragment,
70
+ /**
71
+ * String representation of the HTML in the template that
72
+ * threw the binding error.
73
+ */
74
+ templateString: string,
75
+ /**
76
+ * Structured description of the binding the hydration walk was
77
+ * attempting to apply when the mismatch was detected.
78
+ */
79
+ expected?: HydrationMismatchExpectation | undefined,
80
+ /**
81
+ * Structured description of the server-rendered DOM that was
82
+ * encountered at the mismatch point.
83
+ */
84
+ received?: HydrationMismatchActual | undefined);
85
+ }
86
+ export declare class HydrationView<TSource = any, TParent = any> extends DefaultExecutionContext<TParent> implements HydratableView {
87
+ readonly firstChild: Node;
88
+ readonly lastChild: Node;
89
+ private sourceTemplate;
90
+ private hostBindingTarget?;
91
+ [Hydratable]: symbol;
92
+ context: ExecutionContext<any>;
93
+ source: TSource | null;
94
+ isBound: boolean;
95
+ get hydrationStage(): "hydrated" | "hydrating" | "unhydrated";
96
+ get targets(): ViewBehaviorTargets;
97
+ get bindingViewBoundaries(): ViewBehaviorBoundaries;
98
+ readonly sourceLifetime: SourceLifetime;
99
+ private unbindables;
100
+ private fragment;
101
+ private behaviors;
102
+ private factories;
103
+ private _hydrationStage;
104
+ private _bindingViewBoundaries;
105
+ private _targets;
106
+ constructor(firstChild: Node, lastChild: Node, sourceTemplate: ViewTemplate, hostBindingTarget?: Element | undefined);
107
+ /**
108
+ * no-op. Hydrated views are don't need to be moved from a documentFragment
109
+ * to the target node.
110
+ */
111
+ insertBefore(node: Node): void;
112
+ /**
113
+ * Appends the view to a node. In cases where this is called before the
114
+ * view has been removed, the method will no-op.
115
+ * @param node - the node to append the view to.
116
+ */
117
+ appendTo(node: Node): void;
118
+ remove(): void;
119
+ bind(source: TSource, context?: ExecutionContext<any>): void;
120
+ unbind(): void;
121
+ /**
122
+ * Removes the view and unbinds its behaviors, disposing of DOM nodes afterward.
123
+ * Once a view has been disposed, it cannot be inserted or bound again.
124
+ */
125
+ dispose(): void;
126
+ onUnbind(behavior: {
127
+ unbind(controller: ViewController<TSource, TParent>): void;
128
+ }): void;
129
+ private evaluateUnbindables;
130
+ }
@@ -1,6 +1,6 @@
1
1
  import { Binding, type BindingDirective } from "../binding/binding.js";
2
2
  import type { FASTElement } from "../components/fast-element.js";
3
- import type { DOMPolicy } from "../dom.js";
3
+ import type { DOMPolicy } from "../dom-policy.js";
4
4
  import { type Constructable } from "../interfaces.js";
5
5
  import type { Subscriber } from "../observation/notifier.js";
6
6
  import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
@@ -1,5 +1,5 @@
1
1
  import type { Binding, BindingDirective } from "../binding/binding.js";
2
- import { Sort, Splice } from "../observation/arrays.js";
2
+ import { type Sort, type Splice } from "../observation/arrays.js";
3
3
  import type { Subscriber } from "../observation/notifier.js";
4
4
  import { type Expression, type ExpressionObserver } from "../observation/observable.js";
5
5
  import { type AddViewBehaviorFactory, HTMLDirective, type ViewBehavior, type ViewBehaviorFactory, type ViewController } from "./html-directive.js";
@@ -1,5 +1,5 @@
1
1
  import { Binding } from "../binding/binding.js";
2
- import type { DOMPolicy } from "../dom.js";
2
+ import type { DOMPolicy } from "../dom-policy.js";
3
3
  import type { Expression } from "../observation/observable.js";
4
4
  import { type AddViewBehaviorFactory, type CompiledViewBehaviorFactory, HTMLDirective, type ViewBehaviorFactory } from "./html-directive.js";
5
5
  import type { ElementView, HTMLView, SyntheticView } from "./view.js";
@@ -22,6 +22,10 @@ export interface ElementViewTemplate<TSource = any, TParent = any> {
22
22
  */
23
23
  render(source: TSource, host: Node, hostBindingTarget?: Element): ElementView<TSource, TParent>;
24
24
  }
25
+ /**
26
+ * A template capable of hydrating an element view from existing DOM nodes.
27
+ * @beta
28
+ */
25
29
  export interface HydratableElementViewTemplate<TSource = any, TParent = any> extends ElementViewTemplate<TSource, TParent> {
26
30
  hydrate(firstChild: Node, lastChild: Node, hostBindingTarget?: Element): ElementView<TSource, TParent>;
27
31
  }
@@ -30,7 +34,7 @@ export interface HydratableElementViewTemplate<TSource = any, TParent = any> ext
30
34
  * into templates.
31
35
  * @public
32
36
  */
33
- export interface CaptureType<TSource, TParent> {
37
+ export interface CaptureType<TSource = any, TParent = any> {
34
38
  }
35
39
  /**
36
40
  * A template capable of rendering views not specifically connected to custom elements.
@@ -46,6 +50,10 @@ export interface SyntheticViewTemplate<TSource = any, TParent = any> {
46
50
  */
47
51
  inline(): CaptureType<TSource, TParent>;
48
52
  }
53
+ /**
54
+ * A template capable of hydrating a synthetic view from existing DOM nodes.
55
+ * @beta
56
+ */
49
57
  export interface HydratableSyntheticViewTemplate<TSource = any, TParent = any> extends SyntheticViewTemplate {
50
58
  hydrate(firstChild: Node, lastChild: Node): SyntheticView<TSource, TParent>;
51
59
  }
@@ -115,11 +123,6 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
115
123
  * @internal
116
124
  */
117
125
  compile(): HTMLTemplateCompilationResult<TSource, TParent>;
118
- /**
119
- * Creates an HTMLView instance based on this template definition.
120
- * @param hostBindingTarget - The element that host behaviors will be bound to.
121
- */
122
- create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
123
126
  /**
124
127
  * Returns a directive that can inline the template.
125
128
  */
@@ -141,6 +144,11 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
141
144
  * host that the template is being attached to.
142
145
  */
143
146
  render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
147
+ /**
148
+ * Creates an HTMLView instance based on this template definition.
149
+ * @param hostBindingTarget - The element that host behaviors will be bound to.
150
+ */
151
+ create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
144
152
  /**
145
153
  * Processes the tagged template literal's static strings and interpolated values and
146
154
  * creates a ViewTemplate.
@@ -1,9 +1,6 @@
1
- import { Hydratable } from "../components/hydration.js";
2
- import { type ViewBehaviorBoundaries } from "../hydration/target-builder.js";
3
1
  import type { Disposable } from "../interfaces.js";
4
2
  import { ExecutionContext, SourceLifetime } from "../observation/observable.js";
5
- import type { ViewTemplate } from "../templating/template.js";
6
- import type { CompiledViewBehaviorFactory, ViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
3
+ import type { CompiledViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
7
4
  /**
8
5
  * Represents a collection of DOM nodes which can be bound to a data source.
9
6
  * @public
@@ -77,7 +74,12 @@ export interface SyntheticView<TSource = any, TParent = any> extends View<TSourc
77
74
  */
78
75
  remove(): void;
79
76
  }
80
- declare class DefaultExecutionContext<TParent> implements ExecutionContext<TParent> {
77
+ export declare function removeNodeSequence(firstNode: Node, lastNode: Node): void;
78
+ /**
79
+ * The default execution context for template views.
80
+ * @public
81
+ */
82
+ export declare class DefaultExecutionContext<TParent> implements ExecutionContext<TParent> {
81
83
  /**
82
84
  * The index of the current item within a repeat context.
83
85
  */
@@ -154,6 +156,24 @@ export declare class HTMLView<TSource = any, TParent = any> extends DefaultExecu
154
156
  * Indicates how the source's lifetime relates to the controller's lifetime.
155
157
  */
156
158
  readonly sourceLifetime: SourceLifetime;
159
+ /**
160
+ * When true, directives skip attribute/booleanAttribute DOM
161
+ * updates during bind(). Set only during the prerendered bind
162
+ * window and cleared immediately after.
163
+ * @internal
164
+ */
165
+ _skipAttrUpdates: boolean;
166
+ /**
167
+ * A promise that resolves with `true` after prerendered content
168
+ * has been hydrated, or `false` when the view is client-side
169
+ * rendered. Resolves once the first bind completes.
170
+ */
171
+ isPrerendered: Promise<boolean>;
172
+ /**
173
+ * Resolves `true` after prerendered content has been hydrated,
174
+ * `false` when client-side rendered or hydration not enabled.
175
+ */
176
+ isHydrated: Promise<boolean>;
157
177
  /**
158
178
  * The execution context the view is running within.
159
179
  */
@@ -223,100 +243,3 @@ export declare class HTMLView<TSource = any, TParent = any> extends DefaultExecu
223
243
  */
224
244
  static disposeContiguousBatch(views: SyntheticView[]): void;
225
245
  }
226
- /** @public */
227
- export interface HydratableView<TSource = any, TParent = any> extends ElementView, SyntheticView, DefaultExecutionContext<TParent> {
228
- [Hydratable]: symbol;
229
- readonly bindingViewBoundaries: Record<string, ViewNodes>;
230
- readonly hydrationStage: keyof typeof HydrationStage;
231
- }
232
- export interface ViewNodes {
233
- first: Node;
234
- last: Node;
235
- }
236
- export declare const HydrationStage: {
237
- readonly unhydrated: "unhydrated";
238
- readonly hydrating: "hydrating";
239
- readonly hydrated: "hydrated";
240
- };
241
- /** @public */
242
- export declare class HydrationBindingError extends Error {
243
- /**
244
- * The factory that was unable to be bound
245
- */
246
- readonly factory: ViewBehaviorFactory;
247
- /**
248
- * A DocumentFragment containing a clone of the
249
- * view's Nodes.
250
- */
251
- readonly fragment: DocumentFragment;
252
- /**
253
- * String representation of the HTML in the template that
254
- * threw the binding error.
255
- */
256
- readonly templateString: string;
257
- constructor(
258
- /**
259
- * The error message
260
- */
261
- message: string | undefined,
262
- /**
263
- * The factory that was unable to be bound
264
- */
265
- factory: ViewBehaviorFactory,
266
- /**
267
- * A DocumentFragment containing a clone of the
268
- * view's Nodes.
269
- */
270
- fragment: DocumentFragment,
271
- /**
272
- * String representation of the HTML in the template that
273
- * threw the binding error.
274
- */
275
- templateString: string);
276
- }
277
- export declare class HydrationView<TSource = any, TParent = any> extends DefaultExecutionContext<TParent> implements HydratableView {
278
- readonly firstChild: Node;
279
- readonly lastChild: Node;
280
- private sourceTemplate;
281
- private hostBindingTarget?;
282
- [Hydratable]: symbol;
283
- context: ExecutionContext<any>;
284
- source: TSource | null;
285
- isBound: boolean;
286
- get hydrationStage(): "unhydrated" | "hydrating" | "hydrated";
287
- get targets(): ViewBehaviorTargets;
288
- get bindingViewBoundaries(): ViewBehaviorBoundaries;
289
- readonly sourceLifetime: SourceLifetime;
290
- private unbindables;
291
- private fragment;
292
- private behaviors;
293
- private factories;
294
- private _hydrationStage;
295
- private _bindingViewBoundaries;
296
- private _targets;
297
- constructor(firstChild: Node, lastChild: Node, sourceTemplate: ViewTemplate, hostBindingTarget?: Element | undefined);
298
- /**
299
- * no-op. Hydrated views are don't need to be moved from a documentFragment
300
- * to the target node.
301
- */
302
- insertBefore(node: Node): void;
303
- /**
304
- * Appends the view to a node. In cases where this is called before the
305
- * view has been removed, the method will no-op.
306
- * @param node - the node to append the view to.
307
- */
308
- appendTo(node: Node): void;
309
- remove(): void;
310
- bind(source: TSource, context?: ExecutionContext<any>): void;
311
- unbind(): void;
312
- /**
313
- * Removes the view and unbinds its behaviors, disposing of DOM nodes afterward.
314
- * Once a view has been disposed, it cannot be inserted or bound again.
315
- */
316
- dispose(): void;
317
- onUnbind(behavior: {
318
- unbind(controller: ViewController<TSource, TParent>): void;
319
- }): void;
320
- private evaluateUnbindables;
321
- }
322
- export {};
@@ -0,0 +1,10 @@
1
+ export type { Binding, BindingDirective } from "./binding/binding.js";
2
+ export type { DOMAspect, DOMPolicy } from "./dom.js";
3
+ export type { ExecutionContext, ExpressionController, SourceLifetime, } from "./observation/observable.js";
4
+ export { type CompilationStrategy, Compiler } from "./templating/compiler.js";
5
+ export { type ContentTemplate, type ContentView, HTMLBindingDirective, } from "./templating/html-binding-directive.js";
6
+ export { type AddViewBehaviorFactory, type Aspected, type CompiledViewBehaviorFactory, HTMLDirective, type HTMLDirectiveDefinition, htmlDirective, type PartialHTMLDirectiveDefinition, StatelessAttachedAttributeDirective, type ViewBehavior, type ViewBehaviorFactory, type ViewBehaviorTargets, type ViewController, } from "./templating/html-directive.js";
7
+ export { Markup, Parser } from "./templating/markup.js";
8
+ export { RenderBehavior, RenderDirective, render } from "./templating/render.js";
9
+ export { type CaptureType, type ElementViewTemplate, type HTMLTemplateCompilationResult, type HTMLTemplateTag, InlineTemplateDirective, type SyntheticViewTemplate, type TemplateValue, ViewTemplate, } from "./templating/template.js";
10
+ export { type ElementView, HTMLView, type SyntheticView, type View, } from "./templating/view.js";
@@ -1,3 +1,3 @@
1
- export { timeout } from "./timeout.js";
2
- export * from "./fixture.js";
3
1
  export * from "./fakes.js";
2
+ export * from "./fixture.js";
3
+ export { timeout } from "./timeout.js";
@@ -1,15 +1,15 @@
1
1
  import { ExecutionContext } from "../observation/observable.js";
2
2
  import type { ViewBehavior, ViewBehaviorTargets } from "../templating/html-directive.js";
3
3
  export declare const Fake: Readonly<{
4
- executionContext<TParent = any>(parent?: TParent | undefined, parentContext?: ExecutionContext<TParent> | undefined): ExecutionContext<TParent>;
5
- viewController<TSource = any, TParent_1 = any>(targets?: ViewBehaviorTargets, ...behaviors: ViewBehavior<TSource, TParent_1>[]): {
4
+ executionContext<TParent = any>(parent?: TParent, parentContext?: ExecutionContext<TParent>): ExecutionContext<TParent>;
5
+ viewController<TSource = any, TParent = any>(targets?: ViewBehaviorTargets, ...behaviors: ViewBehavior<TSource, TParent>[]): {
6
6
  isBound: boolean;
7
- context: ExecutionContext<TParent_1>;
7
+ context: ExecutionContext<TParent>;
8
8
  onUnbind(object: any): void;
9
9
  source: TSource;
10
10
  targets: ViewBehaviorTargets;
11
11
  toJSON: () => undefined;
12
- bind(source: TSource, context?: ExecutionContext<TParent_1>): void;
12
+ bind(source: TSource, context?: ExecutionContext<TParent>): void;
13
13
  unbind(): void;
14
14
  };
15
15
  }>;
@@ -0,0 +1 @@
1
+ export { type UpdateQueue, Updates } from "./observation/update-queue.js";
@@ -0,0 +1,2 @@
1
+ export type { Accessor } from "./observation/observable.js";
2
+ export { volatile } from "./observation/observable.js";
@@ -0,0 +1,22 @@
1
+ export function toHTML(node, preserveCommentMarkup = false) {
2
+ return Array.from(node.childNodes)
3
+ .map((x) => {
4
+ if (preserveCommentMarkup && x.nodeType === 8) {
5
+ return `<!--${x.textContent}-->`;
6
+ }
7
+ return x.outerHTML || x.textContent;
8
+ })
9
+ .join("");
10
+ }
11
+ export function createTrackableDOMPolicy() {
12
+ return {
13
+ used: false,
14
+ createHTML: (html) => html,
15
+ protect(tagName, aspect, aspectName, sink) {
16
+ return (node, aspectName, value, ...args) => {
17
+ this.used = true;
18
+ sink(node, aspectName, value, ...args);
19
+ };
20
+ },
21
+ };
22
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ if (window.document && !window.document.createRange) {
4
+ window.document.createRange = () => ({
5
+ setStart: () => { },
6
+ setEnd: () => { },
7
+ // @ts-ignore
8
+ commonAncestorContainer: {
9
+ nodeName: "BODY",
10
+ ownerDocument: document,
11
+ },
12
+ });
13
+ }
14
+ if (!window.requestAnimationFrame) {
15
+ window.requestAnimationFrame = function (callback) {
16
+ return setTimeout(callback, 4);
17
+ };
18
+ }
@@ -0,0 +1 @@
1
+ export { ArrayObserver, Sort, Splice, SpliceStrategy, SpliceStrategySupport, } from "./observation/arrays.js";