soma-core 2.0.0 → 2.1.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 +28 -19
- package/bin/codegen.cjs +191 -0
- package/bin/eject.cjs +25 -12
- package/bin/service-codegen.cjs +98 -0
- package/bin/soma-lsp.cjs +140 -23
- package/bin/soma-runtime.cjs +75 -0
- package/bin/soma-sync-runtime.cjs +130 -0
- package/bin/soma.cjs +200 -13
- package/bin/soma.ts +170 -0
- package/core/build/compiler/flat-page.ts +305 -0
- package/core/build/compiler/full-manifest-builder.ts +68 -27
- package/core/build/compiler/html-index.ts +169 -0
- package/core/build/compiler/page-assets.ts +30 -7
- package/core/build/compiler/page-base-resolver.ts +11 -0
- package/core/build/compiler/page-declaration-compiler.ts +264 -226
- package/core/build/compiler/rollup-plugin-soma.ts +7 -2
- package/core/build/compiler/soma-manifest-webpack-plugin.js +114 -229
- package/core/build/compiler/soma-precompile.js +3733 -1892
- package/core/build/compiler/soma-precompile.ts +15 -20
- package/core/build/compiler/soma-rspack-yaml-loader.js +4 -3
- package/core/build/compiler/soma-webpack-loader.js +8 -4
- package/core/build/compiler/vite-plugin-soma.ts +8 -8
- package/core/build/component/component-graph.ts +1 -1
- package/core/build/component-tree/artifact-codec.ts +9 -42
- package/core/build/component-tree/collection-binding-lowerer.ts +1 -1
- package/core/build/component-tree/definition-preparation.ts +4 -5
- package/core/build/component-tree/parser.ts +1 -1
- package/core/build/component-tree/registry-snapshot.ts +45 -10
- package/core/build/component-tree/source-preflight.ts +2 -90
- package/core/build/component-tree/structure-topology.ts +1 -1
- package/core/build/eject/plan-eject.ts +9 -11
- package/core/build/lsp/component-tree-service.ts +4 -1
- package/core/build/lsp/component-tree.cjs +1 -1
- package/core/build/lsp/cross-file-diagnostics.cjs +5 -21
- package/core/build/lsp/soma-declaration.cjs +45 -47
- package/core/build/lsp/std-completion.generated.json +26 -0
- package/core/build/lsp/ui-yaml-completion.cjs +25 -37
- package/core/client/a11y/a11y-config.ts +50 -0
- package/core/client/a11y/announcer.ts +140 -0
- package/core/client/a11y/dom-id.ts +31 -0
- package/core/client/a11y/index.ts +40 -0
- package/core/client/a11y/motion-hook.ts +48 -0
- package/core/client/a11y/motion.ts +95 -0
- package/core/client/base/SomaPageRootBase.ts +44 -2
- package/core/client/base/index.ts +10 -8
- package/core/client/behavior/adapter-collection.ts +65 -0
- package/core/client/behavior/adapter-popper.ts +60 -0
- package/core/client/behavior/aria-hide-outside.ts +144 -0
- package/core/client/behavior/css-escape.ts +51 -0
- package/core/client/behavior/focus-scope.ts +433 -0
- package/core/client/behavior/focus-traversal.ts +68 -0
- package/core/client/behavior/index.ts +109 -0
- package/core/client/behavior/layer-stack.ts +234 -0
- package/core/client/behavior/overlay-host/index.ts +192 -0
- package/core/client/behavior/overlay-host/port.ts +76 -0
- package/core/client/behavior/overlay-wiring.ts +186 -0
- package/core/client/behavior/port.ts +85 -0
- package/core/client/behavior/positioner.ts +32 -0
- package/core/client/behavior/presence.ts +197 -0
- package/core/client/behavior/zag/adapter-vanilla.ts +96 -0
- package/core/client/behavior/zag/layer-bridge.ts +51 -0
- package/core/client/behavior/zag/machine-host.ts +69 -0
- package/core/client/behavior/zag/machines.ts +52 -0
- package/core/client/compiler/manifest-compiler.ts +33 -70
- package/core/client/component/adapter/adapt.ts +79 -0
- package/core/client/component/adapter/index.ts +3 -0
- package/core/client/component/adapter/types.ts +37 -0
- package/core/client/component/adapter/web-component.ts +130 -0
- package/core/client/component/component-defaults.ts +1 -1
- package/core/client/component/component-definition.types.ts +27 -5
- package/core/client/component/component-expander.ts +24 -16
- package/core/client/component/component-manager.ts +245 -814
- package/core/client/component/component-pack.ts +58 -216
- package/core/client/component/component-registry.ts +53 -29
- package/core/client/component/projection-admission.ts +63 -0
- package/core/client/component/projection-registry.ts +653 -0
- package/core/client/component/projection.types.ts +48 -0
- package/core/client/component/region-unavailable.ts +37 -0
- package/core/client/component/scoped-adapter.ts +3 -3
- package/core/client/component/structure-adapter.ts +93 -8
- package/core/client/container/IContainerAdapter.ts +4 -3
- package/core/client/container/SomaContainerAdapter.ts +22 -123
- package/core/client/data/collection-payload.ts +2 -0
- package/core/client/data/data-object-resolver.ts +827 -330
- package/core/client/data/data-polling.ts +110 -0
- package/core/client/data/data-subscriptions.ts +98 -0
- package/core/client/data/data-write-actions.ts +118 -0
- package/core/client/data/envelope-failure.ts +48 -0
- package/core/client/data/format-config.ts +62 -0
- package/core/client/data/region-scope-port.ts +265 -0
- package/core/client/data/region-scope-views.ts +96 -0
- package/core/client/data/role-gate.ts +44 -0
- package/core/client/data/write-outcome-store.ts +101 -0
- package/core/client/data/write-outcome.ts +175 -0
- package/core/client/engine/asset-resolver.ts +12 -21
- package/core/client/engine/dom-renderer.ts +85 -460
- package/core/client/engine/event-engine.ts +349 -323
- package/core/client/engine/locale-text-binder.ts +168 -0
- package/core/client/engine/property-watcher.ts +18 -164
- package/core/client/engine/reactive-proxy.ts +23 -194
- package/core/client/engine/render-engine.ts +16 -118
- package/core/client/engine/row-range.ts +11 -0
- package/core/client/engine/runtime-builder.ts +10 -13
- package/core/client/engine/scope-resolver.ts +3 -3
- package/core/client/engine/soma-bootstrap.ts +1238 -323
- package/core/client/engine/step-runner.ts +90 -12
- package/core/client/engine/style-binder.ts +2 -162
- package/core/client/engine/timer-engine.ts +2 -1
- package/core/client/engines/chart/adapter-echarts.ts +144 -0
- package/core/client/engines/chart/echarts-subpaths.d.ts +3 -0
- package/core/client/engines/chart/index.ts +90 -0
- package/core/client/engines/chart/kind-modules.ts +74 -0
- package/core/client/engines/chart/port.ts +44 -0
- package/core/client/engines/diff/adapter-jsdiff.ts +35 -0
- package/core/client/engines/diff/index.ts +33 -0
- package/core/client/engines/diff/port.ts +26 -0
- package/core/client/engines/dnd/adapter-pragmatic.ts +159 -0
- package/core/client/engines/dnd/index.ts +67 -0
- package/core/client/engines/dnd/port.ts +45 -0
- package/core/client/engines/engine-adapters.ts +29 -0
- package/core/client/engines/load.ts +44 -0
- package/core/client/engines/qrcode/adapter-qrcode-generator.ts +52 -0
- package/core/client/engines/qrcode/index.ts +30 -0
- package/core/client/engines/qrcode/port.ts +27 -0
- package/core/client/engines/table/adapter-tanstack.ts +132 -0
- package/core/client/engines/table/index.ts +80 -0
- package/core/client/engines/table/port.ts +55 -0
- package/core/client/engines/temporal/adapter-polyfill.ts +158 -0
- package/core/client/engines/temporal/index.ts +84 -0
- package/core/client/engines/temporal/port.ts +53 -0
- package/core/client/engines/virtual/adapter-tanstack.ts +133 -0
- package/core/client/engines/virtual/index.ts +43 -0
- package/core/client/engines/virtual/port.ts +43 -0
- package/core/client/format/formatter.ts +32 -0
- package/core/client/format/index.ts +26 -0
- package/core/client/format/zoned.ts +10 -0
- package/core/client/host-bridge/index.ts +17 -0
- package/core/client/host-bridge/load-host-domain-class.ts +15 -4
- package/core/client/host-bridge/resolve-host-bootstrap.ts +63 -11
- package/core/client/host-bridge/soma-app-host.stub.ts +3 -0
- package/core/client/host-bridge/soma-bootstrap-from-app.ts +25 -0
- package/core/client/infra/auth/IAuthService.ts +18 -13
- package/core/client/infra/auth/TokenAuthService.ts +126 -112
- package/core/client/infra/config/SomaConfig.ts +16 -0
- package/core/client/infra/config/feature-flags.ts +28 -0
- package/core/client/infra/http/IHttpClient.ts +2 -0
- package/core/client/infra/http/SomaHttpService.ts +1 -0
- package/core/client/infra/i18n/II18n.ts +23 -6
- package/core/client/infra/i18n/builtin-locale.ts +31 -0
- package/core/client/infra/i18n/index.ts +4 -0
- package/core/client/infra/i18n/interpolate.ts +28 -0
- package/core/client/infra/i18n/locale-catalog.ts +233 -0
- package/core/client/infra/i18n/pack-locales.ts +117 -0
- package/core/client/infra/identity/identity-port.ts +178 -0
- package/core/client/infra/notify/DefaultNotifyService.ts +86 -31
- package/core/client/infra/notify/INotifyService.ts +2 -14
- package/core/client/infra/notify/notify-declaration.ts +37 -0
- package/core/client/infra/permission/SomaPermission.ts +58 -48
- package/core/client/infra/router/IRouter.ts +24 -19
- package/core/client/infra/router/SomaRouter.ts +78 -66
- package/core/client/keyboard/collection.ts +197 -0
- package/core/client/keyboard/compose-keys.ts +68 -0
- package/core/client/keyboard/cursor.ts +117 -0
- package/core/client/keyboard/delegate.ts +195 -0
- package/core/client/keyboard/ime.ts +8 -0
- package/core/client/keyboard/index.ts +73 -0
- package/core/client/keyboard/intents.ts +60 -0
- package/core/client/keyboard/matrix.ts +269 -0
- package/core/client/keyboard/submit.ts +30 -0
- package/core/client/keyboard/typeahead.ts +203 -0
- package/core/client/keyboard/wiring.ts +324 -0
- package/core/client/middleware/createPermissionMiddleware.ts +20 -11
- package/core/client/mount/domain-rule.ts +43 -0
- package/core/client/mount/index.ts +3 -0
- package/core/client/mount/mount-page.ts +163 -0
- package/core/client/mount/types.ts +93 -0
- package/core/client/observability/runtime-observer.ts +136 -0
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/confirm-spec.ts +139 -0
- package/core/client/parser/data-config-parser.ts +416 -217
- package/core/client/parser/duration.ts +2 -16
- package/core/client/parser/page-state-parser.ts +59 -64
- package/core/client/parser/pipeline-parser.ts +178 -236
- package/core/client/parser/style-config-parser.ts +15 -81
- package/core/client/parser/subscribe-parser.ts +83 -0
- package/core/client/parser/timer-parser.ts +1 -1
- package/core/client/parser/trigger-parser.ts +1 -1
- package/core/client/parser/ui-config-parser.ts +244 -243
- package/core/client/pipes/pipe-registry.ts +304 -76
- package/core/client/registry/declaration-renderer.ts +20 -8
- package/core/client/registry/page-lifecycle.ts +4 -4
- package/core/client/registry/remote-page.ts +4 -4
- package/core/client/render-ports/index.ts +18 -0
- package/core/client/render-ports/notify-renderer.ts +45 -0
- package/core/client/render-ports/region-fallback.ts +8 -0
- package/core/client/render-ports/scheduling/prompt-queue.ts +102 -0
- package/core/client/render-ports/scheduling/toast-scheduler.ts +253 -0
- package/core/client/runtime/SomaRuntimeServices.ts +180 -16
- package/core/client/runtime/SomaSnapshotStore.ts +100 -100
- package/core/client/runtime/nav-history.ts +147 -0
- package/core/client/runtime/nav-port.ts +68 -0
- package/core/client/runtime/shortcuts.ts +360 -0
- package/core/client/runtime/write-feedback.ts +71 -0
- package/core/client/runtime-entry.ts +29 -0
- package/core/client/scheduler/SomaScheduler.ts +13 -3
- package/core/client/scheduling/flush-scheduler.ts +100 -0
- package/core/client/scheduling/index.ts +22 -0
- package/core/client/scheduling/observer-pool.ts +109 -0
- package/core/client/security/attribute-presence.ts +1 -3
- package/core/client/security/html-sanitizer.ts +23 -1
- package/core/client/security/url-guard.ts +0 -0
- package/core/client/styles/compiled-styles.ts +47 -0
- package/core/client/styles/index.ts +10 -0
- package/core/client/styles/pack-styles.ts +169 -0
- package/core/client/styles/sheet-mount.ts +48 -0
- package/core/client/styles/style-features.ts +131 -0
- package/core/client/time/clock.ts +36 -0
- package/core/client/time/instant.ts +2 -0
- package/core/client/url-state/index.ts +15 -0
- package/core/client/url-state/page-tabs-controller.ts +47 -0
- package/core/client/url-state/state-query-binding.ts +114 -0
- package/core/client/url-state/url-state.ts +149 -0
- package/core/client/validation/async-check-registry.ts +129 -0
- package/core/client/validation/async-rules.ts +259 -0
- package/core/client/validation/contract-validator.ts +44 -5
- package/core/client/validation/field-rules.ts +49 -0
- package/core/client/validation/index.ts +53 -0
- package/core/client/validation/object-rules.ts +72 -0
- package/core/index.ts +290 -264
- package/core/inspect/check-product.ts +542 -0
- package/core/inspect/check-runtime.ts +865 -0
- package/core/inspect/runtime.ts +98 -0
- package/core/page-target/index.ts +9 -0
- package/core/page-target/provenance.ts +119 -0
- package/core/page-target/slug.ts +7 -0
- package/core/page-target/testing/index.ts +329 -0
- package/core/page-target/types.ts +279 -0
- package/core/predicates-entry.ts +43 -0
- package/core/server/api/load-host-service.ts +3 -0
- package/core/server/compile-port.ts +18 -0
- package/core/server/diagnostic-gate-entry.ts +14 -0
- package/core/server/engines/style/candidate-guard.ts +59 -0
- package/core/server/engines/style/index.ts +57 -0
- package/core/server/engines/style/port.ts +34 -0
- package/core/server/engines/style/tailwind-adapter.ts +68 -0
- package/core/server/host/content-security-policy.ts +3 -5
- package/core/server/host/host-assembly-entry.ts +24 -0
- package/core/server/host/host-assembly.ts +267 -0
- package/core/server/host/host-caller.ts +52 -0
- package/core/server/host/host-response-headers.ts +49 -0
- package/core/server/host/invoke-host-request-hook.ts +5 -0
- package/core/server/host/locale-yaml.ts +53 -0
- package/core/server/host/page-markup-config.ts +13 -0
- package/core/server/host/published-page-artifact-cache.ts +355 -124
- package/core/server/host/published-page-assets.ts +91 -46
- package/core/server/host/resolve-host-request-hook.ts +9 -10
- package/core/server/host/resolve-host-tree-context.ts +8 -28
- package/core/server/host/server-page-assets.ts +175 -57
- package/core/server/host/soma-page-compile.ts +57 -16
- package/core/server/host/source-packages.cjs +184 -0
- package/core/server/host/source-packages.ts +18 -126
- package/core/server/host/virtual-pages.ts +197 -0
- package/core/server/index.ts +12 -43
- package/core/server/node.ts +52 -0
- package/core/server/page-assets.ts +73 -0
- package/core/server/page-declaration.ts +83 -7
- package/core/server/registry/api-registry-store.ts +17 -28
- package/core/server/registry/asset-store.ts +17 -19
- package/core/server/registry/batch-publish.ts +38 -0
- package/core/server/registry/batch-stage.ts +130 -0
- package/core/server/registry/component-supply.ts +31 -0
- package/core/server/registry/declaration-precompiler.ts +48 -34
- package/core/server/registry/index.ts +78 -1
- package/core/server/registry/page-registry-repository.ts +484 -69
- package/core/server/registry/page-registry-store.ts +617 -108
- package/core/server/registry/publish-asset-pin.ts +22 -20
- package/core/server/registry/registry-file-lock.ts +16 -3
- package/core/server/registry/registry-subjects.ts +6 -6
- package/core/server/registry/registry-write-pipeline.ts +65 -1
- package/core/server/registry/request-body-limit.ts +3 -1
- package/core/server/registry/rollback-plan.ts +181 -0
- package/core/server/registry/services/index.ts +14 -1
- package/core/server/registry/services/pages/Get.ts +26 -4
- package/core/server/registry/services/pages/Register.ts +29 -7
- package/core/server/registry/services/pages/RegisterBatch.ts +68 -0
- package/core/server/registry/services/pages/Rollback.ts +14 -4
- package/core/server/registry/services/pages/Unregister.ts +2 -1
- package/core/server/registry/source/canonical.ts +57 -0
- package/core/server/registry/source/errors.ts +81 -0
- package/core/server/registry/source/index.ts +49 -0
- package/core/server/registry/source/ledger.ts +306 -0
- package/core/server/registry/source/snapshot.ts +29 -0
- package/core/server/registry/source/source-name.ts +48 -0
- package/core/server/registry/source/types.ts +106 -0
- package/core/server/registry/source/version-store.ts +349 -0
- package/core/server/registry/standard-product.ts +185 -0
- package/core/server/registry/validation/compile-gate.ts +39 -50
- package/core/server/registry/validation/cross-check.ts +18 -5
- package/core/server/registry/validation/declaration-safety-scan.ts +12 -10
- package/core/server/registry/validation/region-scopes.ts +50 -0
- package/core/server/runtime-space/access-gate.ts +206 -0
- package/core/server/runtime-space/advice-log.ts +67 -0
- package/core/server/runtime-space/artifact-evict.ts +15 -0
- package/core/server/runtime-space/bindings.ts +478 -0
- package/core/server/runtime-space/digest.ts +62 -0
- package/core/server/runtime-space/dynamic-pages.ts +379 -0
- package/core/server/runtime-space/errors.ts +96 -0
- package/core/server/runtime-space/gc.ts +116 -0
- package/core/server/runtime-space/index.ts +106 -0
- package/core/server/runtime-space/inject.ts +497 -0
- package/core/server/runtime-space/nav-catalog.ts +140 -0
- package/core/server/runtime-space/page-grants.ts +436 -0
- package/core/server/runtime-space/prewarm.ts +234 -0
- package/core/server/runtime-space/registry-cold-start.ts +69 -0
- package/core/server/runtime-space/resolve.ts +538 -0
- package/core/server/runtime-space/root.cjs +160 -0
- package/core/server/runtime-space/root.ts +26 -0
- package/core/server/runtime-space/static-source.ts +85 -0
- package/core/server/runtime-space/store.ts +253 -0
- package/core/server/runtime-space/submit-steps.ts +412 -0
- package/core/server/runtime-space/types.ts +314 -0
- package/core/shared/anchor-space.ts +48 -0
- package/core/shared/artifact-compatibility.ts +156 -0
- package/core/shared/behavior-machine-names.ts +8 -0
- package/core/shared/calc/coerce.ts +2 -29
- package/core/shared/calc/errors.ts +4 -7
- package/core/shared/calc/evaluator.ts +23 -11
- package/core/shared/calc/index.ts +3 -4
- package/core/shared/calc/lexer.ts +7 -12
- package/core/shared/calc/parser.ts +8 -19
- package/core/shared/calc/typer.ts +10 -23
- package/core/shared/component-tree-artifact.ts +81 -7
- package/core/shared/contract-a11y.ts +335 -0
- package/core/shared/contract-sections.ts +344 -0
- package/core/shared/core-diagnostic-codes.ts +208 -0
- package/core/shared/data-declaration-checks.ts +211 -0
- package/core/shared/date-parts.ts +2 -0
- package/core/shared/declaration-errors.ts +14 -0
- package/core/shared/declaration-keys.ts +36 -0
- package/core/shared/diagnostic-code-index-entry.ts +14 -0
- package/core/shared/diagnostic-gate.ts +139 -0
- package/core/shared/engines/engine-error.ts +33 -0
- package/core/shared/engines/style/style-engine.types.ts +28 -0
- package/core/shared/envelope-text-width.generated.d.mts +19 -0
- package/core/shared/envelope-text-width.generated.mjs +413 -0
- package/core/shared/fragments-section.ts +10 -0
- package/core/shared/generation-diagnostics.ts +58 -0
- package/core/shared/generation-error.ts +73 -0
- package/core/shared/hook-attributes.ts +159 -0
- package/core/shared/inert-data-element.ts +50 -0
- package/core/shared/nav-back.ts +120 -0
- package/core/shared/page-access-text.ts +7 -0
- package/core/shared/page-envelope-runtime.ts +88 -0
- package/core/shared/page-envelope.ts +618 -0
- package/core/shared/page-scopes.ts +83 -0
- package/core/shared/pipeline-error-codes-view.ts +30 -0
- package/core/shared/pipeline-limits-view.ts +27 -0
- package/core/shared/predicates/index.ts +85 -497
- package/core/shared/predicates/relative-window.ts +19 -0
- package/core/shared/published-page-route.ts +5 -14
- package/core/shared/region-scope-decl.ts +488 -0
- package/core/shared/registry-generated/compile-purposes.ts +53 -0
- package/core/shared/registry-generated/diagnostic-registry-index.ts +796 -0
- package/core/shared/registry-generated/diagnostic-registry.ts +5872 -0
- package/core/shared/registry-generated/error-codes.ts +137 -0
- package/core/shared/registry-generated/index.ts +13 -0
- package/core/shared/registry-generated/limits.ts +552 -0
- package/core/shared/registry-generated/platform-keys.ts +56 -0
- package/core/shared/registry-generated/region-scope.ts +823 -0
- package/core/shared/registry-generated/std-grammar-completion.ts +216 -0
- package/core/shared/registry-generated/std-grammar-views.ts +139 -0
- package/core/shared/registry-generated/std-grammar.ts +161 -0
- package/core/shared/rule-step.ts +2 -0
- package/core/shared/runtime-address.ts +244 -0
- package/core/shared/scope-decl.ts +77 -0
- package/core/shared/sha256.ts +108 -0
- package/core/shared/show-when.ts +77 -0
- package/core/shared/source-file-suffix.ts +8 -0
- package/core/shared/std-auth-scan.ts +158 -0
- package/core/shared/types/choice-confirm.types.ts +2 -0
- package/core/shared/types/compile-diagnostic.types.ts +42 -0
- package/core/shared/types/compile-port.types.ts +41 -0
- package/core/shared/types/component-contract.types.ts +145 -156
- package/core/shared/types/component-tree-artifact.types.ts +18 -2
- package/core/shared/types/component-tree.types.ts +17 -6
- package/core/shared/types/data-config.types.ts +182 -222
- package/core/shared/types/domain.types.ts +20 -5
- package/core/shared/types/engine.types.ts +2 -0
- package/core/shared/types/event.types.ts +78 -8
- package/core/shared/types/generation-error.types.ts +83 -0
- package/core/shared/types/host-assembly.types.ts +126 -0
- package/core/shared/types/locale.types.ts +46 -0
- package/core/shared/types/manifest.types.ts +2 -7
- package/core/shared/types/nav-context.types.ts +46 -0
- package/core/shared/types/nav.types.ts +57 -0
- package/core/shared/types/notify.types.ts +45 -0
- package/core/shared/types/observation.types.ts +76 -0
- package/core/shared/types/page-envelope.types.ts +125 -0
- package/core/shared/types/page-state.types.ts +21 -42
- package/core/shared/types/region-scope.types.ts +177 -0
- package/core/shared/types/registry-batch.types.ts +45 -0
- package/core/shared/types/shortcuts.types.ts +61 -0
- package/core/shared/types/source.types.ts +10 -0
- package/core/shared/types/style-config.types.ts +61 -82
- package/core/shared/types/temporal.types.ts +3 -0
- package/core/shared/types/ui-config.types.ts +80 -152
- package/core/shared/types/write-outcome-view.types.ts +24 -0
- package/core/shared/types/write-runtime.types.ts +10 -0
- package/core/shared/types/write.types.ts +86 -0
- package/dist/browser/runtime-bundle.manifest.json +938 -0
- package/dist/browser/soma-runtime.js +120260 -0
- package/dist/cli/soma.js +120 -456
- package/dist/core/adaptive-pure.cjs +41 -0
- package/dist/core/index.cjs +119695 -22484
- package/dist/core/theme-pure.cjs +38 -0
- package/dist/diagnostics/telemetry.cjs +2 -1
- package/dist/lsp/component-tree.cjs +6398 -8254
- package/dist/preview-export.cjs +3401 -0
- package/dist/types/build/compiler/flat-page.d.ts +52 -0
- package/dist/types/build/compiler/full-manifest-builder.d.ts +26 -1
- package/dist/types/build/compiler/html-index.d.ts +48 -0
- package/dist/types/build/compiler/page-assets.d.ts +11 -3
- package/dist/types/build/compiler/page-base-resolver.d.ts +5 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +97 -56
- package/dist/types/build/compiler/soma-precompile.d.ts +3 -3
- package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -2
- package/dist/types/build/component/component-graph.d.ts +1 -1
- package/dist/types/build/component-tree/artifact-codec.d.ts +5 -8
- package/dist/types/build/component-tree/registry-snapshot.d.ts +18 -0
- package/dist/types/build/component-tree/source-preflight.d.ts +4 -14
- package/dist/types/build/component-tree/structure-topology.d.ts +1 -1
- package/dist/types/build/eject/plan-eject.d.ts +0 -1
- package/dist/types/build/lsp/component-tree-service.d.ts +2 -0
- package/dist/types/client/a11y/a11y-config.d.ts +15 -0
- package/dist/types/client/a11y/announcer.d.ts +45 -0
- package/dist/types/client/a11y/dom-id.d.ts +4 -0
- package/dist/types/client/a11y/index.d.ts +5 -0
- package/dist/types/client/a11y/motion-hook.d.ts +13 -0
- package/dist/types/client/a11y/motion.d.ts +24 -0
- package/dist/types/client/base/SomaPageRootBase.d.ts +17 -2
- package/dist/types/client/base/index.d.ts +8 -8
- package/dist/types/client/behavior/adapter-collection.d.ts +39 -0
- package/dist/types/client/behavior/adapter-popper.d.ts +2 -0
- package/dist/types/client/behavior/aria-hide-outside.d.ts +13 -0
- package/dist/types/client/behavior/css-escape.d.ts +11 -0
- package/dist/types/client/behavior/focus-scope.d.ts +69 -0
- package/dist/types/client/behavior/focus-traversal.d.ts +3 -0
- package/dist/types/client/behavior/index.d.ts +17 -0
- package/dist/types/client/behavior/layer-stack.d.ts +39 -0
- package/dist/types/client/behavior/overlay-host/index.d.ts +5 -0
- package/dist/types/client/behavior/overlay-host/port.d.ts +55 -0
- package/dist/types/client/behavior/overlay-wiring.d.ts +59 -0
- package/dist/types/client/behavior/port.d.ts +79 -0
- package/dist/types/client/behavior/positioner.d.ts +2 -0
- package/dist/types/client/behavior/presence.d.ts +27 -0
- package/dist/types/client/behavior/zag/adapter-vanilla.d.ts +2 -0
- package/dist/types/client/behavior/zag/layer-bridge.d.ts +15 -0
- package/dist/types/client/behavior/zag/machine-host.d.ts +22 -0
- package/dist/types/client/behavior/zag/machines.d.ts +23 -0
- package/dist/types/client/compiler/manifest-compiler.d.ts +4 -14
- package/dist/types/client/component/adapter/adapt.d.ts +9 -0
- package/dist/types/client/component/adapter/index.d.ts +3 -0
- package/dist/types/client/component/adapter/types.d.ts +33 -0
- package/dist/types/client/component/adapter/web-component.d.ts +9 -0
- package/dist/types/client/component/component-definition.types.d.ts +23 -5
- package/dist/types/client/component/component-expander.d.ts +1 -12
- package/dist/types/client/component/component-manager.d.ts +39 -89
- package/dist/types/client/component/component-pack.d.ts +21 -54
- package/dist/types/client/component/component-registry.d.ts +5 -0
- package/dist/types/client/component/projection-admission.d.ts +5 -0
- package/dist/types/client/component/projection-registry.d.ts +6 -0
- package/dist/types/client/component/projection.types.d.ts +44 -0
- package/dist/types/client/component/region-unavailable.d.ts +10 -0
- package/dist/types/client/component/scoped-adapter.d.ts +2 -3
- package/dist/types/client/container/IContainerAdapter.d.ts +8 -3
- package/dist/types/client/container/SomaContainerAdapter.d.ts +7 -10
- package/dist/types/client/data/collection-payload.d.ts +1 -0
- package/dist/types/client/data/data-object-resolver.d.ts +231 -110
- package/dist/types/client/data/data-polling.d.ts +28 -0
- package/dist/types/client/data/data-subscriptions.d.ts +20 -0
- package/dist/types/client/data/data-write-actions.d.ts +9 -0
- package/dist/types/client/data/envelope-failure.d.ts +17 -0
- package/dist/types/client/data/format-config.d.ts +13 -0
- package/dist/types/client/data/region-scope-port.d.ts +34 -0
- package/dist/types/client/data/region-scope-views.d.ts +15 -0
- package/dist/types/client/data/role-gate.d.ts +10 -0
- package/dist/types/client/data/write-outcome-store.d.ts +23 -0
- package/dist/types/client/data/write-outcome.d.ts +48 -0
- package/dist/types/client/engine/asset-resolver.d.ts +2 -7
- package/dist/types/client/engine/dom-renderer.d.ts +5 -111
- package/dist/types/client/engine/event-engine.d.ts +52 -63
- package/dist/types/client/engine/locale-text-binder.d.ts +28 -0
- package/dist/types/client/engine/property-watcher.d.ts +1 -41
- package/dist/types/client/engine/reactive-proxy.d.ts +2 -42
- package/dist/types/client/engine/render-engine.d.ts +3 -54
- package/dist/types/client/engine/row-range.d.ts +1 -0
- package/dist/types/client/engine/runtime-builder.d.ts +7 -3
- package/dist/types/client/engine/soma-bootstrap.d.ts +314 -91
- package/dist/types/client/engine/step-runner.d.ts +20 -2
- package/dist/types/client/engine/style-binder.d.ts +2 -16
- package/dist/types/client/engines/chart/adapter-echarts.d.ts +6 -0
- package/dist/types/client/engines/chart/index.d.ts +8 -0
- package/dist/types/client/engines/chart/kind-modules.d.ts +8 -0
- package/dist/types/client/engines/chart/port.d.ts +46 -0
- package/dist/types/client/engines/diff/adapter-jsdiff.d.ts +6 -0
- package/dist/types/client/engines/diff/index.d.ts +8 -0
- package/dist/types/client/engines/diff/port.d.ts +16 -0
- package/dist/types/client/engines/dnd/adapter-pragmatic.d.ts +9 -0
- package/dist/types/client/engines/dnd/index.d.ts +6 -0
- package/dist/types/client/engines/dnd/port.d.ts +33 -0
- package/dist/types/client/engines/engine-adapters.d.ts +23 -0
- package/dist/types/client/engines/load.d.ts +11 -0
- package/dist/types/client/engines/qrcode/adapter-qrcode-generator.d.ts +6 -0
- package/dist/types/client/engines/qrcode/index.d.ts +8 -0
- package/dist/types/client/engines/qrcode/port.d.ts +16 -0
- package/dist/types/client/engines/table/adapter-tanstack.d.ts +6 -0
- package/dist/types/client/engines/table/index.d.ts +8 -0
- package/dist/types/client/engines/table/port.d.ts +51 -0
- package/dist/types/client/engines/temporal/adapter-polyfill.d.ts +6 -0
- package/dist/types/client/engines/temporal/index.d.ts +8 -0
- package/dist/types/client/engines/temporal/port.d.ts +41 -0
- package/dist/types/client/engines/virtual/adapter-tanstack.d.ts +9 -0
- package/dist/types/client/engines/virtual/index.d.ts +8 -0
- package/dist/types/client/engines/virtual/port.d.ts +33 -0
- package/dist/types/client/format/formatter.d.ts +3 -0
- package/dist/types/client/format/index.d.ts +2 -0
- package/dist/types/client/format/zoned.d.ts +1 -0
- package/dist/types/client/host-bridge/index.d.ts +3 -0
- package/dist/types/client/host-bridge/resolve-host-bootstrap.d.ts +7 -1
- package/dist/types/client/host-bridge/soma-app-host.stub.d.ts +3 -0
- package/dist/types/client/host-bridge/soma-bootstrap-from-app.d.ts +9 -0
- package/dist/types/client/infra/auth/IAuthService.d.ts +5 -0
- package/dist/types/client/infra/auth/TokenAuthService.d.ts +1 -0
- package/dist/types/client/infra/config/SomaConfig.d.ts +4 -0
- package/dist/types/client/infra/config/feature-flags.d.ts +10 -0
- package/dist/types/client/infra/http/IHttpClient.d.ts +4 -0
- package/dist/types/client/infra/i18n/II18n.d.ts +17 -1
- package/dist/types/client/infra/i18n/builtin-locale.d.ts +11 -0
- package/dist/types/client/infra/i18n/index.d.ts +1 -0
- package/dist/types/client/infra/i18n/interpolate.d.ts +12 -0
- package/dist/types/client/infra/i18n/locale-catalog.d.ts +71 -0
- package/dist/types/client/infra/i18n/pack-locales.d.ts +29 -0
- package/dist/types/client/infra/identity/identity-port.d.ts +54 -0
- package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +29 -7
- package/dist/types/client/infra/notify/INotifyService.d.ts +1 -12
- package/dist/types/client/infra/notify/notify-declaration.d.ts +10 -0
- package/dist/types/client/infra/permission/SomaPermission.d.ts +7 -0
- package/dist/types/client/infra/router/IRouter.d.ts +5 -1
- package/dist/types/client/infra/router/SomaRouter.d.ts +6 -2
- package/dist/types/client/keyboard/collection.d.ts +58 -0
- package/dist/types/client/keyboard/compose-keys.d.ts +24 -0
- package/dist/types/client/keyboard/cursor.d.ts +48 -0
- package/dist/types/client/keyboard/delegate.d.ts +48 -0
- package/dist/types/client/keyboard/ime.d.ts +2 -0
- package/dist/types/client/keyboard/index.d.ts +10 -0
- package/dist/types/client/keyboard/intents.d.ts +35 -0
- package/dist/types/client/keyboard/matrix.d.ts +29 -0
- package/dist/types/client/keyboard/submit.d.ts +7 -0
- package/dist/types/client/keyboard/typeahead.d.ts +28 -0
- package/dist/types/client/keyboard/wiring.d.ts +85 -0
- package/dist/types/client/middleware/createPermissionMiddleware.d.ts +5 -0
- package/dist/types/client/mount/domain-rule.d.ts +17 -0
- package/dist/types/client/mount/index.d.ts +3 -0
- package/dist/types/client/mount/mount-page.d.ts +11 -0
- package/dist/types/client/mount/types.d.ts +100 -0
- package/dist/types/client/observability/runtime-observer.d.ts +24 -0
- package/dist/types/client/parser/confirm-spec.d.ts +37 -0
- package/dist/types/client/parser/data-config-parser.d.ts +23 -17
- package/dist/types/client/parser/duration.d.ts +1 -1
- package/dist/types/client/parser/page-state-parser.d.ts +1 -6
- package/dist/types/client/parser/pipeline-parser.d.ts +7 -12
- package/dist/types/client/parser/style-config-parser.d.ts +2 -1
- package/dist/types/client/parser/subscribe-parser.d.ts +5 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +26 -25
- package/dist/types/client/pipes/pipe-registry.d.ts +30 -40
- package/dist/types/client/registry/declaration-renderer.d.ts +11 -3
- package/dist/types/client/registry/page-lifecycle.d.ts +3 -3
- package/dist/types/client/registry/remote-page.d.ts +3 -3
- package/dist/types/client/render-ports/index.d.ts +15 -0
- package/dist/types/client/render-ports/notify-renderer.d.ts +55 -0
- package/dist/types/client/render-ports/region-fallback.d.ts +10 -0
- package/dist/types/client/render-ports/scheduling/prompt-queue.d.ts +19 -0
- package/dist/types/client/render-ports/scheduling/toast-scheduler.d.ts +60 -0
- package/dist/types/client/runtime/SomaRuntimeServices.d.ts +102 -5
- package/dist/types/client/runtime/nav-history.d.ts +31 -0
- package/dist/types/client/runtime/nav-port.d.ts +12 -0
- package/dist/types/client/runtime/shortcuts.d.ts +41 -0
- package/dist/types/client/runtime/write-feedback.d.ts +22 -0
- package/dist/types/client/runtime-entry.d.ts +13 -0
- package/dist/types/client/scheduler/SomaScheduler.d.ts +5 -0
- package/dist/types/client/scheduling/flush-scheduler.d.ts +13 -0
- package/dist/types/client/scheduling/index.d.ts +4 -0
- package/dist/types/client/scheduling/observer-pool.d.ts +15 -0
- package/dist/types/client/security/url-guard.d.ts +18 -0
- package/dist/types/client/styles/compiled-styles.d.ts +10 -0
- package/dist/types/client/styles/index.d.ts +3 -0
- package/dist/types/client/styles/pack-styles.d.ts +51 -0
- package/dist/types/client/styles/sheet-mount.d.ts +7 -0
- package/dist/types/client/styles/style-features.d.ts +26 -0
- package/dist/types/client/time/clock.d.ts +10 -0
- package/dist/types/client/time/instant.d.ts +1 -0
- package/dist/types/client/url-state/index.d.ts +6 -0
- package/dist/types/client/url-state/page-tabs-controller.d.ts +22 -0
- package/dist/types/client/url-state/state-query-binding.d.ts +22 -0
- package/dist/types/client/url-state/url-state.d.ts +47 -0
- package/dist/types/client/validation/async-check-registry.d.ts +41 -0
- package/dist/types/client/validation/async-rules.d.ts +81 -0
- package/dist/types/client/validation/contract-validator.d.ts +10 -0
- package/dist/types/client/validation/field-rules.d.ts +6 -0
- package/dist/types/client/validation/index.d.ts +5 -0
- package/dist/types/client/validation/object-rules.d.ts +22 -0
- package/dist/types/index.d.ts +97 -61
- package/dist/types/inspect/check-product.d.ts +123 -0
- package/dist/types/inspect/check-runtime.d.ts +19 -0
- package/dist/types/inspect/runtime.d.ts +39 -0
- package/dist/types/page-target/index.d.ts +3 -0
- package/dist/types/page-target/provenance.d.ts +20 -0
- package/dist/types/page-target/slug.d.ts +7 -0
- package/dist/types/page-target/testing/index.d.ts +55 -0
- package/dist/types/page-target/types.d.ts +260 -0
- package/dist/types/predicates-entry.d.ts +3 -0
- package/dist/types/server/compile-port.d.ts +13 -0
- package/dist/types/server/diagnostic-gate-entry.d.ts +3 -0
- package/dist/types/server/engines/style/candidate-guard.d.ts +14 -0
- package/dist/types/server/engines/style/index.d.ts +10 -0
- package/dist/types/server/engines/style/port.d.ts +8 -0
- package/dist/types/server/engines/style/tailwind-adapter.d.ts +6 -0
- package/dist/types/server/host/host-assembly-entry.d.ts +5 -0
- package/dist/types/server/host/host-assembly.d.ts +61 -0
- package/dist/types/server/host/host-caller.d.ts +10 -0
- package/dist/types/server/host/host-config-paths.d.cts +7 -0
- package/dist/types/server/host/host-response-headers.d.ts +16 -0
- package/dist/types/server/host/locale-yaml.d.ts +3 -0
- package/dist/types/server/host/page-markup-config.d.ts +6 -0
- package/dist/types/server/host/published-page-artifact-cache.d.ts +99 -22
- package/dist/types/server/host/published-page-assets.d.ts +75 -5
- package/dist/types/server/host/resolve-host-request-hook.d.ts +0 -4
- package/dist/types/server/host/resolve-host-tree-context.d.ts +1 -1
- package/dist/types/server/host/server-page-assets.d.ts +29 -3
- package/dist/types/server/host/soma-page-compile.d.ts +26 -4
- package/dist/types/server/host/source-packages.d.cts +23 -0
- package/dist/types/server/host/source-packages.d.ts +15 -2
- package/dist/types/server/host/virtual-pages.d.ts +33 -0
- package/dist/types/server/index.d.ts +7 -12
- package/dist/types/server/node.d.ts +16 -0
- package/dist/types/server/page-assets.d.ts +7 -0
- package/dist/types/server/page-declaration.d.ts +21 -6
- package/dist/types/server/registry/api-registry-store.d.ts +4 -7
- package/dist/types/server/registry/asset-store.d.ts +4 -7
- package/dist/types/server/registry/batch-publish.d.ts +12 -0
- package/dist/types/server/registry/batch-stage.d.ts +24 -0
- package/dist/types/server/registry/component-supply.d.ts +6 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +22 -8
- package/dist/types/server/registry/index.d.ts +12 -3
- package/dist/types/server/registry/page-registry-repository.d.ts +50 -4
- package/dist/types/server/registry/page-registry-store.d.ts +227 -33
- package/dist/types/server/registry/publish-asset-pin.d.ts +5 -4
- package/dist/types/server/registry/registry-file-lock.d.ts +5 -0
- package/dist/types/server/registry/registry-subjects.d.ts +2 -2
- package/dist/types/server/registry/registry-write-pipeline.d.ts +22 -0
- package/dist/types/server/registry/request-body-limit.d.ts +1 -1
- package/dist/types/server/registry/rollback-plan.d.ts +58 -0
- package/dist/types/server/registry/services/index.d.ts +5 -0
- package/dist/types/server/registry/services/pages/Register.d.ts +1 -1
- package/dist/types/server/registry/services/pages/RegisterBatch.d.ts +12 -0
- package/dist/types/server/registry/services/pages/Rollback.d.ts +4 -1
- package/dist/types/server/registry/source/canonical.d.ts +2 -0
- package/dist/types/server/registry/source/errors.d.ts +44 -0
- package/dist/types/server/registry/source/index.d.ts +7 -0
- package/dist/types/server/registry/source/ledger.d.ts +99 -0
- package/dist/types/server/registry/source/snapshot.d.ts +6 -0
- package/dist/types/server/registry/source/source-name.d.ts +20 -0
- package/dist/types/server/registry/source/types.d.ts +89 -0
- package/dist/types/server/registry/source/version-store.d.ts +58 -0
- package/dist/types/server/registry/standard-product.d.ts +78 -0
- package/dist/types/server/registry/validation/compile-gate.d.ts +12 -45
- package/dist/types/server/registry/validation/cross-check.d.ts +7 -0
- package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +0 -1
- package/dist/types/server/registry/validation/region-scopes.d.ts +10 -0
- package/dist/types/server/runtime-space/access-gate.d.ts +41 -0
- package/dist/types/server/runtime-space/advice-log.d.ts +18 -0
- package/dist/types/server/runtime-space/artifact-evict.d.ts +4 -0
- package/dist/types/server/runtime-space/bindings.d.ts +115 -0
- package/dist/types/server/runtime-space/digest.d.ts +19 -0
- package/dist/types/server/runtime-space/dynamic-pages.d.ts +120 -0
- package/dist/types/server/runtime-space/errors.d.ts +37 -0
- package/dist/types/server/runtime-space/gc.d.ts +6 -0
- package/dist/types/server/runtime-space/index.d.ts +19 -0
- package/dist/types/server/runtime-space/inject.d.ts +55 -0
- package/dist/types/server/runtime-space/nav-catalog.d.ts +33 -0
- package/dist/types/server/runtime-space/page-grants.d.ts +90 -0
- package/dist/types/server/runtime-space/prewarm.d.ts +60 -0
- package/dist/types/server/runtime-space/registry-cold-start.d.ts +4 -0
- package/dist/types/server/runtime-space/resolve.d.ts +35 -0
- package/dist/types/server/runtime-space/root.d.cts +65 -0
- package/dist/types/server/runtime-space/root.d.ts +16 -0
- package/dist/types/server/runtime-space/static-source.d.ts +8 -0
- package/dist/types/server/runtime-space/store.d.ts +63 -0
- package/dist/types/server/runtime-space/submit-steps.d.ts +116 -0
- package/dist/types/server/runtime-space/types.d.ts +255 -0
- package/dist/types/shared/anchor-space.d.ts +17 -0
- package/dist/types/shared/artifact-compatibility.d.ts +75 -0
- package/dist/types/shared/behavior-machine-names.d.ts +2 -0
- package/dist/types/shared/calc/coerce.d.ts +1 -4
- package/dist/types/shared/calc/lexer.d.ts +1 -2
- package/dist/types/shared/calc/parser.d.ts +1 -7
- package/dist/types/shared/calc/typer.d.ts +1 -6
- package/dist/types/shared/component-tree-artifact.d.ts +16 -2
- package/dist/types/shared/contract-a11y.d.ts +33 -0
- package/dist/types/shared/contract-sections.d.ts +50 -0
- package/dist/types/shared/core-diagnostic-codes.d.ts +28 -0
- package/dist/types/shared/data-declaration-checks.d.ts +71 -0
- package/dist/types/shared/date-parts.d.ts +1 -0
- package/dist/types/shared/declaration-errors.d.ts +12 -0
- package/dist/types/shared/declaration-keys.d.ts +9 -0
- package/dist/types/shared/diagnostic-code-index-entry.d.ts +5 -0
- package/dist/types/shared/diagnostic-gate.d.ts +60 -0
- package/dist/types/shared/engines/engine-error.d.ts +14 -0
- package/dist/types/shared/engines/style/style-engine.types.d.ts +22 -0
- package/dist/types/shared/fragments-section.d.ts +2 -0
- package/dist/types/shared/generation-diagnostics.d.ts +7 -0
- package/dist/types/shared/generation-error.d.ts +20 -0
- package/dist/types/shared/hook-attributes.d.ts +220 -0
- package/dist/types/shared/inert-data-element.d.ts +14 -0
- package/dist/types/shared/nav-back.d.ts +22 -0
- package/dist/types/shared/page-access-text.d.ts +4 -0
- package/dist/types/shared/page-envelope-runtime.d.ts +32 -0
- package/dist/types/shared/page-envelope.d.ts +61 -0
- package/dist/types/shared/page-scopes.d.ts +35 -0
- package/dist/types/shared/pipeline-error-codes-view.d.ts +11 -0
- package/dist/types/shared/pipeline-limits-view.d.ts +8 -0
- package/dist/types/shared/predicates/index.d.ts +24 -67
- package/dist/types/shared/predicates/relative-window.d.ts +1 -0
- package/dist/types/shared/published-page-route.d.ts +3 -5
- package/dist/types/shared/region-scope-decl.d.ts +121 -0
- package/dist/types/shared/registry-generated/compile-purposes.d.ts +37 -0
- package/dist/types/shared/registry-generated/diagnostic-registry-index.d.ts +2 -0
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +5011 -0
- package/dist/types/shared/registry-generated/error-codes.d.ts +115 -0
- package/dist/types/shared/registry-generated/index.d.ts +10 -0
- package/dist/types/shared/registry-generated/limits.d.ts +461 -0
- package/dist/types/shared/registry-generated/platform-keys.d.ts +42 -0
- package/dist/types/shared/registry-generated/region-scope.d.ts +511 -0
- package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +773 -0
- package/dist/types/shared/registry-generated/std-grammar-views.d.ts +203 -0
- package/dist/types/shared/registry-generated/std-grammar.d.ts +3515 -0
- package/dist/types/shared/rule-step.d.ts +1 -0
- package/dist/types/shared/runtime-address.d.ts +70 -0
- package/dist/types/shared/scope-decl.d.ts +15 -0
- package/dist/types/shared/sha256.d.ts +4 -0
- package/dist/types/shared/show-when.d.ts +21 -0
- package/dist/types/shared/source-file-suffix.d.ts +2 -0
- package/dist/types/shared/std-auth-scan.d.ts +45 -0
- package/dist/types/shared/types/choice-confirm.types.d.ts +1 -0
- package/dist/types/shared/types/compile-diagnostic.types.d.ts +34 -0
- package/dist/types/shared/types/compile-port.types.d.ts +30 -0
- package/dist/types/shared/types/component-contract.types.d.ts +134 -129
- package/dist/types/shared/types/component-tree-artifact.types.d.ts +16 -2
- package/dist/types/shared/types/component-tree.types.d.ts +15 -6
- package/dist/types/shared/types/data-config.types.d.ts +175 -191
- package/dist/types/shared/types/domain.types.d.ts +20 -5
- package/dist/types/shared/types/engine.types.d.ts +2 -0
- package/dist/types/shared/types/event.types.d.ts +59 -9
- package/dist/types/shared/types/generation-error.types.d.ts +28 -0
- package/dist/types/shared/types/host-assembly.types.d.ts +121 -0
- package/dist/types/shared/types/locale.types.d.ts +17 -0
- package/dist/types/shared/types/manifest.types.d.ts +2 -7
- package/dist/types/shared/types/nav-context.types.d.ts +41 -0
- package/dist/types/shared/types/nav.types.d.ts +53 -0
- package/dist/types/shared/types/notify.types.d.ts +37 -0
- package/dist/types/shared/types/observation.types.d.ts +72 -0
- package/dist/types/shared/types/page-envelope.types.d.ts +98 -0
- package/dist/types/shared/types/page-state.types.d.ts +17 -33
- package/dist/types/shared/types/region-scope.types.d.ts +150 -0
- package/dist/types/shared/types/registry-batch.types.d.ts +48 -0
- package/dist/types/shared/types/shortcuts.types.d.ts +67 -0
- package/dist/types/shared/types/source.types.d.ts +10 -0
- package/dist/types/shared/types/style-config.types.d.ts +0 -19
- package/dist/types/shared/types/temporal.types.d.ts +1 -0
- package/dist/types/shared/types/ui-config.types.d.ts +77 -148
- package/dist/types/shared/types/write-outcome-view.types.d.ts +19 -0
- package/dist/types/shared/types/write-runtime.types.d.ts +1 -0
- package/dist/types/shared/types/write.types.d.ts +70 -0
- package/global.d.ts +2 -10
- package/host-next/app/SomaPageClient.tsx +359 -0
- package/host-next/app/api/[...path]/route.ts +98 -0
- package/host-next/app/api/soma-registry/[...path]/route.ts +79 -0
- package/host-next/app/components/SomaPageForbidden.tsx +19 -0
- package/host-next/app/globals.css +177 -0
- package/host-next/app/page-access.ts +47 -0
- package/host-next/app/router-bridge.ts +42 -0
- package/host-next/app/soma/_shared/host-prepare.ts +33 -0
- package/host-next/app/soma/_shared/page-http.ts +86 -0
- package/host-next/app/soma/manifest/route.ts +98 -0
- package/host-next/app/soma/page/route.ts +36 -0
- package/host-next/app/soma-runtime/[...file]/route.ts +21 -0
- package/host-next/app/soma-runtime/_shared/static-file.ts +89 -0
- package/host-next/bin/host-next.cjs +59 -0
- package/host-next/instrumentation.ts +13 -0
- package/host-next/next-env.d.ts +7 -0
- package/host-next/next.config.js +382 -0
- package/host-next/proxy.ts +43 -0
- package/host-next/src/shell-routes.cjs +51 -0
- package/host-next/src/workspace.ts +543 -0
- package/package.json +238 -59
- package/tsconfig.json +4 -11
- package/app/SomaPageClient.tsx +0 -313
- package/app/api/[...path]/route.ts +0 -86
- package/app/api/soma-registry/[...path]/route.ts +0 -67
- package/app/globals.css +0 -126
- package/app/soma/manifest/route.ts +0 -43
- package/app/soma/page/route.ts +0 -44
- package/app/soma/page-object/route.ts +0 -159
- package/bin/component.cjs +0 -240
- package/bin/migrate.cjs +0 -432
- package/bin/soma-db.cjs +0 -13
- package/bin/soma-mock.mjs +0 -38
- package/bin/soma-sync.cjs +0 -3
- package/core/build/blocks/block-compile.ts +0 -373
- package/core/build/blocks/block-container.ts +0 -207
- package/core/build/blocks/block-loader.ts +0 -33
- package/core/build/blocks/html-index.ts +0 -120
- package/core/build/blocks/migrate-flat.ts +0 -463
- package/core/build/compiler/precompiled-manifest-loader.ts +0 -41
- package/core/build/component/pack-from-dir.ts +0 -58
- package/core/build/component/package-loader.ts +0 -358
- package/core/build/component-tree/binding-bridge.ts +0 -272
- package/core/build/component-tree/migration-files.ts +0 -214
- package/core/build/component-tree/migration.ts +0 -170
- package/core/build/component-tree/validator.ts +0 -318
- package/core/build/db/cli.ts +0 -10
- package/core/build/db/emit-entities.ts +0 -45
- package/core/build/db/emit-mappers.ts +0 -175
- package/core/build/db/emit-prisma-schema.ts +0 -92
- package/core/build/db/generate.ts +0 -166
- package/core/build/db/ir.ts +0 -75
- package/core/build/db/load-db-yaml.ts +0 -241
- package/core/build/eject/component-eject.ts +0 -480
- package/core/build/eject/component-upgrade.ts +0 -359
- package/core/build/layout/constraint-solver.ts +0 -350
- package/core/build/layout/css-emitter.ts +0 -135
- package/core/build/layout/page-layout.ts +0 -85
- package/core/build/ooui/artifact/artifact.types.ts +0 -275
- package/core/build/ooui/artifact/emit-artifact.ts +0 -269
- package/core/build/ooui/artifact/emit-html.ts +0 -204
- package/core/build/ooui/artifact/index.ts +0 -53
- package/core/build/ooui/artifact/spatial-tree.ts +0 -268
- package/core/build/ooui/artifact/utility-class.ts +0 -83
- package/core/build/ooui/composition/candidate.types.ts +0 -323
- package/core/build/ooui/composition/control-model.ts +0 -114
- package/core/build/ooui/composition/registry.ts +0 -520
- package/core/build/ooui/composition/select.ts +0 -232
- package/core/build/ooui/diagnostics/codes.ts +0 -230
- package/core/build/ooui/diagnostics/error.ts +0 -235
- package/core/build/ooui/diagnostics/format.ts +0 -106
- package/core/build/ooui/diagnostics/index.ts +0 -62
- package/core/build/ooui/diagnostics/issue.types.ts +0 -112
- package/core/build/ooui/engine-slot.ts +0 -184
- package/core/build/ooui/index.ts +0 -1427
- package/core/build/ooui/intent/derive-intent.ts +0 -450
- package/core/build/ooui/intent/field-rules.ts +0 -330
- package/core/build/ooui/intent/intent.types.ts +0 -476
- package/core/build/ooui/intent/verb-events.ts +0 -285
- package/core/build/ooui/page/budget.ts +0 -503
- package/core/build/ooui/page/compose-page.ts +0 -736
- package/core/build/ooui/page/index.ts +0 -66
- package/core/build/ooui/page/page.types.ts +0 -402
- package/core/build/ooui/page/region-row.ts +0 -241
- package/core/build/ooui/semantic/expand-page-surface.ts +0 -180
- package/core/build/ooui/semantic/kernel.types.ts +0 -187
- package/core/build/ooui/semantic/normalize.ts +0 -784
- package/core/build/ooui/semantic/origin.types.ts +0 -211
- package/core/build/ooui/semantic/role-alias.ts +0 -154
- package/core/build/ooui/semantic/shorthand.ts +0 -233
- package/core/build/ooui/semantic/surface.types.ts +0 -78
- package/core/build/ooui/semantic/validate-request.ts +0 -267
- package/core/build/ooui/spatial/emit-utility.ts +0 -480
- package/core/build/ooui/spatial/ir.types.ts +0 -443
- package/core/build/ooui/spatial/registry.ts +0 -565
- package/core/build/ooui/spatial/solve.ts +0 -769
- package/core/build/ooui/spatial/utility.types.ts +0 -242
- package/core/build/ooui/trace/index.ts +0 -40
- package/core/build/ooui/trace/render.ts +0 -190
- package/core/build/ooui/trace/source.types.ts +0 -69
- package/core/build/ooui/trace/trace.types.ts +0 -326
- package/core/build/pack/pack-init.ts +0 -270
- package/core/client/adaptive/flush-scheduler.ts +0 -96
- package/core/client/adaptive/hysteresis.ts +0 -56
- package/core/client/adaptive/index.ts +0 -23
- package/core/client/adaptive/observer-pool.ts +0 -204
- package/core/client/compiler/adaptive-compile.ts +0 -136
- package/core/client/component/ai-catalog.ts +0 -432
- package/core/client/component/catalog-examples.ts +0 -60
- package/core/client/component/contract-compat.ts +0 -161
- package/core/client/component/example-blocks.ts +0 -126
- package/core/client/component/keyboard-matrix.ts +0 -144
- package/core/client/component/pack-styles.ts +0 -152
- package/core/client/component/style-features.ts +0 -131
- package/core/client/component/theme-component-tokens.ts +0 -80
- package/core/client/component/verify-pack.ts +0 -429
- package/core/client/container/MiniProgramContainerAdapter.ts +0 -204
- package/core/client/container/ReactNativeContainerAdapter.ts +0 -203
- package/core/client/data/reaction-engine.ts +0 -176
- package/core/client/data/window-engine.ts +0 -477
- package/core/client/infra/i18n/DefaultI18n.ts +0 -29
- package/core/client/infra/notify/DomNotifyService.ts +0 -99
- package/core/client/infra/notify/INotifyTheme.ts +0 -22
- package/core/client/parser/adaptive-parser.ts +0 -264
- package/core/client/parser/blocks/namespace.ts +0 -207
- package/core/client/parser/blocks/page-parser.ts +0 -466
- package/core/client/parser/blocks/use-parser.ts +0 -646
- package/core/client/parser/layout-parser.ts +0 -158
- package/core/client/parser/reaction-parser.ts +0 -458
- package/core/client/parser/reaction-sugar.ts +0 -47
- package/core/client/parser/window-parser.ts +0 -294
- package/core/client/quality/SomaQualityRegistry.ts +0 -71
- package/core/client/runtime/serialize-page-state.ts +0 -152
- package/core/client/theme/harmony.ts +0 -429
- package/core/client/theme/scene-tokens.ts +0 -155
- package/core/client/theme/theme-axes.ts +0 -323
- package/core/client/theme/theme-engine.ts +0 -2390
- package/core/client/theme/tone-solver.ts +0 -119
- package/core/client/typography/typography-base.ts +0 -34
- package/core/server/headless/soma-headless-page.ts +0 -103
- package/core/server/host/page-response-mode.cjs +0 -96
- package/core/server/host/page-response-request.ts +0 -33
- package/core/server/host/request-origin.ts +0 -18
- package/core/server/host/soma-request-hook-host.stub.ts +0 -4
- package/core/server/infra/db/errors.ts +0 -11
- package/core/server/infra/db/mapper/PrismaSomaMapper.ts +0 -313
- package/core/server/infra/db/mapper/SomaBaseMapper.ts +0 -23
- package/core/server/infra/db/mapper/SomaMapperHooks.ts +0 -13
- package/core/server/infra/db/query/SomaQuery.ts +0 -149
- package/core/server/infra/db/service/SomaDbService.ts +0 -64
- package/core/server/infra/db/soma-db.ts +0 -120
- package/core/server/infra/db/types.ts +0 -21
- package/core/server/mock/node/catch-all.mjs +0 -35
- package/core/server/mock/node/cli.d.mts +0 -58
- package/core/server/mock/node/cli.mjs +0 -244
- package/core/server/mock/node/context.mjs +0 -167
- package/core/server/mock/node/environment-policy.mjs +0 -52
- package/core/server/mock/node/plugin-loader.mjs +0 -212
- package/core/server/mock/node/preload.mjs +0 -91
- package/core/server/mock/node/process-lifecycle.mjs +0 -236
- package/core/server/mock/node/public.d.mts +0 -110
- package/core/server/mock/node/public.mjs +0 -4
- package/core/server/mock/node/registry.mjs +0 -336
- package/core/server/mock/node/schema-generator.mjs +0 -1309
- package/core/server/mock/testing/host-harness.d.mts +0 -66
- package/core/server/mock/testing/host-harness.mjs +0 -276
- package/core/server/mock/testing/host-runtime.mjs +0 -48
- package/core/server/ooui.ts +0 -34
- package/core/shared/block-errors.ts +0 -11
- package/core/shared/component/derive-sample.ts +0 -290
- package/core/shared/component/field-lines.ts +0 -563
- package/core/shared/container-breakpoints.ts +0 -46
- package/core/shared/object-semantics.ts +0 -240
- package/core/shared/ooui-declaration.ts +0 -235
- package/core/shared/path-algebra.ts +0 -169
- package/core/shared/types/adaptive.types.ts +0 -109
- package/core/shared/types/layout-constraint.types.ts +0 -89
- package/core/shared/types/reaction.types.ts +0 -144
- package/core/shared/types/window.types.ts +0 -177
- package/dist/types/build/blocks/block-compile.d.ts +0 -52
- package/dist/types/build/blocks/block-container.d.ts +0 -40
- package/dist/types/build/blocks/block-loader.d.ts +0 -9
- package/dist/types/build/blocks/html-index.d.ts +0 -37
- package/dist/types/build/blocks/migrate-flat.d.ts +0 -49
- package/dist/types/build/compiler/precompiled-manifest-loader.d.ts +0 -5
- package/dist/types/build/component/pack-from-dir.d.ts +0 -17
- package/dist/types/build/component/package-loader.d.ts +0 -50
- package/dist/types/build/component-tree/binding-bridge.d.ts +0 -19
- package/dist/types/build/component-tree/migration-files.d.ts +0 -35
- package/dist/types/build/component-tree/migration.d.ts +0 -28
- package/dist/types/build/component-tree/validator.d.ts +0 -9
- package/dist/types/build/db/cli.d.ts +0 -2
- package/dist/types/build/db/emit-entities.d.ts +0 -5
- package/dist/types/build/db/emit-mappers.d.ts +0 -15
- package/dist/types/build/db/emit-prisma-schema.d.ts +0 -2
- package/dist/types/build/db/generate.d.ts +0 -7
- package/dist/types/build/db/ir.d.ts +0 -58
- package/dist/types/build/db/load-db-yaml.d.ts +0 -14
- package/dist/types/build/eject/component-eject.d.ts +0 -121
- package/dist/types/build/eject/component-upgrade.d.ts +0 -43
- package/dist/types/build/layout/constraint-solver.d.ts +0 -78
- package/dist/types/build/layout/css-emitter.d.ts +0 -18
- package/dist/types/build/layout/page-layout.d.ts +0 -24
- package/dist/types/build/ooui/artifact/artifact.types.d.ts +0 -180
- package/dist/types/build/ooui/artifact/emit-artifact.d.ts +0 -58
- package/dist/types/build/ooui/artifact/emit-html.d.ts +0 -53
- package/dist/types/build/ooui/artifact/index.d.ts +0 -5
- package/dist/types/build/ooui/artifact/spatial-tree.d.ts +0 -48
- package/dist/types/build/ooui/artifact/utility-class.d.ts +0 -46
- package/dist/types/build/ooui/composition/candidate.types.d.ts +0 -206
- package/dist/types/build/ooui/composition/control-model.d.ts +0 -37
- package/dist/types/build/ooui/composition/registry.d.ts +0 -66
- package/dist/types/build/ooui/composition/select.d.ts +0 -63
- package/dist/types/build/ooui/diagnostics/codes.d.ts +0 -28
- package/dist/types/build/ooui/diagnostics/error.d.ts +0 -135
- package/dist/types/build/ooui/diagnostics/format.d.ts +0 -51
- package/dist/types/build/ooui/diagnostics/index.d.ts +0 -25
- package/dist/types/build/ooui/diagnostics/issue.types.d.ts +0 -56
- package/dist/types/build/ooui/engine-slot.d.ts +0 -41
- package/dist/types/build/ooui/index.d.ts +0 -286
- package/dist/types/build/ooui/intent/derive-intent.d.ts +0 -32
- package/dist/types/build/ooui/intent/field-rules.d.ts +0 -99
- package/dist/types/build/ooui/intent/intent.types.d.ts +0 -318
- package/dist/types/build/ooui/intent/verb-events.d.ts +0 -70
- package/dist/types/build/ooui/page/budget.d.ts +0 -28
- package/dist/types/build/ooui/page/compose-page.d.ts +0 -41
- package/dist/types/build/ooui/page/index.d.ts +0 -4
- package/dist/types/build/ooui/page/page.types.d.ts +0 -264
- package/dist/types/build/ooui/page/region-row.d.ts +0 -16
- package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +0 -33
- package/dist/types/build/ooui/semantic/kernel.types.d.ts +0 -125
- package/dist/types/build/ooui/semantic/normalize.d.ts +0 -45
- package/dist/types/build/ooui/semantic/origin.types.d.ts +0 -95
- package/dist/types/build/ooui/semantic/role-alias.d.ts +0 -35
- package/dist/types/build/ooui/semantic/shorthand.d.ts +0 -60
- package/dist/types/build/ooui/semantic/surface.types.d.ts +0 -16
- package/dist/types/build/ooui/semantic/validate-request.d.ts +0 -19
- package/dist/types/build/ooui/spatial/emit-utility.d.ts +0 -43
- package/dist/types/build/ooui/spatial/ir.types.d.ts +0 -280
- package/dist/types/build/ooui/spatial/registry.d.ts +0 -110
- package/dist/types/build/ooui/spatial/solve.d.ts +0 -42
- package/dist/types/build/ooui/spatial/utility.types.d.ts +0 -191
- package/dist/types/build/ooui/trace/index.d.ts +0 -3
- package/dist/types/build/ooui/trace/render.d.ts +0 -42
- package/dist/types/build/ooui/trace/source.types.d.ts +0 -25
- package/dist/types/build/ooui/trace/trace.types.d.ts +0 -143
- package/dist/types/build/pack/pack-init.d.ts +0 -8
- package/dist/types/client/adaptive/flush-scheduler.d.ts +0 -13
- package/dist/types/client/adaptive/hysteresis.d.ts +0 -16
- package/dist/types/client/adaptive/index.d.ts +0 -5
- package/dist/types/client/adaptive/observer-pool.d.ts +0 -22
- package/dist/types/client/compiler/adaptive-compile.d.ts +0 -26
- package/dist/types/client/component/ai-catalog.d.ts +0 -122
- package/dist/types/client/component/catalog-examples.d.ts +0 -18
- package/dist/types/client/component/contract-compat.d.ts +0 -16
- package/dist/types/client/component/example-blocks.d.ts +0 -7
- package/dist/types/client/component/keyboard-matrix.d.ts +0 -24
- package/dist/types/client/component/pack-styles.d.ts +0 -43
- package/dist/types/client/component/style-features.d.ts +0 -26
- package/dist/types/client/component/theme-component-tokens.d.ts +0 -17
- package/dist/types/client/component/verify-pack.d.ts +0 -24
- package/dist/types/client/container/MiniProgramContainerAdapter.d.ts +0 -52
- package/dist/types/client/container/ReactNativeContainerAdapter.d.ts +0 -47
- package/dist/types/client/data/reaction-engine.d.ts +0 -21
- package/dist/types/client/data/window-engine.d.ts +0 -27
- package/dist/types/client/infra/i18n/DefaultI18n.d.ts +0 -7
- package/dist/types/client/infra/notify/DomNotifyService.d.ts +0 -17
- package/dist/types/client/infra/notify/INotifyTheme.d.ts +0 -12
- package/dist/types/client/parser/adaptive-parser.d.ts +0 -28
- package/dist/types/client/parser/blocks/namespace.d.ts +0 -72
- package/dist/types/client/parser/blocks/page-parser.d.ts +0 -30
- package/dist/types/client/parser/blocks/use-parser.d.ts +0 -124
- package/dist/types/client/parser/layout-parser.d.ts +0 -9
- package/dist/types/client/parser/reaction-parser.d.ts +0 -16
- package/dist/types/client/parser/reaction-sugar.d.ts +0 -13
- package/dist/types/client/parser/window-parser.d.ts +0 -25
- package/dist/types/client/quality/SomaQualityRegistry.d.ts +0 -31
- package/dist/types/client/runtime/serialize-page-state.d.ts +0 -10
- package/dist/types/client/theme/harmony.d.ts +0 -119
- package/dist/types/client/theme/scene-tokens.d.ts +0 -41
- package/dist/types/client/theme/theme-axes.d.ts +0 -174
- package/dist/types/client/theme/theme-engine.d.ts +0 -119
- package/dist/types/client/theme/tone-solver.d.ts +0 -51
- package/dist/types/client/typography/typography-base.d.ts +0 -15
- package/dist/types/server/headless/soma-headless-page.d.ts +0 -12
- package/dist/types/server/host/page-response-request.d.ts +0 -8
- package/dist/types/server/host/request-origin.d.ts +0 -1
- package/dist/types/server/host/soma-request-hook-host.stub.d.ts +0 -2
- package/dist/types/server/infra/db/errors.d.ts +0 -5
- package/dist/types/server/infra/db/mapper/PrismaSomaMapper.d.ts +0 -77
- package/dist/types/server/infra/db/mapper/SomaBaseMapper.d.ts +0 -20
- package/dist/types/server/infra/db/mapper/SomaMapperHooks.d.ts +0 -12
- package/dist/types/server/infra/db/query/SomaQuery.d.ts +0 -42
- package/dist/types/server/infra/db/service/SomaDbService.d.ts +0 -24
- package/dist/types/server/infra/db/soma-db.d.ts +0 -45
- package/dist/types/server/infra/db/types.d.ts +0 -18
- package/dist/types/server/ooui.d.ts +0 -18
- package/dist/types/shared/block-errors.d.ts +0 -5
- package/dist/types/shared/component/derive-sample.d.ts +0 -37
- package/dist/types/shared/component/field-lines.d.ts +0 -19
- package/dist/types/shared/container-breakpoints.d.ts +0 -42
- package/dist/types/shared/object-semantics.d.ts +0 -42
- package/dist/types/shared/ooui-declaration.d.ts +0 -135
- package/dist/types/shared/path-algebra.d.ts +0 -56
- package/dist/types/shared/types/adaptive.types.d.ts +0 -88
- package/dist/types/shared/types/layout-constraint.types.d.ts +0 -53
- package/dist/types/shared/types/reaction.types.d.ts +0 -115
- package/dist/types/shared/types/window.types.d.ts +0 -171
- package/next.config.js +0 -387
- package/proxy.ts +0 -62
- /package/{app → host-next/app}/[...path]/page.tsx +0 -0
- /package/{app → host-next/app}/components/SomaHostPage.tsx +0 -0
- /package/{app → host-next/app}/components/SomaHydrationShell.tsx +0 -0
- /package/{app → host-next/app}/components/SomaPageClientBoundary.tsx +0 -0
- /package/{app → host-next/app}/favicon.ico/route.ts +0 -0
- /package/{app → host-next/app}/layout.tsx +0 -0
- /package/{app → host-next/app}/page.tsx +0 -0
- /package/{app → host-next/app}/soma/[...path]/route.ts +0 -0
- /package/{app → host-next/app}/soma/route.ts +0 -0
|
@@ -3,22 +3,21 @@
|
|
|
3
3
|
// 一个组件实例 = 一个复用现有引擎的"迷你页面":
|
|
4
4
|
// 实例作用域根(props + ctrl)→ ScopeResolver → ManifestCompiler
|
|
5
5
|
// → RenderEngine + EventEngine(经 Scoped 适配器隔离锚点)。
|
|
6
|
-
//
|
|
6
|
+
// 页面与实例之间只有两条通道:
|
|
7
7
|
// props 下行(页面路径 → 实例作用域,prop 源变更触发实例整树重渲);
|
|
8
|
-
// emit 上行(契约 emit → 页面 Pipeline
|
|
9
|
-
// model 回写(契约 mode: 'model' 的 prop 在实例内被改写 → 写回绑定它的数据路径,
|
|
10
|
-
// 走页面响应式代理,于是 props 下行的 watch 照常把同一个值推回实例,见 installModelProps)。
|
|
8
|
+
// emit 上行(契约 emit → 页面 Pipeline,四动词与修饰符原样可用)。
|
|
11
9
|
//
|
|
12
|
-
// 设计规范:soma-core/doc/soma
|
|
10
|
+
// 设计规范:soma-core/doc/soma 作用域清单树.md、soma-ui/doc/soma 组件契约.md。
|
|
13
11
|
|
|
14
12
|
import { SomaManifestCompiler } from '../compiler/manifest-compiler';
|
|
15
13
|
import { isKnownDomEvent } from '../parser/pipeline-parser';
|
|
16
14
|
import { SomaRenderEngine } from '../engine/render-engine';
|
|
17
15
|
import { SomaEventEngine } from '../engine/event-engine';
|
|
16
|
+
import type { SomaConfirmSpec } from '../../shared/types/event.types';
|
|
18
17
|
import { SomaScopeResolver } from '../engine/scope-resolver';
|
|
19
18
|
import { SomaRowScope } from '../engine/row-scope';
|
|
19
|
+
import { getSomaRowScope } from '../engine/row-range';
|
|
20
20
|
import { SomaEmitEvent } from '../engine/emit-event';
|
|
21
|
-
import { SomaCompositionGate } from '../engine/dom-renderer';
|
|
22
21
|
import type { SomaScheduler } from '../scheduler/SomaScheduler';
|
|
23
22
|
import type { SomaDiagnostics } from '../diagnostics/SomaDiagnostics';
|
|
24
23
|
import type { SomaRuntimeManifest } from '../../shared/types/manifest.types';
|
|
@@ -29,7 +28,6 @@ import type {
|
|
|
29
28
|
ShowValue,
|
|
30
29
|
UiConfig,
|
|
31
30
|
} from '../../shared/types/ui-config.types';
|
|
32
|
-
import type { SomaContractProp } from '../../shared/types/component-contract.types';
|
|
33
31
|
import type { SomaComponentDefinition } from './component-definition.types';
|
|
34
32
|
import { SOMA_COMPONENT_CTRL_KEY } from './component-definition.types';
|
|
35
33
|
import { SomaComponentRegistry } from './component-registry';
|
|
@@ -42,19 +40,14 @@ import {
|
|
|
42
40
|
} from './component-expander';
|
|
43
41
|
import { SomaScopedContainerAdapter, SOMA_SCOPE_ATTR } from './scoped-adapter';
|
|
44
42
|
import type { SomaComponentDefaults } from './component-defaults';
|
|
45
|
-
import { ensureStyleFeatures } from '
|
|
46
|
-
import type { PackStyleOptions } from '
|
|
43
|
+
import { ensureStyleFeatures } from '../styles/style-features';
|
|
44
|
+
import type { PackStyleOptions } from '../styles/pack-styles';
|
|
45
|
+
import type { SomaRuntimeObserver } from '../observability/runtime-observer';
|
|
47
46
|
import { COMPONENT_TREE_CAPABILITIES, type TreeArtifact, type StructurePlan } from '../../shared/types/component-tree-artifact.types';
|
|
48
47
|
import { SomaComponentTreeError } from '../../shared/component-tree-errors';
|
|
49
48
|
import { assertDefinitionPreparation } from '../../shared/component-tree-artifact';
|
|
50
49
|
import { assertPreparedStructureProps, withPreparedStructureProps } from './structure-adapter';
|
|
51
|
-
import {
|
|
52
|
-
defaultPipeRegistry,
|
|
53
|
-
hasPipes,
|
|
54
|
-
parsePipedValue,
|
|
55
|
-
type ParsedPipedValue,
|
|
56
|
-
type SomaPipeRegistry,
|
|
57
|
-
} from '../pipes/pipe-registry';
|
|
50
|
+
import { bindSomaProjection, getSomaProjectionReleaseOrder, revokeSomaProjections } from './projection-registry';
|
|
58
51
|
|
|
59
52
|
const MAX_EXPANSION_ROUNDS = 8;
|
|
60
53
|
|
|
@@ -83,33 +76,22 @@ export interface SomaComponentManagerOptions {
|
|
|
83
76
|
* validateComponentDefaults 保证,这里只做取值。
|
|
84
77
|
*/
|
|
85
78
|
componentDefaults?: SomaComponentDefaults;
|
|
79
|
+
/** 观测埋点(M03):仅 observe: true 时传入;缺省不采集 */
|
|
80
|
+
observer?: Pick<SomaRuntimeObserver, 'recordActivation' | 'recordEmit'>;
|
|
81
|
+
/** 文案服务:区域不可用的受控提示按当前显示语言取词条 */
|
|
82
|
+
i18n?: Pick<import('../infra/i18n/II18n').II18n, 't'>;
|
|
86
83
|
/** 特性分片注入用的 CSP nonce(M-3) */
|
|
87
84
|
styleOptions?: PackStyleOptions;
|
|
85
|
+
/** 分级确认执行口(typed / consent;与页面级事件引擎同一个,缺省则组件内回落 plain) */
|
|
86
|
+
confirmGraded?: (spec: SomaConfirmSpec) => boolean | Promise<boolean>;
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
/** 作用域读取器:绑定路径求值 + var
|
|
89
|
+
/** 作用域读取器:绑定路径求值 + var 判定(页面作用域 / 行作用域两种实现) */
|
|
91
90
|
interface ScopeReader {
|
|
92
91
|
read(path: string): unknown;
|
|
92
|
+
readLatest?(path: string): unknown;
|
|
93
93
|
hasVar(seg: string): boolean;
|
|
94
|
-
|
|
95
|
-
locale(): Record<string, unknown> | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* 把值写到绑定路径(只给 mode: 'model' 的 prop 用)。
|
|
98
|
-
* 写进去返回 null;写不了返回原因(进告警文案),此时什么都不写。
|
|
99
|
-
*/
|
|
100
|
-
write(path: string, value: unknown): string | null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* props 管道求值的出处:告警点名到实例锚点与组件名。
|
|
105
|
-
* `warned` 由管理器持有、跨实例共享:行内实例逐行求值、父实例每次重渲都会重算子组件 props,
|
|
106
|
-
* 同一锚点同一 prop 同一声明只告警一次,不然一张表刷一屏。
|
|
107
|
-
*/
|
|
108
|
-
interface PropPipeSite {
|
|
109
|
-
instanceId: string;
|
|
110
|
-
componentName: string;
|
|
111
|
-
pipes: SomaPipeRegistry;
|
|
112
|
-
warned: Set<string>;
|
|
94
|
+
readRows(): readonly SomaRowScope[];
|
|
113
95
|
}
|
|
114
96
|
|
|
115
97
|
interface StaticInstanceDecl {
|
|
@@ -119,19 +101,6 @@ interface StaticInstanceDecl {
|
|
|
119
101
|
propsDecl: Record<string, unknown>;
|
|
120
102
|
}
|
|
121
103
|
|
|
122
|
-
/**
|
|
123
|
-
* 行内实例对页面作用域路径的订阅(见 watchRowPageProps)。
|
|
124
|
-
* `propsDecl` / `rowData` 每次行渲染都刷新:键控列表复用行时实例不重建、行数据却换了,
|
|
125
|
-
* 页面路径变更时按最新的这一份重解析,行字段 prop 才不会被打回旧行值。
|
|
126
|
-
*/
|
|
127
|
-
interface RowPageWatch {
|
|
128
|
-
/** 订阅的页面路径(已解析、排序后拼接):行渲染时声明里的页面路径没变就沿用原订阅 */
|
|
129
|
-
paths: string;
|
|
130
|
-
propsDecl: Record<string, unknown>;
|
|
131
|
-
rowData: unknown;
|
|
132
|
-
dispose: () => void;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
104
|
export class SomaComponentManager {
|
|
136
105
|
private readonly registry: SomaComponentRegistry;
|
|
137
106
|
private readonly scheduler?: SomaScheduler;
|
|
@@ -139,6 +108,9 @@ export class SomaComponentManager {
|
|
|
139
108
|
private readonly pipeRegistry?: import('../pipes/pipe-registry').SomaPipeRegistry;
|
|
140
109
|
private readonly componentDefaults?: SomaComponentDefaults;
|
|
141
110
|
private readonly styleOptions?: PackStyleOptions;
|
|
111
|
+
private readonly observer?: Pick<SomaRuntimeObserver, 'recordActivation' | 'recordEmit'>;
|
|
112
|
+
private readonly i18n?: Pick<import('../infra/i18n/II18n').II18n, 't'>;
|
|
113
|
+
private readonly confirmGraded?: (spec: SomaConfirmSpec) => boolean | Promise<boolean>;
|
|
142
114
|
private readonly expander = new SomaComponentExpander();
|
|
143
115
|
private readonly treeArtifact?: TreeArtifact;
|
|
144
116
|
private readonly preparedDefinitions = new Map<string, SomaComponentDefinition>();
|
|
@@ -148,16 +120,6 @@ export class SomaComponentManager {
|
|
|
148
120
|
private readonly instances = new Set<SomaComponentInstance>();
|
|
149
121
|
private readonly hostInstances = new WeakMap<HTMLElement, SomaComponentInstance>();
|
|
150
122
|
private readonly watchDisposers: Array<() => void> = [];
|
|
151
|
-
/** 行内实例的页面路径订阅,随实例释放(releaseHost)与管理器销毁一起撤掉 */
|
|
152
|
-
private readonly rowPageWatches = new Map<SomaComponentInstance, RowPageWatch>();
|
|
153
|
-
/** props 管道告警的去重键(见 PropPipeSite) */
|
|
154
|
-
private readonly warnedPropPipes = new Set<string>();
|
|
155
|
-
/**
|
|
156
|
-
* 正在构造实例的宿主(见 constructInstance)。控制器工厂里改写 model prop 会同步回写到父实例、
|
|
157
|
-
* 触发父整树重渲,重渲又为这个宿主调 mountChild——此刻 hostInstances 里还没有它,
|
|
158
|
-
* 不拦就会给同一个宿主再建一个实例(旧的那个带着监听器泄漏)。
|
|
159
|
-
*/
|
|
160
|
-
private readonly constructingHosts = new WeakSet<HTMLElement>();
|
|
161
123
|
private page: SomaComponentPageRuntime | null = null;
|
|
162
124
|
|
|
163
125
|
constructor(options: SomaComponentManagerOptions) {
|
|
@@ -168,6 +130,9 @@ export class SomaComponentManager {
|
|
|
168
130
|
this.pipeRegistry = options.pipeRegistry;
|
|
169
131
|
this.componentDefaults = options.componentDefaults;
|
|
170
132
|
this.styleOptions = options.styleOptions;
|
|
133
|
+
this.observer = options.observer;
|
|
134
|
+
this.i18n = options.i18n;
|
|
135
|
+
this.confirmGraded = options.confirmGraded;
|
|
171
136
|
}
|
|
172
137
|
|
|
173
138
|
/**
|
|
@@ -225,7 +190,8 @@ export class SomaComponentManager {
|
|
|
225
190
|
this.markEmitRoutes(page);
|
|
226
191
|
|
|
227
192
|
for (const decl of this.staticDecls) {
|
|
228
|
-
const
|
|
193
|
+
const row = getSomaRowScope(decl.host);
|
|
194
|
+
const reader = row ? this.createRowReader(page, row) : this.createPageReader(page);
|
|
229
195
|
const instance = this.mountInstance(decl.host, decl.instanceId, decl.def, decl.propsDecl, reader);
|
|
230
196
|
this.registerPropWatches(page, decl, instance, reader);
|
|
231
197
|
}
|
|
@@ -247,7 +213,7 @@ export class SomaComponentManager {
|
|
|
247
213
|
*
|
|
248
214
|
* 为什么需要它:数据对象层是**异步**取数的(首屏不阻塞),而自治组件在取数完成前
|
|
249
215
|
* 就已经挂载。页面侧的 `renderEngine.render()` 重渲的是页面模板,进不到组件实例
|
|
250
|
-
* 自己的渲染引擎——于是一个 `data_object`
|
|
216
|
+
* 自己的渲染引擎——于是一个 `data_object` 形态的表单组件在数据到达后
|
|
251
217
|
* 仍然显示着它挂载那一刻看到的空字典:一张空表单,没有任何报错。
|
|
252
218
|
*
|
|
253
219
|
* 组件的 ctrl 派生 getter 本来就是幂等的纯读,重算一遍是安全的。
|
|
@@ -258,18 +224,45 @@ export class SomaComponentManager {
|
|
|
258
224
|
}
|
|
259
225
|
}
|
|
260
226
|
|
|
227
|
+
/** 本次存活实例的有限初始化;初始化重渲新建的子实例也在同一生命周期内收敛。 */
|
|
228
|
+
async whenInitialized(): Promise<void> {
|
|
229
|
+
while (true) {
|
|
230
|
+
const pending = [...this.instances].filter((instance) => !instance.isInitialized());
|
|
231
|
+
if (pending.length === 0) return;
|
|
232
|
+
await Promise.all(pending.map((instance) => instance.whenInitialized()));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
isInitialized(): boolean {
|
|
237
|
+
return [...this.instances].every((instance) => instance.isInitialized());
|
|
238
|
+
}
|
|
239
|
+
|
|
261
240
|
destroy(): void {
|
|
241
|
+
const pageRoot = this.page?.container;
|
|
242
|
+
const roots = new Set([
|
|
243
|
+
...this.staticDecls.map((decl) => decl.host),
|
|
244
|
+
...[...this.instances].map((instance) => instance.getHost()),
|
|
245
|
+
].filter(root => !pageRoot?.contains(root)));
|
|
246
|
+
if (pageRoot) revokeSomaProjections(pageRoot);
|
|
247
|
+
for (const root of roots) revokeSomaProjections(root);
|
|
262
248
|
for (const dispose of this.watchDisposers) {
|
|
263
249
|
dispose();
|
|
264
250
|
}
|
|
265
251
|
this.watchDisposers.length = 0;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
252
|
+
if (pageRoot) this.releaseSubtree(pageRoot);
|
|
253
|
+
for (const root of roots) this.releaseSubtree(root);
|
|
254
|
+
const ordered = [...this.instances].map(instance => {
|
|
255
|
+
let depth = 0;
|
|
256
|
+
for (let ancestor = instance.getHost().parentElement; ancestor; ancestor = ancestor.parentElement) depth += 1;
|
|
257
|
+
return { instance, depth };
|
|
258
|
+
}).sort((first, second) => second.depth - first.depth);
|
|
259
|
+
for (const { instance } of ordered) {
|
|
260
|
+
this.releaseHost(instance.getHost());
|
|
261
|
+
}
|
|
262
|
+
for (const { host } of this.staticDecls) {
|
|
263
|
+
host.removeAttribute(SOMA_COMPONENT_ATTR);
|
|
264
|
+
host.removeAttribute(SOMA_COMPONENT_READY_ATTR);
|
|
265
|
+
host.removeAttribute('data-soma-id');
|
|
273
266
|
}
|
|
274
267
|
this.instances.clear();
|
|
275
268
|
this.staticDecls = [];
|
|
@@ -290,16 +283,15 @@ export class SomaComponentManager {
|
|
|
290
283
|
* 子实例(applyChildComponent)——两者都登记在 hostInstances 上,一次遍历全收。
|
|
291
284
|
*/
|
|
292
285
|
private releaseSubtree(root: HTMLElement): void {
|
|
286
|
+
const hosts = getSomaProjectionReleaseOrder(root);
|
|
287
|
+
revokeSomaProjections(root);
|
|
293
288
|
if (this.instances.size === 0) {
|
|
294
289
|
return;
|
|
295
290
|
}
|
|
296
291
|
// 被摘除的行根元素自己就可能是组件宿主(行模板根 = 组件)
|
|
297
|
-
for (const host of
|
|
298
|
-
root.querySelectorAll<HTMLElement>(`[${SOMA_COMPONENT_ATTR}]`),
|
|
299
|
-
).reverse()) {
|
|
292
|
+
for (const host of hosts) {
|
|
300
293
|
this.releaseHost(host);
|
|
301
294
|
}
|
|
302
|
-
this.releaseHost(root);
|
|
303
295
|
}
|
|
304
296
|
|
|
305
297
|
private releaseHost(host: HTMLElement): void {
|
|
@@ -309,8 +301,6 @@ export class SomaComponentManager {
|
|
|
309
301
|
}
|
|
310
302
|
this.hostInstances.delete(host);
|
|
311
303
|
this.instances.delete(instance);
|
|
312
|
-
this.rowPageWatches.get(instance)?.dispose();
|
|
313
|
-
this.rowPageWatches.delete(instance);
|
|
314
304
|
instance.destroy();
|
|
315
305
|
}
|
|
316
306
|
|
|
@@ -330,15 +320,11 @@ export class SomaComponentManager {
|
|
|
330
320
|
return;
|
|
331
321
|
}
|
|
332
322
|
|
|
333
|
-
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
const reader = this.createRowReader(this.page, rowData);
|
|
323
|
+
const reader = this.createRowReader(this.page, rowData === undefined ? getSomaRowScope(element) : rowData);
|
|
337
324
|
const existing = this.hostInstances.get(element);
|
|
338
325
|
if (existing) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
existing.setProps(withPreparedStructureProps(element, resolveProps(propsDecl, reader, existing.def, this.defaultsFor(existing.def), this.pipeSite(element.getAttribute('data-soma-id') ?? name, existing.def)), propsDecl));
|
|
326
|
+
existing.setSourceReader(this.createPropsReader(element, propsDecl, reader, existing.def), reader.readRows);
|
|
327
|
+
existing.setProps(withPreparedStructureProps(element, resolveProps(propsDecl, reader, existing.def, this.defaultsFor(existing.def)), propsDecl));
|
|
342
328
|
return;
|
|
343
329
|
}
|
|
344
330
|
|
|
@@ -348,63 +334,7 @@ export class SomaComponentManager {
|
|
|
348
334
|
}
|
|
349
335
|
const def = this.registry.get(name);
|
|
350
336
|
this.expandHost(element, def, propsDecl);
|
|
351
|
-
|
|
352
|
-
this.watchRowPageProps(element, instance, propsDecl, rowData, this.page);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* 行内实例订阅 props 声明里的页面作用域路径(首段是页面 bind 的 var,如 `page.kw`、管道实参 `page.unit`):
|
|
357
|
-
* 路径变更 → 按这一行最新的声明与行数据重解析 → 只更新这个实例,列表不重渲。
|
|
358
|
-
*
|
|
359
|
-
* 列表绑定只 watch 自己的数据源(`page.groups`),行模板里引用的页面路径不在任何 watch 里,
|
|
360
|
-
* 不订阅的话行内实例只在整个列表重渲时才拿到页面路径的新值。
|
|
361
|
-
* 行变量(`g.kw`)与对象作用域变量读的是行数据,行数据不经响应式代理,仍由列表重渲驱动,不订阅。
|
|
362
|
-
*
|
|
363
|
-
* 订阅随实例走:releaseHost 与 destroy 撤掉;行复用时声明里的页面路径没变就沿用原订阅,只换声明与行数据。
|
|
364
|
-
* 与静态实例(registerPropWatches)同一套路径收集(collectBindingPaths)与重解析(resolveProps 带 Host 默认)。
|
|
365
|
-
*/
|
|
366
|
-
private watchRowPageProps(
|
|
367
|
-
host: HTMLElement,
|
|
368
|
-
instance: SomaComponentInstance,
|
|
369
|
-
propsDecl: Record<string, unknown>,
|
|
370
|
-
rowData: unknown,
|
|
371
|
-
page: SomaComponentPageRuntime,
|
|
372
|
-
): void {
|
|
373
|
-
const collected = new Set<string>();
|
|
374
|
-
collectBindingPaths(propsDecl, page.resolver, collected);
|
|
375
|
-
const resolved = new Set<string>();
|
|
376
|
-
for (const path of collected) {
|
|
377
|
-
const first = path.split('.')[0];
|
|
378
|
-
// 页面 bind 的 var 映射到根(路径为空);显式键行作用域的别名同名时以行变量为准
|
|
379
|
-
if (page.resolver.getVarPath(first) !== '' || (rowData instanceof SomaRowScope && rowData.has(first))) {
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
resolved.add(page.resolver.resolvePath(path));
|
|
383
|
-
}
|
|
384
|
-
const paths = [...resolved].sort().join('\n');
|
|
385
|
-
const current = this.rowPageWatches.get(instance);
|
|
386
|
-
if (current && current.paths === paths) {
|
|
387
|
-
current.propsDecl = propsDecl;
|
|
388
|
-
current.rowData = rowData;
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
current?.dispose();
|
|
392
|
-
this.rowPageWatches.delete(instance);
|
|
393
|
-
if (resolved.size === 0) {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
const watch: RowPageWatch = { paths, propsDecl, rowData, dispose: () => {} };
|
|
397
|
-
const instanceId = host.getAttribute('data-soma-id') ?? instance.def.contract.name;
|
|
398
|
-
const disposers = [...resolved].map((path) => page.renderEngine.watch(path, () => {
|
|
399
|
-
// 已撤掉或换掉的订阅不再下发:属性观察者撤订阅是换一张新表,正在遍历的那一轮通知仍会调到这里
|
|
400
|
-
if (this.rowPageWatches.get(instance) !== watch) return;
|
|
401
|
-
const rowReader = this.createRowReader(page, watch.rowData);
|
|
402
|
-
instance.setProps(withPreparedStructureProps(host, resolveProps(watch.propsDecl, rowReader, instance.def, this.defaultsFor(instance.def), this.pipeSite(instanceId, instance.def)), watch.propsDecl));
|
|
403
|
-
}));
|
|
404
|
-
watch.dispose = () => {
|
|
405
|
-
for (const dispose of disposers) dispose();
|
|
406
|
-
};
|
|
407
|
-
this.rowPageWatches.set(instance, watch);
|
|
337
|
+
this.mountInstance(element, instanceId, def, propsDecl, reader);
|
|
408
338
|
}
|
|
409
339
|
|
|
410
340
|
// ─── 实例装配 ──────────────────────────────────────────────
|
|
@@ -416,39 +346,33 @@ export class SomaComponentManager {
|
|
|
416
346
|
propsDecl: Record<string, unknown>,
|
|
417
347
|
reader: ScopeReader,
|
|
418
348
|
): SomaComponentInstance {
|
|
419
|
-
const
|
|
349
|
+
const readProps = this.createPropsReader(host, propsDecl, reader, def);
|
|
350
|
+
const instance = new SomaComponentInstance({
|
|
420
351
|
host,
|
|
421
352
|
instanceId,
|
|
422
353
|
def,
|
|
423
|
-
initialProps: withPreparedStructureProps(host, resolveProps(propsDecl, reader, def, this.defaultsFor(def)
|
|
354
|
+
initialProps: withPreparedStructureProps(host, resolveProps(propsDecl, reader, def, this.defaultsFor(def)), propsDecl),
|
|
355
|
+
readProps,
|
|
356
|
+
readRows: reader.readRows,
|
|
424
357
|
scheduler: this.scheduler,
|
|
425
358
|
diagnostics: this.diagnostics,
|
|
426
359
|
pipeRegistry: this.pipeRegistry,
|
|
427
360
|
styleOptions: this.styleOptions,
|
|
428
|
-
|
|
361
|
+
...(this.confirmGraded ? { confirmGraded: this.confirmGraded } : {}),
|
|
362
|
+
services: this.filterServices(def, instanceId),
|
|
429
363
|
dispatchEmit: (emitName, payload) => this.dispatchEmit(instanceId, host, emitName, payload),
|
|
430
|
-
writeModel: createModelWriter(instanceId, def, propsDecl, reader),
|
|
431
364
|
registry: this.registry,
|
|
432
365
|
expandNested: (root) => this.expandNestedTemplates(root),
|
|
433
366
|
mountChild: (parent, childHost, childPropsDecl, rowData) =>
|
|
434
367
|
this.applyChildComponent(parent, childHost, childPropsDecl, rowData),
|
|
435
368
|
releaseSubtree: (removedRoot) => this.releaseSubtree(removedRoot),
|
|
436
|
-
})
|
|
369
|
+
});
|
|
437
370
|
this.instances.add(instance);
|
|
438
371
|
this.hostInstances.set(host, instance);
|
|
372
|
+
this.observer?.recordActivation({ kind: 'component', name: def.contract.name });
|
|
439
373
|
return instance;
|
|
440
374
|
}
|
|
441
375
|
|
|
442
|
-
/** 构造期间把宿主登记进 constructingHosts(重入原因见该字段注释),构造抛错也要摘掉 */
|
|
443
|
-
private constructInstance(host: HTMLElement, build: () => SomaComponentInstance): SomaComponentInstance {
|
|
444
|
-
this.constructingHosts.add(host);
|
|
445
|
-
try {
|
|
446
|
-
return build();
|
|
447
|
-
} finally {
|
|
448
|
-
this.constructingHosts.delete(host);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
376
|
/**
|
|
453
377
|
* 父组件模板里的真实子组件:props 在父实例作用域求值,emit 回到父实例事件清单。
|
|
454
378
|
* 这是通用组合能力;父子双方仍各自拥有独立 controller / render / event 生命周期。
|
|
@@ -462,37 +386,41 @@ export class SomaComponentManager {
|
|
|
462
386
|
const name = element.getAttribute(SOMA_COMPONENT_ATTR);
|
|
463
387
|
const childId = element.getAttribute(SOMA_CHILD_COMPONENT_ID_ATTR);
|
|
464
388
|
if (!name || !childId) return;
|
|
465
|
-
if (this.constructingHosts.has(element)) return;
|
|
466
389
|
|
|
467
|
-
const reader = this.createChildReader(parent, rowData);
|
|
390
|
+
const reader = this.createChildReader(parent, rowData === undefined ? getSomaRowScope(element) : rowData);
|
|
468
391
|
const existing = this.hostInstances.get(element);
|
|
469
392
|
if (existing) {
|
|
470
|
-
existing.
|
|
393
|
+
existing.setSourceReader(this.createPropsReader(element, propsDecl, reader, existing.def), reader.readRows);
|
|
394
|
+
existing.setProps(withPreparedStructureProps(element, resolveProps(propsDecl, reader, existing.def, this.defaultsFor(existing.def)), propsDecl));
|
|
471
395
|
return;
|
|
472
396
|
}
|
|
473
397
|
|
|
474
398
|
const def = this.registry.get(name);
|
|
475
399
|
this.expandHost(element, def, propsDecl);
|
|
476
|
-
const
|
|
400
|
+
const readProps = this.createPropsReader(element, propsDecl, reader, def);
|
|
401
|
+
const child = new SomaComponentInstance({
|
|
477
402
|
host: element,
|
|
478
403
|
instanceId: childId,
|
|
479
404
|
def,
|
|
480
|
-
initialProps: withPreparedStructureProps(element, resolveProps(propsDecl, reader, def, this.defaultsFor(def)
|
|
405
|
+
initialProps: withPreparedStructureProps(element, resolveProps(propsDecl, reader, def, this.defaultsFor(def)), propsDecl),
|
|
406
|
+
readProps,
|
|
407
|
+
readRows: reader.readRows,
|
|
481
408
|
scheduler: this.scheduler,
|
|
482
409
|
diagnostics: this.diagnostics,
|
|
483
410
|
pipeRegistry: this.pipeRegistry,
|
|
484
411
|
styleOptions: this.styleOptions,
|
|
485
|
-
|
|
412
|
+
...(this.confirmGraded ? { confirmGraded: this.confirmGraded } : {}),
|
|
413
|
+
services: this.filterServices(def, childId),
|
|
486
414
|
registry: this.registry,
|
|
487
415
|
expandNested: (root) => this.expandNestedTemplates(root),
|
|
488
416
|
mountChild: (owner, childHost, childProps, nestedRow) =>
|
|
489
417
|
this.applyChildComponent(owner, childHost, childProps, nestedRow),
|
|
490
418
|
releaseSubtree: (removedRoot) => this.releaseSubtree(removedRoot),
|
|
491
419
|
dispatchEmit: (emitName, payload) => parent.dispatchChildEmit(childId, element, emitName, payload),
|
|
492
|
-
|
|
493
|
-
}));
|
|
420
|
+
});
|
|
494
421
|
this.instances.add(child);
|
|
495
422
|
this.hostInstances.set(element, child);
|
|
423
|
+
this.observer?.recordActivation({ kind: 'component', name: def.contract.name });
|
|
496
424
|
}
|
|
497
425
|
|
|
498
426
|
/**
|
|
@@ -591,25 +519,41 @@ export class SomaComponentManager {
|
|
|
591
519
|
private createChildReader(parent: SomaComponentInstance, rowData: unknown): ScopeReader {
|
|
592
520
|
return {
|
|
593
521
|
read: (path: string) => parent.read(path, rowData),
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
write: (path: string, value: unknown) => parent.writeBoundPath(path, value, rowData),
|
|
522
|
+
readLatest: (path: string) => parent.readLatest(path, rowData),
|
|
523
|
+
hasVar: (seg: string) => rowData instanceof SomaRowScope && rowData.has(seg) || parent.hasVar(seg),
|
|
524
|
+
readRows: () => [...new Set([...parent.readRows(), ...collectRowScopes(rowData)])],
|
|
598
525
|
};
|
|
599
526
|
}
|
|
600
527
|
|
|
601
|
-
|
|
602
|
-
|
|
528
|
+
private createPropsReader(
|
|
529
|
+
host: HTMLElement, propsDecl: Record<string, unknown>, reader: ScopeReader, def: SomaComponentDefinition,
|
|
530
|
+
): () => Record<string, unknown> {
|
|
531
|
+
const source = reader.readLatest ? { ...reader, read: reader.readLatest } : reader;
|
|
532
|
+
return () => withPreparedStructureProps(host, resolveProps(propsDecl, source, def, this.defaultsFor(def)), propsDecl);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* 自治组件服务注入:按定义白名单过滤页面服务表(白名单外不可见)。
|
|
537
|
+
*
|
|
538
|
+
* `region` 例外:页面服务表里它是 `(scopeId, instanceId) => 端口`,按**调用实例**包成 `(scopeId) => 端口`,
|
|
539
|
+
* 写者身份就此绑死在实例 id(页面 `data-soma-id`)上,组件无法冒用别的实例的写权。
|
|
540
|
+
*/
|
|
541
|
+
private filterServices(def: SomaComponentDefinition, instanceId: string): Record<string, unknown> | undefined {
|
|
603
542
|
if (!def.services?.length) {
|
|
604
543
|
return undefined;
|
|
605
544
|
}
|
|
606
545
|
const source = (this.page?.services ?? {}) as Record<string, unknown>;
|
|
607
546
|
const filtered: Record<string, unknown> = {};
|
|
608
547
|
for (const name of def.services) {
|
|
609
|
-
if (name in source) {
|
|
610
|
-
filtered[name] = source[name];
|
|
611
|
-
} else {
|
|
548
|
+
if (!(name in source)) {
|
|
612
549
|
console.warn(`[soma-core][组件] 组件 "${def.contract.name}" 声明的服务 "${name}" 不存在于页面运行时`);
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
if (name === 'region') {
|
|
553
|
+
const factory = source.region as (scopeId: string, instanceId: string) => unknown;
|
|
554
|
+
filtered.region = (scopeId: string) => factory(scopeId, instanceId);
|
|
555
|
+
} else {
|
|
556
|
+
filtered[name] = source[name];
|
|
613
557
|
}
|
|
614
558
|
}
|
|
615
559
|
return filtered;
|
|
@@ -617,6 +561,7 @@ export class SomaComponentManager {
|
|
|
617
561
|
|
|
618
562
|
/** 页面订阅了的契约 emit → 走页面 Pipeline;未订阅静默丢弃(契约规范第 4 章) */
|
|
619
563
|
private dispatchEmit(instanceId: string, host: HTMLElement, emitName: string, payload: unknown): void {
|
|
564
|
+
this.observer?.recordEmit({ component: this.hostInstances.get(host)?.def.contract.name ?? instanceId, event: emitName });
|
|
620
565
|
const config = this.page?.manifest.eventIndex.get(`${emitName}:${instanceId}`);
|
|
621
566
|
if (!config?.emitRoute || !this.page) {
|
|
622
567
|
return;
|
|
@@ -627,17 +572,13 @@ export class SomaComponentManager {
|
|
|
627
572
|
/**
|
|
628
573
|
* 把页面事件清单中"实例id.契约emit名"的条目标记为 emit 路由。
|
|
629
574
|
* 覆盖静态实例与行模板内的实例(模板内容递归扫描)。
|
|
630
|
-
* 标完对没走上 emit 路由的订阅告警(见 warnUnroutedSubscriptions)。
|
|
631
575
|
*/
|
|
632
576
|
private markEmitRoutes(page: SomaComponentPageRuntime): void {
|
|
633
577
|
const hosts = new Map<string, string>();
|
|
634
578
|
collectComponentHosts(page.container, hosts);
|
|
635
579
|
|
|
636
|
-
// 宿主写着组件名、但注册表里没有它的那些:先攒起来,循环结束统一点名(见 warnUnregisteredHosts)。
|
|
637
|
-
const unregistered = new Map<string, string[]>();
|
|
638
580
|
for (const [instanceId, name] of hosts) {
|
|
639
581
|
if (!this.registry.has(name)) {
|
|
640
|
-
unregistered.set(name, [...(unregistered.get(name) ?? []), instanceId]);
|
|
641
582
|
continue;
|
|
642
583
|
}
|
|
643
584
|
const contract = this.registry.get(name).contract;
|
|
@@ -649,8 +590,15 @@ export class SomaComponentManager {
|
|
|
649
590
|
}
|
|
650
591
|
}
|
|
651
592
|
|
|
652
|
-
|
|
653
|
-
|
|
593
|
+
// 兜底告警:既非 DOM 事件、又没匹配上任何契约 emit 的订阅(多为拼写错误)
|
|
594
|
+
for (const event of page.manifest.events) {
|
|
595
|
+
if (!event.emitRoute && event.domEvent && !isKnownDomEvent(event.domEvent)) {
|
|
596
|
+
console.warn(
|
|
597
|
+
`[soma-core][组件] 事件订阅 "${event.somaId}.${event.domEvent}" ` +
|
|
598
|
+
`既不是 DOM 事件,也未匹配任何组件契约 emit,永远不会触发`,
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
654
602
|
}
|
|
655
603
|
|
|
656
604
|
// ─── props 求值 ────────────────────────────────────────────
|
|
@@ -662,18 +610,7 @@ export class SomaComponentManager {
|
|
|
662
610
|
return page.resolver.readFromRoot(resolved);
|
|
663
611
|
},
|
|
664
612
|
hasVar: (seg: string) => page.resolver.hasVar(seg),
|
|
665
|
-
|
|
666
|
-
write: (path: string, value: unknown) => writePagePath(page.resolver, path, value),
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
/** 该实例 props 管道求值的出处;没传注册表时与页面绑定一样用内置表(manifest-compiler / dom-renderer 同款缺省) */
|
|
671
|
-
private pipeSite(instanceId: string, def: SomaComponentDefinition): PropPipeSite {
|
|
672
|
-
return {
|
|
673
|
-
instanceId,
|
|
674
|
-
componentName: def.contract.name,
|
|
675
|
-
pipes: this.pipeRegistry ?? defaultPipeRegistry,
|
|
676
|
-
warned: this.warnedPropPipes,
|
|
613
|
+
readRows: () => [],
|
|
677
614
|
};
|
|
678
615
|
}
|
|
679
616
|
|
|
@@ -687,11 +624,7 @@ export class SomaComponentManager {
|
|
|
687
624
|
if (rowData instanceof SomaRowScope) return {
|
|
688
625
|
read: path => rowData.read(path, value => page.resolver.readFromRoot(page.resolver.resolvePath(value))),
|
|
689
626
|
hasVar: seg => rowData.has(seg) || page.resolver.hasVar(seg),
|
|
690
|
-
|
|
691
|
-
write: (path, value) => {
|
|
692
|
-
const first = path.split('.')[0];
|
|
693
|
-
return rowData.has(first) ? rowVariableRefusal(first) : writePagePath(page.resolver, path, value);
|
|
694
|
-
},
|
|
627
|
+
readRows: () => collectRowScopes(rowData),
|
|
695
628
|
};
|
|
696
629
|
return {
|
|
697
630
|
read: (path: string) => {
|
|
@@ -707,9 +640,7 @@ export class SomaComponentManager {
|
|
|
707
640
|
return segments.reduce((obj: any, key) => obj?.[key], rowData);
|
|
708
641
|
},
|
|
709
642
|
hasVar: (seg: string) => page.resolver.hasVar(seg),
|
|
710
|
-
|
|
711
|
-
// 行变量段(getVarPath 非空)读的是行数据,写回时由 writePagePath 统一拒收
|
|
712
|
-
write: (path: string, value: unknown) => writePagePath(page.resolver, path, value),
|
|
643
|
+
readRows: () => [],
|
|
713
644
|
};
|
|
714
645
|
}
|
|
715
646
|
|
|
@@ -723,13 +654,20 @@ export class SomaComponentManager {
|
|
|
723
654
|
const paths = new Set<string>();
|
|
724
655
|
collectBindingPaths(decl.propsDecl, page.resolver, paths);
|
|
725
656
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
|
|
657
|
+
const resolvedPaths = [...new Set([...paths].map(path => page.resolver.resolvePath(path)))];
|
|
658
|
+
const sourcePaths = resolvedPaths.filter(path => !resolvedPaths.some(parent => parent !== path && path.startsWith(`${parent}.`)));
|
|
659
|
+
const watchedPaths = new Map(sourcePaths.map(path => [path, true]));
|
|
660
|
+
for (const path of sourcePaths) {
|
|
661
|
+
const segments = path.split('.');
|
|
662
|
+
for (let length = 1; length < segments.length; length++) {
|
|
663
|
+
const ancestor = segments.slice(0, length).join('.');
|
|
664
|
+
if (!watchedPaths.has(ancestor)) watchedPaths.set(ancestor, false);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
for (const [path, prefix] of watchedPaths) {
|
|
668
|
+
const dispose = page.renderEngine.watch(path, () => {
|
|
669
|
+
instance.setProps(withPreparedStructureProps(decl.host, resolveProps(decl.propsDecl, reader, decl.def), decl.propsDecl));
|
|
670
|
+
}, { prefix });
|
|
733
671
|
this.watchDisposers.push(dispose);
|
|
734
672
|
}
|
|
735
673
|
}
|
|
@@ -742,15 +680,17 @@ interface SomaComponentInstanceOptions {
|
|
|
742
680
|
instanceId: string;
|
|
743
681
|
def: SomaComponentDefinition;
|
|
744
682
|
initialProps: Record<string, unknown>;
|
|
683
|
+
readProps?: () => Record<string, unknown>;
|
|
684
|
+
readRows?: () => readonly SomaRowScope[];
|
|
745
685
|
scheduler?: SomaScheduler;
|
|
746
686
|
diagnostics?: SomaDiagnostics;
|
|
747
687
|
pipeRegistry?: import('../pipes/pipe-registry').SomaPipeRegistry;
|
|
748
688
|
/** 特性分片注入选项(M-3) */
|
|
749
689
|
styleOptions?: PackStyleOptions;
|
|
750
690
|
services?: Record<string, unknown>;
|
|
691
|
+
/** 分级确认执行口,原样交给实例事件引擎 */
|
|
692
|
+
confirmGraded?: (spec: SomaConfirmSpec) => boolean | Promise<boolean>;
|
|
751
693
|
dispatchEmit: (emitName: string, payload: unknown) => void;
|
|
752
|
-
/** model 回写通道:mode: 'model' 的 prop 在实例内被改写时调用(见 installModelProps) */
|
|
753
|
-
writeModel?: (propName: string, value: unknown) => void;
|
|
754
694
|
registry: SomaComponentRegistry;
|
|
755
695
|
/** 编译前的结构展开(插槽投影必须先于编译完成,见 expandNestedTemplates) */
|
|
756
696
|
expandNested: (root: HTMLElement) => void;
|
|
@@ -772,6 +712,11 @@ export class SomaComponentInstance {
|
|
|
772
712
|
private readonly resolver: SomaScopeResolver;
|
|
773
713
|
private readonly manifest: SomaRuntimeManifest;
|
|
774
714
|
private destroyed = false;
|
|
715
|
+
private initializationState: 'pending' | 'ready' = 'ready';
|
|
716
|
+
private initialization: Promise<void> = Promise.resolve();
|
|
717
|
+
private finishInitialization: (() => void) | undefined;
|
|
718
|
+
private propsReader: () => Record<string, unknown>;
|
|
719
|
+
private rowsReader: () => readonly SomaRowScope[];
|
|
775
720
|
/**
|
|
776
721
|
* 模板里静态嵌套的子组件(宿主元素 + 父 uiConfig 里那份 props 声明)。
|
|
777
722
|
*
|
|
@@ -790,12 +735,6 @@ export class SomaComponentInstance {
|
|
|
790
735
|
private readonly mountChild: SomaComponentInstanceOptions['mountChild'];
|
|
791
736
|
private readonly styleOptions?: PackStyleOptions;
|
|
792
737
|
private readonly host: HTMLElement;
|
|
793
|
-
/** mode: 'model' 的 prop 的实际取值(作用域根上的同名键是它的访问器,见 installModelProps) */
|
|
794
|
-
private readonly modelValues = new Map<string, unknown>();
|
|
795
|
-
/** 宿主内输入法组合期间被改写、还没回写的 model prop(见 installModelProps) */
|
|
796
|
-
private readonly heldModelProps = new Set<string>();
|
|
797
|
-
/** 宿主上组合闸门的监听与补写随实例销毁撤掉 */
|
|
798
|
-
private readonly modelAbort = new AbortController();
|
|
799
738
|
|
|
800
739
|
constructor(options: SomaComponentInstanceOptions) {
|
|
801
740
|
this.host = options.host;
|
|
@@ -804,29 +743,27 @@ export class SomaComponentInstance {
|
|
|
804
743
|
this.mountChild = options.mountChild;
|
|
805
744
|
this.styleOptions = options.styleOptions;
|
|
806
745
|
this.scopeRoot = { ...options.initialProps };
|
|
807
|
-
|
|
808
|
-
|
|
746
|
+
this.propsReader = options.readProps ?? (() => Object.fromEntries(
|
|
747
|
+
Object.entries(this.scopeRoot).filter(([key]) => key !== SOMA_COMPONENT_CTRL_KEY),
|
|
748
|
+
));
|
|
749
|
+
this.rowsReader = options.readRows ?? (() => []);
|
|
809
750
|
|
|
810
751
|
// 特性分片(M-3):必须在控制器与渲染之前注入,否则首帧是无样式的。
|
|
811
752
|
ensureStyleFeatures(options.def, this.scopeRoot, this.styleOptions);
|
|
812
753
|
|
|
754
|
+
const projection = options.def.projectionRegions ? bindSomaProjection(options.host, {
|
|
755
|
+
isActive: () => !this.destroyed,
|
|
756
|
+
readRows: () => this.readRows(),
|
|
757
|
+
}) : undefined;
|
|
813
758
|
if (options.def.controllerFactory) {
|
|
814
759
|
this.scopeRoot[SOMA_COMPONENT_CTRL_KEY] = options.def.controllerFactory({
|
|
815
760
|
props: this.scopeRoot,
|
|
816
|
-
|
|
761
|
+
readProps: () => this.readProps(),
|
|
762
|
+
...(projection ? { projection } : {}),
|
|
763
|
+
emit: (name, payload) => { if (!this.destroyed) options.dispatchEmit(name, payload); },
|
|
817
764
|
host: options.host,
|
|
818
765
|
services: options.services,
|
|
819
|
-
// 惰性求值:工厂执行时引擎尚未就绪,refresh
|
|
820
|
-
//
|
|
821
|
-
// 它是**同步整树重渲**(rerender → renderEngine.render(),整张绑定表逐条过一遍),
|
|
822
|
-
// 而且必须留成同步的:调用方大量存在「refresh() 之后当场读 DOM / 移焦点」的写法
|
|
823
|
-
// (列表键盘导航、焦点归还、滚动定位),改成异步会让这些当场失焦。
|
|
824
|
-
//
|
|
825
|
-
// 代价因此落在调用方身上:**不要把它直接接到每帧都来的事件源上**(scroll / pointermove /
|
|
826
|
-
// 观察者回调)。滚动那条路的正确接法是先合帧、再判断这一帧的渲染输入到底变没变,
|
|
827
|
-
// 组件侧的共享实现在 soma-ui `shared/scroll-frame.ts`(rAF 合帧 + 窗口签名去重)。
|
|
828
|
-
// 引擎这一侧只做得到"算出来的值没变就不写 DOM"(见 render-engine 的 lastWritten),
|
|
829
|
-
// 它省的是 DOM 写入,省不掉"把每个 getter 重算一遍"——那一半只有调用方自己拦得住。
|
|
766
|
+
// 惰性求值:工厂执行时引擎尚未就绪,refresh 只在实例存活且引擎可用时生效
|
|
830
767
|
refresh: () => {
|
|
831
768
|
if (!this.destroyed && this.renderEngine) {
|
|
832
769
|
this.rerender();
|
|
@@ -914,112 +851,45 @@ export class SomaComponentInstance {
|
|
|
914
851
|
},
|
|
915
852
|
diagnostics: options.diagnostics,
|
|
916
853
|
scheduler: options.scheduler,
|
|
854
|
+
...(options.confirmGraded ? { confirmGraded: options.confirmGraded } : {}),
|
|
917
855
|
});
|
|
918
856
|
this.eventEngine.init();
|
|
919
857
|
|
|
920
|
-
//
|
|
858
|
+
// 自治组件生命周期:只等待 onMount 的有限初始化,不把订阅的存活期当作初始化。
|
|
921
859
|
const ctrl = this.scopeRoot[SOMA_COMPONENT_CTRL_KEY] as
|
|
922
860
|
| { onMount?: () => void | Promise<void> }
|
|
923
861
|
| undefined;
|
|
924
862
|
if (typeof ctrl?.onMount === 'function') {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
863
|
+
// 同步调用保留原有前置校验拒绝语义(如适配器注册冲突);只跟踪返回后的异步初始化。
|
|
864
|
+
const pending = ctrl.onMount();
|
|
865
|
+
this.initializationState = 'pending';
|
|
866
|
+
this.initialization = new Promise<void>((resolve) => {
|
|
867
|
+
// destroy 结束旧实例的等待;晚到的初始化结果不能重渲或污染替代实例。
|
|
868
|
+
this.finishInitialization = () => {
|
|
869
|
+
this.initializationState = 'ready';
|
|
870
|
+
this.finishInitialization = undefined;
|
|
871
|
+
resolve();
|
|
872
|
+
};
|
|
873
|
+
const failInitialization = (error: unknown): void => {
|
|
874
|
+
// 生命周期既有容错:失败可观测,但不销毁组件或让页面挂载失败。
|
|
932
875
|
console.warn(`[soma-core][组件] "${options.def.contract.name}" onMount 失败:`, error);
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
* 为什么在作用域根上拦而不是在某个写入点上拦:实例内部改 prop 的路不止一条——
|
|
941
|
-
* 模板 `model: 'p.keyword'` 经渲染引擎 writeToProxy 直接赋值(作用域根是普通对象,没有代理,
|
|
942
|
-
* 写完没人知道),控制器也可以 `props.keyword = x`(契约 P3 允许 model prop 被组件改写)。
|
|
943
|
-
* 两条路也会串起来走:RailList 的搜索框绑的是 `model: 'ctrl.keyword'`,渲染引擎写控制器存取器,存取器再 `props.keyword = x`。
|
|
944
|
-
* 这些路最后都落在作用域根的这个键上,只有这里能一处接全。
|
|
945
|
-
*
|
|
946
|
-
* 不会回环、不会跳光标,靠的是三处去重:
|
|
947
|
-
* - 这里:与实例当前值相同的写入直接丢(文本控件 input / change / blur 会连发同一个值);
|
|
948
|
-
* - createModelWriter:与绑定路径上现有值相同就不写(写的可能是父实例作用域根这种普通对象,那里没有代理);
|
|
949
|
-
* - setProps 走 modelValues 直接落值、不经访问器:回写触发页面 watch → setProps 推回的正是
|
|
950
|
-
* 刚写的值,渲染引擎 writeModelValue 比对控件现值相同就不写 `.value`。
|
|
951
|
-
*
|
|
952
|
-
* 宿主内有输入法组合进行时不回写:组合期间的改写只落进实例(模板照常读到),组合结束后按实例当前值
|
|
953
|
-
* 回写一次。判断与页面 model 绑定是同一个 SomaCompositionGate(见 watchHostComposition)。
|
|
954
|
-
* 模板 `model:` 这条路在渲染引擎里已经按控件挡过一道;控制器的 input 处理器由实例事件引擎的 input 闸门挡过一道
|
|
955
|
-
* (组合期间不执行、组合结束补发一次,见 event-engine 的 attachInputComposition,补发时组合已结束,改写直接回写)。
|
|
956
|
-
* 这里接住的是其余在组合期间改写 prop 的路:非 input 声明的处理器、控制器在别的时机直接赋值。
|
|
957
|
-
*
|
|
958
|
-
* 其他 prop 保持普通数据属性,没有 model prop 的组件(绝大多数)作用域根一字不变,也不挂组合监听。
|
|
959
|
-
*/
|
|
960
|
-
private installModelProps(writeModel: SomaComponentInstanceOptions['writeModel']): void {
|
|
961
|
-
const modelProps = Object.entries(this.def.contract.props ?? {}).filter(([, prop]) => prop.mode === 'model');
|
|
962
|
-
if (modelProps.length === 0) return;
|
|
963
|
-
const composition = writeModel ? this.watchHostComposition(writeModel) : undefined;
|
|
964
|
-
for (const [propName] of modelProps) {
|
|
965
|
-
this.modelValues.set(propName, this.scopeRoot[propName]);
|
|
966
|
-
Object.defineProperty(this.scopeRoot, propName, {
|
|
967
|
-
enumerable: true,
|
|
968
|
-
configurable: true,
|
|
969
|
-
get: () => this.modelValues.get(propName),
|
|
970
|
-
set: (value: unknown) => {
|
|
971
|
-
if (Object.is(value, this.modelValues.get(propName))) return;
|
|
972
|
-
this.modelValues.set(propName, value);
|
|
973
|
-
if (this.destroyed) return;
|
|
974
|
-
if (composition?.holds()) {
|
|
975
|
-
this.heldModelProps.add(propName);
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
this.heldModelProps.delete(propName);
|
|
979
|
-
writeModel?.(propName, value);
|
|
980
|
-
},
|
|
876
|
+
this.finishInitialization?.();
|
|
877
|
+
};
|
|
878
|
+
void Promise.resolve(pending)
|
|
879
|
+
.then(() => {
|
|
880
|
+
if (!this.destroyed) this.rerender();
|
|
881
|
+
})
|
|
882
|
+
.then(() => this.finishInitialization?.(), failInitialization);
|
|
981
883
|
});
|
|
982
884
|
}
|
|
983
885
|
}
|
|
984
886
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
* 模板控件与控制器的监听随后改写 prop 时按更新后的状态判断。
|
|
988
|
-
* 组合结束后的补写:组合期间被改写的 model prop 按实例当前值各回写一次(与绑定路径上的值相同时 createModelWriter 不写)。
|
|
989
|
-
*/
|
|
990
|
-
private watchHostComposition(writeModel: NonNullable<SomaComponentInstanceOptions['writeModel']>): SomaCompositionGate {
|
|
991
|
-
const signal = this.modelAbort.signal;
|
|
992
|
-
return new SomaCompositionGate(
|
|
993
|
-
(type, listener) => this.host.addEventListener(type, listener, { capture: true, signal }),
|
|
994
|
-
signal,
|
|
995
|
-
() => {
|
|
996
|
-
for (const propName of [...this.heldModelProps]) {
|
|
997
|
-
this.heldModelProps.delete(propName);
|
|
998
|
-
if (!this.destroyed) writeModel(propName, this.modelValues.get(propName));
|
|
999
|
-
}
|
|
1000
|
-
},
|
|
1001
|
-
);
|
|
887
|
+
whenInitialized(): Promise<void> {
|
|
888
|
+
return this.initialization;
|
|
1002
889
|
}
|
|
1003
890
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
*
|
|
1007
|
-
* 可写的只有本实例自己持有的东西:`p.*`(作用域根;若它本身也是 model prop,
|
|
1008
|
-
* 访问器会接着往上一层回写)与 `ctrl.*`(控制器字段)。行变量段读的是行数据,拒收。
|
|
1009
|
-
* 写进去之后整树重渲——本实例的绑定与静态子组件的 props 都要看到新值。
|
|
1010
|
-
*/
|
|
1011
|
-
writeBoundPath(path: string, value: unknown, rowData?: unknown): string | null {
|
|
1012
|
-
if (this.destroyed) return null;
|
|
1013
|
-
const first = path.split('.')[0];
|
|
1014
|
-
const ownRoot = first === SOMA_COMPONENT_CTRL_KEY || this.resolver.getVarPath(first) === '';
|
|
1015
|
-
if (!ownRoot || (rowData instanceof SomaRowScope && rowData.has(first))) {
|
|
1016
|
-
return rowVariableRefusal(first);
|
|
1017
|
-
}
|
|
1018
|
-
const refused = assignBoundPath(this.scopeRoot, this.resolver.resolvePath(path).split('.'), value);
|
|
1019
|
-
if (refused === null) {
|
|
1020
|
-
this.rerender();
|
|
1021
|
-
}
|
|
1022
|
-
return refused;
|
|
891
|
+
isInitialized(): boolean {
|
|
892
|
+
return this.initializationState === 'ready';
|
|
1023
893
|
}
|
|
1024
894
|
|
|
1025
895
|
/**
|
|
@@ -1067,11 +937,6 @@ export class SomaComponentInstance {
|
|
|
1067
937
|
if (key === SOMA_COMPONENT_CTRL_KEY) {
|
|
1068
938
|
continue;
|
|
1069
939
|
}
|
|
1070
|
-
// model prop 的下行值直接落进 modelValues:经访问器会被当成实例内改写再回写一遍
|
|
1071
|
-
if (this.modelValues.has(key)) {
|
|
1072
|
-
this.modelValues.set(key, value);
|
|
1073
|
-
continue;
|
|
1074
|
-
}
|
|
1075
940
|
this.scopeRoot[key] = value;
|
|
1076
941
|
}
|
|
1077
942
|
// 特性开关可能是这一帧才翻真的(页面把 batch_actions 从空数组换成两条)。
|
|
@@ -1094,6 +959,23 @@ export class SomaComponentInstance {
|
|
|
1094
959
|
return this.scopeRoot;
|
|
1095
960
|
}
|
|
1096
961
|
|
|
962
|
+
setSourceReader(readProps: () => Record<string, unknown>, readRows: () => readonly SomaRowScope[]): void {
|
|
963
|
+
if (this.destroyed) return;
|
|
964
|
+
this.propsReader = readProps;
|
|
965
|
+
this.rowsReader = readRows;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
readProps(): Record<string, unknown> {
|
|
969
|
+
if (this.destroyed) return {};
|
|
970
|
+
const props = this.propsReader();
|
|
971
|
+
assertPreparedStructureProps(this.host, props);
|
|
972
|
+
return props;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
readRows(): readonly SomaRowScope[] {
|
|
976
|
+
return this.rowsReader();
|
|
977
|
+
}
|
|
978
|
+
|
|
1097
979
|
/** Internal lifecycle ordering: children must release while their DOM is still attached. */
|
|
1098
980
|
getHost(): HTMLElement {
|
|
1099
981
|
return this.host;
|
|
@@ -1116,6 +998,28 @@ export class SomaComponentInstance {
|
|
|
1116
998
|
return this.resolver.readFromRoot(resolved);
|
|
1117
999
|
}
|
|
1118
1000
|
|
|
1001
|
+
readLatest(path: string, rowData?: unknown): unknown {
|
|
1002
|
+
const readRoot = (value: string): unknown => {
|
|
1003
|
+
const resolved = this.resolver.resolvePath(value);
|
|
1004
|
+
return resolved.split('.')[0] === SOMA_COMPONENT_CTRL_KEY
|
|
1005
|
+
? this.resolver.readFromRoot(resolved)
|
|
1006
|
+
: this.resolver.readValue(this.readProps(), resolved);
|
|
1007
|
+
};
|
|
1008
|
+
if (rowData instanceof SomaRowScope) {
|
|
1009
|
+
return rowData.read(path, readRoot);
|
|
1010
|
+
}
|
|
1011
|
+
const segments = path.split('.');
|
|
1012
|
+
const first = segments[0];
|
|
1013
|
+
if (rowData !== undefined && this.resolver.hasVar(first)
|
|
1014
|
+
&& this.resolver.getVarPath(first) !== '' && first !== SOMA_COMPONENT_CTRL_KEY) {
|
|
1015
|
+
return segments.slice(1).reduce(
|
|
1016
|
+
(value: any, key) => value?.[key],
|
|
1017
|
+
rowData,
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
return readRoot(path);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1119
1023
|
hasVar(segment: string): boolean {
|
|
1120
1024
|
// ctrl 不由 bind 声明,而是引擎注入实例作用域根的(SOMA_COMPONENT_CTRL_KEY),
|
|
1121
1025
|
// 所以 resolver 的变量表里没有它。但上面的 read() 第一分支已显式为 'ctrl' 留了位置
|
|
@@ -1126,7 +1030,7 @@ export class SomaComponentInstance {
|
|
|
1126
1030
|
// 于是父组件无法把派生值喂给模板内的子组件,"用组件搭组件"看着能跑却是坏的
|
|
1127
1031
|
// ——293 个 soma-ui 组件里只有 1 个敢嵌套,多个组件的文件头把这归因于"引擎不支持"。
|
|
1128
1032
|
//
|
|
1129
|
-
// 唯一调用方是子组件 reader(createChildReader),影响面止于子组件 props
|
|
1033
|
+
// 唯一调用方是子组件 reader(createChildReader),影响面止于子组件 props 求值。
|
|
1130
1034
|
if (segment === SOMA_COMPONENT_CTRL_KEY) return true;
|
|
1131
1035
|
return this.resolver.hasVar(segment);
|
|
1132
1036
|
}
|
|
@@ -1149,6 +1053,8 @@ export class SomaComponentInstance {
|
|
|
1149
1053
|
return;
|
|
1150
1054
|
}
|
|
1151
1055
|
this.destroyed = true;
|
|
1056
|
+
this.finishInitialization?.();
|
|
1057
|
+
revokeSomaProjections(this.host);
|
|
1152
1058
|
const ctrl = this.scopeRoot[SOMA_COMPONENT_CTRL_KEY] as { onUnmount?: () => void } | undefined;
|
|
1153
1059
|
try {
|
|
1154
1060
|
ctrl?.onUnmount?.();
|
|
@@ -1159,36 +1065,28 @@ export class SomaComponentInstance {
|
|
|
1159
1065
|
this.renderEngine.setComponentHook(null);
|
|
1160
1066
|
this.renderEngine.setComponentReleaseHook(null);
|
|
1161
1067
|
this.renderEngine.destroy();
|
|
1162
|
-
this.modelAbort.abort();
|
|
1163
|
-
this.heldModelProps.clear();
|
|
1164
1068
|
this.staticChildren.length = 0;
|
|
1165
1069
|
}
|
|
1166
1070
|
}
|
|
1167
1071
|
|
|
1168
1072
|
// ─── 求值与遍历工具 ──────────────────────────────────────────
|
|
1169
1073
|
|
|
1074
|
+
function collectRowScopes(rowData: unknown): SomaRowScope[] {
|
|
1075
|
+
const rows: SomaRowScope[] = [];
|
|
1076
|
+
for (let scope = rowData instanceof SomaRowScope ? rowData : undefined; scope; scope = scope.parent) rows.push(scope);
|
|
1077
|
+
return rows.reverse();
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1170
1080
|
/**
|
|
1171
1081
|
* prop 声明值求值规则(DSL 扩展规范第 2 章):
|
|
1172
|
-
* -
|
|
1173
|
-
* (见 resolvePipedProp);首段是已注册 var → 绑定路径;否则字面量字符串
|
|
1082
|
+
* - 字符串:`!path` → 布尔取反;首段是已注册 var → 绑定路径;否则字面量字符串
|
|
1174
1083
|
* - number / boolean → 字面量
|
|
1175
1084
|
* - 数组 / 普通对象 → 逐项递归
|
|
1176
|
-
*
|
|
1177
|
-
* `propName` 只用于告警点名,嵌套项带上下标 / 键(`columns[0].label`)。
|
|
1178
1085
|
*/
|
|
1179
|
-
function resolvePropValue(value: unknown, reader: ScopeReader
|
|
1086
|
+
function resolvePropValue(value: unknown, reader: ScopeReader): unknown {
|
|
1180
1087
|
if (typeof value === 'string') {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
if (isPipedBinding(raw, (seg) => reader.hasVar(seg))) {
|
|
1184
|
-
const piped = resolvePipedProp(raw, reader, site, propName, value);
|
|
1185
|
-
if (piped === PIPE_UNRESOLVED) {
|
|
1186
|
-
return undefined;
|
|
1187
|
-
}
|
|
1188
|
-
return negate ? !piped : piped;
|
|
1189
|
-
}
|
|
1190
|
-
if (negate) {
|
|
1191
|
-
return !reader.read(raw);
|
|
1088
|
+
if (value.startsWith('!')) {
|
|
1089
|
+
return !reader.read(value.slice(1));
|
|
1192
1090
|
}
|
|
1193
1091
|
if (reader.hasVar(value.split('.')[0])) {
|
|
1194
1092
|
return reader.read(value);
|
|
@@ -1196,116 +1094,18 @@ function resolvePropValue(value: unknown, reader: ScopeReader, site: PropPipeSit
|
|
|
1196
1094
|
return value;
|
|
1197
1095
|
}
|
|
1198
1096
|
if (Array.isArray(value)) {
|
|
1199
|
-
return value.map((item
|
|
1097
|
+
return value.map((item) => resolvePropValue(item, reader));
|
|
1200
1098
|
}
|
|
1201
1099
|
if (value !== null && typeof value === 'object') {
|
|
1202
1100
|
const result: Record<string, unknown> = {};
|
|
1203
1101
|
for (const [key, item] of Object.entries(value)) {
|
|
1204
|
-
result[key] = resolvePropValue(item, reader
|
|
1102
|
+
result[key] = resolvePropValue(item, reader);
|
|
1205
1103
|
}
|
|
1206
1104
|
return result;
|
|
1207
1105
|
}
|
|
1208
1106
|
return value;
|
|
1209
1107
|
}
|
|
1210
1108
|
|
|
1211
|
-
/**
|
|
1212
|
-
* 声明值是不是管道绑定:带 ` | ` 且管道前那段的首段是作用域变量。
|
|
1213
|
-
* 首段不是变量的整串是字面量("是 | 否" 这类文案),不进管道解析——解析器对它会报管道段格式错误。
|
|
1214
|
-
* 求值(resolvePropValue)与 watch 收集(collectBindingPaths)共用这一个判定,两边不会各认各的。
|
|
1215
|
-
*/
|
|
1216
|
-
function isPipedBinding(raw: string, hasVar: (seg: string) => boolean): boolean {
|
|
1217
|
-
return hasPipes(raw) && hasVar(raw.slice(0, raw.indexOf(' | ')).trim().split('.')[0]);
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
/** 管道前那段的形状:作用域变量段 + 零到多段字段 */
|
|
1221
|
-
const PIPE_BASE_PATH = /^[A-Za-z_$][\w$]*(\.[\w$]+)*$/;
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* 解析管道绑定(与页面绑定同一个 parsePipedValue、同一份解析缓存)。管道段格式错误由解析器抛出;
|
|
1225
|
-
* 管道前那段不是数据路径(`page.price * page.count | money` 这类算术段)也在这里抛:运行时读不出算术段,
|
|
1226
|
-
* 不拦的话它读成 undefined 再过管道,prop 静默拿到空串。页面绑定对同一写法在挂载时由契约校验报"路径不存在",
|
|
1227
|
-
* props 声明不经那道校验。
|
|
1228
|
-
*/
|
|
1229
|
-
function parsePipedProp(raw: string, hasVar: (seg: string) => boolean): ParsedPipedValue {
|
|
1230
|
-
const parsed = parsePipedValue(raw, hasVar);
|
|
1231
|
-
if (!PIPE_BASE_PATH.test(parsed.basePath)) {
|
|
1232
|
-
throw new Error(`管道前那段 ${JSON.stringify(parsed.basePath)} 不是数据路径(运行时只认"路径 | 管道")`);
|
|
1233
|
-
}
|
|
1234
|
-
return parsed;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
/** 管道绑定求值失败的标记(区别于管道正常算出的任何值) */
|
|
1238
|
-
const PIPE_UNRESOLVED = Symbol('pipe-unresolved');
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* 管道绑定求值,与页面 text / @属性 绑定走同一套:parsePipedValue 解析(经 parsePipedProp)、注册表 assertKnown 白名单、
|
|
1242
|
-
* 从左到右链式执行。基础路径与管道里的绑定型实参都经当前作用域读取器读
|
|
1243
|
-
* (页面路径、行变量、父实例的 p.* / ctrl.* 都认),locale 取同一作用域根上的 `_locale`。
|
|
1244
|
-
* 算出来的与页面绑定一样是展示字符串。
|
|
1245
|
-
*
|
|
1246
|
-
* 页面绑定对未注册管道在编译期 fail fast;props 声明不经编译器,只能在这里发现。
|
|
1247
|
-
* 这里不抛:一个 prop 写错不该让整个组件挂载失败(行内实例会让整张表失败),
|
|
1248
|
-
* 管道段格式错误、管道前不是数据路径、管道未注册、管道函数执行时抛错 → 告警点名实例锚点与 prop,
|
|
1249
|
-
* 返回 PIPE_UNRESOLVED,该 prop 按 undefined 下发。
|
|
1250
|
-
* 执行走 registry.tryApply 而不是 apply:apply 自己接住管道抛错、告警 `[soma-core][管道] 管道 "x" 执行失败`
|
|
1251
|
-
* 并降级为原值字符串(页面绑定用的是这一套),调用方分不出失败,prop 会拿到未经格式化的原值,
|
|
1252
|
-
* 告警也不带锚点与 prop、每次重算都打一遍。tryApply 把失败交回来,由这里按上面的口径告警一次。
|
|
1253
|
-
*/
|
|
1254
|
-
function resolvePipedProp(
|
|
1255
|
-
raw: string,
|
|
1256
|
-
reader: ScopeReader,
|
|
1257
|
-
site: PropPipeSite,
|
|
1258
|
-
propName: string,
|
|
1259
|
-
// 告警里点名的声明原文。取反声明的 `!` 在 resolvePropValue 里已经切掉了(求值要的是 `!` 之后那段),
|
|
1260
|
-
// 只传 raw 会把 "!page.kw | explode" 报成 "page.kw | explode",照着告警回去搜 _ui.yaml 搜不到那一行。
|
|
1261
|
-
decl: string = raw,
|
|
1262
|
-
): unknown {
|
|
1263
|
-
let parsed: ParsedPipedValue;
|
|
1264
|
-
try {
|
|
1265
|
-
parsed = parsePipedProp(raw, (seg) => reader.hasVar(seg));
|
|
1266
|
-
site.pipes.assertKnown(parsed.pipes, '组件 props');
|
|
1267
|
-
} catch (error) {
|
|
1268
|
-
warnUnresolvedPropPipe(site, propName, decl, error);
|
|
1269
|
-
return PIPE_UNRESOLVED;
|
|
1270
|
-
}
|
|
1271
|
-
const result = site.pipes.tryApply(reader.read(parsed.basePath), parsed.pipes, {
|
|
1272
|
-
read: (path) => reader.read(path),
|
|
1273
|
-
locale: () => reader.locale(),
|
|
1274
|
-
});
|
|
1275
|
-
if (!result.ok) {
|
|
1276
|
-
warnUnresolvedPropPipe(site, propName, decl, result.error, result.pipeName);
|
|
1277
|
-
return PIPE_UNRESOLVED;
|
|
1278
|
-
}
|
|
1279
|
-
return result.value;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
* props 管道无法求值的告警:点名组件、实例锚点、prop 与声明原文;同一锚点同一 prop 同一声明只告警一次。
|
|
1284
|
-
* `failedPipe` 有值表示管道函数执行时抛错,`error` 是它抛出的原始异常,追加为第二个实参(控制台可展开堆栈);
|
|
1285
|
-
* 没有值表示解析或白名单阶段失败,异常消息已经说清原因,只打一段文本。
|
|
1286
|
-
*/
|
|
1287
|
-
function warnUnresolvedPropPipe(
|
|
1288
|
-
site: PropPipeSite,
|
|
1289
|
-
propName: string,
|
|
1290
|
-
raw: string,
|
|
1291
|
-
error: unknown,
|
|
1292
|
-
failedPipe?: string,
|
|
1293
|
-
): void {
|
|
1294
|
-
const key = `${site.instanceId}\u0000${propName}\u0000${raw}`;
|
|
1295
|
-
if (site.warned.has(key)) {
|
|
1296
|
-
return;
|
|
1297
|
-
}
|
|
1298
|
-
site.warned.add(key);
|
|
1299
|
-
// SomaPipeError 的消息自带 [soma-core][管道] 前缀,拼进本条告警前去掉,免得一行两个前缀
|
|
1300
|
-
const reason = error instanceof Error ? error.message.replace(/^\[soma-core\]\[管道\]\s*/, '') : String(error);
|
|
1301
|
-
const detail = failedPipe === undefined ? reason : `管道 "${failedPipe}" 执行失败(${reason})`;
|
|
1302
|
-
console.warn(
|
|
1303
|
-
`[soma-core][组件] 组件 "${site.componentName}" 实例 "${site.instanceId}" 的 prop "${propName}" `
|
|
1304
|
-
+ `绑定为 ${JSON.stringify(raw)},管道无法求值:${detail}。该 prop 按 undefined 下发,组件照常挂载`,
|
|
1305
|
-
...(failedPipe === undefined ? [] : [error]),
|
|
1306
|
-
);
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
1109
|
/**
|
|
1310
1110
|
* 契约默认值下发前的隔离拷贝。
|
|
1311
1111
|
*
|
|
@@ -1349,8 +1149,7 @@ function resolveProps(
|
|
|
1349
1149
|
propsDecl: Record<string, unknown>,
|
|
1350
1150
|
reader: ScopeReader,
|
|
1351
1151
|
def: SomaComponentDefinition,
|
|
1352
|
-
hostDefaults
|
|
1353
|
-
site: PropPipeSite,
|
|
1152
|
+
hostDefaults?: Record<string, unknown>,
|
|
1354
1153
|
): Record<string, unknown> {
|
|
1355
1154
|
const result: Record<string, unknown> = {};
|
|
1356
1155
|
|
|
@@ -1373,131 +1172,11 @@ function resolveProps(
|
|
|
1373
1172
|
// Closed enum tokens are literals even when named page/p/ctrl. A path
|
|
1374
1173
|
// remains a path only when it is not one of the declared tokens.
|
|
1375
1174
|
result[propName] = field?.type === 'enum' && field.values?.some(value => value === declValue)
|
|
1376
|
-
? declValue : resolvePropValue(declValue, reader
|
|
1175
|
+
? declValue : resolvePropValue(declValue, reader);
|
|
1377
1176
|
}
|
|
1378
1177
|
return result;
|
|
1379
1178
|
}
|
|
1380
1179
|
|
|
1381
|
-
// ─── model 回写 ──────────────────────────────────────────────
|
|
1382
|
-
|
|
1383
|
-
/** 可写绑定路径的形状:作用域变量段 + 至少一段字段,逐段是标识符或数组下标 */
|
|
1384
|
-
const WRITABLE_BINDING_PATH = /^[A-Za-z_$][\w$]*(\.[\w$]+)+$/;
|
|
1385
|
-
/** 与 row-scope readRowPath 同一份拒收名单:沿这几段赋值就是改原型 */
|
|
1386
|
-
const UNSAFE_PATH_SEGMENTS: ReadonlySet<string> = new Set(['__proto__', 'prototype', 'constructor']);
|
|
1387
|
-
|
|
1388
|
-
/**
|
|
1389
|
-
* 一个实例的 model 回写函数:实例内改写了 model prop → 按 props 声明找到绑定路径 → 经读取器写回。
|
|
1390
|
-
*
|
|
1391
|
-
* 声明值与 resolveProps 同一套判定,能求值成路径的才可能可写;字面量、`!` 取反、带管道或运算的
|
|
1392
|
-
* 表达式都没有"源"可写。写不了时**不回写**,值只留在实例内,同一实例同一 prop 只告警一次
|
|
1393
|
-
* (键入会逐字符触发,告警刷屏等于没有告警)。
|
|
1394
|
-
* 页面没声明这个 prop 时静默:那是非受控用法,组件自己持有值,本来就不该回写。
|
|
1395
|
-
*/
|
|
1396
|
-
function createModelWriter(
|
|
1397
|
-
instanceId: string,
|
|
1398
|
-
def: SomaComponentDefinition,
|
|
1399
|
-
propsDecl: Record<string, unknown>,
|
|
1400
|
-
reader: ScopeReader,
|
|
1401
|
-
): (propName: string, value: unknown) => void {
|
|
1402
|
-
const warned = new Set<string>();
|
|
1403
|
-
return (propName, value) => {
|
|
1404
|
-
if (!Object.prototype.hasOwnProperty.call(propsDecl, propName)) {
|
|
1405
|
-
return;
|
|
1406
|
-
}
|
|
1407
|
-
const declValue = propsDecl[propName];
|
|
1408
|
-
const binding = modelBindingPath(declValue, def.contract.props?.[propName], reader);
|
|
1409
|
-
let refused: string | null;
|
|
1410
|
-
if ('reason' in binding) {
|
|
1411
|
-
refused = binding.reason;
|
|
1412
|
-
} else if (Object.is(reader.read(binding.path), value)) {
|
|
1413
|
-
return;
|
|
1414
|
-
} else {
|
|
1415
|
-
refused = reader.write(binding.path, value);
|
|
1416
|
-
}
|
|
1417
|
-
if (refused === null || warned.has(propName)) {
|
|
1418
|
-
return;
|
|
1419
|
-
}
|
|
1420
|
-
warned.add(propName);
|
|
1421
|
-
console.warn(
|
|
1422
|
-
`[soma-core][组件] 组件 "${def.contract.name}" 实例 "${instanceId}" 的双向 prop "${propName}" `
|
|
1423
|
-
+ `绑定为 ${JSON.stringify(declValue)},${refused}。组件内的改动只留在实例里,不回写;`
|
|
1424
|
-
+ '要双向请绑定到可写的数据路径(页面里写 page.字段,组件模板里写 p.字段 或 ctrl.字段)',
|
|
1425
|
-
);
|
|
1426
|
-
};
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
function modelBindingPath(
|
|
1430
|
-
declValue: unknown,
|
|
1431
|
-
field: SomaContractProp | undefined,
|
|
1432
|
-
reader: ScopeReader,
|
|
1433
|
-
): { path: string } | { reason: string } {
|
|
1434
|
-
if (typeof declValue !== 'string') {
|
|
1435
|
-
return { reason: '这是字面量,没有可写的源' };
|
|
1436
|
-
}
|
|
1437
|
-
if (field?.type === 'enum' && field.values?.some(value => value === declValue)) {
|
|
1438
|
-
return { reason: '这是枚举字面量,没有可写的源' };
|
|
1439
|
-
}
|
|
1440
|
-
if (declValue.startsWith('!')) {
|
|
1441
|
-
return { reason: '取反表达式没有可写的源' };
|
|
1442
|
-
}
|
|
1443
|
-
const segments = declValue.split('.');
|
|
1444
|
-
if (!reader.hasVar(segments[0])) {
|
|
1445
|
-
return { reason: '首段不是作用域变量,按字面量字符串下发,没有可写的源' };
|
|
1446
|
-
}
|
|
1447
|
-
if (!WRITABLE_BINDING_PATH.test(declValue) || segments.some(seg => UNSAFE_PATH_SEGMENTS.has(seg))) {
|
|
1448
|
-
return { reason: '不是纯数据路径(带管道、运算、空白或非法段,或只有作用域变量本身)' };
|
|
1449
|
-
}
|
|
1450
|
-
return { path: declValue };
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
/** 行 / 嵌套作用域变量段的拒收原因(页面读取器与父实例读取器共用) */
|
|
1454
|
-
function rowVariableRefusal(varName: string): string {
|
|
1455
|
-
return `首段 "${varName}" 是列表行或嵌套作用域变量,行数据不在响应式代理里(数组靠整体替换触发更新),写进去上层不会知道`;
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
/**
|
|
1459
|
-
* 页面作用域写回:只收首段指向页面根的路径(`page.xxx`),经页面响应式代理赋值。
|
|
1460
|
-
* 代理的 set 触发 schedulePatch(页面绑定重渲)与 propertyWatcher(registerPropWatches 把值推回实例),
|
|
1461
|
-
* 与页面自己的 `model:` 绑定走的是同一条路。
|
|
1462
|
-
*/
|
|
1463
|
-
function writePagePath(resolver: SomaScopeResolver, path: string, value: unknown): string | null {
|
|
1464
|
-
const first = path.split('.')[0];
|
|
1465
|
-
if (resolver.getVarPath(first) !== '') {
|
|
1466
|
-
return rowVariableRefusal(first);
|
|
1467
|
-
}
|
|
1468
|
-
return assignBoundPath(resolver.readFromRoot(''), resolver.resolvePath(path).split('.'), value);
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
/**
|
|
1472
|
-
* 沿已解析路径逐段下钻后赋值。中间段不是对象、路径穿过数组、目标字段不可写时拒收,一个字节都不写。
|
|
1473
|
-
* 穿过数组要拒:代理不包数组,数组元素上的赋值不会通知任何人。
|
|
1474
|
-
*/
|
|
1475
|
-
function assignBoundPath(root: unknown, segments: string[], value: unknown): string | null {
|
|
1476
|
-
let owner = root;
|
|
1477
|
-
for (const seg of segments.slice(0, -1)) {
|
|
1478
|
-
if (Array.isArray(owner)) {
|
|
1479
|
-
return `路径在 "${seg}" 之前穿过了数组,数组元素不在响应式代理里(数组靠整体替换触发更新)`;
|
|
1480
|
-
}
|
|
1481
|
-
owner = (owner as Record<string, unknown> | null | undefined)?.[seg];
|
|
1482
|
-
if (owner === null || typeof owner !== 'object') {
|
|
1483
|
-
return `中间段 "${seg}" 当前不是对象,无处可写`;
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
if (Array.isArray(owner)) {
|
|
1487
|
-
return '目标是数组元素,数组元素不在响应式代理里(数组靠整体替换触发更新)';
|
|
1488
|
-
}
|
|
1489
|
-
const key = segments[segments.length - 1];
|
|
1490
|
-
try {
|
|
1491
|
-
// Reflect.set 对只读 getter / 冻结对象返回 false 而不是抛错,不依赖所在模块是否严格模式
|
|
1492
|
-
if (!Reflect.set(owner as object, key, value)) {
|
|
1493
|
-
return `字段 "${key}" 不可写(只读 getter 或冻结对象)`;
|
|
1494
|
-
}
|
|
1495
|
-
} catch (error) {
|
|
1496
|
-
return `字段 "${key}" 赋值抛错:${error instanceof Error ? error.message : String(error)}`;
|
|
1497
|
-
}
|
|
1498
|
-
return null;
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
1180
|
/** 收集页面作用域(含 extended.show 嵌套,不进入 bind 行作用域)的 props 声明 */
|
|
1502
1181
|
function collectPagePropsDecls(
|
|
1503
1182
|
show: ShowMapping,
|
|
@@ -1521,11 +1200,7 @@ function collectPagePropsDecls(
|
|
|
1521
1200
|
return into;
|
|
1522
1201
|
}
|
|
1523
1202
|
|
|
1524
|
-
/**
|
|
1525
|
-
* 递归收集 props 声明里的绑定路径(供 watch 注册)。
|
|
1526
|
-
* 管道绑定收的是管道前那段路径与绑定型实参(与页面绑定的 watchPaths 同口径)——整串不是路径,
|
|
1527
|
-
* watch 它永远不会触发,prop 就停在首帧值。parsePipedProp 拒收的声明求值恒为 undefined,不必 watch。
|
|
1528
|
-
*/
|
|
1203
|
+
/** 递归收集 props 声明里的绑定路径(供 watch 注册) */
|
|
1529
1204
|
function collectBindingPaths(
|
|
1530
1205
|
value: unknown,
|
|
1531
1206
|
resolver: SomaScopeResolver,
|
|
@@ -1533,21 +1208,7 @@ function collectBindingPaths(
|
|
|
1533
1208
|
): void {
|
|
1534
1209
|
if (typeof value === 'string') {
|
|
1535
1210
|
const raw = value.startsWith('!') ? value.slice(1) : value;
|
|
1536
|
-
|
|
1537
|
-
if (isPipedBinding(raw, hasVar)) {
|
|
1538
|
-
let parsed: ParsedPipedValue;
|
|
1539
|
-
try {
|
|
1540
|
-
parsed = parsePipedProp(raw, hasVar);
|
|
1541
|
-
} catch {
|
|
1542
|
-
return;
|
|
1543
|
-
}
|
|
1544
|
-
into.add(parsed.basePath);
|
|
1545
|
-
for (const argPath of parsed.argPaths) {
|
|
1546
|
-
into.add(argPath);
|
|
1547
|
-
}
|
|
1548
|
-
return;
|
|
1549
|
-
}
|
|
1550
|
-
if (hasVar(raw.split('.')[0])) {
|
|
1211
|
+
if (resolver.hasVar(raw.split('.')[0])) {
|
|
1551
1212
|
into.add(raw);
|
|
1552
1213
|
}
|
|
1553
1214
|
return;
|
|
@@ -1579,236 +1240,6 @@ function collectComponentHosts(root: ParentNode, into: Map<string, string>): voi
|
|
|
1579
1240
|
});
|
|
1580
1241
|
}
|
|
1581
1242
|
|
|
1582
|
-
const HOVER_ALTERNATIVE = '悬停样式用 Style transitions 的 hover;悬停才出现的提示或面板用 click、focusin / focusout,或 Tooltip 组件';
|
|
1583
|
-
const CONTROLLER_ALTERNATIVE = '封装成组件,由控制器把监听直接挂到元素上,再经契约 emit 上报';
|
|
1584
|
-
|
|
1585
|
-
interface UnlistedDomEventHint {
|
|
1586
|
-
bubbles: boolean;
|
|
1587
|
-
behavior: string;
|
|
1588
|
-
alternative: string;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
function hintGroup(
|
|
1592
|
-
names: readonly string[],
|
|
1593
|
-
bubbles: boolean,
|
|
1594
|
-
behavior: string,
|
|
1595
|
-
alternative: string,
|
|
1596
|
-
): [string, UnlistedDomEventHint][] {
|
|
1597
|
-
return names.map((name) => [name, { bubbles, behavior, alternative }]);
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
* 常见但不在支持的 DOM 事件里的事件名 → 原生委托下的表现与替代写法。
|
|
1602
|
-
*
|
|
1603
|
-
* 文案与 pipeline-parser 的 UNLISTED_DOM_EVENT_HINTS 逐条一致(那张表没有导出):
|
|
1604
|
-
* `${behavior}。替代写法:${alternative}` 拼起来就是解析期告警里的那段。拆成两段,是因为
|
|
1605
|
-
* 组件实例上只讲表现——替代写法是改订阅契约 emit,不是这里的写法。解析期那张表增删名字时同步改这里。
|
|
1606
|
-
*/
|
|
1607
|
-
const UNLISTED_DOM_EVENT_HINTS: ReadonlyMap<string, UnlistedDomEventHint> = new Map([
|
|
1608
|
-
...hintGroup(['mouseover', 'mouseout', 'pointerover', 'pointerout'], true,
|
|
1609
|
-
'会冒泡,但指针在锚点内的子元素之间移动时会反复触发', HOVER_ALTERNATIVE),
|
|
1610
|
-
...hintGroup(['pointerenter', 'pointerleave'], false,
|
|
1611
|
-
'不冒泡,内层锚点上的声明永远不会执行', HOVER_ALTERNATIVE),
|
|
1612
|
-
...hintGroup(['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'touchstart', 'touchend'], true,
|
|
1613
|
-
'会冒泡,能触发', `改用 click;确实要区分按下与抬起时${CONTROLLER_ALTERNATIVE}`),
|
|
1614
|
-
...hintGroup(['mousemove', 'pointermove', 'touchmove', 'wheel'], true,
|
|
1615
|
-
'会冒泡,每次派发都执行一遍 Pipeline', CONTROLLER_ALTERNATIVE),
|
|
1616
|
-
...hintGroup(['contextmenu', 'auxclick', 'pointercancel', 'touchcancel', 'dragstart', 'dragend',
|
|
1617
|
-
'dragenter', 'dragleave', 'dragover', 'animationend', 'transitionend'], true,
|
|
1618
|
-
'会冒泡,能触发', CONTROLLER_ALTERNATIVE),
|
|
1619
|
-
...hintGroup(['scrollend'], false,
|
|
1620
|
-
'在元素上不冒泡,内层锚点上的声明永远不会执行', CONTROLLER_ALTERNATIVE),
|
|
1621
|
-
...hintGroup(['keypress'], true, '会冒泡,能触发,但已被浏览器弃用', '改用 keydown'),
|
|
1622
|
-
...hintGroup(['beforeinput', 'compositionstart', 'compositionupdate', 'compositionend'], true,
|
|
1623
|
-
'会冒泡,能触发', '改用 input'),
|
|
1624
|
-
]);
|
|
1625
|
-
|
|
1626
|
-
/**
|
|
1627
|
-
* 支持的 DOM 事件里不冒泡的几个(见 pipeline-parser VALID_DOM_EVENTS 的注释):
|
|
1628
|
-
* 事件引擎只在页面容器上挂委托监听,宿主或内层锚点上的这类声明永远收不到。
|
|
1629
|
-
*/
|
|
1630
|
-
const LISTED_NON_BUBBLING_DOM_EVENTS: ReadonlySet<string> = new Set(['mouseenter', 'mouseleave', 'scroll']);
|
|
1631
|
-
|
|
1632
|
-
const NATIVE_EVENT_ARG = ',处理器第二实参是原生 Event,不是 emit payload';
|
|
1633
|
-
|
|
1634
|
-
/**
|
|
1635
|
-
* 激活期告警:页面事件清单里没走上 emit 路由、也不是普通锚点上合法 DOM 订阅的条目。
|
|
1636
|
-
*
|
|
1637
|
-
* 没匹配上契约 emit 的订阅不走 emit 路由,事件引擎按事件名原样在页面容器上挂原生委托——
|
|
1638
|
-
* 同名原生事件冒泡上来照样执行,并不是"永远不会触发"。这里手上有宿主表和注册表,
|
|
1639
|
-
* 锚点类型是确定的,按锚点类型分开说:
|
|
1640
|
-
* - 组件实例、契约里没有这个名字(白名单 DOM 事件名也算):组件交互只能走契约 emit,
|
|
1641
|
-
* 控制器 emit 的意图到不了这条订阅;能让它执行的只有组件内部冒泡到宿主的原生事件。
|
|
1642
|
-
* - 普通锚点、事件名不在支持的 DOM 事件里:讲原生委托下的实际表现与替代写法。
|
|
1643
|
-
* 合法 emit、普通锚点上的白名单 DOM 事件不告警。同一订阅(按键修饰符的多条候选)只告警一次。
|
|
1644
|
-
*
|
|
1645
|
-
* 与解析期告警(pipeline-parser)的分工:解析期看不到注册表和页面 HTML,只对 UNLISTED_DOM_EVENT_HINTS
|
|
1646
|
-
* 里的名字打一条"分不清是不是组件实例"的条件告警。两边同时命中时这里仍给完整说明,末尾注明锚点类型
|
|
1647
|
-
* 以本条为准,而不是只补一句"已确认":预编译模式下解析发生在构建期,浏览器控制台里只有本条。
|
|
1648
|
-
*
|
|
1649
|
-
* `registry` 为 null 表示本页与 Host 一个组件都没注册(组件管理器根本没建,
|
|
1650
|
-
* 见 warnSubscriptionsWithoutComponents):那时每个锚点都是普通锚点,宿主上写着组件名的那些
|
|
1651
|
-
* 连实例都不会有,两种都由这里按锚点类型点名。
|
|
1652
|
-
*
|
|
1653
|
-
* 锚点一共四档,四档都要有话说——少一档就是一条静默的订阅:
|
|
1654
|
-
* ① 普通锚点(宿主上没有 data-soma-component) → plainAnchorDetail
|
|
1655
|
-
* ② 整页零注册 + 宿主写着组件名(registry === null) → unregisteredHostDetail
|
|
1656
|
-
* ③ 组件实例,但契约没有这个 emit → instanceAnchorDetail
|
|
1657
|
-
* ④ 注册了别的组件、唯独没有这一个 → unregisteredOnPageDetail(2026-09-20 补)
|
|
1658
|
-
* ④ 此前落在一个没有 else 的 if 链末尾,detail 停在 undefined,整条订阅一声不吭。
|
|
1659
|
-
*/
|
|
1660
|
-
function warnUnroutedSubscriptions(
|
|
1661
|
-
manifest: SomaRuntimeManifest,
|
|
1662
|
-
hosts: ReadonlyMap<string, string>,
|
|
1663
|
-
registry: SomaComponentRegistry | null,
|
|
1664
|
-
): void {
|
|
1665
|
-
const warned = new Set<string>();
|
|
1666
|
-
for (const event of manifest.events) {
|
|
1667
|
-
const name = event.domEvent;
|
|
1668
|
-
const selector = `${event.somaId}.${name}`;
|
|
1669
|
-
if (warned.has(selector)) {
|
|
1670
|
-
continue;
|
|
1671
|
-
}
|
|
1672
|
-
const componentName = hosts.get(event.somaId);
|
|
1673
|
-
let detail: string | undefined;
|
|
1674
|
-
if (componentName === undefined) {
|
|
1675
|
-
detail = isKnownDomEvent(name) ? undefined : plainAnchorDetail(event.somaId, name);
|
|
1676
|
-
} else if (registry === null) {
|
|
1677
|
-
detail = isKnownDomEvent(name) ? undefined : unregisteredHostDetail(event.somaId, componentName, name);
|
|
1678
|
-
} else if (registry.has(componentName)) {
|
|
1679
|
-
const emits = Object.keys(registry.get(componentName).contract.emits ?? {});
|
|
1680
|
-
detail = emits.includes(name) ? undefined : instanceAnchorDetail(event.somaId, componentName, name, emits);
|
|
1681
|
-
} else {
|
|
1682
|
-
// 第三档(2026-09-20 补):本页注册了别的组件,**唯独没有这一个**。
|
|
1683
|
-
// 此前这一支 detail 停在 undefined,这条订阅整条静默——而它与上面两档一样,
|
|
1684
|
-
// 都是"锚点不会成为组件实例",只是原因不同。锚点类型在这里同样是**确定的**
|
|
1685
|
-
// (注册表就在手上,查得到"没有"),所以文案不留余地。
|
|
1686
|
-
detail = isKnownDomEvent(name) ? undefined : unregisteredOnPageDetail(event.somaId, componentName, name);
|
|
1687
|
-
}
|
|
1688
|
-
if (detail === undefined) {
|
|
1689
|
-
continue;
|
|
1690
|
-
}
|
|
1691
|
-
warned.add(selector);
|
|
1692
|
-
const confirmed = UNLISTED_DOM_EVENT_HINTS.has(name)
|
|
1693
|
-
? '(解析期对这条订阅有一条分不清锚点类型的告警,锚点类型以本条为准)'
|
|
1694
|
-
: '';
|
|
1695
|
-
console.warn(`[soma-core][组件] 事件订阅 "${selector}":${detail}${confirmed}`);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
/**
|
|
1700
|
-
* 没有注册任何组件的页面(Host 与页面级资产都是空的)的事件名告警。
|
|
1701
|
-
*
|
|
1702
|
-
* 这类页面走不到 markEmitRoutes:组件管理器根本不建(soma-bootstrap 的 setupComponentManager 在 defs 为空时提前返回),
|
|
1703
|
-
* 于是 `card.reach_limit` 这种笔误全程静默——解析期那条只认 UNLISTED_DOM_EVENT_HINTS 里的 33 个
|
|
1704
|
-
* DOM 专有名字,snake_case 的假 emit 名一个都不在其中,而运行时这一侧又整个缺席。
|
|
1705
|
-
*
|
|
1706
|
-
* 为一条告警去建整个组件管理器不值当(展开模板、建注册表、挂行钩子,全是这类页面用不上的),
|
|
1707
|
-
* 这里只做管理器那一步真正需要的两件事:扫一遍宿主表(querySelectorAll,含 template 内容),
|
|
1708
|
-
* 再复用同一个 warnUnroutedSubscriptions。注册表传 null——本页确实一个组件定义都没有,
|
|
1709
|
-
* 这不是"查不到"而是"确定没有",锚点类型因此是确定的,文案不必留余地。
|
|
1710
|
-
*/
|
|
1711
|
-
export function warnSubscriptionsWithoutComponents(
|
|
1712
|
-
manifest: SomaRuntimeManifest,
|
|
1713
|
-
container: HTMLElement,
|
|
1714
|
-
): void {
|
|
1715
|
-
const hosts = new Map<string, string>();
|
|
1716
|
-
collectComponentHosts(container, hosts);
|
|
1717
|
-
warnUnroutedSubscriptions(manifest, hosts, null);
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
/**
|
|
1721
|
-
* 宿主写着组件名,但**本页注册表里没有这一个**(其余组件都注册了)——此前这一档一声不吭。
|
|
1722
|
-
*
|
|
1723
|
-
* 与"本页零组件注册"那一档(warnSubscriptionsWithoutComponents)的区别只在组件管理器建没建;
|
|
1724
|
-
* 与"顶层宿主名字拼错"那一档的区别在于**够不够得到 registry.get()**:
|
|
1725
|
-
* · 顶层宿主(不在 template 里、没有 data-soma-child-id)在 prepare() 就走
|
|
1726
|
-
* `this.registry.get(name)`,未注册当场抛 SomaComponentRegistryError,**这一档是响的**;
|
|
1727
|
-
* · 而**封在 `<template>` 里的宿主**(行模板、插槽模板)prepare() 根本扫不到——
|
|
1728
|
-
* `querySelectorAll` 不下钻 template content,collectComponentHosts 才下钻。
|
|
1729
|
-
* 它们的实例化入口是 applyRowComponent / applyChildComponent,而那两处只对
|
|
1730
|
-
* **有 props 声明**的锚点触发(applyRowComponent 的第一句就是"props 声明的锚点")。
|
|
1731
|
-
* 于是"行模板里写了个没注册的组件名、又没给它写 props"这条路上:
|
|
1732
|
-
* prepare 不抛、实例不建、模板不注入、emit 不会有、控制台一个字都没有——
|
|
1733
|
-
* 页面上就是一个空壳 div。这正是本条要堵的形态。
|
|
1734
|
-
*
|
|
1735
|
-
* 为什么点名在 markEmitRoutes 而不是只在 warnUnroutedSubscriptions 里补一支:
|
|
1736
|
-
* 后者是**逐条订阅**说话的,零订阅的页面它一句都不会说;而"这个组件根本不会出现"
|
|
1737
|
-
* 这件事与有没有人订阅它的 emit 无关。两处各说各的那一半,都不重复。
|
|
1738
|
-
*
|
|
1739
|
-
* 已注册清单只印前 12 个:全量注册时它有三百多个名字,整串打出来会把真正的那行淹掉。
|
|
1740
|
-
*/
|
|
1741
|
-
function warnUnregisteredHosts(
|
|
1742
|
-
byName: ReadonlyMap<string, string[]>,
|
|
1743
|
-
registry: SomaComponentRegistry,
|
|
1744
|
-
): void {
|
|
1745
|
-
if (byName.size === 0) {
|
|
1746
|
-
return;
|
|
1747
|
-
}
|
|
1748
|
-
const all = registry.names();
|
|
1749
|
-
const shown = all.slice(0, 12).join(', ');
|
|
1750
|
-
const rest = all.length > 12 ? `…另有 ${all.length - 12} 个` : '';
|
|
1751
|
-
for (const [componentName, instanceIds] of byName) {
|
|
1752
|
-
console.warn(
|
|
1753
|
-
`[soma-core][组件] 宿主写着组件 "${componentName}"(锚点:${instanceIds.join('、')}),`
|
|
1754
|
-
+ '但本页注册表里没有它:模板不会注入、实例不会建、契约 emit 不会有人发,'
|
|
1755
|
-
+ `页面上留下的是一个空壳。本页已注册 ${all.length} 个:${shown}${rest}。`
|
|
1756
|
-
+ '修法:把它加进 bootstrap 的 components(自定义组件)或对应的 soma-ui 包,'
|
|
1757
|
-
+ '名字拼错的改回契约名——两者都不改的话,这处 DOM 永远只是个空 div。',
|
|
1758
|
-
);
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
/** 本页零组件注册,宿主上却写着组件名:实例不会建,契约 emit 不会有人发 */
|
|
1763
|
-
function unregisteredHostDetail(instanceId: string, componentName: string, name: string): string {
|
|
1764
|
-
return `${instanceId} 的宿主写着组件 "${componentName}",但本页与 Host 都没有注册组件定义,实例不会建;`
|
|
1765
|
-
+ `没有实例就没有契约 emit,这条订阅只剩引擎按事件名原样挂的原生委托——${nativeBehaviorOnHost(name)}`;
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
/**
|
|
1769
|
-
* 本页注册了别的组件、唯独没有这一个:实例不会建,契约 emit 不会有人发。
|
|
1770
|
-
* 与 unregisteredHostDetail 只差一句"为什么没有"——那一档是整页零注册,这一档是漏了/拼错了一个。
|
|
1771
|
-
* "这个组件根本不会出现"那一半由 warnUnregisteredHosts 单独点名(零订阅的页面也说得上话)。
|
|
1772
|
-
*/
|
|
1773
|
-
function unregisteredOnPageDetail(instanceId: string, componentName: string, name: string): string {
|
|
1774
|
-
return `${instanceId} 的宿主写着组件 "${componentName}",但本页注册表里没有它(其余组件已注册),实例不会建;`
|
|
1775
|
-
+ `没有实例就没有契约 emit,这条订阅只剩引擎按事件名原样挂的原生委托——${nativeBehaviorOnHost(name)}`;
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
function instanceAnchorDetail(instanceId: string, componentName: string, name: string, emits: string[]): string {
|
|
1779
|
-
const available = emits.length > 0 ? `可用 emit:${emits.join(', ')}` : '这个组件的契约没有声明任何 emit';
|
|
1780
|
-
return `${instanceId} 是组件 ${componentName} 的实例,契约没有 emit "${name}";组件交互只能走契约 emit(${available})。`
|
|
1781
|
-
+ `这条订阅不走 emit 路由,组件 emit 的意图到不了它,只剩引擎按事件名原样挂的原生委托——${nativeBehaviorOnHost(name)}`;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
/** 组件实例宿主上按原生事件名委托的实际表现 */
|
|
1785
|
-
function nativeBehaviorOnHost(name: string): string {
|
|
1786
|
-
if (LISTED_NON_BUBBLING_DOM_EVENTS.has(name)) {
|
|
1787
|
-
return `${name} 不冒泡,宿主上的声明永远不会执行`;
|
|
1788
|
-
}
|
|
1789
|
-
if (isKnownDomEvent(name)) {
|
|
1790
|
-
// 事件引擎把 focus / blur 改挂 focusin / focusout 委托
|
|
1791
|
-
const listened = name === 'focus' ? 'focusin' : name === 'blur' ? 'focusout' : name;
|
|
1792
|
-
return `组件内部的原生 ${listened} 冒泡到宿主时照样执行它${NATIVE_EVENT_ARG}`;
|
|
1793
|
-
}
|
|
1794
|
-
const hint = UNLISTED_DOM_EVENT_HINTS.get(name);
|
|
1795
|
-
if (hint) {
|
|
1796
|
-
return `${name} ${hint.behavior}${hint.bubbles ? NATIVE_EVENT_ARG : ''}`;
|
|
1797
|
-
}
|
|
1798
|
-
return `浏览器派发同名原生事件并冒泡到宿主时才会执行${NATIVE_EVENT_ARG};浏览器没有这个事件时永远不会触发(多为 emit 名拼错)`;
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
function plainAnchorDetail(somaId: string, name: string): string {
|
|
1802
|
-
const head = `${somaId} 是普通锚点(不是组件实例),${name} 不在支持的 DOM 事件里,`
|
|
1803
|
-
+ '不走 emit 路由,引擎按原生事件名原样委托——';
|
|
1804
|
-
const hint = UNLISTED_DOM_EVENT_HINTS.get(name);
|
|
1805
|
-
if (hint) {
|
|
1806
|
-
return `${head}${name} ${hint.behavior}。替代写法:${hint.alternative}`;
|
|
1807
|
-
}
|
|
1808
|
-
return `${head}浏览器有同名原生事件时,会冒泡的照样执行、不冒泡的永远不执行;没有这个事件时永远不会触发(多为拼写错误)。`
|
|
1809
|
-
+ `替代写法:改用支持的 DOM 事件(如 click、input、change、keydown);白名单外的交互${CONTROLLER_ALTERNATIVE}`;
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
1243
|
/**
|
|
1813
1244
|
* 「本作用域自己声明的子组件宿主」选择器。
|
|
1814
1245
|
* 结构展开会把整棵嵌套树摊进同一子树,只靠 data-soma-child-id 已分不清是谁的孩子;
|