@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.
- package/CHANGELOG.md +52 -2
- package/README.md +244 -1
- package/dist/arrays/arrays.api.json +2621 -0
- package/dist/context/context.api.json +13 -13
- package/dist/declarative/declarative.api.json +8483 -0
- package/dist/di/di.api.json +16 -16
- package/dist/dts/__test__/helpers.d.ts +6 -0
- package/dist/dts/array-observer.d.ts +2 -0
- package/dist/dts/arrays.d.ts +2 -0
- package/dist/dts/attr.d.ts +1 -0
- package/dist/dts/binding/binding.d.ts +15 -5
- package/dist/dts/binding/one-time.d.ts +1 -1
- package/dist/dts/binding/one-way.d.ts +1 -1
- package/dist/dts/binding/signal.d.ts +6 -6
- package/dist/dts/binding/two-way.d.ts +2 -1
- package/dist/dts/binding.d.ts +7 -0
- package/dist/dts/components/attributes.d.ts +1 -4
- package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
- package/dist/dts/components/element-controller.d.ts +80 -114
- package/dist/dts/components/element-hydration.d.ts +1 -1
- package/dist/dts/components/enable-hydration.d.ts +54 -0
- package/dist/dts/components/fast-definitions.d.ts +98 -46
- package/dist/dts/components/fast-element.d.ts +43 -16
- package/dist/dts/components/hydration-tracker.d.ts +83 -0
- package/dist/dts/components/hydration.d.ts +23 -53
- package/dist/dts/components/schema.d.ts +205 -0
- package/dist/dts/context.d.ts +13 -13
- package/dist/dts/css.d.ts +3 -0
- package/dist/dts/debug.d.ts +5 -1
- package/dist/dts/declarative/attribute-map.d.ts +58 -0
- package/dist/dts/declarative/debug.d.ts +4 -0
- package/dist/dts/declarative/index.d.ts +14 -0
- package/dist/dts/declarative/interfaces.d.ts +8 -0
- package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
- package/dist/dts/declarative/observer-map.d.ts +89 -0
- package/dist/dts/declarative/runtime.d.ts +5 -0
- package/dist/dts/declarative/syntax.d.ts +21 -0
- package/dist/dts/declarative/template-bridge.d.ts +33 -0
- package/dist/dts/declarative/template-parser.d.ts +98 -0
- package/dist/dts/declarative/template.d.ts +10 -0
- package/dist/dts/declarative/utilities.d.ts +358 -0
- package/dist/dts/di/di.d.ts +7 -7
- package/dist/dts/directives/children.d.ts +2 -0
- package/dist/dts/directives/node-observation.d.ts +2 -0
- package/dist/dts/directives/ref.d.ts +2 -0
- package/dist/dts/directives/repeat.d.ts +4 -0
- package/dist/dts/directives/slotted.d.ts +2 -0
- package/dist/dts/directives/when.d.ts +3 -0
- package/dist/dts/dom-policy.d.ts +23 -5
- package/dist/dts/dom.d.ts +4 -16
- package/dist/dts/html.d.ts +5 -0
- package/dist/dts/hydration/diagnostics.d.ts +93 -0
- package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
- package/dist/dts/hydration/messages.d.ts +62 -0
- package/dist/dts/hydration/runtime.d.ts +7 -0
- package/dist/dts/hydration/target-builder.d.ts +40 -12
- package/dist/dts/hydration.d.ts +18 -0
- package/dist/dts/index.d.ts +42 -42
- package/dist/dts/index.debug.d.ts +0 -1
- package/dist/dts/index.rollup.debug.d.ts +0 -1
- package/dist/dts/interfaces.d.ts +2 -49
- package/dist/dts/observable.d.ts +3 -6
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +3 -3
- package/dist/dts/observation/update-queue.d.ts +1 -1
- package/dist/dts/platform.d.ts +45 -8
- package/dist/dts/registry.d.ts +1 -0
- package/dist/dts/render.d.ts +7 -0
- package/dist/dts/schema.d.ts +1 -0
- package/dist/dts/state/exports.d.ts +1 -1
- package/dist/dts/state/state.d.ts +2 -2
- package/dist/dts/styles/css-directive.d.ts +5 -12
- package/dist/dts/styles/css.d.ts +5 -7
- package/dist/dts/styles/element-styles.d.ts +0 -10
- package/dist/dts/styles.d.ts +6 -0
- package/dist/dts/templating/compiler.d.ts +1 -1
- package/dist/dts/templating/html-binding-directive.d.ts +10 -2
- package/dist/dts/templating/html-directive.d.ts +19 -1
- package/dist/dts/templating/hydration-view.d.ts +130 -0
- package/dist/dts/templating/render.d.ts +1 -1
- package/dist/dts/templating/repeat.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +15 -7
- package/dist/dts/templating/view.d.ts +25 -102
- package/dist/dts/templating.d.ts +10 -0
- package/dist/dts/testing/exports.d.ts +2 -2
- package/dist/dts/testing/fakes.d.ts +4 -4
- package/dist/dts/updates.d.ts +1 -0
- package/dist/dts/volatile.d.ts +2 -0
- package/dist/esm/__test__/helpers.js +22 -0
- package/dist/esm/__test__/setup-node.js +18 -0
- package/dist/esm/array-observer.js +1 -0
- package/dist/esm/arrays.js +1 -0
- package/dist/esm/attr.js +1 -0
- package/dist/esm/binding/normalize.js +1 -1
- package/dist/esm/binding/signal.js +4 -4
- package/dist/esm/binding/two-way.js +3 -3
- package/dist/esm/binding.js +4 -0
- package/dist/esm/components/attributes.js +18 -11
- package/dist/esm/components/definition-schema-transforms.js +23 -0
- package/dist/esm/components/element-controller.js +206 -270
- package/dist/esm/components/element-hydration.js +1 -1
- package/dist/esm/components/enable-hydration.js +124 -0
- package/dist/esm/components/fast-definitions.js +219 -56
- package/dist/esm/components/fast-element.js +18 -27
- package/dist/esm/components/hydration-tracker.js +122 -0
- package/dist/esm/components/hydration.js +137 -140
- package/dist/esm/components/schema.js +253 -0
- package/dist/esm/context.js +6 -6
- package/dist/esm/css.js +3 -0
- package/dist/esm/debug.js +27 -26
- package/dist/esm/declarative/attribute-map.js +122 -0
- package/dist/esm/declarative/debug.js +4 -0
- package/dist/esm/declarative/index.js +4 -0
- package/dist/esm/declarative/interfaces.js +9 -0
- package/dist/esm/declarative/observer-map-utilities.js +565 -0
- package/dist/esm/declarative/observer-map.js +216 -0
- package/dist/esm/declarative/runtime.js +14 -0
- package/dist/esm/declarative/syntax.js +36 -0
- package/dist/esm/declarative/template-bridge.js +160 -0
- package/dist/esm/declarative/template-parser.js +306 -0
- package/dist/esm/declarative/template.js +143 -0
- package/dist/esm/declarative/utilities.js +1069 -0
- package/dist/esm/di/di.js +8 -9
- package/dist/esm/directives/children.js +1 -0
- package/dist/esm/directives/node-observation.js +1 -0
- package/dist/esm/directives/ref.js +1 -0
- package/dist/esm/directives/repeat.js +1 -0
- package/dist/esm/directives/slotted.js +1 -0
- package/dist/esm/directives/when.js +1 -0
- package/dist/esm/dom-policy.js +35 -6
- package/dist/esm/dom.js +1 -1
- package/dist/esm/html.js +2 -0
- package/dist/esm/hydration/diagnostics.js +50 -0
- package/dist/esm/hydration/hydration-debugger.js +112 -0
- package/dist/esm/hydration/messages.js +84 -0
- package/dist/esm/hydration/runtime.js +33 -0
- package/dist/esm/hydration/target-builder.js +144 -91
- package/dist/esm/hydration.js +6 -0
- package/dist/esm/index.debug.js +2 -1
- package/dist/esm/index.js +38 -29
- package/dist/esm/index.rollup.debug.js +3 -2
- package/dist/esm/index.rollup.js +1 -1
- package/dist/esm/interfaces.js +2 -45
- package/dist/esm/metadata.js +2 -8
- package/dist/esm/observable.js +1 -4
- package/dist/esm/observation/arrays.js +1 -1
- package/dist/esm/observation/notifier.js +2 -4
- package/dist/esm/observation/observable.js +5 -5
- package/dist/esm/observation/update-queue.js +47 -58
- package/dist/esm/platform.js +31 -30
- package/dist/esm/registry.js +1 -0
- package/dist/esm/render.js +1 -0
- package/dist/esm/schema.js +1 -0
- package/dist/esm/state/exports.js +1 -1
- package/dist/esm/styles/css-directive.js +1 -2
- package/dist/esm/styles/css.js +15 -56
- package/dist/esm/styles/element-styles.js +69 -15
- package/dist/esm/styles.js +2 -0
- package/dist/esm/templating/html-binding-directive.js +11 -9
- package/dist/esm/templating/hydration-view.js +228 -0
- package/dist/esm/templating/render.js +39 -18
- package/dist/esm/templating/repeat.js +69 -33
- package/dist/esm/templating/template.js +7 -7
- package/dist/esm/templating/view.js +25 -234
- package/dist/esm/templating.js +7 -0
- package/dist/esm/testing/exports.js +2 -2
- package/dist/esm/testing/fixture.js +2 -2
- package/dist/esm/testing/timeout.js +2 -2
- package/dist/esm/updates.js +1 -0
- package/dist/esm/volatile.js +1 -0
- package/dist/fast-element.api.json +14389 -11138
- package/dist/fast-element.d.ts +3651 -809
- package/dist/fast-element.debug.js +5666 -4722
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +5394 -4381
- package/dist/fast-element.min.js +2 -2
- package/dist/fast-element.untrimmed.d.ts +923 -472
- package/dist/hydration/hydration.api.json +6460 -0
- package/dist/styles/styles.api.json +2672 -0
- package/package.json +165 -45
- package/ARCHITECTURE_FASTELEMENT.md +0 -63
- package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +0 -36
- package/ARCHITECTURE_INTRO.md +0 -10
- package/ARCHITECTURE_OVERVIEW.md +0 -52
- package/ARCHITECTURE_UPDATES.md +0 -11
- package/CHANGELOG.json +0 -2275
- package/DESIGN.md +0 -510
- package/api-extractor.context.json +0 -14
- package/api-extractor.di.json +0 -14
- package/biome.json +0 -4
- package/dist/dts/components/install-hydration.d.ts +0 -1
- package/dist/dts/pending-task.d.ts +0 -32
- package/dist/dts/styles/css-binding-directive.d.ts +0 -60
- package/dist/dts/templating/install-hydratable-view-templates.d.ts +0 -1
- package/dist/esm/components/install-hydration.js +0 -3
- package/dist/esm/pending-task.js +0 -28
- package/dist/esm/polyfills.js +0 -60
- package/dist/esm/styles/css-binding-directive.js +0 -76
- package/dist/esm/templating/install-hydratable-view-templates.js +0 -23
- package/docs/ACKNOWLEDGEMENTS.md +0 -12
- package/docs/api-report.api.md +0 -1122
- package/docs/context/api-report.api.md +0 -69
- package/docs/di/api-report.api.md +0 -315
- package/docs/fast-element-2-changes.md +0 -15
- package/playwright.config.ts +0 -26
- package/scripts/run-api-extractor.js +0 -51
- package/test/index.html +0 -11
- package/test/main.ts +0 -104
- package/test/vite.config.ts +0 -19
- package/tsconfig.api-extractor.json +0 -6
- /package/dist/dts/{polyfills.d.ts → __test__/setup-node.d.ts} +0 -0
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { type Constructable } from "../interfaces.js";
|
|
2
|
-
import { type TypeRegistry } from "../platform.js";
|
|
2
|
+
import { type TypeDefinition, type TypeRegistry } from "../platform.js";
|
|
3
3
|
import { type ComposableStyles, ElementStyles } from "../styles/element-styles.js";
|
|
4
4
|
import type { ElementViewTemplate } from "../templating/template.js";
|
|
5
|
-
import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";
|
|
5
|
+
import { type AttributeConfiguration, AttributeDefinition } from "./attributes.js";
|
|
6
|
+
import type { Schema } from "./schema.js";
|
|
6
7
|
/**
|
|
7
|
-
* The FAST custom element registry
|
|
8
|
-
* @
|
|
8
|
+
* The FAST custom element registry.
|
|
9
|
+
* @remarks
|
|
10
|
+
* This registry stores FAST element definitions by constructor so consumers can
|
|
11
|
+
* look up the `FASTElementDefinition` associated with an element type or instance.
|
|
12
|
+
* @public
|
|
9
13
|
*/
|
|
10
14
|
export declare const fastElementRegistry: TypeRegistry<FASTElementDefinition>;
|
|
11
|
-
export type { TypeRegistry };
|
|
15
|
+
export type { TypeDefinition, TypeRegistry };
|
|
12
16
|
/**
|
|
13
17
|
* Shadow root initialization options.
|
|
14
18
|
* @public
|
|
@@ -21,50 +25,99 @@ export interface ShadowRootOptions extends ShadowRootInit {
|
|
|
21
25
|
*/
|
|
22
26
|
registry?: CustomElementRegistry;
|
|
23
27
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Values for the `templateOptions` property.
|
|
26
|
-
* @alpha
|
|
27
|
-
*/
|
|
28
|
-
export declare const TemplateOptions: {
|
|
29
|
-
readonly deferAndHydrate: "defer-and-hydrate";
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Type for the `TemplateOptions` const enum.
|
|
33
|
-
* @alpha
|
|
34
|
-
*/
|
|
35
|
-
export type TemplateOptions = (typeof TemplateOptions)[keyof typeof TemplateOptions];
|
|
36
28
|
/**
|
|
37
29
|
* Lifecycle callbacks for template events.
|
|
38
30
|
* @public
|
|
39
31
|
*/
|
|
40
32
|
export interface TemplateLifecycleCallbacks {
|
|
41
33
|
/**
|
|
42
|
-
* Called after the
|
|
34
|
+
* Called after the JS class definition has been registered.
|
|
35
|
+
*/
|
|
36
|
+
elementDidRegister?(name: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Called before the template has been evaluated and assigned.
|
|
39
|
+
*/
|
|
40
|
+
templateWillUpdate?(name: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Called after the template has been assigned to the definition.
|
|
43
43
|
*/
|
|
44
44
|
templateDidUpdate?(name: string): void;
|
|
45
45
|
/**
|
|
46
|
-
* Called after the custom element has been defined
|
|
46
|
+
* Called after the custom element has been defined.
|
|
47
47
|
*/
|
|
48
48
|
elementDidDefine?(name: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Called before an individual element's hydration begins.
|
|
51
|
+
*/
|
|
52
|
+
elementWillHydrate?(source: HTMLElement): void;
|
|
53
|
+
/**
|
|
54
|
+
* Called after an individual element's hydration has finished.
|
|
55
|
+
*/
|
|
56
|
+
elementDidHydrate?(source: HTMLElement): void;
|
|
49
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A callback that receives a FASTElementDefinition during element registration.
|
|
60
|
+
* Extensions are invoked before the element is registered with the platform,
|
|
61
|
+
* allowing plugins to inspect or act on the resolved definition.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export type FASTElementExtension = (definition: FASTElementDefinition) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves an element template from a composed definition.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export type FASTElementTemplateResolver<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> = (definition: FASTElementDefinition<TType>) => ElementViewTemplate<InstanceType<TType>> | Promise<ElementViewTemplate<InstanceType<TType>>>;
|
|
70
|
+
/**
|
|
71
|
+
* Applies extension callbacks to a FAST element definition.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function applyFASTElementExtensions(definition: FASTElementDefinition, registry?: CustomElementRegistry, extensions?: FASTElementExtension[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Tracks attribute definitions that were added after the element was already
|
|
77
|
+
* registered with the platform and therefore are not covered by the browser's
|
|
78
|
+
* static observedAttributes snapshot.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export declare function trackLateAttributeDefinition(definition: FASTElementDefinition, attribute: AttributeDefinition): void;
|
|
82
|
+
/**
|
|
83
|
+
* Gets the attribute definitions that were added after platform registration.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
export declare function getLateAttributeLookup(definition: FASTElementDefinition): Readonly<Record<string, AttributeDefinition>> | null;
|
|
87
|
+
/**
|
|
88
|
+
* Resolves the concrete template for a FAST element definition when the
|
|
89
|
+
* definition was composed with a template resolver.
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
export declare function resolveFASTElementTemplate<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>): ElementViewTemplate<InstanceType<TType>> | Promise<ElementViewTemplate<InstanceType<TType>> | undefined> | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Indicates whether a definition still has a pending template resolver.
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
export declare function hasFASTElementTemplateResolver<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Gets any pending template resolution error for a FAST element definition.
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
export declare function getFASTElementTemplateError<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>): unknown;
|
|
103
|
+
/**
|
|
104
|
+
* Sets or clears the template resolution error for a FAST element definition.
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
export declare function setFASTElementTemplateError<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(definition: FASTElementDefinition<TType>, error?: unknown): void;
|
|
50
108
|
/**
|
|
51
109
|
* Represents metadata configuration for a custom element.
|
|
52
110
|
* @public
|
|
53
111
|
*/
|
|
54
|
-
export interface PartialFASTElementDefinition {
|
|
112
|
+
export interface PartialFASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
|
|
55
113
|
/**
|
|
56
114
|
* The name of the custom element.
|
|
57
115
|
*/
|
|
58
116
|
readonly name: string;
|
|
59
117
|
/**
|
|
60
|
-
* The template
|
|
118
|
+
* The template, or template resolver, for the custom element.
|
|
61
119
|
*/
|
|
62
|
-
readonly template?: ElementViewTemplate
|
|
63
|
-
/**
|
|
64
|
-
* Options controlling how the template will be created.
|
|
65
|
-
* @alpha
|
|
66
|
-
*/
|
|
67
|
-
readonly templateOptions?: TemplateOptions;
|
|
120
|
+
readonly template?: ElementViewTemplate<InstanceType<TType>> | FASTElementTemplateResolver<TType>;
|
|
68
121
|
/**
|
|
69
122
|
* The styles to associate with the custom element.
|
|
70
123
|
*/
|
|
@@ -94,6 +147,12 @@ export interface PartialFASTElementDefinition {
|
|
|
94
147
|
* Lifecycle callbacks for template events.
|
|
95
148
|
*/
|
|
96
149
|
readonly lifecycleCallbacks?: TemplateLifecycleCallbacks;
|
|
150
|
+
/**
|
|
151
|
+
* The optional schema associated with the custom element definition.
|
|
152
|
+
* Declarative templates assign this automatically during template resolution.
|
|
153
|
+
* Non-declarative callers can provide one for schema-driven extensions.
|
|
154
|
+
*/
|
|
155
|
+
readonly schema?: Schema;
|
|
97
156
|
}
|
|
98
157
|
/**
|
|
99
158
|
* Defines metadata for a FASTElement.
|
|
@@ -128,12 +187,7 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
|
|
|
128
187
|
/**
|
|
129
188
|
* The template to render for the custom element.
|
|
130
189
|
*/
|
|
131
|
-
template?: ElementViewTemplate
|
|
132
|
-
/**
|
|
133
|
-
* The template options.
|
|
134
|
-
* @alpha
|
|
135
|
-
*/
|
|
136
|
-
templateOptions?: TemplateOptions;
|
|
190
|
+
template?: ElementViewTemplate<InstanceType<TType>>;
|
|
137
191
|
/**
|
|
138
192
|
* The styles to associate with the custom element.
|
|
139
193
|
*/
|
|
@@ -154,6 +208,12 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
|
|
|
154
208
|
* Lifecycle callbacks for template events.
|
|
155
209
|
*/
|
|
156
210
|
readonly lifecycleCallbacks?: TemplateLifecycleCallbacks;
|
|
211
|
+
/**
|
|
212
|
+
* The optional schema associated with the custom element definition.
|
|
213
|
+
* Declarative templates assign this automatically during template resolution.
|
|
214
|
+
* Non-declarative callers can provide one for schema-driven extensions.
|
|
215
|
+
*/
|
|
216
|
+
schema?: Schema;
|
|
157
217
|
/**
|
|
158
218
|
* The definition has been registered to the FAST element registry.
|
|
159
219
|
*/
|
|
@@ -162,17 +222,19 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
|
|
|
162
222
|
/**
|
|
163
223
|
* Defines a custom element based on this definition.
|
|
164
224
|
* @param registry - The element registry to define the element in.
|
|
225
|
+
* @param extensions - An optional array of extension callbacks to invoke
|
|
226
|
+
* with this definition before platform registration.
|
|
165
227
|
* @remarks
|
|
166
228
|
* This operation is idempotent per registry.
|
|
167
229
|
*/
|
|
168
|
-
define(registry?: CustomElementRegistry): this;
|
|
230
|
+
define(registry?: CustomElementRegistry, extensions?: FASTElementExtension[]): this;
|
|
169
231
|
/**
|
|
170
232
|
* Creates an instance of FASTElementDefinition.
|
|
171
233
|
* @param type - The type this definition is being created for.
|
|
172
234
|
* @param nameOrDef - The name of the element to define or a config object
|
|
173
235
|
* that describes the element to define.
|
|
174
236
|
*/
|
|
175
|
-
static compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType
|
|
237
|
+
static compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition<TType>): Promise<FASTElementDefinition<TType>>;
|
|
176
238
|
/**
|
|
177
239
|
* Registers a FASTElement base type.
|
|
178
240
|
* @param type - The type to register as a base type.
|
|
@@ -194,15 +256,5 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
|
|
|
194
256
|
* @param name - The name of the defined custom element.
|
|
195
257
|
* @alpha
|
|
196
258
|
*/
|
|
197
|
-
static
|
|
198
|
-
/**
|
|
199
|
-
* Creates an instance of FASTElementDefinition asynchronously. This option assumes
|
|
200
|
-
* that a template and shadowOptions will be provided and completes when those requirements
|
|
201
|
-
* are met.
|
|
202
|
-
* @param type - The type this definition is being created for.
|
|
203
|
-
* @param nameOrDef - The name of the element to define or a config object
|
|
204
|
-
* that describes the element to define.
|
|
205
|
-
* @alpha
|
|
206
|
-
*/
|
|
207
|
-
static composeAsync<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): Promise<FASTElementDefinition<TType>>;
|
|
259
|
+
static register: (name: string, registry?: CustomElementRegistry) => Promise<Function>;
|
|
208
260
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Constructable } from "../interfaces.js";
|
|
2
2
|
import { ElementController } from "./element-controller.js";
|
|
3
|
-
import { FASTElementDefinition, type PartialFASTElementDefinition } from "./fast-definitions.js";
|
|
3
|
+
import { FASTElementDefinition, type FASTElementExtension, type PartialFASTElementDefinition } from "./fast-definitions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represents a custom element based on the FASTElement infrastructure.
|
|
6
6
|
* @public
|
|
@@ -45,25 +45,53 @@ export interface FASTElement extends HTMLElement {
|
|
|
45
45
|
*/
|
|
46
46
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The FASTElement constructor and static registration helpers.
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export interface FASTElementConstructor {
|
|
53
|
+
/**
|
|
54
|
+
* Creates a FASTElement instance.
|
|
55
|
+
*/
|
|
56
|
+
new (): FASTElement;
|
|
57
|
+
/**
|
|
58
|
+
* Defines a platform custom element based on the provided type and definition.
|
|
59
|
+
* @param nameOrDef - The name of the element to define or a definition object.
|
|
60
|
+
* @param extensions - Optional callbacks to run before registration.
|
|
61
|
+
*/
|
|
62
|
+
define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition<TType>, extensions?: FASTElementExtension[]): Promise<TType>;
|
|
63
|
+
/**
|
|
64
|
+
* Defines a platform custom element based on the provided type and definition.
|
|
65
|
+
* @param type - The custom element type to define.
|
|
66
|
+
* @param nameOrDef - The name of the element to define or a definition object.
|
|
67
|
+
* @param extensions - Optional callbacks to run before registration.
|
|
68
|
+
*/
|
|
69
|
+
define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition<TType>, extensions?: FASTElementExtension[]): Promise<TType>;
|
|
70
|
+
/**
|
|
71
|
+
* Composes FASTElement metadata without registering the element.
|
|
72
|
+
* @param nameOrDef - The name of the element to compose or a definition object.
|
|
73
|
+
*/
|
|
74
|
+
compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition<TType>): Promise<FASTElementDefinition<TType>>;
|
|
75
|
+
/**
|
|
76
|
+
* Composes FASTElement metadata without registering the element.
|
|
77
|
+
* @param type - The custom element type to compose.
|
|
78
|
+
* @param nameOrDef - The name of the element to compose or a definition object.
|
|
79
|
+
*/
|
|
80
|
+
compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition<TType>): Promise<FASTElementDefinition<TType>>;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new FASTElement base class inherited from the provided base type.
|
|
83
|
+
* @param BaseType - The base element type to inherit from.
|
|
84
|
+
*/
|
|
85
|
+
from<TBase extends typeof HTMLElement>(BaseType: TBase): {
|
|
86
|
+
new (): InstanceType<TBase> & FASTElement;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
55
89
|
/**
|
|
56
90
|
* A minimal base class for FASTElements that also provides
|
|
57
91
|
* static helpers for working with FASTElements.
|
|
58
92
|
* @public
|
|
59
93
|
*/
|
|
60
|
-
export declare const FASTElement:
|
|
61
|
-
new (): FASTElement;
|
|
62
|
-
define: typeof define;
|
|
63
|
-
compose: typeof compose;
|
|
64
|
-
defineAsync: typeof defineAsync;
|
|
65
|
-
from: typeof from;
|
|
66
|
-
};
|
|
94
|
+
export declare const FASTElement: FASTElementConstructor;
|
|
67
95
|
/**
|
|
68
96
|
* Decorator: Defines a platform custom element based on `FASTElement`.
|
|
69
97
|
* @param nameOrDef - The name of the element to define or a definition object
|
|
@@ -71,4 +99,3 @@ export declare const FASTElement: {
|
|
|
71
99
|
* @public
|
|
72
100
|
*/
|
|
73
101
|
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
|
|
74
|
-
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes when FAST should stop hydrating newly connected prerendered elements.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export declare const StopHydration: Readonly<{
|
|
6
|
+
/**
|
|
7
|
+
* Stop hydrating new prerendered elements after the active hydration batch completes.
|
|
8
|
+
*/
|
|
9
|
+
readonly hydrationComplete: "hydration-complete";
|
|
10
|
+
/**
|
|
11
|
+
* Keep the hydration hook active for later prerendered elements.
|
|
12
|
+
*/
|
|
13
|
+
readonly never: "never";
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Describes when FAST should stop hydrating newly connected prerendered elements.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type StopHydration = (typeof StopHydration)[keyof typeof StopHydration];
|
|
20
|
+
import type { HydrationDebugger } from "../hydration/hydration-debugger.js";
|
|
21
|
+
/**
|
|
22
|
+
* Options for configuring global hydration lifecycle events and behavior.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export interface HydrationOptions {
|
|
26
|
+
/** Called when a prerendered hydration batch begins. */
|
|
27
|
+
hydrationStarted?(): void;
|
|
28
|
+
/** Called after all prerendered elements in a hydration batch complete. */
|
|
29
|
+
hydrationComplete?(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Indicates when the hydration hook should stop handling new
|
|
32
|
+
* prerendered elements.
|
|
33
|
+
*
|
|
34
|
+
* @defaultValue StopHydration.hydrationComplete
|
|
35
|
+
*/
|
|
36
|
+
stopHydration?: StopHydration;
|
|
37
|
+
/**
|
|
38
|
+
* Optional opt-in debugger that swaps the default minimal hydration
|
|
39
|
+
* mismatch error message for a rich "Expected … / Received …" report
|
|
40
|
+
* including an HTML snippet of the SSR DOM and structured
|
|
41
|
+
* `expected`/`received` fields on `HydrationBindingError` /
|
|
42
|
+
* `HydrationTargetElementError`. Obtained via
|
|
43
|
+
* `hydrationDebugger()` from `@microsoft/fast-element/hydration.js`.
|
|
44
|
+
*/
|
|
45
|
+
debugger?: HydrationDebugger;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tracks prerendered elements through the hydration lifecycle and
|
|
49
|
+
* fires global callbacks at start and completion. Per-element callbacks
|
|
50
|
+
* (`elementWillHydrate`, `elementDidHydrate`) are handled through
|
|
51
|
+
* definition-level `TemplateLifecycleCallbacks`.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare class HydrationTracker {
|
|
56
|
+
private elements;
|
|
57
|
+
private started;
|
|
58
|
+
private completed;
|
|
59
|
+
private checkTimer;
|
|
60
|
+
private callbacks;
|
|
61
|
+
private stopHydration;
|
|
62
|
+
constructor(options: HydrationOptions);
|
|
63
|
+
/**
|
|
64
|
+
* Indicates whether the hydration hook should attempt to hydrate
|
|
65
|
+
* prerendered elements.
|
|
66
|
+
*/
|
|
67
|
+
get shouldHydrate(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Registers an element as pending hydration.
|
|
70
|
+
* Fires `hydrationStarted` on the first call.
|
|
71
|
+
*/
|
|
72
|
+
add(element: HTMLElement): void;
|
|
73
|
+
/**
|
|
74
|
+
* Removes an element from the pending set and schedules
|
|
75
|
+
* a debounced completion check.
|
|
76
|
+
*/
|
|
77
|
+
remove(element: HTMLElement): void;
|
|
78
|
+
/**
|
|
79
|
+
* Merges additional options into the tracker, chaining
|
|
80
|
+
* callbacks so both the original and new callbacks fire.
|
|
81
|
+
*/
|
|
82
|
+
mergeOptions(incoming: HydrationOptions): void;
|
|
83
|
+
}
|
|
@@ -1,63 +1,38 @@
|
|
|
1
1
|
import type { ContentTemplate, HydratableContentTemplate } from "../templating/html-binding-directive.js";
|
|
2
2
|
import type { ViewController } from "../templating/html-directive.js";
|
|
3
|
+
import type { HydratableViewController } from "../templating/hydration-view.js";
|
|
3
4
|
import type { ElementViewTemplate, HydratableElementViewTemplate, HydratableSyntheticViewTemplate, SyntheticViewTemplate } from "../templating/template.js";
|
|
4
|
-
import type { HydrationView } from "../templating/view.js";
|
|
5
5
|
/**
|
|
6
6
|
* Markup utilities to aid in template hydration.
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
export declare const HydrationMarkup: Readonly<{
|
|
10
|
-
attributeMarkerName: "data-fe
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
contentBindingStartMarker(
|
|
14
|
-
contentBindingEndMarker(
|
|
15
|
-
repeatStartMarker(
|
|
16
|
-
repeatEndMarker(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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;
|
|
21
23
|
isElementBoundaryStartMarker(node: Node): boolean;
|
|
22
24
|
isElementBoundaryEndMarker(node: Node): boolean;
|
|
23
25
|
/**
|
|
24
|
-
* Returns the
|
|
25
|
-
*
|
|
26
|
+
* Returns the count of attribute bindings on the element, or null
|
|
27
|
+
* if no attribute binding marker is present.
|
|
26
28
|
*
|
|
27
|
-
*
|
|
29
|
+
* Parses the `data-fe="N"` attribute format where N is the count
|
|
30
|
+
* of attribute binding factories targeting this element.
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
* This method parses the enumerated format: `data-fe-b-0`, `data-fe-b-1`, `data-fe-b-2`.
|
|
35
|
-
* This is an alternative format that uses separate attributes for each binding index.
|
|
36
|
-
*/
|
|
37
|
-
parseEnumeratedAttributeBinding(node: Element): null | number[];
|
|
38
|
-
/**
|
|
39
|
-
* Returns the indexes of the ViewBehaviorFactories affecting
|
|
40
|
-
* attributes for the element, or null if no factories were found.
|
|
41
|
-
*
|
|
42
|
-
* This method parses the compact format: `data-fe-c-{index}-{count}`.
|
|
43
|
-
*/
|
|
44
|
-
parseCompactAttributeBinding(node: Element): null | number[];
|
|
45
|
-
/**
|
|
46
|
-
* Parses the ViewBehaviorFactory index from string data. Returns
|
|
47
|
-
* the binding index or null if the index cannot be retrieved.
|
|
48
|
-
*/
|
|
49
|
-
parseContentBindingStartMarker(content: string): null | [index: number, id: string];
|
|
50
|
-
parseContentBindingEndMarker(content: string): null | [index: number, id: string];
|
|
51
|
-
/**
|
|
52
|
-
* Parses the index of a repeat directive from a content string.
|
|
53
|
-
*/
|
|
54
|
-
parseRepeatStartMarker(content: string): null | number;
|
|
55
|
-
parseRepeatEndMarker(content: string): null | number;
|
|
56
|
-
/**
|
|
57
|
-
* Parses element Id from element boundary markers
|
|
58
|
-
*/
|
|
59
|
-
parseElementBoundaryStartMarker(content: string): null | string;
|
|
60
|
-
parseElementBoundaryEndMarker(content: string): null | string;
|
|
32
|
+
parseAttributeBindingCount(node: Element): number | null;
|
|
33
|
+
parseLegacyAttributeBindingIndices(node: Element): number[] | null;
|
|
34
|
+
removeLegacyAttributeBindingMarkers(node: Element): void;
|
|
35
|
+
parseLegacyContentBindingStartIndex(data: string): number | null;
|
|
61
36
|
}>;
|
|
62
37
|
/**
|
|
63
38
|
* @internal
|
|
@@ -68,15 +43,10 @@ export declare const Hydratable: unique symbol;
|
|
|
68
43
|
*
|
|
69
44
|
* @beta
|
|
70
45
|
*/
|
|
71
|
-
export declare function isHydratable(view: ViewController): view is
|
|
46
|
+
export declare function isHydratable(view: ViewController): view is HydratableViewController;
|
|
72
47
|
/** @beta */
|
|
73
48
|
export declare function isHydratable<TSource = any, TParent = any>(template: SyntheticViewTemplate<TSource, TParent>): template is HydratableSyntheticViewTemplate<TSource, TParent>;
|
|
74
49
|
/** @beta */
|
|
75
50
|
export declare function isHydratable<TSource = any, TParent = any>(template: ElementViewTemplate<TSource, TParent>): template is HydratableElementViewTemplate<TSource, TParent>;
|
|
76
51
|
/** @beta */
|
|
77
52
|
export declare function isHydratable(template: ContentTemplate): template is HydratableContentTemplate;
|
|
78
|
-
/**
|
|
79
|
-
* The attribute used to defer hydration of an element.
|
|
80
|
-
* @beta
|
|
81
|
-
*/
|
|
82
|
-
export declare const deferHydrationAttribute = "defer-hydration";
|