@microsoft/fast-element 2.10.4 → 3.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +1 -1
- package/ARCHITECTURE_OVERVIEW.md +2 -2
- package/CHANGELOG.json +1 -1
- package/CHANGELOG.md +2 -2
- package/DECLARATIVE_DESIGN.md +806 -0
- package/DECLARATIVE_HTML.md +470 -0
- package/DECLARATIVE_MIGRATION.md +215 -0
- package/DECLARATIVE_RENDERING.md +530 -0
- package/DECLARATIVE_RENDERING_LIFECYCLE.md +288 -0
- package/DECLARATIVE_SCHEMA_OBSERVER_MAP.md +489 -0
- package/DESIGN.md +138 -33
- package/MIGRATION.md +387 -0
- package/README.md +208 -1
- package/SIZES.md +25 -0
- package/api-extractor.arrays.json +15 -0
- package/api-extractor.context.json +1 -0
- package/api-extractor.declarative.json +15 -0
- package/api-extractor.di.json +1 -0
- package/api-extractor.hydration.json +15 -0
- package/api-extractor.styles.json +15 -0
- package/dist/arrays/arrays.api.json +2621 -0
- package/dist/declarative/declarative.api.json +7844 -0
- package/dist/di/di.api.json +1 -1
- 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/signal.d.ts +6 -6
- package/dist/dts/binding/two-way.d.ts +1 -0
- package/dist/dts/binding.d.ts +7 -0
- package/dist/dts/components/attributes.d.ts +2 -5
- 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 +34 -0
- package/dist/dts/components/fast-definitions.d.ts +91 -42
- package/dist/dts/components/fast-element.d.ts +5 -8
- package/dist/dts/components/hydration-tracker.d.ts +40 -0
- package/dist/dts/components/hydration.d.ts +18 -53
- package/dist/dts/components/schema.d.ts +205 -0
- package/dist/dts/context.d.ts +6 -6
- 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 +5 -0
- package/dist/dts/declarative/index.d.ts +13 -0
- package/dist/dts/declarative/interfaces.d.ts +9 -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 +9 -0
- package/dist/dts/declarative/utilities.d.ts +312 -0
- package/dist/dts/di/di.d.ts +1 -1
- 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 +1 -1
- package/dist/dts/html.d.ts +5 -0
- package/dist/dts/hydration/runtime.d.ts +7 -0
- package/dist/dts/hydration/target-builder.d.ts +15 -12
- package/dist/dts/hydration.d.ts +14 -0
- package/dist/dts/index.d.ts +38 -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 +1 -49
- package/dist/dts/observable.d.ts +3 -6
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/update-queue.d.ts +1 -1
- package/dist/dts/platform.d.ts +25 -4
- 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/children.d.ts +1 -1
- package/dist/dts/templating/html-binding-directive.d.ts +4 -0
- package/dist/dts/templating/html-directive.d.ts +17 -0
- package/dist/dts/templating/hydration-view.d.ts +109 -0
- package/dist/dts/templating/ref.d.ts +1 -1
- package/dist/dts/templating/render.d.ts +1 -1
- package/dist/dts/templating/repeat.d.ts +2 -2
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +17 -9
- package/dist/dts/templating/view.d.ts +25 -102
- package/dist/dts/templating/when.d.ts +1 -1
- package/dist/dts/templating.d.ts +10 -0
- package/dist/dts/testing/exports.d.ts +2 -2
- package/dist/dts/updates.d.ts +1 -0
- package/dist/dts/volatile.d.ts +2 -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 +2 -1
- package/dist/esm/binding.js +4 -0
- package/dist/esm/components/attributes.js +8 -5
- package/dist/esm/components/definition-schema-transforms.js +23 -0
- package/dist/esm/components/element-controller.js +200 -269
- package/dist/esm/components/element-hydration.js +1 -1
- package/dist/esm/components/enable-hydration.js +100 -0
- package/dist/esm/components/fast-definitions.js +211 -49
- package/dist/esm/components/fast-element.js +18 -27
- package/dist/esm/components/hydration-tracker.js +93 -0
- package/dist/esm/components/hydration.js +62 -144
- 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 +26 -26
- package/dist/esm/declarative/attribute-map.js +121 -0
- package/dist/esm/declarative/debug.js +5 -0
- package/dist/esm/declarative/index.js +3 -0
- package/dist/esm/declarative/interfaces.js +10 -0
- package/dist/esm/declarative/observer-map-utilities.js +562 -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 +170 -0
- package/dist/esm/declarative/template-parser.js +306 -0
- package/dist/esm/declarative/template.js +142 -0
- package/dist/esm/declarative/utilities.js +834 -0
- package/dist/esm/di/di.js +6 -8
- 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 +2 -2
- package/dist/esm/dom.js +1 -1
- package/dist/esm/html.js +2 -0
- package/dist/esm/hydration/runtime.js +33 -0
- package/dist/esm/hydration/target-builder.js +97 -90
- package/dist/esm/hydration.js +4 -0
- package/dist/esm/index.debug.js +2 -1
- package/dist/esm/index.js +34 -29
- package/dist/esm/index.rollup.debug.js +3 -2
- package/dist/esm/index.rollup.js +1 -1
- package/dist/esm/interfaces.js +1 -45
- package/dist/esm/observable.js +1 -4
- package/dist/esm/observation/arrays.js +1 -1
- 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/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 +10 -8
- package/dist/esm/templating/hydration-view.js +235 -0
- package/dist/esm/templating/render.js +1 -1
- package/dist/esm/templating/repeat.js +36 -34
- package/dist/esm/templating/template.js +7 -7
- package/dist/esm/templating/view.js +24 -233
- package/dist/esm/templating.js +7 -0
- package/dist/esm/testing/exports.js +2 -2
- package/dist/esm/updates.js +1 -0
- package/dist/esm/volatile.js +1 -0
- package/dist/fast-element.api.json +9016 -6995
- package/dist/fast-element.d.ts +3557 -796
- package/dist/fast-element.debug.js +5088 -4437
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +5369 -4649
- package/dist/fast-element.min.js +2 -2
- package/dist/fast-element.untrimmed.d.ts +863 -475
- package/dist/hydration/hydration.api.json +5237 -0
- package/dist/styles/styles.api.json +2672 -0
- package/docs/api-report.api.md +343 -166
- package/docs/arrays/api-report.api.md +114 -0
- package/docs/declarative/api-report.api.md +397 -0
- package/docs/hydration/api-report.api.md +285 -0
- package/docs/styles/api-report.api.md +135 -0
- package/package.json +149 -41
- package/playwright.declarative.config.ts +26 -0
- package/playwright.declarative.webui.config.ts +20 -0
- package/scripts/declarative/build-fixtures-with-webui.js +135 -0
- package/scripts/declarative/build-fixtures.js +49 -0
- package/scripts/declarative/build-fixtures.utilities.js +101 -0
- package/scripts/measure-sizes.js +219 -0
- package/scripts/run-api-extractor.js +39 -20
- package/test/declarative/fixtures/README.md +72 -0
- package/test/declarative/fixtures/WRITING_FIXTURES.md +330 -0
- package/test/declarative/fixtures/bindings/README.md +12 -0
- package/test/declarative/fixtures/bindings/attribute/entry.html +13 -0
- package/test/declarative/fixtures/bindings/attribute/fast-build.config.json +6 -0
- package/test/declarative/fixtures/bindings/attribute/index.html +25 -0
- package/test/declarative/fixtures/bindings/attribute/main.ts +41 -0
- package/test/declarative/fixtures/bindings/attribute/state.json +8 -0
- package/test/declarative/fixtures/bindings/attribute/templates.html +11 -0
- package/test/declarative/fixtures/bindings/content/entry.html +12 -0
- package/test/declarative/fixtures/bindings/content/fast-build.config.json +6 -0
- package/test/declarative/fixtures/bindings/content/index.html +19 -0
- package/test/declarative/fixtures/bindings/content/main.ts +27 -0
- package/test/declarative/fixtures/bindings/content/state.json +4 -0
- package/test/declarative/fixtures/bindings/content/templates.html +6 -0
- package/test/declarative/fixtures/bindings/dot-syntax/entry.html +11 -0
- package/test/declarative/fixtures/bindings/dot-syntax/fast-build.config.json +6 -0
- package/test/declarative/fixtures/bindings/dot-syntax/index.html +47 -0
- package/test/declarative/fixtures/bindings/dot-syntax/main.ts +59 -0
- package/test/declarative/fixtures/bindings/dot-syntax/state.json +16 -0
- package/test/declarative/fixtures/bindings/dot-syntax/templates.html +17 -0
- package/test/declarative/fixtures/bindings/event/entry.html +11 -0
- package/test/declarative/fixtures/bindings/event/fast-build.config.json +6 -0
- package/test/declarative/fixtures/bindings/event/index.html +43 -0
- package/test/declarative/fixtures/bindings/event/main.ts +43 -0
- package/test/declarative/fixtures/bindings/event/state.json +3 -0
- package/test/declarative/fixtures/bindings/event/templates.html +18 -0
- package/test/declarative/fixtures/bindings/host/entry.html +40 -0
- package/test/declarative/fixtures/bindings/host/fast-build.config.json +6 -0
- package/test/declarative/fixtures/bindings/host/index.html +96 -0
- package/test/declarative/fixtures/bindings/host/main.ts +222 -0
- package/test/declarative/fixtures/bindings/host/state.json +9 -0
- package/test/declarative/fixtures/bindings/host/templates.html +55 -0
- package/test/declarative/fixtures/directives/README.md +12 -0
- package/test/declarative/fixtures/directives/children/entry.html +11 -0
- package/test/declarative/fixtures/directives/children/fast-build.config.json +6 -0
- package/test/declarative/fixtures/directives/children/index.html +15 -0
- package/test/declarative/fixtures/directives/children/main.ts +22 -0
- package/test/declarative/fixtures/directives/children/state.json +3 -0
- package/test/declarative/fixtures/directives/children/templates.html +3 -0
- package/test/declarative/fixtures/directives/ref/entry.html +11 -0
- package/test/declarative/fixtures/directives/ref/fast-build.config.json +6 -0
- package/test/declarative/fixtures/directives/ref/index.html +15 -0
- package/test/declarative/fixtures/directives/ref/main.ts +17 -0
- package/test/declarative/fixtures/directives/ref/state.json +1 -0
- package/test/declarative/fixtures/directives/ref/templates.html +3 -0
- package/test/declarative/fixtures/directives/repeat/entry.html +21 -0
- package/test/declarative/fixtures/directives/repeat/fast-build.config.json +6 -0
- package/test/declarative/fixtures/directives/repeat/index.html +133 -0
- package/test/declarative/fixtures/directives/repeat/main.ts +110 -0
- package/test/declarative/fixtures/directives/repeat/sprites.svg +8 -0
- package/test/declarative/fixtures/directives/repeat/state.json +10 -0
- package/test/declarative/fixtures/directives/repeat/templates.html +75 -0
- package/test/declarative/fixtures/directives/slotted/entry.html +17 -0
- package/test/declarative/fixtures/directives/slotted/fast-build.config.json +6 -0
- package/test/declarative/fixtures/directives/slotted/index.html +27 -0
- package/test/declarative/fixtures/directives/slotted/main.ts +29 -0
- package/test/declarative/fixtures/directives/slotted/state.json +1 -0
- package/test/declarative/fixtures/directives/slotted/templates.html +7 -0
- package/test/declarative/fixtures/directives/when/entry.html +51 -0
- package/test/declarative/fixtures/directives/when/fast-build.config.json +6 -0
- package/test/declarative/fixtures/directives/when/index.html +136 -0
- package/test/declarative/fixtures/directives/when/main.ts +172 -0
- package/test/declarative/fixtures/directives/when/state.json +12 -0
- package/test/declarative/fixtures/directives/when/templates.html +75 -0
- package/test/declarative/fixtures/ecosystem/README.md +11 -0
- package/test/declarative/fixtures/ecosystem/declarative-no-hydration/entry.html +12 -0
- package/test/declarative/fixtures/ecosystem/declarative-no-hydration/fast-build.config.json +6 -0
- package/test/declarative/fixtures/ecosystem/declarative-no-hydration/index.html +20 -0
- package/test/declarative/fixtures/ecosystem/declarative-no-hydration/main.ts +68 -0
- package/test/declarative/fixtures/ecosystem/declarative-no-hydration/state.json +4 -0
- package/test/declarative/fixtures/ecosystem/declarative-no-hydration/templates.html +7 -0
- package/test/declarative/fixtures/ecosystem/errors/entry.html +12 -0
- package/test/declarative/fixtures/ecosystem/errors/fast-build.config.json +6 -0
- package/test/declarative/fixtures/ecosystem/errors/index.html +20 -0
- package/test/declarative/fixtures/ecosystem/errors/main.ts +17 -0
- package/test/declarative/fixtures/ecosystem/errors/state.json +1 -0
- package/test/declarative/fixtures/ecosystem/errors/templates.html +7 -0
- package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/entry.html +17 -0
- package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/fast-build.config.json +6 -0
- package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/index.html +56 -0
- package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/main.ts +134 -0
- package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/state.json +12 -0
- package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/templates.html +34 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/entry.html +25 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/fast-build.config.json +6 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/fast-card.css +10 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/index.html +181 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/main.ts +58 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/state.json +6 -0
- package/test/declarative/fixtures/ecosystem/performance-metrics/templates.html +15 -0
- package/test/declarative/fixtures/extensions/README.md +15 -0
- package/test/declarative/fixtures/extensions/attribute-map/entry.html +14 -0
- package/test/declarative/fixtures/extensions/attribute-map/fast-build.config.json +6 -0
- package/test/declarative/fixtures/extensions/attribute-map/index.html +31 -0
- package/test/declarative/fixtures/extensions/attribute-map/main.ts +40 -0
- package/test/declarative/fixtures/extensions/attribute-map/state.json +4 -0
- package/test/declarative/fixtures/extensions/attribute-map/templates.html +14 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/entry.html +12 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/fast-build.config.json +7 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/index.html +25 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/main.ts +31 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/state.json +5 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/templates.html +11 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/entry.html +13 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/fast-build.config.json +7 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/index.html +23 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/main.ts +37 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/state.json +1 -0
- package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/templates.html +9 -0
- package/test/declarative/fixtures/extensions/observer-map/entry.html +15 -0
- package/test/declarative/fixtures/extensions/observer-map/fast-build.config.json +6 -0
- package/test/declarative/fixtures/extensions/observer-map/index.html +442 -0
- package/test/declarative/fixtures/extensions/observer-map/main.ts +482 -0
- package/test/declarative/fixtures/extensions/observer-map/state.json +158 -0
- package/test/declarative/fixtures/extensions/observer-map/templates.html +172 -0
- package/test/declarative/fixtures/extensions/observer-map-config-object/entry.html +16 -0
- package/test/declarative/fixtures/extensions/observer-map-config-object/fast-build.config.json +6 -0
- package/test/declarative/fixtures/extensions/observer-map-config-object/index.html +27 -0
- package/test/declarative/fixtures/extensions/observer-map-config-object/main.ts +53 -0
- package/test/declarative/fixtures/extensions/observer-map-config-object/state.json +9 -0
- package/test/declarative/fixtures/extensions/observer-map-config-object/templates.html +12 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/README.md +98 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/entry.html +156 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/fast-build.config.json +6 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/index.html +376 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/main.ts +366 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/state.json +69 -0
- package/test/declarative/fixtures/extensions/observer-map-deep-merge/templates.html +91 -0
- package/test/declarative/fixtures/extensions/observer-map-properties/entry.html +14 -0
- package/test/declarative/fixtures/extensions/observer-map-properties/fast-build.config.json +6 -0
- package/test/declarative/fixtures/extensions/observer-map-properties/index.html +110 -0
- package/test/declarative/fixtures/extensions/observer-map-properties/main.ts +175 -0
- package/test/declarative/fixtures/extensions/observer-map-properties/state.json +29 -0
- package/test/declarative/fixtures/extensions/observer-map-properties/templates.html +55 -0
- package/test/declarative/fixtures/scenarios/README.md +7 -0
- package/test/declarative/fixtures/scenarios/nested-elements/entry.html +16 -0
- package/test/declarative/fixtures/scenarios/nested-elements/fast-build.config.json +6 -0
- package/test/declarative/fixtures/scenarios/nested-elements/index.html +126 -0
- package/test/declarative/fixtures/scenarios/nested-elements/main.ts +214 -0
- package/test/declarative/fixtures/scenarios/nested-elements/state.json +10 -0
- package/test/declarative/fixtures/scenarios/nested-elements/templates.html +54 -0
- package/test/declarative/index.html +12 -0
- package/test/declarative/vite.config.ts +55 -0
- package/test/declarative-main.ts +6 -0
- package/test/extension-subpaths-main.ts +9 -0
- package/test/main.ts +38 -33
- package/test/pure-declarative-main.ts +1 -0
- package/dist/dts/components/install-hydration.d.ts +0 -1
- package/dist/dts/pending-task.d.ts +0 -32
- package/dist/dts/polyfills.d.ts +0 -0
- 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
|
@@ -3,13 +3,7 @@ import { PropertyChangeNotifier } from "../observation/notifier.js";
|
|
|
3
3
|
import { ExecutionContext, Observable, SourceLifetime, } from "../observation/observable.js";
|
|
4
4
|
import { FAST, makeSerializationNoop } from "../platform.js";
|
|
5
5
|
import { ElementStyles } from "../styles/element-styles.js";
|
|
6
|
-
import {
|
|
7
|
-
import { FASTElementDefinition, TemplateOptions, } from "./fast-definitions.js";
|
|
8
|
-
import { deferHydrationAttribute, HydrationMarkup, isHydratable } from "./hydration.js";
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use the export from ./hydration.js instead.
|
|
11
|
-
*/
|
|
12
|
-
export { deferHydrationAttribute } from "./hydration.js";
|
|
6
|
+
import { FASTElementDefinition, getLateAttributeLookup, } from "./fast-definitions.js";
|
|
13
7
|
const defaultEventOptions = {
|
|
14
8
|
bubbles: true,
|
|
15
9
|
composed: true,
|
|
@@ -17,6 +11,7 @@ const defaultEventOptions = {
|
|
|
17
11
|
};
|
|
18
12
|
const isConnectedPropertyName = "isConnected";
|
|
19
13
|
const shadowRoots = new WeakMap();
|
|
14
|
+
const lateAttributeObserver = Symbol("fast-late-attribute-observer");
|
|
20
15
|
function getShadowRoot(element) {
|
|
21
16
|
var _a, _b;
|
|
22
17
|
return (_b = (_a = element.shadowRoot) !== null && _a !== void 0 ? _a : shadowRoots.get(element)) !== null && _b !== void 0 ? _b : null;
|
|
@@ -41,7 +36,7 @@ export var Stages;
|
|
|
41
36
|
* Controls the lifecycle and rendering of a `FASTElement`.
|
|
42
37
|
* @public
|
|
43
38
|
*/
|
|
44
|
-
export class ElementController
|
|
39
|
+
export class ElementController {
|
|
45
40
|
/**
|
|
46
41
|
* Indicates whether or not the custom element has been
|
|
47
42
|
* connected to the document.
|
|
@@ -87,7 +82,8 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
87
82
|
}
|
|
88
83
|
else if (definition.template) {
|
|
89
84
|
// 3. Default to the static definition.
|
|
90
|
-
this._template =
|
|
85
|
+
this._template =
|
|
86
|
+
(_a = definition.template) !== null && _a !== void 0 ? _a : null;
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
return this._template;
|
|
@@ -163,7 +159,6 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
163
159
|
* @internal
|
|
164
160
|
*/
|
|
165
161
|
constructor(element, definition) {
|
|
166
|
-
super(element);
|
|
167
162
|
/**
|
|
168
163
|
* A map of observable properties that were set on the element before upgrade.
|
|
169
164
|
*/
|
|
@@ -176,6 +171,22 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
176
171
|
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
177
172
|
*/
|
|
178
173
|
this.hasExistingShadowRoot = false;
|
|
174
|
+
/**
|
|
175
|
+
* Resolves `true` when the element had an existing shadow root
|
|
176
|
+
* (from SSR or declarative shadow DOM) at connect time, `false`
|
|
177
|
+
* otherwise.
|
|
178
|
+
*/
|
|
179
|
+
this.isPrerendered = new Promise(resolve => {
|
|
180
|
+
this._resolvePrerendered = resolve;
|
|
181
|
+
});
|
|
182
|
+
/**
|
|
183
|
+
* Resolves `true` after prerendered content has been successfully
|
|
184
|
+
* hydrated, or `false` when the component is client-side rendered
|
|
185
|
+
* or hydration is not enabled.
|
|
186
|
+
*/
|
|
187
|
+
this.isHydrated = new Promise(resolve => {
|
|
188
|
+
this._resolveHydrated = resolve;
|
|
189
|
+
});
|
|
179
190
|
/**
|
|
180
191
|
* The template used to render the component.
|
|
181
192
|
*/
|
|
@@ -219,14 +230,12 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
219
230
|
* If `null` then the element is managing its own rendering.
|
|
220
231
|
*/
|
|
221
232
|
this.view = null;
|
|
233
|
+
this._notifier = new PropertyChangeNotifier(element);
|
|
222
234
|
this.source = element;
|
|
223
235
|
this.definition = definition;
|
|
224
236
|
this.shadowOptions = definition.shadowOptions;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// shadow the getter/setter that is required to make the observable operate.
|
|
228
|
-
// Later, in the connect callback, we'll re-apply the values.
|
|
229
|
-
const accessors = Observable.getAccessors(element);
|
|
237
|
+
const prototype = Reflect.getPrototypeOf(element);
|
|
238
|
+
const accessors = prototype === null ? [] : Observable.getAccessors(prototype);
|
|
230
239
|
if (accessors.length > 0) {
|
|
231
240
|
const boundObservables = (this.boundObservables = Object.create(null));
|
|
232
241
|
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
@@ -237,7 +246,42 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
237
246
|
boundObservables[propertyName] = value;
|
|
238
247
|
}
|
|
239
248
|
}
|
|
249
|
+
if (Object.keys(boundObservables).length === 0) {
|
|
250
|
+
this.boundObservables = null;
|
|
251
|
+
}
|
|
240
252
|
}
|
|
253
|
+
// Capture any observable values that were set after construction but before
|
|
254
|
+
// the first connect (for example, late-defined declarative accessors).
|
|
255
|
+
this.captureBoundObservables();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The subject that subscribers will receive notifications for.
|
|
259
|
+
*/
|
|
260
|
+
get subject() {
|
|
261
|
+
return this._notifier.subject;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Notifies all subscribers of a property change.
|
|
265
|
+
* @param args - The property name that changed.
|
|
266
|
+
*/
|
|
267
|
+
notify(args) {
|
|
268
|
+
this._notifier.notify(args);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Subscribes to notification of changes in the element's state.
|
|
272
|
+
* @param subscriber - The object that is subscribing for change notification.
|
|
273
|
+
* @param propertyToWatch - The name of the property to watch for changes.
|
|
274
|
+
*/
|
|
275
|
+
subscribe(subscriber, propertyToWatch) {
|
|
276
|
+
this._notifier.subscribe(subscriber, propertyToWatch);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Unsubscribes from notification of changes in the element's state.
|
|
280
|
+
* @param subscriber - The object that is unsubscribing from change notification.
|
|
281
|
+
* @param propertyToUnwatch - The name of the property to unsubscribe from.
|
|
282
|
+
*/
|
|
283
|
+
unsubscribe(subscriber, propertyToUnwatch) {
|
|
284
|
+
this._notifier.unsubscribe(subscriber, propertyToUnwatch);
|
|
241
285
|
}
|
|
242
286
|
/**
|
|
243
287
|
* Registers an unbind handler with the controller.
|
|
@@ -308,13 +352,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
308
352
|
target.append(styles);
|
|
309
353
|
}
|
|
310
354
|
else if (!styles.isAttachedTo(source)) {
|
|
311
|
-
const sourceBehaviors = styles.behaviors;
|
|
312
355
|
styles.addStylesTo(source);
|
|
313
|
-
if (sourceBehaviors !== null) {
|
|
314
|
-
for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
|
|
315
|
-
this.addBehavior(sourceBehaviors[i]);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
356
|
}
|
|
319
357
|
}
|
|
320
358
|
/**
|
|
@@ -332,13 +370,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
332
370
|
target.removeChild(styles);
|
|
333
371
|
}
|
|
334
372
|
else if (styles.isAttachedTo(source)) {
|
|
335
|
-
const sourceBehaviors = styles.behaviors;
|
|
336
373
|
styles.removeStylesFrom(source);
|
|
337
|
-
if (sourceBehaviors !== null) {
|
|
338
|
-
for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
|
|
339
|
-
this.removeBehavior(sourceBehaviors[i]);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
374
|
}
|
|
343
375
|
}
|
|
344
376
|
/**
|
|
@@ -349,6 +381,9 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
349
381
|
return;
|
|
350
382
|
}
|
|
351
383
|
this.stage = Stages.connecting;
|
|
384
|
+
this.captureBoundObservables();
|
|
385
|
+
this.syncLateAttributes();
|
|
386
|
+
this.observeLateAttributes();
|
|
352
387
|
this.bindObservables();
|
|
353
388
|
this.connectBehaviors();
|
|
354
389
|
if (this.needsInitialization) {
|
|
@@ -377,6 +412,95 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
377
412
|
this.boundObservables = null;
|
|
378
413
|
}
|
|
379
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Captures own-properties that shadow observable accessors on the prototype so
|
|
417
|
+
* they can be rebound through the accessor before rendering.
|
|
418
|
+
*/
|
|
419
|
+
captureBoundObservables() {
|
|
420
|
+
const element = this.source;
|
|
421
|
+
const propertyNames = Object.getOwnPropertyNames(element);
|
|
422
|
+
const hasPrototypeAccessor = (propertyName) => {
|
|
423
|
+
let currentTarget = Reflect.getPrototypeOf(element);
|
|
424
|
+
while (currentTarget !== null) {
|
|
425
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(currentTarget, propertyName);
|
|
426
|
+
if ((descriptor === null || descriptor === void 0 ? void 0 : descriptor.get) || (descriptor === null || descriptor === void 0 ? void 0 : descriptor.set)) {
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
currentTarget = Reflect.getPrototypeOf(currentTarget);
|
|
430
|
+
}
|
|
431
|
+
return false;
|
|
432
|
+
};
|
|
433
|
+
let boundObservables = this.boundObservables;
|
|
434
|
+
for (let i = 0, ii = propertyNames.length; i < ii; ++i) {
|
|
435
|
+
const ownPropertyName = propertyNames[i];
|
|
436
|
+
const propertyName = (ownPropertyName[0] === "_" ? ownPropertyName.slice(1) : ownPropertyName);
|
|
437
|
+
if (!hasPrototypeAccessor(propertyName)) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
const value = element[propertyName];
|
|
441
|
+
const isBackingField = ownPropertyName !== propertyName;
|
|
442
|
+
const isRebindableObject = value !== null &&
|
|
443
|
+
typeof value === "object" &&
|
|
444
|
+
!(value === null || value === void 0 ? void 0 : value.$isProxy) &&
|
|
445
|
+
!(Array.isArray(value) && (value === null || value === void 0 ? void 0 : value.$fastController));
|
|
446
|
+
if (value === void 0) {
|
|
447
|
+
if (!isBackingField) {
|
|
448
|
+
delete element[ownPropertyName];
|
|
449
|
+
}
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
if (isBackingField && !isRebindableObject) {
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
delete element[ownPropertyName];
|
|
456
|
+
(boundObservables !== null && boundObservables !== void 0 ? boundObservables : (boundObservables = this.boundObservables = Object.create(null)))[propertyName] = value;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Synchronizes late-defined attribute-map attributes from the live DOM to the
|
|
461
|
+
* associated property values before the initial render occurs.
|
|
462
|
+
*/
|
|
463
|
+
syncLateAttributes() {
|
|
464
|
+
const lateAttributes = getLateAttributeLookup(this.definition);
|
|
465
|
+
if (lateAttributes === null) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
for (const attributeName of Object.keys(lateAttributes)) {
|
|
469
|
+
if (!this.source.hasAttribute(attributeName)) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
this.onAttributeChangedCallback(attributeName, null, this.source.getAttribute(attributeName));
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Observes late-defined attribute-map attributes that the platform does not
|
|
477
|
+
* surface through attributeChangedCallback because they were added after
|
|
478
|
+
* customElements.define() completed.
|
|
479
|
+
*/
|
|
480
|
+
observeLateAttributes() {
|
|
481
|
+
if (getLateAttributeLookup(this.definition) === null) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const element = this.source;
|
|
485
|
+
if (element[lateAttributeObserver] !== void 0) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
element[lateAttributeObserver] = new MutationObserver(records => {
|
|
489
|
+
const controller = element.$fastController;
|
|
490
|
+
const lateAttributes = getLateAttributeLookup(controller.definition);
|
|
491
|
+
if (lateAttributes === null) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
for (let i = 0, ii = records.length; i < ii; ++i) {
|
|
495
|
+
const attributeName = records[i].attributeName;
|
|
496
|
+
if (attributeName === null || lateAttributes[attributeName] === void 0) {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
controller.onAttributeChangedCallback(attributeName, null, element.getAttribute(attributeName));
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
element[lateAttributeObserver].observe(element, { attributes: true });
|
|
503
|
+
}
|
|
380
504
|
/**
|
|
381
505
|
* Connects any existing behaviors on the associated element.
|
|
382
506
|
*/
|
|
@@ -457,30 +581,51 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
457
581
|
*/
|
|
458
582
|
renderTemplate(template) {
|
|
459
583
|
var _a;
|
|
460
|
-
// When getting the host to render to, we start by looking
|
|
461
|
-
// up the shadow root. If there isn't one, then that means
|
|
462
|
-
// we're doing a Light DOM render to the element's direct children.
|
|
463
584
|
const element = this.source;
|
|
464
585
|
const host = (_a = getShadowRoot(element)) !== null && _a !== void 0 ? _a : element;
|
|
465
586
|
if (this.view !== null) {
|
|
466
|
-
// If there's already a view, we need to unbind and remove through dispose.
|
|
467
587
|
this.view.dispose();
|
|
468
588
|
this.view = null;
|
|
469
589
|
}
|
|
470
590
|
else if (!this.needsInitialization || this.hasExistingShadowRoot) {
|
|
471
|
-
this.hasExistingShadowRoot
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
591
|
+
if (!this.hasExistingShadowRoot || !this.needsInitialization) {
|
|
592
|
+
for (let child = host.firstChild; child !== null; child = host.firstChild) {
|
|
593
|
+
host.removeChild(child);
|
|
594
|
+
}
|
|
475
595
|
}
|
|
476
596
|
}
|
|
477
597
|
if (template) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
598
|
+
const hasPrerenderedContent = this.hasExistingShadowRoot && this.needsInitialization;
|
|
599
|
+
let didHydrate = false;
|
|
600
|
+
if (hasPrerenderedContent && ElementController.hydrationHook) {
|
|
601
|
+
didHydrate = ElementController.hydrationHook(this, template, element, host);
|
|
602
|
+
}
|
|
603
|
+
if (!didHydrate) {
|
|
604
|
+
this.renderClientSide(template, element, host);
|
|
605
|
+
}
|
|
606
|
+
this._resolvePrerendered(hasPrerenderedContent);
|
|
607
|
+
this._resolveHydrated(didHydrate);
|
|
608
|
+
}
|
|
609
|
+
else if (this.needsInitialization) {
|
|
610
|
+
this._resolvePrerendered(false);
|
|
611
|
+
this._resolveHydrated(false);
|
|
482
612
|
}
|
|
483
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Standard client-side render: clears any stale content, clones the
|
|
616
|
+
* compiled fragment, binds, and appends to the host.
|
|
617
|
+
*/
|
|
618
|
+
renderClientSide(template, element, host) {
|
|
619
|
+
if (this.hasExistingShadowRoot) {
|
|
620
|
+
for (let child = host.firstChild; child !== null; child = host.firstChild) {
|
|
621
|
+
host.removeChild(child);
|
|
622
|
+
}
|
|
623
|
+
this.hasExistingShadowRoot = false;
|
|
624
|
+
}
|
|
625
|
+
this.view = template.render(element, host, element);
|
|
626
|
+
this.view.sourceLifetime =
|
|
627
|
+
SourceLifetime.coupled;
|
|
628
|
+
}
|
|
484
629
|
/**
|
|
485
630
|
* Locates or creates a controller for the specified element.
|
|
486
631
|
* @param element - The element to return the controller for.
|
|
@@ -521,7 +666,22 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
521
666
|
static setStrategy(strategy) {
|
|
522
667
|
elementControllerStrategy = strategy;
|
|
523
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* Installs the hydration hook. Called by enableHydration().
|
|
671
|
+
* @internal
|
|
672
|
+
*/
|
|
673
|
+
static installHydrationHook(hook) {
|
|
674
|
+
ElementController.hydrationHook = hook;
|
|
675
|
+
}
|
|
524
676
|
}
|
|
677
|
+
// --- Static hydration hook ---
|
|
678
|
+
/**
|
|
679
|
+
* A hook that, when set, handles prerendered content hydration.
|
|
680
|
+
* Called by renderTemplate when an existing shadow root is detected.
|
|
681
|
+
* Returns true if hydration was performed, false to fall back to client-side.
|
|
682
|
+
* @internal
|
|
683
|
+
*/
|
|
684
|
+
ElementController.hydrationHook = null;
|
|
525
685
|
makeSerializationNoop(ElementController);
|
|
526
686
|
// Set default strategy for ElementController
|
|
527
687
|
ElementController.setStrategy(ElementController);
|
|
@@ -633,7 +793,7 @@ if (ElementStyles.supportsAdoptedStyleSheets) {
|
|
|
633
793
|
}
|
|
634
794
|
};
|
|
635
795
|
}
|
|
636
|
-
catch (
|
|
796
|
+
catch (_e) {
|
|
637
797
|
// Do nothing if an error is thrown, the default
|
|
638
798
|
// case handles FrozenArray.
|
|
639
799
|
}
|
|
@@ -642,232 +802,3 @@ if (ElementStyles.supportsAdoptedStyleSheets) {
|
|
|
642
802
|
else {
|
|
643
803
|
ElementStyles.setDefaultStrategy(StyleElementStrategy);
|
|
644
804
|
}
|
|
645
|
-
/**
|
|
646
|
-
* The attribute used to indicate that an element needs hydration.
|
|
647
|
-
* @public
|
|
648
|
-
*/
|
|
649
|
-
export const needsHydrationAttribute = "needs-hydration";
|
|
650
|
-
/**
|
|
651
|
-
* An ElementController capable of hydrating FAST elements from
|
|
652
|
-
* Declarative Shadow DOM.
|
|
653
|
-
*
|
|
654
|
-
* @beta
|
|
655
|
-
*/
|
|
656
|
-
export class HydratableElementController extends ElementController {
|
|
657
|
-
/**
|
|
658
|
-
* {@inheritdoc ElementController.shadowOptions}
|
|
659
|
-
*/
|
|
660
|
-
get shadowOptions() {
|
|
661
|
-
return super.shadowOptions;
|
|
662
|
-
}
|
|
663
|
-
set shadowOptions(value) {
|
|
664
|
-
super.shadowOptions = value;
|
|
665
|
-
if ((this.hasExistingShadowRoot || (value !== void 0 && !this.template)) &&
|
|
666
|
-
this.definition.templateOptions === TemplateOptions.deferAndHydrate) {
|
|
667
|
-
this.source.toggleAttribute(deferHydrationAttribute, true);
|
|
668
|
-
this.source.toggleAttribute(needsHydrationAttribute, true);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Adds the current element instance to the hydrating instances map
|
|
673
|
-
*/
|
|
674
|
-
addHydratingInstance() {
|
|
675
|
-
if (!HydratableElementController.hydratingInstances) {
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
const name = this.definition.name;
|
|
679
|
-
let instances = HydratableElementController.hydratingInstances.get(name);
|
|
680
|
-
if (!instances) {
|
|
681
|
-
instances = new Set();
|
|
682
|
-
HydratableElementController.hydratingInstances.set(name, instances);
|
|
683
|
-
}
|
|
684
|
-
instances.add(this.source);
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* Configure lifecycle callbacks for hydration events
|
|
688
|
-
*/
|
|
689
|
-
static config(callbacks) {
|
|
690
|
-
HydratableElementController.lifecycleCallbacks = callbacks;
|
|
691
|
-
return this;
|
|
692
|
-
}
|
|
693
|
-
static hydrationObserverHandler(records) {
|
|
694
|
-
for (const record of records) {
|
|
695
|
-
if (!record.target.hasAttribute(deferHydrationAttribute)) {
|
|
696
|
-
HydratableElementController.hydrationObserver.unobserve(record.target);
|
|
697
|
-
record.target.$fastController.connect();
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Checks to see if hydration is complete and if so, invokes the hydrationComplete callback.
|
|
703
|
-
* Then resets the ElementController strategy to the default so that future elements
|
|
704
|
-
* don't use the HydratableElementController.
|
|
705
|
-
*
|
|
706
|
-
* @param deadline - the idle deadline object
|
|
707
|
-
*/
|
|
708
|
-
static checkHydrationComplete(deadline) {
|
|
709
|
-
var _a, _b, _c;
|
|
710
|
-
if (deadline.didTimeout) {
|
|
711
|
-
HydratableElementController.idleCallbackId = requestIdleCallback(HydratableElementController.checkHydrationComplete, { timeout: 50 });
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
// If there are no more hydrating instances, invoke the hydrationComplete callback
|
|
715
|
-
if (((_a = HydratableElementController.hydratingInstances) === null || _a === void 0 ? void 0 : _a.size) === 0) {
|
|
716
|
-
try {
|
|
717
|
-
(_c = (_b = HydratableElementController.lifecycleCallbacks).hydrationComplete) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
718
|
-
}
|
|
719
|
-
catch (_d) {
|
|
720
|
-
// A lifecycle callback must never prevent post-hydration cleanup.
|
|
721
|
-
}
|
|
722
|
-
// Reset to the default strategy after hydration is complete
|
|
723
|
-
ElementController.setStrategy(ElementController);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* Runs connected lifecycle behavior on the associated element.
|
|
728
|
-
*/
|
|
729
|
-
connect() {
|
|
730
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
731
|
-
// Initialize needsHydration on first connect
|
|
732
|
-
this.needsHydration =
|
|
733
|
-
(_a = this.needsHydration) !== null && _a !== void 0 ? _a : this.source.hasAttribute(needsHydrationAttribute);
|
|
734
|
-
if (this.needsHydration) {
|
|
735
|
-
this.addHydratingInstance();
|
|
736
|
-
}
|
|
737
|
-
// If the `defer-hydration` attribute exists on the source,
|
|
738
|
-
// wait for it to be removed before continuing connection behavior.
|
|
739
|
-
if (this.source.hasAttribute(deferHydrationAttribute)) {
|
|
740
|
-
this.addHydratingInstance();
|
|
741
|
-
HydratableElementController.hydrationObserver.observe(this.source, {
|
|
742
|
-
attributeFilter: [deferHydrationAttribute],
|
|
743
|
-
});
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
// If the controller does not need to be hydrated, defer connection behavior
|
|
747
|
-
// to the base-class. This case handles element re-connection and initial connection
|
|
748
|
-
// of elements that did not get declarative shadow-dom emitted, as well as if an extending
|
|
749
|
-
// class
|
|
750
|
-
if (!this.needsHydration) {
|
|
751
|
-
super.connect();
|
|
752
|
-
this.removeHydratingInstance();
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
if (this.stage !== Stages.disconnected) {
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
if (!HydratableElementController.hydrationStarted) {
|
|
759
|
-
HydratableElementController.hydrationStarted = true;
|
|
760
|
-
try {
|
|
761
|
-
(_c = (_b = HydratableElementController.lifecycleCallbacks).hydrationStarted) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
762
|
-
}
|
|
763
|
-
catch (_h) {
|
|
764
|
-
// A lifecycle callback must never prevent hydration.
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
try {
|
|
768
|
-
(_e = (_d = HydratableElementController.lifecycleCallbacks).elementWillHydrate) === null || _e === void 0 ? void 0 : _e.call(_d, this.source);
|
|
769
|
-
}
|
|
770
|
-
catch (_j) {
|
|
771
|
-
// A lifecycle callback must never prevent hydration.
|
|
772
|
-
}
|
|
773
|
-
this.stage = Stages.connecting;
|
|
774
|
-
this.bindObservables();
|
|
775
|
-
this.connectBehaviors();
|
|
776
|
-
if (this.template) {
|
|
777
|
-
if (isHydratable(this.template)) {
|
|
778
|
-
const element = this.source;
|
|
779
|
-
const host = (_f = getShadowRoot(element)) !== null && _f !== void 0 ? _f : element;
|
|
780
|
-
let firstChild = host.firstChild;
|
|
781
|
-
let lastChild = host.lastChild;
|
|
782
|
-
if (element.shadowRoot === null) {
|
|
783
|
-
// handle element boundary markers when shadowRoot is not present
|
|
784
|
-
if (HydrationMarkup.isElementBoundaryStartMarker(firstChild)) {
|
|
785
|
-
firstChild.data = "";
|
|
786
|
-
firstChild = firstChild.nextSibling;
|
|
787
|
-
}
|
|
788
|
-
if (HydrationMarkup.isElementBoundaryEndMarker(lastChild)) {
|
|
789
|
-
lastChild.data = "";
|
|
790
|
-
lastChild = lastChild.previousSibling;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
this.view = this.template.hydrate(firstChild, lastChild, element);
|
|
794
|
-
(_g = this.view) === null || _g === void 0 ? void 0 : _g.bind(this.source);
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
this.renderTemplate(this.template);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
this.addStyles(this.mainStyles);
|
|
801
|
-
this.stage = Stages.connected;
|
|
802
|
-
this.source.removeAttribute(needsHydrationAttribute);
|
|
803
|
-
this.needsInitialization = this.needsHydration = false;
|
|
804
|
-
this.removeHydratingInstance();
|
|
805
|
-
Observable.notify(this, isConnectedPropertyName);
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* Removes the current element instance from the hydrating instances map
|
|
809
|
-
*/
|
|
810
|
-
removeHydratingInstance() {
|
|
811
|
-
var _a, _b;
|
|
812
|
-
if (!HydratableElementController.hydratingInstances) {
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
try {
|
|
816
|
-
(_b = (_a = HydratableElementController.lifecycleCallbacks).elementDidHydrate) === null || _b === void 0 ? void 0 : _b.call(_a, this.source);
|
|
817
|
-
}
|
|
818
|
-
catch (_c) {
|
|
819
|
-
// A lifecycle callback must never prevent hydration.
|
|
820
|
-
}
|
|
821
|
-
const name = this.definition.name;
|
|
822
|
-
const instances = HydratableElementController.hydratingInstances.get(name);
|
|
823
|
-
if (instances) {
|
|
824
|
-
instances.delete(this.source);
|
|
825
|
-
if (!instances.size) {
|
|
826
|
-
HydratableElementController.hydratingInstances.delete(name);
|
|
827
|
-
}
|
|
828
|
-
if (HydratableElementController.idleCallbackId) {
|
|
829
|
-
cancelIdleCallback(HydratableElementController.idleCallbackId);
|
|
830
|
-
}
|
|
831
|
-
HydratableElementController.idleCallbackId = requestIdleCallback(HydratableElementController.checkHydrationComplete, { timeout: 50 });
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Unregisters the hydration observer when the element is disconnected.
|
|
836
|
-
*/
|
|
837
|
-
disconnect() {
|
|
838
|
-
super.disconnect();
|
|
839
|
-
HydratableElementController.hydrationObserver.unobserve(this.source);
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Sets the ElementController strategy to HydratableElementController.
|
|
843
|
-
* @remarks
|
|
844
|
-
* This method is typically called during application startup to enable
|
|
845
|
-
* hydration support for FAST elements.
|
|
846
|
-
*/
|
|
847
|
-
static install() {
|
|
848
|
-
ElementController.setStrategy(HydratableElementController);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
HydratableElementController.hydrationObserver = new UnobservableMutationObserver(HydratableElementController.hydrationObserverHandler);
|
|
852
|
-
/**
|
|
853
|
-
* Lifecycle callbacks for hydration events
|
|
854
|
-
*/
|
|
855
|
-
HydratableElementController.lifecycleCallbacks = {};
|
|
856
|
-
/**
|
|
857
|
-
* Whether the hydrationStarted callback has already been invoked.
|
|
858
|
-
*/
|
|
859
|
-
HydratableElementController.hydrationStarted = false;
|
|
860
|
-
/**
|
|
861
|
-
* An idle callback ID used to track hydration completion
|
|
862
|
-
*/
|
|
863
|
-
HydratableElementController.idleCallbackId = null;
|
|
864
|
-
/**
|
|
865
|
-
* A map of element instances by the name of the custom element they are
|
|
866
|
-
* associated with. The key is the custom element name, and the value is the
|
|
867
|
-
* instances of hydratable elements which currently need to be hydrated.
|
|
868
|
-
*
|
|
869
|
-
* When all of the instances in the set have been hydrated, the set is
|
|
870
|
-
* cleared and removed from the map. If the map is empty, the
|
|
871
|
-
* hydrationComplete callback is invoked.
|
|
872
|
-
*/
|
|
873
|
-
HydratableElementController.hydratingInstances = new Map();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ElementController } from "./element-controller.js";
|
|
2
2
|
export * from "./hydration.js";
|