soma-core 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +193 -0
- package/bin/soma-sync-runtime.cjs +130 -0
- package/bin/soma.cjs +200 -13
- package/bin/soma.ts +182 -0
- package/core/build/compiler/flat-page.ts +305 -0
- package/core/build/compiler/full-manifest-builder.ts +68 -27
- package/core/build/{blocks → compiler}/html-index.ts +64 -15
- 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 +265 -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 +50 -46
- 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 +348 -317
- 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 +1246 -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 +24 -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 +230 -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 +74 -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 +327 -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 +247 -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/{adaptive → scheduling}/flush-scheduler.ts +16 -12
- 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/{component → styles}/style-features.ts +3 -3
- 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 +866 -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 +12 -5
- package/core/server/host/host-assembly-entry.ts +16 -0
- package/core/server/host/host-assembly.ts +249 -0
- package/core/server/host/invoke-host-request-hook.ts +5 -0
- package/core/server/host/locale-yaml.ts +51 -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 +90 -45
- package/core/server/host/resolve-host-request-hook.ts +8 -0
- package/core/server/host/resolve-host-tree-context.ts +15 -1
- package/core/server/host/server-page-assets.ts +178 -38
- package/core/server/host/soma-page-compile.ts +57 -16
- package/core/server/host/source-packages.cjs +185 -0
- package/core/server/host/source-packages.ts +18 -126
- package/core/server/host/virtual-pages.ts +255 -0
- package/core/server/index.ts +13 -42
- package/core/server/node.ts +53 -0
- package/core/server/page-assets.ts +91 -0
- package/core/server/page-declaration.ts +83 -7
- package/core/server/registry/api-registry-store.ts +38 -29
- package/core/server/registry/asset-store.ts +35 -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 +479 -60
- package/core/server/registry/page-registry-store.ts +627 -80
- package/core/server/registry/publish-asset-pin.ts +19 -16
- package/core/server/registry/registry-file-lock.ts +16 -3
- 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 +184 -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 +371 -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 +481 -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 +117 -0
- package/core/server/runtime-space/index.ts +106 -0
- package/core/server/runtime-space/inject.ts +498 -0
- package/core/server/runtime-space/migrate-sources.ts +124 -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 +552 -0
- package/core/server/runtime-space/root.cjs +251 -0
- package/core/server/runtime-space/root.ts +46 -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 +325 -0
- package/core/shared/anchor-space.ts +48 -0
- package/core/shared/artifact-compatibility.ts +166 -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 +85 -7
- package/core/shared/contract-a11y.ts +335 -0
- package/core/shared/contract-sections.ts +344 -0
- package/core/shared/core-diagnostic-codes.ts +210 -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 +31 -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 +4 -8
- 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 +798 -0
- package/core/shared/registry-generated/diagnostic-registry.ts +5886 -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-compat.ts +9 -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 +31 -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 +97 -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 +85 -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 +120276 -0
- package/dist/cli/soma.js +131 -454
- package/dist/core/adaptive-pure.cjs +41 -0
- package/dist/core/index.cjs +119747 -22518
- package/dist/core/theme-pure.cjs +38 -0
- package/dist/diagnostics/telemetry.cjs +2 -1
- package/dist/lsp/component-tree.cjs +6412 -8261
- 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/{blocks → compiler}/html-index.d.ts +19 -8
- 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 -61
- 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 +315 -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 +18 -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 +87 -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/{adaptive → scheduling}/flush-scheduler.d.ts +2 -2
- 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/{component → styles}/style-features.d.ts +1 -1
- 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/content-security-policy.d.ts +5 -0
- package/dist/types/server/host/host-assembly-entry.d.ts +2 -0
- package/dist/types/server/host/host-assembly.d.ts +56 -0
- package/dist/types/server/host/host-config-paths.d.cts +7 -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 +74 -4
- package/dist/types/server/host/server-page-assets.d.ts +29 -1
- 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 +43 -0
- package/dist/types/server/index.d.ts +8 -12
- package/dist/types/server/node.d.ts +16 -0
- package/dist/types/server/page-assets.d.ts +10 -0
- package/dist/types/server/page-declaration.d.ts +21 -6
- package/dist/types/server/registry/api-registry-store.d.ts +9 -7
- package/dist/types/server/registry/asset-store.d.ts +13 -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 +46 -0
- package/dist/types/server/registry/page-registry-store.d.ts +225 -23
- 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-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 +61 -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 +66 -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/migrate-sources.d.ts +19 -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 +38 -0
- package/dist/types/server/runtime-space/root.d.cts +88 -0
- package/dist/types/server/runtime-space/root.d.ts +21 -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 +264 -0
- package/dist/types/shared/anchor-space.d.ts +17 -0
- package/dist/types/shared/artifact-compatibility.d.ts +77 -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 +2 -2
- 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 +5023 -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-compat.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 +29 -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 +95 -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 +82 -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 -1
- package/package.json +216 -62
- package/tsconfig.json +2 -10
- package/app/SomaPageClient.tsx +0 -313
- package/app/[...path]/page.tsx +0 -22
- package/app/api/[...path]/route.ts +0 -86
- package/app/api/soma-registry/[...path]/route.ts +0 -67
- package/app/components/SomaHostPage.tsx +0 -128
- package/app/components/SomaHydrationShell.tsx +0 -20
- package/app/components/SomaPageClientBoundary.tsx +0 -13
- package/app/favicon.ico/route.ts +0 -13
- package/app/globals.css +0 -126
- package/app/layout.tsx +0 -27
- package/app/page.tsx +0 -9
- package/app/soma/[...path]/route.ts +0 -9
- 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/app/soma/route.ts +0 -9
- 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/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/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/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/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/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/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/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/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
|
@@ -0,0 +1,3401 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// core/compiler/preview-export-entry.ts
|
|
31
|
+
var preview_export_entry_exports = {};
|
|
32
|
+
__export(preview_export_entry_exports, {
|
|
33
|
+
runPreviewExport: () => runPreviewExport
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(preview_export_entry_exports);
|
|
36
|
+
var import_node_fs2 = __toESM(require("node:fs"));
|
|
37
|
+
|
|
38
|
+
// core/compiler/preview-export.ts
|
|
39
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
40
|
+
var import_node_path = __toESM(require("node:path"));
|
|
41
|
+
|
|
42
|
+
// ../node_modules/js-yaml/dist/js-yaml.mjs
|
|
43
|
+
function isNothing(subject) {
|
|
44
|
+
return typeof subject === "undefined" || subject === null;
|
|
45
|
+
}
|
|
46
|
+
function isObject(subject) {
|
|
47
|
+
return typeof subject === "object" && subject !== null;
|
|
48
|
+
}
|
|
49
|
+
function toArray(sequence) {
|
|
50
|
+
if (Array.isArray(sequence)) return sequence;
|
|
51
|
+
else if (isNothing(sequence)) return [];
|
|
52
|
+
return [sequence];
|
|
53
|
+
}
|
|
54
|
+
function extend(target, source) {
|
|
55
|
+
var index, length, key, sourceKeys;
|
|
56
|
+
if (source) {
|
|
57
|
+
sourceKeys = Object.keys(source);
|
|
58
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
59
|
+
key = sourceKeys[index];
|
|
60
|
+
target[key] = source[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function repeat(string, count) {
|
|
66
|
+
var result = "", cycle;
|
|
67
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
68
|
+
result += string;
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
function isNegativeZero(number) {
|
|
73
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
74
|
+
}
|
|
75
|
+
var isNothing_1 = isNothing;
|
|
76
|
+
var isObject_1 = isObject;
|
|
77
|
+
var toArray_1 = toArray;
|
|
78
|
+
var repeat_1 = repeat;
|
|
79
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
80
|
+
var extend_1 = extend;
|
|
81
|
+
var common = {
|
|
82
|
+
isNothing: isNothing_1,
|
|
83
|
+
isObject: isObject_1,
|
|
84
|
+
toArray: toArray_1,
|
|
85
|
+
repeat: repeat_1,
|
|
86
|
+
isNegativeZero: isNegativeZero_1,
|
|
87
|
+
extend: extend_1
|
|
88
|
+
};
|
|
89
|
+
function formatError(exception2, compact) {
|
|
90
|
+
var where = "", message = exception2.reason || "(unknown reason)";
|
|
91
|
+
if (!exception2.mark) return message;
|
|
92
|
+
if (exception2.mark.name) {
|
|
93
|
+
where += 'in "' + exception2.mark.name + '" ';
|
|
94
|
+
}
|
|
95
|
+
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
96
|
+
if (!compact && exception2.mark.snippet) {
|
|
97
|
+
where += "\n\n" + exception2.mark.snippet;
|
|
98
|
+
}
|
|
99
|
+
return message + " " + where;
|
|
100
|
+
}
|
|
101
|
+
function YAMLException$1(reason, mark) {
|
|
102
|
+
Error.call(this);
|
|
103
|
+
this.name = "YAMLException";
|
|
104
|
+
this.reason = reason;
|
|
105
|
+
this.mark = mark;
|
|
106
|
+
this.message = formatError(this, false);
|
|
107
|
+
if (Error.captureStackTrace) {
|
|
108
|
+
Error.captureStackTrace(this, this.constructor);
|
|
109
|
+
} else {
|
|
110
|
+
this.stack = new Error().stack || "";
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
114
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
115
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
116
|
+
return this.name + ": " + formatError(this, compact);
|
|
117
|
+
};
|
|
118
|
+
var exception = YAMLException$1;
|
|
119
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
120
|
+
var head = "";
|
|
121
|
+
var tail = "";
|
|
122
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
123
|
+
if (position - lineStart > maxHalfLength) {
|
|
124
|
+
head = " ... ";
|
|
125
|
+
lineStart = position - maxHalfLength + head.length;
|
|
126
|
+
}
|
|
127
|
+
if (lineEnd - position > maxHalfLength) {
|
|
128
|
+
tail = " ...";
|
|
129
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
133
|
+
pos: position - lineStart + head.length
|
|
134
|
+
// relative position
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function padStart(string, max) {
|
|
138
|
+
return common.repeat(" ", max - string.length) + string;
|
|
139
|
+
}
|
|
140
|
+
function makeSnippet(mark, options) {
|
|
141
|
+
options = Object.create(options || null);
|
|
142
|
+
if (!mark.buffer) return null;
|
|
143
|
+
if (!options.maxLength) options.maxLength = 79;
|
|
144
|
+
if (typeof options.indent !== "number") options.indent = 1;
|
|
145
|
+
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
146
|
+
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
147
|
+
var re = /\r?\n|\r|\0/g;
|
|
148
|
+
var lineStarts = [0];
|
|
149
|
+
var lineEnds = [];
|
|
150
|
+
var match;
|
|
151
|
+
var foundLineNo = -1;
|
|
152
|
+
while (match = re.exec(mark.buffer)) {
|
|
153
|
+
lineEnds.push(match.index);
|
|
154
|
+
lineStarts.push(match.index + match[0].length);
|
|
155
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
156
|
+
foundLineNo = lineStarts.length - 2;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
160
|
+
var result = "", i, line;
|
|
161
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
162
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
163
|
+
for (i = 1; i <= options.linesBefore; i++) {
|
|
164
|
+
if (foundLineNo - i < 0) break;
|
|
165
|
+
line = getLine(
|
|
166
|
+
mark.buffer,
|
|
167
|
+
lineStarts[foundLineNo - i],
|
|
168
|
+
lineEnds[foundLineNo - i],
|
|
169
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
170
|
+
maxLineLength
|
|
171
|
+
);
|
|
172
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
173
|
+
}
|
|
174
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
175
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
176
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
177
|
+
for (i = 1; i <= options.linesAfter; i++) {
|
|
178
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
179
|
+
line = getLine(
|
|
180
|
+
mark.buffer,
|
|
181
|
+
lineStarts[foundLineNo + i],
|
|
182
|
+
lineEnds[foundLineNo + i],
|
|
183
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
184
|
+
maxLineLength
|
|
185
|
+
);
|
|
186
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
187
|
+
}
|
|
188
|
+
return result.replace(/\n$/, "");
|
|
189
|
+
}
|
|
190
|
+
var snippet = makeSnippet;
|
|
191
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
192
|
+
"kind",
|
|
193
|
+
"multi",
|
|
194
|
+
"resolve",
|
|
195
|
+
"construct",
|
|
196
|
+
"instanceOf",
|
|
197
|
+
"predicate",
|
|
198
|
+
"represent",
|
|
199
|
+
"representName",
|
|
200
|
+
"defaultStyle",
|
|
201
|
+
"styleAliases"
|
|
202
|
+
];
|
|
203
|
+
var YAML_NODE_KINDS = [
|
|
204
|
+
"scalar",
|
|
205
|
+
"sequence",
|
|
206
|
+
"mapping"
|
|
207
|
+
];
|
|
208
|
+
function compileStyleAliases(map2) {
|
|
209
|
+
var result = {};
|
|
210
|
+
if (map2 !== null) {
|
|
211
|
+
Object.keys(map2).forEach(function(style) {
|
|
212
|
+
map2[style].forEach(function(alias) {
|
|
213
|
+
result[String(alias)] = style;
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
function Type$1(tag, options) {
|
|
220
|
+
options = options || {};
|
|
221
|
+
Object.keys(options).forEach(function(name) {
|
|
222
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
223
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
this.options = options;
|
|
227
|
+
this.tag = tag;
|
|
228
|
+
this.kind = options["kind"] || null;
|
|
229
|
+
this.resolve = options["resolve"] || function() {
|
|
230
|
+
return true;
|
|
231
|
+
};
|
|
232
|
+
this.construct = options["construct"] || function(data) {
|
|
233
|
+
return data;
|
|
234
|
+
};
|
|
235
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
236
|
+
this.predicate = options["predicate"] || null;
|
|
237
|
+
this.represent = options["represent"] || null;
|
|
238
|
+
this.representName = options["representName"] || null;
|
|
239
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
240
|
+
this.multi = options["multi"] || false;
|
|
241
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
242
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
243
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
var type = Type$1;
|
|
247
|
+
function compileList(schema2, name) {
|
|
248
|
+
var result = [];
|
|
249
|
+
schema2[name].forEach(function(currentType) {
|
|
250
|
+
var newIndex = result.length;
|
|
251
|
+
result.forEach(function(previousType, previousIndex) {
|
|
252
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
253
|
+
newIndex = previousIndex;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
result[newIndex] = currentType;
|
|
257
|
+
});
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
function compileMap() {
|
|
261
|
+
var result = {
|
|
262
|
+
scalar: {},
|
|
263
|
+
sequence: {},
|
|
264
|
+
mapping: {},
|
|
265
|
+
fallback: {},
|
|
266
|
+
multi: {
|
|
267
|
+
scalar: [],
|
|
268
|
+
sequence: [],
|
|
269
|
+
mapping: [],
|
|
270
|
+
fallback: []
|
|
271
|
+
}
|
|
272
|
+
}, index, length;
|
|
273
|
+
function collectType(type2) {
|
|
274
|
+
if (type2.multi) {
|
|
275
|
+
result.multi[type2.kind].push(type2);
|
|
276
|
+
result.multi["fallback"].push(type2);
|
|
277
|
+
} else {
|
|
278
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
282
|
+
arguments[index].forEach(collectType);
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
function Schema$1(definition) {
|
|
287
|
+
return this.extend(definition);
|
|
288
|
+
}
|
|
289
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
290
|
+
var implicit = [];
|
|
291
|
+
var explicit = [];
|
|
292
|
+
if (definition instanceof type) {
|
|
293
|
+
explicit.push(definition);
|
|
294
|
+
} else if (Array.isArray(definition)) {
|
|
295
|
+
explicit = explicit.concat(definition);
|
|
296
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
297
|
+
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
298
|
+
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
299
|
+
} else {
|
|
300
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
301
|
+
}
|
|
302
|
+
implicit.forEach(function(type$1) {
|
|
303
|
+
if (!(type$1 instanceof type)) {
|
|
304
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
305
|
+
}
|
|
306
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
307
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
308
|
+
}
|
|
309
|
+
if (type$1.multi) {
|
|
310
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
explicit.forEach(function(type$1) {
|
|
314
|
+
if (!(type$1 instanceof type)) {
|
|
315
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
var result = Object.create(Schema$1.prototype);
|
|
319
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
320
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
321
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
322
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
323
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
324
|
+
return result;
|
|
325
|
+
};
|
|
326
|
+
var schema = Schema$1;
|
|
327
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
328
|
+
kind: "scalar",
|
|
329
|
+
construct: function(data) {
|
|
330
|
+
return data !== null ? data : "";
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
334
|
+
kind: "sequence",
|
|
335
|
+
construct: function(data) {
|
|
336
|
+
return data !== null ? data : [];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
340
|
+
kind: "mapping",
|
|
341
|
+
construct: function(data) {
|
|
342
|
+
return data !== null ? data : {};
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
var failsafe = new schema({
|
|
346
|
+
explicit: [
|
|
347
|
+
str,
|
|
348
|
+
seq,
|
|
349
|
+
map
|
|
350
|
+
]
|
|
351
|
+
});
|
|
352
|
+
function resolveYamlNull(data) {
|
|
353
|
+
if (data === null) return true;
|
|
354
|
+
var max = data.length;
|
|
355
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
356
|
+
}
|
|
357
|
+
function constructYamlNull() {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
function isNull(object) {
|
|
361
|
+
return object === null;
|
|
362
|
+
}
|
|
363
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
364
|
+
kind: "scalar",
|
|
365
|
+
resolve: resolveYamlNull,
|
|
366
|
+
construct: constructYamlNull,
|
|
367
|
+
predicate: isNull,
|
|
368
|
+
represent: {
|
|
369
|
+
canonical: function() {
|
|
370
|
+
return "~";
|
|
371
|
+
},
|
|
372
|
+
lowercase: function() {
|
|
373
|
+
return "null";
|
|
374
|
+
},
|
|
375
|
+
uppercase: function() {
|
|
376
|
+
return "NULL";
|
|
377
|
+
},
|
|
378
|
+
camelcase: function() {
|
|
379
|
+
return "Null";
|
|
380
|
+
},
|
|
381
|
+
empty: function() {
|
|
382
|
+
return "";
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
defaultStyle: "lowercase"
|
|
386
|
+
});
|
|
387
|
+
function resolveYamlBoolean(data) {
|
|
388
|
+
if (data === null) return false;
|
|
389
|
+
var max = data.length;
|
|
390
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
391
|
+
}
|
|
392
|
+
function constructYamlBoolean(data) {
|
|
393
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
394
|
+
}
|
|
395
|
+
function isBoolean(object) {
|
|
396
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
397
|
+
}
|
|
398
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
399
|
+
kind: "scalar",
|
|
400
|
+
resolve: resolveYamlBoolean,
|
|
401
|
+
construct: constructYamlBoolean,
|
|
402
|
+
predicate: isBoolean,
|
|
403
|
+
represent: {
|
|
404
|
+
lowercase: function(object) {
|
|
405
|
+
return object ? "true" : "false";
|
|
406
|
+
},
|
|
407
|
+
uppercase: function(object) {
|
|
408
|
+
return object ? "TRUE" : "FALSE";
|
|
409
|
+
},
|
|
410
|
+
camelcase: function(object) {
|
|
411
|
+
return object ? "True" : "False";
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
defaultStyle: "lowercase"
|
|
415
|
+
});
|
|
416
|
+
function isHexCode(c) {
|
|
417
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
418
|
+
}
|
|
419
|
+
function isOctCode(c) {
|
|
420
|
+
return 48 <= c && c <= 55;
|
|
421
|
+
}
|
|
422
|
+
function isDecCode(c) {
|
|
423
|
+
return 48 <= c && c <= 57;
|
|
424
|
+
}
|
|
425
|
+
function resolveYamlInteger(data) {
|
|
426
|
+
if (data === null) return false;
|
|
427
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
428
|
+
if (!max) return false;
|
|
429
|
+
ch = data[index];
|
|
430
|
+
if (ch === "-" || ch === "+") {
|
|
431
|
+
ch = data[++index];
|
|
432
|
+
}
|
|
433
|
+
if (ch === "0") {
|
|
434
|
+
if (index + 1 === max) return true;
|
|
435
|
+
ch = data[++index];
|
|
436
|
+
if (ch === "b") {
|
|
437
|
+
index++;
|
|
438
|
+
for (; index < max; index++) {
|
|
439
|
+
ch = data[index];
|
|
440
|
+
if (ch === "_") continue;
|
|
441
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
442
|
+
hasDigits = true;
|
|
443
|
+
}
|
|
444
|
+
return hasDigits && ch !== "_";
|
|
445
|
+
}
|
|
446
|
+
if (ch === "x") {
|
|
447
|
+
index++;
|
|
448
|
+
for (; index < max; index++) {
|
|
449
|
+
ch = data[index];
|
|
450
|
+
if (ch === "_") continue;
|
|
451
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
452
|
+
hasDigits = true;
|
|
453
|
+
}
|
|
454
|
+
return hasDigits && ch !== "_";
|
|
455
|
+
}
|
|
456
|
+
if (ch === "o") {
|
|
457
|
+
index++;
|
|
458
|
+
for (; index < max; index++) {
|
|
459
|
+
ch = data[index];
|
|
460
|
+
if (ch === "_") continue;
|
|
461
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
462
|
+
hasDigits = true;
|
|
463
|
+
}
|
|
464
|
+
return hasDigits && ch !== "_";
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (ch === "_") return false;
|
|
468
|
+
for (; index < max; index++) {
|
|
469
|
+
ch = data[index];
|
|
470
|
+
if (ch === "_") continue;
|
|
471
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
hasDigits = true;
|
|
475
|
+
}
|
|
476
|
+
if (!hasDigits || ch === "_") return false;
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
function constructYamlInteger(data) {
|
|
480
|
+
var value = data, sign = 1, ch;
|
|
481
|
+
if (value.indexOf("_") !== -1) {
|
|
482
|
+
value = value.replace(/_/g, "");
|
|
483
|
+
}
|
|
484
|
+
ch = value[0];
|
|
485
|
+
if (ch === "-" || ch === "+") {
|
|
486
|
+
if (ch === "-") sign = -1;
|
|
487
|
+
value = value.slice(1);
|
|
488
|
+
ch = value[0];
|
|
489
|
+
}
|
|
490
|
+
if (value === "0") return 0;
|
|
491
|
+
if (ch === "0") {
|
|
492
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
493
|
+
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
494
|
+
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
495
|
+
}
|
|
496
|
+
return sign * parseInt(value, 10);
|
|
497
|
+
}
|
|
498
|
+
function isInteger(object) {
|
|
499
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
500
|
+
}
|
|
501
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
502
|
+
kind: "scalar",
|
|
503
|
+
resolve: resolveYamlInteger,
|
|
504
|
+
construct: constructYamlInteger,
|
|
505
|
+
predicate: isInteger,
|
|
506
|
+
represent: {
|
|
507
|
+
binary: function(obj) {
|
|
508
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
509
|
+
},
|
|
510
|
+
octal: function(obj) {
|
|
511
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
512
|
+
},
|
|
513
|
+
decimal: function(obj) {
|
|
514
|
+
return obj.toString(10);
|
|
515
|
+
},
|
|
516
|
+
/* eslint-disable max-len */
|
|
517
|
+
hexadecimal: function(obj) {
|
|
518
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
defaultStyle: "decimal",
|
|
522
|
+
styleAliases: {
|
|
523
|
+
binary: [2, "bin"],
|
|
524
|
+
octal: [8, "oct"],
|
|
525
|
+
decimal: [10, "dec"],
|
|
526
|
+
hexadecimal: [16, "hex"]
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
530
|
+
// 2.5e4, 2.5 and integers
|
|
531
|
+
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
532
|
+
);
|
|
533
|
+
function resolveYamlFloat(data) {
|
|
534
|
+
if (data === null) return false;
|
|
535
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
536
|
+
// Probably should update regexp & check speed
|
|
537
|
+
data[data.length - 1] === "_") {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
function constructYamlFloat(data) {
|
|
543
|
+
var value, sign;
|
|
544
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
545
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
546
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
547
|
+
value = value.slice(1);
|
|
548
|
+
}
|
|
549
|
+
if (value === ".inf") {
|
|
550
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
551
|
+
} else if (value === ".nan") {
|
|
552
|
+
return NaN;
|
|
553
|
+
}
|
|
554
|
+
return sign * parseFloat(value, 10);
|
|
555
|
+
}
|
|
556
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
557
|
+
function representYamlFloat(object, style) {
|
|
558
|
+
var res;
|
|
559
|
+
if (isNaN(object)) {
|
|
560
|
+
switch (style) {
|
|
561
|
+
case "lowercase":
|
|
562
|
+
return ".nan";
|
|
563
|
+
case "uppercase":
|
|
564
|
+
return ".NAN";
|
|
565
|
+
case "camelcase":
|
|
566
|
+
return ".NaN";
|
|
567
|
+
}
|
|
568
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
569
|
+
switch (style) {
|
|
570
|
+
case "lowercase":
|
|
571
|
+
return ".inf";
|
|
572
|
+
case "uppercase":
|
|
573
|
+
return ".INF";
|
|
574
|
+
case "camelcase":
|
|
575
|
+
return ".Inf";
|
|
576
|
+
}
|
|
577
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
578
|
+
switch (style) {
|
|
579
|
+
case "lowercase":
|
|
580
|
+
return "-.inf";
|
|
581
|
+
case "uppercase":
|
|
582
|
+
return "-.INF";
|
|
583
|
+
case "camelcase":
|
|
584
|
+
return "-.Inf";
|
|
585
|
+
}
|
|
586
|
+
} else if (common.isNegativeZero(object)) {
|
|
587
|
+
return "-0.0";
|
|
588
|
+
}
|
|
589
|
+
res = object.toString(10);
|
|
590
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
591
|
+
}
|
|
592
|
+
function isFloat(object) {
|
|
593
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
594
|
+
}
|
|
595
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
596
|
+
kind: "scalar",
|
|
597
|
+
resolve: resolveYamlFloat,
|
|
598
|
+
construct: constructYamlFloat,
|
|
599
|
+
predicate: isFloat,
|
|
600
|
+
represent: representYamlFloat,
|
|
601
|
+
defaultStyle: "lowercase"
|
|
602
|
+
});
|
|
603
|
+
var json = failsafe.extend({
|
|
604
|
+
implicit: [
|
|
605
|
+
_null,
|
|
606
|
+
bool,
|
|
607
|
+
int,
|
|
608
|
+
float
|
|
609
|
+
]
|
|
610
|
+
});
|
|
611
|
+
var core = json;
|
|
612
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
613
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
614
|
+
);
|
|
615
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
616
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
|
|
617
|
+
);
|
|
618
|
+
function resolveYamlTimestamp(data) {
|
|
619
|
+
if (data === null) return false;
|
|
620
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
621
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
function constructYamlTimestamp(data) {
|
|
625
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
626
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
627
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
628
|
+
if (match === null) throw new Error("Date resolve error");
|
|
629
|
+
year = +match[1];
|
|
630
|
+
month = +match[2] - 1;
|
|
631
|
+
day = +match[3];
|
|
632
|
+
if (!match[4]) {
|
|
633
|
+
return new Date(Date.UTC(year, month, day));
|
|
634
|
+
}
|
|
635
|
+
hour = +match[4];
|
|
636
|
+
minute = +match[5];
|
|
637
|
+
second = +match[6];
|
|
638
|
+
if (match[7]) {
|
|
639
|
+
fraction = match[7].slice(0, 3);
|
|
640
|
+
while (fraction.length < 3) {
|
|
641
|
+
fraction += "0";
|
|
642
|
+
}
|
|
643
|
+
fraction = +fraction;
|
|
644
|
+
}
|
|
645
|
+
if (match[9]) {
|
|
646
|
+
tz_hour = +match[10];
|
|
647
|
+
tz_minute = +(match[11] || 0);
|
|
648
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
649
|
+
if (match[9] === "-") delta = -delta;
|
|
650
|
+
}
|
|
651
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
652
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
653
|
+
return date;
|
|
654
|
+
}
|
|
655
|
+
function representYamlTimestamp(object) {
|
|
656
|
+
return object.toISOString();
|
|
657
|
+
}
|
|
658
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
659
|
+
kind: "scalar",
|
|
660
|
+
resolve: resolveYamlTimestamp,
|
|
661
|
+
construct: constructYamlTimestamp,
|
|
662
|
+
instanceOf: Date,
|
|
663
|
+
represent: representYamlTimestamp
|
|
664
|
+
});
|
|
665
|
+
function resolveYamlMerge(data) {
|
|
666
|
+
return data === "<<" || data === null;
|
|
667
|
+
}
|
|
668
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
669
|
+
kind: "scalar",
|
|
670
|
+
resolve: resolveYamlMerge
|
|
671
|
+
});
|
|
672
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
673
|
+
function resolveYamlBinary(data) {
|
|
674
|
+
if (data === null) return false;
|
|
675
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
676
|
+
for (idx = 0; idx < max; idx++) {
|
|
677
|
+
code = map2.indexOf(data.charAt(idx));
|
|
678
|
+
if (code > 64) continue;
|
|
679
|
+
if (code < 0) return false;
|
|
680
|
+
bitlen += 6;
|
|
681
|
+
}
|
|
682
|
+
return bitlen % 8 === 0;
|
|
683
|
+
}
|
|
684
|
+
function constructYamlBinary(data) {
|
|
685
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
686
|
+
for (idx = 0; idx < max; idx++) {
|
|
687
|
+
if (idx % 4 === 0 && idx) {
|
|
688
|
+
result.push(bits >> 16 & 255);
|
|
689
|
+
result.push(bits >> 8 & 255);
|
|
690
|
+
result.push(bits & 255);
|
|
691
|
+
}
|
|
692
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
693
|
+
}
|
|
694
|
+
tailbits = max % 4 * 6;
|
|
695
|
+
if (tailbits === 0) {
|
|
696
|
+
result.push(bits >> 16 & 255);
|
|
697
|
+
result.push(bits >> 8 & 255);
|
|
698
|
+
result.push(bits & 255);
|
|
699
|
+
} else if (tailbits === 18) {
|
|
700
|
+
result.push(bits >> 10 & 255);
|
|
701
|
+
result.push(bits >> 2 & 255);
|
|
702
|
+
} else if (tailbits === 12) {
|
|
703
|
+
result.push(bits >> 4 & 255);
|
|
704
|
+
}
|
|
705
|
+
return new Uint8Array(result);
|
|
706
|
+
}
|
|
707
|
+
function representYamlBinary(object) {
|
|
708
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
709
|
+
for (idx = 0; idx < max; idx++) {
|
|
710
|
+
if (idx % 3 === 0 && idx) {
|
|
711
|
+
result += map2[bits >> 18 & 63];
|
|
712
|
+
result += map2[bits >> 12 & 63];
|
|
713
|
+
result += map2[bits >> 6 & 63];
|
|
714
|
+
result += map2[bits & 63];
|
|
715
|
+
}
|
|
716
|
+
bits = (bits << 8) + object[idx];
|
|
717
|
+
}
|
|
718
|
+
tail = max % 3;
|
|
719
|
+
if (tail === 0) {
|
|
720
|
+
result += map2[bits >> 18 & 63];
|
|
721
|
+
result += map2[bits >> 12 & 63];
|
|
722
|
+
result += map2[bits >> 6 & 63];
|
|
723
|
+
result += map2[bits & 63];
|
|
724
|
+
} else if (tail === 2) {
|
|
725
|
+
result += map2[bits >> 10 & 63];
|
|
726
|
+
result += map2[bits >> 4 & 63];
|
|
727
|
+
result += map2[bits << 2 & 63];
|
|
728
|
+
result += map2[64];
|
|
729
|
+
} else if (tail === 1) {
|
|
730
|
+
result += map2[bits >> 2 & 63];
|
|
731
|
+
result += map2[bits << 4 & 63];
|
|
732
|
+
result += map2[64];
|
|
733
|
+
result += map2[64];
|
|
734
|
+
}
|
|
735
|
+
return result;
|
|
736
|
+
}
|
|
737
|
+
function isBinary(obj) {
|
|
738
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
739
|
+
}
|
|
740
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
741
|
+
kind: "scalar",
|
|
742
|
+
resolve: resolveYamlBinary,
|
|
743
|
+
construct: constructYamlBinary,
|
|
744
|
+
predicate: isBinary,
|
|
745
|
+
represent: representYamlBinary
|
|
746
|
+
});
|
|
747
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
748
|
+
var _toString$2 = Object.prototype.toString;
|
|
749
|
+
function resolveYamlOmap(data) {
|
|
750
|
+
if (data === null) return true;
|
|
751
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
752
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
753
|
+
pair = object[index];
|
|
754
|
+
pairHasKey = false;
|
|
755
|
+
if (_toString$2.call(pair) !== "[object Object]") return false;
|
|
756
|
+
for (pairKey in pair) {
|
|
757
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
758
|
+
if (!pairHasKey) pairHasKey = true;
|
|
759
|
+
else return false;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (!pairHasKey) return false;
|
|
763
|
+
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
764
|
+
else return false;
|
|
765
|
+
}
|
|
766
|
+
return true;
|
|
767
|
+
}
|
|
768
|
+
function constructYamlOmap(data) {
|
|
769
|
+
return data !== null ? data : [];
|
|
770
|
+
}
|
|
771
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
772
|
+
kind: "sequence",
|
|
773
|
+
resolve: resolveYamlOmap,
|
|
774
|
+
construct: constructYamlOmap
|
|
775
|
+
});
|
|
776
|
+
var _toString$1 = Object.prototype.toString;
|
|
777
|
+
function resolveYamlPairs(data) {
|
|
778
|
+
if (data === null) return true;
|
|
779
|
+
var index, length, pair, keys, result, object = data;
|
|
780
|
+
result = new Array(object.length);
|
|
781
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
782
|
+
pair = object[index];
|
|
783
|
+
if (_toString$1.call(pair) !== "[object Object]") return false;
|
|
784
|
+
keys = Object.keys(pair);
|
|
785
|
+
if (keys.length !== 1) return false;
|
|
786
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
787
|
+
}
|
|
788
|
+
return true;
|
|
789
|
+
}
|
|
790
|
+
function constructYamlPairs(data) {
|
|
791
|
+
if (data === null) return [];
|
|
792
|
+
var index, length, pair, keys, result, object = data;
|
|
793
|
+
result = new Array(object.length);
|
|
794
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
795
|
+
pair = object[index];
|
|
796
|
+
keys = Object.keys(pair);
|
|
797
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
798
|
+
}
|
|
799
|
+
return result;
|
|
800
|
+
}
|
|
801
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
802
|
+
kind: "sequence",
|
|
803
|
+
resolve: resolveYamlPairs,
|
|
804
|
+
construct: constructYamlPairs
|
|
805
|
+
});
|
|
806
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
807
|
+
function resolveYamlSet(data) {
|
|
808
|
+
if (data === null) return true;
|
|
809
|
+
var key, object = data;
|
|
810
|
+
for (key in object) {
|
|
811
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
812
|
+
if (object[key] !== null) return false;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return true;
|
|
816
|
+
}
|
|
817
|
+
function constructYamlSet(data) {
|
|
818
|
+
return data !== null ? data : {};
|
|
819
|
+
}
|
|
820
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
821
|
+
kind: "mapping",
|
|
822
|
+
resolve: resolveYamlSet,
|
|
823
|
+
construct: constructYamlSet
|
|
824
|
+
});
|
|
825
|
+
var _default = core.extend({
|
|
826
|
+
implicit: [
|
|
827
|
+
timestamp,
|
|
828
|
+
merge
|
|
829
|
+
],
|
|
830
|
+
explicit: [
|
|
831
|
+
binary,
|
|
832
|
+
omap,
|
|
833
|
+
pairs,
|
|
834
|
+
set
|
|
835
|
+
]
|
|
836
|
+
});
|
|
837
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
838
|
+
var CONTEXT_FLOW_IN = 1;
|
|
839
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
840
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
841
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
842
|
+
var CHOMPING_CLIP = 1;
|
|
843
|
+
var CHOMPING_STRIP = 2;
|
|
844
|
+
var CHOMPING_KEEP = 3;
|
|
845
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
846
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
847
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
848
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
849
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
850
|
+
function _class(obj) {
|
|
851
|
+
return Object.prototype.toString.call(obj);
|
|
852
|
+
}
|
|
853
|
+
function is_EOL(c) {
|
|
854
|
+
return c === 10 || c === 13;
|
|
855
|
+
}
|
|
856
|
+
function is_WHITE_SPACE(c) {
|
|
857
|
+
return c === 9 || c === 32;
|
|
858
|
+
}
|
|
859
|
+
function is_WS_OR_EOL(c) {
|
|
860
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
861
|
+
}
|
|
862
|
+
function is_FLOW_INDICATOR(c) {
|
|
863
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
864
|
+
}
|
|
865
|
+
function fromHexCode(c) {
|
|
866
|
+
var lc;
|
|
867
|
+
if (48 <= c && c <= 57) {
|
|
868
|
+
return c - 48;
|
|
869
|
+
}
|
|
870
|
+
lc = c | 32;
|
|
871
|
+
if (97 <= lc && lc <= 102) {
|
|
872
|
+
return lc - 97 + 10;
|
|
873
|
+
}
|
|
874
|
+
return -1;
|
|
875
|
+
}
|
|
876
|
+
function escapedHexLen(c) {
|
|
877
|
+
if (c === 120) {
|
|
878
|
+
return 2;
|
|
879
|
+
}
|
|
880
|
+
if (c === 117) {
|
|
881
|
+
return 4;
|
|
882
|
+
}
|
|
883
|
+
if (c === 85) {
|
|
884
|
+
return 8;
|
|
885
|
+
}
|
|
886
|
+
return 0;
|
|
887
|
+
}
|
|
888
|
+
function fromDecimalCode(c) {
|
|
889
|
+
if (48 <= c && c <= 57) {
|
|
890
|
+
return c - 48;
|
|
891
|
+
}
|
|
892
|
+
return -1;
|
|
893
|
+
}
|
|
894
|
+
function simpleEscapeSequence(c) {
|
|
895
|
+
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
896
|
+
}
|
|
897
|
+
function charFromCodepoint(c) {
|
|
898
|
+
if (c <= 65535) {
|
|
899
|
+
return String.fromCharCode(c);
|
|
900
|
+
}
|
|
901
|
+
return String.fromCharCode(
|
|
902
|
+
(c - 65536 >> 10) + 55296,
|
|
903
|
+
(c - 65536 & 1023) + 56320
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
function setProperty(object, key, value) {
|
|
907
|
+
if (key === "__proto__") {
|
|
908
|
+
Object.defineProperty(object, key, {
|
|
909
|
+
configurable: true,
|
|
910
|
+
enumerable: true,
|
|
911
|
+
writable: true,
|
|
912
|
+
value
|
|
913
|
+
});
|
|
914
|
+
} else {
|
|
915
|
+
object[key] = value;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
var simpleEscapeCheck = new Array(256);
|
|
919
|
+
var simpleEscapeMap = new Array(256);
|
|
920
|
+
for (i = 0; i < 256; i++) {
|
|
921
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
922
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
923
|
+
}
|
|
924
|
+
var i;
|
|
925
|
+
function State$1(input, options) {
|
|
926
|
+
this.input = input;
|
|
927
|
+
this.filename = options["filename"] || null;
|
|
928
|
+
this.schema = options["schema"] || _default;
|
|
929
|
+
this.onWarning = options["onWarning"] || null;
|
|
930
|
+
this.legacy = options["legacy"] || false;
|
|
931
|
+
this.json = options["json"] || false;
|
|
932
|
+
this.listener = options["listener"] || null;
|
|
933
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
934
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
935
|
+
this.length = input.length;
|
|
936
|
+
this.position = 0;
|
|
937
|
+
this.line = 0;
|
|
938
|
+
this.lineStart = 0;
|
|
939
|
+
this.lineIndent = 0;
|
|
940
|
+
this.firstTabInLine = -1;
|
|
941
|
+
this.documents = [];
|
|
942
|
+
}
|
|
943
|
+
function generateError(state, message) {
|
|
944
|
+
var mark = {
|
|
945
|
+
name: state.filename,
|
|
946
|
+
buffer: state.input.slice(0, -1),
|
|
947
|
+
// omit trailing \0
|
|
948
|
+
position: state.position,
|
|
949
|
+
line: state.line,
|
|
950
|
+
column: state.position - state.lineStart
|
|
951
|
+
};
|
|
952
|
+
mark.snippet = snippet(mark);
|
|
953
|
+
return new exception(message, mark);
|
|
954
|
+
}
|
|
955
|
+
function throwError(state, message) {
|
|
956
|
+
throw generateError(state, message);
|
|
957
|
+
}
|
|
958
|
+
function throwWarning(state, message) {
|
|
959
|
+
if (state.onWarning) {
|
|
960
|
+
state.onWarning.call(null, generateError(state, message));
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
var directiveHandlers = {
|
|
964
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
965
|
+
var match, major, minor;
|
|
966
|
+
if (state.version !== null) {
|
|
967
|
+
throwError(state, "duplication of %YAML directive");
|
|
968
|
+
}
|
|
969
|
+
if (args.length !== 1) {
|
|
970
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
971
|
+
}
|
|
972
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
973
|
+
if (match === null) {
|
|
974
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
975
|
+
}
|
|
976
|
+
major = parseInt(match[1], 10);
|
|
977
|
+
minor = parseInt(match[2], 10);
|
|
978
|
+
if (major !== 1) {
|
|
979
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
980
|
+
}
|
|
981
|
+
state.version = args[0];
|
|
982
|
+
state.checkLineBreaks = minor < 2;
|
|
983
|
+
if (minor !== 1 && minor !== 2) {
|
|
984
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
985
|
+
}
|
|
986
|
+
},
|
|
987
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
988
|
+
var handle, prefix;
|
|
989
|
+
if (args.length !== 2) {
|
|
990
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
991
|
+
}
|
|
992
|
+
handle = args[0];
|
|
993
|
+
prefix = args[1];
|
|
994
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
995
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
996
|
+
}
|
|
997
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
998
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
999
|
+
}
|
|
1000
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1001
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1002
|
+
}
|
|
1003
|
+
try {
|
|
1004
|
+
prefix = decodeURIComponent(prefix);
|
|
1005
|
+
} catch (err) {
|
|
1006
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1007
|
+
}
|
|
1008
|
+
state.tagMap[handle] = prefix;
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1012
|
+
var _position, _length, _character, _result;
|
|
1013
|
+
if (start < end) {
|
|
1014
|
+
_result = state.input.slice(start, end);
|
|
1015
|
+
if (checkJson) {
|
|
1016
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1017
|
+
_character = _result.charCodeAt(_position);
|
|
1018
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1019
|
+
throwError(state, "expected valid JSON character");
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1023
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1024
|
+
}
|
|
1025
|
+
state.result += _result;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1029
|
+
var sourceKeys, key, index, quantity;
|
|
1030
|
+
if (!common.isObject(source)) {
|
|
1031
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1032
|
+
}
|
|
1033
|
+
sourceKeys = Object.keys(source);
|
|
1034
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1035
|
+
key = sourceKeys[index];
|
|
1036
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1037
|
+
setProperty(destination, key, source[key]);
|
|
1038
|
+
overridableKeys[key] = true;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1043
|
+
var index, quantity;
|
|
1044
|
+
if (Array.isArray(keyNode)) {
|
|
1045
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1046
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1047
|
+
if (Array.isArray(keyNode[index])) {
|
|
1048
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1049
|
+
}
|
|
1050
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1051
|
+
keyNode[index] = "[object Object]";
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1056
|
+
keyNode = "[object Object]";
|
|
1057
|
+
}
|
|
1058
|
+
keyNode = String(keyNode);
|
|
1059
|
+
if (_result === null) {
|
|
1060
|
+
_result = {};
|
|
1061
|
+
}
|
|
1062
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1063
|
+
if (Array.isArray(valueNode)) {
|
|
1064
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1065
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1066
|
+
}
|
|
1067
|
+
} else {
|
|
1068
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1069
|
+
}
|
|
1070
|
+
} else {
|
|
1071
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1072
|
+
state.line = startLine || state.line;
|
|
1073
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1074
|
+
state.position = startPos || state.position;
|
|
1075
|
+
throwError(state, "duplicated mapping key");
|
|
1076
|
+
}
|
|
1077
|
+
setProperty(_result, keyNode, valueNode);
|
|
1078
|
+
delete overridableKeys[keyNode];
|
|
1079
|
+
}
|
|
1080
|
+
return _result;
|
|
1081
|
+
}
|
|
1082
|
+
function readLineBreak(state) {
|
|
1083
|
+
var ch;
|
|
1084
|
+
ch = state.input.charCodeAt(state.position);
|
|
1085
|
+
if (ch === 10) {
|
|
1086
|
+
state.position++;
|
|
1087
|
+
} else if (ch === 13) {
|
|
1088
|
+
state.position++;
|
|
1089
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1090
|
+
state.position++;
|
|
1091
|
+
}
|
|
1092
|
+
} else {
|
|
1093
|
+
throwError(state, "a line break is expected");
|
|
1094
|
+
}
|
|
1095
|
+
state.line += 1;
|
|
1096
|
+
state.lineStart = state.position;
|
|
1097
|
+
state.firstTabInLine = -1;
|
|
1098
|
+
}
|
|
1099
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1100
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1101
|
+
while (ch !== 0) {
|
|
1102
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1103
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1104
|
+
state.firstTabInLine = state.position;
|
|
1105
|
+
}
|
|
1106
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1107
|
+
}
|
|
1108
|
+
if (allowComments && ch === 35) {
|
|
1109
|
+
do {
|
|
1110
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1111
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1112
|
+
}
|
|
1113
|
+
if (is_EOL(ch)) {
|
|
1114
|
+
readLineBreak(state);
|
|
1115
|
+
ch = state.input.charCodeAt(state.position);
|
|
1116
|
+
lineBreaks++;
|
|
1117
|
+
state.lineIndent = 0;
|
|
1118
|
+
while (ch === 32) {
|
|
1119
|
+
state.lineIndent++;
|
|
1120
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1127
|
+
throwWarning(state, "deficient indentation");
|
|
1128
|
+
}
|
|
1129
|
+
return lineBreaks;
|
|
1130
|
+
}
|
|
1131
|
+
function testDocumentSeparator(state) {
|
|
1132
|
+
var _position = state.position, ch;
|
|
1133
|
+
ch = state.input.charCodeAt(_position);
|
|
1134
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1135
|
+
_position += 3;
|
|
1136
|
+
ch = state.input.charCodeAt(_position);
|
|
1137
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
function writeFoldedLines(state, count) {
|
|
1144
|
+
if (count === 1) {
|
|
1145
|
+
state.result += " ";
|
|
1146
|
+
} else if (count > 1) {
|
|
1147
|
+
state.result += common.repeat("\n", count - 1);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1151
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1152
|
+
ch = state.input.charCodeAt(state.position);
|
|
1153
|
+
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
if (ch === 63 || ch === 45) {
|
|
1157
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1158
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
state.kind = "scalar";
|
|
1163
|
+
state.result = "";
|
|
1164
|
+
captureStart = captureEnd = state.position;
|
|
1165
|
+
hasPendingContent = false;
|
|
1166
|
+
while (ch !== 0) {
|
|
1167
|
+
if (ch === 58) {
|
|
1168
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1169
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
} else if (ch === 35) {
|
|
1173
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1174
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1175
|
+
break;
|
|
1176
|
+
}
|
|
1177
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1178
|
+
break;
|
|
1179
|
+
} else if (is_EOL(ch)) {
|
|
1180
|
+
_line = state.line;
|
|
1181
|
+
_lineStart = state.lineStart;
|
|
1182
|
+
_lineIndent = state.lineIndent;
|
|
1183
|
+
skipSeparationSpace(state, false, -1);
|
|
1184
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1185
|
+
hasPendingContent = true;
|
|
1186
|
+
ch = state.input.charCodeAt(state.position);
|
|
1187
|
+
continue;
|
|
1188
|
+
} else {
|
|
1189
|
+
state.position = captureEnd;
|
|
1190
|
+
state.line = _line;
|
|
1191
|
+
state.lineStart = _lineStart;
|
|
1192
|
+
state.lineIndent = _lineIndent;
|
|
1193
|
+
break;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
if (hasPendingContent) {
|
|
1197
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1198
|
+
writeFoldedLines(state, state.line - _line);
|
|
1199
|
+
captureStart = captureEnd = state.position;
|
|
1200
|
+
hasPendingContent = false;
|
|
1201
|
+
}
|
|
1202
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1203
|
+
captureEnd = state.position + 1;
|
|
1204
|
+
}
|
|
1205
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1206
|
+
}
|
|
1207
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1208
|
+
if (state.result) {
|
|
1209
|
+
return true;
|
|
1210
|
+
}
|
|
1211
|
+
state.kind = _kind;
|
|
1212
|
+
state.result = _result;
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1216
|
+
var ch, captureStart, captureEnd;
|
|
1217
|
+
ch = state.input.charCodeAt(state.position);
|
|
1218
|
+
if (ch !== 39) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
state.kind = "scalar";
|
|
1222
|
+
state.result = "";
|
|
1223
|
+
state.position++;
|
|
1224
|
+
captureStart = captureEnd = state.position;
|
|
1225
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1226
|
+
if (ch === 39) {
|
|
1227
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1228
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1229
|
+
if (ch === 39) {
|
|
1230
|
+
captureStart = state.position;
|
|
1231
|
+
state.position++;
|
|
1232
|
+
captureEnd = state.position;
|
|
1233
|
+
} else {
|
|
1234
|
+
return true;
|
|
1235
|
+
}
|
|
1236
|
+
} else if (is_EOL(ch)) {
|
|
1237
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1238
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1239
|
+
captureStart = captureEnd = state.position;
|
|
1240
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1241
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1242
|
+
} else {
|
|
1243
|
+
state.position++;
|
|
1244
|
+
captureEnd = state.position;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1248
|
+
}
|
|
1249
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1250
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1251
|
+
ch = state.input.charCodeAt(state.position);
|
|
1252
|
+
if (ch !== 34) {
|
|
1253
|
+
return false;
|
|
1254
|
+
}
|
|
1255
|
+
state.kind = "scalar";
|
|
1256
|
+
state.result = "";
|
|
1257
|
+
state.position++;
|
|
1258
|
+
captureStart = captureEnd = state.position;
|
|
1259
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1260
|
+
if (ch === 34) {
|
|
1261
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1262
|
+
state.position++;
|
|
1263
|
+
return true;
|
|
1264
|
+
} else if (ch === 92) {
|
|
1265
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1266
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1267
|
+
if (is_EOL(ch)) {
|
|
1268
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1269
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1270
|
+
state.result += simpleEscapeMap[ch];
|
|
1271
|
+
state.position++;
|
|
1272
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1273
|
+
hexLength = tmp;
|
|
1274
|
+
hexResult = 0;
|
|
1275
|
+
for (; hexLength > 0; hexLength--) {
|
|
1276
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1277
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1278
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1279
|
+
} else {
|
|
1280
|
+
throwError(state, "expected hexadecimal character");
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
state.result += charFromCodepoint(hexResult);
|
|
1284
|
+
state.position++;
|
|
1285
|
+
} else {
|
|
1286
|
+
throwError(state, "unknown escape sequence");
|
|
1287
|
+
}
|
|
1288
|
+
captureStart = captureEnd = state.position;
|
|
1289
|
+
} else if (is_EOL(ch)) {
|
|
1290
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1291
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1292
|
+
captureStart = captureEnd = state.position;
|
|
1293
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1294
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1295
|
+
} else {
|
|
1296
|
+
state.position++;
|
|
1297
|
+
captureEnd = state.position;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1301
|
+
}
|
|
1302
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1303
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1304
|
+
ch = state.input.charCodeAt(state.position);
|
|
1305
|
+
if (ch === 91) {
|
|
1306
|
+
terminator = 93;
|
|
1307
|
+
isMapping = false;
|
|
1308
|
+
_result = [];
|
|
1309
|
+
} else if (ch === 123) {
|
|
1310
|
+
terminator = 125;
|
|
1311
|
+
isMapping = true;
|
|
1312
|
+
_result = {};
|
|
1313
|
+
} else {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1316
|
+
if (state.anchor !== null) {
|
|
1317
|
+
state.anchorMap[state.anchor] = _result;
|
|
1318
|
+
}
|
|
1319
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1320
|
+
while (ch !== 0) {
|
|
1321
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1322
|
+
ch = state.input.charCodeAt(state.position);
|
|
1323
|
+
if (ch === terminator) {
|
|
1324
|
+
state.position++;
|
|
1325
|
+
state.tag = _tag;
|
|
1326
|
+
state.anchor = _anchor;
|
|
1327
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
1328
|
+
state.result = _result;
|
|
1329
|
+
return true;
|
|
1330
|
+
} else if (!readNext) {
|
|
1331
|
+
throwError(state, "missed comma between flow collection entries");
|
|
1332
|
+
} else if (ch === 44) {
|
|
1333
|
+
throwError(state, "expected the node content, but found ','");
|
|
1334
|
+
}
|
|
1335
|
+
keyTag = keyNode = valueNode = null;
|
|
1336
|
+
isPair = isExplicitPair = false;
|
|
1337
|
+
if (ch === 63) {
|
|
1338
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1339
|
+
if (is_WS_OR_EOL(following)) {
|
|
1340
|
+
isPair = isExplicitPair = true;
|
|
1341
|
+
state.position++;
|
|
1342
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
_line = state.line;
|
|
1346
|
+
_lineStart = state.lineStart;
|
|
1347
|
+
_pos = state.position;
|
|
1348
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1349
|
+
keyTag = state.tag;
|
|
1350
|
+
keyNode = state.result;
|
|
1351
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1352
|
+
ch = state.input.charCodeAt(state.position);
|
|
1353
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1354
|
+
isPair = true;
|
|
1355
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1356
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1357
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1358
|
+
valueNode = state.result;
|
|
1359
|
+
}
|
|
1360
|
+
if (isMapping) {
|
|
1361
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1362
|
+
} else if (isPair) {
|
|
1363
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1364
|
+
} else {
|
|
1365
|
+
_result.push(keyNode);
|
|
1366
|
+
}
|
|
1367
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1368
|
+
ch = state.input.charCodeAt(state.position);
|
|
1369
|
+
if (ch === 44) {
|
|
1370
|
+
readNext = true;
|
|
1371
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1372
|
+
} else {
|
|
1373
|
+
readNext = false;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1377
|
+
}
|
|
1378
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1379
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1380
|
+
ch = state.input.charCodeAt(state.position);
|
|
1381
|
+
if (ch === 124) {
|
|
1382
|
+
folding = false;
|
|
1383
|
+
} else if (ch === 62) {
|
|
1384
|
+
folding = true;
|
|
1385
|
+
} else {
|
|
1386
|
+
return false;
|
|
1387
|
+
}
|
|
1388
|
+
state.kind = "scalar";
|
|
1389
|
+
state.result = "";
|
|
1390
|
+
while (ch !== 0) {
|
|
1391
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1392
|
+
if (ch === 43 || ch === 45) {
|
|
1393
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1394
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1395
|
+
} else {
|
|
1396
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
1397
|
+
}
|
|
1398
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1399
|
+
if (tmp === 0) {
|
|
1400
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1401
|
+
} else if (!detectedIndent) {
|
|
1402
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1403
|
+
detectedIndent = true;
|
|
1404
|
+
} else {
|
|
1405
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
1406
|
+
}
|
|
1407
|
+
} else {
|
|
1408
|
+
break;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1412
|
+
do {
|
|
1413
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1414
|
+
} while (is_WHITE_SPACE(ch));
|
|
1415
|
+
if (ch === 35) {
|
|
1416
|
+
do {
|
|
1417
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1418
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
while (ch !== 0) {
|
|
1422
|
+
readLineBreak(state);
|
|
1423
|
+
state.lineIndent = 0;
|
|
1424
|
+
ch = state.input.charCodeAt(state.position);
|
|
1425
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1426
|
+
state.lineIndent++;
|
|
1427
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1428
|
+
}
|
|
1429
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1430
|
+
textIndent = state.lineIndent;
|
|
1431
|
+
}
|
|
1432
|
+
if (is_EOL(ch)) {
|
|
1433
|
+
emptyLines++;
|
|
1434
|
+
continue;
|
|
1435
|
+
}
|
|
1436
|
+
if (state.lineIndent < textIndent) {
|
|
1437
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1438
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1439
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1440
|
+
if (didReadContent) {
|
|
1441
|
+
state.result += "\n";
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
if (folding) {
|
|
1447
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1448
|
+
atMoreIndented = true;
|
|
1449
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1450
|
+
} else if (atMoreIndented) {
|
|
1451
|
+
atMoreIndented = false;
|
|
1452
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
1453
|
+
} else if (emptyLines === 0) {
|
|
1454
|
+
if (didReadContent) {
|
|
1455
|
+
state.result += " ";
|
|
1456
|
+
}
|
|
1457
|
+
} else {
|
|
1458
|
+
state.result += common.repeat("\n", emptyLines);
|
|
1459
|
+
}
|
|
1460
|
+
} else {
|
|
1461
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1462
|
+
}
|
|
1463
|
+
didReadContent = true;
|
|
1464
|
+
detectedIndent = true;
|
|
1465
|
+
emptyLines = 0;
|
|
1466
|
+
captureStart = state.position;
|
|
1467
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
1468
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1469
|
+
}
|
|
1470
|
+
captureSegment(state, captureStart, state.position, false);
|
|
1471
|
+
}
|
|
1472
|
+
return true;
|
|
1473
|
+
}
|
|
1474
|
+
function readBlockSequence(state, nodeIndent) {
|
|
1475
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1476
|
+
if (state.firstTabInLine !== -1) return false;
|
|
1477
|
+
if (state.anchor !== null) {
|
|
1478
|
+
state.anchorMap[state.anchor] = _result;
|
|
1479
|
+
}
|
|
1480
|
+
ch = state.input.charCodeAt(state.position);
|
|
1481
|
+
while (ch !== 0) {
|
|
1482
|
+
if (state.firstTabInLine !== -1) {
|
|
1483
|
+
state.position = state.firstTabInLine;
|
|
1484
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1485
|
+
}
|
|
1486
|
+
if (ch !== 45) {
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1490
|
+
if (!is_WS_OR_EOL(following)) {
|
|
1491
|
+
break;
|
|
1492
|
+
}
|
|
1493
|
+
detected = true;
|
|
1494
|
+
state.position++;
|
|
1495
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1496
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1497
|
+
_result.push(null);
|
|
1498
|
+
ch = state.input.charCodeAt(state.position);
|
|
1499
|
+
continue;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
_line = state.line;
|
|
1503
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1504
|
+
_result.push(state.result);
|
|
1505
|
+
skipSeparationSpace(state, true, -1);
|
|
1506
|
+
ch = state.input.charCodeAt(state.position);
|
|
1507
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1508
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
1509
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1510
|
+
break;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
if (detected) {
|
|
1514
|
+
state.tag = _tag;
|
|
1515
|
+
state.anchor = _anchor;
|
|
1516
|
+
state.kind = "sequence";
|
|
1517
|
+
state.result = _result;
|
|
1518
|
+
return true;
|
|
1519
|
+
}
|
|
1520
|
+
return false;
|
|
1521
|
+
}
|
|
1522
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1523
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1524
|
+
if (state.firstTabInLine !== -1) return false;
|
|
1525
|
+
if (state.anchor !== null) {
|
|
1526
|
+
state.anchorMap[state.anchor] = _result;
|
|
1527
|
+
}
|
|
1528
|
+
ch = state.input.charCodeAt(state.position);
|
|
1529
|
+
while (ch !== 0) {
|
|
1530
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1531
|
+
state.position = state.firstTabInLine;
|
|
1532
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1533
|
+
}
|
|
1534
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1535
|
+
_line = state.line;
|
|
1536
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1537
|
+
if (ch === 63) {
|
|
1538
|
+
if (atExplicitKey) {
|
|
1539
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1540
|
+
keyTag = keyNode = valueNode = null;
|
|
1541
|
+
}
|
|
1542
|
+
detected = true;
|
|
1543
|
+
atExplicitKey = true;
|
|
1544
|
+
allowCompact = true;
|
|
1545
|
+
} else if (atExplicitKey) {
|
|
1546
|
+
atExplicitKey = false;
|
|
1547
|
+
allowCompact = true;
|
|
1548
|
+
} else {
|
|
1549
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1550
|
+
}
|
|
1551
|
+
state.position += 1;
|
|
1552
|
+
ch = following;
|
|
1553
|
+
} else {
|
|
1554
|
+
_keyLine = state.line;
|
|
1555
|
+
_keyLineStart = state.lineStart;
|
|
1556
|
+
_keyPos = state.position;
|
|
1557
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
if (state.line === _line) {
|
|
1561
|
+
ch = state.input.charCodeAt(state.position);
|
|
1562
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1563
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1564
|
+
}
|
|
1565
|
+
if (ch === 58) {
|
|
1566
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1567
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
1568
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1569
|
+
}
|
|
1570
|
+
if (atExplicitKey) {
|
|
1571
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1572
|
+
keyTag = keyNode = valueNode = null;
|
|
1573
|
+
}
|
|
1574
|
+
detected = true;
|
|
1575
|
+
atExplicitKey = false;
|
|
1576
|
+
allowCompact = false;
|
|
1577
|
+
keyTag = state.tag;
|
|
1578
|
+
keyNode = state.result;
|
|
1579
|
+
} else if (detected) {
|
|
1580
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1581
|
+
} else {
|
|
1582
|
+
state.tag = _tag;
|
|
1583
|
+
state.anchor = _anchor;
|
|
1584
|
+
return true;
|
|
1585
|
+
}
|
|
1586
|
+
} else if (detected) {
|
|
1587
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1588
|
+
} else {
|
|
1589
|
+
state.tag = _tag;
|
|
1590
|
+
state.anchor = _anchor;
|
|
1591
|
+
return true;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1595
|
+
if (atExplicitKey) {
|
|
1596
|
+
_keyLine = state.line;
|
|
1597
|
+
_keyLineStart = state.lineStart;
|
|
1598
|
+
_keyPos = state.position;
|
|
1599
|
+
}
|
|
1600
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1601
|
+
if (atExplicitKey) {
|
|
1602
|
+
keyNode = state.result;
|
|
1603
|
+
} else {
|
|
1604
|
+
valueNode = state.result;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (!atExplicitKey) {
|
|
1608
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1609
|
+
keyTag = keyNode = valueNode = null;
|
|
1610
|
+
}
|
|
1611
|
+
skipSeparationSpace(state, true, -1);
|
|
1612
|
+
ch = state.input.charCodeAt(state.position);
|
|
1613
|
+
}
|
|
1614
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1615
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
1616
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
if (atExplicitKey) {
|
|
1621
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1622
|
+
}
|
|
1623
|
+
if (detected) {
|
|
1624
|
+
state.tag = _tag;
|
|
1625
|
+
state.anchor = _anchor;
|
|
1626
|
+
state.kind = "mapping";
|
|
1627
|
+
state.result = _result;
|
|
1628
|
+
}
|
|
1629
|
+
return detected;
|
|
1630
|
+
}
|
|
1631
|
+
function readTagProperty(state) {
|
|
1632
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1633
|
+
ch = state.input.charCodeAt(state.position);
|
|
1634
|
+
if (ch !== 33) return false;
|
|
1635
|
+
if (state.tag !== null) {
|
|
1636
|
+
throwError(state, "duplication of a tag property");
|
|
1637
|
+
}
|
|
1638
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1639
|
+
if (ch === 60) {
|
|
1640
|
+
isVerbatim = true;
|
|
1641
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1642
|
+
} else if (ch === 33) {
|
|
1643
|
+
isNamed = true;
|
|
1644
|
+
tagHandle = "!!";
|
|
1645
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1646
|
+
} else {
|
|
1647
|
+
tagHandle = "!";
|
|
1648
|
+
}
|
|
1649
|
+
_position = state.position;
|
|
1650
|
+
if (isVerbatim) {
|
|
1651
|
+
do {
|
|
1652
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1653
|
+
} while (ch !== 0 && ch !== 62);
|
|
1654
|
+
if (state.position < state.length) {
|
|
1655
|
+
tagName = state.input.slice(_position, state.position);
|
|
1656
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1657
|
+
} else {
|
|
1658
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1659
|
+
}
|
|
1660
|
+
} else {
|
|
1661
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1662
|
+
if (ch === 33) {
|
|
1663
|
+
if (!isNamed) {
|
|
1664
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1665
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1666
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
1667
|
+
}
|
|
1668
|
+
isNamed = true;
|
|
1669
|
+
_position = state.position + 1;
|
|
1670
|
+
} else {
|
|
1671
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1675
|
+
}
|
|
1676
|
+
tagName = state.input.slice(_position, state.position);
|
|
1677
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1678
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1682
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
1683
|
+
}
|
|
1684
|
+
try {
|
|
1685
|
+
tagName = decodeURIComponent(tagName);
|
|
1686
|
+
} catch (err) {
|
|
1687
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
1688
|
+
}
|
|
1689
|
+
if (isVerbatim) {
|
|
1690
|
+
state.tag = tagName;
|
|
1691
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
1692
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1693
|
+
} else if (tagHandle === "!") {
|
|
1694
|
+
state.tag = "!" + tagName;
|
|
1695
|
+
} else if (tagHandle === "!!") {
|
|
1696
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
1697
|
+
} else {
|
|
1698
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1699
|
+
}
|
|
1700
|
+
return true;
|
|
1701
|
+
}
|
|
1702
|
+
function readAnchorProperty(state) {
|
|
1703
|
+
var _position, ch;
|
|
1704
|
+
ch = state.input.charCodeAt(state.position);
|
|
1705
|
+
if (ch !== 38) return false;
|
|
1706
|
+
if (state.anchor !== null) {
|
|
1707
|
+
throwError(state, "duplication of an anchor property");
|
|
1708
|
+
}
|
|
1709
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1710
|
+
_position = state.position;
|
|
1711
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1712
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1713
|
+
}
|
|
1714
|
+
if (state.position === _position) {
|
|
1715
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
1716
|
+
}
|
|
1717
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
1718
|
+
return true;
|
|
1719
|
+
}
|
|
1720
|
+
function readAlias(state) {
|
|
1721
|
+
var _position, alias, ch;
|
|
1722
|
+
ch = state.input.charCodeAt(state.position);
|
|
1723
|
+
if (ch !== 42) return false;
|
|
1724
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1725
|
+
_position = state.position;
|
|
1726
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1727
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1728
|
+
}
|
|
1729
|
+
if (state.position === _position) {
|
|
1730
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
1731
|
+
}
|
|
1732
|
+
alias = state.input.slice(_position, state.position);
|
|
1733
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
1734
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
1735
|
+
}
|
|
1736
|
+
state.result = state.anchorMap[alias];
|
|
1737
|
+
skipSeparationSpace(state, true, -1);
|
|
1738
|
+
return true;
|
|
1739
|
+
}
|
|
1740
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1741
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
1742
|
+
if (state.listener !== null) {
|
|
1743
|
+
state.listener("open", state);
|
|
1744
|
+
}
|
|
1745
|
+
state.tag = null;
|
|
1746
|
+
state.anchor = null;
|
|
1747
|
+
state.kind = null;
|
|
1748
|
+
state.result = null;
|
|
1749
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
1750
|
+
if (allowToSeek) {
|
|
1751
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1752
|
+
atNewLine = true;
|
|
1753
|
+
if (state.lineIndent > parentIndent) {
|
|
1754
|
+
indentStatus = 1;
|
|
1755
|
+
} else if (state.lineIndent === parentIndent) {
|
|
1756
|
+
indentStatus = 0;
|
|
1757
|
+
} else if (state.lineIndent < parentIndent) {
|
|
1758
|
+
indentStatus = -1;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
if (indentStatus === 1) {
|
|
1763
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
1764
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1765
|
+
atNewLine = true;
|
|
1766
|
+
allowBlockCollections = allowBlockStyles;
|
|
1767
|
+
if (state.lineIndent > parentIndent) {
|
|
1768
|
+
indentStatus = 1;
|
|
1769
|
+
} else if (state.lineIndent === parentIndent) {
|
|
1770
|
+
indentStatus = 0;
|
|
1771
|
+
} else if (state.lineIndent < parentIndent) {
|
|
1772
|
+
indentStatus = -1;
|
|
1773
|
+
}
|
|
1774
|
+
} else {
|
|
1775
|
+
allowBlockCollections = false;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
if (allowBlockCollections) {
|
|
1780
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
1781
|
+
}
|
|
1782
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1783
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
1784
|
+
flowIndent = parentIndent;
|
|
1785
|
+
} else {
|
|
1786
|
+
flowIndent = parentIndent + 1;
|
|
1787
|
+
}
|
|
1788
|
+
blockIndent = state.position - state.lineStart;
|
|
1789
|
+
if (indentStatus === 1) {
|
|
1790
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
1791
|
+
hasContent = true;
|
|
1792
|
+
} else {
|
|
1793
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
1794
|
+
hasContent = true;
|
|
1795
|
+
} else if (readAlias(state)) {
|
|
1796
|
+
hasContent = true;
|
|
1797
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
1798
|
+
throwError(state, "alias node should not have any properties");
|
|
1799
|
+
}
|
|
1800
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1801
|
+
hasContent = true;
|
|
1802
|
+
if (state.tag === null) {
|
|
1803
|
+
state.tag = "?";
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
if (state.anchor !== null) {
|
|
1807
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
} else if (indentStatus === 0) {
|
|
1811
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
if (state.tag === null) {
|
|
1815
|
+
if (state.anchor !== null) {
|
|
1816
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1817
|
+
}
|
|
1818
|
+
} else if (state.tag === "?") {
|
|
1819
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
1820
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
1821
|
+
}
|
|
1822
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1823
|
+
type2 = state.implicitTypes[typeIndex];
|
|
1824
|
+
if (type2.resolve(state.result)) {
|
|
1825
|
+
state.result = type2.construct(state.result);
|
|
1826
|
+
state.tag = type2.tag;
|
|
1827
|
+
if (state.anchor !== null) {
|
|
1828
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1829
|
+
}
|
|
1830
|
+
break;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
} else if (state.tag !== "!") {
|
|
1834
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
1835
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
1836
|
+
} else {
|
|
1837
|
+
type2 = null;
|
|
1838
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
1839
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1840
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
1841
|
+
type2 = typeList[typeIndex];
|
|
1842
|
+
break;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if (!type2) {
|
|
1847
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
1848
|
+
}
|
|
1849
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
1850
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
1851
|
+
}
|
|
1852
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
1853
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
1854
|
+
} else {
|
|
1855
|
+
state.result = type2.construct(state.result, state.tag);
|
|
1856
|
+
if (state.anchor !== null) {
|
|
1857
|
+
state.anchorMap[state.anchor] = state.result;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
if (state.listener !== null) {
|
|
1862
|
+
state.listener("close", state);
|
|
1863
|
+
}
|
|
1864
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
1865
|
+
}
|
|
1866
|
+
function readDocument(state) {
|
|
1867
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
1868
|
+
state.version = null;
|
|
1869
|
+
state.checkLineBreaks = state.legacy;
|
|
1870
|
+
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
1871
|
+
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
1872
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1873
|
+
skipSeparationSpace(state, true, -1);
|
|
1874
|
+
ch = state.input.charCodeAt(state.position);
|
|
1875
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
1876
|
+
break;
|
|
1877
|
+
}
|
|
1878
|
+
hasDirectives = true;
|
|
1879
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1880
|
+
_position = state.position;
|
|
1881
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1882
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1883
|
+
}
|
|
1884
|
+
directiveName = state.input.slice(_position, state.position);
|
|
1885
|
+
directiveArgs = [];
|
|
1886
|
+
if (directiveName.length < 1) {
|
|
1887
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
1888
|
+
}
|
|
1889
|
+
while (ch !== 0) {
|
|
1890
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1891
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1892
|
+
}
|
|
1893
|
+
if (ch === 35) {
|
|
1894
|
+
do {
|
|
1895
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1896
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
1897
|
+
break;
|
|
1898
|
+
}
|
|
1899
|
+
if (is_EOL(ch)) break;
|
|
1900
|
+
_position = state.position;
|
|
1901
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1902
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1903
|
+
}
|
|
1904
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
1905
|
+
}
|
|
1906
|
+
if (ch !== 0) readLineBreak(state);
|
|
1907
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
1908
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
1909
|
+
} else {
|
|
1910
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
skipSeparationSpace(state, true, -1);
|
|
1914
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
1915
|
+
state.position += 3;
|
|
1916
|
+
skipSeparationSpace(state, true, -1);
|
|
1917
|
+
} else if (hasDirectives) {
|
|
1918
|
+
throwError(state, "directives end mark is expected");
|
|
1919
|
+
}
|
|
1920
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
1921
|
+
skipSeparationSpace(state, true, -1);
|
|
1922
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
1923
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
1924
|
+
}
|
|
1925
|
+
state.documents.push(state.result);
|
|
1926
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1927
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
1928
|
+
state.position += 3;
|
|
1929
|
+
skipSeparationSpace(state, true, -1);
|
|
1930
|
+
}
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
if (state.position < state.length - 1) {
|
|
1934
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
1935
|
+
} else {
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
function loadDocuments(input, options) {
|
|
1940
|
+
input = String(input);
|
|
1941
|
+
options = options || {};
|
|
1942
|
+
if (input.length !== 0) {
|
|
1943
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
1944
|
+
input += "\n";
|
|
1945
|
+
}
|
|
1946
|
+
if (input.charCodeAt(0) === 65279) {
|
|
1947
|
+
input = input.slice(1);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
var state = new State$1(input, options);
|
|
1951
|
+
var nullpos = input.indexOf("\0");
|
|
1952
|
+
if (nullpos !== -1) {
|
|
1953
|
+
state.position = nullpos;
|
|
1954
|
+
throwError(state, "null byte is not allowed in input");
|
|
1955
|
+
}
|
|
1956
|
+
state.input += "\0";
|
|
1957
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
1958
|
+
state.lineIndent += 1;
|
|
1959
|
+
state.position += 1;
|
|
1960
|
+
}
|
|
1961
|
+
while (state.position < state.length - 1) {
|
|
1962
|
+
readDocument(state);
|
|
1963
|
+
}
|
|
1964
|
+
return state.documents;
|
|
1965
|
+
}
|
|
1966
|
+
function loadAll$1(input, iterator, options) {
|
|
1967
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
1968
|
+
options = iterator;
|
|
1969
|
+
iterator = null;
|
|
1970
|
+
}
|
|
1971
|
+
var documents = loadDocuments(input, options);
|
|
1972
|
+
if (typeof iterator !== "function") {
|
|
1973
|
+
return documents;
|
|
1974
|
+
}
|
|
1975
|
+
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
1976
|
+
iterator(documents[index]);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
function load$1(input, options) {
|
|
1980
|
+
var documents = loadDocuments(input, options);
|
|
1981
|
+
if (documents.length === 0) {
|
|
1982
|
+
return void 0;
|
|
1983
|
+
} else if (documents.length === 1) {
|
|
1984
|
+
return documents[0];
|
|
1985
|
+
}
|
|
1986
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
1987
|
+
}
|
|
1988
|
+
var loadAll_1 = loadAll$1;
|
|
1989
|
+
var load_1 = load$1;
|
|
1990
|
+
var loader = {
|
|
1991
|
+
loadAll: loadAll_1,
|
|
1992
|
+
load: load_1
|
|
1993
|
+
};
|
|
1994
|
+
var _toString = Object.prototype.toString;
|
|
1995
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1996
|
+
var CHAR_BOM = 65279;
|
|
1997
|
+
var CHAR_TAB = 9;
|
|
1998
|
+
var CHAR_LINE_FEED = 10;
|
|
1999
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2000
|
+
var CHAR_SPACE = 32;
|
|
2001
|
+
var CHAR_EXCLAMATION = 33;
|
|
2002
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2003
|
+
var CHAR_SHARP = 35;
|
|
2004
|
+
var CHAR_PERCENT = 37;
|
|
2005
|
+
var CHAR_AMPERSAND = 38;
|
|
2006
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2007
|
+
var CHAR_ASTERISK = 42;
|
|
2008
|
+
var CHAR_COMMA = 44;
|
|
2009
|
+
var CHAR_MINUS = 45;
|
|
2010
|
+
var CHAR_COLON = 58;
|
|
2011
|
+
var CHAR_EQUALS = 61;
|
|
2012
|
+
var CHAR_GREATER_THAN = 62;
|
|
2013
|
+
var CHAR_QUESTION = 63;
|
|
2014
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2015
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2016
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2017
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2018
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2019
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2020
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2021
|
+
var ESCAPE_SEQUENCES = {};
|
|
2022
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2023
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2024
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2025
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2026
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2027
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2028
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2029
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2030
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2031
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2032
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2033
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2034
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2035
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2036
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2037
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2038
|
+
"y",
|
|
2039
|
+
"Y",
|
|
2040
|
+
"yes",
|
|
2041
|
+
"Yes",
|
|
2042
|
+
"YES",
|
|
2043
|
+
"on",
|
|
2044
|
+
"On",
|
|
2045
|
+
"ON",
|
|
2046
|
+
"n",
|
|
2047
|
+
"N",
|
|
2048
|
+
"no",
|
|
2049
|
+
"No",
|
|
2050
|
+
"NO",
|
|
2051
|
+
"off",
|
|
2052
|
+
"Off",
|
|
2053
|
+
"OFF"
|
|
2054
|
+
];
|
|
2055
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2056
|
+
function compileStyleMap(schema2, map2) {
|
|
2057
|
+
var result, keys, index, length, tag, style, type2;
|
|
2058
|
+
if (map2 === null) return {};
|
|
2059
|
+
result = {};
|
|
2060
|
+
keys = Object.keys(map2);
|
|
2061
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2062
|
+
tag = keys[index];
|
|
2063
|
+
style = String(map2[tag]);
|
|
2064
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2065
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2066
|
+
}
|
|
2067
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2068
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2069
|
+
style = type2.styleAliases[style];
|
|
2070
|
+
}
|
|
2071
|
+
result[tag] = style;
|
|
2072
|
+
}
|
|
2073
|
+
return result;
|
|
2074
|
+
}
|
|
2075
|
+
function encodeHex(character) {
|
|
2076
|
+
var string, handle, length;
|
|
2077
|
+
string = character.toString(16).toUpperCase();
|
|
2078
|
+
if (character <= 255) {
|
|
2079
|
+
handle = "x";
|
|
2080
|
+
length = 2;
|
|
2081
|
+
} else if (character <= 65535) {
|
|
2082
|
+
handle = "u";
|
|
2083
|
+
length = 4;
|
|
2084
|
+
} else if (character <= 4294967295) {
|
|
2085
|
+
handle = "U";
|
|
2086
|
+
length = 8;
|
|
2087
|
+
} else {
|
|
2088
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2089
|
+
}
|
|
2090
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2091
|
+
}
|
|
2092
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
2093
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
2094
|
+
function State(options) {
|
|
2095
|
+
this.schema = options["schema"] || _default;
|
|
2096
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2097
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2098
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2099
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2100
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2101
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2102
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2103
|
+
this.noRefs = options["noRefs"] || false;
|
|
2104
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2105
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2106
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2107
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
2108
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2109
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2110
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2111
|
+
this.tag = null;
|
|
2112
|
+
this.result = "";
|
|
2113
|
+
this.duplicates = [];
|
|
2114
|
+
this.usedDuplicates = null;
|
|
2115
|
+
}
|
|
2116
|
+
function indentString(string, spaces) {
|
|
2117
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2118
|
+
while (position < length) {
|
|
2119
|
+
next = string.indexOf("\n", position);
|
|
2120
|
+
if (next === -1) {
|
|
2121
|
+
line = string.slice(position);
|
|
2122
|
+
position = length;
|
|
2123
|
+
} else {
|
|
2124
|
+
line = string.slice(position, next + 1);
|
|
2125
|
+
position = next + 1;
|
|
2126
|
+
}
|
|
2127
|
+
if (line.length && line !== "\n") result += ind;
|
|
2128
|
+
result += line;
|
|
2129
|
+
}
|
|
2130
|
+
return result;
|
|
2131
|
+
}
|
|
2132
|
+
function generateNextLine(state, level) {
|
|
2133
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
2134
|
+
}
|
|
2135
|
+
function testImplicitResolving(state, str2) {
|
|
2136
|
+
var index, length, type2;
|
|
2137
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2138
|
+
type2 = state.implicitTypes[index];
|
|
2139
|
+
if (type2.resolve(str2)) {
|
|
2140
|
+
return true;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
return false;
|
|
2144
|
+
}
|
|
2145
|
+
function isWhitespace(c) {
|
|
2146
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2147
|
+
}
|
|
2148
|
+
function isPrintable(c) {
|
|
2149
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2150
|
+
}
|
|
2151
|
+
function isNsCharOrWhitespace(c) {
|
|
2152
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2153
|
+
}
|
|
2154
|
+
function isPlainSafe(c, prev, inblock) {
|
|
2155
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2156
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2157
|
+
return (
|
|
2158
|
+
// ns-plain-safe
|
|
2159
|
+
(inblock ? (
|
|
2160
|
+
// c = flow-in
|
|
2161
|
+
cIsNsCharOrWhitespace
|
|
2162
|
+
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
2163
|
+
);
|
|
2164
|
+
}
|
|
2165
|
+
function isPlainSafeFirst(c) {
|
|
2166
|
+
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2167
|
+
}
|
|
2168
|
+
function isPlainSafeLast(c) {
|
|
2169
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2170
|
+
}
|
|
2171
|
+
function codePointAt(string, pos) {
|
|
2172
|
+
var first = string.charCodeAt(pos), second;
|
|
2173
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2174
|
+
second = string.charCodeAt(pos + 1);
|
|
2175
|
+
if (second >= 56320 && second <= 57343) {
|
|
2176
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
return first;
|
|
2180
|
+
}
|
|
2181
|
+
function needIndentIndicator(string) {
|
|
2182
|
+
var leadingSpaceRe = /^\n* /;
|
|
2183
|
+
return leadingSpaceRe.test(string);
|
|
2184
|
+
}
|
|
2185
|
+
var STYLE_PLAIN = 1;
|
|
2186
|
+
var STYLE_SINGLE = 2;
|
|
2187
|
+
var STYLE_LITERAL = 3;
|
|
2188
|
+
var STYLE_FOLDED = 4;
|
|
2189
|
+
var STYLE_DOUBLE = 5;
|
|
2190
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2191
|
+
var i;
|
|
2192
|
+
var char = 0;
|
|
2193
|
+
var prevChar = null;
|
|
2194
|
+
var hasLineBreak = false;
|
|
2195
|
+
var hasFoldableLine = false;
|
|
2196
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2197
|
+
var previousLineBreak = -1;
|
|
2198
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2199
|
+
if (singleLineOnly || forceQuotes) {
|
|
2200
|
+
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2201
|
+
char = codePointAt(string, i);
|
|
2202
|
+
if (!isPrintable(char)) {
|
|
2203
|
+
return STYLE_DOUBLE;
|
|
2204
|
+
}
|
|
2205
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2206
|
+
prevChar = char;
|
|
2207
|
+
}
|
|
2208
|
+
} else {
|
|
2209
|
+
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2210
|
+
char = codePointAt(string, i);
|
|
2211
|
+
if (char === CHAR_LINE_FEED) {
|
|
2212
|
+
hasLineBreak = true;
|
|
2213
|
+
if (shouldTrackWidth) {
|
|
2214
|
+
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2215
|
+
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2216
|
+
previousLineBreak = i;
|
|
2217
|
+
}
|
|
2218
|
+
} else if (!isPrintable(char)) {
|
|
2219
|
+
return STYLE_DOUBLE;
|
|
2220
|
+
}
|
|
2221
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2222
|
+
prevChar = char;
|
|
2223
|
+
}
|
|
2224
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2225
|
+
}
|
|
2226
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2227
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2228
|
+
return STYLE_PLAIN;
|
|
2229
|
+
}
|
|
2230
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2231
|
+
}
|
|
2232
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2233
|
+
return STYLE_DOUBLE;
|
|
2234
|
+
}
|
|
2235
|
+
if (!forceQuotes) {
|
|
2236
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2237
|
+
}
|
|
2238
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2239
|
+
}
|
|
2240
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
2241
|
+
state.dump = (function() {
|
|
2242
|
+
if (string.length === 0) {
|
|
2243
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2244
|
+
}
|
|
2245
|
+
if (!state.noCompatMode) {
|
|
2246
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2247
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
var indent = state.indent * Math.max(1, level);
|
|
2251
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2252
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2253
|
+
function testAmbiguity(string2) {
|
|
2254
|
+
return testImplicitResolving(state, string2);
|
|
2255
|
+
}
|
|
2256
|
+
switch (chooseScalarStyle(
|
|
2257
|
+
string,
|
|
2258
|
+
singleLineOnly,
|
|
2259
|
+
state.indent,
|
|
2260
|
+
lineWidth,
|
|
2261
|
+
testAmbiguity,
|
|
2262
|
+
state.quotingType,
|
|
2263
|
+
state.forceQuotes && !iskey,
|
|
2264
|
+
inblock
|
|
2265
|
+
)) {
|
|
2266
|
+
case STYLE_PLAIN:
|
|
2267
|
+
return string;
|
|
2268
|
+
case STYLE_SINGLE:
|
|
2269
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
2270
|
+
case STYLE_LITERAL:
|
|
2271
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2272
|
+
case STYLE_FOLDED:
|
|
2273
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2274
|
+
case STYLE_DOUBLE:
|
|
2275
|
+
return '"' + escapeString(string) + '"';
|
|
2276
|
+
default:
|
|
2277
|
+
throw new exception("impossible error: invalid scalar style");
|
|
2278
|
+
}
|
|
2279
|
+
})();
|
|
2280
|
+
}
|
|
2281
|
+
function blockHeader(string, indentPerLevel) {
|
|
2282
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2283
|
+
var clip = string[string.length - 1] === "\n";
|
|
2284
|
+
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
2285
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2286
|
+
return indentIndicator + chomp + "\n";
|
|
2287
|
+
}
|
|
2288
|
+
function dropEndingNewline(string) {
|
|
2289
|
+
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2290
|
+
}
|
|
2291
|
+
function foldString(string, width) {
|
|
2292
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
2293
|
+
var result = (function() {
|
|
2294
|
+
var nextLF = string.indexOf("\n");
|
|
2295
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2296
|
+
lineRe.lastIndex = nextLF;
|
|
2297
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
2298
|
+
})();
|
|
2299
|
+
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2300
|
+
var moreIndented;
|
|
2301
|
+
var match;
|
|
2302
|
+
while (match = lineRe.exec(string)) {
|
|
2303
|
+
var prefix = match[1], line = match[2];
|
|
2304
|
+
moreIndented = line[0] === " ";
|
|
2305
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2306
|
+
prevMoreIndented = moreIndented;
|
|
2307
|
+
}
|
|
2308
|
+
return result;
|
|
2309
|
+
}
|
|
2310
|
+
function foldLine(line, width) {
|
|
2311
|
+
if (line === "" || line[0] === " ") return line;
|
|
2312
|
+
var breakRe = / [^ ]/g;
|
|
2313
|
+
var match;
|
|
2314
|
+
var start = 0, end, curr = 0, next = 0;
|
|
2315
|
+
var result = "";
|
|
2316
|
+
while (match = breakRe.exec(line)) {
|
|
2317
|
+
next = match.index;
|
|
2318
|
+
if (next - start > width) {
|
|
2319
|
+
end = curr > start ? curr : next;
|
|
2320
|
+
result += "\n" + line.slice(start, end);
|
|
2321
|
+
start = end + 1;
|
|
2322
|
+
}
|
|
2323
|
+
curr = next;
|
|
2324
|
+
}
|
|
2325
|
+
result += "\n";
|
|
2326
|
+
if (line.length - start > width && curr > start) {
|
|
2327
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2328
|
+
} else {
|
|
2329
|
+
result += line.slice(start);
|
|
2330
|
+
}
|
|
2331
|
+
return result.slice(1);
|
|
2332
|
+
}
|
|
2333
|
+
function escapeString(string) {
|
|
2334
|
+
var result = "";
|
|
2335
|
+
var char = 0;
|
|
2336
|
+
var escapeSeq;
|
|
2337
|
+
for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2338
|
+
char = codePointAt(string, i);
|
|
2339
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2340
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
2341
|
+
result += string[i];
|
|
2342
|
+
if (char >= 65536) result += string[i + 1];
|
|
2343
|
+
} else {
|
|
2344
|
+
result += escapeSeq || encodeHex(char);
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
return result;
|
|
2348
|
+
}
|
|
2349
|
+
function writeFlowSequence(state, level, object) {
|
|
2350
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2351
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2352
|
+
value = object[index];
|
|
2353
|
+
if (state.replacer) {
|
|
2354
|
+
value = state.replacer.call(object, String(index), value);
|
|
2355
|
+
}
|
|
2356
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2357
|
+
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
2358
|
+
_result += state.dump;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
state.tag = _tag;
|
|
2362
|
+
state.dump = "[" + _result + "]";
|
|
2363
|
+
}
|
|
2364
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
2365
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2366
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2367
|
+
value = object[index];
|
|
2368
|
+
if (state.replacer) {
|
|
2369
|
+
value = state.replacer.call(object, String(index), value);
|
|
2370
|
+
}
|
|
2371
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2372
|
+
if (!compact || _result !== "") {
|
|
2373
|
+
_result += generateNextLine(state, level);
|
|
2374
|
+
}
|
|
2375
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2376
|
+
_result += "-";
|
|
2377
|
+
} else {
|
|
2378
|
+
_result += "- ";
|
|
2379
|
+
}
|
|
2380
|
+
_result += state.dump;
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
state.tag = _tag;
|
|
2384
|
+
state.dump = _result || "[]";
|
|
2385
|
+
}
|
|
2386
|
+
function writeFlowMapping(state, level, object) {
|
|
2387
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2388
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2389
|
+
pairBuffer = "";
|
|
2390
|
+
if (_result !== "") pairBuffer += ", ";
|
|
2391
|
+
if (state.condenseFlow) pairBuffer += '"';
|
|
2392
|
+
objectKey = objectKeyList[index];
|
|
2393
|
+
objectValue = object[objectKey];
|
|
2394
|
+
if (state.replacer) {
|
|
2395
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2396
|
+
}
|
|
2397
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2398
|
+
continue;
|
|
2399
|
+
}
|
|
2400
|
+
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2401
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2402
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2403
|
+
continue;
|
|
2404
|
+
}
|
|
2405
|
+
pairBuffer += state.dump;
|
|
2406
|
+
_result += pairBuffer;
|
|
2407
|
+
}
|
|
2408
|
+
state.tag = _tag;
|
|
2409
|
+
state.dump = "{" + _result + "}";
|
|
2410
|
+
}
|
|
2411
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
2412
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2413
|
+
if (state.sortKeys === true) {
|
|
2414
|
+
objectKeyList.sort();
|
|
2415
|
+
} else if (typeof state.sortKeys === "function") {
|
|
2416
|
+
objectKeyList.sort(state.sortKeys);
|
|
2417
|
+
} else if (state.sortKeys) {
|
|
2418
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
2419
|
+
}
|
|
2420
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2421
|
+
pairBuffer = "";
|
|
2422
|
+
if (!compact || _result !== "") {
|
|
2423
|
+
pairBuffer += generateNextLine(state, level);
|
|
2424
|
+
}
|
|
2425
|
+
objectKey = objectKeyList[index];
|
|
2426
|
+
objectValue = object[objectKey];
|
|
2427
|
+
if (state.replacer) {
|
|
2428
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2429
|
+
}
|
|
2430
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2431
|
+
continue;
|
|
2432
|
+
}
|
|
2433
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2434
|
+
if (explicitPair) {
|
|
2435
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2436
|
+
pairBuffer += "?";
|
|
2437
|
+
} else {
|
|
2438
|
+
pairBuffer += "? ";
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
pairBuffer += state.dump;
|
|
2442
|
+
if (explicitPair) {
|
|
2443
|
+
pairBuffer += generateNextLine(state, level);
|
|
2444
|
+
}
|
|
2445
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2449
|
+
pairBuffer += ":";
|
|
2450
|
+
} else {
|
|
2451
|
+
pairBuffer += ": ";
|
|
2452
|
+
}
|
|
2453
|
+
pairBuffer += state.dump;
|
|
2454
|
+
_result += pairBuffer;
|
|
2455
|
+
}
|
|
2456
|
+
state.tag = _tag;
|
|
2457
|
+
state.dump = _result || "{}";
|
|
2458
|
+
}
|
|
2459
|
+
function detectType(state, object, explicit) {
|
|
2460
|
+
var _result, typeList, index, length, type2, style;
|
|
2461
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2462
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2463
|
+
type2 = typeList[index];
|
|
2464
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
2465
|
+
if (explicit) {
|
|
2466
|
+
if (type2.multi && type2.representName) {
|
|
2467
|
+
state.tag = type2.representName(object);
|
|
2468
|
+
} else {
|
|
2469
|
+
state.tag = type2.tag;
|
|
2470
|
+
}
|
|
2471
|
+
} else {
|
|
2472
|
+
state.tag = "?";
|
|
2473
|
+
}
|
|
2474
|
+
if (type2.represent) {
|
|
2475
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2476
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2477
|
+
_result = type2.represent(object, style);
|
|
2478
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2479
|
+
_result = type2.represent[style](object, style);
|
|
2480
|
+
} else {
|
|
2481
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2482
|
+
}
|
|
2483
|
+
state.dump = _result;
|
|
2484
|
+
}
|
|
2485
|
+
return true;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
return false;
|
|
2489
|
+
}
|
|
2490
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2491
|
+
state.tag = null;
|
|
2492
|
+
state.dump = object;
|
|
2493
|
+
if (!detectType(state, object, false)) {
|
|
2494
|
+
detectType(state, object, true);
|
|
2495
|
+
}
|
|
2496
|
+
var type2 = _toString.call(state.dump);
|
|
2497
|
+
var inblock = block;
|
|
2498
|
+
var tagStr;
|
|
2499
|
+
if (block) {
|
|
2500
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2501
|
+
}
|
|
2502
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2503
|
+
if (objectOrArray) {
|
|
2504
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
2505
|
+
duplicate = duplicateIndex !== -1;
|
|
2506
|
+
}
|
|
2507
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2508
|
+
compact = false;
|
|
2509
|
+
}
|
|
2510
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2511
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
2512
|
+
} else {
|
|
2513
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2514
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
2515
|
+
}
|
|
2516
|
+
if (type2 === "[object Object]") {
|
|
2517
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
2518
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
2519
|
+
if (duplicate) {
|
|
2520
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2521
|
+
}
|
|
2522
|
+
} else {
|
|
2523
|
+
writeFlowMapping(state, level, state.dump);
|
|
2524
|
+
if (duplicate) {
|
|
2525
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
} else if (type2 === "[object Array]") {
|
|
2529
|
+
if (block && state.dump.length !== 0) {
|
|
2530
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2531
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2532
|
+
} else {
|
|
2533
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
2534
|
+
}
|
|
2535
|
+
if (duplicate) {
|
|
2536
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2537
|
+
}
|
|
2538
|
+
} else {
|
|
2539
|
+
writeFlowSequence(state, level, state.dump);
|
|
2540
|
+
if (duplicate) {
|
|
2541
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
} else if (type2 === "[object String]") {
|
|
2545
|
+
if (state.tag !== "?") {
|
|
2546
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2547
|
+
}
|
|
2548
|
+
} else if (type2 === "[object Undefined]") {
|
|
2549
|
+
return false;
|
|
2550
|
+
} else {
|
|
2551
|
+
if (state.skipInvalid) return false;
|
|
2552
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2553
|
+
}
|
|
2554
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
2555
|
+
tagStr = encodeURI(
|
|
2556
|
+
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
2557
|
+
).replace(/!/g, "%21");
|
|
2558
|
+
if (state.tag[0] === "!") {
|
|
2559
|
+
tagStr = "!" + tagStr;
|
|
2560
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2561
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
2562
|
+
} else {
|
|
2563
|
+
tagStr = "!<" + tagStr + ">";
|
|
2564
|
+
}
|
|
2565
|
+
state.dump = tagStr + " " + state.dump;
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
return true;
|
|
2569
|
+
}
|
|
2570
|
+
function getDuplicateReferences(object, state) {
|
|
2571
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
2572
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
2573
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2574
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2575
|
+
}
|
|
2576
|
+
state.usedDuplicates = new Array(length);
|
|
2577
|
+
}
|
|
2578
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2579
|
+
var objectKeyList, index, length;
|
|
2580
|
+
if (object !== null && typeof object === "object") {
|
|
2581
|
+
index = objects.indexOf(object);
|
|
2582
|
+
if (index !== -1) {
|
|
2583
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2584
|
+
duplicatesIndexes.push(index);
|
|
2585
|
+
}
|
|
2586
|
+
} else {
|
|
2587
|
+
objects.push(object);
|
|
2588
|
+
if (Array.isArray(object)) {
|
|
2589
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2590
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2591
|
+
}
|
|
2592
|
+
} else {
|
|
2593
|
+
objectKeyList = Object.keys(object);
|
|
2594
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2595
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
function dump$1(input, options) {
|
|
2602
|
+
options = options || {};
|
|
2603
|
+
var state = new State(options);
|
|
2604
|
+
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2605
|
+
var value = input;
|
|
2606
|
+
if (state.replacer) {
|
|
2607
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
2608
|
+
}
|
|
2609
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
2610
|
+
return "";
|
|
2611
|
+
}
|
|
2612
|
+
var dump_1 = dump$1;
|
|
2613
|
+
var dumper = {
|
|
2614
|
+
dump: dump_1
|
|
2615
|
+
};
|
|
2616
|
+
function renamed(from, to) {
|
|
2617
|
+
return function() {
|
|
2618
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
var Type = type;
|
|
2622
|
+
var Schema = schema;
|
|
2623
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
2624
|
+
var JSON_SCHEMA = json;
|
|
2625
|
+
var CORE_SCHEMA = core;
|
|
2626
|
+
var DEFAULT_SCHEMA = _default;
|
|
2627
|
+
var load = loader.load;
|
|
2628
|
+
var loadAll = loader.loadAll;
|
|
2629
|
+
var dump = dumper.dump;
|
|
2630
|
+
var YAMLException = exception;
|
|
2631
|
+
var types = {
|
|
2632
|
+
binary,
|
|
2633
|
+
float,
|
|
2634
|
+
map,
|
|
2635
|
+
null: _null,
|
|
2636
|
+
pairs,
|
|
2637
|
+
set,
|
|
2638
|
+
timestamp,
|
|
2639
|
+
bool,
|
|
2640
|
+
int,
|
|
2641
|
+
merge,
|
|
2642
|
+
omap,
|
|
2643
|
+
seq,
|
|
2644
|
+
str
|
|
2645
|
+
};
|
|
2646
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
2647
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
2648
|
+
var safeDump = renamed("safeDump", "dump");
|
|
2649
|
+
var jsYaml = {
|
|
2650
|
+
Type,
|
|
2651
|
+
Schema,
|
|
2652
|
+
FAILSAFE_SCHEMA,
|
|
2653
|
+
JSON_SCHEMA,
|
|
2654
|
+
CORE_SCHEMA,
|
|
2655
|
+
DEFAULT_SCHEMA,
|
|
2656
|
+
load,
|
|
2657
|
+
loadAll,
|
|
2658
|
+
dump,
|
|
2659
|
+
YAMLException,
|
|
2660
|
+
types,
|
|
2661
|
+
safeLoad,
|
|
2662
|
+
safeLoadAll,
|
|
2663
|
+
safeDump
|
|
2664
|
+
};
|
|
2665
|
+
|
|
2666
|
+
// core/manifest/manifest-contract.ts
|
|
2667
|
+
var SOMA_MANIFEST_VERSION = "1.0.0";
|
|
2668
|
+
function assertManifestVersion(version) {
|
|
2669
|
+
if (version !== SOMA_MANIFEST_VERSION) {
|
|
2670
|
+
throw new Error(
|
|
2671
|
+
`[SOMA] Manifest \u7248\u672C\u4E0D\u517C\u5BB9: \u671F\u671B ${SOMA_MANIFEST_VERSION}\uFF0C\u6536\u5230 ${version}`
|
|
2672
|
+
);
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
// core/compiler/preview-manifest-adapter.ts
|
|
2677
|
+
function mapPreviewAction(action, target) {
|
|
2678
|
+
switch (action) {
|
|
2679
|
+
case "refresh":
|
|
2680
|
+
return { type: "UI_REFRESH" };
|
|
2681
|
+
case "toggle":
|
|
2682
|
+
return { type: "UI_INTERACT", targetId: target, action: "toggle" };
|
|
2683
|
+
case "navigate":
|
|
2684
|
+
return { type: "NAV_STATIC", targetUrl: target };
|
|
2685
|
+
default:
|
|
2686
|
+
return { type: "UI_REFRESH" };
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
function previewManifestToCoreConfig(manifest) {
|
|
2690
|
+
assertManifestVersion(manifest.version);
|
|
2691
|
+
const show = {};
|
|
2692
|
+
for (const binding of manifest.bindings) {
|
|
2693
|
+
show[binding.somaId] = binding.bindPath;
|
|
2694
|
+
}
|
|
2695
|
+
const uiConfig = {
|
|
2696
|
+
bind: { obj: inferPageClass(manifest.page), var: "page" },
|
|
2697
|
+
show
|
|
2698
|
+
};
|
|
2699
|
+
const eventConfig = manifest.events.map((ev) => {
|
|
2700
|
+
const [domEvent, ...modifiers] = ev.trigger.split(".");
|
|
2701
|
+
const keyModifier = modifiers.length > 0 ? modifiers.join(".") : void 0;
|
|
2702
|
+
const mapped = mapPreviewAction(ev.action, ev.target);
|
|
2703
|
+
return {
|
|
2704
|
+
somaId: ev.somaId,
|
|
2705
|
+
domEvent,
|
|
2706
|
+
type: mapped.type,
|
|
2707
|
+
funcPath: null,
|
|
2708
|
+
targetUrl: mapped.targetUrl,
|
|
2709
|
+
targetId: mapped.targetId,
|
|
2710
|
+
action: mapped.action,
|
|
2711
|
+
keyModifier
|
|
2712
|
+
};
|
|
2713
|
+
});
|
|
2714
|
+
return { uiConfig, eventConfig };
|
|
2715
|
+
}
|
|
2716
|
+
function inferPageClass(pagePath) {
|
|
2717
|
+
if (!pagePath) return "PageClass";
|
|
2718
|
+
const base = pagePath.replace(/\.html$/, "").split("/").pop() ?? "Page";
|
|
2719
|
+
return base.charAt(0).toUpperCase() + base.slice(1) + "Class";
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
// core/compiler/preview-export.ts
|
|
2723
|
+
function pageFileToBase(pageFile) {
|
|
2724
|
+
return pageFile.replace(/\.html$/, "").replace(/\//g, "_");
|
|
2725
|
+
}
|
|
2726
|
+
function toDomainFileName(baseName) {
|
|
2727
|
+
return baseName.replace(/_([a-z])/g, (_, c) => c);
|
|
2728
|
+
}
|
|
2729
|
+
function inferBindObj(pageFile) {
|
|
2730
|
+
const base = pageFile.replace(/\.html$/, "").split("/").pop() ?? "page";
|
|
2731
|
+
return base.charAt(0).toUpperCase() + base.slice(1) + "Class";
|
|
2732
|
+
}
|
|
2733
|
+
function toEventYaml(events) {
|
|
2734
|
+
return events.map((ev) => {
|
|
2735
|
+
const parts = [ev.type];
|
|
2736
|
+
if (ev.funcPath) parts.push(ev.funcPath);
|
|
2737
|
+
if (ev.targetUrl) parts.push(ev.targetUrl);
|
|
2738
|
+
if (ev.targetId) parts.push(ev.targetId);
|
|
2739
|
+
if (ev.action && ev.action !== "toggle") parts.push(ev.action);
|
|
2740
|
+
const key = ev.keyModifier ? `${ev.domEvent}.${ev.keyModifier}` : ev.domEvent;
|
|
2741
|
+
return `${ev.somaId}.${key}: ${parts.join(" | ")}`;
|
|
2742
|
+
}).join("\n");
|
|
2743
|
+
}
|
|
2744
|
+
function buildDomainSkeleton(className, manifest, events) {
|
|
2745
|
+
const pageVar = "page";
|
|
2746
|
+
const showFields = manifest.bindings.slice(0, 8).map((b) => {
|
|
2747
|
+
const field = b.bindPath.split(".").pop() ?? b.somaId;
|
|
2748
|
+
return ` ${field}: '',`;
|
|
2749
|
+
});
|
|
2750
|
+
const methods = /* @__PURE__ */ new Set();
|
|
2751
|
+
for (const ev of events) {
|
|
2752
|
+
if (ev.funcPath) {
|
|
2753
|
+
const method = ev.funcPath.split(".").pop();
|
|
2754
|
+
if (method) methods.add(method);
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
const methodBlocks = [...methods].map((m) => `
|
|
2758
|
+
async ${m}(): Promise<boolean> {
|
|
2759
|
+
return true;
|
|
2760
|
+
}`).join("\n");
|
|
2761
|
+
return `import { SomaPageRoot } from '@core/base/SomaPageRoot';
|
|
2762
|
+
import { Page } from '@core/base/decorators';
|
|
2763
|
+
|
|
2764
|
+
/** Generated by soma preview export \u2014 ${(/* @__PURE__ */ new Date()).toISOString()} */
|
|
2765
|
+
@Page({ id: '${className.replace(/Class$/, "")}' })
|
|
2766
|
+
export default class ${className} extends SomaPageRoot {
|
|
2767
|
+
${pageVar} = {
|
|
2768
|
+
${showFields.length ? showFields.join("\n") : " title: '',"}
|
|
2769
|
+
};
|
|
2770
|
+
${methodBlocks || "\n async onMount(): Promise<void> {\n // TODO: \u521D\u59CB\u5316\n }"}
|
|
2771
|
+
}
|
|
2772
|
+
`;
|
|
2773
|
+
}
|
|
2774
|
+
function generateCoreFilesFromManifest(manifest) {
|
|
2775
|
+
const { uiConfig, eventConfig } = previewManifestToCoreConfig(manifest);
|
|
2776
|
+
const baseName = pageFileToBase(manifest.page ?? "page.html");
|
|
2777
|
+
const className = inferBindObj(manifest.page ?? "page.html");
|
|
2778
|
+
const uiYaml = jsYaml.dump(uiConfig, { lineWidth: 120, noRefs: true });
|
|
2779
|
+
const eventYaml = toEventYaml(eventConfig);
|
|
2780
|
+
const domainTs = buildDomainSkeleton(className, manifest, eventConfig);
|
|
2781
|
+
const styleYaml = `# Generated by soma preview export
|
|
2782
|
+
base: {}
|
|
2783
|
+
states: {}
|
|
2784
|
+
transitions: {}
|
|
2785
|
+
themes: {}
|
|
2786
|
+
`;
|
|
2787
|
+
return { uiYaml, eventYaml, domainTs, styleYaml, baseName };
|
|
2788
|
+
}
|
|
2789
|
+
function writePreviewExport(manifest, hostDir) {
|
|
2790
|
+
const generated = generateCoreFilesFromManifest(manifest);
|
|
2791
|
+
const baseName = generated.baseName;
|
|
2792
|
+
const pageFile = manifest.page ?? `${baseName}.html`;
|
|
2793
|
+
const targets = {
|
|
2794
|
+
ui: import_node_path.default.join(hostDir, "ui", `${baseName}_ui.yaml`),
|
|
2795
|
+
event: import_node_path.default.join(hostDir, "event", `${baseName}_event.yaml`),
|
|
2796
|
+
domain: import_node_path.default.join(hostDir, "domain", "ui", `${toDomainFileName(baseName)}Class.ts`),
|
|
2797
|
+
style: import_node_path.default.join(hostDir, "ui", `${baseName}_style.yaml`)
|
|
2798
|
+
};
|
|
2799
|
+
const written = [];
|
|
2800
|
+
const write = (filePath, content) => {
|
|
2801
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(filePath), { recursive: true });
|
|
2802
|
+
import_node_fs.default.writeFileSync(filePath, content.startsWith("#") || content.startsWith("import") ? content : `# Generated by soma preview export \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2803
|
+
${content}`);
|
|
2804
|
+
written.push(filePath);
|
|
2805
|
+
};
|
|
2806
|
+
write(targets.ui, generated.uiYaml);
|
|
2807
|
+
write(targets.event, generated.eventYaml);
|
|
2808
|
+
write(targets.domain, generated.domainTs);
|
|
2809
|
+
write(targets.style, generated.styleYaml);
|
|
2810
|
+
return {
|
|
2811
|
+
pageFile,
|
|
2812
|
+
baseName,
|
|
2813
|
+
files: {
|
|
2814
|
+
uiYaml: generated.uiYaml,
|
|
2815
|
+
eventYaml: generated.eventYaml,
|
|
2816
|
+
domainTs: generated.domainTs,
|
|
2817
|
+
styleYaml: generated.styleYaml
|
|
2818
|
+
},
|
|
2819
|
+
written
|
|
2820
|
+
};
|
|
2821
|
+
}
|
|
2822
|
+
function previewEngineManifestToLike(manifest) {
|
|
2823
|
+
return {
|
|
2824
|
+
version: manifest.version ?? SOMA_MANIFEST_VERSION,
|
|
2825
|
+
page: manifest.page,
|
|
2826
|
+
bindings: manifest.bindings.map((b) => ({
|
|
2827
|
+
somaId: b.somaId,
|
|
2828
|
+
bindPath: b.bindPath,
|
|
2829
|
+
render: b.render
|
|
2830
|
+
})),
|
|
2831
|
+
events: manifest.events.map((e) => ({
|
|
2832
|
+
somaId: e.somaId,
|
|
2833
|
+
trigger: e.trigger,
|
|
2834
|
+
action: e.action,
|
|
2835
|
+
target: e.target
|
|
2836
|
+
}))
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
// ../soma-preview/engine/spec-parser.ts
|
|
2841
|
+
var SpecParser = class _SpecParser {
|
|
2842
|
+
constructor(markdown) {
|
|
2843
|
+
const normalized = markdown.replace(/\r\n?/g, "\n");
|
|
2844
|
+
this.lines = normalized.split("\n");
|
|
2845
|
+
this.rawText = normalized;
|
|
2846
|
+
}
|
|
2847
|
+
static fromMultiple(markdowns) {
|
|
2848
|
+
return new _SpecParser(markdowns.join("\n\n"));
|
|
2849
|
+
}
|
|
2850
|
+
// ─── 公开 API ──────────────────────────────────────────
|
|
2851
|
+
getPages() {
|
|
2852
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2853
|
+
const pages = [];
|
|
2854
|
+
for (const line of this.lines) {
|
|
2855
|
+
const m = line.match(/^### \d+\.\d+ (.+\.html)\s*$/);
|
|
2856
|
+
if (!m) continue;
|
|
2857
|
+
const f = m[1].trim();
|
|
2858
|
+
if (seen.has(f)) continue;
|
|
2859
|
+
seen.add(f);
|
|
2860
|
+
pages.push(f);
|
|
2861
|
+
}
|
|
2862
|
+
return pages;
|
|
2863
|
+
}
|
|
2864
|
+
getPage(fileName) {
|
|
2865
|
+
return {
|
|
2866
|
+
file: fileName,
|
|
2867
|
+
attrs: this.getAttrs(fileName),
|
|
2868
|
+
templates: this.getTemplates(fileName),
|
|
2869
|
+
events: this.getEvents(fileName)
|
|
2870
|
+
};
|
|
2871
|
+
}
|
|
2872
|
+
getAllPages() {
|
|
2873
|
+
return this.getPages().map((f) => this.getPage(f));
|
|
2874
|
+
}
|
|
2875
|
+
getAttrs(fileName) {
|
|
2876
|
+
const block = this.locateSection(fileName, "\u5C5E\u6027\u63CF\u8FF0");
|
|
2877
|
+
if (!block) return [];
|
|
2878
|
+
return this.parseAttrLines(block);
|
|
2879
|
+
}
|
|
2880
|
+
getTemplates(fileName) {
|
|
2881
|
+
const ranges = this.locateTemplateSectionRanges(fileName);
|
|
2882
|
+
if (!ranges || ranges.length === 0) return [];
|
|
2883
|
+
const all = [];
|
|
2884
|
+
for (const { start, end } of ranges) {
|
|
2885
|
+
const block = this.lines.slice(start, end);
|
|
2886
|
+
all.push(...this.parseTemplateBlock(block));
|
|
2887
|
+
}
|
|
2888
|
+
return all;
|
|
2889
|
+
}
|
|
2890
|
+
getEvents(fileName) {
|
|
2891
|
+
const block = this.locateSection(fileName, "\u4EA4\u4E92\u63CF\u8FF0");
|
|
2892
|
+
if (!block) return [];
|
|
2893
|
+
return this.parseEventLines(block);
|
|
2894
|
+
}
|
|
2895
|
+
// ─── 语义解析 ──────────────────────────────────────────
|
|
2896
|
+
/**
|
|
2897
|
+
* 解析语义化 Mock 指令
|
|
2898
|
+
* 支持: [姓名], [金额:100-500], [企业名], [占位图:200x200], [计算:qty*price]
|
|
2899
|
+
*/
|
|
2900
|
+
parseSemanticTag(sample) {
|
|
2901
|
+
const match = sample.match(/^\[([^\]:]+)(?::([^\]]+))?\]$/);
|
|
2902
|
+
if (!match) return null;
|
|
2903
|
+
const [, type2, params] = match;
|
|
2904
|
+
switch (type2) {
|
|
2905
|
+
case "\u59D3\u540D":
|
|
2906
|
+
return { type: "name" };
|
|
2907
|
+
case "\u4F01\u4E1A\u540D":
|
|
2908
|
+
return { type: "company" };
|
|
2909
|
+
case "\u91D1\u989D":
|
|
2910
|
+
if (params) {
|
|
2911
|
+
const [min, max] = params.split("-").map(Number);
|
|
2912
|
+
return { type: "amount", params: { min: min ?? 0, max: max ?? 1e3 } };
|
|
2913
|
+
}
|
|
2914
|
+
return { type: "amount", params: { min: 1, max: 1e3 } };
|
|
2915
|
+
case "\u65E5\u671F":
|
|
2916
|
+
return { type: "date" };
|
|
2917
|
+
case "\u624B\u673A\u53F7":
|
|
2918
|
+
return { type: "phone" };
|
|
2919
|
+
case "\u90AE\u7BB1":
|
|
2920
|
+
return { type: "email" };
|
|
2921
|
+
case "\u5360\u4F4D\u56FE":
|
|
2922
|
+
if (params) {
|
|
2923
|
+
const [w, h] = params.split("x").map(Number);
|
|
2924
|
+
return { type: "image", params: { width: w ?? 200, height: h ?? 200 } };
|
|
2925
|
+
}
|
|
2926
|
+
return { type: "image", params: { width: 400, height: 300 } };
|
|
2927
|
+
case "\u8BA1\u7B97":
|
|
2928
|
+
return { type: "calc", expression: params ?? "" };
|
|
2929
|
+
default:
|
|
2930
|
+
return null;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
// ─── 定位层 ────────────────────────────────────────────
|
|
2934
|
+
locateSection(fileName, sectionName) {
|
|
2935
|
+
const pageRange = this.findPageRange(fileName);
|
|
2936
|
+
if (!pageRange) return null;
|
|
2937
|
+
const { start, end } = pageRange;
|
|
2938
|
+
let sectionStart = -1;
|
|
2939
|
+
let sectionEnd = end;
|
|
2940
|
+
for (let i = start; i < end; i++) {
|
|
2941
|
+
const line = this.lines[i];
|
|
2942
|
+
if (sectionStart === -1 && line.match(/^####\s+\d+/) && line.includes(sectionName)) {
|
|
2943
|
+
sectionStart = i + 1;
|
|
2944
|
+
continue;
|
|
2945
|
+
}
|
|
2946
|
+
if (sectionStart !== -1 && line.match(/^####\s/) && !line.match(/^#####/)) {
|
|
2947
|
+
sectionEnd = i;
|
|
2948
|
+
break;
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
if (sectionStart === -1) return null;
|
|
2952
|
+
return this.lines.slice(sectionStart, sectionEnd);
|
|
2953
|
+
}
|
|
2954
|
+
findPageRange(fileName) {
|
|
2955
|
+
let start = -1;
|
|
2956
|
+
for (let i = 0; i < this.lines.length; i++) {
|
|
2957
|
+
const line = this.lines[i];
|
|
2958
|
+
const m = line.match(/^### \d+\.\d+ (.+\.html)\s*$/);
|
|
2959
|
+
if (!m) continue;
|
|
2960
|
+
if (m[1].trim() === fileName) {
|
|
2961
|
+
if (start === -1) start = i + 1;
|
|
2962
|
+
continue;
|
|
2963
|
+
}
|
|
2964
|
+
if (start !== -1) {
|
|
2965
|
+
return { start, end: i };
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
if (start !== -1) {
|
|
2969
|
+
return { start, end: this.lines.length };
|
|
2970
|
+
}
|
|
2971
|
+
return null;
|
|
2972
|
+
}
|
|
2973
|
+
/** 同一页面可有多个「#### n.n.m 模板属性描述」块 */
|
|
2974
|
+
locateTemplateSectionRanges(fileName) {
|
|
2975
|
+
const pageRange = this.findPageRange(fileName);
|
|
2976
|
+
if (!pageRange) return null;
|
|
2977
|
+
const { start, end } = pageRange;
|
|
2978
|
+
const ranges = [];
|
|
2979
|
+
let i = start;
|
|
2980
|
+
while (i < end) {
|
|
2981
|
+
const line = this.lines[i];
|
|
2982
|
+
if (line.match(/^####\s+\d+/) && line.includes("\u6A21\u677F\u5C5E\u6027\u63CF\u8FF0")) {
|
|
2983
|
+
const blockStart = i + 1;
|
|
2984
|
+
let j = blockStart;
|
|
2985
|
+
for (; j < end; j++) {
|
|
2986
|
+
const ln = this.lines[j];
|
|
2987
|
+
if (ln.match(/^####\s/) && !ln.match(/^#####/)) break;
|
|
2988
|
+
}
|
|
2989
|
+
ranges.push({ start: blockStart, end: j });
|
|
2990
|
+
i = j;
|
|
2991
|
+
} else {
|
|
2992
|
+
i++;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
return ranges.length ? ranges : null;
|
|
2996
|
+
}
|
|
2997
|
+
// ─── 解析层 ────────────────────────────────────────────
|
|
2998
|
+
parseAttrLines(lines) {
|
|
2999
|
+
const result = [];
|
|
3000
|
+
for (const line of lines) {
|
|
3001
|
+
const trimmed = line.trim();
|
|
3002
|
+
if (!trimmed || trimmed.startsWith(">") || trimmed.startsWith("#") || trimmed.startsWith("|") || trimmed.startsWith("---")) continue;
|
|
3003
|
+
const parts = trimmed.split("|").map((s) => s.trim());
|
|
3004
|
+
if (parts.length < 4) continue;
|
|
3005
|
+
const id = parts[0];
|
|
3006
|
+
const second = parts[1];
|
|
3007
|
+
if (second.startsWith("toggle:")) {
|
|
3008
|
+
result.push({
|
|
3009
|
+
id,
|
|
3010
|
+
strategy: "\u9875\u9762",
|
|
3011
|
+
render: second,
|
|
3012
|
+
sample: "",
|
|
3013
|
+
length: parts[4] || "--",
|
|
3014
|
+
desc: parts[5] || parts[3] || ""
|
|
3015
|
+
});
|
|
3016
|
+
} else {
|
|
3017
|
+
result.push({
|
|
3018
|
+
id,
|
|
3019
|
+
strategy: second,
|
|
3020
|
+
render: parts[2],
|
|
3021
|
+
sample: parts[3] || "",
|
|
3022
|
+
length: parts[4] || "--",
|
|
3023
|
+
desc: parts[5] || ""
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
return result;
|
|
3028
|
+
}
|
|
3029
|
+
parseTemplateBlock(lines) {
|
|
3030
|
+
const templates = [];
|
|
3031
|
+
let currentId = null;
|
|
3032
|
+
let currentLines = [];
|
|
3033
|
+
for (const line of lines) {
|
|
3034
|
+
const m = line.match(/^##### (?:\d+[\d.]*\s+)?(\S+)(?:\s*\(.*\))?\s*$/);
|
|
3035
|
+
if (m) {
|
|
3036
|
+
if (currentId) {
|
|
3037
|
+
templates.push({ id: currentId, attrs: this.parseAttrLines(currentLines) });
|
|
3038
|
+
}
|
|
3039
|
+
currentId = m[1];
|
|
3040
|
+
currentLines = [];
|
|
3041
|
+
continue;
|
|
3042
|
+
}
|
|
3043
|
+
if (currentId) {
|
|
3044
|
+
currentLines.push(line);
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
if (currentId) {
|
|
3048
|
+
templates.push({ id: currentId, attrs: this.parseAttrLines(currentLines) });
|
|
3049
|
+
}
|
|
3050
|
+
return templates;
|
|
3051
|
+
}
|
|
3052
|
+
parseEventLines(lines) {
|
|
3053
|
+
const result = [];
|
|
3054
|
+
for (const line of lines) {
|
|
3055
|
+
const trimmed = line.trim();
|
|
3056
|
+
if (!trimmed || trimmed.startsWith(">") || trimmed.startsWith("#") || trimmed.startsWith("---")) continue;
|
|
3057
|
+
const parts = trimmed.split("::").map((s) => s.trim());
|
|
3058
|
+
if (parts.length < 3) continue;
|
|
3059
|
+
const action = this.normalizeAction(parts[2]);
|
|
3060
|
+
result.push({
|
|
3061
|
+
id: parts[0],
|
|
3062
|
+
trigger: this.normalizeTrigger(parts[1]),
|
|
3063
|
+
action,
|
|
3064
|
+
target: parts[3] || "",
|
|
3065
|
+
desc: parts[4] || ""
|
|
3066
|
+
});
|
|
3067
|
+
}
|
|
3068
|
+
return result;
|
|
3069
|
+
}
|
|
3070
|
+
/** 标准化触发器格式 */
|
|
3071
|
+
normalizeTrigger(trigger) {
|
|
3072
|
+
if (trigger.startsWith("keydown")) {
|
|
3073
|
+
const match = trigger.match(/^keydown\.((?:ctrl|alt|shift|meta)\+)*(.+)$/i);
|
|
3074
|
+
if (match) {
|
|
3075
|
+
const mods = match[1]?.match(/(ctrl|alt|shift|meta)/gi) ?? [];
|
|
3076
|
+
const key = match[2];
|
|
3077
|
+
const sorted = [...mods.map((m) => m.toLowerCase()), key.toLowerCase()].join(".");
|
|
3078
|
+
return `keydown.${sorted}`;
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
return trigger;
|
|
3082
|
+
}
|
|
3083
|
+
/** 标准化动作类型 */
|
|
3084
|
+
normalizeAction(action) {
|
|
3085
|
+
switch (action) {
|
|
3086
|
+
case "refresh":
|
|
3087
|
+
case "navigate":
|
|
3088
|
+
case "toggle":
|
|
3089
|
+
return action;
|
|
3090
|
+
default:
|
|
3091
|
+
return "refresh";
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
};
|
|
3095
|
+
|
|
3096
|
+
// ../soma-preview/engine/compiler.ts
|
|
3097
|
+
var SpecCompiler = class {
|
|
3098
|
+
constructor(spec) {
|
|
3099
|
+
this.spec = spec;
|
|
3100
|
+
}
|
|
3101
|
+
/**
|
|
3102
|
+
* 编译页面规格为 AST
|
|
3103
|
+
*/
|
|
3104
|
+
compile() {
|
|
3105
|
+
const scopeTree = this.buildScopeTree();
|
|
3106
|
+
const dependencies = this.extractDependencies(scopeTree);
|
|
3107
|
+
const bindings = this.generateBindings(scopeTree);
|
|
3108
|
+
const events = this.compileEvents();
|
|
3109
|
+
return {
|
|
3110
|
+
page: this.spec,
|
|
3111
|
+
scopeTree,
|
|
3112
|
+
dependencies,
|
|
3113
|
+
bindings,
|
|
3114
|
+
events
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
/**
|
|
3118
|
+
* 编译 AST 为 Manifest
|
|
3119
|
+
*/
|
|
3120
|
+
compileManifest() {
|
|
3121
|
+
const ast = this.compile();
|
|
3122
|
+
return {
|
|
3123
|
+
version: "1.0.0",
|
|
3124
|
+
page: this.spec.file,
|
|
3125
|
+
state: this.compileState(ast),
|
|
3126
|
+
bindings: ast.bindings,
|
|
3127
|
+
events: ast.events,
|
|
3128
|
+
computed: this.compileComputed(ast),
|
|
3129
|
+
scopes: this.compileScopes(ast)
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3132
|
+
// ─── 作用域树构建 ──────────────────────────────────────
|
|
3133
|
+
buildScopeTree() {
|
|
3134
|
+
const root = {
|
|
3135
|
+
id: "page",
|
|
3136
|
+
type: "page",
|
|
3137
|
+
parentId: null,
|
|
3138
|
+
depth: 0,
|
|
3139
|
+
attrs: this.spec.attrs,
|
|
3140
|
+
children: []
|
|
3141
|
+
};
|
|
3142
|
+
for (const tpl of this.spec.templates) {
|
|
3143
|
+
const tplNode = this.buildTemplateNode(tpl, root);
|
|
3144
|
+
root.children.push(tplNode);
|
|
3145
|
+
}
|
|
3146
|
+
return root;
|
|
3147
|
+
}
|
|
3148
|
+
buildTemplateNode(tpl, parent) {
|
|
3149
|
+
const isNested = tpl.id.includes(".");
|
|
3150
|
+
const inferredCount = this.inferListCount(tpl);
|
|
3151
|
+
const listCount = inferredCount !== void 0 ? inferredCount : 3;
|
|
3152
|
+
let node;
|
|
3153
|
+
if (isNested) {
|
|
3154
|
+
const parentId = tpl.id.split(".")[0];
|
|
3155
|
+
node = {
|
|
3156
|
+
id: tpl.id,
|
|
3157
|
+
type: "nested",
|
|
3158
|
+
parentId,
|
|
3159
|
+
depth: parent.depth + 1,
|
|
3160
|
+
attrs: tpl.attrs,
|
|
3161
|
+
children: [],
|
|
3162
|
+
nestedTemplateId: tpl.id,
|
|
3163
|
+
listCount
|
|
3164
|
+
};
|
|
3165
|
+
} else {
|
|
3166
|
+
node = {
|
|
3167
|
+
id: tpl.id,
|
|
3168
|
+
type: "template",
|
|
3169
|
+
parentId: parent.id,
|
|
3170
|
+
depth: parent.depth + 1,
|
|
3171
|
+
attrs: tpl.attrs,
|
|
3172
|
+
children: [],
|
|
3173
|
+
listCount
|
|
3174
|
+
};
|
|
3175
|
+
}
|
|
3176
|
+
return node;
|
|
3177
|
+
}
|
|
3178
|
+
/** 从示例值推断列表迭代次数 */
|
|
3179
|
+
inferListCount(tpl) {
|
|
3180
|
+
for (const attr of tpl.attrs) {
|
|
3181
|
+
if (attr.sample?.includes("@repeat")) {
|
|
3182
|
+
const match = attr.sample.match(/@repeat\((\d+)(?:[,;]\s*(\d+))?\)/);
|
|
3183
|
+
if (match) {
|
|
3184
|
+
if (match[2]) {
|
|
3185
|
+
const min = parseInt(match[1], 10);
|
|
3186
|
+
const max = parseInt(match[2], 10);
|
|
3187
|
+
return Math.floor((min + max) / 2);
|
|
3188
|
+
}
|
|
3189
|
+
return parseInt(match[1], 10);
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
return void 0;
|
|
3194
|
+
}
|
|
3195
|
+
// ─── 依赖提取 ──────────────────────────────────────────
|
|
3196
|
+
extractDependencies(scopeTree) {
|
|
3197
|
+
const deps = [];
|
|
3198
|
+
const scanNode = (node) => {
|
|
3199
|
+
for (const attr of node.attrs) {
|
|
3200
|
+
if (attr.sample?.includes("[\u8BA1\u7B97:")) {
|
|
3201
|
+
const match = attr.sample.match(/\[计算:\s*(.+?)\]/);
|
|
3202
|
+
if (match) {
|
|
3203
|
+
deps.push({
|
|
3204
|
+
sourceId: this.extractDepsFromExpr(match[1]),
|
|
3205
|
+
targetId: attr.id,
|
|
3206
|
+
type: "compute",
|
|
3207
|
+
expression: match[1]
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
for (const child of node.children) {
|
|
3213
|
+
scanNode(child);
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
scanNode(scopeTree);
|
|
3217
|
+
return deps;
|
|
3218
|
+
}
|
|
3219
|
+
extractDepsFromExpr(expr) {
|
|
3220
|
+
const matches = expr.match(/[a-zA-Z_][a-zA-Z0-9_]*/g) ?? [];
|
|
3221
|
+
return matches.join(",");
|
|
3222
|
+
}
|
|
3223
|
+
// ─── 绑定生成 ──────────────────────────────────────────
|
|
3224
|
+
generateBindings(scopeTree) {
|
|
3225
|
+
const bindings = [];
|
|
3226
|
+
const scanNode = (node, prefix) => {
|
|
3227
|
+
const pathPrefix = prefix ? `${prefix}.${node.id}` : `page.${node.id}`;
|
|
3228
|
+
for (const attr of node.attrs) {
|
|
3229
|
+
bindings.push({
|
|
3230
|
+
somaId: attr.id,
|
|
3231
|
+
bindPath: `${pathPrefix}.${attr.id}`,
|
|
3232
|
+
render: attr.render,
|
|
3233
|
+
semantic: attr.sample
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3236
|
+
for (const child of node.children) {
|
|
3237
|
+
scanNode(child, pathPrefix);
|
|
3238
|
+
}
|
|
3239
|
+
};
|
|
3240
|
+
scanNode(scopeTree, "");
|
|
3241
|
+
return bindings;
|
|
3242
|
+
}
|
|
3243
|
+
// ─── 事件编译 ──────────────────────────────────────────
|
|
3244
|
+
compileEvents() {
|
|
3245
|
+
return this.spec.events.map((ev) => ({
|
|
3246
|
+
somaId: ev.id,
|
|
3247
|
+
trigger: ev.trigger,
|
|
3248
|
+
action: ev.action,
|
|
3249
|
+
target: ev.target
|
|
3250
|
+
}));
|
|
3251
|
+
}
|
|
3252
|
+
// ─── Manifest 编译 ────────────────────────────────────
|
|
3253
|
+
compileState(ast) {
|
|
3254
|
+
const fields = [];
|
|
3255
|
+
const lists = [];
|
|
3256
|
+
const scanNode = (node, prefix) => {
|
|
3257
|
+
const pathPrefix = prefix ? `${prefix}.${node.id}` : `page.${node.id}`;
|
|
3258
|
+
if (node.listCount !== void 0 && node.listCount >= 0) {
|
|
3259
|
+
lists.push({
|
|
3260
|
+
id: node.id,
|
|
3261
|
+
path: pathPrefix,
|
|
3262
|
+
itemCount: node.listCount,
|
|
3263
|
+
itemType: "object",
|
|
3264
|
+
fields: node.attrs.map((attr) => this.fieldSpecFromAttr(attr, `${pathPrefix}.item`))
|
|
3265
|
+
});
|
|
3266
|
+
} else {
|
|
3267
|
+
for (const attr of node.attrs) {
|
|
3268
|
+
if (!attr.render.startsWith("toggle:")) {
|
|
3269
|
+
fields.push(this.fieldSpecFromAttr(attr, pathPrefix));
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
for (const child of node.children) {
|
|
3274
|
+
if (child.type === "template" || child.type === "nested") {
|
|
3275
|
+
scanNode(child, pathPrefix);
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
};
|
|
3279
|
+
scanNode(ast.scopeTree, "page");
|
|
3280
|
+
return { fields, lists };
|
|
3281
|
+
}
|
|
3282
|
+
fieldSpecFromAttr(attr, path2) {
|
|
3283
|
+
return {
|
|
3284
|
+
id: attr.id,
|
|
3285
|
+
path: `${path2}.${attr.id}`,
|
|
3286
|
+
type: this.inferFieldType(attr.render),
|
|
3287
|
+
initial: attr.sample,
|
|
3288
|
+
mock: this.inferMockConfig(attr)
|
|
3289
|
+
};
|
|
3290
|
+
}
|
|
3291
|
+
inferFieldType(render) {
|
|
3292
|
+
if (render === "number") return "number";
|
|
3293
|
+
if (render === "image") return "image";
|
|
3294
|
+
if (render.startsWith("toggle:")) return "boolean";
|
|
3295
|
+
return "text";
|
|
3296
|
+
}
|
|
3297
|
+
inferMockConfig(attr) {
|
|
3298
|
+
const strategy = attr.strategy;
|
|
3299
|
+
if (strategy === "\u9875\u9762" || strategy === "static") {
|
|
3300
|
+
return { strategy: "static", params: { value: attr.sample } };
|
|
3301
|
+
}
|
|
3302
|
+
if (strategy === "\u679A\u4E3E" || strategy === "enum") {
|
|
3303
|
+
return {
|
|
3304
|
+
strategy: "enum",
|
|
3305
|
+
params: { values: attr.sample.split(",").map((s) => s.trim()) }
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3308
|
+
const semanticMatch = attr.sample.match(/^\[([^\]:]+)(?::([^\]]+))?\]$/);
|
|
3309
|
+
if (semanticMatch) {
|
|
3310
|
+
return {
|
|
3311
|
+
strategy: "semantic",
|
|
3312
|
+
semanticType: semanticMatch[1],
|
|
3313
|
+
params: semanticMatch[2] ? this.parseSemanticParams(semanticMatch[1], semanticMatch[2]) : {}
|
|
3314
|
+
};
|
|
3315
|
+
}
|
|
3316
|
+
return {
|
|
3317
|
+
strategy: "semantic",
|
|
3318
|
+
semanticType: attr.render === "number" ? "number" : attr.render === "image" ? "image" : "text",
|
|
3319
|
+
params: {}
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
parseSemanticParams(type2, params) {
|
|
3323
|
+
switch (type2) {
|
|
3324
|
+
case "\u91D1\u989D": {
|
|
3325
|
+
const [min, max] = params.split("-").map(Number);
|
|
3326
|
+
return { min: min ?? 0, max: max ?? 1e3 };
|
|
3327
|
+
}
|
|
3328
|
+
case "\u5360\u4F4D\u56FE": {
|
|
3329
|
+
const [w, h] = params.split("x").map(Number);
|
|
3330
|
+
return { width: w ?? 400, height: h ?? 300 };
|
|
3331
|
+
}
|
|
3332
|
+
default:
|
|
3333
|
+
return {};
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
compileComputed(ast) {
|
|
3337
|
+
return ast.dependencies.filter((dep) => dep.type === "compute").map((dep) => ({
|
|
3338
|
+
id: dep.targetId,
|
|
3339
|
+
path: `page.computed.${dep.targetId}`,
|
|
3340
|
+
expression: dep.expression ?? "",
|
|
3341
|
+
deps: dep.sourceId.split(",")
|
|
3342
|
+
}));
|
|
3343
|
+
}
|
|
3344
|
+
compileScopes(ast) {
|
|
3345
|
+
const scopes = [];
|
|
3346
|
+
const scanNode = (node, parentId) => {
|
|
3347
|
+
const scope = {
|
|
3348
|
+
id: node.id,
|
|
3349
|
+
type: node.type,
|
|
3350
|
+
parentId,
|
|
3351
|
+
bindObj: node.parentId ? `page.${node.parentId}` : "page",
|
|
3352
|
+
bindVar: node.id.split(".")[node.id.split(".").length - 1]
|
|
3353
|
+
};
|
|
3354
|
+
if (node.listCount) {
|
|
3355
|
+
scope.count = node.listCount;
|
|
3356
|
+
}
|
|
3357
|
+
scopes.push(scope);
|
|
3358
|
+
for (const child of node.children) {
|
|
3359
|
+
scanNode(child, node.id);
|
|
3360
|
+
}
|
|
3361
|
+
};
|
|
3362
|
+
scanNode(ast.scopeTree, null);
|
|
3363
|
+
return scopes;
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
|
|
3367
|
+
// core/compiler/preview-export-entry.ts
|
|
3368
|
+
function runPreviewExport(options) {
|
|
3369
|
+
const specMd = import_node_fs2.default.readFileSync(options.specPath, "utf8");
|
|
3370
|
+
const parser = new SpecParser(specMd);
|
|
3371
|
+
const spec = parser.getPage(options.pageFile);
|
|
3372
|
+
if (!spec) {
|
|
3373
|
+
throw new Error(`\u672A\u5728\u89C4\u683C\u4E66\u4E2D\u627E\u5230\u9875\u9762: ${options.pageFile}`);
|
|
3374
|
+
}
|
|
3375
|
+
const manifest = new SpecCompiler(spec).compileManifest();
|
|
3376
|
+
const like = previewEngineManifestToLike(manifest);
|
|
3377
|
+
if (options.dryRun) {
|
|
3378
|
+
const files = generateCoreFilesFromManifest(like);
|
|
3379
|
+
return {
|
|
3380
|
+
pageFile: options.pageFile,
|
|
3381
|
+
baseName: files.baseName,
|
|
3382
|
+
files: {
|
|
3383
|
+
uiYaml: files.uiYaml,
|
|
3384
|
+
eventYaml: files.eventYaml,
|
|
3385
|
+
domainTs: files.domainTs,
|
|
3386
|
+
styleYaml: files.styleYaml
|
|
3387
|
+
},
|
|
3388
|
+
written: []
|
|
3389
|
+
};
|
|
3390
|
+
}
|
|
3391
|
+
return writePreviewExport(like, options.hostDir);
|
|
3392
|
+
}
|
|
3393
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3394
|
+
0 && (module.exports = {
|
|
3395
|
+
runPreviewExport
|
|
3396
|
+
});
|
|
3397
|
+
/*! Bundled license information:
|
|
3398
|
+
|
|
3399
|
+
js-yaml/dist/js-yaml.mjs:
|
|
3400
|
+
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
3401
|
+
*/
|