@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
|
@@ -1,27 +1,26 @@
|
|
|
1
|
+
import { Message } from "../interfaces.js";
|
|
1
2
|
import { FAST } from "../platform.js";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Data-free sequential hydration markers.
|
|
5
|
+
*
|
|
6
|
+
* All markers use the `fe:` prefix to namespace them to FAST Element. The closing
|
|
7
|
+
* marker uses `/` following HTML/XML convention. Markers carry zero
|
|
8
|
+
* embedded data — the hydration walker derives factory-to-node mappings
|
|
9
|
+
* by maintaining a sequential pointer through the factories array.
|
|
5
10
|
*
|
|
6
11
|
* Content binding markers bracket text/template content:
|
|
7
|
-
* <!--
|
|
8
|
-
*
|
|
9
|
-
*
|
|
12
|
+
* <!--fe:b--> ...content... <!--fe:/b-->
|
|
13
|
+
*
|
|
14
|
+
* Repeat item markers bracket each repeated item:
|
|
15
|
+
* <!--fe:r--> ...item... <!--fe:/r-->
|
|
10
16
|
*
|
|
11
|
-
*
|
|
12
|
-
* <!-- fe
|
|
13
|
-
* <!-- fe-repeat$$end$$<itemIndex>$$fe-repeat -->
|
|
17
|
+
* Element boundary markers demarcate nested custom elements:
|
|
18
|
+
* <!--fe:e--> ...shadow content... <!--fe:/e-->
|
|
14
19
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* Attribute bindings use a single `data-fe` attribute whose value is
|
|
21
|
+
* the count of attribute binding factories targeting the element:
|
|
22
|
+
* <div data-fe="3"> (3 attribute bindings)
|
|
18
23
|
*/
|
|
19
|
-
const bindingStartMarker = /fe-b\$\$start\$\$(\d+)\$\$(.+)\$\$fe-b/;
|
|
20
|
-
const bindingEndMarker = /fe-b\$\$end\$\$(\d+)\$\$(.+)\$\$fe-b/;
|
|
21
|
-
const repeatViewStartMarker = /fe-repeat\$\$start\$\$(\d+)\$\$fe-repeat/;
|
|
22
|
-
const repeatViewEndMarker = /fe-repeat\$\$end\$\$(\d+)\$\$fe-repeat/;
|
|
23
|
-
const elementBoundaryStartMarker = /^(?:.{0,1000})fe-eb\$\$start\$\$(.+?)\$\$fe-eb/;
|
|
24
|
-
const elementBoundaryEndMarker = /fe-eb\$\$end\$\$(.{0,1000})\$\$fe-eb(?:.{0,1000})$/;
|
|
25
24
|
function isComment(node) {
|
|
26
25
|
return node && node.nodeType === Node.COMMENT_NODE;
|
|
27
26
|
}
|
|
@@ -30,151 +29,75 @@ function isComment(node) {
|
|
|
30
29
|
* @internal
|
|
31
30
|
*/
|
|
32
31
|
export const HydrationMarkup = Object.freeze({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
contentBindingStartMarker(
|
|
37
|
-
return
|
|
32
|
+
// Single attribute marker format (count only)
|
|
33
|
+
attributeMarkerName: "data-fe",
|
|
34
|
+
// Content binding markers (no arguments)
|
|
35
|
+
contentBindingStartMarker() {
|
|
36
|
+
return "fe:b";
|
|
37
|
+
},
|
|
38
|
+
contentBindingEndMarker() {
|
|
39
|
+
return "fe:/b";
|
|
40
|
+
},
|
|
41
|
+
// Repeat item markers (no arguments)
|
|
42
|
+
repeatStartMarker() {
|
|
43
|
+
return "fe:r";
|
|
38
44
|
},
|
|
39
|
-
|
|
40
|
-
return
|
|
45
|
+
repeatEndMarker() {
|
|
46
|
+
return "fe:/r";
|
|
41
47
|
},
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
// Element boundary markers (no arguments)
|
|
49
|
+
elementBoundaryStartMarker() {
|
|
50
|
+
return "fe:e";
|
|
44
51
|
},
|
|
45
|
-
|
|
46
|
-
return
|
|
52
|
+
elementBoundaryEndMarker() {
|
|
53
|
+
return "fe:/e";
|
|
47
54
|
},
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
// Detection — simple string equality
|
|
56
|
+
isContentBindingStartMarker(data) {
|
|
57
|
+
return data === "fe:b";
|
|
50
58
|
},
|
|
51
|
-
isContentBindingEndMarker(
|
|
52
|
-
return
|
|
59
|
+
isContentBindingEndMarker(data) {
|
|
60
|
+
return data === "fe:/b";
|
|
53
61
|
},
|
|
54
|
-
isRepeatViewStartMarker(
|
|
55
|
-
return
|
|
62
|
+
isRepeatViewStartMarker(data) {
|
|
63
|
+
return data === "fe:r";
|
|
56
64
|
},
|
|
57
|
-
isRepeatViewEndMarker(
|
|
58
|
-
return
|
|
65
|
+
isRepeatViewEndMarker(data) {
|
|
66
|
+
return data === "fe:/r";
|
|
59
67
|
},
|
|
60
68
|
isElementBoundaryStartMarker(node) {
|
|
61
|
-
return isComment(node) &&
|
|
69
|
+
return isComment(node) && node.data === "fe:e";
|
|
62
70
|
},
|
|
63
71
|
isElementBoundaryEndMarker(node) {
|
|
64
|
-
return isComment(node) &&
|
|
72
|
+
return isComment(node) && node.data === "fe:/e";
|
|
65
73
|
},
|
|
66
74
|
/**
|
|
67
|
-
* Returns the
|
|
68
|
-
*
|
|
75
|
+
* Returns the count of attribute bindings on the element, or null
|
|
76
|
+
* if no attribute binding marker is present.
|
|
69
77
|
*
|
|
70
|
-
*
|
|
78
|
+
* Parses the `data-fe="N"` attribute format where N is the count
|
|
79
|
+
* of attribute binding factories targeting this element.
|
|
71
80
|
*/
|
|
72
|
-
|
|
81
|
+
parseAttributeBindingCount(node) {
|
|
73
82
|
const attr = node.getAttribute(this.attributeMarkerName);
|
|
74
|
-
|
|
75
|
-
? attr
|
|
76
|
-
: attr.split(this.attributeBindingSeparator).map(i => parseInt(i));
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* Returns the indexes of the ViewBehaviorFactories affecting
|
|
80
|
-
* attributes for the element, or null if no factories were found.
|
|
81
|
-
*
|
|
82
|
-
* This method parses the enumerated format: `data-fe-b-0`, `data-fe-b-1`, `data-fe-b-2`.
|
|
83
|
-
* This is an alternative format that uses separate attributes for each binding index.
|
|
84
|
-
*/
|
|
85
|
-
parseEnumeratedAttributeBinding(node) {
|
|
86
|
-
const attrs = [];
|
|
87
|
-
const prefixLength = this.attributeMarkerName.length + 1;
|
|
88
|
-
const prefix = `${this.attributeMarkerName}-`;
|
|
89
|
-
for (const attr of node.getAttributeNames()) {
|
|
90
|
-
if (attr.startsWith(prefix)) {
|
|
91
|
-
const count = Number(attr.slice(prefixLength));
|
|
92
|
-
if (!Number.isNaN(count)) {
|
|
93
|
-
attrs.push(count);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
throw FAST.error(1601 /* invalidAttributeMarkerName */, {
|
|
97
|
-
name: attr,
|
|
98
|
-
expectedFormat: `${prefix}<number>`,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return attrs.length === 0 ? null : attrs;
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Returns the indexes of the ViewBehaviorFactories affecting
|
|
107
|
-
* attributes for the element, or null if no factories were found.
|
|
108
|
-
*
|
|
109
|
-
* This method parses the compact format: `data-fe-c-{index}-{count}`.
|
|
110
|
-
*/
|
|
111
|
-
parseCompactAttributeBinding(node) {
|
|
112
|
-
const prefix = `${this.compactAttributeMarkerName}-`;
|
|
113
|
-
const attrName = node.getAttributeNames().find(name => name.startsWith(prefix));
|
|
114
|
-
if (!attrName) {
|
|
83
|
+
if (attr === null) {
|
|
115
84
|
return null;
|
|
116
85
|
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (parts.length !== 2 ||
|
|
122
|
-
Number.isNaN(startIndex) ||
|
|
123
|
-
Number.isNaN(count) ||
|
|
124
|
-
startIndex < 0 ||
|
|
125
|
-
count < 1) {
|
|
126
|
-
throw FAST.error(1604 /* invalidCompactAttributeMarkerName */, {
|
|
127
|
-
name: attrName,
|
|
128
|
-
expectedFormat: `${this.compactAttributeMarkerName}-{index}-{count}`,
|
|
86
|
+
const trimmed = attr.trim();
|
|
87
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
88
|
+
throw FAST.error(Message.invalidHydrationAttributeMarker, {
|
|
89
|
+
value: attr,
|
|
129
90
|
});
|
|
130
91
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
92
|
+
const count = parseInt(trimmed, 10);
|
|
93
|
+
if (count < 1) {
|
|
94
|
+
throw FAST.error(Message.invalidHydrationAttributeMarker, {
|
|
95
|
+
value: attr,
|
|
96
|
+
});
|
|
134
97
|
}
|
|
135
|
-
return
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Parses the ViewBehaviorFactory index from string data. Returns
|
|
139
|
-
* the binding index or null if the index cannot be retrieved.
|
|
140
|
-
*/
|
|
141
|
-
parseContentBindingStartMarker(content) {
|
|
142
|
-
return parseIndexAndIdMarker(bindingStartMarker, content);
|
|
143
|
-
},
|
|
144
|
-
parseContentBindingEndMarker(content) {
|
|
145
|
-
return parseIndexAndIdMarker(bindingEndMarker, content);
|
|
146
|
-
},
|
|
147
|
-
/**
|
|
148
|
-
* Parses the index of a repeat directive from a content string.
|
|
149
|
-
*/
|
|
150
|
-
parseRepeatStartMarker(content) {
|
|
151
|
-
return parseIntMarker(repeatViewStartMarker, content);
|
|
152
|
-
},
|
|
153
|
-
parseRepeatEndMarker(content) {
|
|
154
|
-
return parseIntMarker(repeatViewEndMarker, content);
|
|
155
|
-
},
|
|
156
|
-
/**
|
|
157
|
-
* Parses element Id from element boundary markers
|
|
158
|
-
*/
|
|
159
|
-
parseElementBoundaryStartMarker(content) {
|
|
160
|
-
return parseStringMarker(elementBoundaryStartMarker, content.trim());
|
|
161
|
-
},
|
|
162
|
-
parseElementBoundaryEndMarker(content) {
|
|
163
|
-
return parseStringMarker(elementBoundaryEndMarker, content);
|
|
98
|
+
return count;
|
|
164
99
|
},
|
|
165
100
|
});
|
|
166
|
-
function parseIntMarker(regex, content) {
|
|
167
|
-
const match = regex.exec(content);
|
|
168
|
-
return match === null ? match : parseInt(match[1]);
|
|
169
|
-
}
|
|
170
|
-
function parseStringMarker(regex, content) {
|
|
171
|
-
const match = regex.exec(content);
|
|
172
|
-
return match === null ? match : match[1];
|
|
173
|
-
}
|
|
174
|
-
function parseIndexAndIdMarker(regex, content) {
|
|
175
|
-
const match = regex.exec(content);
|
|
176
|
-
return match === null ? match : [parseInt(match[1]), match[2]];
|
|
177
|
-
}
|
|
178
101
|
/**
|
|
179
102
|
* @internal
|
|
180
103
|
*/
|
|
@@ -183,8 +106,3 @@ export const Hydratable = Symbol.for("fe-hydration");
|
|
|
183
106
|
export function isHydratable(value) {
|
|
184
107
|
return value[Hydratable] === Hydratable;
|
|
185
108
|
}
|
|
186
|
-
/**
|
|
187
|
-
* The attribute used to defer hydration of an element.
|
|
188
|
-
* @beta
|
|
189
|
-
*/
|
|
190
|
-
export const deferHydrationAttribute = "defer-hydration";
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
// The context, in most cases the array property e.g. users
|
|
2
|
+
export const fastContextMetaData = "$fast_context";
|
|
3
|
+
// The list of contexts preceeding this context, the first of which should be the root property
|
|
4
|
+
export const fastContextsMetaData = "$fast_parent_contexts";
|
|
5
|
+
export const defsPropertyName = "$defs";
|
|
6
|
+
export const refPropertyName = "$ref";
|
|
7
|
+
/**
|
|
8
|
+
* Module-level registry that maps custom element names to their schema maps.
|
|
9
|
+
* Used for cross-element `$ref` resolution (e.g. nested element schemas).
|
|
10
|
+
* Each Schema instance registers itself here on construction.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const schemaRegistry = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* A constructed JSON schema from a template
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export class Schema {
|
|
19
|
+
constructor(name) {
|
|
20
|
+
this.customElementName = name;
|
|
21
|
+
this.schemaMap = new Map();
|
|
22
|
+
schemaRegistry.set(name, this.schemaMap);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Add a path to a schema
|
|
26
|
+
* @param config - The path registration configuration.
|
|
27
|
+
*/
|
|
28
|
+
addPath(config) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
const splitPath = this.getSplitPath(config.pathConfig.path);
|
|
31
|
+
let schema = this.schemaMap.get(config.rootPropertyName);
|
|
32
|
+
let childRef = null;
|
|
33
|
+
// Create a root level property JSON
|
|
34
|
+
if (!schema) {
|
|
35
|
+
this.addNewSchema(config.rootPropertyName);
|
|
36
|
+
schema = this.schemaMap.get(config.rootPropertyName);
|
|
37
|
+
}
|
|
38
|
+
if (config.childrenMap) {
|
|
39
|
+
childRef = this.getSchemaId(config.childrenMap.customElementName, config.childrenMap.attributeName);
|
|
40
|
+
if (splitPath.length === 1) {
|
|
41
|
+
schema.anyOf
|
|
42
|
+
? schema.anyOf.push({ [refPropertyName]: childRef })
|
|
43
|
+
: (schema.anyOf = [{ [refPropertyName]: childRef }]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
switch (config.pathConfig.type) {
|
|
47
|
+
case "default":
|
|
48
|
+
case "access": {
|
|
49
|
+
if (splitPath.length > 1) {
|
|
50
|
+
if (config.pathConfig.currentContext === null) {
|
|
51
|
+
this.addPropertiesToAnObject(schema, splitPath.slice(1), config.pathConfig.currentContext, childRef);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (!((_a = schema[defsPropertyName]) === null || _a === void 0 ? void 0 : _a[splitPath[0]])) {
|
|
55
|
+
schema[defsPropertyName] = Object.assign(Object.assign({}, schema[defsPropertyName]), { [splitPath[0]]: {} });
|
|
56
|
+
}
|
|
57
|
+
this.addPropertiesToAContext(schema[defsPropertyName][splitPath[0]], splitPath.slice(1), config.pathConfig.currentContext, childRef);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case "repeat": {
|
|
63
|
+
this.addContext(schema, splitPath[splitPath.length - 1], // example items
|
|
64
|
+
config.pathConfig.currentContext, // example item
|
|
65
|
+
config.pathConfig.parentContext);
|
|
66
|
+
if (splitPath.length > 2) {
|
|
67
|
+
let updatedSchema = schema;
|
|
68
|
+
const hasParentContext = !!config.pathConfig.parentContext;
|
|
69
|
+
if (hasParentContext) {
|
|
70
|
+
updatedSchema = this.addPropertiesToAnObject((_b = schema[defsPropertyName]) === null || _b === void 0 ? void 0 : _b[config.pathConfig.parentContext], splitPath.slice(1, -1), config.pathConfig.parentContext, childRef);
|
|
71
|
+
}
|
|
72
|
+
this.addPropertiesToAnObject(updatedSchema, hasParentContext ? splitPath.slice(2) : splitPath.slice(1), config.pathConfig.currentContext, childRef, "array");
|
|
73
|
+
}
|
|
74
|
+
else if (splitPath.length > 1) {
|
|
75
|
+
let schemaDefinition;
|
|
76
|
+
if (config.pathConfig.parentContext) {
|
|
77
|
+
schemaDefinition = (_c = schema === null || schema === void 0 ? void 0 : schema[defsPropertyName]) === null || _c === void 0 ? void 0 : _c[config.pathConfig.parentContext];
|
|
78
|
+
}
|
|
79
|
+
this.addPropertiesToAnObject(schemaDefinition !== null && schemaDefinition !== void 0 ? schemaDefinition : schema, splitPath.slice(1), config.pathConfig.currentContext, childRef, "array");
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
schema.type = "array";
|
|
83
|
+
schema[refPropertyName] = this.getDefsPath(config.pathConfig.currentContext);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets the JSON schema for a property name
|
|
91
|
+
* @param rootPropertyName - the root property the JSON schema is mapped to
|
|
92
|
+
* @returns The JSON schema for the root property
|
|
93
|
+
*/
|
|
94
|
+
getSchema(rootPropertyName) {
|
|
95
|
+
var _a;
|
|
96
|
+
return (_a = this.schemaMap.get(rootPropertyName)) !== null && _a !== void 0 ? _a : null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Gets root properties
|
|
100
|
+
* @returns IterableIterator<string>
|
|
101
|
+
*/
|
|
102
|
+
getRootProperties() {
|
|
103
|
+
return this.schemaMap.keys();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get a path split into property names
|
|
107
|
+
* @param path - The dot syntax path, e.g. `a.b.c`.
|
|
108
|
+
* @returns An array of items in the path
|
|
109
|
+
*/
|
|
110
|
+
getSplitPath(path) {
|
|
111
|
+
return path.split(".");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Gets the path to the $def
|
|
115
|
+
* @param context - The context name. For example, `item in items` creates the `item` context.
|
|
116
|
+
* @returns A string to use as a $ref
|
|
117
|
+
*/
|
|
118
|
+
getDefsPath(context) {
|
|
119
|
+
return `#/${defsPropertyName}/${context}`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get the schema $id
|
|
123
|
+
* @param customElementName - The custom element name
|
|
124
|
+
* @param propertyName - The property name
|
|
125
|
+
* @returns The ID that can be used in the JSON schema as $id
|
|
126
|
+
*/
|
|
127
|
+
getSchemaId(customElementName, propertyName) {
|
|
128
|
+
return `https://fast.design/schemas/${customElementName}/${propertyName}.json`;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Add a new JSON schema to the JSON schema map
|
|
132
|
+
* @param propertyName - The name of the property to assign this JSON schema to.
|
|
133
|
+
*/
|
|
134
|
+
addNewSchema(propertyName) {
|
|
135
|
+
this.schemaMap.set(propertyName, {
|
|
136
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
137
|
+
$id: this.getSchemaId(this.customElementName, propertyName),
|
|
138
|
+
[defsPropertyName]: {},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Add properties to a context
|
|
143
|
+
* @param schema - The schema to add the properties to.
|
|
144
|
+
* @param splitPath - The path split into property/context names.
|
|
145
|
+
* @param context - The path context.
|
|
146
|
+
*/
|
|
147
|
+
addPropertiesToAContext(schema, splitPath, context, childRef) {
|
|
148
|
+
schema.type = "object";
|
|
149
|
+
if (schema.properties && !schema.properties[splitPath[0]]) {
|
|
150
|
+
schema.properties[splitPath[0]] = {};
|
|
151
|
+
}
|
|
152
|
+
else if (!schema.properties) {
|
|
153
|
+
schema.properties = {
|
|
154
|
+
[splitPath[0]]: {},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (splitPath.length > 1) {
|
|
158
|
+
this.addPropertiesToAnObject(schema.properties[splitPath[0]], splitPath.slice(1), context, childRef);
|
|
159
|
+
}
|
|
160
|
+
else if (childRef) {
|
|
161
|
+
if (schema.properties[splitPath[0]].anyOf) {
|
|
162
|
+
schema.properties[splitPath[0]].anyOf.push({
|
|
163
|
+
[refPropertyName]: childRef,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
schema.properties[splitPath[0]].anyOf = [{ [refPropertyName]: childRef }];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Add properties to an object
|
|
173
|
+
* @param schema - The schema to add the properties to.
|
|
174
|
+
* @param splitPath - The path split into property/context names.
|
|
175
|
+
* @param context - The path context.
|
|
176
|
+
* @param type - The data type (see JSON schema for details).
|
|
177
|
+
*/
|
|
178
|
+
addPropertiesToAnObject(schema, splitPath, context, childRef, type = "object") {
|
|
179
|
+
schema.type = "object";
|
|
180
|
+
if (schema.properties && !schema.properties[splitPath[0]]) {
|
|
181
|
+
schema.properties[splitPath[0]] = {};
|
|
182
|
+
}
|
|
183
|
+
else if (!schema.properties) {
|
|
184
|
+
schema.properties = {
|
|
185
|
+
[splitPath[0]]: {},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (type === "object" && splitPath.length > 1) {
|
|
189
|
+
return this.addPropertiesToAnObject(schema.properties[splitPath[0]], splitPath.slice(1), context, childRef, type);
|
|
190
|
+
}
|
|
191
|
+
else if (type === "array") {
|
|
192
|
+
if (splitPath.length > 1) {
|
|
193
|
+
return this.addPropertiesToAnObject(schema.properties[splitPath[0]], splitPath.slice(1), context, childRef, type);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return this.addArrayToAnObject(schema.properties[splitPath[0]], context);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (schema.properties[splitPath[0]].anyOf && childRef) {
|
|
200
|
+
schema.properties[splitPath[0]].anyOf.push({ [refPropertyName]: childRef });
|
|
201
|
+
}
|
|
202
|
+
else if (childRef) {
|
|
203
|
+
schema.properties[splitPath[0]].anyOf = [{ [refPropertyName]: childRef }];
|
|
204
|
+
}
|
|
205
|
+
return schema.properties[splitPath[0]];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Add an array to an object property
|
|
209
|
+
* @param schema - The schema to add the properties to.
|
|
210
|
+
* @param context - The name of the context.
|
|
211
|
+
*/
|
|
212
|
+
addArrayToAnObject(schema, context) {
|
|
213
|
+
schema.type = "array";
|
|
214
|
+
schema.items = {
|
|
215
|
+
[refPropertyName]: this.getDefsPath(context),
|
|
216
|
+
};
|
|
217
|
+
return schema.items;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Add a context to the $defs property
|
|
221
|
+
* @param schema - The schema to use.
|
|
222
|
+
* @param propertyName - The name of the property the context belongs to.
|
|
223
|
+
* @param currentContext - The current context.
|
|
224
|
+
* @param parentContext - The parent context.
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
addContext(schema, propertyName, // e.g items
|
|
228
|
+
currentContext, // e.g. item
|
|
229
|
+
parentContext) {
|
|
230
|
+
if (schema[defsPropertyName][currentContext]) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
schema[defsPropertyName][currentContext] = {
|
|
234
|
+
[fastContextMetaData]: propertyName,
|
|
235
|
+
[fastContextsMetaData]: this.getParentContexts(schema, parentContext),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Get parent contexts
|
|
240
|
+
* @param schema - The schema to use.
|
|
241
|
+
* @param parentContext - The parent context.
|
|
242
|
+
* @param contexts - A list of parent contexts.
|
|
243
|
+
* @returns
|
|
244
|
+
*/
|
|
245
|
+
getParentContexts(schema, parentContext, contexts = []) {
|
|
246
|
+
var _a;
|
|
247
|
+
if (parentContext === null) {
|
|
248
|
+
return [null, ...contexts];
|
|
249
|
+
}
|
|
250
|
+
const parentParentContext = (_a = schema === null || schema === void 0 ? void 0 : schema[defsPropertyName]) === null || _a === void 0 ? void 0 : _a[parentContext][fastContextsMetaData];
|
|
251
|
+
return this.getParentContexts(schema, parentParentContext[parentParentContext.length - 1], [parentContext, ...contexts]);
|
|
252
|
+
}
|
|
253
|
+
}
|
package/dist/esm/context.js
CHANGED
|
@@ -112,9 +112,9 @@ export const Context = Object.freeze({
|
|
|
112
112
|
},
|
|
113
113
|
/**
|
|
114
114
|
* Enables an event target to provide a context value.
|
|
115
|
-
* @param target The target to provide the context value for.
|
|
116
|
-
* @param context The context to provide the value for.
|
|
117
|
-
* @param value The value to provide for the context.
|
|
115
|
+
* @param target - The target to provide the context value for.
|
|
116
|
+
* @param context - The context to provide the value for.
|
|
117
|
+
* @param value - The value to provide for the context.
|
|
118
118
|
*/
|
|
119
119
|
provide(target, context, value) {
|
|
120
120
|
Context.handle(target, (event) => {
|
|
@@ -146,9 +146,9 @@ export const Context = Object.freeze({
|
|
|
146
146
|
/**
|
|
147
147
|
* Defines a getter-only property on the target that will return the context
|
|
148
148
|
* value for the target.
|
|
149
|
-
* @param target The target to define the property on.
|
|
150
|
-
* @param propertyName The name of the property to define.
|
|
151
|
-
* @param context The context that will be used to retrieve the property value.
|
|
149
|
+
* @param target - The target to define the property on.
|
|
150
|
+
* @param propertyName - The name of the property to define.
|
|
151
|
+
* @param context - The context that will be used to retrieve the property value.
|
|
152
152
|
* @remarks
|
|
153
153
|
* Uses the default request strategy to locate the context and will return the
|
|
154
154
|
* initialValue if the context isn't handled.
|
package/dist/esm/css.js
ADDED
package/dist/esm/debug.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
value: Object.create(null),
|
|
4
|
-
configurable: false,
|
|
5
|
-
enumerable: false,
|
|
6
|
-
writable: false,
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
const FAST = globalThis.FAST;
|
|
10
|
-
const debugMessages = {
|
|
1
|
+
import { FAST, getDebugMessageLookup } from "./platform.js";
|
|
2
|
+
const baseDebugMessages = {
|
|
11
3
|
[1101 /* needsArrayObservation */]: "Must call ArrayObserver.enable() before observing arrays.",
|
|
12
4
|
[1201 /* onlySetDOMPolicyOnce */]: "The DOM Policy can only be set once.",
|
|
13
5
|
[1202 /* bindingInnerHTMLRequiresTrustedTypes */]: "To bind innerHTML, you must use a TrustedTypesPolicy.",
|
|
@@ -18,6 +10,7 @@ const debugMessages = {
|
|
|
18
10
|
[1207 /* onlySetTemplatePolicyOnce */]: "The DOM Policy for an HTML template can only be set once.",
|
|
19
11
|
[1208 /* cannotSetTemplatePolicyAfterCompilation */]: "The DOM Policy cannot be set after a template is compiled.",
|
|
20
12
|
[1209 /* blockedByDOMPolicy */]: "'${aspectName}' on '${tagName}' is blocked by the current DOMPolicy.",
|
|
13
|
+
[1210 /* invalidHydrationAttributeMarker */]: "Invalid data-fe attribute value '${value}'. Expected a positive integer.",
|
|
21
14
|
[1401 /* missingElementDefinition */]: "Missing FASTElement definition.",
|
|
22
15
|
[1501 /* noRegistrationForContext */]: "No registration for Context/Interface '${name}'.",
|
|
23
16
|
[1502 /* noFactoryForResolver */]: "Dependency injection resolver for '${key}' returned a null factory.",
|
|
@@ -52,19 +45,26 @@ function formatMessage(message, values) {
|
|
|
52
45
|
})
|
|
53
46
|
.join("");
|
|
54
47
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Enables human-readable FAST debug messages.
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export function enableDebug() {
|
|
53
|
+
const debugMessages = getDebugMessageLookup();
|
|
54
|
+
Object.assign(debugMessages, baseDebugMessages);
|
|
55
|
+
Object.assign(FAST, {
|
|
56
|
+
addMessages(messages) {
|
|
57
|
+
Object.assign(debugMessages, messages);
|
|
58
|
+
},
|
|
59
|
+
warn(code, values = noValues) {
|
|
60
|
+
var _a;
|
|
61
|
+
const message = (_a = debugMessages[code]) !== null && _a !== void 0 ? _a : "Unknown Warning";
|
|
62
|
+
console.warn(formatMessage(message, values));
|
|
63
|
+
},
|
|
64
|
+
error(code, values = noValues) {
|
|
65
|
+
var _a;
|
|
66
|
+
const message = (_a = debugMessages[code]) !== null && _a !== void 0 ? _a : "Unknown Error";
|
|
67
|
+
return new Error(formatMessage(message, values));
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|