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
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
// core 标准产物独立校验的第八阶段 `runtime`(`soma check --core --fixtures <目录>`;《core 标准格式与 runtime 空间》§8.1)。
|
|
2
|
+
//
|
|
3
|
+
// 读一致性夹具目录(`manifest.json` + 页面目录 + `negative/*.json`,结构见 `soma-core/tests/conformance/README.md`),逐用例:
|
|
4
|
+
// ① 在独立临时 runtime 根与临时宿主里按地址 `inject` / `bindPrefix`;
|
|
5
|
+
// ② `loadPageByAddress` 逐条请求,比对状态码、参数、查询、缓存、用途、错误码;绑定摘要 = `computeStandardPageDigest`;
|
|
6
|
+
// ③ 实例树 / scopes / 事件:从页面标准格式导出(`dumpInstanceTree` + `validateCoreProduct` 的规范化导出)并与 `expected.tree.json` 比对;
|
|
7
|
+
// ④ 无头挂载(jsdom + 只依契约的占位组件,经 `mountSomaPage`):每个组件锚点都被实例化,`actions[]` 触发后应用具名动作恰好被调用一次;
|
|
8
|
+
// ⑤ 信封同构(门 G53):`isomorphism[]` 同一地址的几个用例,去掉 `drop` 键后的 `page.envelope` 经 `canonicalEnvelopeJson` 逐字相同;
|
|
9
|
+
// ⑥ 负样本:按 `negative/*.json` 的 `setup` / `act` / `expect` 逐个执行并核对期望码。
|
|
10
|
+
// 结果是结构化报告(每个用例 / 同构集 / 负样本一份,沿用 `SomaCoreProductReport`,阶段恒为 `runtime`,码 `CORE-CHECK-RUNTIME`)。
|
|
11
|
+
//
|
|
12
|
+
// 纪律:不登记编译端口;运行在临时目录,进程环境变量(SOMA_HOST_DIR / SOMA_RUNTIME_DIR 等)与全局 DOM 对象运行后原样恢复;
|
|
13
|
+
// 夹具目录空或没有 manifest 如实报错(「无夹具」不算通过);缺 jsdom 时挂载一步报错(`mount: false` 才显式跳过,报告里标 skipped)。
|
|
14
|
+
// 内部用 `any`/宽类型读夹具 JSON:夹具是外部输入,字段逐处判形,不信任。
|
|
15
|
+
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import os from 'node:os';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { readFlatDoc, readFlatEnvelope } from '../build/compiler/flat-page';
|
|
20
|
+
import { buildHtmlAnchorIndex } from '../build/compiler/html-index';
|
|
21
|
+
import { resetHostAssemblyCache } from '../server/host/host-assembly';
|
|
22
|
+
import { resetRuntimeSpace } from '../server/runtime-space/bindings';
|
|
23
|
+
import { computeStandardPageDigest } from '../server/runtime-space/digest';
|
|
24
|
+
import { bindPrefix, inject, injectMany } from '../server/runtime-space/inject';
|
|
25
|
+
import { loadPageByAddress, resolveAddress } from '../server/runtime-space/resolve';
|
|
26
|
+
import { invalidateStaticAddresses } from '../server/runtime-space/static-source';
|
|
27
|
+
import type { SomaStandardPage } from '../server/runtime-space/types';
|
|
28
|
+
import { canonicalEnvelopeJson, checkPageEnvelope } from '../shared/page-envelope';
|
|
29
|
+
import {
|
|
30
|
+
SOMA_CORE_CHECK_CODES,
|
|
31
|
+
dumpInstanceTree,
|
|
32
|
+
validateCoreProduct,
|
|
33
|
+
type SomaCoreProductDiagnostic,
|
|
34
|
+
type SomaCoreProductReport,
|
|
35
|
+
} from './check-product';
|
|
36
|
+
|
|
37
|
+
type Json = Record<string, unknown>;
|
|
38
|
+
|
|
39
|
+
export interface SomaRuntimeFixtureOptions {
|
|
40
|
+
/** 是否做无头挂载与动作触发(缺省 true);false = 显式跳过,报告标 skipped */
|
|
41
|
+
readonly mount?: boolean;
|
|
42
|
+
/** 只跑 id 包含该子串的用例 / 负样本 */
|
|
43
|
+
readonly only?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type SomaRuntimeFixtureStatus = 'passed' | 'failed' | 'pending' | 'skipped';
|
|
47
|
+
|
|
48
|
+
export interface SomaRuntimeFixtureReport extends SomaCoreProductReport {
|
|
49
|
+
readonly status: SomaRuntimeFixtureStatus;
|
|
50
|
+
readonly kind: 'case' | 'isomorphism' | 'negative' | 'fixtures';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const isRecord = (value: unknown): value is Json => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
54
|
+
const messageOf = (error: unknown): string => (error instanceof Error ? error.message : String(error));
|
|
55
|
+
|
|
56
|
+
function readJson(file: string): Json {
|
|
57
|
+
const parsed: unknown = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
58
|
+
if (!isRecord(parsed)) throw new Error(`${file} 不是 JSON 对象`);
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ── 报告 ─────────────────────────────────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
class Collector {
|
|
65
|
+
readonly diagnostics: SomaCoreProductDiagnostic[] = [];
|
|
66
|
+
fail(at: string, message: string): void {
|
|
67
|
+
this.diagnostics.push({ code: SOMA_CORE_CHECK_CODES.runtime, severity: 'error', stage: 'runtime', path: at, message });
|
|
68
|
+
}
|
|
69
|
+
warn(at: string, message: string): void {
|
|
70
|
+
this.diagnostics.push({ code: SOMA_CORE_CHECK_CODES.runtime, severity: 'warning', stage: 'runtime', path: at, message });
|
|
71
|
+
}
|
|
72
|
+
report(file: string, kind: SomaRuntimeFixtureReport['kind'], forced?: SomaRuntimeFixtureStatus): SomaRuntimeFixtureReport {
|
|
73
|
+
const ok = !this.diagnostics.some((item) => item.severity === 'error');
|
|
74
|
+
return { file, kind, ok, status: forced ?? (ok ? 'passed' : 'failed'), diagnostics: this.diagnostics };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function deepEqual(a: unknown, b: unknown): boolean {
|
|
79
|
+
return JSON.stringify(canon(a)) === JSON.stringify(canon(b));
|
|
80
|
+
}
|
|
81
|
+
function canon(value: unknown): unknown {
|
|
82
|
+
if (Array.isArray(value)) return value.map(canon);
|
|
83
|
+
if (isRecord(value)) return Object.fromEntries(Object.keys(value).sort().filter((k) => value[k] !== undefined).map((k) => [k, canon(value[k])]));
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
/** 期望是实际的子集(对象逐键、数组逐项按下标) */
|
|
87
|
+
function subsetOf(expected: unknown, actual: unknown): boolean {
|
|
88
|
+
if (Array.isArray(expected)) return Array.isArray(actual) && expected.every((item, i) => subsetOf(item, actual[i]));
|
|
89
|
+
if (isRecord(expected)) return isRecord(actual) && Object.keys(expected).every((k) => subsetOf(expected[k], actual[k]));
|
|
90
|
+
return expected === actual;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ── 隔离环境 ─────────────────────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
const ENV_KEYS = ['SOMA_HOST_DIR', 'SOMA_RUNTIME_DIR', 'SOMA_RUNTIME_GC'] as const;
|
|
96
|
+
|
|
97
|
+
interface HostSetup {
|
|
98
|
+
readonly identity?: unknown;
|
|
99
|
+
readonly reservedRoutes?: readonly string[];
|
|
100
|
+
readonly pageGrants?: readonly unknown[];
|
|
101
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
102
|
+
readonly static?: readonly string[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface Isolated {
|
|
106
|
+
readonly host: string;
|
|
107
|
+
readonly runtime: string;
|
|
108
|
+
addStatic(address: string): void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const MINIMAL_UI = 'soma: 1\nlocale: [heading]\n';
|
|
112
|
+
const MINIMAL_HTML = '<main data-soma-host="StaticPage"><h1 data-soma-id="heading">--</h1></main>\n';
|
|
113
|
+
|
|
114
|
+
function writeApp(host: string, setup: HostSetup, defaultIdentity: unknown): void {
|
|
115
|
+
const identity = setup.identity !== undefined ? setup.identity : defaultIdentity;
|
|
116
|
+
const lines = [
|
|
117
|
+
"export default {",
|
|
118
|
+
" kind: 'soma-host',",
|
|
119
|
+
' bootstrap: () => ({}),',
|
|
120
|
+
" services: () => ({ kind: 'table', routes: {} }),",
|
|
121
|
+
' virtualPages: () => [],',
|
|
122
|
+
' treeContext: () => ({}),',
|
|
123
|
+
` identity: () => (${JSON.stringify(identity ?? null)}),`,
|
|
124
|
+
];
|
|
125
|
+
if (setup.reservedRoutes !== undefined) lines.push(` reservedRoutes: ${JSON.stringify(setup.reservedRoutes)},`);
|
|
126
|
+
if (setup.pageGrants !== undefined) lines.push(` pageGrants: () => (${JSON.stringify(setup.pageGrants)}),`);
|
|
127
|
+
lines.push('};', '');
|
|
128
|
+
fs.writeFileSync(path.join(host, 'soma.app.ts'), lines.join('\n'));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function addStaticPage(host: string, address: string): void {
|
|
132
|
+
const base = address === '/' ? 'index' : address.slice(1);
|
|
133
|
+
const html = path.join(host, 'html', `${base}.html`);
|
|
134
|
+
const ui = path.join(host, 'ui', `${base}_ui.yaml`);
|
|
135
|
+
fs.mkdirSync(path.dirname(html), { recursive: true });
|
|
136
|
+
fs.mkdirSync(path.dirname(ui), { recursive: true });
|
|
137
|
+
fs.writeFileSync(html, MINIMAL_HTML);
|
|
138
|
+
fs.writeFileSync(ui, MINIMAL_UI);
|
|
139
|
+
invalidateStaticAddresses();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function withIsolated<T>(setup: HostSetup, defaultIdentity: unknown, run: (env: Isolated) => Promise<T>): Promise<T> {
|
|
143
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'soma-conformance-'));
|
|
144
|
+
const host = path.join(root, 'host');
|
|
145
|
+
const runtime = path.join(root, 'runtime');
|
|
146
|
+
for (const dir of ['html/shared', 'ui', 'config']) fs.mkdirSync(path.join(host, dir), { recursive: true });
|
|
147
|
+
fs.mkdirSync(runtime, { recursive: true });
|
|
148
|
+
fs.writeFileSync(path.join(host, 'package.json'), JSON.stringify({ soma: { configRoot: 'config' } }));
|
|
149
|
+
writeApp(host, setup, defaultIdentity);
|
|
150
|
+
const saved: Record<string, string | undefined> = {};
|
|
151
|
+
for (const key of ENV_KEYS) saved[key] = process.env[key];
|
|
152
|
+
for (const key of ENV_KEYS) delete process.env[key];
|
|
153
|
+
process.env.SOMA_HOST_DIR = host;
|
|
154
|
+
process.env.SOMA_RUNTIME_DIR = runtime;
|
|
155
|
+
process.env.SOMA_RUNTIME_GC = 'off';
|
|
156
|
+
for (const [key, value] of Object.entries(setup.env ?? {})) process.env[key] = value;
|
|
157
|
+
resetHostAssemblyCache();
|
|
158
|
+
resetRuntimeSpace();
|
|
159
|
+
invalidateStaticAddresses();
|
|
160
|
+
for (const address of setup.static ?? []) addStaticPage(host, address);
|
|
161
|
+
try {
|
|
162
|
+
return await run({ host, runtime, addStatic: (address) => addStaticPage(host, address) });
|
|
163
|
+
} finally {
|
|
164
|
+
for (const key of ENV_KEYS) {
|
|
165
|
+
if (saved[key] === undefined) delete process.env[key];
|
|
166
|
+
else process.env[key] = saved[key];
|
|
167
|
+
}
|
|
168
|
+
resetHostAssemblyCache();
|
|
169
|
+
resetRuntimeSpace();
|
|
170
|
+
invalidateStaticAddresses();
|
|
171
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ── 页面载荷 ─────────────────────────────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
interface FixturePage {
|
|
178
|
+
readonly page: SomaStandardPage;
|
|
179
|
+
readonly dir: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function readPageDir(root: string, ref: string): FixturePage {
|
|
183
|
+
const dir = path.join(root, ref.replace(/^@/, ''));
|
|
184
|
+
const read = (name: string): string | undefined => {
|
|
185
|
+
const file = path.join(dir, name);
|
|
186
|
+
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : undefined;
|
|
187
|
+
};
|
|
188
|
+
const html = read('page.html');
|
|
189
|
+
const uiYaml = read('page_ui.yaml');
|
|
190
|
+
if (html === undefined || uiYaml === undefined) throw new Error(`页面目录 ${ref} 缺 page.html 或 page_ui.yaml`);
|
|
191
|
+
const localeYaml = read('locale.yaml');
|
|
192
|
+
const eventYaml = read('page_event.yaml');
|
|
193
|
+
const styleYaml = read('page_style.yaml');
|
|
194
|
+
return {
|
|
195
|
+
dir,
|
|
196
|
+
page: {
|
|
197
|
+
format: 1, html, uiYaml,
|
|
198
|
+
...(eventYaml !== undefined ? { eventYaml } : {}),
|
|
199
|
+
...(styleYaml !== undefined ? { styleYaml } : {}),
|
|
200
|
+
...(localeYaml !== undefined ? { locale: localeYaml } : {}),
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function buildPage(root: string, spec: unknown, variant?: unknown): SomaStandardPage {
|
|
206
|
+
const source = typeof spec === 'string' ? { ref: spec } : isRecord(spec) ? spec : null;
|
|
207
|
+
if (source === null || typeof source.ref !== 'string') throw new Error(`页面引用不合法:${JSON.stringify(spec)}`);
|
|
208
|
+
const base = readPageDir(root, source.ref).page;
|
|
209
|
+
const mutable: Record<string, unknown> = { ...base };
|
|
210
|
+
if (source.format !== undefined) mutable.format = source.format;
|
|
211
|
+
if (source.envelope !== undefined) mutable.envelope = source.envelope;
|
|
212
|
+
if (typeof source.uiYaml === 'string') mutable.uiYaml = source.uiYaml;
|
|
213
|
+
if (typeof source.html === 'string') mutable.html = source.html;
|
|
214
|
+
if (typeof source.eventYaml === 'string') mutable.eventYaml = source.eventYaml;
|
|
215
|
+
if (typeof source.styleYaml === 'string') mutable.styleYaml = source.styleYaml;
|
|
216
|
+
if (variant === 'changed-heading' && typeof mutable.locale === 'string') {
|
|
217
|
+
mutable.locale = (mutable.locale as string).replace(/^(\s*heading:\s*)(.*)$/m, '$1$2(变)');
|
|
218
|
+
}
|
|
219
|
+
return mutable as unknown as SomaStandardPage;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function envelopeOfPage(page: SomaStandardPage): Json | null {
|
|
223
|
+
if (isRecord(page.envelope)) return page.envelope;
|
|
224
|
+
return readFlatEnvelope(page.uiYaml);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ── 请求 ─────────────────────────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
interface LoadOutcome {
|
|
230
|
+
readonly ok: boolean;
|
|
231
|
+
readonly status: number;
|
|
232
|
+
readonly code?: string;
|
|
233
|
+
readonly message?: string;
|
|
234
|
+
readonly textKey?: string;
|
|
235
|
+
readonly addresses?: readonly string[];
|
|
236
|
+
readonly page?: Awaited<ReturnType<typeof loadPageByAddress>>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function load(requestPath: string): Promise<LoadOutcome> {
|
|
240
|
+
try {
|
|
241
|
+
const request = new Request(new URL(requestPath, 'http://soma.invalid'));
|
|
242
|
+
const page = await loadPageByAddress(requestPath, request);
|
|
243
|
+
return { ok: true, status: 200, page };
|
|
244
|
+
} catch (error) {
|
|
245
|
+
const e = error as { code?: unknown; status?: unknown; textKey?: unknown; addresses?: unknown; message?: unknown };
|
|
246
|
+
return {
|
|
247
|
+
ok: false,
|
|
248
|
+
status: typeof e.status === 'number' ? e.status : 500,
|
|
249
|
+
...(typeof e.code === 'string' ? { code: e.code } : {}),
|
|
250
|
+
message: typeof e.message === 'string' ? e.message : String(error),
|
|
251
|
+
...(typeof e.textKey === 'string' ? { textKey: e.textKey } : {}),
|
|
252
|
+
...(Array.isArray(e.addresses) ? { addresses: e.addresses as string[] } : {}),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ── 正样本用例 ───────────────────────────────────────────────────────────────
|
|
258
|
+
|
|
259
|
+
interface Component { readonly name: string; readonly props: readonly string[]; readonly emits: readonly string[]; readonly slots: readonly string[] }
|
|
260
|
+
|
|
261
|
+
function readComponents(root: string, file: unknown): Component[] {
|
|
262
|
+
if (typeof file !== 'string') return [];
|
|
263
|
+
const raw = readJson(path.join(root, file)).components;
|
|
264
|
+
return Array.isArray(raw)
|
|
265
|
+
? raw.filter(isRecord).map((item) => ({
|
|
266
|
+
name: String(item.name),
|
|
267
|
+
props: Array.isArray(item.props) ? item.props.map(String) : [],
|
|
268
|
+
emits: Array.isArray(item.emits) ? item.emits.map(String) : [],
|
|
269
|
+
slots: Array.isArray(item.slots) ? item.slots.map(String) : [],
|
|
270
|
+
}))
|
|
271
|
+
: [];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function propTypeOf(value: unknown): { type: string; default: unknown } {
|
|
275
|
+
if (Array.isArray(value)) return { type: 'array', default: [] };
|
|
276
|
+
if (isRecord(value)) return { type: 'object', default: {} };
|
|
277
|
+
if (typeof value === 'boolean') return { type: 'boolean', default: false };
|
|
278
|
+
if (typeof value === 'number') return { type: 'number', default: 0 };
|
|
279
|
+
return { type: 'string', default: '' };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** 页面里各组件实例写的 ui 值类型(占位组件契约的 prop 类型据此推断,夹具只列了 prop 名) */
|
|
283
|
+
function inferPropTypes(
|
|
284
|
+
uiYaml: string | Readonly<Record<string, unknown>>,
|
|
285
|
+
html: string,
|
|
286
|
+
): Map<string, Map<string, { type: string; default: unknown }>> {
|
|
287
|
+
const out = new Map<string, Map<string, { type: string; default: unknown }>>();
|
|
288
|
+
// 平铺 `_ui.yaml`:组件实例的 prop 绑定写在 `show.<锚点>.props`;组件名取自 HTML 的 data-soma-component
|
|
289
|
+
try {
|
|
290
|
+
const doc = readFlatDoc(uiYaml, 'ui');
|
|
291
|
+
const anchors = buildHtmlAnchorIndex(html).anchors;
|
|
292
|
+
const show = isRecord(doc.show) ? doc.show : {};
|
|
293
|
+
for (const [anchor, entry] of Object.entries(show)) {
|
|
294
|
+
const component = anchors.get(anchor)?.component;
|
|
295
|
+
if (component === undefined || !isRecord(entry) || !isRecord(entry.props)) continue;
|
|
296
|
+
const types = out.get(component) ?? new Map();
|
|
297
|
+
for (const [prop, value] of Object.entries(entry.props)) if (!types.has(prop)) types.set(prop, propTypeOf(value));
|
|
298
|
+
out.set(component, types);
|
|
299
|
+
}
|
|
300
|
+
} catch {
|
|
301
|
+
/* 声明读取失败由实例树一步报 */
|
|
302
|
+
}
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface DomEnv {
|
|
307
|
+
readonly dom: { window: Record<string, unknown> & { close(): void } };
|
|
308
|
+
restore(): void;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const DOM_GLOBALS = ['window', 'document', 'HTMLElement', 'Element', 'Node', 'Event', 'CustomEvent', 'MutationObserver', 'DocumentFragment',
|
|
312
|
+
'HTMLTemplateElement', 'getComputedStyle', 'KeyboardEvent', 'MouseEvent', 'customElements', 'DOMParser', 'requestAnimationFrame',
|
|
313
|
+
'cancelAnimationFrame', 'navigator', 'location', 'history', 'localStorage', 'sessionStorage', 'matchMedia', 'ResizeObserver', 'AbortController', 'AbortSignal'];
|
|
314
|
+
|
|
315
|
+
async function installDom(): Promise<DomEnv | { error: string }> {
|
|
316
|
+
let JSDOM: new (html: string, options?: unknown) => { window: Record<string, unknown> & { close(): void } };
|
|
317
|
+
try {
|
|
318
|
+
const mod = (await import('jsdom')) as { JSDOM: typeof JSDOM };
|
|
319
|
+
JSDOM = mod.JSDOM;
|
|
320
|
+
} catch {
|
|
321
|
+
return { error: '无头挂载需要 jsdom(soma-core 的 devDependency);在宿主工程安装 jsdom,或加 --no-mount 显式跳过挂载一步' };
|
|
322
|
+
}
|
|
323
|
+
const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://soma.invalid/', pretendToBeVisual: true });
|
|
324
|
+
const g = globalThis as unknown as Record<string, unknown>;
|
|
325
|
+
const previous = new Map<string, PropertyDescriptor | undefined>();
|
|
326
|
+
for (const key of DOM_GLOBALS) {
|
|
327
|
+
previous.set(key, Object.getOwnPropertyDescriptor(globalThis, key));
|
|
328
|
+
const value = dom.window[key];
|
|
329
|
+
if (value === undefined) continue;
|
|
330
|
+
Object.defineProperty(g, key, { value: typeof value === 'function' && key !== 'customElements' ? (value as (...a: unknown[]) => unknown).bind?.(dom.window) ?? value : value, configurable: true, writable: true });
|
|
331
|
+
}
|
|
332
|
+
// 类(HTMLElement 等)不能 bind,直接用原对象
|
|
333
|
+
for (const key of ['HTMLElement', 'Element', 'Node', 'Event', 'CustomEvent', 'MutationObserver', 'DocumentFragment', 'HTMLTemplateElement', 'KeyboardEvent', 'MouseEvent', 'DOMParser', 'ResizeObserver']) {
|
|
334
|
+
if (dom.window[key] !== undefined) Object.defineProperty(g, key, { value: dom.window[key], configurable: true, writable: true });
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
dom,
|
|
338
|
+
restore() {
|
|
339
|
+
for (const [key, descriptor] of previous) {
|
|
340
|
+
if (descriptor === undefined) delete g[key];
|
|
341
|
+
else Object.defineProperty(g, key, descriptor);
|
|
342
|
+
}
|
|
343
|
+
dom.window.close();
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async function mountAndAct(
|
|
349
|
+
out: Collector,
|
|
350
|
+
root: string,
|
|
351
|
+
caseSpec: Json,
|
|
352
|
+
groupComponents: readonly Component[],
|
|
353
|
+
page: SomaStandardPage,
|
|
354
|
+
loaded: NonNullable<LoadOutcome['page']>,
|
|
355
|
+
events: readonly { source: string; verb: string; target?: string }[],
|
|
356
|
+
rows: Json,
|
|
357
|
+
): Promise<void> {
|
|
358
|
+
const env = await installDom();
|
|
359
|
+
if ('error' in env) { out.fail('mount', env.error); return; }
|
|
360
|
+
const savedFetch = globalThis.fetch;
|
|
361
|
+
try {
|
|
362
|
+
const { mountSomaPage } = await import('../client/mount/mount-page');
|
|
363
|
+
const types = inferPropTypes(page.uiYaml, page.html);
|
|
364
|
+
const emitters = new Map<unknown, (name: string, payload?: unknown) => void>();
|
|
365
|
+
const components: Record<string, unknown> = {};
|
|
366
|
+
for (const component of groupComponents) {
|
|
367
|
+
const inferred = types.get(component.name) ?? new Map();
|
|
368
|
+
const props: Json = {};
|
|
369
|
+
for (const prop of component.props) props[prop] = { ...(inferred.get(prop) ?? { type: 'string', default: '' }), desc: '占位' };
|
|
370
|
+
const emits: Json = {};
|
|
371
|
+
for (const name of component.emits) emits[name] = { payload: {}, desc: '占位' };
|
|
372
|
+
const slots: Json = {};
|
|
373
|
+
for (const name of component.slots) slots[name] = { desc: '占位' };
|
|
374
|
+
components[component.name] = {
|
|
375
|
+
contract: { name: component.name, version: '1.0.0', description: '一致性夹具占位组件(只依契约,不测视觉)', props, emits, slots },
|
|
376
|
+
templateHtml: `<div data-soma-fixture-placeholder="${component.name}">${component.slots.map((s) => `<div data-soma-slot-outlet="${s}"></div>`).join('')}</div>`,
|
|
377
|
+
controllerFactory: (ctx: { host: unknown; emit: (name: string, payload?: unknown) => void }) => {
|
|
378
|
+
emitters.set(ctx.host, ctx.emit);
|
|
379
|
+
return {};
|
|
380
|
+
},
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
const calls = new Map<string, unknown[][]>();
|
|
384
|
+
const actionNames = new Set<string>();
|
|
385
|
+
for (const event of events) if (event.verb === 'ACTION' && event.target !== undefined) actionNames.add(event.target);
|
|
386
|
+
const wanted = Array.isArray(caseSpec.actions) ? caseSpec.actions.filter(isRecord) : [];
|
|
387
|
+
for (const action of wanted) if (typeof action.calls === 'string') actionNames.add(action.calls);
|
|
388
|
+
const actions: Record<string, (...args: unknown[]) => void> = {};
|
|
389
|
+
for (const name of actionNames) actions[name] = (...args: unknown[]) => { calls.set(name, [...(calls.get(name) ?? []), args]); };
|
|
390
|
+
|
|
391
|
+
// 假数据端口:按对象名返回共享数据行,不走网络
|
|
392
|
+
(globalThis as { fetch: unknown }).fetch = async (input: unknown): Promise<unknown> => {
|
|
393
|
+
const url = String(input);
|
|
394
|
+
const objects = isRecord(rows.objects) ? rows.objects : {};
|
|
395
|
+
const hit = Object.keys(objects).sort((a, b) => b.length - a.length).find((name) => url.includes(`/${name.replace(/_/g, '-')}`) || url.includes(`/${name}`));
|
|
396
|
+
const list = hit !== undefined && Array.isArray(objects[hit]) ? (objects[hit] as unknown[]) : [];
|
|
397
|
+
const body = { data: list, rows: list, items: list, total: list.length };
|
|
398
|
+
return { ok: true, status: 200, statusText: 'OK', headers: new Headers({ 'content-type': 'application/json' }), json: async () => body, text: async () => JSON.stringify(body) };
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
const document = (globalThis as unknown as { document: Document }).document;
|
|
402
|
+
const container = document.createElement('div');
|
|
403
|
+
document.body.appendChild(container);
|
|
404
|
+
let mounted;
|
|
405
|
+
try {
|
|
406
|
+
mounted = await mountSomaPage(container, { assets: loaded as never }, {
|
|
407
|
+
components: { name: 'conformance', version: '1.0.0', components } as never,
|
|
408
|
+
actions,
|
|
409
|
+
routerPath: loaded.binding.address,
|
|
410
|
+
});
|
|
411
|
+
await mounted.whenSettled();
|
|
412
|
+
} catch (error) {
|
|
413
|
+
out.fail('mount', `无头挂载失败:${messageOf(error)}`);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
// 每个组件锚点都被实例化
|
|
417
|
+
const anchors = [...container.querySelectorAll('[data-soma-component]')];
|
|
418
|
+
for (const anchor of anchors) {
|
|
419
|
+
const name = anchor.getAttribute('data-soma-component') ?? '';
|
|
420
|
+
if (anchor.querySelector('[data-soma-fixture-placeholder]') === null && !anchor.hasAttribute('data-soma-fixture-placeholder')) {
|
|
421
|
+
out.fail(`mount.${anchor.getAttribute('data-soma-id') ?? name}`, `组件锚点 ${name} 没有被实例化(夹具 components.json 缺该名字,或挂载失败)`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// 触发动作
|
|
425
|
+
for (const [index, action] of wanted.entries()) {
|
|
426
|
+
const on = typeof action.on === 'string' ? action.on : '';
|
|
427
|
+
const [anchorId, eventName] = [on.slice(0, on.indexOf('.')), on.slice(on.indexOf('.') + 1)];
|
|
428
|
+
const calls0 = (calls.get(String(action.calls)) ?? []).length;
|
|
429
|
+
const element = container.querySelector(`[data-soma-id="${anchorId}"]`) as HTMLElement | null;
|
|
430
|
+
if (element === null) { out.fail(`actions[${index}]`, `找不到锚点 ${anchorId}`); continue; }
|
|
431
|
+
const emit = element.hasAttribute('data-soma-component')
|
|
432
|
+
? (emitters.get(element) ?? emitters.get(element.closest('[data-soma-component]')))
|
|
433
|
+
: undefined;
|
|
434
|
+
if (emit !== undefined) emit(eventName, {});
|
|
435
|
+
else if (eventName === 'click') element.click();
|
|
436
|
+
else element.dispatchEvent(new (globalThis as unknown as { Event: typeof Event }).Event(eventName, { bubbles: true }));
|
|
437
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
438
|
+
await mounted.whenSettled();
|
|
439
|
+
const delta = (calls.get(String(action.calls)) ?? []).length - calls0;
|
|
440
|
+
if (delta !== 1) out.fail(`actions[${index}]`, `${on} 触发后应用动作 ${String(action.calls)} 应恰好被调用 1 次,实际 ${delta} 次`);
|
|
441
|
+
}
|
|
442
|
+
mounted.unmount();
|
|
443
|
+
} catch (error) {
|
|
444
|
+
out.fail('mount', `挂载一步异常:${messageOf(error)}`);
|
|
445
|
+
} finally {
|
|
446
|
+
(globalThis as { fetch: unknown }).fetch = savedFetch;
|
|
447
|
+
env.restore();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function runCase(root: string, manifest: Json, spec: Json, options: SomaRuntimeFixtureOptions): Promise<SomaRuntimeFixtureReport> {
|
|
452
|
+
const out = new Collector();
|
|
453
|
+
const id = String(spec.id);
|
|
454
|
+
let skippedMount = false;
|
|
455
|
+
try {
|
|
456
|
+
const run = isRecord(manifest.run) ? manifest.run : {};
|
|
457
|
+
const rowsFile = typeof run.dataRows === 'string' ? path.join(root, run.dataRows) : null;
|
|
458
|
+
const rows: Json = rowsFile !== null && fs.existsSync(rowsFile) ? readJson(rowsFile) : {};
|
|
459
|
+
const groups = isRecord(manifest.groups) ? manifest.groups : {};
|
|
460
|
+
const group = isRecord(groups[String(spec.group)]) ? (groups[String(spec.group)] as Json) : {};
|
|
461
|
+
const page = buildPage(root, spec.page);
|
|
462
|
+
const address = String(spec.address);
|
|
463
|
+
const expect = isRecord(spec.expect) ? spec.expect : {};
|
|
464
|
+
const callOptions = isRecord(spec.options) ? spec.options : {};
|
|
465
|
+
|
|
466
|
+
// 实例树 / scopes / 事件:页面标准格式导出,同时要过 core 自己的独立校验(①–⑦ 阶段)
|
|
467
|
+
const product = validateCoreProduct({
|
|
468
|
+
file: id,
|
|
469
|
+
html: page.html,
|
|
470
|
+
uiYaml: page.uiYaml,
|
|
471
|
+
...(page.eventYaml !== undefined ? { eventYaml: page.eventYaml } : {}),
|
|
472
|
+
...(page.styleYaml !== undefined ? { styleYaml: page.styleYaml } : {}),
|
|
473
|
+
...(page.includes ? { includes: page.includes } : {}),
|
|
474
|
+
}, { dump: true });
|
|
475
|
+
for (const d of product.diagnostics) if (d.severity === 'error') out.fail(`product.${d.stage}${d.path ? `.${d.path}` : ''}`, `标准格式校验未过 ${d.code}:${d.message}`);
|
|
476
|
+
const dump = product.dump;
|
|
477
|
+
if (typeof expect.tree === 'string' && dump !== undefined) {
|
|
478
|
+
const expected = readJson(path.join(root, expect.tree));
|
|
479
|
+
const treeActual = dump.instances ?? dumpInstanceTree(page.html);
|
|
480
|
+
if (!deepEqual(expected.instances, treeActual)) out.fail('tree.instances', `实例树与 ${expect.tree} 不符\n 期望 ${JSON.stringify(canon(expected.instances))}\n 实际 ${JSON.stringify(canon(treeActual))}`);
|
|
481
|
+
if (expected.scopes !== undefined && !deepEqual(expected.scopes, dump.scopes)) out.fail('tree.scopes', `scopes 与 ${expect.tree} 不符\n 期望 ${JSON.stringify(canon(expected.scopes))}\n 实际 ${JSON.stringify(canon(dump.scopes))}`);
|
|
482
|
+
if (expected.events !== undefined && !deepEqual(expected.events, dump.events)) out.fail('tree.events', `事件与 ${expect.tree} 不符\n 期望 ${JSON.stringify(canon(expected.events))}\n 实际 ${JSON.stringify(canon(dump.events))}`);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
await withIsolated({}, run.identity, async () => {
|
|
486
|
+
// 绑定
|
|
487
|
+
let binding;
|
|
488
|
+
try {
|
|
489
|
+
if (spec.bind === 'prefix') binding = bindPrefix(address, () => page, callOptions as never);
|
|
490
|
+
else binding = inject(address, page, callOptions as never);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
out.fail('bind', `${String(spec.bind)} ${address} 失败:${messageOf(error)}`);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const digest = computeStandardPageDigest(page);
|
|
496
|
+
if (spec.bind !== 'prefix' && expect.digest !== undefined && expect.digest !== false && binding.digest !== digest) {
|
|
497
|
+
out.fail('digest', `绑定摘要 ${String(binding.digest)} 与 computeStandardPageDigest 的 ${digest} 不等`);
|
|
498
|
+
}
|
|
499
|
+
// 请求
|
|
500
|
+
const requests = Array.isArray(spec.requests) ? spec.requests.filter(isRecord) : [];
|
|
501
|
+
let firstLoaded: LoadOutcome['page'];
|
|
502
|
+
for (const [index, request] of requests.entries()) {
|
|
503
|
+
const at = `requests[${index}]`;
|
|
504
|
+
const want = isRecord(request.expect) ? request.expect : {};
|
|
505
|
+
const got = await load(String(request.path));
|
|
506
|
+
if (got.page !== undefined && firstLoaded === undefined) firstLoaded = got.page;
|
|
507
|
+
const wantStatus = typeof want.status === 'number' ? want.status : 200;
|
|
508
|
+
if (got.status !== wantStatus) out.fail(at, `${String(request.path)} 状态 ${got.status}(期望 ${wantStatus})${got.message ? `:${got.message}` : ''}`);
|
|
509
|
+
if (typeof want.code === 'string' && got.code !== want.code) out.fail(at, `${String(request.path)} 码 ${String(got.code)}(期望 ${want.code})`);
|
|
510
|
+
if (got.page !== undefined) {
|
|
511
|
+
if (want.params !== undefined && !deepEqual(want.params, got.page.params)) out.fail(at, `params ${JSON.stringify(got.page.params)}(期望 ${JSON.stringify(want.params)})`);
|
|
512
|
+
if (want.query !== undefined && !subsetOf(want.query, got.page.query)) out.fail(at, `query ${JSON.stringify(got.page.query)}(期望含 ${JSON.stringify(want.query)})`);
|
|
513
|
+
if (typeof want.cache === 'string' && got.page.binding.cache !== want.cache) out.fail(at, `cache ${got.page.binding.cache}(期望 ${want.cache})`);
|
|
514
|
+
if (typeof want.purpose === 'string' && got.page.purpose !== want.purpose) out.fail(at, `purpose ${got.page.purpose}(期望 ${want.purpose})`);
|
|
515
|
+
if (index === 0 && isRecord(expect.nav) && !subsetOf(expect.nav, got.page.nav)) out.fail('nav', `导航目录 ${JSON.stringify(got.page.nav)}(期望含 ${JSON.stringify(expect.nav)})`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
if (requests.length === 0) out.fail('requests', '用例没有 requests,无法取回对账');
|
|
519
|
+
// 挂载
|
|
520
|
+
if (options.mount === false) { skippedMount = true; return; }
|
|
521
|
+
if (firstLoaded === undefined) { out.fail('mount', '没有成功取回的请求,无法挂载'); return; }
|
|
522
|
+
await mountAndAct(out, root, spec, readComponents(root, group.components), page, firstLoaded, dump?.events ?? [], rows);
|
|
523
|
+
});
|
|
524
|
+
} catch (error) {
|
|
525
|
+
out.fail('', `用例执行异常:${messageOf(error)}`);
|
|
526
|
+
}
|
|
527
|
+
const report = out.report(`runtime:${id}`, 'case');
|
|
528
|
+
return skippedMount && report.ok ? { ...report, status: 'skipped' } : report;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// ── 信封同构(G53) ──────────────────────────────────────────────────────────
|
|
532
|
+
|
|
533
|
+
function runIsomorphism(root: string, manifest: Json, spec: Json, index: number): SomaRuntimeFixtureReport {
|
|
534
|
+
const out = new Collector();
|
|
535
|
+
const cases = Array.isArray(manifest.cases) ? manifest.cases.filter(isRecord) : [];
|
|
536
|
+
const drop = Array.isArray(spec.drop) ? spec.drop.map(String) : [];
|
|
537
|
+
const sets = Array.isArray(spec.sets) ? spec.sets.filter(isRecord) : [];
|
|
538
|
+
for (const set of sets) {
|
|
539
|
+
const address = String(set.address);
|
|
540
|
+
const ids = Array.isArray(set.cases) ? set.cases.map(String) : [];
|
|
541
|
+
if (ids.length < 2) out.fail(address, '同构集至少要两个用例');
|
|
542
|
+
const prints: { id: string; json: string }[] = [];
|
|
543
|
+
for (const id of ids) {
|
|
544
|
+
const found = cases.find((item) => item.id === id);
|
|
545
|
+
if (found === undefined) { out.fail(address, `同构集引用了不存在的用例 ${id}`); continue; }
|
|
546
|
+
if (found.address !== address) out.fail(address, `用例 ${id} 的地址 ${String(found.address)} 与同构集地址不等`);
|
|
547
|
+
const envelope = envelopeOfPage(buildPage(root, found.page));
|
|
548
|
+
if (envelope === null) { out.fail(address, `用例 ${id} 的 page 块没有 envelope`); continue; }
|
|
549
|
+
const checked = checkPageEnvelope(envelope, { address });
|
|
550
|
+
if (!checked.ok) out.fail(address, `用例 ${id} 的信封自身未过 checkPageEnvelope:${checked.diagnostics.filter((d) => d.severity === 'error').map((d) => d.problem).join(';')}`);
|
|
551
|
+
const kept = Object.fromEntries(Object.entries(envelope).filter(([key]) => !drop.includes(key)));
|
|
552
|
+
prints.push({ id, json: canonicalEnvelopeJson(kept as never) });
|
|
553
|
+
}
|
|
554
|
+
const first = prints[0];
|
|
555
|
+
for (const other of prints.slice(1)) {
|
|
556
|
+
if (first !== undefined && other.json !== first.json) {
|
|
557
|
+
out.fail(address, `信封不同构:${first.id} 与 ${other.id} 的 page.envelope(去掉 ${drop.join('、') || '无'})规范化后不等\n ${first.id} ${first.json}\n ${other.id} ${other.json}`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (sets.length === 0) out.fail('', '同构清单没有任何 sets');
|
|
562
|
+
return out.report(`runtime:isomorphism[${index}]${typeof spec.gate === 'string' ? `(${spec.gate})` : ''}`, 'isomorphism');
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// ── 负样本 ───────────────────────────────────────────────────────────────────
|
|
566
|
+
|
|
567
|
+
function substitute(value: unknown, row: unknown, each: string): unknown {
|
|
568
|
+
if (typeof value === 'string') {
|
|
569
|
+
const exact = /^\$\{([A-Za-z0-9_.]+)\}$/.exec(value);
|
|
570
|
+
if (exact !== null) {
|
|
571
|
+
const segments = exact[1]!.split('.');
|
|
572
|
+
if (segments[0] !== each) return value;
|
|
573
|
+
let cursor: unknown = row;
|
|
574
|
+
for (const segment of segments.slice(1)) cursor = isRecord(cursor) ? cursor[segment] : undefined;
|
|
575
|
+
return cursor;
|
|
576
|
+
}
|
|
577
|
+
return value;
|
|
578
|
+
}
|
|
579
|
+
if (Array.isArray(value)) return value.map((item) => substitute(item, row, each));
|
|
580
|
+
if (isRecord(value)) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, substitute(v, row, each)]));
|
|
581
|
+
return value;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
interface ActResult {
|
|
585
|
+
readonly ok: boolean;
|
|
586
|
+
readonly code?: string;
|
|
587
|
+
readonly status?: number;
|
|
588
|
+
readonly message?: string;
|
|
589
|
+
readonly textKey?: string;
|
|
590
|
+
readonly addresses?: readonly string[];
|
|
591
|
+
readonly diagnostics?: readonly { code: string; severity: string; path: string }[];
|
|
592
|
+
readonly warnings: readonly string[];
|
|
593
|
+
readonly binding?: { generation: number; address: string };
|
|
594
|
+
readonly params?: unknown;
|
|
595
|
+
readonly failures?: readonly { address: string; code: string }[];
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function errorResult(error: unknown, warnings: string[]): ActResult {
|
|
599
|
+
const e = error as { code?: unknown; status?: unknown; textKey?: unknown; addresses?: unknown; failures?: unknown };
|
|
600
|
+
return {
|
|
601
|
+
ok: false,
|
|
602
|
+
...(typeof e.code === 'string' ? { code: e.code } : {}),
|
|
603
|
+
...(typeof e.status === 'number' ? { status: e.status } : {}),
|
|
604
|
+
message: messageOf(error),
|
|
605
|
+
...(typeof e.textKey === 'string' ? { textKey: e.textKey } : {}),
|
|
606
|
+
...(Array.isArray(e.addresses) ? { addresses: e.addresses as string[] } : {}),
|
|
607
|
+
...(Array.isArray(e.failures) ? { failures: e.failures as { address: string; code: string }[] } : {}),
|
|
608
|
+
warnings,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
async function execute(root: string, act: Json, env: Isolated): Promise<ActResult> {
|
|
613
|
+
const warnings: string[] = [];
|
|
614
|
+
const originalWarn = console.warn;
|
|
615
|
+
console.warn = (...args: unknown[]) => { warnings.push(args.map(String).join(' ')); };
|
|
616
|
+
try {
|
|
617
|
+
switch (act.op) {
|
|
618
|
+
case 'inject': {
|
|
619
|
+
const address = String(act.address);
|
|
620
|
+
if (address.endsWith('/*')) {
|
|
621
|
+
const page = buildPage(root, act.page, act.payloadVariant);
|
|
622
|
+
const binding = bindPrefix(address, () => page, (act.options ?? {}) as never);
|
|
623
|
+
return { ok: true, binding, warnings };
|
|
624
|
+
}
|
|
625
|
+
const binding = inject(address, buildPage(root, act.page, act.payloadVariant), (act.options ?? {}) as never);
|
|
626
|
+
return { ok: true, binding, warnings };
|
|
627
|
+
}
|
|
628
|
+
case 'register': {
|
|
629
|
+
// 注册入口的授权终裁(CORE-RUNTIME-GRANT):入口随授权表落地后经 registerPage 调用;入口缺失如实报
|
|
630
|
+
const modulePath = '../server/runtime-space/page-grants';
|
|
631
|
+
const mod = (await import(/* @vite-ignore */ modulePath).catch(() => null)) as { registerPage?: (...a: unknown[]) => unknown } | null;
|
|
632
|
+
if (mod?.registerPage === undefined) throw new Error('op register 需要 server/runtime-space/page-grants 的 registerPage(授权终裁入口尚未落地)');
|
|
633
|
+
const binding = mod.registerPage(String(act.address), buildPage(root, act.page, act.payloadVariant), act.options ?? {}) as { generation: number; address: string };
|
|
634
|
+
return { ok: true, binding, warnings };
|
|
635
|
+
}
|
|
636
|
+
case 'injectMany': {
|
|
637
|
+
const entries = (Array.isArray(act.entries) ? act.entries.filter(isRecord) : []).map((entry) => ({
|
|
638
|
+
address: String(entry.address), page: buildPage(root, entry.page), options: (entry.options ?? {}) as never,
|
|
639
|
+
}));
|
|
640
|
+
const outcomes = injectMany(entries, (act.options ?? {}) as never);
|
|
641
|
+
return { ok: outcomes.every((item) => item.ok), warnings };
|
|
642
|
+
}
|
|
643
|
+
case 'bindPrefix': {
|
|
644
|
+
const page = buildPage(root, act.page);
|
|
645
|
+
const binding = bindPrefix(String(act.prefix), () => page, (act.options ?? {}) as never);
|
|
646
|
+
return { ok: true, binding, warnings };
|
|
647
|
+
}
|
|
648
|
+
case 'load': {
|
|
649
|
+
const got = await load(String(act.path));
|
|
650
|
+
return got.ok
|
|
651
|
+
? { ok: true, params: got.page?.params, status: 200, warnings }
|
|
652
|
+
: { ok: false, status: got.status, ...(got.code ? { code: got.code } : {}), message: got.message ?? '', ...(got.textKey ? { textKey: got.textKey } : {}), ...(got.addresses ? { addresses: got.addresses } : {}), warnings };
|
|
653
|
+
}
|
|
654
|
+
case 'addStaticThenLoad': {
|
|
655
|
+
env.addStatic(String(act.static));
|
|
656
|
+
const got = await load(String(act.path));
|
|
657
|
+
return got.ok ? { ok: true, status: 200, warnings } : { ok: false, status: got.status, ...(got.code ? { code: got.code } : {}), message: got.message ?? '', warnings };
|
|
658
|
+
}
|
|
659
|
+
case 'resolveAddress': {
|
|
660
|
+
const hit = resolveAddress(String(act.path));
|
|
661
|
+
return { ok: true, binding: hit === null ? undefined : (hit.binding as never), warnings };
|
|
662
|
+
}
|
|
663
|
+
case 'checkEnvelope': {
|
|
664
|
+
const result = checkPageEnvelope(act.envelope, (isRecord(act.options) ? act.options : {}) as never);
|
|
665
|
+
return {
|
|
666
|
+
ok: result.ok,
|
|
667
|
+
diagnostics: result.diagnostics.map((d) => ({ code: d.code, severity: d.severity, path: d.src.path })),
|
|
668
|
+
warnings,
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
case 'parse': {
|
|
672
|
+
const page = buildPage(root, act.page);
|
|
673
|
+
const report = validateCoreProduct({
|
|
674
|
+
html: page.html,
|
|
675
|
+
uiYaml: page.uiYaml,
|
|
676
|
+
...(page.eventYaml !== undefined ? { eventYaml: page.eventYaml } : {}),
|
|
677
|
+
...(page.styleYaml !== undefined ? { styleYaml: page.styleYaml } : {}),
|
|
678
|
+
});
|
|
679
|
+
// 告警级诊断也进日志行,供 `expect.ok + code + severity: warning` 的样本核对
|
|
680
|
+
for (const d of report.diagnostics) if (d.severity === 'warning') warnings.push(`[${d.code}] ${d.path}:${d.message}`);
|
|
681
|
+
const first = report.diagnostics.find((d) => d.severity === 'error');
|
|
682
|
+
if (first === undefined) return { ok: true, warnings };
|
|
683
|
+
const embeddedCode = first.message.match(/\[(CORE-[A-Z0-9_-]+)\]/)?.[1];
|
|
684
|
+
return { ok: false, code: embeddedCode ?? first.code, message: first.message, warnings };
|
|
685
|
+
}
|
|
686
|
+
default:
|
|
687
|
+
throw new Error(`负样本 act.op 不认识:${String(act.op)}`);
|
|
688
|
+
}
|
|
689
|
+
} catch (error) {
|
|
690
|
+
if (error instanceof Error && error.message.startsWith('op register') || error instanceof Error && error.message.startsWith('负样本 act.op')) throw error;
|
|
691
|
+
return errorResult(error, warnings);
|
|
692
|
+
} finally {
|
|
693
|
+
console.warn = originalWarn;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
async function runStep(root: string, step: Json, env: Isolated): Promise<void> {
|
|
698
|
+
const result = await execute(root, step, env);
|
|
699
|
+
if (!result.ok && step.op !== 'injectMany') throw new Error(`前置步骤 ${String(step.op)} 失败:${result.code ?? ''} ${result.message ?? ''}`);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
function checkExpect(out: Collector, at: string, expect: Json, result: ActResult): void {
|
|
703
|
+
const severity = typeof expect.severity === 'string' ? expect.severity : undefined;
|
|
704
|
+
const wantOk = expect.ok === true;
|
|
705
|
+
if (wantOk) {
|
|
706
|
+
if (!result.ok) out.fail(at, `期望成功,实际失败 ${result.code ?? ''} ${result.message ?? ''}`);
|
|
707
|
+
if (typeof expect.generation === 'number' && result.binding?.generation !== expect.generation) out.fail(at, `代次 ${String(result.binding?.generation)}(期望 ${expect.generation})`);
|
|
708
|
+
if (expect.params !== undefined && !deepEqual(expect.params, result.params)) out.fail(at, `params ${JSON.stringify(result.params)}(期望 ${JSON.stringify(expect.params)})`);
|
|
709
|
+
if (typeof expect.code === 'string' && !result.warnings.some((line) => line.includes(String(expect.code)))) {
|
|
710
|
+
out.fail(at, `期望提示 ${expect.code}(${severity ?? 'advice'})出现在引擎日志里,实际 ${result.warnings.length === 0 ? '无任何提示' : result.warnings.join(' | ')}`);
|
|
711
|
+
}
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
if (result.ok && Array.isArray(result.diagnostics) === false) {
|
|
715
|
+
out.fail(at, `期望失败 ${String(expect.code ?? expect.error ?? '')},实际成功`);
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
if (typeof expect.code === 'string') {
|
|
719
|
+
const hit = result.code === expect.code || result.diagnostics?.some((d) => d.code === expect.code && d.severity === 'error');
|
|
720
|
+
if (!hit) out.fail(at, `码 ${String(result.code ?? result.diagnostics?.map((d) => d.code).join(','))}(期望 ${expect.code})${result.message ? `:${result.message}` : ''}`);
|
|
721
|
+
}
|
|
722
|
+
if (typeof expect.error === 'string' && !(result.message ?? '').includes(expect.error)) out.fail(at, `错误文案不含 ${JSON.stringify(expect.error)}:${result.message ?? ''}`);
|
|
723
|
+
if (typeof expect.httpStatus === 'number' && result.status !== expect.httpStatus) out.fail(at, `HTTP 状态 ${String(result.status)}(期望 ${expect.httpStatus})`);
|
|
724
|
+
if (typeof expect.textKey === 'string' && result.textKey !== expect.textKey) out.fail(at, `textKey ${String(result.textKey)}(期望 ${expect.textKey})`);
|
|
725
|
+
if (Array.isArray(expect.addresses)) {
|
|
726
|
+
for (const address of expect.addresses.map(String)) if (!(result.addresses ?? []).includes(address)) out.fail(at, `诊断地址清单缺 ${address}(实际 ${JSON.stringify(result.addresses ?? [])})`);
|
|
727
|
+
}
|
|
728
|
+
for (const key of ['bodyMustNotContain', 'messageMustNotContain']) {
|
|
729
|
+
const list = expect[key];
|
|
730
|
+
if (!Array.isArray(list)) continue;
|
|
731
|
+
const text = `${result.message ?? ''}`.toLowerCase();
|
|
732
|
+
for (const word of list.map(String)) if (text.includes(word.toLowerCase())) out.fail(at, `${key}:文案含 ${JSON.stringify(word)}`);
|
|
733
|
+
}
|
|
734
|
+
if (Array.isArray(expect.perEntry)) {
|
|
735
|
+
for (const want of expect.perEntry.filter(isRecord)) {
|
|
736
|
+
if (!(result.failures ?? []).some((f) => f.address === want.address && f.code === want.code)) out.fail(at, `批次逐条原因缺 ${String(want.address)} ${String(want.code)}`);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
async function checkThen(out: Collector, at: string, then: unknown, env: Isolated, root: string): Promise<void> {
|
|
742
|
+
if (!Array.isArray(then)) return;
|
|
743
|
+
for (const [index, item] of then.filter(isRecord).entries()) {
|
|
744
|
+
const result = await execute(root, item, env);
|
|
745
|
+
if (item.op === 'resolveAddress') {
|
|
746
|
+
const want = item.bindingAddress === null ? undefined : String(item.bindingAddress);
|
|
747
|
+
if (result.binding?.address !== want) out.fail(`${at}.then[${index}]`, `${String(item.path)} 命中 ${String(result.binding?.address)}(期望 ${String(want)})`);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
async function runNegative(root: string, file: string, manifest: Json, options: SomaRuntimeFixtureOptions): Promise<SomaRuntimeFixtureReport> {
|
|
753
|
+
const out = new Collector();
|
|
754
|
+
let spec: Json;
|
|
755
|
+
try {
|
|
756
|
+
spec = readJson(path.join(root, file));
|
|
757
|
+
} catch (error) {
|
|
758
|
+
out.fail('', `负样本文件读不了:${messageOf(error)}`);
|
|
759
|
+
return out.report(`runtime:${file}`, 'negative');
|
|
760
|
+
}
|
|
761
|
+
const id = String(spec.id ?? file);
|
|
762
|
+
if (spec.status === 'pending') {
|
|
763
|
+
out.warn('', `待落地:${String(spec.pendingReason ?? '该判定在 core 内尚无落点')}(运行器跳过,不算通过)`);
|
|
764
|
+
return out.report(`runtime:${id}`, 'negative', 'pending');
|
|
765
|
+
}
|
|
766
|
+
const run = isRecord(manifest.run) ? manifest.run : {};
|
|
767
|
+
const setup = (isRecord(spec.setup) ? spec.setup : {}) as HostSetup & { steps?: unknown[] };
|
|
768
|
+
try {
|
|
769
|
+
await withIsolated(setup, run.identity, async (env) => {
|
|
770
|
+
for (const step of Array.isArray(setup.steps) ? setup.steps.filter(isRecord) : []) await runStep(root, step, env);
|
|
771
|
+
const act = isRecord(spec.act) ? spec.act : {};
|
|
772
|
+
const expect = isRecord(spec.expect) ? spec.expect : {};
|
|
773
|
+
if (act.op === 'table') {
|
|
774
|
+
const each = String(act.each);
|
|
775
|
+
const rows = Array.isArray(act.rows) ? act.rows : [];
|
|
776
|
+
const template = isRecord(act.template) ? act.template : {};
|
|
777
|
+
const results: ActResult[] = [];
|
|
778
|
+
for (const row of rows) results.push(await execute(root, substitute(template, row, each) as Json, env));
|
|
779
|
+
if (Array.isArray(expect.codes)) {
|
|
780
|
+
const codes = expect.codes as readonly unknown[];
|
|
781
|
+
const paths = Array.isArray(expect.paths) ? (expect.paths as readonly unknown[]) : undefined;
|
|
782
|
+
rows.forEach((_row, i) => {
|
|
783
|
+
const got = results[i]!;
|
|
784
|
+
const wantCode = String(codes[i]);
|
|
785
|
+
const first = got.diagnostics?.find((d) => d.severity === 'error');
|
|
786
|
+
const code = got.code ?? first?.code;
|
|
787
|
+
if (code !== wantCode) out.fail(`rows[${i}]`, `码 ${String(code)}(期望 ${wantCode})`);
|
|
788
|
+
if (paths && first !== undefined && first.path !== paths[i]) out.fail(`rows[${i}]`, `路径 ${first.path}(期望 ${String(paths[i])})`);
|
|
789
|
+
});
|
|
790
|
+
} else {
|
|
791
|
+
rows.forEach((_row, i) => checkExpect(out, `rows[${i}]`, { ...expect, ok: false }, results[i]!));
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
const result = await execute(root, act, env);
|
|
795
|
+
checkExpect(out, 'act', expect, result);
|
|
796
|
+
await checkThen(out, 'act', expect.then, env, root);
|
|
797
|
+
}
|
|
798
|
+
const positive = isRecord(spec.positive) ? spec.positive : null;
|
|
799
|
+
if (positive !== null && isRecord(positive.act)) {
|
|
800
|
+
for (const extra of Array.isArray(positive.setupExtra) ? positive.setupExtra.filter(isRecord) : []) await runStep(root, extra, env);
|
|
801
|
+
const result = await execute(root, positive.act, env);
|
|
802
|
+
checkExpect(out, 'positive', isRecord(positive.expect) ? positive.expect : { ok: true }, result);
|
|
803
|
+
await checkThen(out, 'positive', isRecord(positive.expect) ? positive.expect.then : undefined, env, root);
|
|
804
|
+
}
|
|
805
|
+
for (const [index, also] of (Array.isArray(spec.also) ? spec.also.filter(isRecord) : []).entries()) {
|
|
806
|
+
if (!isRecord(also.act)) continue;
|
|
807
|
+
checkExpect(out, `also[${index}]`, isRecord(also.expect) ? also.expect : {}, await execute(root, also.act, env));
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
} catch (error) {
|
|
811
|
+
out.fail('', `负样本执行异常:${messageOf(error)}`);
|
|
812
|
+
}
|
|
813
|
+
void options;
|
|
814
|
+
return out.report(`runtime:${id}`, 'negative');
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// ── 入口 ─────────────────────────────────────────────────────────────────────
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* 跑一个夹具目录。目录或 manifest 缺失 / 没有任何用例 → 单份失败报告「无夹具」。
|
|
821
|
+
* 返回的报告按:正样本用例 → 信封同构 → 负样本 排列;`ok` 全真才算接入。
|
|
822
|
+
*/
|
|
823
|
+
export async function validateRuntimeFixtures(dir: string, options: SomaRuntimeFixtureOptions = {}): Promise<SomaRuntimeFixtureReport[]> {
|
|
824
|
+
const root = path.resolve(dir);
|
|
825
|
+
const manifestFile = path.join(root, 'manifest.json');
|
|
826
|
+
if (!fs.existsSync(manifestFile)) {
|
|
827
|
+
const out = new Collector();
|
|
828
|
+
out.fail('manifest.json', `无夹具:${root} 下没有 manifest.json(空目录不算通过)`);
|
|
829
|
+
return [out.report('runtime:<fixtures>', 'fixtures')];
|
|
830
|
+
}
|
|
831
|
+
let manifest: Json;
|
|
832
|
+
try {
|
|
833
|
+
manifest = readJson(manifestFile);
|
|
834
|
+
} catch (error) {
|
|
835
|
+
const out = new Collector();
|
|
836
|
+
out.fail('manifest.json', `manifest.json 读不了:${messageOf(error)}`);
|
|
837
|
+
return [out.report('runtime:<fixtures>', 'fixtures')];
|
|
838
|
+
}
|
|
839
|
+
const cases = Array.isArray(manifest.cases) ? manifest.cases.filter(isRecord) : [];
|
|
840
|
+
const negatives = Array.isArray(manifest.negative) ? manifest.negative.map(String) : [];
|
|
841
|
+
if (cases.length === 0 && negatives.length === 0) {
|
|
842
|
+
const out = new Collector();
|
|
843
|
+
out.fail('manifest.json', '无夹具:manifest 没有任何 cases 或 negative');
|
|
844
|
+
return [out.report('runtime:<fixtures>', 'fixtures')];
|
|
845
|
+
}
|
|
846
|
+
const matches = (id: string): boolean => options.only === undefined || id.includes(options.only);
|
|
847
|
+
const reports: SomaRuntimeFixtureReport[] = [];
|
|
848
|
+
for (const spec of cases) if (matches(String(spec.id))) reports.push(await runCase(root, manifest, spec, options));
|
|
849
|
+
const iso = Array.isArray(manifest.isomorphism) ? manifest.isomorphism.filter(isRecord) : [];
|
|
850
|
+
if (options.only === undefined) iso.forEach((spec, index) => {
|
|
851
|
+
try { reports.push(runIsomorphism(root, manifest, spec, index)); } catch (error) {
|
|
852
|
+
const out = new Collector();
|
|
853
|
+
out.fail('', `同构检查异常:${messageOf(error)}`);
|
|
854
|
+
reports.push(out.report(`runtime:isomorphism[${index}]`, 'isomorphism'));
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
for (const file of negatives) if (matches(file)) reports.push(await runNegative(root, file, manifest, options));
|
|
858
|
+
return reports;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/** 文本摘要行:通过 / 失败 / 待落地 / 跳过 各多少 */
|
|
862
|
+
export function summarizeRuntimeFixtures(reports: readonly SomaRuntimeFixtureReport[]): string {
|
|
863
|
+
const count = (status: SomaRuntimeFixtureStatus): number => reports.filter((item) => item.status === status).length;
|
|
864
|
+
return `runtime 阶段:${reports.length} 项,通过 ${count('passed')},失败 ${count('failed')},待落地 ${count('pending')},跳过 ${count('skipped')}`;
|
|
865
|
+
}
|