@intentius/chant 0.102.0 → 0.104.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/dist/audit/core.d.ts +2 -0
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/discover.d.ts.map +1 -1
- package/dist/change-set.d.ts +232 -0
- package/dist/change-set.d.ts.map +1 -0
- package/dist/cli/commands/audit.d.ts +7 -0
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/change-set.d.ts +11 -0
- package/dist/cli/handlers/change-set.d.ts.map +1 -0
- package/dist/cli/handlers/fan-out.d.ts +33 -0
- package/dist/cli/handlers/fan-out.d.ts.map +1 -1
- package/dist/cli/handlers/operator.d.ts +7 -0
- package/dist/cli/handlers/operator.d.ts.map +1 -1
- package/dist/cli/handlers/pr.d.ts +31 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -0
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/mcp/op-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.d.ts +3 -2
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/registry.d.ts +63 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts +16 -0
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/capability.d.ts +53 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/changed-files.d.ts +31 -0
- package/dist/components/changed-files.d.ts.map +1 -0
- package/dist/components/cli-support.d.ts +9 -1
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/component.d.ts +24 -0
- package/dist/components/component.d.ts.map +1 -1
- package/dist/components/deploy-units.d.ts.map +1 -1
- package/dist/components/driver.d.ts +13 -0
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/fan-out-output.d.ts +6 -0
- package/dist/components/fan-out-output.d.ts.map +1 -1
- package/dist/components/fan-out-record.d.ts +41 -0
- package/dist/components/fan-out-record.d.ts.map +1 -0
- package/dist/components/fan-out-run.d.ts +65 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-support.d.ts +2 -0
- package/dist/components/fan-out-support.d.ts.map +1 -1
- package/dist/components/fan-out.d.ts +6 -0
- package/dist/components/fan-out.d.ts.map +1 -1
- package/dist/components/gated-wave-pipeline.d.ts +50 -0
- package/dist/components/gated-wave-pipeline.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/layers.d.ts +25 -0
- package/dist/components/layers.d.ts.map +1 -0
- package/dist/components/pr-pipeline.d.ts +61 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -0
- package/dist/components/pr-run.d.ts +119 -0
- package/dist/components/pr-run.d.ts.map +1 -0
- package/dist/components/promote.d.ts.map +1 -1
- package/dist/components/verbs/shell.d.ts.map +1 -1
- package/dist/components/wave-plan.d.ts +49 -0
- package/dist/components/wave-plan.d.ts.map +1 -0
- package/dist/gated-waves.d.ts +147 -0
- package/dist/gated-waves.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/lexicon.d.ts +48 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.d.ts +7 -0
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +46 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lint/post-synth.d.ts +18 -0
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/op/activities/activity-contracts.d.ts +126 -0
- package/dist/op/activities/activity-contracts.d.ts.map +1 -1
- package/dist/op/activities/change-set.d.ts +62 -0
- package/dist/op/activities/change-set.d.ts.map +1 -0
- package/dist/op/activities/decide.d.ts +2 -0
- package/dist/op/activities/decide.d.ts.map +1 -1
- package/dist/op/activities/factory.d.ts +137 -0
- package/dist/op/activities/factory.d.ts.map +1 -0
- package/dist/op/activities/index.d.ts +4 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activity-contract.d.ts.map +1 -1
- package/dist/op/builders.d.ts +11 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/decide-backend.d.ts +5 -1
- package/dist/op/decide-backend.d.ts.map +1 -1
- package/dist/op/decide-read-inputs.d.ts +4 -2
- package/dist/op/decide-read-inputs.d.ts.map +1 -1
- package/dist/op/factory.d.ts +83 -0
- package/dist/op/factory.d.ts.map +1 -0
- package/dist/op/index.d.ts +4 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/op-ir.d.ts +2 -0
- package/dist/op/op-ir.d.ts.map +1 -1
- package/dist/op/op-verb-class.d.ts.map +1 -1
- package/dist/op/types.d.ts +8 -0
- package/dist/op/types.d.ts.map +1 -1
- package/dist/op/work-lease-run.d.ts.map +1 -1
- package/dist/plan-summary.d.ts +207 -0
- package/dist/plan-summary.d.ts.map +1 -0
- package/dist/pr-forge.d.ts +105 -0
- package/dist/pr-forge.d.ts.map +1 -0
- package/dist/pr-loop.d.ts +178 -0
- package/dist/pr-loop.d.ts.map +1 -0
- package/dist/telemetry-attribution.d.ts +31 -0
- package/dist/telemetry-attribution.d.ts.map +1 -1
- package/dist/terraform/hcl2json.d.ts +45 -0
- package/dist/terraform/hcl2json.d.ts.map +1 -0
- package/dist/terraform/parse.d.ts +4 -40
- package/dist/terraform/parse.d.ts.map +1 -1
- package/dist/vendor/js-yaml-load.d.ts +56 -0
- package/dist/vendor/js-yaml-load.d.ts.map +1 -0
- package/dist/workspace/box-cli.d.ts +12 -0
- package/dist/workspace/box-cli.d.ts.map +1 -0
- package/dist/workspace/box-factory.d.ts +27 -3
- package/dist/workspace/box-factory.d.ts.map +1 -1
- package/dist/workspace/box-listing.d.ts +85 -0
- package/dist/workspace/box-listing.d.ts.map +1 -0
- package/dist/workspace/box-publish.d.ts +147 -0
- package/dist/workspace/box-publish.d.ts.map +1 -0
- package/dist/workspace/broker-protocol.d.ts +190 -0
- package/dist/workspace/broker-protocol.d.ts.map +1 -0
- package/dist/workspace/checks.d.ts.map +1 -1
- package/dist/workspace/composites.d.ts +2 -2
- package/dist/workspace/composites.d.ts.map +1 -1
- package/dist/workspace/conformance/__fixtures__/reference-broker.d.ts +17 -0
- package/dist/workspace/conformance/__fixtures__/reference-broker.d.ts.map +1 -0
- package/dist/workspace/conformance/broker.d.ts +202 -0
- package/dist/workspace/conformance/broker.d.ts.map +1 -0
- package/dist/workspace/conformance/index.d.ts +2 -1
- package/dist/workspace/conformance/index.d.ts.map +1 -1
- package/dist/workspace/conformance/vitest.d.ts +9 -2
- package/dist/workspace/conformance/vitest.d.ts.map +1 -1
- package/dist/workspace/conformance/writer.d.ts +108 -14
- package/dist/workspace/conformance/writer.d.ts.map +1 -1
- package/dist/workspace/decide.d.ts +126 -12
- package/dist/workspace/decide.d.ts.map +1 -1
- package/dist/workspace/decision-points.schema.json +11 -4
- package/dist/workspace/declaration.d.ts +65 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.schema.json +153 -4
- package/dist/workspace/environments.d.ts +36 -10
- package/dist/workspace/environments.d.ts.map +1 -1
- package/dist/workspace/factory-rules.d.ts +180 -0
- package/dist/workspace/factory-rules.d.ts.map +1 -0
- package/dist/workspace/init.d.ts +21 -0
- package/dist/workspace/init.d.ts.map +1 -1
- package/dist/workspace/intent-cli.d.ts +1 -1
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-record.d.ts +28 -1
- package/dist/workspace/intent-record.d.ts.map +1 -1
- package/dist/workspace/intent.d.ts +102 -5
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/json-edit.d.ts +24 -0
- package/dist/workspace/json-edit.d.ts.map +1 -0
- package/dist/workspace/jsonc.d.ts +11 -0
- package/dist/workspace/jsonc.d.ts.map +1 -1
- package/dist/workspace/kinds.d.ts +48 -0
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/lexicon-symbols.d.ts +29 -0
- package/dist/workspace/lexicon-symbols.d.ts.map +1 -0
- package/dist/workspace/lineage-upgrade.d.ts +31 -2
- package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
- package/dist/workspace/point-answer.schema.json +42 -2
- package/dist/workspace/points-cli.d.ts +10 -3
- package/dist/workspace/points-cli.d.ts.map +1 -1
- package/dist/workspace/points.d.ts +66 -5
- package/dist/workspace/points.d.ts.map +1 -1
- package/dist/workspace/reason-codes.d.ts +33 -4
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/record-sessions.d.ts +5 -7
- package/dist/workspace/record-sessions.d.ts.map +1 -1
- package/dist/workspace/records-cli.d.ts +7 -0
- package/dist/workspace/records-cli.d.ts.map +1 -1
- package/dist/workspace/records-close.d.ts +7 -3
- package/dist/workspace/records-close.d.ts.map +1 -1
- package/dist/workspace/records-write.d.ts +66 -6
- package/dist/workspace/records-write.d.ts.map +1 -1
- package/dist/workspace/records.d.ts +28 -9
- package/dist/workspace/records.d.ts.map +1 -1
- package/dist/workspace/runs-cli.d.ts +138 -6
- package/dist/workspace/runs-cli.d.ts.map +1 -1
- package/dist/workspace/runs.d.ts +132 -11
- package/dist/workspace/runs.d.ts.map +1 -1
- package/dist/workspace/session-kinds.d.ts +1 -1
- package/dist/workspace/session-kinds.d.ts.map +1 -1
- package/dist/workspace/squash.d.ts +80 -0
- package/dist/workspace/squash.d.ts.map +1 -0
- package/dist/workspace/status-gates.d.ts +2 -0
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status.d.ts +54 -0
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/symbols.d.ts +16 -5
- package/dist/workspace/symbols.d.ts.map +1 -1
- package/dist/workspace/trust/run-commits.d.ts +46 -0
- package/dist/workspace/trust/run-commits.d.ts.map +1 -0
- package/dist/workspace/trust/run-statement.d.ts +128 -0
- package/dist/workspace/trust/run-statement.d.ts.map +1 -0
- package/dist/workspace/trust/seal.d.ts +6 -1
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/verify-cli.d.ts +1 -1
- package/dist/workspace/trust/verify.d.ts +16 -2
- package/dist/workspace/trust/verify.d.ts.map +1 -1
- package/dist/workspace/wip-cli.d.ts +21 -0
- package/dist/workspace/wip-cli.d.ts.map +1 -0
- package/dist/workspace/wip.d.ts +268 -0
- package/dist/workspace/wip.d.ts.map +1 -0
- package/dist/workspace/work-cli.d.ts.map +1 -1
- package/dist/workspace/work-evidence.d.ts +1 -1
- package/dist/workspace/work-evidence.d.ts.map +1 -1
- package/dist/workspace/work-size.d.ts +55 -0
- package/dist/workspace/work-size.d.ts.map +1 -0
- package/dist/workspace/workspace-kinds.schema.json +122 -0
- package/dist/workspace/write-lock-cli.d.ts +60 -0
- package/dist/workspace/write-lock-cli.d.ts.map +1 -0
- package/dist/workspace/write-lock.d.ts +152 -0
- package/dist/workspace/write-lock.d.ts.map +1 -0
- package/dist/workspace/write-scope.d.ts +6 -2
- package/dist/workspace/write-scope.d.ts.map +1 -1
- package/dist/yaml.d.ts +1 -1
- package/dist/yaml.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/__fixtures__/change-set/lifecycle-plan.floci.json +59 -0
- package/src/__fixtures__/change-set/lifecycle-v1.ts.txt +4 -0
- package/src/__fixtures__/change-set/lifecycle-v2.ts.txt +4 -0
- package/src/__fixtures__/change-set/lifecycle.change-set.golden.json +95 -0
- package/src/__fixtures__/change-set/warden.change-set.golden.json +106 -0
- package/src/__fixtures__/change-set/warden.plan.json +44 -0
- package/src/__fixtures__/plan-summary/normalization-vectors.json +1593 -0
- package/src/__fixtures__/pr-loop/pr-apply-applied.note.golden.md +31 -0
- package/src/__fixtures__/pr-loop/pr-apply-refused.note.golden.md +31 -0
- package/src/__fixtures__/pr-loop/pr-plan.golden.json +127 -0
- package/src/__fixtures__/pr-loop/pr-plan.note.golden.md +37 -0
- package/src/audit/core.test.ts +15 -0
- package/src/audit/core.ts +8 -2
- package/src/audit/discover.test.ts +11 -0
- package/src/audit/discover.ts +7 -2
- package/src/change-set-bundle.test.ts +57 -0
- package/src/change-set.test.ts +215 -0
- package/src/change-set.ts +445 -0
- package/src/cli/commands/audit-opt-in.test.ts +54 -0
- package/src/cli/commands/audit.ts +29 -2
- package/src/cli/commands/build.test.ts +19 -0
- package/src/cli/commands/build.ts +3 -2
- package/src/cli/handlers/build.ts +13 -1
- package/src/cli/handlers/change-set.test.ts +56 -0
- package/src/cli/handlers/change-set.ts +44 -0
- package/src/cli/handlers/fan-out.test.ts +221 -2
- package/src/cli/handlers/fan-out.ts +165 -75
- package/src/cli/handlers/graph.ts +3 -0
- package/src/cli/handlers/operator.test.ts +21 -0
- package/src/cli/handlers/operator.ts +34 -3
- package/src/cli/handlers/pr.ts +373 -0
- package/src/cli/handlers/run.ts +1 -0
- package/src/cli/main.test.ts +20 -0
- package/src/cli/main.ts +185 -23
- package/src/cli/mcp/never-over-mcp.test.ts +101 -0
- package/src/cli/mcp/op-tools.ts +24 -2
- package/src/cli/mcp/workspace-tools.test.ts +1 -1
- package/src/cli/mcp/workspace-tools.ts +34 -6
- package/src/cli/registry.ts +63 -1
- package/src/components/auto-release.ts +1 -1
- package/src/components/capability.ts +55 -0
- package/src/components/changed-files.ts +66 -0
- package/src/components/cli-support.ts +28 -5
- package/src/components/component.schema.json +17 -0
- package/src/components/component.ts +25 -0
- package/src/components/deploy-units.ts +3 -0
- package/src/components/driver.test.ts +52 -0
- package/src/components/driver.ts +31 -13
- package/src/components/fan-out-output.ts +42 -1
- package/src/components/fan-out-record.ts +69 -0
- package/src/components/fan-out-run.test.ts +17 -0
- package/src/components/fan-out-run.ts +304 -1
- package/src/components/fan-out-support.ts +3 -0
- package/src/components/fan-out-waves.test.ts +375 -0
- package/src/components/fan-out.ts +18 -17
- package/src/components/gated-wave-pipeline.ts +82 -0
- package/src/components/index.ts +1 -0
- package/src/components/layers.ts +30 -0
- package/src/components/pr-pipeline.ts +91 -0
- package/src/components/pr-run.test.ts +205 -0
- package/src/components/pr-run.ts +280 -0
- package/src/components/promote.ts +5 -0
- package/src/components/verbs/shell.test.ts +11 -0
- package/src/components/verbs/shell.ts +7 -3
- package/src/components/wave-plan.ts +124 -0
- package/src/discovery/sandbox/bundle.ts +1 -1
- package/src/gated-waves-bundle.test.ts +62 -0
- package/src/gated-waves.test.ts +118 -0
- package/src/gated-waves.ts +240 -0
- package/src/index.ts +1 -0
- package/src/lexicon.ts +51 -0
- package/src/lifecycle/gate-ledger.ts +7 -0
- package/src/lifecycle/git.ts +102 -16
- package/src/lint/post-synth.test.ts +19 -0
- package/src/lint/post-synth.ts +19 -1
- package/src/meta/declared-imports.test.ts +1 -1
- package/src/op/activities/activity-contracts.ts +84 -0
- package/src/op/activities/change-set.ts +114 -0
- package/src/op/activities/decide.ts +3 -0
- package/src/op/activities/factory.ts +675 -0
- package/src/op/activities/index.ts +6 -0
- package/src/op/activity-contract.test.ts +21 -1
- package/src/op/activity-contract.ts +19 -9
- package/src/op/builders.ts +23 -0
- package/src/op/decide-backend.ts +5 -1
- package/src/op/decide-read-inputs.ts +33 -5
- package/src/op/factory.e2e.test.ts +232 -0
- package/src/op/factory.ts +118 -0
- package/src/op/index.ts +9 -1
- package/src/op/op-ir.test.ts +9 -0
- package/src/op/op-ir.ts +4 -0
- package/src/op/op-verb-class.ts +3 -0
- package/src/op/types.ts +8 -0
- package/src/op/work-lease-run.ts +3 -0
- package/src/plan-summary.test.ts +263 -0
- package/src/plan-summary.ts +845 -0
- package/src/pr-forge.test.ts +237 -0
- package/src/pr-forge.ts +332 -0
- package/src/pr-loop-bundle.test.ts +46 -0
- package/src/pr-loop.test.ts +171 -0
- package/src/pr-loop.ts +324 -0
- package/src/telemetry-attribution.test.ts +23 -1
- package/src/telemetry-attribution.ts +51 -0
- package/src/terraform/hcl2json.test.ts +21 -0
- package/src/terraform/hcl2json.ts +81 -0
- package/src/terraform/parse.ts +11 -74
- package/src/vendor/js-yaml-load.test.ts +115 -0
- package/src/vendor/js-yaml-load.ts +1939 -0
- package/src/workspace/__fixtures__/studio-template-84c8b21.json +1 -1
- package/src/workspace/app-kind.test.ts +196 -0
- package/src/workspace/box-cli.ts +113 -0
- package/src/workspace/box-factory.test.ts +4 -1
- package/src/workspace/box-factory.ts +37 -4
- package/src/workspace/box-listing-write.schema.json +204 -0
- package/src/workspace/box-listing.test.ts +234 -0
- package/src/workspace/box-listing.ts +324 -0
- package/src/workspace/box-publish.schema.json +498 -0
- package/src/workspace/box-publish.test.ts +204 -0
- package/src/workspace/box-publish.ts +420 -0
- package/src/workspace/box-ship.test.ts +96 -0
- package/src/workspace/broker-protocol.schema.json +186 -0
- package/src/workspace/broker-protocol.test.ts +122 -0
- package/src/workspace/broker-protocol.ts +317 -0
- package/src/workspace/builder-tiers.test.ts +146 -0
- package/src/workspace/change-set.schema.json +460 -0
- package/src/workspace/chant-migrations.e2e.test.ts +17 -5
- package/src/workspace/checks/boxes.test.ts +3 -0
- package/src/workspace/checks.ts +10 -3
- package/src/workspace/component-environments.test.ts +105 -0
- package/src/workspace/composites.schema.json +23 -4
- package/src/workspace/composites.test.ts +8 -8
- package/src/workspace/composites.ts +13 -2
- package/src/workspace/conformance/__fixture__/decisions/decision.schema.json +2 -2
- package/src/workspace/conformance/__fixtures__/reference-broker.ts +207 -0
- package/src/workspace/conformance/__writer_fixture__/answers/answer.kind.mjs +7 -2
- package/src/workspace/conformance/__writer_fixture__/answers/answer.schema.json +42 -2
- package/src/workspace/conformance/__writer_fixture__/contracts/contract.kind.mjs +37 -0
- package/src/workspace/conformance/__writer_fixture__/contracts/contract.schema.json +213 -0
- package/src/workspace/conformance/__writer_fixture__/decisions/points.json +96 -0
- package/src/workspace/conformance/__writer_fixture__/drivers/driver.kind.mjs +15 -0
- package/src/workspace/conformance/__writer_fixture__/drivers/driver.schema.json +38 -0
- package/src/workspace/conformance/__writer_fixture__/sessions/session.kind.mjs +14 -8
- package/src/workspace/conformance/__writer_fixture__/sessions/session.schema.json +187 -6
- package/src/workspace/conformance/__writer_fixture__/work/work.schema.json +25 -0
- package/src/workspace/conformance/broker.test.ts +122 -0
- package/src/workspace/conformance/broker.ts +792 -0
- package/src/workspace/conformance/conformance.e2e.test.ts +2 -1
- package/src/workspace/conformance/index.mjs +22 -1
- package/src/workspace/conformance/index.ts +5 -1
- package/src/workspace/conformance/vitest.ts +33 -1
- package/src/workspace/conformance/writer-conformance.e2e.test.ts +49 -3
- package/src/workspace/conformance/writer.test.ts +32 -2
- package/src/workspace/conformance/writer.ts +339 -28
- package/src/workspace/decide.test.ts +208 -4
- package/src/workspace/decide.ts +427 -73
- package/src/workspace/decision-points.schema.json +11 -4
- package/src/workspace/declaration.schema.json +153 -4
- package/src/workspace/declaration.ts +141 -0
- package/src/workspace/environments.ts +66 -14
- package/src/workspace/factory-rules.test.ts +62 -0
- package/src/workspace/factory-rules.ts +218 -0
- package/src/workspace/graph-cli.ts +2 -2
- package/src/workspace/graph.schema.json +67 -0
- package/src/workspace/identity.test.ts +23 -0
- package/src/workspace/init.ts +82 -2
- package/src/workspace/intent-cli.ts +26 -9
- package/src/workspace/intent-patch-id.test.ts +162 -0
- package/src/workspace/intent-record.schema.json +130 -3
- package/src/workspace/intent-record.ts +74 -28
- package/src/workspace/intent-reviews.test.ts +76 -0
- package/src/workspace/intent-squash.test.ts +213 -0
- package/src/workspace/intent-why.test.ts +5 -5
- package/src/workspace/intent.schema.json +234 -4
- package/src/workspace/intent.ts +260 -66
- package/src/workspace/json-edit.test.ts +121 -0
- package/src/workspace/json-edit.ts +142 -0
- package/src/workspace/jsonc.ts +20 -0
- package/src/workspace/kinds.ts +157 -2
- package/src/workspace/lexicon-symbols.test.ts +148 -0
- package/src/workspace/lexicon-symbols.ts +125 -0
- package/src/workspace/lineage-upgrade.test.ts +63 -0
- package/src/workspace/lineage-upgrade.ts +146 -5
- package/src/workspace/plan-summary.schema.json +155 -0
- package/src/workspace/point-answer.schema.json +42 -2
- package/src/workspace/points-cli.ts +42 -16
- package/src/workspace/points-write.schema.json +162 -4
- package/src/workspace/points.schema.json +157 -2
- package/src/workspace/points.test.ts +13 -1
- package/src/workspace/points.ts +118 -12
- package/src/workspace/pr-report.schema.json +95 -0
- package/src/workspace/profiles.test.ts +159 -0
- package/src/workspace/read-contract.test.ts +2 -2
- package/src/workspace/reason-codes.test.ts +13 -1
- package/src/workspace/reason-codes.ts +38 -4
- package/src/workspace/record-sessions.ts +9 -8
- package/src/workspace/records-amend.schema.json +78 -0
- package/src/workspace/records-cli.ts +20 -6
- package/src/workspace/records-close.schema.json +78 -0
- package/src/workspace/records-close.ts +31 -7
- package/src/workspace/records-concurrent.e2e.test.ts +135 -0
- package/src/workspace/records-concurrent.test.ts +145 -0
- package/src/workspace/records-formats.test.ts +46 -10
- package/src/workspace/records-new.schema.json +7 -0
- package/src/workspace/records-review.schema.json +78 -0
- package/src/workspace/records-sessions-write.test.ts +69 -0
- package/src/workspace/records-sessions.test.ts +22 -0
- package/src/workspace/records-write.ts +192 -25
- package/src/workspace/records.schema.json +16 -0
- package/src/workspace/records.ts +50 -9
- package/src/workspace/reference-kinds/app/package.json +10 -0
- package/src/workspace/reference-kinds/app/workspace-kinds.json +45 -0
- package/src/workspace/run-statement.schema.json +622 -0
- package/src/workspace/runs-cli.ts +343 -14
- package/src/workspace/runs-statement.test.ts +239 -0
- package/src/workspace/runs-write.schema.json +416 -5
- package/src/workspace/runs.schema.json +451 -4
- package/src/workspace/runs.test.ts +39 -0
- package/src/workspace/runs.ts +296 -35
- package/src/workspace/session-kinds.ts +3 -3
- package/src/workspace/squash.ts +198 -0
- package/src/workspace/status-contract.test.ts +5 -2
- package/src/workspace/status-gates.ts +3 -1
- package/src/workspace/status.schema.json +126 -3
- package/src/workspace/status.ts +90 -1
- package/src/workspace/symbols.ts +20 -9
- package/src/workspace/trust/run-commits.ts +115 -0
- package/src/workspace/trust/run-statement.ts +226 -0
- package/src/workspace/trust/seal.ts +8 -2
- package/src/workspace/trust/verify-cli.ts +6 -5
- package/src/workspace/trust/verify.ts +39 -6
- package/src/workspace/wip-cli.ts +97 -0
- package/src/workspace/wip-write.schema.json +504 -0
- package/src/workspace/wip.schema.json +334 -0
- package/src/workspace/wip.test.ts +294 -0
- package/src/workspace/wip.ts +753 -0
- package/src/workspace/work-cli.ts +3 -0
- package/src/workspace/work-evidence.schema.json +3 -0
- package/src/workspace/work-size.test.ts +77 -0
- package/src/workspace/work-size.ts +93 -0
- package/src/workspace/workspace-kinds.schema.json +122 -0
- package/src/workspace/write-lock-cli.ts +131 -0
- package/src/workspace/write-lock.schema.json +172 -0
- package/src/workspace/write-lock.test.ts +189 -0
- package/src/workspace/write-lock.ts +474 -0
- package/src/workspace/write-scope.test.ts +16 -1
- package/src/workspace/write-scope.ts +33 -11
- package/src/yaml.ts +31 -21
|
@@ -0,0 +1,1939 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/*
|
|
3
|
+
* A load-only YAML reader, vendored from js-yaml 4.3.2 (lib/loader.js and the core types).
|
|
4
|
+
*
|
|
5
|
+
* js-yaml is MIT licensed:
|
|
6
|
+
*
|
|
7
|
+
* Copyright (C) 2011-2015 by Vitaly Puzrin
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
10
|
+
* copy of this software and associated documentation files (the
|
|
11
|
+
* "Software"), to deal in the Software without restriction, including
|
|
12
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
13
|
+
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
14
|
+
* persons to whom the Software is furnished to do so, subject to the
|
|
15
|
+
* following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included
|
|
18
|
+
* in all copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
21
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
22
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
23
|
+
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
24
|
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
25
|
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
26
|
+
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
*
|
|
28
|
+
* Changes from upstream: the dumper, the unused built-in types (binary,
|
|
29
|
+
* timestamp, omap, pairs, set), the snippet renderer, the schema classes and
|
|
30
|
+
* the loader's option handling are gone. The reader always runs in json mode
|
|
31
|
+
* (a repeated mapping key takes the last value) and takes its type list from
|
|
32
|
+
* the caller. The parsing code itself is unchanged. It is kept in one file
|
|
33
|
+
* because js-yaml's ES module wraps each of its files in an init function a
|
|
34
|
+
* bundler cannot shake, so importing it costs the whole library.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export class YAMLException extends Error {
|
|
38
|
+
reason: string;
|
|
39
|
+
mark: { line: number; column: number; position: number; name: string | null; buffer: string };
|
|
40
|
+
constructor(reason, mark) {
|
|
41
|
+
super(reason);
|
|
42
|
+
this.name = "YAMLException";
|
|
43
|
+
this.reason = reason;
|
|
44
|
+
this.mark = mark;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const common = {
|
|
49
|
+
isObject: (subject) => typeof subject === "object" && subject !== null,
|
|
50
|
+
repeat: (string, count) => string.repeat(Math.max(0, count)),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function isNegativeZero(number) {
|
|
54
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// Types (YAML 1.2 core schema scalars)
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
export const NULL_TYPE = {
|
|
62
|
+
tag: "tag:yaml.org,2002:null",
|
|
63
|
+
kind: "scalar",
|
|
64
|
+
resolve: (data) => data === null || data === "~" || data === "null" || data === "Null" || data === "NULL",
|
|
65
|
+
construct: () => null,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const isHexCode = (c) => (c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66)
|
|
69
|
+
const isOctCode = (c) => c >= 0x30 && c <= 0x37
|
|
70
|
+
const isDecCode = (c) => c >= 0x30 && c <= 0x39
|
|
71
|
+
|
|
72
|
+
function resolveYamlInteger (data) {
|
|
73
|
+
if (data === null) return false
|
|
74
|
+
|
|
75
|
+
const max = data.length
|
|
76
|
+
let index = 0
|
|
77
|
+
let hasDigits = false
|
|
78
|
+
|
|
79
|
+
if (!max) return false
|
|
80
|
+
|
|
81
|
+
let ch = data[index]
|
|
82
|
+
|
|
83
|
+
// sign
|
|
84
|
+
if (ch === '-' || ch === '+') {
|
|
85
|
+
ch = data[++index]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (ch === '0') {
|
|
89
|
+
if (index + 1 === max) return true
|
|
90
|
+
ch = data[++index]
|
|
91
|
+
|
|
92
|
+
// base 2, base 8, base 16
|
|
93
|
+
const digit = { b: (c) => c === 0x30 || c === 0x31, x: isHexCode, o: isOctCode }[ch]
|
|
94
|
+
if (digit) {
|
|
95
|
+
index++
|
|
96
|
+
for (; index < max; index++) {
|
|
97
|
+
if (!digit(data.charCodeAt(index))) return false
|
|
98
|
+
hasDigits = true
|
|
99
|
+
}
|
|
100
|
+
return hasDigits && isFinite(parseYamlInteger(data))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// base 10 (except 0)
|
|
105
|
+
for (; index < max; index++) {
|
|
106
|
+
if (!isDecCode(data.charCodeAt(index))) return false
|
|
107
|
+
hasDigits = true
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!hasDigits) return false
|
|
111
|
+
|
|
112
|
+
return isFinite(parseYamlInteger(data))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function parseYamlInteger (data) {
|
|
116
|
+
let value = data
|
|
117
|
+
let sign = 1
|
|
118
|
+
|
|
119
|
+
let ch = value[0]
|
|
120
|
+
|
|
121
|
+
if (ch === '-' || ch === '+') {
|
|
122
|
+
if (ch === '-') sign = -1
|
|
123
|
+
value = value.slice(1)
|
|
124
|
+
ch = value[0]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (value === '0') return 0
|
|
128
|
+
|
|
129
|
+
if (ch === '0') {
|
|
130
|
+
if (value[1] === 'b') return sign * parseInt(value.slice(2), 2)
|
|
131
|
+
if (value[1] === 'x') return sign * parseInt(value.slice(2), 16)
|
|
132
|
+
if (value[1] === 'o') return sign * parseInt(value.slice(2), 8)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return sign * parseInt(value, 10)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export const INT_TYPE = {
|
|
139
|
+
tag: 'tag:yaml.org,2002:int',
|
|
140
|
+
kind: 'scalar',
|
|
141
|
+
resolve: resolveYamlInteger,
|
|
142
|
+
construct: parseYamlInteger,
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const YAML_FLOAT_PATTERN = new RegExp(
|
|
146
|
+
'^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?' +
|
|
147
|
+
'|\\.[0-9]+(?:[eE][-+]?[0-9]+)?' +
|
|
148
|
+
'|[-+]?\\.(?:inf|Inf|INF)' +
|
|
149
|
+
'|\\.(?:nan|NaN|NAN))$')
|
|
150
|
+
|
|
151
|
+
const YAML_FLOAT_SPECIAL_PATTERN = new RegExp(
|
|
152
|
+
'^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$')
|
|
153
|
+
|
|
154
|
+
function resolveYamlFloat (data) {
|
|
155
|
+
if (data === null) return false
|
|
156
|
+
if (!YAML_FLOAT_PATTERN.test(data)) return false
|
|
157
|
+
if (isFinite(parseFloat(data, 10))) return true
|
|
158
|
+
return YAML_FLOAT_SPECIAL_PATTERN.test(data)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const FLOAT_TYPE = {
|
|
162
|
+
tag: 'tag:yaml.org,2002:float',
|
|
163
|
+
kind: 'scalar',
|
|
164
|
+
resolve: resolveYamlFloat,
|
|
165
|
+
construct: (data) => {
|
|
166
|
+
let value = data.toLowerCase()
|
|
167
|
+
const sign = value[0] === '-' ? -1 : 1
|
|
168
|
+
if ('+-'.indexOf(value[0]) >= 0) value = value.slice(1)
|
|
169
|
+
if (value === '.inf') return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY
|
|
170
|
+
if (value === '.nan') return NaN
|
|
171
|
+
return sign * parseFloat(value, 10)
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const STR_TYPE = { tag: "tag:yaml.org,2002:str", kind: "scalar", construct: (data) => (data !== null ? data : "") };
|
|
176
|
+
export const SEQ_TYPE = { tag: "tag:yaml.org,2002:seq", kind: "sequence", construct: (data) => (data !== null ? data : []) };
|
|
177
|
+
export const MAP_TYPE = { tag: "tag:yaml.org,2002:map", kind: "mapping", construct: (data) => (data !== null ? data : {}) };
|
|
178
|
+
|
|
179
|
+
for (const t of [NULL_TYPE, INT_TYPE, FLOAT_TYPE, STR_TYPE, SEQ_TYPE, MAP_TYPE]) {
|
|
180
|
+
t.resolve ??= () => true;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** A type list as the loader uses it: implicit scalar resolvers, then tag lookup maps. */
|
|
184
|
+
function compileTypes(implicit, explicit) {
|
|
185
|
+
const typeMap = { scalar: {}, sequence: {}, mapping: {}, fallback: {}, multi: { scalar: [], sequence: [], mapping: [], fallback: [] } };
|
|
186
|
+
for (const type of [...implicit, ...explicit]) {
|
|
187
|
+
type.resolve ??= () => true;
|
|
188
|
+
type.construct ??= (data) => data;
|
|
189
|
+
if (type.multi) {
|
|
190
|
+
typeMap.multi[type.kind].push(type);
|
|
191
|
+
typeMap.multi.fallback.push(type);
|
|
192
|
+
} else {
|
|
193
|
+
typeMap[type.kind][type.tag] = typeMap.fallback[type.tag] = type;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return typeMap;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
// Loader
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
205
|
+
|
|
206
|
+
const CONTEXT_FLOW_IN = 1
|
|
207
|
+
const CONTEXT_FLOW_OUT = 2
|
|
208
|
+
const CONTEXT_BLOCK_IN = 3
|
|
209
|
+
const CONTEXT_BLOCK_OUT = 4
|
|
210
|
+
|
|
211
|
+
const CHOMPING_CLIP = 1
|
|
212
|
+
const CHOMPING_STRIP = 2
|
|
213
|
+
const CHOMPING_KEEP = 3
|
|
214
|
+
|
|
215
|
+
// eslint-disable-next-line no-control-regex
|
|
216
|
+
const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
|
|
217
|
+
const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/
|
|
218
|
+
// eslint-disable-next-line no-useless-escape
|
|
219
|
+
const PATTERN_FLOW_INDICATORS = /[,\[\]{}]/
|
|
220
|
+
// eslint-disable-next-line no-useless-escape
|
|
221
|
+
const PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/
|
|
222
|
+
// eslint-disable-next-line no-useless-escape
|
|
223
|
+
const PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i
|
|
224
|
+
|
|
225
|
+
function _class (obj) { return Object.prototype.toString.call(obj) }
|
|
226
|
+
|
|
227
|
+
function isEol (c) {
|
|
228
|
+
return (c === 0x0A/* LF */) || (c === 0x0D/* CR */)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function isWhiteSpace (c) {
|
|
232
|
+
return (c === 0x09/* Tab */) || (c === 0x20/* Space */)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function isWsOrEol (c) {
|
|
236
|
+
return (c === 0x09/* Tab */) ||
|
|
237
|
+
(c === 0x20/* Space */) ||
|
|
238
|
+
(c === 0x0A/* LF */) ||
|
|
239
|
+
(c === 0x0D/* CR */)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function isFlowIndicator (c) {
|
|
243
|
+
return c === 0x2C/* , */ ||
|
|
244
|
+
c === 0x5B/* [ */ ||
|
|
245
|
+
c === 0x5D/* ] */ ||
|
|
246
|
+
c === 0x7B/* { */ ||
|
|
247
|
+
c === 0x7D/* } */
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function fromHexCode (c) {
|
|
251
|
+
if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) {
|
|
252
|
+
return c - 0x30
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const lc = c | 0x20
|
|
256
|
+
|
|
257
|
+
if ((lc >= 0x61/* a */) && (lc <= 0x66/* f */)) {
|
|
258
|
+
return lc - 0x61 + 10
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return -1
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function escapedHexLen (c) {
|
|
265
|
+
if (c === 0x78/* x */) { return 2 }
|
|
266
|
+
if (c === 0x75/* u */) { return 4 }
|
|
267
|
+
if (c === 0x55/* U */) { return 8 }
|
|
268
|
+
return 0
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function fromDecimalCode (c) {
|
|
272
|
+
if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) {
|
|
273
|
+
return c - 0x30
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return -1
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function simpleEscapeSequence (c) {
|
|
280
|
+
switch (c) {
|
|
281
|
+
case 0x30/* 0 */: return '\x00'
|
|
282
|
+
case 0x61/* a */: return '\x07'
|
|
283
|
+
case 0x62/* b */: return '\x08'
|
|
284
|
+
case 0x74/* t */: return '\x09'
|
|
285
|
+
case 0x09/* Tab */: return '\x09'
|
|
286
|
+
case 0x6E/* n */: return '\x0A'
|
|
287
|
+
case 0x76/* v */: return '\x0B'
|
|
288
|
+
case 0x66/* f */: return '\x0C'
|
|
289
|
+
case 0x72/* r */: return '\x0D'
|
|
290
|
+
case 0x65/* e */: return '\x1B'
|
|
291
|
+
case 0x20/* Space */: return ' '
|
|
292
|
+
case 0x22/* " */: return '\x22'
|
|
293
|
+
case 0x2F/* / */: return '/'
|
|
294
|
+
case 0x5C/* \ */: return '\x5C'
|
|
295
|
+
case 0x4E/* N */: return '\x85'
|
|
296
|
+
case 0x5F/* _ */: return '\xA0'
|
|
297
|
+
case 0x4C/* L */: return '\u2028'
|
|
298
|
+
case 0x50/* P */: return '\u2029'
|
|
299
|
+
default: return ''
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function charFromCodepoint (c) {
|
|
304
|
+
if (c <= 0xFFFF) {
|
|
305
|
+
return String.fromCharCode(c)
|
|
306
|
+
}
|
|
307
|
+
// Encode UTF-16 surrogate pair
|
|
308
|
+
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
|
309
|
+
return String.fromCharCode(
|
|
310
|
+
((c - 0x010000) >> 10) + 0xD800,
|
|
311
|
+
((c - 0x010000) & 0x03FF) + 0xDC00
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// set a property of a literal object, while protecting against prototype pollution,
|
|
316
|
+
// see https://github.com/nodeca/js-yaml/issues/164 for more details
|
|
317
|
+
function setProperty (object, key, value) {
|
|
318
|
+
// used for this specific key only because Object.defineProperty is slow
|
|
319
|
+
if (key === '__proto__') {
|
|
320
|
+
Object.defineProperty(object, key, {
|
|
321
|
+
configurable: true,
|
|
322
|
+
enumerable: true,
|
|
323
|
+
writable: true,
|
|
324
|
+
value: value
|
|
325
|
+
})
|
|
326
|
+
} else {
|
|
327
|
+
object[key] = value
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const simpleEscapeCheck = new Array(256) // integer, for fast access
|
|
332
|
+
const simpleEscapeMap = new Array(256)
|
|
333
|
+
for (let i = 0; i < 256; i++) {
|
|
334
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0
|
|
335
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function State (input, types) {
|
|
339
|
+
this.input = input
|
|
340
|
+
|
|
341
|
+
this.filename = null
|
|
342
|
+
this.implicitTypes = types.implicit
|
|
343
|
+
this.typeMap = compileTypes(types.implicit, types.explicit)
|
|
344
|
+
// json mode: a duplicate mapping key takes the last value
|
|
345
|
+
this.json = true
|
|
346
|
+
this.legacy = false
|
|
347
|
+
this.maxDepth = 100
|
|
348
|
+
this.maxTotalMergeKeys = 10000
|
|
349
|
+
|
|
350
|
+
this.length = input.length
|
|
351
|
+
this.position = 0
|
|
352
|
+
this.line = 0
|
|
353
|
+
this.lineStart = 0
|
|
354
|
+
this.lineIndent = 0
|
|
355
|
+
this.depth = 0
|
|
356
|
+
this.totalMergeKeys = 0
|
|
357
|
+
|
|
358
|
+
// position of first leading tab in the current line,
|
|
359
|
+
// used to make sure there are no tabs in the indentation
|
|
360
|
+
this.firstTabInLine = -1
|
|
361
|
+
|
|
362
|
+
this.documents = []
|
|
363
|
+
this.anchorMapTransactions = []
|
|
364
|
+
|
|
365
|
+
/*
|
|
366
|
+
this.version;
|
|
367
|
+
this.checkLineBreaks;
|
|
368
|
+
this.tagMap;
|
|
369
|
+
this.anchorMap;
|
|
370
|
+
this.tag;
|
|
371
|
+
this.anchor;
|
|
372
|
+
this.kind;
|
|
373
|
+
this.result; */
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function generateError (state, message) {
|
|
377
|
+
const mark = {
|
|
378
|
+
name: state.filename,
|
|
379
|
+
buffer: state.input.slice(0, -1), // omit trailing \0
|
|
380
|
+
position: state.position,
|
|
381
|
+
line: state.line,
|
|
382
|
+
column: state.position - state.lineStart
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return new YAMLException(message, mark)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function throwError (state, message) {
|
|
389
|
+
throw generateError(state, message)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function throwWarning () {}
|
|
393
|
+
|
|
394
|
+
function storeAnchor (state, name, value) {
|
|
395
|
+
const transactions = state.anchorMapTransactions
|
|
396
|
+
|
|
397
|
+
if (transactions.length !== 0) {
|
|
398
|
+
const transaction = transactions[transactions.length - 1]
|
|
399
|
+
|
|
400
|
+
if (!_hasOwnProperty.call(transaction, name)) {
|
|
401
|
+
transaction[name] = {
|
|
402
|
+
existed: _hasOwnProperty.call(state.anchorMap, name),
|
|
403
|
+
value: state.anchorMap[name]
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
state.anchorMap[name] = value
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function beginAnchorTransaction (state) {
|
|
412
|
+
state.anchorMapTransactions.push(Object.create(null))
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function commitAnchorTransaction (state) {
|
|
416
|
+
const transaction = state.anchorMapTransactions.pop()
|
|
417
|
+
const transactions = state.anchorMapTransactions
|
|
418
|
+
|
|
419
|
+
if (transactions.length === 0) return
|
|
420
|
+
|
|
421
|
+
const parent = transactions[transactions.length - 1]
|
|
422
|
+
const names = Object.keys(transaction)
|
|
423
|
+
|
|
424
|
+
for (let index = 0, length = names.length; index < length; index += 1) {
|
|
425
|
+
const name = names[index]
|
|
426
|
+
|
|
427
|
+
if (!_hasOwnProperty.call(parent, name)) {
|
|
428
|
+
parent[name] = transaction[name]
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function rollbackAnchorTransaction (state) {
|
|
434
|
+
const transaction = state.anchorMapTransactions.pop()
|
|
435
|
+
const names = Object.keys(transaction)
|
|
436
|
+
|
|
437
|
+
for (let index = names.length - 1; index >= 0; index -= 1) {
|
|
438
|
+
const entry = transaction[names[index]]
|
|
439
|
+
|
|
440
|
+
if (entry.existed) {
|
|
441
|
+
state.anchorMap[names[index]] = entry.value
|
|
442
|
+
} else {
|
|
443
|
+
delete state.anchorMap[names[index]]
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function snapshotState (state) {
|
|
449
|
+
return {
|
|
450
|
+
position: state.position,
|
|
451
|
+
line: state.line,
|
|
452
|
+
lineStart: state.lineStart,
|
|
453
|
+
lineIndent: state.lineIndent,
|
|
454
|
+
firstTabInLine: state.firstTabInLine,
|
|
455
|
+
tag: state.tag,
|
|
456
|
+
anchor: state.anchor,
|
|
457
|
+
kind: state.kind,
|
|
458
|
+
result: state.result
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function restoreState (state, snapshot) {
|
|
463
|
+
state.position = snapshot.position
|
|
464
|
+
state.line = snapshot.line
|
|
465
|
+
state.lineStart = snapshot.lineStart
|
|
466
|
+
state.lineIndent = snapshot.lineIndent
|
|
467
|
+
state.firstTabInLine = snapshot.firstTabInLine
|
|
468
|
+
state.tag = snapshot.tag
|
|
469
|
+
state.anchor = snapshot.anchor
|
|
470
|
+
state.kind = snapshot.kind
|
|
471
|
+
state.result = snapshot.result
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const directiveHandlers = {
|
|
475
|
+
|
|
476
|
+
YAML: function handleYamlDirective (state, name, args) {
|
|
477
|
+
if (state.version !== null) {
|
|
478
|
+
throwError(state, 'duplication of %YAML directive')
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (args.length !== 1) {
|
|
482
|
+
throwError(state, 'YAML directive accepts exactly one argument')
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0])
|
|
486
|
+
|
|
487
|
+
if (match === null) {
|
|
488
|
+
throwError(state, 'ill-formed argument of the YAML directive')
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const major = parseInt(match[1], 10)
|
|
492
|
+
const minor = parseInt(match[2], 10)
|
|
493
|
+
|
|
494
|
+
if (major !== 1) {
|
|
495
|
+
throwError(state, 'unacceptable YAML version of the document')
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
state.version = args[0]
|
|
499
|
+
state.checkLineBreaks = (minor < 2)
|
|
500
|
+
|
|
501
|
+
if (minor !== 1 && minor !== 2) {
|
|
502
|
+
throwWarning(state, 'unsupported YAML version of the document')
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
TAG: function handleTagDirective (state, name, args) {
|
|
507
|
+
let prefix
|
|
508
|
+
|
|
509
|
+
if (args.length !== 2) {
|
|
510
|
+
throwError(state, 'TAG directive accepts exactly two arguments')
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const handle = args[0]
|
|
514
|
+
prefix = args[1]
|
|
515
|
+
|
|
516
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
517
|
+
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive')
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
521
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle')
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
525
|
+
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive')
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
try {
|
|
529
|
+
prefix = decodeURIComponent(prefix)
|
|
530
|
+
} catch (err) {
|
|
531
|
+
throwError(state, 'tag prefix is malformed: ' + prefix)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
state.tagMap[handle] = prefix
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function captureSegment (state, start, end, checkJson) {
|
|
539
|
+
if (start < end) {
|
|
540
|
+
const _result = state.input.slice(start, end)
|
|
541
|
+
|
|
542
|
+
if (checkJson) {
|
|
543
|
+
for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
544
|
+
const _character = _result.charCodeAt(_position)
|
|
545
|
+
if (!(_character === 0x09 ||
|
|
546
|
+
(_character >= 0x20 && _character <= 0x10FFFF))) {
|
|
547
|
+
throwError(state, 'expected valid JSON character')
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
551
|
+
throwError(state, 'the stream contains non-printable characters')
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
state.result += _result
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function chargeMergeWork (state) {
|
|
559
|
+
state.totalMergeKeys++
|
|
560
|
+
|
|
561
|
+
if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) {
|
|
562
|
+
throwError(state, 'merge keys exceeded maxTotalMergeKeys (' + state.maxTotalMergeKeys + ')')
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function mergeMappings (state, destination, source, overridableKeys) {
|
|
567
|
+
if (!common.isObject(source)) {
|
|
568
|
+
throwError(state, 'cannot merge mappings; the provided source object is unacceptable')
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Count the source mapping itself to bound sequences of empty mappings.
|
|
572
|
+
chargeMergeWork(state)
|
|
573
|
+
|
|
574
|
+
const sourceKeys = Object.keys(source)
|
|
575
|
+
|
|
576
|
+
for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
577
|
+
const key = sourceKeys[index]
|
|
578
|
+
|
|
579
|
+
chargeMergeWork(state)
|
|
580
|
+
|
|
581
|
+
if (!_hasOwnProperty.call(destination, key)) {
|
|
582
|
+
setProperty(destination, key, source[key])
|
|
583
|
+
overridableKeys[key] = true
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function storeMappingPair (state, _result, overridableKeys, keyTag, keyNode, valueNode,
|
|
589
|
+
startLine, startLineStart, startPos) {
|
|
590
|
+
// The output is a plain object here, so keys can only be strings.
|
|
591
|
+
// We need to convert keyNode to a string, but doing so can hang the process
|
|
592
|
+
// (deeply nested arrays that explode exponentially using aliases).
|
|
593
|
+
if (Array.isArray(keyNode)) {
|
|
594
|
+
keyNode = Array.prototype.slice.call(keyNode)
|
|
595
|
+
|
|
596
|
+
for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
597
|
+
if (Array.isArray(keyNode[index])) {
|
|
598
|
+
throwError(state, 'nested arrays are not supported inside keys')
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
|
|
602
|
+
keyNode[index] = '[object Object]'
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// Avoid code execution in load() via toString property
|
|
608
|
+
// (still use its own toString for arrays, timestamps,
|
|
609
|
+
// and whatever user schema extensions happen to have @@toStringTag)
|
|
610
|
+
if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
|
|
611
|
+
keyNode = '[object Object]'
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
keyNode = String(keyNode)
|
|
615
|
+
|
|
616
|
+
if (_result === null) {
|
|
617
|
+
_result = {}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (keyTag === 'tag:yaml.org,2002:merge') {
|
|
621
|
+
if (Array.isArray(valueNode)) {
|
|
622
|
+
if (valueNode.length > 100) {
|
|
623
|
+
throwError(state, 'abnormal merge sequence size')
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
627
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys)
|
|
628
|
+
}
|
|
629
|
+
} else {
|
|
630
|
+
mergeMappings(state, _result, valueNode, overridableKeys)
|
|
631
|
+
}
|
|
632
|
+
} else {
|
|
633
|
+
if (!state.json &&
|
|
634
|
+
!_hasOwnProperty.call(overridableKeys, keyNode) &&
|
|
635
|
+
_hasOwnProperty.call(_result, keyNode)) {
|
|
636
|
+
state.line = startLine || state.line
|
|
637
|
+
state.lineStart = startLineStart || state.lineStart
|
|
638
|
+
state.position = startPos || state.position
|
|
639
|
+
throwError(state, 'duplicated mapping key')
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
setProperty(_result, keyNode, valueNode)
|
|
643
|
+
delete overridableKeys[keyNode]
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
return _result
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function readLineBreak (state) {
|
|
650
|
+
const ch = state.input.charCodeAt(state.position)
|
|
651
|
+
|
|
652
|
+
if (ch === 0x0A/* LF */) {
|
|
653
|
+
state.position++
|
|
654
|
+
} else if (ch === 0x0D/* CR */) {
|
|
655
|
+
state.position++
|
|
656
|
+
if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
|
|
657
|
+
state.position++
|
|
658
|
+
}
|
|
659
|
+
} else {
|
|
660
|
+
throwError(state, 'a line break is expected')
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
state.line += 1
|
|
664
|
+
state.lineStart = state.position
|
|
665
|
+
state.firstTabInLine = -1
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function skipSeparationSpace (state, allowComments, checkIndent) {
|
|
669
|
+
let lineBreaks = 0
|
|
670
|
+
let ch = state.input.charCodeAt(state.position)
|
|
671
|
+
|
|
672
|
+
while (ch !== 0) {
|
|
673
|
+
while (isWhiteSpace(ch)) {
|
|
674
|
+
if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) {
|
|
675
|
+
state.firstTabInLine = state.position
|
|
676
|
+
}
|
|
677
|
+
ch = state.input.charCodeAt(++state.position)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (allowComments && ch === 0x23/* # */) {
|
|
681
|
+
do {
|
|
682
|
+
ch = state.input.charCodeAt(++state.position)
|
|
683
|
+
} while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (isEol(ch)) {
|
|
687
|
+
readLineBreak(state)
|
|
688
|
+
|
|
689
|
+
ch = state.input.charCodeAt(state.position)
|
|
690
|
+
lineBreaks++
|
|
691
|
+
state.lineIndent = 0
|
|
692
|
+
|
|
693
|
+
while (ch === 0x20/* Space */) {
|
|
694
|
+
state.lineIndent++
|
|
695
|
+
ch = state.input.charCodeAt(++state.position)
|
|
696
|
+
}
|
|
697
|
+
} else {
|
|
698
|
+
break
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
703
|
+
throwWarning(state, 'deficient indentation')
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return lineBreaks
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function testDocumentSeparator (state) {
|
|
710
|
+
let _position = state.position
|
|
711
|
+
let ch = state.input.charCodeAt(_position)
|
|
712
|
+
|
|
713
|
+
// Condition state.position === state.lineStart is tested
|
|
714
|
+
// in parent on each call, for efficiency. No needs to test here again.
|
|
715
|
+
if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
|
|
716
|
+
ch === state.input.charCodeAt(_position + 1) &&
|
|
717
|
+
ch === state.input.charCodeAt(_position + 2)) {
|
|
718
|
+
_position += 3
|
|
719
|
+
|
|
720
|
+
ch = state.input.charCodeAt(_position)
|
|
721
|
+
|
|
722
|
+
if (ch === 0 || isWsOrEol(ch)) {
|
|
723
|
+
return true
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
return false
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function writeFoldedLines (state, count) {
|
|
731
|
+
if (count === 1) {
|
|
732
|
+
state.result += ' '
|
|
733
|
+
} else if (count > 1) {
|
|
734
|
+
state.result += common.repeat('\n', count - 1)
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function readPlainScalar (state, nodeIndent, withinFlowCollection) {
|
|
739
|
+
let captureStart
|
|
740
|
+
let captureEnd
|
|
741
|
+
let hasPendingContent
|
|
742
|
+
let _line
|
|
743
|
+
let _lineStart
|
|
744
|
+
let _lineIndent
|
|
745
|
+
const _kind = state.kind
|
|
746
|
+
const _result = state.result
|
|
747
|
+
|
|
748
|
+
let ch = state.input.charCodeAt(state.position)
|
|
749
|
+
|
|
750
|
+
if (isWsOrEol(ch) ||
|
|
751
|
+
isFlowIndicator(ch) ||
|
|
752
|
+
ch === 0x23/* # */ ||
|
|
753
|
+
ch === 0x26/* & */ ||
|
|
754
|
+
ch === 0x2A/* * */ ||
|
|
755
|
+
ch === 0x21/* ! */ ||
|
|
756
|
+
ch === 0x7C/* | */ ||
|
|
757
|
+
ch === 0x3E/* > */ ||
|
|
758
|
+
ch === 0x27/* ' */ ||
|
|
759
|
+
ch === 0x22/* " */ ||
|
|
760
|
+
ch === 0x25/* % */ ||
|
|
761
|
+
ch === 0x40/* @ */ ||
|
|
762
|
+
ch === 0x60/* ` */) {
|
|
763
|
+
return false
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
|
|
767
|
+
const following = state.input.charCodeAt(state.position + 1)
|
|
768
|
+
|
|
769
|
+
if (isWsOrEol(following) ||
|
|
770
|
+
(withinFlowCollection && isFlowIndicator(following))) {
|
|
771
|
+
return false
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
state.kind = 'scalar'
|
|
776
|
+
state.result = ''
|
|
777
|
+
captureStart = captureEnd = state.position
|
|
778
|
+
hasPendingContent = false
|
|
779
|
+
|
|
780
|
+
while (ch !== 0) {
|
|
781
|
+
if (ch === 0x3A/* : */) {
|
|
782
|
+
const following = state.input.charCodeAt(state.position + 1)
|
|
783
|
+
|
|
784
|
+
if (isWsOrEol(following) ||
|
|
785
|
+
(withinFlowCollection && isFlowIndicator(following))) {
|
|
786
|
+
break
|
|
787
|
+
}
|
|
788
|
+
} else if (ch === 0x23/* # */) {
|
|
789
|
+
const preceding = state.input.charCodeAt(state.position - 1)
|
|
790
|
+
|
|
791
|
+
if (isWsOrEol(preceding)) {
|
|
792
|
+
break
|
|
793
|
+
}
|
|
794
|
+
} else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
|
|
795
|
+
(withinFlowCollection && isFlowIndicator(ch))) {
|
|
796
|
+
break
|
|
797
|
+
} else if (isEol(ch)) {
|
|
798
|
+
_line = state.line
|
|
799
|
+
_lineStart = state.lineStart
|
|
800
|
+
_lineIndent = state.lineIndent
|
|
801
|
+
skipSeparationSpace(state, false, -1)
|
|
802
|
+
|
|
803
|
+
if (state.lineIndent >= nodeIndent) {
|
|
804
|
+
hasPendingContent = true
|
|
805
|
+
ch = state.input.charCodeAt(state.position)
|
|
806
|
+
continue
|
|
807
|
+
} else {
|
|
808
|
+
state.position = captureEnd
|
|
809
|
+
state.line = _line
|
|
810
|
+
state.lineStart = _lineStart
|
|
811
|
+
state.lineIndent = _lineIndent
|
|
812
|
+
break
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
if (hasPendingContent) {
|
|
817
|
+
captureSegment(state, captureStart, captureEnd, false)
|
|
818
|
+
writeFoldedLines(state, state.line - _line)
|
|
819
|
+
captureStart = captureEnd = state.position
|
|
820
|
+
hasPendingContent = false
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (!isWhiteSpace(ch)) {
|
|
824
|
+
captureEnd = state.position + 1
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
ch = state.input.charCodeAt(++state.position)
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
captureSegment(state, captureStart, captureEnd, false)
|
|
831
|
+
|
|
832
|
+
if (state.result) {
|
|
833
|
+
return true
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
state.kind = _kind
|
|
837
|
+
state.result = _result
|
|
838
|
+
return false
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function readSingleQuotedScalar (state, nodeIndent) {
|
|
842
|
+
let captureStart
|
|
843
|
+
let captureEnd
|
|
844
|
+
|
|
845
|
+
let ch = state.input.charCodeAt(state.position)
|
|
846
|
+
|
|
847
|
+
if (ch !== 0x27/* ' */) {
|
|
848
|
+
return false
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
state.kind = 'scalar'
|
|
852
|
+
state.result = ''
|
|
853
|
+
state.position++
|
|
854
|
+
captureStart = captureEnd = state.position
|
|
855
|
+
|
|
856
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
857
|
+
if (ch === 0x27/* ' */) {
|
|
858
|
+
captureSegment(state, captureStart, state.position, true)
|
|
859
|
+
ch = state.input.charCodeAt(++state.position)
|
|
860
|
+
|
|
861
|
+
if (ch === 0x27/* ' */) {
|
|
862
|
+
captureStart = state.position
|
|
863
|
+
state.position++
|
|
864
|
+
captureEnd = state.position
|
|
865
|
+
} else {
|
|
866
|
+
return true
|
|
867
|
+
}
|
|
868
|
+
} else if (isEol(ch)) {
|
|
869
|
+
captureSegment(state, captureStart, captureEnd, true)
|
|
870
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent))
|
|
871
|
+
captureStart = captureEnd = state.position
|
|
872
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
873
|
+
throwError(state, 'unexpected end of the document within a single quoted scalar')
|
|
874
|
+
} else {
|
|
875
|
+
state.position++
|
|
876
|
+
if (!isWhiteSpace(ch)) {
|
|
877
|
+
captureEnd = state.position
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
throwError(state, 'unexpected end of the stream within a single quoted scalar')
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
function readDoubleQuotedScalar (state, nodeIndent) {
|
|
886
|
+
let captureStart
|
|
887
|
+
let captureEnd
|
|
888
|
+
let tmp
|
|
889
|
+
|
|
890
|
+
let ch = state.input.charCodeAt(state.position)
|
|
891
|
+
|
|
892
|
+
if (ch !== 0x22/* " */) {
|
|
893
|
+
return false
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
state.kind = 'scalar'
|
|
897
|
+
state.result = ''
|
|
898
|
+
state.position++
|
|
899
|
+
captureStart = captureEnd = state.position
|
|
900
|
+
|
|
901
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
902
|
+
if (ch === 0x22/* " */) {
|
|
903
|
+
captureSegment(state, captureStart, state.position, true)
|
|
904
|
+
state.position++
|
|
905
|
+
return true
|
|
906
|
+
} else if (ch === 0x5C/* \ */) {
|
|
907
|
+
captureSegment(state, captureStart, state.position, true)
|
|
908
|
+
ch = state.input.charCodeAt(++state.position)
|
|
909
|
+
|
|
910
|
+
if (isEol(ch)) {
|
|
911
|
+
skipSeparationSpace(state, false, nodeIndent)
|
|
912
|
+
|
|
913
|
+
// TODO: rework to inline fn with no type cast?
|
|
914
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
915
|
+
state.result += simpleEscapeMap[ch]
|
|
916
|
+
state.position++
|
|
917
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
918
|
+
let hexLength = tmp
|
|
919
|
+
let hexResult = 0
|
|
920
|
+
|
|
921
|
+
for (; hexLength > 0; hexLength--) {
|
|
922
|
+
ch = state.input.charCodeAt(++state.position)
|
|
923
|
+
|
|
924
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
925
|
+
hexResult = (hexResult << 4) + tmp
|
|
926
|
+
} else {
|
|
927
|
+
throwError(state, 'expected hexadecimal character')
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
state.result += charFromCodepoint(hexResult)
|
|
932
|
+
|
|
933
|
+
state.position++
|
|
934
|
+
} else {
|
|
935
|
+
throwError(state, 'unknown escape sequence')
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
captureStart = captureEnd = state.position
|
|
939
|
+
} else if (isEol(ch)) {
|
|
940
|
+
captureSegment(state, captureStart, captureEnd, true)
|
|
941
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent))
|
|
942
|
+
captureStart = captureEnd = state.position
|
|
943
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
944
|
+
throwError(state, 'unexpected end of the document within a double quoted scalar')
|
|
945
|
+
} else {
|
|
946
|
+
state.position++
|
|
947
|
+
if (!isWhiteSpace(ch)) {
|
|
948
|
+
captureEnd = state.position
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
throwError(state, 'unexpected end of the stream within a double quoted scalar')
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
function readFlowCollection (state, nodeIndent) {
|
|
957
|
+
let readNext = true
|
|
958
|
+
let _line
|
|
959
|
+
let _lineStart
|
|
960
|
+
let _pos
|
|
961
|
+
const _tag = state.tag
|
|
962
|
+
let _result
|
|
963
|
+
const _anchor = state.anchor
|
|
964
|
+
let terminator
|
|
965
|
+
let isPair
|
|
966
|
+
let isExplicitPair
|
|
967
|
+
let isMapping
|
|
968
|
+
const overridableKeys = Object.create(null)
|
|
969
|
+
let keyNode
|
|
970
|
+
let keyTag
|
|
971
|
+
let valueNode
|
|
972
|
+
|
|
973
|
+
let ch = state.input.charCodeAt(state.position)
|
|
974
|
+
|
|
975
|
+
if (ch === 0x5B/* [ */) {
|
|
976
|
+
terminator = 0x5D/* ] */
|
|
977
|
+
isMapping = false
|
|
978
|
+
_result = []
|
|
979
|
+
} else if (ch === 0x7B/* { */) {
|
|
980
|
+
terminator = 0x7D/* } */
|
|
981
|
+
isMapping = true
|
|
982
|
+
_result = {}
|
|
983
|
+
} else {
|
|
984
|
+
return false
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
if (state.anchor !== null) {
|
|
988
|
+
storeAnchor(state, state.anchor, _result)
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
ch = state.input.charCodeAt(++state.position)
|
|
992
|
+
|
|
993
|
+
while (ch !== 0) {
|
|
994
|
+
skipSeparationSpace(state, true, nodeIndent)
|
|
995
|
+
|
|
996
|
+
ch = state.input.charCodeAt(state.position)
|
|
997
|
+
|
|
998
|
+
if (ch === terminator) {
|
|
999
|
+
state.position++
|
|
1000
|
+
state.tag = _tag
|
|
1001
|
+
state.anchor = _anchor
|
|
1002
|
+
state.kind = isMapping ? 'mapping' : 'sequence'
|
|
1003
|
+
state.result = _result
|
|
1004
|
+
return true
|
|
1005
|
+
} else if (!readNext) {
|
|
1006
|
+
throwError(state, 'missed comma between flow collection entries')
|
|
1007
|
+
} else if (ch === 0x2C/* , */) {
|
|
1008
|
+
// "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
|
|
1009
|
+
throwError(state, "expected the node content, but found ','")
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
keyTag = keyNode = valueNode = null
|
|
1013
|
+
isPair = isExplicitPair = false
|
|
1014
|
+
|
|
1015
|
+
if (ch === 0x3F/* ? */) {
|
|
1016
|
+
const following = state.input.charCodeAt(state.position + 1)
|
|
1017
|
+
|
|
1018
|
+
if (isWsOrEol(following)) {
|
|
1019
|
+
isPair = isExplicitPair = true
|
|
1020
|
+
state.position++
|
|
1021
|
+
skipSeparationSpace(state, true, nodeIndent)
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
_line = state.line // Save the current line.
|
|
1026
|
+
_lineStart = state.lineStart
|
|
1027
|
+
_pos = state.position
|
|
1028
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)
|
|
1029
|
+
keyTag = state.tag
|
|
1030
|
+
keyNode = state.result
|
|
1031
|
+
skipSeparationSpace(state, true, nodeIndent)
|
|
1032
|
+
|
|
1033
|
+
ch = state.input.charCodeAt(state.position)
|
|
1034
|
+
|
|
1035
|
+
if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
|
|
1036
|
+
isPair = true
|
|
1037
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1038
|
+
skipSeparationSpace(state, true, nodeIndent)
|
|
1039
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)
|
|
1040
|
+
valueNode = state.result
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
if (isMapping) {
|
|
1044
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)
|
|
1045
|
+
} else if (isPair) {
|
|
1046
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos))
|
|
1047
|
+
} else {
|
|
1048
|
+
_result.push(keyNode)
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
skipSeparationSpace(state, true, nodeIndent)
|
|
1052
|
+
|
|
1053
|
+
ch = state.input.charCodeAt(state.position)
|
|
1054
|
+
|
|
1055
|
+
if (ch === 0x2C/* , */) {
|
|
1056
|
+
readNext = true
|
|
1057
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1058
|
+
} else {
|
|
1059
|
+
readNext = false
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
throwError(state, 'unexpected end of the stream within a flow collection')
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
function readBlockScalar (state, nodeIndent) {
|
|
1067
|
+
let folding
|
|
1068
|
+
let chomping = CHOMPING_CLIP
|
|
1069
|
+
let didReadContent = false
|
|
1070
|
+
let detectedIndent = false
|
|
1071
|
+
let textIndent = nodeIndent
|
|
1072
|
+
let emptyLines = 0
|
|
1073
|
+
let atMoreIndented = false
|
|
1074
|
+
let tmp
|
|
1075
|
+
|
|
1076
|
+
let ch = state.input.charCodeAt(state.position)
|
|
1077
|
+
|
|
1078
|
+
if (ch === 0x7C/* | */) {
|
|
1079
|
+
folding = false
|
|
1080
|
+
} else if (ch === 0x3E/* > */) {
|
|
1081
|
+
folding = true
|
|
1082
|
+
} else {
|
|
1083
|
+
return false
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
state.kind = 'scalar'
|
|
1087
|
+
state.result = ''
|
|
1088
|
+
|
|
1089
|
+
while (ch !== 0) {
|
|
1090
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1091
|
+
|
|
1092
|
+
if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
|
|
1093
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1094
|
+
chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP
|
|
1095
|
+
} else {
|
|
1096
|
+
throwError(state, 'repeat of a chomping mode identifier')
|
|
1097
|
+
}
|
|
1098
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1099
|
+
if (tmp === 0) {
|
|
1100
|
+
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one')
|
|
1101
|
+
} else if (!detectedIndent) {
|
|
1102
|
+
textIndent = nodeIndent + tmp - 1
|
|
1103
|
+
detectedIndent = true
|
|
1104
|
+
} else {
|
|
1105
|
+
throwError(state, 'repeat of an indentation width identifier')
|
|
1106
|
+
}
|
|
1107
|
+
} else {
|
|
1108
|
+
break
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
if (isWhiteSpace(ch)) {
|
|
1113
|
+
do { ch = state.input.charCodeAt(++state.position) }
|
|
1114
|
+
while (isWhiteSpace(ch))
|
|
1115
|
+
|
|
1116
|
+
if (ch === 0x23/* # */) {
|
|
1117
|
+
do { ch = state.input.charCodeAt(++state.position) }
|
|
1118
|
+
while (!isEol(ch) && (ch !== 0))
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
while (ch !== 0) {
|
|
1123
|
+
readLineBreak(state)
|
|
1124
|
+
state.lineIndent = 0
|
|
1125
|
+
|
|
1126
|
+
ch = state.input.charCodeAt(state.position)
|
|
1127
|
+
|
|
1128
|
+
// eslint-disable-next-line no-unmodified-loop-condition
|
|
1129
|
+
while ((!detectedIndent || state.lineIndent < textIndent) &&
|
|
1130
|
+
(ch === 0x20/* Space */)) {
|
|
1131
|
+
state.lineIndent++
|
|
1132
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1136
|
+
textIndent = state.lineIndent
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
if (isEol(ch)) {
|
|
1140
|
+
emptyLines++
|
|
1141
|
+
continue
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
if (!detectedIndent && textIndent === 0) {
|
|
1145
|
+
throwError(state, 'missing indentation for block scalar')
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// End of the scalar.
|
|
1149
|
+
if (state.lineIndent < textIndent) {
|
|
1150
|
+
// Perform the chomping.
|
|
1151
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1152
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines)
|
|
1153
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1154
|
+
if (didReadContent) { // i.e. only if the scalar is not empty.
|
|
1155
|
+
state.result += '\n'
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// Break this `while` cycle and go to the funciton's epilogue.
|
|
1160
|
+
break
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// Folded style: use fancy rules to handle line breaks.
|
|
1164
|
+
if (folding) {
|
|
1165
|
+
// Lines starting with white space characters (more-indented lines) are not folded.
|
|
1166
|
+
if (isWhiteSpace(ch)) {
|
|
1167
|
+
atMoreIndented = true
|
|
1168
|
+
// except for the first content line (cf. Example 8.1)
|
|
1169
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines)
|
|
1170
|
+
|
|
1171
|
+
// End of more-indented block.
|
|
1172
|
+
} else if (atMoreIndented) {
|
|
1173
|
+
atMoreIndented = false
|
|
1174
|
+
state.result += common.repeat('\n', emptyLines + 1)
|
|
1175
|
+
|
|
1176
|
+
// Just one line break - perceive as the same line.
|
|
1177
|
+
} else if (emptyLines === 0) {
|
|
1178
|
+
if (didReadContent) { // i.e. only if we have already read some scalar content.
|
|
1179
|
+
state.result += ' '
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// Several line breaks - perceive as different lines.
|
|
1183
|
+
} else {
|
|
1184
|
+
state.result += common.repeat('\n', emptyLines)
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// Literal style: just add exact number of line breaks between content lines.
|
|
1188
|
+
} else {
|
|
1189
|
+
// Keep all line breaks except the header line break.
|
|
1190
|
+
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines)
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
didReadContent = true
|
|
1194
|
+
detectedIndent = true
|
|
1195
|
+
emptyLines = 0
|
|
1196
|
+
const captureStart = state.position
|
|
1197
|
+
|
|
1198
|
+
while (!isEol(ch) && (ch !== 0)) {
|
|
1199
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
captureSegment(state, captureStart, state.position, false)
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return true
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function readBlockSequence (state, nodeIndent) {
|
|
1209
|
+
const _tag = state.tag
|
|
1210
|
+
const _anchor = state.anchor
|
|
1211
|
+
const _result = []
|
|
1212
|
+
let detected = false
|
|
1213
|
+
|
|
1214
|
+
// there is a leading tab before this token, so it can't be a block sequence/mapping;
|
|
1215
|
+
// it can still be flow sequence/mapping or a scalar
|
|
1216
|
+
if (state.firstTabInLine !== -1) return false
|
|
1217
|
+
|
|
1218
|
+
if (state.anchor !== null) {
|
|
1219
|
+
storeAnchor(state, state.anchor, _result)
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
let ch = state.input.charCodeAt(state.position)
|
|
1223
|
+
|
|
1224
|
+
while (ch !== 0) {
|
|
1225
|
+
if (state.firstTabInLine !== -1) {
|
|
1226
|
+
state.position = state.firstTabInLine
|
|
1227
|
+
throwError(state, 'tab characters must not be used in indentation')
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
if (ch !== 0x2D/* - */) {
|
|
1231
|
+
break
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
const following = state.input.charCodeAt(state.position + 1)
|
|
1235
|
+
|
|
1236
|
+
if (!isWsOrEol(following)) {
|
|
1237
|
+
break
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
detected = true
|
|
1241
|
+
state.position++
|
|
1242
|
+
|
|
1243
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1244
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1245
|
+
_result.push(null)
|
|
1246
|
+
ch = state.input.charCodeAt(state.position)
|
|
1247
|
+
continue
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
const _line = state.line
|
|
1252
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true)
|
|
1253
|
+
_result.push(state.result)
|
|
1254
|
+
skipSeparationSpace(state, true, -1)
|
|
1255
|
+
|
|
1256
|
+
ch = state.input.charCodeAt(state.position)
|
|
1257
|
+
|
|
1258
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
|
|
1259
|
+
throwError(state, 'bad indentation of a sequence entry')
|
|
1260
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1261
|
+
break
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
if (detected) {
|
|
1266
|
+
state.tag = _tag
|
|
1267
|
+
state.anchor = _anchor
|
|
1268
|
+
state.kind = 'sequence'
|
|
1269
|
+
state.result = _result
|
|
1270
|
+
return true
|
|
1271
|
+
}
|
|
1272
|
+
return false
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function readBlockMapping (state, nodeIndent, flowIndent) {
|
|
1276
|
+
let allowCompact
|
|
1277
|
+
let _keyLine
|
|
1278
|
+
let _keyLineStart
|
|
1279
|
+
let _keyPos
|
|
1280
|
+
const _tag = state.tag
|
|
1281
|
+
const _anchor = state.anchor
|
|
1282
|
+
const _result = {}
|
|
1283
|
+
const overridableKeys = Object.create(null)
|
|
1284
|
+
let keyTag = null
|
|
1285
|
+
let keyNode = null
|
|
1286
|
+
let valueNode = null
|
|
1287
|
+
let atExplicitKey = false
|
|
1288
|
+
let detected = false
|
|
1289
|
+
|
|
1290
|
+
// there is a leading tab before this token, so it can't be a block sequence/mapping;
|
|
1291
|
+
// it can still be flow sequence/mapping or a scalar
|
|
1292
|
+
if (state.firstTabInLine !== -1) return false
|
|
1293
|
+
|
|
1294
|
+
if (state.anchor !== null) {
|
|
1295
|
+
storeAnchor(state, state.anchor, _result)
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
let ch = state.input.charCodeAt(state.position)
|
|
1299
|
+
|
|
1300
|
+
while (ch !== 0) {
|
|
1301
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1302
|
+
state.position = state.firstTabInLine
|
|
1303
|
+
throwError(state, 'tab characters must not be used in indentation')
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
const following = state.input.charCodeAt(state.position + 1)
|
|
1307
|
+
const _line = state.line // Save the current line.
|
|
1308
|
+
|
|
1309
|
+
//
|
|
1310
|
+
// Explicit notation case. There are two separate blocks:
|
|
1311
|
+
// first for the key (denoted by "?") and second for the value (denoted by ":")
|
|
1312
|
+
//
|
|
1313
|
+
if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && isWsOrEol(following)) {
|
|
1314
|
+
if (ch === 0x3F/* ? */) {
|
|
1315
|
+
if (atExplicitKey) {
|
|
1316
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos)
|
|
1317
|
+
keyTag = keyNode = valueNode = null
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
detected = true
|
|
1321
|
+
atExplicitKey = true
|
|
1322
|
+
allowCompact = true
|
|
1323
|
+
} else if (atExplicitKey) {
|
|
1324
|
+
// i.e. 0x3A/* : */ === character after the explicit key.
|
|
1325
|
+
atExplicitKey = false
|
|
1326
|
+
allowCompact = true
|
|
1327
|
+
} else {
|
|
1328
|
+
throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line')
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
state.position += 1
|
|
1332
|
+
ch = following
|
|
1333
|
+
|
|
1334
|
+
//
|
|
1335
|
+
// Implicit notation case. Flow-style node as the key first, then ":", and the value.
|
|
1336
|
+
//
|
|
1337
|
+
} else {
|
|
1338
|
+
_keyLine = state.line
|
|
1339
|
+
_keyLineStart = state.lineStart
|
|
1340
|
+
_keyPos = state.position
|
|
1341
|
+
|
|
1342
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1343
|
+
// Neither implicit nor explicit notation.
|
|
1344
|
+
// Reading is done. Go to the epilogue.
|
|
1345
|
+
break
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
if (state.line === _line) {
|
|
1349
|
+
ch = state.input.charCodeAt(state.position)
|
|
1350
|
+
|
|
1351
|
+
while (isWhiteSpace(ch)) {
|
|
1352
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
if (ch === 0x3A/* : */) {
|
|
1356
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1357
|
+
|
|
1358
|
+
if (!isWsOrEol(ch)) {
|
|
1359
|
+
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping')
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
if (atExplicitKey) {
|
|
1363
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos)
|
|
1364
|
+
keyTag = keyNode = valueNode = null
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
detected = true
|
|
1368
|
+
atExplicitKey = false
|
|
1369
|
+
allowCompact = false
|
|
1370
|
+
keyTag = state.tag
|
|
1371
|
+
keyNode = state.result
|
|
1372
|
+
} else if (detected) {
|
|
1373
|
+
throwError(state, 'can not read an implicit mapping pair; a colon is missed')
|
|
1374
|
+
} else {
|
|
1375
|
+
state.tag = _tag
|
|
1376
|
+
state.anchor = _anchor
|
|
1377
|
+
return true // Keep the result of `composeNode`.
|
|
1378
|
+
}
|
|
1379
|
+
} else if (detected) {
|
|
1380
|
+
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key')
|
|
1381
|
+
} else {
|
|
1382
|
+
state.tag = _tag
|
|
1383
|
+
state.anchor = _anchor
|
|
1384
|
+
return true // Keep the result of `composeNode`.
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
//
|
|
1389
|
+
// Common reading code for both explicit and implicit notations.
|
|
1390
|
+
//
|
|
1391
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1392
|
+
if (atExplicitKey) {
|
|
1393
|
+
_keyLine = state.line
|
|
1394
|
+
_keyLineStart = state.lineStart
|
|
1395
|
+
_keyPos = state.position
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1399
|
+
if (atExplicitKey) {
|
|
1400
|
+
keyNode = state.result
|
|
1401
|
+
} else {
|
|
1402
|
+
valueNode = state.result
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
if (!atExplicitKey) {
|
|
1407
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos)
|
|
1408
|
+
keyTag = keyNode = valueNode = null
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
skipSeparationSpace(state, true, -1)
|
|
1412
|
+
ch = state.input.charCodeAt(state.position)
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
|
|
1416
|
+
throwError(state, 'bad indentation of a mapping entry')
|
|
1417
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1418
|
+
break
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
//
|
|
1423
|
+
// Epilogue.
|
|
1424
|
+
//
|
|
1425
|
+
|
|
1426
|
+
// Special case: last mapping's node contains only the key in explicit notation.
|
|
1427
|
+
if (atExplicitKey) {
|
|
1428
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos)
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// Expose the resulting mapping.
|
|
1432
|
+
if (detected) {
|
|
1433
|
+
state.tag = _tag
|
|
1434
|
+
state.anchor = _anchor
|
|
1435
|
+
state.kind = 'mapping'
|
|
1436
|
+
state.result = _result
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
return detected
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
function readTagProperty (state) {
|
|
1443
|
+
let isVerbatim = false
|
|
1444
|
+
let isNamed = false
|
|
1445
|
+
let tagHandle
|
|
1446
|
+
let tagName
|
|
1447
|
+
|
|
1448
|
+
let ch = state.input.charCodeAt(state.position)
|
|
1449
|
+
|
|
1450
|
+
if (ch !== 0x21/* ! */) return false
|
|
1451
|
+
|
|
1452
|
+
if (state.tag !== null) {
|
|
1453
|
+
throwError(state, 'duplication of a tag property')
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1457
|
+
|
|
1458
|
+
if (ch === 0x3C/* < */) {
|
|
1459
|
+
isVerbatim = true
|
|
1460
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1461
|
+
} else if (ch === 0x21/* ! */) {
|
|
1462
|
+
isNamed = true
|
|
1463
|
+
tagHandle = '!!'
|
|
1464
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1465
|
+
} else {
|
|
1466
|
+
tagHandle = '!'
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
let _position = state.position
|
|
1470
|
+
|
|
1471
|
+
if (isVerbatim) {
|
|
1472
|
+
do { ch = state.input.charCodeAt(++state.position) }
|
|
1473
|
+
while (ch !== 0 && ch !== 0x3E/* > */)
|
|
1474
|
+
|
|
1475
|
+
if (state.position < state.length) {
|
|
1476
|
+
tagName = state.input.slice(_position, state.position)
|
|
1477
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1478
|
+
} else {
|
|
1479
|
+
throwError(state, 'unexpected end of the stream within a verbatim tag')
|
|
1480
|
+
}
|
|
1481
|
+
} else {
|
|
1482
|
+
while (ch !== 0 && !isWsOrEol(ch)) {
|
|
1483
|
+
if (ch === 0x21/* ! */) {
|
|
1484
|
+
if (!isNamed) {
|
|
1485
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1)
|
|
1486
|
+
|
|
1487
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1488
|
+
throwError(state, 'named tag handle cannot contain such characters')
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
isNamed = true
|
|
1492
|
+
_position = state.position + 1
|
|
1493
|
+
} else {
|
|
1494
|
+
throwError(state, 'tag suffix cannot contain exclamation marks')
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
tagName = state.input.slice(_position, state.position)
|
|
1502
|
+
|
|
1503
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1504
|
+
throwError(state, 'tag suffix cannot contain flow indicator characters')
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1509
|
+
throwError(state, 'tag name cannot contain such characters: ' + tagName)
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
try {
|
|
1513
|
+
tagName = decodeURIComponent(tagName)
|
|
1514
|
+
} catch (err) {
|
|
1515
|
+
throwError(state, 'tag name is malformed: ' + tagName)
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
if (isVerbatim) {
|
|
1519
|
+
state.tag = tagName
|
|
1520
|
+
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
1521
|
+
state.tag = state.tagMap[tagHandle] + tagName
|
|
1522
|
+
} else if (tagHandle === '!') {
|
|
1523
|
+
state.tag = '!' + tagName
|
|
1524
|
+
} else if (tagHandle === '!!') {
|
|
1525
|
+
state.tag = 'tag:yaml.org,2002:' + tagName
|
|
1526
|
+
} else {
|
|
1527
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"')
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
return true
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
function readAnchorProperty (state) {
|
|
1534
|
+
let ch = state.input.charCodeAt(state.position)
|
|
1535
|
+
|
|
1536
|
+
if (ch !== 0x26/* & */) return false
|
|
1537
|
+
|
|
1538
|
+
if (state.anchor !== null) {
|
|
1539
|
+
throwError(state, 'duplication of an anchor property')
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1543
|
+
const _position = state.position
|
|
1544
|
+
|
|
1545
|
+
while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
|
|
1546
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
if (state.position === _position) {
|
|
1550
|
+
throwError(state, 'name of an anchor node must contain at least one character')
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
state.anchor = state.input.slice(_position, state.position)
|
|
1554
|
+
return true
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
function readAlias (state) {
|
|
1558
|
+
let ch = state.input.charCodeAt(state.position)
|
|
1559
|
+
|
|
1560
|
+
if (ch !== 0x2A/* * */) return false
|
|
1561
|
+
|
|
1562
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1563
|
+
const _position = state.position
|
|
1564
|
+
|
|
1565
|
+
while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
|
|
1566
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
if (state.position === _position) {
|
|
1570
|
+
throwError(state, 'name of an alias node must contain at least one character')
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
const alias = state.input.slice(_position, state.position)
|
|
1574
|
+
|
|
1575
|
+
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
|
1576
|
+
throwError(state, 'unidentified alias "' + alias + '"')
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
state.result = state.anchorMap[alias]
|
|
1580
|
+
skipSeparationSpace(state, true, -1)
|
|
1581
|
+
return true
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function tryReadBlockMappingFromProperty (state, propertyStart, nodeIndent, flowIndent) {
|
|
1585
|
+
const fallbackState = snapshotState(state)
|
|
1586
|
+
|
|
1587
|
+
beginAnchorTransaction(state)
|
|
1588
|
+
restoreState(state, propertyStart)
|
|
1589
|
+
|
|
1590
|
+
// Re-read the leading properties as part of the first implicit key, not as
|
|
1591
|
+
// properties of the current node.
|
|
1592
|
+
state.tag = null
|
|
1593
|
+
state.anchor = null
|
|
1594
|
+
state.kind = null
|
|
1595
|
+
state.result = null
|
|
1596
|
+
|
|
1597
|
+
if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === 'mapping') {
|
|
1598
|
+
commitAnchorTransaction(state)
|
|
1599
|
+
return true
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
rollbackAnchorTransaction(state)
|
|
1603
|
+
restoreState(state, fallbackState)
|
|
1604
|
+
return false
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
function composeNode (state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1608
|
+
let allowBlockScalars
|
|
1609
|
+
let allowBlockCollections
|
|
1610
|
+
let indentStatus = 1 // 1: this>parent, 0: this=parent, -1: this<parent
|
|
1611
|
+
let atNewLine = false
|
|
1612
|
+
let hasContent = false
|
|
1613
|
+
let propertyStart = null
|
|
1614
|
+
let type
|
|
1615
|
+
let flowIndent
|
|
1616
|
+
let blockIndent
|
|
1617
|
+
|
|
1618
|
+
if (state.depth >= state.maxDepth) {
|
|
1619
|
+
throwError(state, 'nesting exceeded maxDepth (' + state.maxDepth + ')')
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
state.depth += 1
|
|
1623
|
+
|
|
1624
|
+
state.tag = null
|
|
1625
|
+
state.anchor = null
|
|
1626
|
+
state.kind = null
|
|
1627
|
+
state.result = null
|
|
1628
|
+
|
|
1629
|
+
const allowBlockStyles = allowBlockScalars = allowBlockCollections =
|
|
1630
|
+
CONTEXT_BLOCK_OUT === nodeContext ||
|
|
1631
|
+
CONTEXT_BLOCK_IN === nodeContext
|
|
1632
|
+
|
|
1633
|
+
if (allowToSeek) {
|
|
1634
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1635
|
+
atNewLine = true
|
|
1636
|
+
|
|
1637
|
+
if (state.lineIndent > parentIndent) {
|
|
1638
|
+
indentStatus = 1
|
|
1639
|
+
} else if (state.lineIndent === parentIndent) {
|
|
1640
|
+
indentStatus = 0
|
|
1641
|
+
} else if (state.lineIndent < parentIndent) {
|
|
1642
|
+
indentStatus = -1
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
if (indentStatus === 1) {
|
|
1648
|
+
while (true) {
|
|
1649
|
+
const ch = state.input.charCodeAt(state.position)
|
|
1650
|
+
const propertyState = snapshotState(state)
|
|
1651
|
+
|
|
1652
|
+
// A duplicate property token after a line break can be the first key of
|
|
1653
|
+
// a nested block mapping, e.g. `!!map\n !!str key: value`.
|
|
1654
|
+
if (atNewLine &&
|
|
1655
|
+
((ch === 0x21/* ! */ && state.tag !== null) ||
|
|
1656
|
+
(ch === 0x26/* & */ && state.anchor !== null))) {
|
|
1657
|
+
break
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
if (!readTagProperty(state) && !readAnchorProperty(state)) {
|
|
1661
|
+
break
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
if (propertyStart === null) {
|
|
1665
|
+
propertyStart = propertyState
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1669
|
+
atNewLine = true
|
|
1670
|
+
allowBlockCollections = allowBlockStyles
|
|
1671
|
+
|
|
1672
|
+
if (state.lineIndent > parentIndent) {
|
|
1673
|
+
indentStatus = 1
|
|
1674
|
+
} else if (state.lineIndent === parentIndent) {
|
|
1675
|
+
indentStatus = 0
|
|
1676
|
+
} else if (state.lineIndent < parentIndent) {
|
|
1677
|
+
indentStatus = -1
|
|
1678
|
+
}
|
|
1679
|
+
} else {
|
|
1680
|
+
allowBlockCollections = false
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
if (allowBlockCollections) {
|
|
1686
|
+
allowBlockCollections = atNewLine || allowCompact
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1690
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
1691
|
+
flowIndent = parentIndent
|
|
1692
|
+
} else {
|
|
1693
|
+
flowIndent = parentIndent + 1
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
blockIndent = state.position - state.lineStart
|
|
1697
|
+
|
|
1698
|
+
if (indentStatus === 1) {
|
|
1699
|
+
if ((allowBlockCollections &&
|
|
1700
|
+
(readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent))) ||
|
|
1701
|
+
readFlowCollection(state, flowIndent)) {
|
|
1702
|
+
hasContent = true
|
|
1703
|
+
} else {
|
|
1704
|
+
const ch = state.input.charCodeAt(state.position)
|
|
1705
|
+
|
|
1706
|
+
if (propertyStart !== null && allowBlockStyles && !allowBlockCollections &&
|
|
1707
|
+
ch !== 0x7C/* | */ && ch !== 0x3E/* > */ &&
|
|
1708
|
+
tryReadBlockMappingFromProperty(
|
|
1709
|
+
state,
|
|
1710
|
+
propertyStart,
|
|
1711
|
+
propertyStart.position - propertyStart.lineStart,
|
|
1712
|
+
flowIndent
|
|
1713
|
+
)) {
|
|
1714
|
+
hasContent = true
|
|
1715
|
+
} else if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
|
|
1716
|
+
readSingleQuotedScalar(state, flowIndent) ||
|
|
1717
|
+
readDoubleQuotedScalar(state, flowIndent)) {
|
|
1718
|
+
hasContent = true
|
|
1719
|
+
} else if (readAlias(state)) {
|
|
1720
|
+
hasContent = true
|
|
1721
|
+
|
|
1722
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
1723
|
+
throwError(state, 'alias node should not have any properties')
|
|
1724
|
+
}
|
|
1725
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1726
|
+
hasContent = true
|
|
1727
|
+
|
|
1728
|
+
if (state.tag === null) {
|
|
1729
|
+
state.tag = '?'
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
if (state.anchor !== null) {
|
|
1734
|
+
storeAnchor(state, state.anchor, state.result)
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
} else if (indentStatus === 0) {
|
|
1738
|
+
// Special case: block sequences are allowed to have same indentation level as the parent.
|
|
1739
|
+
// http://www.yaml.org/spec/1.2/spec.html#id2799784
|
|
1740
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent)
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
if (state.tag === null) {
|
|
1745
|
+
if (state.anchor !== null) {
|
|
1746
|
+
storeAnchor(state, state.anchor, state.result)
|
|
1747
|
+
}
|
|
1748
|
+
} else if (state.tag === '?') {
|
|
1749
|
+
// Implicit resolving is not allowed for non-scalar types, and '?'
|
|
1750
|
+
// non-specific tag is only automatically assigned to plain scalars.
|
|
1751
|
+
//
|
|
1752
|
+
// We only need to check kind conformity in case user explicitly assigns '?'
|
|
1753
|
+
// tag, for example like this: "!<?> [0]"
|
|
1754
|
+
//
|
|
1755
|
+
if (state.result !== null && state.kind !== 'scalar') {
|
|
1756
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"')
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1760
|
+
type = state.implicitTypes[typeIndex]
|
|
1761
|
+
|
|
1762
|
+
if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
|
|
1763
|
+
state.result = type.construct(state.result)
|
|
1764
|
+
state.tag = type.tag
|
|
1765
|
+
if (state.anchor !== null) {
|
|
1766
|
+
storeAnchor(state, state.anchor, state.result)
|
|
1767
|
+
}
|
|
1768
|
+
break
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
} else if (state.tag !== '!') {
|
|
1772
|
+
if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
|
|
1773
|
+
type = state.typeMap[state.kind || 'fallback'][state.tag]
|
|
1774
|
+
} else {
|
|
1775
|
+
// looking for multi type
|
|
1776
|
+
type = null
|
|
1777
|
+
const typeList = state.typeMap.multi[state.kind || 'fallback']
|
|
1778
|
+
|
|
1779
|
+
for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1780
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
1781
|
+
type = typeList[typeIndex]
|
|
1782
|
+
break
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
if (!type) {
|
|
1788
|
+
throwError(state, 'unknown tag !<' + state.tag + '>')
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
if (state.result !== null && type.kind !== state.kind) {
|
|
1792
|
+
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"')
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched
|
|
1796
|
+
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag')
|
|
1797
|
+
} else {
|
|
1798
|
+
state.result = type.construct(state.result, state.tag)
|
|
1799
|
+
if (state.anchor !== null) {
|
|
1800
|
+
storeAnchor(state, state.anchor, state.result)
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
state.depth -= 1
|
|
1806
|
+
return state.tag !== null || state.anchor !== null || hasContent
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
function readDocument (state) {
|
|
1810
|
+
const documentStart = state.position
|
|
1811
|
+
let hasDirectives = false
|
|
1812
|
+
let ch
|
|
1813
|
+
|
|
1814
|
+
state.version = null
|
|
1815
|
+
state.checkLineBreaks = state.legacy
|
|
1816
|
+
state.tagMap = Object.create(null)
|
|
1817
|
+
state.anchorMap = Object.create(null)
|
|
1818
|
+
|
|
1819
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1820
|
+
skipSeparationSpace(state, true, -1)
|
|
1821
|
+
|
|
1822
|
+
ch = state.input.charCodeAt(state.position)
|
|
1823
|
+
|
|
1824
|
+
if (state.lineIndent > 0 || ch !== 0x25/* % */) {
|
|
1825
|
+
break
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
hasDirectives = true
|
|
1829
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1830
|
+
let _position = state.position
|
|
1831
|
+
|
|
1832
|
+
while (ch !== 0 && !isWsOrEol(ch)) {
|
|
1833
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
const directiveName = state.input.slice(_position, state.position)
|
|
1837
|
+
const directiveArgs = []
|
|
1838
|
+
|
|
1839
|
+
if (directiveName.length < 1) {
|
|
1840
|
+
throwError(state, 'directive name must not be less than one character in length')
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
while (ch !== 0) {
|
|
1844
|
+
while (isWhiteSpace(ch)) {
|
|
1845
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
if (ch === 0x23/* # */) {
|
|
1849
|
+
do { ch = state.input.charCodeAt(++state.position) }
|
|
1850
|
+
while (ch !== 0 && !isEol(ch))
|
|
1851
|
+
break
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
if (isEol(ch)) break
|
|
1855
|
+
|
|
1856
|
+
_position = state.position
|
|
1857
|
+
|
|
1858
|
+
while (ch !== 0 && !isWsOrEol(ch)) {
|
|
1859
|
+
ch = state.input.charCodeAt(++state.position)
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
directiveArgs.push(state.input.slice(_position, state.position))
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
if (ch !== 0) readLineBreak(state)
|
|
1866
|
+
|
|
1867
|
+
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
1868
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs)
|
|
1869
|
+
} else {
|
|
1870
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"')
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
skipSeparationSpace(state, true, -1)
|
|
1875
|
+
|
|
1876
|
+
if (state.lineIndent === 0 &&
|
|
1877
|
+
state.input.charCodeAt(state.position) === 0x2D/* - */ &&
|
|
1878
|
+
state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
|
|
1879
|
+
state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
|
|
1880
|
+
state.position += 3
|
|
1881
|
+
skipSeparationSpace(state, true, -1)
|
|
1882
|
+
} else if (hasDirectives) {
|
|
1883
|
+
throwError(state, 'directives end mark is expected')
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true)
|
|
1887
|
+
skipSeparationSpace(state, true, -1)
|
|
1888
|
+
|
|
1889
|
+
if (state.checkLineBreaks &&
|
|
1890
|
+
PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
1891
|
+
throwWarning(state, 'non-ASCII line breaks are interpreted as content')
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
state.documents.push(state.result)
|
|
1895
|
+
|
|
1896
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1897
|
+
if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
|
|
1898
|
+
state.position += 3
|
|
1899
|
+
skipSeparationSpace(state, true, -1)
|
|
1900
|
+
}
|
|
1901
|
+
return
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
if (state.position < (state.length - 1)) {
|
|
1905
|
+
throwError(state, 'end of the stream or a document separator is expected')
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
/**
|
|
1911
|
+
* Read one YAML document. `types.implicit` lists the scalar types tried in
|
|
1912
|
+
* order on untagged scalars; `types.explicit` lists those reachable by tag.
|
|
1913
|
+
* Returns `undefined` for an empty stream and throws {@link YAMLException}
|
|
1914
|
+
* on malformed input or more than one document.
|
|
1915
|
+
*/
|
|
1916
|
+
export function load(input, types) {
|
|
1917
|
+
input = String(input);
|
|
1918
|
+
if (input.length !== 0) {
|
|
1919
|
+
if (input.charCodeAt(input.length - 1) !== 0x0a && input.charCodeAt(input.length - 1) !== 0x0d) input += "\n";
|
|
1920
|
+
if (input.charCodeAt(0) === 0xfeff) input = input.slice(1);
|
|
1921
|
+
}
|
|
1922
|
+
var state = new State(input, types);
|
|
1923
|
+
var nullpos = input.indexOf("\0");
|
|
1924
|
+
if (nullpos !== -1) {
|
|
1925
|
+
state.position = nullpos;
|
|
1926
|
+
throwError(state, "null byte is not allowed in input");
|
|
1927
|
+
}
|
|
1928
|
+
// Use 0 as string terminator. That significantly simplifies bounds check.
|
|
1929
|
+
state.input += "\0";
|
|
1930
|
+
while (state.input.charCodeAt(state.position) === 0x20) {
|
|
1931
|
+
state.lineIndent += 1;
|
|
1932
|
+
state.position += 1;
|
|
1933
|
+
}
|
|
1934
|
+
while (state.position < state.length - 1) readDocument(state);
|
|
1935
|
+
const documents = state.documents;
|
|
1936
|
+
if (documents.length === 0) return undefined;
|
|
1937
|
+
if (documents.length === 1) return documents[0];
|
|
1938
|
+
throw new YAMLException("expected a single document in the stream, but found more");
|
|
1939
|
+
}
|