base-screen 0.2.0 → 0.4.0
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/README.md +3 -12
- package/dist/_internal/contracts/document/blueprint-capabilities.d.ts +9 -1
- package/dist/_internal/contracts/document/blueprint-capabilities.js +16 -0
- package/dist/_internal/contracts/document/blueprint-graph.d.ts +68 -0
- package/dist/_internal/contracts/document/blueprint-graph.js +424 -0
- package/dist/_internal/contracts/document/blueprint-strict.d.ts +3 -1
- package/dist/_internal/contracts/document/blueprint-strict.js +77 -91
- package/dist/_internal/contracts/document/component-states.d.ts +54 -0
- package/dist/_internal/contracts/document/component-states.js +171 -0
- package/dist/_internal/contracts/document/json-schema.js +49 -17
- package/dist/_internal/contracts/document/limits.d.ts +40 -8
- package/dist/_internal/contracts/document/limits.js +40 -8
- package/dist/_internal/contracts/document/parse-parts.d.ts +12 -0
- package/dist/_internal/contracts/document/parse-parts.js +56 -0
- package/dist/_internal/contracts/document/parse.js +1 -1
- package/dist/_internal/contracts/document/references.js +108 -41
- package/dist/_internal/contracts/document/schema.d.ts +532 -186
- package/dist/_internal/contracts/document/schema.js +235 -96
- package/dist/_internal/contracts/document/sub-canvas.d.ts +27 -0
- package/dist/_internal/contracts/document/sub-canvas.js +38 -0
- package/dist/_internal/contracts/document/theme.d.ts +22 -0
- package/dist/_internal/contracts/document/theme.js +65 -0
- package/dist/_internal/contracts/document/validate-blueprint.d.ts +7 -0
- package/dist/_internal/contracts/document/validate-blueprint.js +223 -25
- package/dist/_internal/contracts/document/validate-component.d.ts +2 -0
- package/dist/_internal/contracts/document/validate-component.js +111 -54
- package/dist/_internal/contracts/document/validate-data-source.js +84 -9
- package/dist/_internal/contracts/document/validate-sub-canvas.d.ts +9 -0
- package/dist/_internal/contracts/document/validate-sub-canvas.js +92 -0
- package/dist/_internal/contracts/document/validate-theme.d.ts +4 -0
- package/dist/_internal/contracts/document/validate-theme.js +20 -0
- package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
- package/dist/_internal/contracts/document/validate.js +19 -2
- package/dist/_internal/contracts/index.d.ts +11 -4
- package/dist/_internal/contracts/index.js +8 -2
- package/dist/_internal/contracts/migration/blueprint-graph-migration.d.ts +21 -0
- package/dist/_internal/contracts/migration/blueprint-graph-migration.js +328 -0
- package/dist/_internal/contracts/migration/migrate-document.d.ts +2 -1
- package/dist/_internal/contracts/migration/migrate-document.js +11 -3
- package/dist/_internal/contracts/push/delivery.d.ts +16 -0
- package/dist/_internal/contracts/push/delivery.js +70 -0
- package/dist/_internal/contracts/push/level-scale.d.ts +7 -0
- package/dist/_internal/contracts/push/level-scale.js +91 -0
- package/dist/_internal/contracts/screen-document.schema.json +1071 -386
- package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
- package/dist/_internal/contracts/types/document.d.ts +280 -77
- package/dist/_internal/contracts/types/execution.d.ts +12 -2
- package/dist/_internal/contracts/types/execution.js +0 -5
- package/dist/_internal/contracts/types/host.d.ts +35 -1
- package/dist/_internal/contracts/types/host.js +7 -1
- package/dist/_internal/contracts/types/push.d.ts +86 -0
- package/dist/_internal/contracts/types/push.js +1 -0
- package/dist/_internal/contracts/types/variable.d.ts +5 -0
- package/dist/_internal/contracts/variable/parse.js +30 -1
- package/dist/_internal/core/blueprint/runtime-compile.d.ts +4 -0
- package/dist/_internal/core/blueprint/runtime-compile.js +45 -21
- package/dist/_internal/core/blueprint/runtime-dispatch.js +270 -156
- package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
- package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
- package/dist/_internal/core/blueprint/runtime-types.d.ts +112 -6
- package/dist/_internal/core/blueprint/runtime.d.ts +2 -1
- package/dist/_internal/core/blueprint/runtime.js +1 -0
- package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
- package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
- package/dist/_internal/core/commands/apply-component-commands.d.ts +5 -0
- package/dist/_internal/core/commands/apply-component-commands.js +74 -2
- package/dist/_internal/core/commands/apply.js +76 -3
- package/dist/_internal/core/commands/parse-command.js +24 -0
- package/dist/_internal/core/commands/types.d.ts +56 -3
- package/dist/_internal/core/data/data-candidates.d.ts +38 -0
- package/dist/_internal/core/data/data-candidates.js +186 -0
- package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
- package/dist/_internal/core/data/dataset-profile.js +170 -0
- package/dist/_internal/core/data/sample-values.d.ts +25 -0
- package/dist/_internal/core/data/sample-values.js +45 -0
- package/dist/_internal/core/diff/screen-diff.js +7 -1
- package/dist/_internal/core/index.d.ts +7 -1
- package/dist/_internal/core/index.js +7 -1
- package/dist/_internal/core/state/state-preset.d.ts +32 -0
- package/dist/_internal/core/state/state-preset.js +37 -0
- package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
- package/dist/_internal/core/validation/layout-audit.js +228 -0
- package/dist/_internal/core/validation/legibility.d.ts +9 -0
- package/dist/_internal/core/validation/legibility.js +33 -0
- package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-canvas-bridge-helpers.d.ts +1 -1
- package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-canvas-bridge.d.ts +11 -1
- package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-panels-controller.d.ts +18 -4
- package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-timer-scheduler.d.ts +21 -0
- package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-workbench-panel.d.ts +8 -1
- package/dist/_internal/engine/browser/controllers/dataset/designer-data-source-authoring.d.ts +25 -1
- package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-controller-context.d.ts +6 -2
- package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +14 -1
- package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-surface-controller.d.ts +14 -0
- package/dist/_internal/engine/browser/controllers/dataset/designer-update-policy-authoring.d.ts +52 -0
- package/dist/_internal/engine/browser/controllers/designer-artboard-controller.d.ts +80 -0
- package/dist/_internal/engine/browser/controllers/designer-canvas-runtime-controller.d.ts +21 -3
- package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +29 -0
- package/dist/_internal/engine/browser/controllers/designer-command-palette-controller.d.ts +2 -0
- package/dist/_internal/engine/browser/controllers/designer-notification-controller.d.ts +7 -0
- package/dist/_internal/engine/browser/controllers/designer-page-preview-controller.d.ts +34 -0
- package/dist/_internal/engine/browser/controllers/designer-popup-preview-controller.d.ts +40 -0
- package/dist/_internal/engine/browser/controllers/designer-preview-controller.d.ts +1 -3
- package/dist/_internal/engine/browser/controllers/designer-reference-layer-controller.d.ts +45 -0
- package/dist/_internal/engine/browser/controllers/designer-viewport-controller.d.ts +10 -0
- package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-callbacks.d.ts +5 -1
- package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-controller.d.ts +2 -0
- package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-environment.d.ts +18 -7
- package/dist/_internal/engine/browser/controllers/gesture/designer-group-editing-controller.d.ts +8 -1
- package/dist/_internal/engine/browser/controllers/layers/designer-layers-controller.d.ts +11 -0
- package/dist/_internal/engine/browser/controllers/panel/designer-component-states-controller.d.ts +26 -0
- package/dist/_internal/engine/browser/controllers/panel/designer-inspector-focus.d.ts +30 -0
- package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller-callbacks.d.ts +23 -6
- package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller.d.ts +2 -2
- package/dist/_internal/engine/browser/controllers/panel/designer-panel-material-controller.d.ts +4 -0
- package/dist/_internal/engine/browser/controllers/panel/designer-panel-property-controller.d.ts +2 -0
- package/dist/_internal/engine/browser/controllers/workbench/designer-snap-controller.d.ts +5 -1
- package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-controller.d.ts +7 -1
- package/dist/_internal/engine/browser/dom/blueprint/designer-blueprint-inspector-configuration.d.ts +12 -0
- package/dist/_internal/engine/browser/dom/blueprint/designer-blueprint-library-dom.d.ts +18 -2
- package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +22 -5
- package/dist/_internal/engine/browser/dom/color/designer-color-palette-dom.d.ts +1 -0
- package/dist/_internal/engine/browser/dom/color/designer-color-palette-theme.d.ts +10 -0
- package/dist/_internal/engine/browser/dom/color/designer-color-palette-types.d.ts +13 -0
- package/dist/_internal/engine/browser/dom/color/designer-color-theme-slots.d.ts +10 -0
- package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
- package/dist/_internal/engine/browser/dom/dataset/designer-dataset-types.d.ts +17 -6
- package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-control-dom.d.ts +17 -1
- package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-model.d.ts +2 -0
- package/dist/_internal/engine/browser/dom/designer-field-primitives.d.ts +43 -1
- package/dist/_internal/engine/browser/dom/designer-icons.d.ts +2 -0
- package/dist/_internal/engine/browser/dom/designer-select-dom.d.ts +2 -0
- package/dist/_internal/engine/browser/dom/designer-ui-primitives.d.ts +5 -0
- package/dist/_internal/engine/browser/dom/layers/designer-layers-model.d.ts +28 -0
- package/dist/_internal/engine/browser/dom/material-library/designer-material-library-dom.d.ts +18 -2
- package/dist/_internal/engine/browser/dom/material-library/designer-material-library-group-view.d.ts +1 -0
- package/dist/_internal/engine/browser/dom/menu/designer-menu-model.d.ts +4 -2
- package/dist/_internal/engine/browser/dom/panel/designer-canvas-properties-dom.d.ts +10 -2
- package/dist/_internal/engine/browser/dom/panel/designer-canvas-transactions.d.ts +5 -1
- package/dist/_internal/engine/browser/dom/panel/designer-chrome-primitives.d.ts +12 -0
- package/dist/_internal/engine/browser/dom/panel/designer-color-group-dom.d.ts +45 -0
- package/dist/_internal/engine/browser/dom/panel/designer-component-properties-dom.d.ts +4 -3
- package/dist/_internal/engine/browser/dom/panel/designer-component-states-dom.d.ts +22 -0
- package/dist/_internal/engine/browser/dom/panel/designer-panel-primitives.d.ts +18 -2
- package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +2 -0
- package/dist/_internal/engine/browser/dom/workspace/designer-workspace-template.d.ts +13 -0
- package/dist/_internal/engine/browser/dom/workspace/designer-workspace.d.ts +2 -1
- package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +10 -4
- package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +17 -5
- package/dist/_internal/engine/browser/viewport/designer-canvas-coordinates.d.ts +7 -0
- package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +8 -9
- package/dist/_internal/engine/browser/viewport/designer-canvas-snap-alignment-index.d.ts +27 -0
- package/dist/_internal/engine/browser/viewport/designer-canvas-snap-geometry.d.ts +13 -2
- package/dist/_internal/engine/browser/viewport/designer-canvas-snap-preview.d.ts +1 -1
- package/dist/_internal/engine/browser/viewport/designer-canvas-snap-spacing.d.ts +12 -0
- package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +4 -0
- package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
- package/dist/_internal/engine/common/observability/designer-metrics.d.ts +1 -1
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-geometry.d.ts +12 -0
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-graph.d.ts +203 -0
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-model-types.d.ts +6 -2
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-model.d.ts +58 -7
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-protocol-types.d.ts +131 -51
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-value-sources.d.ts +7 -3
- package/dist/_internal/engine/common/operations/catalog/designer-catalog-refresh.d.ts +13 -1
- package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
- package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
- package/dist/_internal/engine/common/operations/designer-operation-registry.d.ts +5 -1
- package/dist/_internal/engine/common/operations/designer-variable-operations.d.ts +8 -0
- package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
- package/dist/_internal/engine/common/operations/element/designer-element-operation-types.d.ts +8 -0
- package/dist/_internal/engine/common/operations/host-resource/host-resource-authoring.d.ts +1 -1
- package/dist/_internal/engine/common/operations/material-component/material-component-fragment-extract.d.ts +34 -0
- package/dist/_internal/engine/common/operations/material-component/material-component-fragment.d.ts +24 -41
- package/dist/_internal/engine/common/operations/material-component/material-component.d.ts +1 -1
- package/dist/_internal/engine/common/operations/material-library/material-library-fragments.d.ts +46 -0
- package/dist/_internal/engine/common/operations/material-library/material-library-grouping.d.ts +11 -0
- package/dist/_internal/engine/common/operations/selection/designer-group.d.ts +16 -4
- package/dist/_internal/engine/common/operations/selection/designer-multi-selection-operations.d.ts +4 -3
- package/dist/_internal/engine/common/operations/selection/designer-selection-actions.d.ts +6 -0
- package/dist/_internal/engine/common/operations/selection/designer-selection.d.ts +8 -0
- package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +67 -0
- package/dist/_internal/engine/common/operations/style/designer-material-appearance.d.ts +30 -0
- package/dist/_internal/engine/common/session/designer-artboard.d.ts +40 -0
- package/dist/_internal/engine/common/session/designer-session.d.ts +21 -0
- package/dist/_internal/engine/common/ui-text/designer-blueprint-ui-text.d.ts +169 -0
- package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +464 -90
- package/dist/_internal/engine/designer-blueprint-workbench-panel-BWSglfAb.js +2792 -0
- package/dist/_internal/engine/{designer-dataset-controller-CPytVNBK.js → designer-dataset-controller-DdbY4ILC.js} +1919 -1604
- package/dist/_internal/engine/designer-element/api/designer-element-catalog.d.ts +4 -3
- package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
- package/dist/_internal/engine/designer-element/api/designer-element-configuration-types.d.ts +11 -8
- package/dist/_internal/engine/designer-element/api/designer-element-fragment-save.d.ts +16 -0
- package/dist/_internal/engine/designer-element/api/designer-element-host-properties.d.ts +0 -5
- package/dist/_internal/engine/designer-element/api/designer-element-insert-component-fragment.d.ts +9 -2
- package/dist/_internal/engine/designer-element/api/designer-element-material-library-fragments.d.ts +17 -0
- package/dist/_internal/engine/designer-element/api/designer-element-project.d.ts +0 -1
- package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +36 -24
- package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +7 -6
- package/dist/_internal/engine/designer-element/runtime/designer-element-guards.d.ts +0 -2
- package/dist/_internal/engine/designer-element/runtime/designer-element-host.d.ts +6 -7
- package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +12 -2
- package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +19 -15
- package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
- package/dist/_internal/engine/designer-element/runtime/designer-element-state.d.ts +29 -10
- package/dist/_internal/engine/{designer-ui-primitives-CH4RNiMa.js → designer-field-primitives-Crn464Qg.js} +919 -348
- package/dist/_internal/engine/designer-left-panel-groups-dom-DFdLWxxY.js +1282 -0
- package/dist/_internal/engine/host-resource-selection-CWrPLVOc.js +2482 -0
- package/dist/_internal/engine/host-tokens.css +12 -12
- package/dist/_internal/engine/index.js +9202 -6279
- package/dist/_internal/host-kit/index.d.ts +3 -0
- package/dist/_internal/host-kit/index.js +3 -0
- package/dist/_internal/host-kit/intent/index.d.ts +16 -0
- package/dist/_internal/host-kit/intent/index.js +13 -0
- package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
- package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
- package/dist/_internal/host-kit/intent/intent-block.d.ts +59 -0
- package/dist/_internal/host-kit/intent/intent-block.js +359 -0
- package/dist/_internal/host-kit/intent/intent-catalog.d.ts +105 -0
- package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
- package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
- package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
- package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
- package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
- package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
- package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
- package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
- package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
- package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
- package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
- package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
- package/dist/_internal/host-kit/intent/intent-format.js +94 -0
- package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
- package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
- package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
- package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
- package/dist/_internal/host-kit/intent/intent-parse.d.ts +39 -0
- package/dist/_internal/host-kit/intent/intent-parse.js +930 -0
- package/dist/_internal/host-kit/intent/intent-prepare.d.ts +52 -0
- package/dist/_internal/host-kit/intent/intent-prepare.js +104 -0
- package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
- package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
- package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
- package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
- package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
- package/dist/_internal/host-kit/intent/intent-style.js +77 -0
- package/dist/_internal/host-kit/intent/intent-types.d.ts +234 -0
- package/dist/_internal/host-kit/intent/intent-types.js +10 -0
- package/dist/_internal/host-kit/push-result.d.ts +5 -0
- package/dist/_internal/host-kit/push-result.js +8 -0
- package/dist/_internal/host-kit/sse-subscribe.d.ts +59 -0
- package/dist/_internal/host-kit/sse-subscribe.js +253 -0
- package/dist/_internal/host-kit/subscription-hub.d.ts +41 -0
- package/dist/_internal/host-kit/subscription-hub.js +179 -0
- package/dist/_internal/material/base-material.d.ts +1 -0
- package/dist/_internal/material/chart.d.ts +4 -0
- package/dist/_internal/material/chart.js +123 -58
- package/dist/_internal/material/container.js +19 -33
- package/dist/_internal/material/{base-material-BArgjOeL.js → editor-descriptor-DJZYygOa.js} +49 -20
- package/dist/_internal/material/editor-descriptor.d.ts +18 -0
- package/dist/_internal/material/image.js +30 -34
- package/dist/_internal/material/rule.js +29 -42
- package/dist/_internal/material/shapes.js +57 -74
- package/dist/_internal/material/table.d.ts +4 -0
- package/dist/_internal/material/table.js +149 -71
- package/dist/_internal/material/text.js +40 -68
- package/dist/_internal/plugin-core/contracts.d.ts +38 -49
- package/dist/_internal/plugin-core/contribution-kind.js +47 -2
- package/dist/_internal/plugin-core/editor/editor-ai-description.d.ts +3 -0
- package/dist/_internal/plugin-core/editor/editor-ai-description.js +124 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor-conditions.js +5 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor-inference.d.ts +32 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor-inference.js +83 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor-items.d.ts +6 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor-items.js +41 -12
- package/dist/_internal/plugin-core/editor/editor-descriptor-model.d.ts +24 -1
- package/dist/_internal/plugin-core/editor/editor-descriptor-model.js +6 -1
- package/dist/_internal/plugin-core/editor/editor-descriptor-schema.js +21 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor-sections.js +5 -7
- package/dist/_internal/plugin-core/editor/editor-descriptor.d.ts +1 -0
- package/dist/_internal/plugin-core/editor/editor-descriptor.js +55 -2
- package/dist/_internal/plugin-core/fragment/fragment.d.ts +96 -0
- package/dist/_internal/plugin-core/fragment/fragment.js +535 -0
- package/dist/_internal/plugin-core/index.d.ts +7 -4
- package/dist/_internal/plugin-core/index.js +5 -2
- package/dist/_internal/plugin-core/material/material-manifest.js +14 -2
- package/dist/_internal/plugin-core/material/material-schema.d.ts +9 -0
- package/dist/_internal/plugin-core/material/material-schema.js +31 -1
- package/dist/_internal/plugin-core/material/material-theme.d.ts +25 -0
- package/dist/_internal/plugin-core/material/material-theme.js +77 -0
- package/dist/_internal/plugin-core/material/material-validation-constants.js +2 -0
- package/dist/_internal/plugin-core/material/material.d.ts +1 -1
- package/dist/_internal/plugin-core/material/material.js +1 -1
- package/dist/_internal/plugin-manager/contribution-kind-plan.d.ts +2 -1
- package/dist/_internal/plugin-manager/contribution-kind-plan.js +6 -0
- package/dist/_internal/plugin-manager/contributions.js +10 -0
- package/dist/_internal/plugin-sdk/authoring-finding.d.ts +19 -0
- package/dist/_internal/plugin-sdk/authoring-finding.js +12 -0
- package/dist/_internal/plugin-sdk/fragment-audit.d.ts +14 -0
- package/dist/_internal/plugin-sdk/fragment-audit.js +170 -0
- package/dist/_internal/plugin-sdk/fragment-definition.d.ts +11 -0
- package/dist/_internal/plugin-sdk/fragment-definition.js +16 -0
- package/dist/_internal/plugin-sdk/index.d.ts +15 -0
- package/dist/_internal/plugin-sdk/index.js +15 -0
- package/dist/_internal/plugin-sdk/material-config-groups.d.ts +44 -0
- package/dist/_internal/plugin-sdk/material-config-groups.js +80 -0
- package/dist/_internal/plugin-sdk/material-editor-audit.d.ts +24 -0
- package/dist/_internal/plugin-sdk/material-editor-audit.js +160 -0
- package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
- package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
- package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
- package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
- package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
- package/dist/_internal/plugin-sdk/material-isolated.js +1024 -0
- package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +77 -0
- package/dist/_internal/plugin-sdk/material-rendered-element.js +229 -0
- package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +24 -0
- package/dist/_internal/plugin-sdk/material-spec-audit.js +204 -0
- package/dist/_internal/plugin-sdk/material-spec.d.ts +134 -0
- package/dist/_internal/plugin-sdk/material-spec.js +710 -0
- package/dist/_internal/plugin-sdk/material-style-keys.d.ts +17 -0
- package/dist/_internal/plugin-sdk/material-style-keys.js +82 -0
- package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
- package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
- package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
- package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
- package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
- package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
- package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
- package/dist/_internal/plugin-sdk/material-template.js +879 -0
- package/dist/_internal/renderer/index.d.ts +2 -0
- package/dist/_internal/renderer/index.js +1745 -616
- package/dist/_internal/renderer/renderer/renderer-component-states.d.ts +34 -0
- package/dist/_internal/renderer/renderer/renderer-effective-style.d.ts +12 -6
- package/dist/_internal/renderer/renderer/renderer-material-dom.d.ts +19 -3
- package/dist/_internal/renderer/renderer/renderer-mounted-material.d.ts +11 -10
- package/dist/_internal/renderer/renderer/renderer-state.d.ts +17 -1
- package/dist/_internal/renderer/renderer/renderer-theme.d.ts +11 -0
- package/dist/_internal/renderer/renderer/renderer-types.d.ts +15 -5
- package/dist/_internal/renderer/renderer/renderer.d.ts +30 -9
- package/dist/_internal/renderer/resource/data-source-runtime.d.ts +25 -2
- package/dist/_internal/renderer/resource/push-window.d.ts +43 -0
- package/dist/_internal/renderer/resource/source-query-port.d.ts +8 -1
- package/dist/_internal/renderer/sub-canvas-layer.d.ts +83 -0
- package/dist/_internal/renderer/viewer/viewer-blueprint-timer-scheduler.d.ts +23 -0
- package/dist/_internal/renderer/viewer/viewer-configuration-guards.d.ts +0 -1
- package/dist/_internal/renderer/viewer/viewer-configuration.d.ts +6 -3
- package/dist/_internal/renderer/viewer/viewer-stale-style.d.ts +3 -0
- package/dist/_internal/renderer/viewer/viewer-variable-controller.d.ts +2 -0
- package/dist/_internal/renderer/viewer/viewer.d.ts +18 -7
- package/dist/_internal/sdk/auto-register.js +7 -7
- package/dist/_internal/sdk/designer-auto-register.js +3 -3
- package/dist/_internal/sdk/designer.d.ts +1 -1
- package/dist/_internal/sdk/designer.js +8 -8
- package/dist/_internal/sdk/host-tokens.css +12 -12
- package/dist/_internal/sdk/index.d.ts +1 -1
- package/dist/_internal/sdk/index.js +6 -6
- package/dist/auto-register.js +11 -11
- package/dist/auto-register.js.map +1 -1
- package/dist/contracts.js +73 -43
- package/dist/contracts.js.map +1 -1
- package/dist/contrast-DRPezUIl.js +131 -0
- package/dist/contrast-DRPezUIl.js.map +1 -0
- package/dist/core.js +169 -21
- package/dist/core.js.map +1 -1
- package/dist/{data-contracts-BFld0hw_.js → data-contracts-CnnB5KC9.js} +2 -2
- package/dist/{data-contracts-BFld0hw_.js.map → data-contracts-CnnB5KC9.js.map} +1 -1
- package/dist/dataset-port-D993nOlT.js +182 -0
- package/dist/dataset-port-D993nOlT.js.map +1 -0
- package/dist/dataset-profile-Dk6xdtsM.js +261 -0
- package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
- package/dist/{designer-Byw45cUM.js → designer-CFOvOmLn.js} +3 -3
- package/dist/designer-CFOvOmLn.js.map +1 -0
- package/dist/designer-auto-register.js +6 -6
- package/dist/designer-auto-register.js.map +1 -1
- package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js +2773 -0
- package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js.map +1 -0
- package/dist/{designer-dataset-controller-CPytVNBK-DWL3SRTP.js → designer-dataset-controller-DdbY4ILC-CMdGdGbr.js} +1471 -1158
- package/dist/designer-dataset-controller-DdbY4ILC-CMdGdGbr.js.map +1 -0
- package/dist/{designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js → designer-field-primitives-Crn464Qg-Bi7q8s5J.js} +914 -345
- package/dist/designer-field-primitives-Crn464Qg-Bi7q8s5J.js.map +1 -0
- package/dist/designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js +1265 -0
- package/dist/designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js.map +1 -0
- package/dist/designer.js +5 -5
- package/dist/dist-B2bW2Tru.js +3305 -0
- package/dist/dist-B2bW2Tru.js.map +1 -0
- package/dist/{dist-BHTClwId.js → dist-CHK9BTXX.js} +9148 -6234
- package/dist/dist-CHK9BTXX.js.map +1 -0
- package/dist/engine.js +5 -4
- package/dist/fragment-B-oP0Fru.js +393 -0
- package/dist/fragment-B-oP0Fru.js.map +1 -0
- package/dist/host-kit.js +4172 -102
- package/dist/host-kit.js.map +1 -1
- package/dist/{host-resource-selection-5Cf_gclK-Sv4Z8UXS.js → host-resource-selection-CWrPLVOc-DPDq3jau.js} +1233 -937
- package/dist/host-resource-selection-CWrPLVOc-DPDq3jau.js.map +1 -0
- package/dist/host-tokens.css +12 -12
- package/dist/index.js +10 -10
- package/dist/legibility-CS28ivEz.js +12 -0
- package/dist/legibility-CS28ivEz.js.map +1 -0
- package/dist/level-scale-CwHqFEVd.js +139 -0
- package/dist/level-scale-CwHqFEVd.js.map +1 -0
- package/dist/{manager-B2CZ2b5I.js → manager-CeB4Jnr9.js} +20 -10
- package/dist/manager-CeB4Jnr9.js.map +1 -0
- package/dist/material-DeVkzSoT.js +12 -0
- package/dist/{material-BPlvEmDi.js.map → material-DeVkzSoT.js.map} +1 -1
- package/dist/material-auto-register.js +6 -6
- package/dist/material-auto-register.js.map +1 -1
- package/dist/{material-definition-B9xCZcD-.js → material-definition-BeW34dJr.js} +2 -2
- package/dist/{material-definition-B9xCZcD-.js.map → material-definition-BeW34dJr.js.map} +1 -1
- package/dist/{material-manifest-bsGl6vZZ.js → material-manifest-B1XatGPx.js} +222 -137
- package/dist/material-manifest-B1XatGPx.js.map +1 -0
- package/dist/material-schema-CLoDx-Tl.js +203 -0
- package/dist/material-schema-CLoDx-Tl.js.map +1 -0
- package/dist/{editor-descriptor-schema-Be30Wv8w.js → material-theme-C91eus78.js} +90 -28
- package/dist/material-theme-C91eus78.js.map +1 -0
- package/dist/material-validation-utils-ku_6Xxk2.js +125 -0
- package/dist/material-validation-utils-ku_6Xxk2.js.map +1 -0
- package/dist/material.js +3 -3
- package/dist/migrate-document-BM888PtC.js +768 -0
- package/dist/migrate-document-BM888PtC.js.map +1 -0
- package/dist/parse-Ji7kE9ZT.js +2313 -0
- package/dist/parse-Ji7kE9ZT.js.map +1 -0
- package/dist/{parse-B0hwp_yj.js → parse-aZat9tAS.js} +69 -61
- package/dist/{parse-B0hwp_yj.js.map → parse-aZat9tAS.js.map} +1 -1
- package/dist/parse-parts-qzl4suzk.js +42 -0
- package/dist/parse-parts-qzl4suzk.js.map +1 -0
- package/dist/{plugin-B9Xxtw7G.js → plugin-CstHQ5ws.js} +140 -94
- package/dist/plugin-CstHQ5ws.js.map +1 -0
- package/dist/plugin-core.js +93 -8
- package/dist/plugin-core.js.map +1 -0
- package/dist/plugin-manager.js +1 -1
- package/dist/plugin-package-DWifuHi1.js +4206 -0
- package/dist/plugin-package-DWifuHi1.js.map +1 -0
- package/dist/{plugin-registration-BjS_CXJU.js → plugin-registration-DTwBvnHX.js} +4 -4
- package/dist/{plugin-registration-BjS_CXJU.js.map → plugin-registration-DTwBvnHX.js.map} +1 -1
- package/dist/plugin-sdk.js +6 -6
- package/dist/{plugins-B9bwk-t6.js → plugins-QDL0yIql.js} +2 -2
- package/dist/{plugins-B9bwk-t6.js.map → plugins-QDL0yIql.js.map} +1 -1
- package/dist/plugins.js +8 -8
- package/dist/renderer.js +1 -1
- package/dist/runtime-dispatch-C0gyIrTv.js +479 -0
- package/dist/runtime-dispatch-C0gyIrTv.js.map +1 -0
- package/dist/runtime-simulate-aSYO9yDX.js +147 -0
- package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
- package/dist/{src-Bm7u11mN-BMeb9fvV.js → src-Bm7u11mN-Bi1hDVkh.js} +30 -30
- package/dist/{src-Bm7u11mN-BMeb9fvV.js.map → src-Bm7u11mN-Bi1hDVkh.js.map} +1 -1
- package/dist/state-preset-DtpygJOH.js +22 -0
- package/dist/state-preset-DtpygJOH.js.map +1 -0
- package/dist/{text-BVzTcUas.js → text-BSTz0pFQ.js} +454 -360
- package/dist/text-BSTz0pFQ.js.map +1 -0
- package/dist/theme-CcBXf4Ay.js +48 -0
- package/dist/theme-CcBXf4Ay.js.map +1 -0
- package/dist/{value-ref-y4_YKUP5.js → value-ref-XkLuckGV.js} +2 -2
- package/dist/{value-ref-y4_YKUP5.js.map → value-ref-XkLuckGV.js.map} +1 -1
- package/dist/{viewer-CrJupI8I-DZZfdHXr.js → viewer-CrJupI8I-BJiz1cvW.js} +5 -5
- package/dist/{viewer-CrJupI8I-DZZfdHXr.js.map → viewer-CrJupI8I-BJiz1cvW.js.map} +1 -1
- package/dist/viewer-auto-register.js +2 -2
- package/dist/viewer.js +2 -2
- package/dist/viewport-BNIRWjiT.js +1207 -0
- package/dist/viewport-BNIRWjiT.js.map +1 -0
- package/package.json +12 -12
- package/dist/_internal/contracts/document/blueprint-relations.d.ts +0 -16
- package/dist/_internal/contracts/document/blueprint-relations.js +0 -196
- package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-panel-mutations.d.ts +0 -5
- package/dist/_internal/engine/browser/controllers/designer-guard-controller.d.ts +0 -27
- package/dist/_internal/engine/browser/controllers/designer-scene-controller.d.ts +0 -47
- package/dist/_internal/engine/browser/controllers/panel/designer-style-rules-controller.d.ts +0 -12
- package/dist/_internal/engine/browser/dom/guard/designer-contrast-measure.d.ts +0 -24
- package/dist/_internal/engine/browser/dom/guard/designer-guard-dom.d.ts +0 -15
- package/dist/_internal/engine/browser/dom/workspace/designer-canvas-hint-dom.d.ts +0 -6
- package/dist/_internal/engine/browser/viewport/designer-canvas-snap-index.d.ts +0 -9
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-connection.d.ts +0 -14
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-mutation-helpers.d.ts +0 -20
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-mutations.d.ts +0 -15
- package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-node-ids.d.ts +0 -12
- package/dist/_internal/engine/common/operations/designer-name-validation.d.ts +0 -2
- package/dist/_internal/engine/common/operations/scene/designer-scene.d.ts +0 -55
- package/dist/_internal/engine/common/operations/style/designer-host-conditional-style.d.ts +0 -21
- package/dist/_internal/engine/common/operations/style/designer-style-rules.d.ts +0 -25
- package/dist/_internal/engine/common/validation/designer-guard.d.ts +0 -49
- package/dist/_internal/engine/designer-blueprint-workbench-panel-C2MoZwKA.js +0 -3548
- package/dist/_internal/engine/designer-element/api/designer-element-guard.d.ts +0 -13
- package/dist/_internal/engine/designer-element/api/designer-element-scene.d.ts +0 -14
- package/dist/_internal/engine/designer-left-panel-groups-dom-WMsH33zw.js +0 -573
- package/dist/_internal/engine/host-resource-selection-5Cf_gclK.js +0 -2188
- package/dist/_internal/renderer/style-rules.d.ts +0 -9
- package/dist/contrast-CZFqj1I5.js +0 -1050
- package/dist/contrast-CZFqj1I5.js.map +0 -1
- package/dist/dataset-port-CUsMmX2x.js +0 -65
- package/dist/dataset-port-CUsMmX2x.js.map +0 -1
- package/dist/designer-Byw45cUM.js.map +0 -1
- package/dist/designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js +0 -3517
- package/dist/designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js.map +0 -1
- package/dist/designer-dataset-controller-CPytVNBK-DWL3SRTP.js.map +0 -1
- package/dist/designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js +0 -557
- package/dist/designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js.map +0 -1
- package/dist/designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js.map +0 -1
- package/dist/dist-BHTClwId.js.map +0 -1
- package/dist/dist-DfAV2jGI.js +0 -2185
- package/dist/dist-DfAV2jGI.js.map +0 -1
- package/dist/editor-descriptor-schema-Be30Wv8w.js.map +0 -1
- package/dist/host-resource-selection-5Cf_gclK-Sv4Z8UXS.js.map +0 -1
- package/dist/manager-B2CZ2b5I.js.map +0 -1
- package/dist/material-BPlvEmDi.js +0 -12
- package/dist/material-manifest-bsGl6vZZ.js.map +0 -1
- package/dist/material-schema-CtxTkCP2.js +0 -267
- package/dist/material-schema-CtxTkCP2.js.map +0 -1
- package/dist/migrate-document-BJUN7NPv.js +0 -436
- package/dist/migrate-document-BJUN7NPv.js.map +0 -1
- package/dist/parse-BQw3u9_4.js +0 -1126
- package/dist/parse-BQw3u9_4.js.map +0 -1
- package/dist/plugin-B9Xxtw7G.js.map +0 -1
- package/dist/plugin-package-BT-pCoTt.js +0 -174
- package/dist/plugin-package-BT-pCoTt.js.map +0 -1
- package/dist/runtime-dispatch-Dt9fhcI5.js +0 -360
- package/dist/runtime-dispatch-Dt9fhcI5.js.map +0 -1
- package/dist/schema-C38FI_z2.js +0 -541
- package/dist/schema-C38FI_z2.js.map +0 -1
- package/dist/text-BVzTcUas.js.map +0 -1
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
import { parseBaseScreenMaterialTemplateExpression, } from './material-template-expression.js';
|
|
2
|
+
export const BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS = {
|
|
3
|
+
nodes: 300,
|
|
4
|
+
repeat: 200,
|
|
5
|
+
animations: 8,
|
|
6
|
+
events: 4,
|
|
7
|
+
gradients: 8,
|
|
8
|
+
pathCommands: 64,
|
|
9
|
+
dash: 6,
|
|
10
|
+
minDuration: 100,
|
|
11
|
+
maxDuration: 20_000,
|
|
12
|
+
};
|
|
13
|
+
/** 节点种类(ADR-0116 §2.2):结构、基础、参数化高层图元。 */
|
|
14
|
+
export const BASE_SCREEN_MATERIAL_TEMPLATE_NODE_KINDS = [
|
|
15
|
+
'g',
|
|
16
|
+
'repeat',
|
|
17
|
+
'when',
|
|
18
|
+
'clip',
|
|
19
|
+
'rect',
|
|
20
|
+
'circle',
|
|
21
|
+
'ellipse',
|
|
22
|
+
'line',
|
|
23
|
+
'polyline',
|
|
24
|
+
'path',
|
|
25
|
+
'text',
|
|
26
|
+
'arc',
|
|
27
|
+
'ticks',
|
|
28
|
+
'wave',
|
|
29
|
+
];
|
|
30
|
+
/** 各种类的数值参数;`change` 动画只能补间这里列出的参数。 */
|
|
31
|
+
export const BASE_SCREEN_MATERIAL_TEMPLATE_NUMBER_ATTRS = {
|
|
32
|
+
g: ['x', 'y', 'scale', 'rotate'],
|
|
33
|
+
repeat: [],
|
|
34
|
+
when: [],
|
|
35
|
+
clip: [],
|
|
36
|
+
rect: ['x', 'y', 'width', 'height', 'rx'],
|
|
37
|
+
circle: ['cx', 'cy', 'r'],
|
|
38
|
+
ellipse: ['cx', 'cy', 'rx', 'ry'],
|
|
39
|
+
line: ['x1', 'y1', 'x2', 'y2'],
|
|
40
|
+
polyline: [],
|
|
41
|
+
path: [],
|
|
42
|
+
text: ['x', 'y', 'fontSize'],
|
|
43
|
+
arc: ['cx', 'cy', 'r', 'thickness', 'start', 'end'],
|
|
44
|
+
ticks: ['cx', 'cy', 'r', 'length', 'count', 'start', 'end'],
|
|
45
|
+
wave: ['x', 'y', 'width', 'height', 'amplitude', 'wavelength', 'phase'],
|
|
46
|
+
};
|
|
47
|
+
const REQUIRED_NUMBER_ATTRS = {
|
|
48
|
+
rect: ['x', 'y', 'width', 'height'],
|
|
49
|
+
circle: ['cx', 'cy', 'r'],
|
|
50
|
+
ellipse: ['cx', 'cy', 'rx', 'ry'],
|
|
51
|
+
line: ['x1', 'y1', 'x2', 'y2'],
|
|
52
|
+
text: ['x', 'y', 'fontSize'],
|
|
53
|
+
arc: ['cx', 'cy', 'r', 'thickness', 'start', 'end'],
|
|
54
|
+
ticks: ['cx', 'cy', 'r', 'length', 'count', 'start', 'end'],
|
|
55
|
+
wave: ['x', 'y', 'width', 'height', 'amplitude', 'wavelength'],
|
|
56
|
+
};
|
|
57
|
+
const SHAPE_KINDS = new Set([
|
|
58
|
+
'rect',
|
|
59
|
+
'circle',
|
|
60
|
+
'ellipse',
|
|
61
|
+
'line',
|
|
62
|
+
'polyline',
|
|
63
|
+
'path',
|
|
64
|
+
'text',
|
|
65
|
+
'arc',
|
|
66
|
+
'ticks',
|
|
67
|
+
'wave',
|
|
68
|
+
]);
|
|
69
|
+
const CLIP_SHAPE_KINDS = new Set(['rect', 'circle', 'ellipse', 'path']);
|
|
70
|
+
const CONTAINER_KINDS = new Set(['g', 'repeat', 'when', 'clip']);
|
|
71
|
+
const FILLABLE_KINDS = new Set([
|
|
72
|
+
'rect',
|
|
73
|
+
'circle',
|
|
74
|
+
'ellipse',
|
|
75
|
+
'path',
|
|
76
|
+
'wave',
|
|
77
|
+
'polyline',
|
|
78
|
+
]);
|
|
79
|
+
const EXTRA_KEYS = {
|
|
80
|
+
g: ['children', 'opacity'],
|
|
81
|
+
repeat: ['source', 'children'],
|
|
82
|
+
when: ['test', 'children'],
|
|
83
|
+
clip: ['shape', 'children'],
|
|
84
|
+
rect: [],
|
|
85
|
+
circle: [],
|
|
86
|
+
ellipse: [],
|
|
87
|
+
line: [],
|
|
88
|
+
polyline: ['points', 'closed'],
|
|
89
|
+
path: ['d'],
|
|
90
|
+
text: ['content', 'fontWeight', 'anchor', 'baseline', 'backdrop'],
|
|
91
|
+
arc: ['linecap'],
|
|
92
|
+
ticks: [],
|
|
93
|
+
wave: [],
|
|
94
|
+
};
|
|
95
|
+
const SHAPE_KEYS = [
|
|
96
|
+
'fill',
|
|
97
|
+
'stroke',
|
|
98
|
+
'strokeWidth',
|
|
99
|
+
'strokeDasharray',
|
|
100
|
+
'strokeLinecap',
|
|
101
|
+
'opacity',
|
|
102
|
+
'on',
|
|
103
|
+
];
|
|
104
|
+
const ID_PATTERN = /^[a-z][A-Za-z0-9-]{0,39}$/;
|
|
105
|
+
const EVENT_PATTERN = /^[a-z][A-Za-z0-9]{0,31}$/;
|
|
106
|
+
const PAYLOAD_KEY_PATTERN = /^[a-z][A-Za-z0-9]{0,31}$/;
|
|
107
|
+
/** 字面量颜色:#rgb / #rrggbb / #rrggbbaa、rgb() / rgba() / hsl() / hsla()(括号里不能再有括号)、几个关键字。 */
|
|
108
|
+
export const BASE_SCREEN_MATERIAL_TEMPLATE_COLOR = /^(?:#[0-9a-fA-F]{3,4}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{8}|(?:rgb|rgba|hsl|hsla)\([0-9.,%\s/deg]*\)|transparent|none|currentColor)$/;
|
|
109
|
+
const PATH_COMMANDS = {
|
|
110
|
+
M: 2,
|
|
111
|
+
L: 2,
|
|
112
|
+
H: 1,
|
|
113
|
+
V: 1,
|
|
114
|
+
C: 6,
|
|
115
|
+
Q: 4,
|
|
116
|
+
A: 7,
|
|
117
|
+
Z: 0,
|
|
118
|
+
};
|
|
119
|
+
const LOOP_PROPERTIES = new Set(['translateX', 'translateY', 'rotate', 'scale', 'opacity']);
|
|
120
|
+
const EASINGS = new Set(['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out']);
|
|
121
|
+
const ANCHORS = new Set(['start', 'middle', 'end']);
|
|
122
|
+
const BASELINES = new Set(['auto', 'middle', 'hanging']);
|
|
123
|
+
const LINECAPS = new Set(['butt', 'round', 'square']);
|
|
124
|
+
const FONT_WEIGHTS = new Set([400, 500, 600, 700]);
|
|
125
|
+
const RULE_MESSAGE = (rule, message) => `${rule}:${message}`;
|
|
126
|
+
/**
|
|
127
|
+
* 解析并编译模板。诊断路径相对规格根(`['template', 'nodes', 2, 'fill']`),消息以规则号开头
|
|
128
|
+
* (`TPL1:…`),体检据此归到 TPL 规则。
|
|
129
|
+
*/
|
|
130
|
+
export function compileBaseScreenMaterialTemplate(input, context) {
|
|
131
|
+
const compiler = new TemplateCompiler(context);
|
|
132
|
+
const compiled = compiler.compile(input);
|
|
133
|
+
if (compiler.diagnostics.length > 0 || compiled === undefined) {
|
|
134
|
+
return { ok: false, diagnostics: compiler.diagnostics };
|
|
135
|
+
}
|
|
136
|
+
return { ok: true, value: compiled, diagnostics: [] };
|
|
137
|
+
}
|
|
138
|
+
class TemplateCompiler {
|
|
139
|
+
context;
|
|
140
|
+
diagnostics = [];
|
|
141
|
+
#index = new Map();
|
|
142
|
+
#ids = new Set();
|
|
143
|
+
#gradientIds = new Set();
|
|
144
|
+
#props;
|
|
145
|
+
#style;
|
|
146
|
+
#roles;
|
|
147
|
+
#colorKeys;
|
|
148
|
+
#numberKeys;
|
|
149
|
+
#events;
|
|
150
|
+
#nodeCount = 0;
|
|
151
|
+
constructor(context) {
|
|
152
|
+
this.context = context;
|
|
153
|
+
this.#props = new Set();
|
|
154
|
+
this.#style = new Set();
|
|
155
|
+
this.#colorKeys = new Set();
|
|
156
|
+
this.#numberKeys = new Set();
|
|
157
|
+
for (const field of context.fields) {
|
|
158
|
+
(context.sectionTarget(field.section) === 'props' ? this.#props : this.#style).add(field.key);
|
|
159
|
+
if (field.kind === 'color')
|
|
160
|
+
this.#colorKeys.add(field.key);
|
|
161
|
+
if (field.kind === 'number')
|
|
162
|
+
this.#numberKeys.add(field.key);
|
|
163
|
+
}
|
|
164
|
+
// 读数格式配置组的 props(decimals / prefix / unit / thousandsSeparator)由 format() 读,不必直接引用。
|
|
165
|
+
this.#roles = new Set(context.data.kind === 'rows' ? context.data.roles.map((role) => role.id) : []);
|
|
166
|
+
this.#events = new Map((context.events ?? []).map((event) => [event.name, event]));
|
|
167
|
+
}
|
|
168
|
+
#add(rule, path, message) {
|
|
169
|
+
this.diagnostics.push({
|
|
170
|
+
severity: 'error',
|
|
171
|
+
code: 'PLUGIN_CORE_MANIFEST_FIELD_INVALID',
|
|
172
|
+
path: ['template', ...path],
|
|
173
|
+
message: RULE_MESSAGE(rule, message),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
compile(input) {
|
|
177
|
+
if (!isRecord(input)) {
|
|
178
|
+
this.#add('TPL4', [], '模板必须是对象。');
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
for (const key of Object.keys(input)) {
|
|
182
|
+
if (!['viewBox', 'fit', 'defs', 'nodes', 'animations'].includes(key)) {
|
|
183
|
+
this.#add('TPL1', [key], `模板没有字段 ${key}。`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const viewBox = input.viewBox;
|
|
187
|
+
const validViewBox = Array.isArray(viewBox) &&
|
|
188
|
+
viewBox.length === 4 &&
|
|
189
|
+
viewBox.every((item) => typeof item === 'number' && Number.isFinite(item)) &&
|
|
190
|
+
viewBox[2] > 0 &&
|
|
191
|
+
viewBox[3] > 0;
|
|
192
|
+
if (!validViewBox)
|
|
193
|
+
this.#add('TPL4', ['viewBox'], 'viewBox 必须是 [x, y, 宽, 高] 四个数字,宽高大于 0。');
|
|
194
|
+
const fit = input.fit ?? 'contain';
|
|
195
|
+
if (fit !== 'contain' && fit !== 'cover' && fit !== 'stretch') {
|
|
196
|
+
this.#add('TPL4', ['fit'], 'fit 只能是 contain / cover / stretch。');
|
|
197
|
+
}
|
|
198
|
+
const gradients = this.#gradients(input.defs);
|
|
199
|
+
const scope = {
|
|
200
|
+
props: this.#props,
|
|
201
|
+
style: this.#style,
|
|
202
|
+
roles: this.#roles,
|
|
203
|
+
data: this.context.data.kind,
|
|
204
|
+
inRepeat: false,
|
|
205
|
+
inRowRepeat: false,
|
|
206
|
+
};
|
|
207
|
+
if (!Array.isArray(input.nodes) || input.nodes.length === 0) {
|
|
208
|
+
this.#add('TPL4', ['nodes'], 'nodes 必须是非空数组。');
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
const nodes = this.#nodeList(input.nodes, ['nodes'], scope);
|
|
212
|
+
this.#checkBackdrops();
|
|
213
|
+
const animations = this.#animations(input.animations, scope);
|
|
214
|
+
if (!validViewBox)
|
|
215
|
+
return undefined;
|
|
216
|
+
return {
|
|
217
|
+
viewBox: viewBox,
|
|
218
|
+
fit: fit,
|
|
219
|
+
gradients,
|
|
220
|
+
nodes,
|
|
221
|
+
animations,
|
|
222
|
+
index: this.#index,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
#gradients(input) {
|
|
226
|
+
if (input === undefined)
|
|
227
|
+
return [];
|
|
228
|
+
if (!Array.isArray(input)) {
|
|
229
|
+
this.#add('TPL4', ['defs'], 'defs 必须是数组。');
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
if (input.length > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.gradients) {
|
|
233
|
+
this.#add('TPL3', ['defs'], `渐变最多 ${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.gradients} 个。`);
|
|
234
|
+
}
|
|
235
|
+
const output = [];
|
|
236
|
+
input.forEach((item, index) => {
|
|
237
|
+
const path = ['defs', index];
|
|
238
|
+
if (!isRecord(item) || (item.kind !== 'linearGradient' && item.kind !== 'radialGradient')) {
|
|
239
|
+
this.#add('TPL1', path, 'defs 里只能是 linearGradient / radialGradient。');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const geometryKeys = item.kind === 'linearGradient' ? ['x1', 'y1', 'x2', 'y2'] : ['cx', 'cy', 'r'];
|
|
243
|
+
for (const key of Object.keys(item)) {
|
|
244
|
+
if (!['kind', 'id', 'stops', ...geometryKeys].includes(key)) {
|
|
245
|
+
this.#add('TPL1', [...path, key], `${item.kind} 没有字段 ${key}。`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const id = item.id;
|
|
249
|
+
if (typeof id !== 'string' || !ID_PATTERN.test(id)) {
|
|
250
|
+
this.#add('TPL4', [...path, 'id'], 'id 为小写字母开头的字母、数字、连字符(≤ 40)。');
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (this.#gradientIds.has(id))
|
|
254
|
+
this.#add('TPL4', [...path, 'id'], `渐变 id ${id} 重复。`);
|
|
255
|
+
this.#gradientIds.add(id);
|
|
256
|
+
const defaults = item.kind === 'linearGradient'
|
|
257
|
+
? { x1: 0, y1: 0, x2: 0, y2: 1 }
|
|
258
|
+
: { cx: 0.5, cy: 0.5, r: 0.5 };
|
|
259
|
+
const geometry = {};
|
|
260
|
+
for (const key of geometryKeys) {
|
|
261
|
+
const value = item[key] ?? defaults[key];
|
|
262
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < -1 || value > 2) {
|
|
263
|
+
this.#add('TPL4', [...path, key], `${key} 是 -1 到 2 之间的数字(相对图形包围盒的比例)。`);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
geometry[key] = value;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const stops = [];
|
|
270
|
+
if (!Array.isArray(item.stops) || item.stops.length < 2 || item.stops.length > 8) {
|
|
271
|
+
this.#add('TPL4', [...path, 'stops'], 'stops 是 2–8 个色标。');
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
item.stops.forEach((stop, at) => {
|
|
275
|
+
const stopPath = [...path, 'stops', at];
|
|
276
|
+
if (!isRecord(stop)) {
|
|
277
|
+
this.#add('TPL4', stopPath, '色标必须是对象。');
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
for (const key of Object.keys(stop)) {
|
|
281
|
+
if (!['offset', 'color', 'opacity'].includes(key)) {
|
|
282
|
+
this.#add('TPL1', [...stopPath, key], `色标没有字段 ${key}。`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const offset = stop.offset;
|
|
286
|
+
if (typeof offset !== 'number' || offset < 0 || offset > 1) {
|
|
287
|
+
this.#add('TPL4', [...stopPath, 'offset'], 'offset 是 0–1 的数字。');
|
|
288
|
+
}
|
|
289
|
+
const opacity = stop.opacity ?? 1;
|
|
290
|
+
if (typeof opacity !== 'number' || opacity < 0 || opacity > 1) {
|
|
291
|
+
this.#add('TPL4', [...stopPath, 'opacity'], 'opacity 是 0–1 的数字。');
|
|
292
|
+
}
|
|
293
|
+
const color = this.#paint(stop.color, [...stopPath, 'color'], this.#rootScope(), false);
|
|
294
|
+
if (color !== undefined && typeof offset === 'number' && typeof opacity === 'number') {
|
|
295
|
+
stops.push({ offset, color, opacity });
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
output.push({ kind: item.kind, id, geometry, stops });
|
|
300
|
+
});
|
|
301
|
+
return output;
|
|
302
|
+
}
|
|
303
|
+
#rootScope() {
|
|
304
|
+
return {
|
|
305
|
+
props: this.#props,
|
|
306
|
+
style: this.#style,
|
|
307
|
+
roles: this.#roles,
|
|
308
|
+
data: this.context.data.kind,
|
|
309
|
+
inRepeat: false,
|
|
310
|
+
inRowRepeat: false,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
#nodeList(input, path, scope) {
|
|
314
|
+
const output = [];
|
|
315
|
+
input.forEach((item, index) => {
|
|
316
|
+
const node = this.#node(item, [...path, index], scope);
|
|
317
|
+
if (node !== undefined)
|
|
318
|
+
output.push(node);
|
|
319
|
+
});
|
|
320
|
+
return output;
|
|
321
|
+
}
|
|
322
|
+
#node(input, path, scope) {
|
|
323
|
+
this.#nodeCount += 1;
|
|
324
|
+
if (this.#nodeCount === BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.nodes + 1) {
|
|
325
|
+
this.#add('TPL3', path, `模板节点最多 ${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.nodes} 个。`);
|
|
326
|
+
}
|
|
327
|
+
if (!isRecord(input)) {
|
|
328
|
+
this.#add('TPL4', path, '节点必须是对象。');
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
const kind = input.kind;
|
|
332
|
+
if (typeof kind !== 'string' ||
|
|
333
|
+
!BASE_SCREEN_MATERIAL_TEMPLATE_NODE_KINDS.includes(kind)) {
|
|
334
|
+
this.#add('TPL1', [...path, 'kind'], `不支持的节点 ${String(kind)}(可用:${BASE_SCREEN_MATERIAL_TEMPLATE_NODE_KINDS.join('、')};不支持 foreignObject、image、use、script、style、filter)。`);
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
const nodeKind = kind;
|
|
338
|
+
const id = input.id;
|
|
339
|
+
if (typeof id !== 'string' || !ID_PATTERN.test(id)) {
|
|
340
|
+
this.#add('TPL4', [...path, 'id'], '每个节点都要有 id:小写字母开头的字母、数字、连字符(≤ 40)。');
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
343
|
+
if (this.#ids.has(id))
|
|
344
|
+
this.#add('TPL4', [...path, 'id'], `节点 id ${id} 重复。`);
|
|
345
|
+
this.#ids.add(id);
|
|
346
|
+
const allowed = new Set([
|
|
347
|
+
'kind',
|
|
348
|
+
'id',
|
|
349
|
+
...BASE_SCREEN_MATERIAL_TEMPLATE_NUMBER_ATTRS[nodeKind],
|
|
350
|
+
...EXTRA_KEYS[nodeKind],
|
|
351
|
+
...(SHAPE_KINDS.has(nodeKind) ? SHAPE_KEYS : []),
|
|
352
|
+
]);
|
|
353
|
+
for (const key of Object.keys(input)) {
|
|
354
|
+
if (!allowed.has(key)) {
|
|
355
|
+
const hint = /^on[A-Z]|^href$|^xlink|^style$|^class$|^filter$/.test(key)
|
|
356
|
+
? '(不支持事件属性、外部引用、样式字符串与滤镜)'
|
|
357
|
+
: '';
|
|
358
|
+
this.#add('TPL1', [...path, key], `${nodeKind} 没有字段 ${key}${hint}。`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const num = {};
|
|
362
|
+
for (const key of BASE_SCREEN_MATERIAL_TEMPLATE_NUMBER_ATTRS[nodeKind]) {
|
|
363
|
+
if (input[key] === undefined)
|
|
364
|
+
continue;
|
|
365
|
+
const expression = this.#number(input[key], [...path, key], scope);
|
|
366
|
+
if (expression !== undefined)
|
|
367
|
+
num[key] = expression;
|
|
368
|
+
}
|
|
369
|
+
for (const key of REQUIRED_NUMBER_ATTRS[nodeKind] ?? []) {
|
|
370
|
+
if (input[key] === undefined)
|
|
371
|
+
this.#add('TPL4', [...path, key], `${nodeKind} 缺少 ${key}。`);
|
|
372
|
+
}
|
|
373
|
+
const node = { kind: nodeKind, id, path, num };
|
|
374
|
+
if (SHAPE_KINDS.has(nodeKind))
|
|
375
|
+
this.#shapeAttributes(input, nodeKind, path, scope, node, num);
|
|
376
|
+
if (nodeKind === 'g' && input.opacity !== undefined) {
|
|
377
|
+
const opacity = this.#number(input.opacity, [...path, 'opacity'], scope);
|
|
378
|
+
if (opacity !== undefined)
|
|
379
|
+
num.opacity = opacity;
|
|
380
|
+
}
|
|
381
|
+
switch (nodeKind) {
|
|
382
|
+
case 'text':
|
|
383
|
+
this.#text(input, path, scope, node, num);
|
|
384
|
+
break;
|
|
385
|
+
case 'repeat': {
|
|
386
|
+
const source = this.#source(input.source, [...path, 'source'], scope);
|
|
387
|
+
if (source !== undefined)
|
|
388
|
+
node.source = source;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
case 'when': {
|
|
392
|
+
const test = this.#expression(input.test, [...path, 'test'], scope);
|
|
393
|
+
if (test !== undefined)
|
|
394
|
+
node.test = test;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
case 'clip': {
|
|
398
|
+
const shape = input.shape;
|
|
399
|
+
if (!isRecord(shape) ||
|
|
400
|
+
typeof shape.kind !== 'string' ||
|
|
401
|
+
!CLIP_SHAPE_KINDS.has(shape.kind)) {
|
|
402
|
+
this.#add('TPL4', [...path, 'shape'], 'clip.shape 必须是一个 rect / circle / ellipse / path 节点。');
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
const compiled = this.#node(shape, [...path, 'shape'], scope);
|
|
406
|
+
if (compiled !== undefined)
|
|
407
|
+
node.clipShape = compiled;
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
case 'polyline':
|
|
412
|
+
this.#polyline(input, path, scope, node);
|
|
413
|
+
break;
|
|
414
|
+
case 'path':
|
|
415
|
+
this.#path(input.d, [...path, 'd'], scope, node);
|
|
416
|
+
break;
|
|
417
|
+
case 'arc':
|
|
418
|
+
if (input.linecap !== undefined) {
|
|
419
|
+
if (typeof input.linecap !== 'string' || !LINECAPS.has(input.linecap)) {
|
|
420
|
+
this.#add('TPL4', [...path, 'linecap'], 'linecap 只能是 butt / round / square。');
|
|
421
|
+
}
|
|
422
|
+
else
|
|
423
|
+
node.linecap = input.linecap;
|
|
424
|
+
}
|
|
425
|
+
break;
|
|
426
|
+
default:
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
if (CONTAINER_KINDS.has(nodeKind)) {
|
|
430
|
+
const childScope = nodeKind === 'repeat'
|
|
431
|
+
? {
|
|
432
|
+
...scope,
|
|
433
|
+
inRepeat: true,
|
|
434
|
+
inRowRepeat: scope.inRowRepeat || node.source?.k === 'rows',
|
|
435
|
+
}
|
|
436
|
+
: scope;
|
|
437
|
+
if (!Array.isArray(input.children)) {
|
|
438
|
+
this.#add('TPL4', [...path, 'children'], `${nodeKind} 需要 children 数组。`);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
node.children = this.#nodeList(input.children, [...path, 'children'], childScope);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const compiled = node;
|
|
445
|
+
this.#index.set(id, compiled);
|
|
446
|
+
return compiled;
|
|
447
|
+
}
|
|
448
|
+
#shapeAttributes(input, kind, path, scope, node, num) {
|
|
449
|
+
if (input.fill !== undefined) {
|
|
450
|
+
const fill = this.#paint(input.fill, [...path, 'fill'], scope, true);
|
|
451
|
+
if (fill !== undefined)
|
|
452
|
+
node.fill = fill;
|
|
453
|
+
}
|
|
454
|
+
if (input.stroke !== undefined) {
|
|
455
|
+
const stroke = this.#paint(input.stroke, [...path, 'stroke'], scope, true);
|
|
456
|
+
if (stroke !== undefined)
|
|
457
|
+
node.stroke = stroke;
|
|
458
|
+
}
|
|
459
|
+
for (const key of ['strokeWidth', 'opacity']) {
|
|
460
|
+
if (input[key] === undefined)
|
|
461
|
+
continue;
|
|
462
|
+
const value = this.#number(input[key], [...path, key], scope);
|
|
463
|
+
if (value !== undefined)
|
|
464
|
+
num[key] = value;
|
|
465
|
+
}
|
|
466
|
+
if (input.strokeDasharray !== undefined) {
|
|
467
|
+
const dash = input.strokeDasharray;
|
|
468
|
+
if (!Array.isArray(dash) ||
|
|
469
|
+
dash.length === 0 ||
|
|
470
|
+
dash.length > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.dash) {
|
|
471
|
+
this.#add('TPL4', [...path, 'strokeDasharray'], `strokeDasharray 是 1–${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.dash} 个数字。`);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
const items = dash
|
|
475
|
+
.map((item, at) => this.#number(item, [...path, 'strokeDasharray', at], scope))
|
|
476
|
+
.filter((item) => item !== undefined);
|
|
477
|
+
node.dash = items;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (input.strokeLinecap !== undefined) {
|
|
481
|
+
if (typeof input.strokeLinecap !== 'string' || !LINECAPS.has(input.strokeLinecap)) {
|
|
482
|
+
this.#add('TPL4', [...path, 'strokeLinecap'], 'strokeLinecap 只能是 butt / round / square。');
|
|
483
|
+
}
|
|
484
|
+
else
|
|
485
|
+
node.linecap = input.strokeLinecap;
|
|
486
|
+
}
|
|
487
|
+
if (input.on !== undefined) {
|
|
488
|
+
const name = input.on;
|
|
489
|
+
const event = typeof name === 'string' ? this.#events.get(name) : undefined;
|
|
490
|
+
if (event === undefined) {
|
|
491
|
+
this.#add('TPL2', [...path, 'on'], `on 必须是规格 events 里声明的事件名(当前:${[...this.#events.keys()].join('、') || '无'})。`);
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
const payload = [];
|
|
495
|
+
for (const [key, item] of Object.entries(event.payload ?? {})) {
|
|
496
|
+
const expression = this.#expression(item.value, [...path, 'on', key], scope);
|
|
497
|
+
if (expression !== undefined)
|
|
498
|
+
payload.push({ key, type: item.type, value: expression });
|
|
499
|
+
}
|
|
500
|
+
node.on = { name: event.name, payload };
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
void kind;
|
|
504
|
+
}
|
|
505
|
+
#text(input, path, scope, node, num) {
|
|
506
|
+
const content = this.#expression(input.content, [...path, 'content'], scope, '文字内容是表达式:字面文字要加引号,如 "\'℃\'";读数用 format(value)。');
|
|
507
|
+
if (content !== undefined)
|
|
508
|
+
node.content = content;
|
|
509
|
+
const fontSize = num.fontSize;
|
|
510
|
+
if (fontSize !== undefined && !this.#isStaticNumber(fontSize)) {
|
|
511
|
+
this.#add('TPL5', [...path, 'fontSize'], '字号只能是数字,或 props / style 数字字段的四则运算(不能随数据变化),体检才能检查最小字号。');
|
|
512
|
+
}
|
|
513
|
+
if (input.fontWeight !== undefined) {
|
|
514
|
+
if (typeof input.fontWeight !== 'number' || !FONT_WEIGHTS.has(input.fontWeight)) {
|
|
515
|
+
this.#add('TPL4', [...path, 'fontWeight'], 'fontWeight 只能是 400 / 500 / 600 / 700。');
|
|
516
|
+
}
|
|
517
|
+
else
|
|
518
|
+
node.fontWeight = input.fontWeight;
|
|
519
|
+
}
|
|
520
|
+
for (const [key, values] of [
|
|
521
|
+
['anchor', ANCHORS],
|
|
522
|
+
['baseline', BASELINES],
|
|
523
|
+
]) {
|
|
524
|
+
const value = input[key];
|
|
525
|
+
if (value === undefined)
|
|
526
|
+
continue;
|
|
527
|
+
if (typeof value !== 'string' || !values.has(value)) {
|
|
528
|
+
this.#add('TPL4', [...path, key], `${key} 只能是 ${[...values].join(' / ')}。`);
|
|
529
|
+
}
|
|
530
|
+
else
|
|
531
|
+
node[key] = value;
|
|
532
|
+
}
|
|
533
|
+
const backdrop = input.backdrop;
|
|
534
|
+
if (typeof backdrop !== 'string' || backdrop === '') {
|
|
535
|
+
this.#add('TPL6', [...path, 'backdrop'], '文字必须声明底板 backdrop:某个填充节点的 id,或 container(组件背景)。');
|
|
536
|
+
}
|
|
537
|
+
else
|
|
538
|
+
node.backdrop = backdrop;
|
|
539
|
+
}
|
|
540
|
+
#checkBackdrops() {
|
|
541
|
+
for (const node of this.#index.values()) {
|
|
542
|
+
if (node.kind !== 'text' || node.backdrop === undefined || node.backdrop === 'container')
|
|
543
|
+
continue;
|
|
544
|
+
const target = this.#index.get(node.backdrop);
|
|
545
|
+
if (target === undefined || !FILLABLE_KINDS.has(target.kind) || target.fill === undefined) {
|
|
546
|
+
this.#add('TPL6', [...node.path, 'backdrop'], `backdrop「${node.backdrop}」必须是带 fill 的填充节点,或 container。`);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
#polyline(input, path, scope, node) {
|
|
551
|
+
const points = input.points;
|
|
552
|
+
if (!isRecord(points)) {
|
|
553
|
+
this.#add('TPL4', [...path, 'points'], 'polyline.points 是 { source, x, y }:对每行(或每个序号)求一个点。');
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
for (const key of Object.keys(points)) {
|
|
557
|
+
if (!['source', 'x', 'y'].includes(key))
|
|
558
|
+
this.#add('TPL1', [...path, 'points', key], `points 没有字段 ${key}。`);
|
|
559
|
+
}
|
|
560
|
+
const source = this.#source(points.source, [...path, 'points', 'source'], scope);
|
|
561
|
+
if (source === undefined)
|
|
562
|
+
return;
|
|
563
|
+
const inner = {
|
|
564
|
+
...scope,
|
|
565
|
+
inRepeat: true,
|
|
566
|
+
inRowRepeat: scope.inRowRepeat || source.k === 'rows',
|
|
567
|
+
};
|
|
568
|
+
const x = this.#number(points.x, [...path, 'points', 'x'], inner);
|
|
569
|
+
const y = this.#number(points.y, [...path, 'points', 'y'], inner);
|
|
570
|
+
if (x !== undefined && y !== undefined)
|
|
571
|
+
node.points = { source, x, y };
|
|
572
|
+
if (input.closed !== undefined) {
|
|
573
|
+
if (typeof input.closed !== 'boolean')
|
|
574
|
+
this.#add('TPL4', [...path, 'closed'], 'closed 必须是布尔值。');
|
|
575
|
+
else
|
|
576
|
+
node.closed = input.closed;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
#path(input, path, scope, node) {
|
|
580
|
+
if (!Array.isArray(input) ||
|
|
581
|
+
input.length === 0 ||
|
|
582
|
+
input.length > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.pathCommands) {
|
|
583
|
+
this.#add('TPL4', path, `path.d 是 1–${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.pathCommands} 条命令,每条形如 ["L", x, y]。`);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const commands = [];
|
|
587
|
+
input.forEach((item, index) => {
|
|
588
|
+
const itemPath = [...path, index];
|
|
589
|
+
if (!Array.isArray(item) ||
|
|
590
|
+
typeof item[0] !== 'string' ||
|
|
591
|
+
PATH_COMMANDS[item[0]] === undefined) {
|
|
592
|
+
this.#add('TPL4', itemPath, '路径命令只能是 M / L / H / V / C / Q / A / Z(绝对坐标)。');
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const command = item[0];
|
|
596
|
+
const arity = PATH_COMMANDS[command];
|
|
597
|
+
if (item.length - 1 !== arity) {
|
|
598
|
+
this.#add('TPL4', itemPath, `${command} 需要 ${arity} 个参数。`);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
const args = item
|
|
602
|
+
.slice(1)
|
|
603
|
+
.map((arg, at) => this.#number(arg, [...itemPath, at + 1], scope))
|
|
604
|
+
.filter((arg) => arg !== undefined);
|
|
605
|
+
if (args.length === arity)
|
|
606
|
+
commands.push([command, args]);
|
|
607
|
+
});
|
|
608
|
+
node.d = commands;
|
|
609
|
+
}
|
|
610
|
+
#source(input, path, scope) {
|
|
611
|
+
if (input === 'rows') {
|
|
612
|
+
if (this.context.data.kind !== 'rows') {
|
|
613
|
+
this.#add('TPL2', path, '组件不是多行数据,不能遍历 rows。');
|
|
614
|
+
return undefined;
|
|
615
|
+
}
|
|
616
|
+
return { k: 'rows' };
|
|
617
|
+
}
|
|
618
|
+
if (isRecord(input) && Object.keys(input).length === 1 && input.range !== undefined) {
|
|
619
|
+
if (typeof input.range === 'number' &&
|
|
620
|
+
input.range > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.repeat) {
|
|
621
|
+
this.#add('TPL3', [...path, 'range'], `repeat 最多 ${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.repeat} 次。`);
|
|
622
|
+
return undefined;
|
|
623
|
+
}
|
|
624
|
+
const n = this.#number(input.range, [...path, 'range'], scope);
|
|
625
|
+
return n === undefined ? undefined : { k: 'range', n };
|
|
626
|
+
}
|
|
627
|
+
this.#add('TPL4', path, 'source 只能是 "rows" 或 { "range": 次数 }。');
|
|
628
|
+
return undefined;
|
|
629
|
+
}
|
|
630
|
+
#animations(input, scope) {
|
|
631
|
+
if (input === undefined)
|
|
632
|
+
return [];
|
|
633
|
+
if (!Array.isArray(input)) {
|
|
634
|
+
this.#add('TPL4', ['animations'], 'animations 必须是数组。');
|
|
635
|
+
return [];
|
|
636
|
+
}
|
|
637
|
+
if (input.length > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.animations) {
|
|
638
|
+
this.#add('TPL3', ['animations'], `动画最多 ${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.animations} 个。`);
|
|
639
|
+
}
|
|
640
|
+
const output = [];
|
|
641
|
+
input.forEach((item, index) => {
|
|
642
|
+
const path = ['animations', index];
|
|
643
|
+
if (!isRecord(item) || (item.kind !== 'loop' && item.kind !== 'change')) {
|
|
644
|
+
this.#add('TPL1', path, '动画只有 loop(循环)与 change(读数变化过渡)两种。');
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
const keys = item.kind === 'loop'
|
|
648
|
+
? [
|
|
649
|
+
'kind',
|
|
650
|
+
'target',
|
|
651
|
+
'property',
|
|
652
|
+
'from',
|
|
653
|
+
'to',
|
|
654
|
+
'duration',
|
|
655
|
+
'easing',
|
|
656
|
+
'alternate',
|
|
657
|
+
'enabledBy',
|
|
658
|
+
]
|
|
659
|
+
: ['kind', 'target', 'attributes', 'duration', 'easing'];
|
|
660
|
+
for (const key of Object.keys(item)) {
|
|
661
|
+
if (!keys.includes(key))
|
|
662
|
+
this.#add('TPL1', [...path, key], `${item.kind} 动画没有字段 ${key}。`);
|
|
663
|
+
}
|
|
664
|
+
const target = typeof item.target === 'string' ? this.#index.get(item.target) : undefined;
|
|
665
|
+
if (target === undefined) {
|
|
666
|
+
this.#add('TPL4', [...path, 'target'], 'target 必须是模板里某个节点的 id。');
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const duration = item.duration;
|
|
670
|
+
if (typeof duration !== 'number' ||
|
|
671
|
+
duration < BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.minDuration ||
|
|
672
|
+
duration > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.maxDuration) {
|
|
673
|
+
this.#add('TPL4', [...path, 'duration'], `duration 是 ${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.minDuration}–${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.maxDuration} 毫秒。`);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const easing = item.easing ?? (item.kind === 'loop' ? 'linear' : 'ease-out');
|
|
677
|
+
if (typeof easing !== 'string' || !EASINGS.has(easing)) {
|
|
678
|
+
this.#add('TPL4', [...path, 'easing'], `easing 只能是 ${[...EASINGS].join(' / ')}。`);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (item.kind === 'loop') {
|
|
682
|
+
if (typeof item.property !== 'string' || !LOOP_PROPERTIES.has(item.property)) {
|
|
683
|
+
this.#add('TPL4', [...path, 'property'], `循环动画只能改 ${[...LOOP_PROPERTIES].join(' / ')}(只动组件内部,不动外框)。`);
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const from = this.#number(item.from, [...path, 'from'], scope);
|
|
687
|
+
const to = this.#number(item.to, [...path, 'to'], scope);
|
|
688
|
+
if (item.alternate !== undefined && typeof item.alternate !== 'boolean') {
|
|
689
|
+
this.#add('TPL4', [...path, 'alternate'], 'alternate 必须是布尔值。');
|
|
690
|
+
}
|
|
691
|
+
const enabledBy = item.enabledBy === undefined
|
|
692
|
+
? undefined
|
|
693
|
+
: this.#expression(item.enabledBy, [...path, 'enabledBy'], scope);
|
|
694
|
+
if (from === undefined || to === undefined)
|
|
695
|
+
return;
|
|
696
|
+
output.push({
|
|
697
|
+
kind: 'loop',
|
|
698
|
+
target: target.id,
|
|
699
|
+
property: item.property,
|
|
700
|
+
from,
|
|
701
|
+
to,
|
|
702
|
+
duration,
|
|
703
|
+
easing,
|
|
704
|
+
alternate: item.alternate === true,
|
|
705
|
+
...(enabledBy === undefined ? {} : { enabledBy }),
|
|
706
|
+
});
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const numeric = BASE_SCREEN_MATERIAL_TEMPLATE_NUMBER_ATTRS[target.kind];
|
|
710
|
+
if (!Array.isArray(item.attributes) ||
|
|
711
|
+
item.attributes.length === 0 ||
|
|
712
|
+
item.attributes.some((attr) => typeof attr !== 'string' || !numeric.includes(attr))) {
|
|
713
|
+
this.#add('TPL4', [...path, 'attributes'], `${target.kind} 能补间的参数:${numeric.join('、') || '无'}。`);
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
output.push({
|
|
717
|
+
kind: 'change',
|
|
718
|
+
target: target.id,
|
|
719
|
+
attributes: item.attributes,
|
|
720
|
+
duration,
|
|
721
|
+
easing,
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
return output;
|
|
725
|
+
}
|
|
726
|
+
#expression(input, path, scope, hint) {
|
|
727
|
+
if (typeof input === 'boolean')
|
|
728
|
+
return { k: 'lit', v: input };
|
|
729
|
+
if (typeof input === 'number' && Number.isFinite(input))
|
|
730
|
+
return { k: 'lit', v: input };
|
|
731
|
+
if (typeof input !== 'string') {
|
|
732
|
+
this.#add('TPL4', path, `需要一个表达式字符串${hint === undefined ? '' : `:${hint}`}`);
|
|
733
|
+
return undefined;
|
|
734
|
+
}
|
|
735
|
+
const parsed = parseBaseScreenMaterialTemplateExpression(input, scope);
|
|
736
|
+
if (!parsed.ok) {
|
|
737
|
+
this.#add('TPL2', path, `${parsed.message}${hint === undefined ? '' : ` ${hint}`}`);
|
|
738
|
+
return undefined;
|
|
739
|
+
}
|
|
740
|
+
return parsed.value;
|
|
741
|
+
}
|
|
742
|
+
#number(input, path, scope) {
|
|
743
|
+
if (typeof input === 'number') {
|
|
744
|
+
if (!Number.isFinite(input)) {
|
|
745
|
+
this.#add('TPL4', path, '数值必须是有限数字。');
|
|
746
|
+
return undefined;
|
|
747
|
+
}
|
|
748
|
+
return { k: 'lit', v: input };
|
|
749
|
+
}
|
|
750
|
+
if (typeof input === 'string')
|
|
751
|
+
return this.#expression(input, path, scope);
|
|
752
|
+
this.#add('TPL4', path, '数值参数写数字或表达式字符串。');
|
|
753
|
+
return undefined;
|
|
754
|
+
}
|
|
755
|
+
#paint(input, path, scope, allowGradient) {
|
|
756
|
+
if (isRecord(input) && Object.keys(input).length === 1 && typeof input.gradient === 'string') {
|
|
757
|
+
if (!allowGradient || !this.#gradientIds.has(input.gradient)) {
|
|
758
|
+
this.#add('TPL4', path, `渐变「${input.gradient}」没有在 defs 里声明。`);
|
|
759
|
+
return undefined;
|
|
760
|
+
}
|
|
761
|
+
return { k: 'gradient', id: input.gradient };
|
|
762
|
+
}
|
|
763
|
+
if (typeof input !== 'string') {
|
|
764
|
+
this.#add('TPL5', path, '颜色写字面量(#rrggbb、rgba(...)、none)、style.<颜色字段>,或 { "gradient": "渐变 id" }。');
|
|
765
|
+
return undefined;
|
|
766
|
+
}
|
|
767
|
+
if (BASE_SCREEN_MATERIAL_TEMPLATE_COLOR.test(input.trim()))
|
|
768
|
+
return { k: 'color', v: input.trim() };
|
|
769
|
+
if (/url\s*\(/i.test(input)) {
|
|
770
|
+
this.#add('TPL1', path, '颜色里不能写 url(...):渐变用 { "gradient": "id" } 引用。');
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
const expression = this.#expression(input, path, scope);
|
|
774
|
+
if (expression === undefined)
|
|
775
|
+
return undefined;
|
|
776
|
+
if (!this.#isAuditablePaint(expression)) {
|
|
777
|
+
this.#add('TPL5', path, '颜色表达式只能在字面量颜色与 style.<颜色字段> 之间选择(pick / 三元),不能由数据算出颜色;语义色请声明成样式字段,值可写 theme:danger。');
|
|
778
|
+
return undefined;
|
|
779
|
+
}
|
|
780
|
+
return { k: 'expr', e: expression };
|
|
781
|
+
}
|
|
782
|
+
/** 颜色表达式能否静态枚举出全部候选(字面量颜色或颜色样式字段)。 */
|
|
783
|
+
#isAuditablePaint(expression) {
|
|
784
|
+
switch (expression.k) {
|
|
785
|
+
case 'lit':
|
|
786
|
+
return (typeof expression.v === 'string' && BASE_SCREEN_MATERIAL_TEMPLATE_COLOR.test(expression.v));
|
|
787
|
+
case 'ref':
|
|
788
|
+
return (expression.root === 'style' &&
|
|
789
|
+
expression.key !== undefined &&
|
|
790
|
+
this.#colorKeys.has(expression.key));
|
|
791
|
+
case 'cond':
|
|
792
|
+
return this.#isAuditablePaint(expression.a) && this.#isAuditablePaint(expression.b);
|
|
793
|
+
case 'call':
|
|
794
|
+
if (expression.fn !== 'pick')
|
|
795
|
+
return false;
|
|
796
|
+
return expression.args.every((arg, index) => index === 0 ||
|
|
797
|
+
(index % 2 === 1 && index !== expression.args.length - 1) ||
|
|
798
|
+
this.#isAuditablePaint(arg));
|
|
799
|
+
default:
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
/** 字号:字面量或 props / style 数字字段的运算,不随数据变化。 */
|
|
804
|
+
#isStaticNumber(expression) {
|
|
805
|
+
switch (expression.k) {
|
|
806
|
+
case 'lit':
|
|
807
|
+
return typeof expression.v === 'number';
|
|
808
|
+
case 'ref':
|
|
809
|
+
return ((expression.root === 'props' || expression.root === 'style') &&
|
|
810
|
+
expression.key !== undefined &&
|
|
811
|
+
this.#numberKeys.has(expression.key));
|
|
812
|
+
case 'un':
|
|
813
|
+
return expression.op === '-' && this.#isStaticNumber(expression.a);
|
|
814
|
+
case 'bin':
|
|
815
|
+
return (['+', '-', '*', '/'].includes(expression.op) &&
|
|
816
|
+
this.#isStaticNumber(expression.a) &&
|
|
817
|
+
this.#isStaticNumber(expression.b));
|
|
818
|
+
case 'call':
|
|
819
|
+
return (['min', 'max', 'clamp', 'round'].includes(expression.fn) &&
|
|
820
|
+
expression.args.every((arg) => this.#isStaticNumber(arg)));
|
|
821
|
+
default:
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
function isRecord(value) {
|
|
827
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
828
|
+
}
|
|
829
|
+
/** 规格事件的形状校验(ADR-0116 §2.6),路径相对规格根。 */
|
|
830
|
+
export function parseBaseScreenMaterialSpecEvents(input, add) {
|
|
831
|
+
if (input === undefined)
|
|
832
|
+
return;
|
|
833
|
+
if (!Array.isArray(input) || input.length > BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.events) {
|
|
834
|
+
add(['events'], `events 是最多 ${BASE_SCREEN_MATERIAL_TEMPLATE_LIMITS.events} 个事件的数组。`);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const names = new Set();
|
|
838
|
+
input.forEach((event, index) => {
|
|
839
|
+
const path = ['events', index];
|
|
840
|
+
if (!isRecord(event)) {
|
|
841
|
+
add(path, '事件必须是对象。');
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
for (const key of Object.keys(event)) {
|
|
845
|
+
if (!['name', 'label', 'payload'].includes(key))
|
|
846
|
+
add([...path, key], `未知字段 ${key}。`);
|
|
847
|
+
}
|
|
848
|
+
if (typeof event.name !== 'string' || !EVENT_PATTERN.test(event.name)) {
|
|
849
|
+
add([...path, 'name'], '事件名为小驼峰 ASCII(如 valueClick)。');
|
|
850
|
+
}
|
|
851
|
+
else if (names.has(event.name)) {
|
|
852
|
+
add([...path, 'name'], `事件 ${event.name} 重复。`);
|
|
853
|
+
}
|
|
854
|
+
else
|
|
855
|
+
names.add(event.name);
|
|
856
|
+
if (typeof event.label !== 'string' ||
|
|
857
|
+
event.label.trim() === '' ||
|
|
858
|
+
[...event.label].length > 16) {
|
|
859
|
+
add([...path, 'label'], '事件标签为 1–16 个字符。');
|
|
860
|
+
}
|
|
861
|
+
if (event.payload !== undefined) {
|
|
862
|
+
if (!isRecord(event.payload) || Object.keys(event.payload).length > 6) {
|
|
863
|
+
add([...path, 'payload'], 'payload 是最多 6 项的对象:{ 键: { type, value } }。');
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
for (const [key, item] of Object.entries(event.payload)) {
|
|
867
|
+
if (!PAYLOAD_KEY_PATTERN.test(key))
|
|
868
|
+
add([...path, 'payload', key], '负载键为小驼峰 ASCII。');
|
|
869
|
+
if (!isRecord(item) ||
|
|
870
|
+
(item.type !== 'number' && item.type !== 'string' && item.type !== 'boolean') ||
|
|
871
|
+
typeof item.value !== 'string' ||
|
|
872
|
+
Object.keys(item).some((name) => name !== 'type' && name !== 'value')) {
|
|
873
|
+
add([...path, 'payload', key], '负载项写 { "type": "number" | "string" | "boolean", "value": "表达式" }。');
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
//# sourceMappingURL=material-template.js.map
|