@synergenius/flow-weaver 0.33.2 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -226
- package/NOTICE +13 -0
- package/README.md +152 -245
- package/dist/agent/agent-loop.d.ts +4 -2
- package/dist/agent/cli-session.d.ts +3 -3
- package/dist/agent/cli-session.js +511 -438
- package/dist/agent/cli-spawn-config.d.ts +4 -4
- package/dist/agent/gate.d.ts +164 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +174 -28
- package/dist/agent/mcp-bridge.d.ts +1 -1
- package/dist/agent/mcp-bridge.js +114 -128
- package/dist/agent/mcp-tool-server.d.ts +2 -2
- package/dist/agent/mcp-tool-server.js +147 -189
- package/dist/agent/profiles.d.ts +69 -0
- package/dist/agent/providers/anthropic.d.ts +2 -4
- package/dist/agent/providers/claude-cli.d.ts +4 -5
- package/dist/agent/providers/openai-compat.d.ts +8 -1
- package/dist/agent/streaming.d.ts +2 -2
- package/dist/agent/types.d.ts +16 -10
- package/dist/api/builder.d.ts +3 -3
- package/dist/api/compile.d.ts +9 -4
- package/dist/api/durable-validation.d.ts +15 -0
- package/dist/api/generate-in-place.d.ts +21 -19
- package/dist/api/generate.d.ts +21 -16
- package/dist/api/generated-module/local-node-functions.d.ts +24 -0
- package/dist/api/generated-module/module-format.d.ts +23 -0
- package/dist/api/generated-module/module-writer.d.ts +34 -0
- package/dist/api/generated-module/node-type-imports.d.ts +39 -0
- package/dist/api/generated-module/preamble.d.ts +16 -0
- package/dist/api/generated-module/workflow-functions.d.ts +29 -0
- package/dist/api/graph-identity.d.ts +39 -0
- package/dist/api/helpers.d.ts +4 -60
- package/dist/api/in-place/built-in-nodes.d.ts +18 -0
- package/dist/api/in-place/function-body.d.ts +21 -0
- package/dist/api/in-place/fw-imports.d.ts +30 -0
- package/dist/api/in-place/macro-coverage.d.ts +14 -0
- package/dist/api/in-place/node-type-functions.d.ts +18 -0
- package/dist/api/in-place/node-type-jsdoc.d.ts +20 -0
- package/dist/api/in-place/orphaned-node-types.d.ts +16 -0
- package/dist/api/in-place/runtime-section.d.ts +16 -0
- package/dist/api/in-place/signature.d.ts +47 -0
- package/dist/api/in-place/source-file.d.ts +19 -0
- package/dist/api/in-place/workflow-jsdoc.d.ts +19 -0
- package/dist/api/index.d.ts +18 -21
- package/dist/api/index.js +259 -53
- package/dist/api/inline-engine.generated.d.ts +3 -0
- package/dist/api/inline-runtime.d.ts +10 -2
- package/dist/api/manipulation/connections.d.ts +1 -1
- package/dist/api/manipulation/index.d.ts +8 -8
- package/dist/api/manipulation/node-types.d.ts +1 -1
- package/dist/api/manipulation/nodes.d.ts +3 -13
- package/dist/api/manipulation/ports.d.ts +1 -1
- package/dist/api/manipulation/scopes.d.ts +1 -1
- package/dist/api/manipulation/workflow.d.ts +1 -1
- package/dist/api/modify-operation.d.ts +0 -2
- package/dist/api/parse.d.ts +22 -1
- package/dist/api/port-references.d.ts +66 -0
- package/dist/api/query.d.ts +18 -2
- package/dist/api/templates.d.ts +1 -1
- package/dist/api/transform.d.ts +1 -1
- package/dist/api/validate.d.ts +1 -1
- package/dist/api/validation-registry.d.ts +2 -2
- package/dist/artifacts/brief.d.ts +43 -0
- package/dist/artifacts/index.d.ts +31 -0
- package/dist/artifacts/pdf.d.ts +19 -0
- package/dist/ast/builder.d.ts +3 -3
- package/dist/ast/index.d.ts +4 -4
- package/dist/ast/index.js +60 -5
- package/dist/ast/serialization-node.d.ts +1 -1
- package/dist/ast/serialization.d.ts +1 -1
- package/dist/ast/types.d.ts +82 -291
- package/dist/ast/workflow-utils.d.ts +4 -4
- package/dist/built-in-nodes/coercion-types.d.ts +1 -1
- package/dist/built-in-nodes/delay.d.ts +3 -1
- package/dist/built-in-nodes/generated-registry.d.ts +1 -1
- package/dist/built-in-nodes/index.d.ts +6 -5
- package/dist/built-in-nodes/index.js +79 -5
- package/dist/built-in-nodes/invoke-workflow.d.ts +2 -1
- package/dist/built-in-nodes/mock-types.d.ts +45 -14
- package/dist/built-in-nodes/sleep.d.ts +12 -0
- package/dist/built-in-nodes/wait-for-agent.d.ts +2 -1
- package/dist/built-in-nodes/wait-for-event.d.ts +2 -1
- package/dist/chevrotain-parser/coerce-parser.d.ts +1 -1
- package/dist/chevrotain-parser/connect-parser.d.ts +1 -1
- package/dist/chevrotain-parser/grammar-diagrams.d.ts +1 -1
- package/dist/chevrotain-parser/index.d.ts +20 -23
- package/dist/chevrotain-parser/node-parser.d.ts +7 -8
- package/dist/chevrotain-parser/parse-line.d.ts +54 -0
- package/dist/chevrotain-parser/tokens.d.ts +0 -17
- package/dist/chevrotain-parser/trigger-cancel-parser.d.ts +6 -1
- package/dist/chunks/chunk-4EUSHAY6.js +298 -0
- package/dist/chunks/chunk-4KDUEOFD.js +197 -0
- package/dist/chunks/chunk-5Y3AIUWY.js +911 -0
- package/dist/chunks/chunk-6KMVP6AU.js +20 -0
- package/dist/chunks/chunk-6PNJORFL.js +128 -0
- package/dist/chunks/chunk-7AAQNGRH.js +2001 -0
- package/dist/chunks/chunk-7YYKTPJ5.js +22705 -0
- package/dist/chunks/chunk-A5MBOFVY.js +33 -0
- package/dist/chunks/chunk-AXNQRVJB.js +18 -0
- package/dist/chunks/chunk-B6HQ6YS5.js +572 -0
- package/dist/chunks/chunk-CY3RNVML.js +296 -0
- package/dist/chunks/chunk-CYHYDLV4.js +653 -0
- package/dist/chunks/chunk-CZBCCK4Y.js +82 -0
- package/dist/chunks/chunk-DCMGQP5V.js +505 -0
- package/dist/chunks/chunk-DIAA66GL.js +72 -0
- package/dist/chunks/chunk-DUO6H5PR.js +20 -0
- package/dist/chunks/chunk-E5WN7IGO.js +125 -0
- package/dist/chunks/chunk-EFGFXXQF.js +184 -0
- package/dist/chunks/chunk-F3RTZV2A.js +2811 -0
- package/dist/chunks/chunk-FMTLP5ZX.js +1397 -0
- package/dist/chunks/chunk-HKZLQJDV.js +79 -0
- package/dist/chunks/chunk-INDEVYEC.js +146 -0
- package/dist/chunks/chunk-JQTF4R5L.js +390 -0
- package/dist/chunks/chunk-KMCAYNUM.js +331 -0
- package/dist/chunks/chunk-KMWCCOUJ.js +1444 -0
- package/dist/chunks/chunk-KU3CLJI2.js +338 -0
- package/dist/chunks/chunk-NDSTGMKR.js +3300 -0
- package/dist/chunks/chunk-NQNLUAPO.js +505 -0
- package/dist/chunks/chunk-O2U2LO57.js +466 -0
- package/dist/chunks/chunk-OOQG7UPP.js +457 -0
- package/dist/chunks/chunk-OZQAW5ZG.js +112 -0
- package/dist/chunks/chunk-P2CVDGHR.js +487 -0
- package/dist/chunks/chunk-P44RIZ7C.js +592 -0
- package/dist/chunks/chunk-PEZCT37T.js +1475 -0
- package/dist/chunks/chunk-PKWSAW6O.js +152 -0
- package/dist/chunks/chunk-Q6MDDZMT.js +4373 -0
- package/dist/chunks/chunk-QDE4Z7KW.js +6 -0
- package/dist/chunks/chunk-QJDAVSNY.js +8 -0
- package/dist/chunks/chunk-QYPORSLO.js +7552 -0
- package/dist/chunks/chunk-R4QGNK34.js +183 -0
- package/dist/chunks/chunk-REEYC73I.js +3002 -0
- package/dist/chunks/chunk-SEWDMQ6Q.js +46 -0
- package/dist/chunks/chunk-TAIUWKZB.js +3057 -0
- package/dist/chunks/chunk-TN4YZ3O7.js +196 -0
- package/dist/chunks/chunk-TRMFB43C.js +143 -0
- package/dist/chunks/chunk-VO4QXG2X.js +1016 -0
- package/dist/chunks/chunk-VP2P3BPA.js +1002 -0
- package/dist/chunks/chunk-VQ7H33J4.js +2176 -0
- package/dist/chunks/chunk-VWA7MCV2.js +105 -0
- package/dist/chunks/chunk-XAV22WD7.js +253 -0
- package/dist/chunks/chunk-YSPBPZDV.js +148 -0
- package/dist/chunks/chunk-ZKEGXO73.js +282 -0
- package/dist/chunks/chunk-ZMGN6F3S.js +4256 -0
- package/dist/chunks/grammar-diagrams-AI7VDXOM.js +14 -0
- package/dist/chunks/index.min-ECJD6GZC.js +37 -0
- package/dist/chunks/manifest-EPTR5MYH.js +21 -0
- package/dist/chunks/openapi-document-6TCGVDUW.js +69 -0
- package/dist/chunks/registry-K2U5KUTY.js +23 -0
- package/dist/chunks/serialization-node-UGY6CFH6.js +38 -0
- package/dist/chunks/validate-GEKSZPIN.js +24 -0
- package/dist/chunks/validation-registry-IQZX3UE3.js +7 -0
- package/dist/chunks/validator-VXFHLPDW.js +26 -0
- package/dist/chunks/workflow-executor-KBGFKHNR.js +36 -0
- package/dist/cli/commands/agents.d.ts +16 -0
- package/dist/cli/commands/artifact.d.ts +10 -0
- package/dist/cli/commands/compile.d.ts +0 -30
- package/dist/cli/commands/console.d.ts +32 -0
- package/dist/cli/commands/context.d.ts +0 -3
- package/dist/cli/commands/describe.js +386 -352
- package/dist/cli/commands/dev.d.ts +9 -4
- package/dist/cli/commands/diagram.d.ts +3 -5
- package/dist/cli/commands/doctor.d.ts +27 -4
- package/dist/cli/commands/doctor.js +3307 -633
- package/dist/cli/commands/export.d.ts +6 -4
- package/dist/cli/commands/grammar.d.ts +0 -3
- package/dist/cli/commands/implement.d.ts +1 -1
- package/dist/cli/commands/init/agent-handoff.d.ts +28 -0
- package/dist/cli/commands/init/config.d.ts +3 -0
- package/dist/cli/commands/init/files.d.ts +12 -0
- package/dist/cli/commands/init/naming.d.ts +13 -0
- package/dist/cli/commands/init/output.d.ts +12 -0
- package/dist/cli/commands/init/setup.d.ts +21 -0
- package/dist/cli/commands/init/types.d.ts +53 -0
- package/dist/cli/commands/init-personas.d.ts +9 -1
- package/dist/cli/commands/init.d.ts +24 -88
- package/dist/cli/commands/market.d.ts +1 -1
- package/dist/cli/commands/mcp-setup.d.ts +1 -4
- package/dist/cli/commands/modify.d.ts +0 -5
- package/dist/cli/commands/openapi.d.ts +9 -11
- package/dist/cli/commands/run.d.ts +0 -4
- package/dist/cli/commands/serve.d.ts +24 -26
- package/dist/cli/commands/status.d.ts +1 -1
- package/dist/cli/exports.d.ts +3 -4
- package/dist/cli/exports.js +124 -23
- package/dist/cli/flow-weaver-agents-H653446S.mjs +81 -0
- package/dist/cli/flow-weaver-artifact-WBFYTW76.mjs +58 -0
- package/dist/cli/flow-weaver-chunk-265CEK74.mjs +2 -0
- package/dist/cli/flow-weaver-chunk-2C7PZCV5.mjs +186 -0
- package/dist/cli/flow-weaver-chunk-3BSYCWPL.mjs +3109 -0
- package/dist/cli/flow-weaver-chunk-3MKUQP3D.mjs +547 -0
- package/dist/cli/flow-weaver-chunk-3ZLMPQTH.mjs +27 -0
- package/dist/cli/flow-weaver-chunk-4DVY73ML.mjs +280 -0
- package/dist/cli/flow-weaver-chunk-54M4KNEL.mjs +200 -0
- package/dist/cli/flow-weaver-chunk-55QMUZIA.mjs +256 -0
- package/dist/cli/flow-weaver-chunk-6ZUJ7LMX.mjs +2003 -0
- package/dist/cli/flow-weaver-chunk-7ET6N32V.mjs +419 -0
- package/dist/cli/flow-weaver-chunk-7G63RR4K.mjs +8880 -0
- package/dist/cli/flow-weaver-chunk-A6M5K3W7.mjs +4418 -0
- package/dist/cli/flow-weaver-chunk-AA3NATMX.mjs +154 -0
- package/dist/cli/flow-weaver-chunk-APX6MQ5A.mjs +5652 -0
- package/dist/cli/flow-weaver-chunk-BHCC5FE5.mjs +17 -0
- package/dist/cli/flow-weaver-chunk-DM4BBRRU.mjs +35 -0
- package/dist/cli/flow-weaver-chunk-DRN7KPWY.mjs +168 -0
- package/dist/cli/flow-weaver-chunk-EKWF27G6.mjs +23 -0
- package/dist/cli/flow-weaver-chunk-EM5HWQ4R.mjs +338 -0
- package/dist/cli/flow-weaver-chunk-FPPPU2DG.mjs +226 -0
- package/dist/cli/flow-weaver-chunk-GAQXZHNO.mjs +3005 -0
- package/dist/cli/flow-weaver-chunk-GBUNNP33.mjs +1329 -0
- package/dist/cli/flow-weaver-chunk-HMAKDE55.mjs +636 -0
- package/dist/cli/flow-weaver-chunk-HQ3ZAN44.mjs +367 -0
- package/dist/cli/flow-weaver-chunk-I4APCXYN.mjs +21442 -0
- package/dist/cli/flow-weaver-chunk-IJJ4JXTL.mjs +2297 -0
- package/dist/cli/flow-weaver-chunk-J7EPZW2I.mjs +33 -0
- package/dist/cli/flow-weaver-chunk-KOEMJHLG.mjs +83 -0
- package/dist/cli/flow-weaver-chunk-M6CBWQKJ.mjs +271 -0
- package/dist/cli/flow-weaver-chunk-MHJ4N652.mjs +1580 -0
- package/dist/cli/flow-weaver-chunk-MKAFQWLP.mjs +202 -0
- package/dist/cli/flow-weaver-chunk-MMV2XGD3.mjs +3291 -0
- package/dist/cli/flow-weaver-chunk-MSI2UJES.mjs +125 -0
- package/dist/cli/flow-weaver-chunk-N767YRAI.mjs +48 -0
- package/dist/cli/flow-weaver-chunk-NQKKWDGF.mjs +56 -0
- package/dist/cli/flow-weaver-chunk-NYZDQYFU.mjs +45 -0
- package/dist/cli/flow-weaver-chunk-OMVWSNHJ.mjs +14 -0
- package/dist/cli/flow-weaver-chunk-PUWZ47H5.mjs +2188 -0
- package/dist/cli/flow-weaver-chunk-QOPRVDES.mjs +46 -0
- package/dist/cli/flow-weaver-chunk-RIWE7YTR.mjs +216 -0
- package/dist/cli/flow-weaver-chunk-S63Q3JIU.mjs +789 -0
- package/dist/cli/flow-weaver-chunk-T7X5A23H.mjs +558 -0
- package/dist/cli/flow-weaver-chunk-TLV3VZUN.mjs +2 -0
- package/dist/cli/flow-weaver-chunk-TS5P3PIN.mjs +194 -0
- package/dist/cli/flow-weaver-chunk-U3EO3X4B.mjs +649 -0
- package/dist/cli/flow-weaver-chunk-UNFS3NQP.mjs +34 -0
- package/dist/cli/flow-weaver-chunk-V6DHWFQG.mjs +2811 -0
- package/dist/cli/flow-weaver-chunk-VXWNLYQU.mjs +9 -0
- package/dist/cli/flow-weaver-chunk-W3YNK26P.mjs +149 -0
- package/dist/cli/flow-weaver-chunk-XG2WKXYZ.mjs +324 -0
- package/dist/cli/flow-weaver-chunk-YLSRZWFK.mjs +2219 -0
- package/dist/cli/flow-weaver-chunk-YVPURWS6.mjs +40 -0
- package/dist/cli/flow-weaver-chunk-Z44JK332.mjs +582 -0
- package/dist/cli/flow-weaver-chunk-Z5ZJPNSY.mjs +517 -0
- package/dist/cli/flow-weaver-chunk-ZQALO25T.mjs +594 -0
- package/dist/cli/flow-weaver-compile-A2CABDSB.mjs +37 -0
- package/dist/cli/flow-weaver-console-6EBHDBTN.mjs +71 -0
- package/dist/cli/flow-weaver-context-ECLYANFF.mjs +17 -0
- package/dist/cli/flow-weaver-context-ZRUMW2KE.mjs +69 -0
- package/dist/cli/flow-weaver-create-WIP4EFNP.mjs +124 -0
- package/dist/cli/flow-weaver-deployment-WJJRK7NO.mjs +14 -0
- package/dist/cli/flow-weaver-describe-XDIFF5LI.mjs +41 -0
- package/dist/cli/flow-weaver-dev-LG2NSQAU.mjs +196 -0
- package/dist/cli/flow-weaver-diagram-3EVQARQE.mjs +52 -0
- package/dist/cli/flow-weaver-diagram-7LR7O4M2.mjs +44 -0
- package/dist/cli/flow-weaver-diff-USF7DJLU.mjs +85 -0
- package/dist/cli/flow-weaver-docs-QU2ZOXKH.mjs +96 -0
- package/dist/cli/flow-weaver-doctor-K447YWHR.mjs +43 -0
- package/dist/cli/flow-weaver-export-LAS6N56Y.mjs +140 -0
- package/dist/cli/flow-weaver-grammar-RIRUS3Q6.mjs +49 -0
- package/dist/cli/flow-weaver-grammar-diagrams-WXRTW5SK.mjs +15 -0
- package/dist/cli/flow-weaver-implement-5JG6BCFZ.mjs +114 -0
- package/dist/cli/flow-weaver-index.min-OR5SIHXD.mjs +39 -0
- package/dist/cli/flow-weaver-init-34YZNPQX.mjs +972 -0
- package/dist/cli/flow-weaver-init-personas-NOGZTQQ2.mjs +48 -0
- package/dist/cli/flow-weaver-manifest-4JNUSEB3.mjs +18 -0
- package/dist/cli/flow-weaver-market-WA4CKHKV.mjs +444 -0
- package/dist/cli/flow-weaver-mcp-setup-O26MGXSD.mjs +22 -0
- package/dist/cli/flow-weaver-migrate-VFVEUTPH.mjs +119 -0
- package/dist/cli/flow-weaver-modify-VM3JP5K6.mjs +97 -0
- package/dist/cli/flow-weaver-openapi-IRBWI3HM.mjs +71 -0
- package/dist/cli/flow-weaver-openapi-document-7N6YMPG3.mjs +30 -0
- package/dist/cli/flow-weaver-pack-commands-OS2QRXAK.mjs +146 -0
- package/dist/cli/flow-weaver-registry-5MLFRPPT.mjs +25 -0
- package/dist/cli/flow-weaver-run-DSTLSTHR.mjs +555 -0
- package/dist/cli/flow-weaver-serialization-node-LE6PCG4M.mjs +50 -0
- package/dist/cli/flow-weaver-serve-NVLCLSOW.mjs +192 -0
- package/dist/cli/flow-weaver-server-7IERLVXE.mjs +2925 -0
- package/dist/cli/flow-weaver-server-KWF4PXYC.mjs +19112 -0
- package/dist/cli/flow-weaver-status-75W2S3YB.mjs +138 -0
- package/dist/cli/flow-weaver-strip-AZPXUYVA.mjs +79 -0
- package/dist/cli/flow-weaver-templates-DSNMB6K7.mjs +72 -0
- package/dist/cli/flow-weaver-validate-A4UWDQN6.mjs +19 -0
- package/dist/cli/flow-weaver-validate-GRBZ5W4C.mjs +296 -0
- package/dist/cli/flow-weaver-validation-registry-BINGUNXX.mjs +9 -0
- package/dist/cli/flow-weaver-validator-TY56CI42.mjs +21 -0
- package/dist/cli/flow-weaver-watch-OPPERXL6.mjs +114 -0
- package/dist/cli/flow-weaver-workflow-executor-6AHYPXAN.mjs +26 -0
- package/dist/cli/flow-weaver.mjs +3557 -89384
- package/dist/cli/index.d.ts +5 -2
- package/dist/cli/pack-commands-needed.d.ts +12 -0
- package/dist/cli/program.d.ts +14 -0
- package/dist/cli/templates/ai/mock-provider.d.ts +1 -1
- package/dist/cli/templates/index.d.ts +1 -8
- package/dist/cli/templates/nodes/agent-router.d.ts +1 -1
- package/dist/cli/templates/nodes/aggregator.d.ts +1 -1
- package/dist/cli/templates/nodes/conversation-memory.d.ts +1 -1
- package/dist/cli/templates/nodes/http.d.ts +1 -1
- package/dist/cli/templates/nodes/human-approval.d.ts +1 -1
- package/dist/cli/templates/nodes/json-extractor.d.ts +1 -1
- package/dist/cli/templates/nodes/llm-call.d.ts +1 -1
- package/dist/cli/templates/nodes/prompt-template.d.ts +1 -1
- package/dist/cli/templates/nodes/rag-retriever.d.ts +1 -1
- package/dist/cli/templates/nodes/tool-executor.d.ts +1 -1
- package/dist/cli/templates/nodes/transformer.d.ts +1 -1
- package/dist/cli/templates/nodes/validator.d.ts +1 -1
- package/dist/cli/templates/shared/approval-types.d.ts +1 -1
- package/dist/cli/templates/shared/case.d.ts +14 -0
- package/dist/cli/templates/shared/llm-types.d.ts +4 -4
- package/dist/cli/templates/workflows/aggregator.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-agent.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-chat.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-rag.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-react.d.ts +1 -1
- package/dist/cli/templates/workflows/approval.d.ts +10 -0
- package/dist/cli/templates/workflows/conditional.d.ts +2 -2
- package/dist/cli/templates/workflows/error-handler.d.ts +2 -2
- package/dist/cli/templates/workflows/foreach.d.ts +1 -1
- package/dist/cli/templates/workflows/sequential.d.ts +1 -1
- package/dist/cli/templates/workflows/webhook.d.ts +1 -1
- package/dist/cli/utils/interactive.d.ts +6 -0
- package/dist/cli/utils/json-option.d.ts +8 -0
- package/dist/cli/utils/logger.d.ts +2 -0
- package/dist/compiler/durable-source-proof.d.ts +23 -0
- package/dist/compiler/executable-artifact.d.ts +29 -0
- package/dist/compiler/index.d.ts +4 -0
- package/dist/compiler/index.js +36 -0
- package/dist/console/app.js +106 -0
- package/dist/console/assets/synergenius.svg +18 -0
- package/dist/console/author.d.ts +32 -0
- package/dist/console/cli-catalog.d.ts +21 -0
- package/dist/console/cli-run.d.ts +35 -0
- package/dist/console/cli-run.js +46 -0
- package/dist/console/debug.d.ts +67 -0
- package/dist/console/diff-view.d.ts +96 -0
- package/dist/console/export.d.ts +36 -0
- package/dist/console/git.d.ts +27 -0
- package/dist/console/index.d.ts +4 -0
- package/dist/console/index.html +16 -0
- package/dist/console/index.js +203 -0
- package/dist/console/packs.d.ts +100 -0
- package/dist/console/request-guard.d.ts +10 -0
- package/dist/console/respond.d.ts +16 -0
- package/dist/console/router.d.ts +64 -0
- package/dist/console/routes-agents.d.ts +14 -0
- package/dist/console/routes-project.d.ts +3 -0
- package/dist/console/routes-runs.d.ts +3 -0
- package/dist/console/routes-services.d.ts +7 -0
- package/dist/console/routes-tools.d.ts +3 -0
- package/dist/console/runs.d.ts +69 -0
- package/dist/console/scan.d.ts +49 -0
- package/dist/console/schema.d.ts +74 -0
- package/dist/console/server.d.ts +34 -0
- package/dist/console/server.js +43264 -0
- package/dist/console/services.d.ts +119 -0
- package/dist/console/source.d.ts +23 -0
- package/dist/console/status.d.ts +68 -0
- package/dist/console/styles.css +1023 -0
- package/dist/console/terminals.d.ts +22 -0
- package/dist/console/workflow-view.d.ts +153 -0
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +56 -167
- package/dist/context/index.d.ts +10 -0
- package/dist/context/index.js +14 -191
- package/dist/coordinator/agent-gate.d.ts +107 -0
- package/dist/coordinator/bundle-digest.d.ts +20 -0
- package/dist/coordinator/clock-tick.d.ts +4 -0
- package/dist/coordinator/effect-receipts.d.ts +10 -0
- package/dist/coordinator/errors.d.ts +31 -0
- package/dist/coordinator/file-store.d.ts +3 -0
- package/dist/coordinator/gate-labeling.d.ts +33 -0
- package/dist/coordinator/gate-resolution.d.ts +28 -0
- package/dist/coordinator/index.d.ts +12 -0
- package/dist/coordinator/index.js +107 -0
- package/dist/coordinator/memory-store.d.ts +3 -0
- package/dist/coordinator/params.d.ts +18 -0
- package/dist/coordinator/run-annotations.d.ts +6 -0
- package/dist/coordinator/run-context.d.ts +11 -0
- package/dist/coordinator/run-ending.d.ts +5 -0
- package/dist/coordinator/run-outcome.d.ts +31 -0
- package/dist/coordinator/run-resume.d.ts +6 -0
- package/dist/coordinator/run-start.d.ts +4 -0
- package/dist/coordinator/run-store.d.ts +275 -0
- package/dist/coordinator/run-trace.d.ts +41 -0
- package/dist/coordinator/run-views.d.ts +12 -0
- package/dist/coordinator/runs-dir.d.ts +26 -0
- package/dist/coordinator/store.d.ts +67 -0
- package/dist/coordinator/time.d.ts +39 -0
- package/dist/coordinator/workflow-selection.d.ts +6 -0
- package/dist/deployment/index.d.ts +11 -16
- package/dist/deployment/index.js +541 -50
- package/dist/deployment/targets/base.d.ts +11 -13
- package/dist/deployment/targets/openapi-parts.d.ts +92 -0
- package/dist/diagram/arms.d.ts +70 -0
- package/dist/diagram/ascii-renderer.d.ts +1 -1
- package/dist/diagram/geometry.d.ts +20 -32
- package/dist/diagram/graph/bounds.d.ts +30 -0
- package/dist/diagram/graph/metrics.d.ts +21 -0
- package/dist/diagram/graph/nodes.d.ts +33 -0
- package/dist/diagram/graph/placement.d.ts +22 -0
- package/dist/diagram/graph/ports.d.ts +23 -0
- package/dist/diagram/graph/routing.d.ts +40 -0
- package/dist/diagram/graph/scopes.d.ts +30 -0
- package/dist/diagram/index.d.ts +15 -23
- package/dist/diagram/index.js +632 -111
- package/dist/diagram/labels.d.ts +12 -0
- package/dist/diagram/lanes.d.ts +93 -0
- package/dist/diagram/layout.d.ts +1 -1
- package/dist/diagram/material-symbols.d.ts +7 -0
- package/dist/diagram/orthogonal-router.d.ts +2 -3
- package/dist/diagram/process-view.d.ts +79 -0
- package/dist/diagram/spine.d.ts +25 -0
- package/dist/diagram/theme.d.ts +1 -5
- package/dist/diagram/types.d.ts +6 -20
- package/dist/diff/index.js +53 -9
- package/dist/diff/types.d.ts +1 -5
- package/dist/doc-metadata/extractors/annotations.d.ts +0 -4
- package/dist/doc-metadata/extractors/cli-commands.d.ts +2 -1
- package/dist/doc-metadata/extractors/core-metadata.d.ts +19 -4
- package/dist/doc-metadata/extractors/error-codes.d.ts +1 -1
- package/dist/doc-metadata/extractors/mcp-tools.d.ts +7 -3
- package/dist/doc-metadata/index.d.ts +1 -2
- package/dist/doc-metadata/index.js +2368 -9
- package/dist/doc-metadata/types.d.ts +7 -24
- package/dist/docs/guide.d.ts +33 -0
- package/dist/docs/index.d.ts +7 -4
- package/dist/docs/index.js +298 -298
- package/dist/docs/pack-topics.d.ts +18 -0
- package/dist/editor-completions/annotationValues.d.ts +1 -1
- package/dist/editor-completions/contextParser.d.ts +3 -2
- package/dist/editor-completions/dataTypes.d.ts +1 -1
- package/dist/editor-completions/goToDefinition.d.ts +1 -1
- package/dist/editor-completions/index.d.ts +8 -8
- package/dist/editor-completions/index.js +1244 -175
- package/dist/editor-completions/jsDocAnnotations.d.ts +1 -1
- package/dist/editor-completions/modifierCompletions.d.ts +1 -1
- package/dist/export/index.d.ts +7 -1
- package/dist/generated-branding.js +8 -21
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +7 -3
- package/dist/generator/annotation-generator.d.ts +84 -0
- package/dist/generator/async-detection.d.ts +1 -1
- package/dist/{body-generator.d.ts → generator/body-generator.d.ts} +7 -3
- package/dist/generator/code-utils.d.ts +15 -60
- package/dist/generator/connection-reads.d.ts +94 -0
- package/dist/generator/control-flow-plan.d.ts +74 -0
- package/dist/generator/control-flow.d.ts +1 -1
- package/dist/generator/exit-assembly.d.ts +11 -0
- package/dist/generator/index.d.ts +4 -5
- package/dist/generator/index.js +34 -11
- package/dist/generator/input-port-values.d.ts +22 -0
- package/dist/generator/{scope-function-generator.d.ts → node-arguments.d.ts} +76 -1
- package/dist/generator/node-invocation.d.ts +74 -0
- package/dist/{node-types-generator.d.ts → generator/node-types-generator.d.ts} +3 -2
- package/dist/generator/scope-closure.d.ts +23 -0
- package/dist/generator/scoped-child.d.ts +49 -0
- package/dist/{sugar-optimizer.d.ts → generator/sugar-optimizer.d.ts} +1 -1
- package/dist/generator/unified.d.ts +14 -2
- package/dist/generator/workflow-generator.d.ts +37 -0
- package/dist/index.d.ts +29 -26
- package/dist/index.js +1322 -92
- package/dist/jsdoc-port-sync/apply-diff.d.ts +15 -0
- package/dist/jsdoc-port-sync/callback-signature.d.ts +17 -0
- package/dist/jsdoc-port-sync/diff.d.ts +5 -7
- package/dist/jsdoc-port-sync/incomplete-lines.d.ts +41 -0
- package/dist/jsdoc-port-sync/index.d.ts +11 -11
- package/dist/jsdoc-port-sync/index.js +88 -45
- package/dist/jsdoc-port-sync/jsdoc-to-signature.d.ts +66 -0
- package/dist/jsdoc-port-sync/port-parser.d.ts +6 -24
- package/dist/jsdoc-port-sync/port-tag-placement.d.ts +55 -0
- package/dist/jsdoc-port-sync/scoped-ports.d.ts +21 -0
- package/dist/jsdoc-port-sync/signature-parser.d.ts +8 -1
- package/dist/jsdoc-port-sync/signature-to-jsdoc.d.ts +77 -0
- package/dist/jsdoc-port-sync/sync.d.ts +4 -1
- package/dist/marketplace/index.d.ts +5 -3
- package/dist/marketplace/index.js +62 -10
- package/dist/marketplace/install.d.ts +24 -0
- package/dist/marketplace/manifest.d.ts +1 -1
- package/dist/marketplace/npmrc.d.ts +24 -0
- package/dist/marketplace/registry.d.ts +46 -11
- package/dist/marketplace/types.d.ts +41 -24
- package/dist/marketplace/validator.d.ts +1 -1
- package/dist/mcp/debug-session.d.ts +2 -4
- package/dist/mcp/dist-imports.d.ts +12 -0
- package/dist/mcp/response-utils.d.ts +11 -9
- package/dist/mcp/server.d.ts +0 -1
- package/dist/mcp/tools-context.d.ts +11 -0
- package/dist/mcp/tools-diagram.d.ts +1 -2
- package/dist/mcp/tools-export.d.ts +2 -2
- package/dist/mcp/tools-marketplace.d.ts +1 -1
- package/dist/mcp/tools-run.d.ts +17 -0
- package/dist/mcp/tools-workflow.d.ts +3 -0
- package/dist/mcp/types.d.ts +4 -14
- package/dist/mcp/workflow-executor.d.ts +57 -19
- package/dist/npm-packages.d.ts +1 -1
- package/dist/npm-packages.js +10 -473
- package/dist/parser/annotation-parser.d.ts +88 -0
- package/dist/parser/annotation-suggestion.d.ts +23 -0
- package/dist/parser/durable-effect-contract.d.ts +10 -0
- package/dist/parser/expression-references.d.ts +101 -0
- package/dist/parser/external-node-types.d.ts +69 -0
- package/dist/{function-like.d.ts → parser/function-like.d.ts} +10 -3
- package/dist/parser/generated-sections.d.ts +25 -0
- package/dist/parser/import-resolution.d.ts +67 -0
- package/dist/parser/import-stub.d.ts +29 -0
- package/dist/parser/jsdoc/config-types.d.ts +209 -0
- package/dist/parser/jsdoc/graph-tags.d.ts +54 -0
- package/dist/parser/jsdoc/node-type-block.d.ts +23 -0
- package/dist/parser/jsdoc/parse-line-once.d.ts +11 -0
- package/dist/parser/jsdoc/port-tags.d.ts +42 -0
- package/dist/parser/jsdoc/runtime-tags.d.ts +65 -0
- package/dist/parser/jsdoc/signature-types.d.ts +52 -0
- package/dist/parser/jsdoc/workflow-block.d.ts +22 -0
- package/dist/parser/jsdoc-parser.d.ts +23 -0
- package/dist/parser/macro-expansion.d.ts +80 -0
- package/dist/parser/module-resolution.d.ts +38 -0
- package/dist/parser/node-inference.d.ts +39 -0
- package/dist/parser/npm-node-types.d.ts +24 -0
- package/dist/parser/pack-handlers.d.ts +12 -0
- package/dist/parser/path-data-resolution.d.ts +75 -0
- package/dist/parser/port-inference.d.ts +15 -0
- package/dist/{resolve-package-types.d.ts → parser/resolve-package-types.d.ts} +4 -0
- package/dist/parser/serialize-deploy-annotations.d.ts +19 -0
- package/dist/parser/tag-registry.d.ts +22 -0
- package/dist/parser/workflow-extraction.d.ts +39 -0
- package/dist/runtime/ExecutionContext.d.ts +87 -99
- package/dist/runtime/continuation-core.d.ts +147 -0
- package/dist/runtime/continuation.d.ts +48 -0
- package/dist/runtime/debug-controller.d.ts +7 -22
- package/dist/runtime/durable-execution.d.ts +176 -0
- package/dist/runtime/events.d.ts +16 -1
- package/dist/runtime/executable-module-contract.d.ts +16 -0
- package/dist/runtime/index.d.ts +13 -10
- package/dist/runtime/index.js +947 -9
- package/dist/runtime/strict-json.d.ts +15 -0
- package/dist/server/access.d.ts +12 -0
- package/dist/server/api.d.ts +126 -0
- package/dist/server/callback-delivery.d.ts +62 -0
- package/dist/server/callback-url.d.ts +44 -0
- package/dist/server/context.d.ts +35 -0
- package/dist/server/http-error.d.ts +10 -0
- package/dist/server/index.d.ts +7 -1
- package/dist/server/index.js +125 -6
- package/dist/server/openapi-document.d.ts +33 -0
- package/dist/server/openapi.d.ts +32 -0
- package/dist/server/respond.d.ts +35 -0
- package/dist/server/route-params.d.ts +17 -0
- package/dist/server/route-plan.d.ts +41 -0
- package/dist/server/routes-catalog.d.ts +5 -0
- package/dist/server/routes-declared.d.ts +12 -0
- package/dist/server/routes-runs.d.ts +8 -0
- package/dist/server/run-driver.d.ts +58 -0
- package/dist/server/run-view.d.ts +26 -0
- package/dist/server/transport.d.ts +35 -0
- package/dist/server/types.d.ts +143 -52
- package/dist/server/webhook-server.d.ts +12 -38
- package/dist/server/workflow-registry.d.ts +7 -4
- package/dist/service-registry.d.ts +49 -0
- package/dist/service-registry.js +123 -0
- package/dist/testing/assertions.d.ts +2 -2
- package/dist/testing/index.d.ts +14 -13
- package/dist/testing/index.js +582 -24
- package/dist/testing/mock-approval.d.ts +3 -5
- package/dist/testing/mock-llm.d.ts +2 -3
- package/dist/testing/recorder.d.ts +5 -6
- package/dist/testing/replayer.d.ts +6 -7
- package/dist/testing/run-store-check.d.ts +3 -0
- package/dist/testing/token-tracker.d.ts +2 -2
- package/dist/{type-mappings.d.ts → types/type-mappings.d.ts} +13 -1
- package/dist/utils/error-utils.d.ts +4 -2
- package/dist/utils/port-ordering.d.ts +2 -2
- package/dist/utils/port-tag-utils.d.ts +1 -1
- package/dist/validation/agent-detection.d.ts +17 -5
- package/dist/validation/agent-rules.d.ts +6 -7
- package/dist/validation/core-rules.d.ts +49 -0
- package/dist/validation/design-rules.d.ts +9 -3
- package/dist/validation/rule-registry.d.ts +3 -3
- package/dist/validation/rules/connections.d.ts +27 -0
- package/dist/validation/rules/context.d.ts +11 -0
- package/dist/validation/rules/cycles.d.ts +17 -0
- package/dist/validation/rules/data-flow.d.ts +19 -0
- package/dist/validation/rules/scope-topology.d.ts +35 -0
- package/dist/validation/rules/type-compatibility.d.ts +30 -0
- package/dist/validation/type-checker.d.ts +39 -0
- package/dist/validation/validator-helpers.d.ts +31 -0
- package/dist/validation/validator.d.ts +30 -0
- package/docs/reference/advanced-annotations.md +277 -60
- package/docs/reference/built-in-nodes.md +164 -94
- package/docs/reference/cancellation.md +44 -0
- package/docs/reference/cli-reference.md +252 -234
- package/docs/reference/compilation.md +36 -109
- package/docs/reference/concepts.md +80 -63
- package/docs/reference/console.md +169 -0
- package/docs/reference/debugging.md +26 -57
- package/docs/reference/deployment.md +217 -143
- package/docs/reference/durable-gates.md +445 -0
- package/docs/reference/error-codes.md +90 -43
- package/docs/reference/export-interface.md +91 -26
- package/docs/reference/iterative-development.md +50 -28
- package/docs/reference/jsdoc-grammar.md +66 -311
- package/docs/reference/library.md +250 -0
- package/docs/reference/marketplace.md +301 -152
- package/docs/reference/mcp-tools.md +102 -0
- package/docs/reference/node-conversion.md +84 -59
- package/docs/reference/orientation.md +68 -0
- package/docs/reference/scaffold.md +5 -4
- package/docs/reference/tutorial.md +106 -166
- package/docs/reference/visual-reference.md +1 -1
- package/package.json +85 -50
- package/dist/agent/agent-loop.js +0 -156
- package/dist/agent/cli-spawn-config.js +0 -65
- package/dist/agent/device-connection.d.ts +0 -79
- package/dist/agent/device-connection.js +0 -184
- package/dist/agent/env-allowlist.js +0 -60
- package/dist/agent/providers/anthropic.js +0 -198
- package/dist/agent/providers/claude-cli.js +0 -161
- package/dist/agent/providers/openai-compat.js +0 -205
- package/dist/agent/providers/platform.d.ts +0 -23
- package/dist/agent/providers/platform.js +0 -132
- package/dist/agent/streaming.js +0 -186
- package/dist/agent/types.js +0 -20
- package/dist/annotation-generator.d.ts +0 -50
- package/dist/annotation-generator.js +0 -743
- package/dist/api/builder.js +0 -345
- package/dist/api/command-runner.js +0 -787
- package/dist/api/compile.js +0 -148
- package/dist/api/extract-types.js +0 -57
- package/dist/api/generate-in-place.js +0 -1477
- package/dist/api/generate.js +0 -514
- package/dist/api/helpers.js +0 -285
- package/dist/api/inline-runtime.js +0 -526
- package/dist/api/manipulation/connections.js +0 -151
- package/dist/api/manipulation/index.js +0 -41
- package/dist/api/manipulation/node-types.js +0 -200
- package/dist/api/manipulation/nodes.js +0 -355
- package/dist/api/manipulation/ports.js +0 -228
- package/dist/api/manipulation/scopes.js +0 -156
- package/dist/api/manipulation/workflow.js +0 -116
- package/dist/api/modify-operation.js +0 -177
- package/dist/api/parse.js +0 -115
- package/dist/api/patterns.d.ts +0 -112
- package/dist/api/patterns.js +0 -303
- package/dist/api/query.js +0 -840
- package/dist/api/templates.js +0 -117
- package/dist/api/transform.js +0 -40
- package/dist/api/validate.js +0 -64
- package/dist/api/validation-registry.js +0 -10
- package/dist/api/workflow-file-operations.js +0 -180
- package/dist/ast/builder.js +0 -395
- package/dist/ast/serialization-node.js +0 -30
- package/dist/ast/serialization.js +0 -134
- package/dist/ast/types.js +0 -2
- package/dist/ast/workflow-utils.js +0 -114
- package/dist/body-generator.js +0 -35
- package/dist/built-in-nodes/coercion-types.js +0 -61
- package/dist/built-in-nodes/delay.js +0 -29
- package/dist/built-in-nodes/generated-registry.js +0 -299
- package/dist/built-in-nodes/invoke-workflow.js +0 -36
- package/dist/built-in-nodes/mock-types.js +0 -42
- package/dist/built-in-nodes/wait-for-agent.js +0 -31
- package/dist/built-in-nodes/wait-for-event.js +0 -25
- package/dist/chevrotain-parser/coerce-parser.js +0 -103
- package/dist/chevrotain-parser/connect-parser.js +0 -136
- package/dist/chevrotain-parser/fan-parser.js +0 -149
- package/dist/chevrotain-parser/grammar-diagrams.js +0 -273
- package/dist/chevrotain-parser/index.js +0 -31
- package/dist/chevrotain-parser/map-parser.js +0 -130
- package/dist/chevrotain-parser/node-parser.js +0 -558
- package/dist/chevrotain-parser/path-parser.js +0 -140
- package/dist/chevrotain-parser/port-parser.js +0 -519
- package/dist/chevrotain-parser/position-parser.d.ts +0 -20
- package/dist/chevrotain-parser/position-parser.js +0 -83
- package/dist/chevrotain-parser/scope-parser.js +0 -104
- package/dist/chevrotain-parser/tokens.js +0 -429
- package/dist/chevrotain-parser/trigger-cancel-parser.js +0 -291
- package/dist/cli/commands/account.d.ts +0 -4
- package/dist/cli/commands/account.js +0 -50
- package/dist/cli/commands/ai-credentials.d.ts +0 -12
- package/dist/cli/commands/ai-credentials.js +0 -95
- package/dist/cli/commands/apikey.d.ts +0 -4
- package/dist/cli/commands/apikey.js +0 -64
- package/dist/cli/commands/auth.d.ts +0 -9
- package/dist/cli/commands/auth.js +0 -255
- package/dist/cli/commands/compile.js +0 -331
- package/dist/cli/commands/connect.d.ts +0 -4
- package/dist/cli/commands/connect.js +0 -163
- package/dist/cli/commands/context.js +0 -51
- package/dist/cli/commands/create.js +0 -139
- package/dist/cli/commands/deploy.d.ts +0 -6
- package/dist/cli/commands/deploy.js +0 -74
- package/dist/cli/commands/dev.js +0 -227
- package/dist/cli/commands/diagram.js +0 -39
- package/dist/cli/commands/diff.js +0 -57
- package/dist/cli/commands/docs.js +0 -74
- package/dist/cli/commands/export.js +0 -153
- package/dist/cli/commands/grammar.js +0 -40
- package/dist/cli/commands/implement.js +0 -91
- package/dist/cli/commands/init-personas.js +0 -541
- package/dist/cli/commands/init.js +0 -797
- package/dist/cli/commands/market.js +0 -440
- package/dist/cli/commands/mcp-setup.js +0 -433
- package/dist/cli/commands/migrate.js +0 -91
- package/dist/cli/commands/modify.js +0 -58
- package/dist/cli/commands/openapi.js +0 -71
- package/dist/cli/commands/org.d.ts +0 -8
- package/dist/cli/commands/org.js +0 -136
- package/dist/cli/commands/pattern.d.ts +0 -34
- package/dist/cli/commands/pattern.js +0 -186
- package/dist/cli/commands/plugin.d.ts +0 -16
- package/dist/cli/commands/plugin.js +0 -176
- package/dist/cli/commands/run.js +0 -742
- package/dist/cli/commands/serve.js +0 -93
- package/dist/cli/commands/status.js +0 -123
- package/dist/cli/commands/strip.js +0 -61
- package/dist/cli/commands/templates.js +0 -58
- package/dist/cli/commands/validate.js +0 -267
- package/dist/cli/commands/watch.js +0 -71
- package/dist/cli/config/credentials.d.ts +0 -15
- package/dist/cli/config/credentials.js +0 -43
- package/dist/cli/config/platform-client.d.ts +0 -123
- package/dist/cli/config/platform-client.js +0 -248
- package/dist/cli/env-setup.js +0 -12
- package/dist/cli/index.js +0 -850
- package/dist/cli/pack-commands.js +0 -122
- package/dist/cli/postinstall.d.ts +0 -16
- package/dist/cli/postinstall.js +0 -119
- package/dist/cli/templates/ai/mock-provider.js +0 -64
- package/dist/cli/templates/ai/types.js +0 -5
- package/dist/cli/templates/approvals/index.d.ts +0 -15
- package/dist/cli/templates/approvals/index.js +0 -241
- package/dist/cli/templates/index.js +0 -123
- package/dist/cli/templates/nodes/agent-router.js +0 -114
- package/dist/cli/templates/nodes/aggregator.js +0 -63
- package/dist/cli/templates/nodes/conversation-memory.js +0 -85
- package/dist/cli/templates/nodes/http.js +0 -80
- package/dist/cli/templates/nodes/human-approval.js +0 -109
- package/dist/cli/templates/nodes/json-extractor.js +0 -119
- package/dist/cli/templates/nodes/llm-call.js +0 -106
- package/dist/cli/templates/nodes/prompt-template.js +0 -52
- package/dist/cli/templates/nodes/rag-retriever.js +0 -128
- package/dist/cli/templates/nodes/tool-executor.js +0 -108
- package/dist/cli/templates/nodes/transformer.js +0 -68
- package/dist/cli/templates/nodes/validator.js +0 -62
- package/dist/cli/templates/pack-loader.js +0 -58
- package/dist/cli/templates/providers/index.js +0 -239
- package/dist/cli/templates/shared/approval-types.js +0 -31
- package/dist/cli/templates/shared/llm-types.js +0 -109
- package/dist/cli/templates/workflows/aggregator.js +0 -101
- package/dist/cli/templates/workflows/ai-agent.js +0 -326
- package/dist/cli/templates/workflows/ai-chat.js +0 -167
- package/dist/cli/templates/workflows/ai-rag.js +0 -184
- package/dist/cli/templates/workflows/ai-react.js +0 -293
- package/dist/cli/templates/workflows/conditional.js +0 -139
- package/dist/cli/templates/workflows/error-handler.js +0 -145
- package/dist/cli/templates/workflows/foreach.js +0 -140
- package/dist/cli/templates/workflows/sequential.js +0 -200
- package/dist/cli/templates/workflows/webhook.js +0 -158
- package/dist/cli/utils/cli-helpers.d.ts +0 -44
- package/dist/cli/utils/cli-helpers.js +0 -99
- package/dist/cli/utils/logger.js +0 -126
- package/dist/cli/utils/parse-int-strict.js +0 -17
- package/dist/cli/utils/safe-write.js +0 -54
- package/dist/deployment/config/defaults.d.ts +0 -29
- package/dist/deployment/config/defaults.js +0 -98
- package/dist/deployment/config/loader.d.ts +0 -24
- package/dist/deployment/config/loader.js +0 -237
- package/dist/deployment/config/types.d.ts +0 -117
- package/dist/deployment/config/types.js +0 -5
- package/dist/deployment/core/adapters.d.ts +0 -66
- package/dist/deployment/core/adapters.js +0 -156
- package/dist/deployment/core/executor.d.ts +0 -62
- package/dist/deployment/core/executor.js +0 -197
- package/dist/deployment/core/formatters.d.ts +0 -42
- package/dist/deployment/core/formatters.js +0 -146
- package/dist/deployment/openapi/generator.d.ts +0 -146
- package/dist/deployment/openapi/generator.js +0 -347
- package/dist/deployment/openapi/schema-converter.d.ts +0 -49
- package/dist/deployment/openapi/schema-converter.js +0 -192
- package/dist/deployment/targets/base.js +0 -855
- package/dist/deployment/types.d.ts +0 -140
- package/dist/deployment/types.js +0 -8
- package/dist/diagram/ascii-renderer.js +0 -528
- package/dist/diagram/geometry.js +0 -1226
- package/dist/diagram/html-viewer.d.ts +0 -21
- package/dist/diagram/html-viewer.js +0 -1745
- package/dist/diagram/layout.js +0 -143
- package/dist/diagram/orthogonal-router.js +0 -458
- package/dist/diagram/renderer.d.ts +0 -3
- package/dist/diagram/renderer.js +0 -280
- package/dist/diagram/theme.js +0 -282
- package/dist/diagram/types.js +0 -2
- package/dist/diff/WorkflowDiffer.js +0 -429
- package/dist/diff/formatDiff.js +0 -239
- package/dist/diff/impact.js +0 -119
- package/dist/diff/types.js +0 -35
- package/dist/doc-metadata/extractors/annotations.js +0 -638
- package/dist/doc-metadata/extractors/cli-commands.js +0 -326
- package/dist/doc-metadata/extractors/core-metadata.js +0 -61
- package/dist/doc-metadata/extractors/error-codes.js +0 -372
- package/dist/doc-metadata/extractors/grammar-rules.js +0 -51
- package/dist/doc-metadata/extractors/mcp-tools.js +0 -705
- package/dist/doc-metadata/extractors/plugin-api.d.ts +0 -19
- package/dist/doc-metadata/extractors/plugin-api.js +0 -279
- package/dist/doc-metadata/types.js +0 -5
- package/dist/editor-completions/annotationValues.js +0 -146
- package/dist/editor-completions/contextParser.js +0 -410
- package/dist/editor-completions/dataTypes.js +0 -95
- package/dist/editor-completions/goToDefinition.js +0 -112
- package/dist/editor-completions/jsDocAnnotations.js +0 -359
- package/dist/editor-completions/modifierCompletions.js +0 -197
- package/dist/editor-completions/types.js +0 -8
- package/dist/export/index.js +0 -212
- package/dist/extensions/index.d.ts +0 -16
- package/dist/extensions/index.js +0 -17
- package/dist/friendly-errors.js +0 -761
- package/dist/function-like.js +0 -84
- package/dist/generator/async-detection.js +0 -56
- package/dist/generator/code-utils.js +0 -551
- package/dist/generator/compile-target-registry.d.ts +0 -20
- package/dist/generator/compile-target-registry.js +0 -20
- package/dist/generator/control-flow.js +0 -358
- package/dist/generator/dev-mode-registry.d.ts +0 -27
- package/dist/generator/dev-mode-registry.js +0 -20
- package/dist/generator/scope-function-generator.js +0 -397
- package/dist/generator/unified.js +0 -1831
- package/dist/generator.d.ts +0 -54
- package/dist/generator.js +0 -101
- package/dist/jsdoc-parser.d.ts +0 -377
- package/dist/jsdoc-parser.js +0 -1189
- package/dist/jsdoc-port-sync/constants.js +0 -103
- package/dist/jsdoc-port-sync/diff.js +0 -319
- package/dist/jsdoc-port-sync/port-parser.js +0 -579
- package/dist/jsdoc-port-sync/rename.js +0 -256
- package/dist/jsdoc-port-sync/signature-parser.js +0 -559
- package/dist/jsdoc-port-sync/sync.js +0 -653
- package/dist/marketplace/manifest.js +0 -194
- package/dist/marketplace/registry.js +0 -198
- package/dist/marketplace/types.js +0 -9
- package/dist/marketplace/validator.js +0 -150
- package/dist/mcp/agent-channel.d.ts +0 -35
- package/dist/mcp/agent-channel.js +0 -61
- package/dist/mcp/auto-registration.d.ts +0 -3
- package/dist/mcp/auto-registration.js +0 -62
- package/dist/mcp/debug-session.js +0 -25
- package/dist/mcp/index.d.ts +0 -11
- package/dist/mcp/index.js +0 -10
- package/dist/mcp/pack-tools.js +0 -59
- package/dist/mcp/prompts.js +0 -68
- package/dist/mcp/response-utils.js +0 -97
- package/dist/mcp/run-registry.d.ts +0 -29
- package/dist/mcp/run-registry.js +0 -24
- package/dist/mcp/server.js +0 -63
- package/dist/mcp/tools-context.js +0 -51
- package/dist/mcp/tools-debug.js +0 -451
- package/dist/mcp/tools-diagram.js +0 -97
- package/dist/mcp/tools-docs.js +0 -62
- package/dist/mcp/tools-export.js +0 -222
- package/dist/mcp/tools-marketplace.js +0 -132
- package/dist/mcp/tools-model.d.ts +0 -3
- package/dist/mcp/tools-model.js +0 -279
- package/dist/mcp/tools-pattern.d.ts +0 -3
- package/dist/mcp/tools-pattern.js +0 -604
- package/dist/mcp/tools-query.js +0 -377
- package/dist/mcp/tools-resources.js +0 -41
- package/dist/mcp/tools-template.js +0 -119
- package/dist/mcp/tools-workflow-run.d.ts +0 -40
- package/dist/mcp/tools-workflow-run.js +0 -150
- package/dist/mcp/types.js +0 -2
- package/dist/mcp/workflow-executor.js +0 -242
- package/dist/migration/registry.js +0 -29
- package/dist/node-types-generator.js +0 -139
- package/dist/parser/tag-registry.js +0 -57
- package/dist/parser.d.ts +0 -232
- package/dist/parser.js +0 -2500
- package/dist/plugin/PluginPanel.d.ts +0 -12
- package/dist/plugin/PluginPanel.js +0 -5
- package/dist/plugin/index.d.ts +0 -13
- package/dist/plugin/index.js +0 -14
- package/dist/plugin/types.d.ts +0 -75
- package/dist/plugin/types.js +0 -8
- package/dist/resolve-package-types.js +0 -123
- package/dist/runtime/CancellationError.js +0 -20
- package/dist/runtime/ExecutionContext.js +0 -280
- package/dist/runtime/builtin-functions.js +0 -549
- package/dist/runtime/checkpoint.d.ts +0 -84
- package/dist/runtime/checkpoint.js +0 -225
- package/dist/runtime/debug-controller.js +0 -247
- package/dist/runtime/events.js +0 -2
- package/dist/runtime/function-registry.js +0 -66
- package/dist/runtime/parameter-resolver.js +0 -113
- package/dist/server/types.js +0 -5
- package/dist/server/webhook-server.js +0 -269
- package/dist/server/workflow-registry.js +0 -202
- package/dist/shared-project.js +0 -28
- package/dist/sugar-optimizer.js +0 -498
- package/dist/testing/assertions.js +0 -127
- package/dist/testing/mock-approval.js +0 -98
- package/dist/testing/mock-llm.js +0 -119
- package/dist/testing/recorder.js +0 -70
- package/dist/testing/replayer.js +0 -143
- package/dist/testing/token-tracker.js +0 -94
- package/dist/type-checker.d.ts +0 -42
- package/dist/type-checker.js +0 -190
- package/dist/type-mappings.js +0 -131
- package/dist/types/branded-ports.d.ts +0 -151
- package/dist/types/branded-ports.js +0 -121
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -5
- package/dist/types.d.ts +0 -139
- package/dist/types.js +0 -15
- package/dist/utils/error-utils.js +0 -27
- package/dist/utils/lru-cache.js +0 -40
- package/dist/utils/port-ordering.js +0 -81
- package/dist/utils/port-tag-utils.js +0 -41
- package/dist/utils/string-distance.js +0 -56
- package/dist/validation/agent-detection.js +0 -115
- package/dist/validation/agent-rules.js +0 -262
- package/dist/validation/design-rules.js +0 -377
- package/dist/validation/rule-registry.js +0 -37
- package/dist/validator.d.ts +0 -113
- package/dist/validator.js +0 -1631
- package/docs/reference/patterns.md +0 -159
- package/scripts/postinstall.cjs +0 -86
- /package/dist/{shared-project.d.ts → parser/shared-project.d.ts} +0 -0
- /package/dist/{friendly-errors.d.ts → validation/friendly-errors.d.ts} +0 -0
|
@@ -0,0 +1,3109 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
5
|
+
var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
|
|
6
|
+
function defineScalarTag(tagName, options) {
|
|
7
|
+
return {
|
|
8
|
+
tagName,
|
|
9
|
+
nodeKind: "scalar",
|
|
10
|
+
implicit: options.implicit ?? false,
|
|
11
|
+
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
12
|
+
implicitFirstChars: options.implicitFirstChars ?? null,
|
|
13
|
+
resolve: options.resolve,
|
|
14
|
+
identify: options.identify,
|
|
15
|
+
represent: options.represent ?? ((data) => String(data)),
|
|
16
|
+
representTagName: options.representTagName ?? (() => tagName)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function defineSequenceTag(tagName, options) {
|
|
20
|
+
const carrierIsResult = options.finalize === void 0;
|
|
21
|
+
return {
|
|
22
|
+
tagName,
|
|
23
|
+
nodeKind: "sequence",
|
|
24
|
+
implicit: false,
|
|
25
|
+
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
26
|
+
create: options.create,
|
|
27
|
+
addItem: options.addItem,
|
|
28
|
+
finalize: options.finalize ?? ((carrier) => carrier),
|
|
29
|
+
carrierIsResult,
|
|
30
|
+
identify: options.identify,
|
|
31
|
+
represent: options.represent ?? ((data) => data),
|
|
32
|
+
representTagName: options.representTagName ?? (() => tagName)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function defineMappingTag(tagName, options) {
|
|
36
|
+
const carrierIsResult = options.finalize === void 0;
|
|
37
|
+
return {
|
|
38
|
+
tagName,
|
|
39
|
+
nodeKind: "mapping",
|
|
40
|
+
implicit: false,
|
|
41
|
+
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
42
|
+
create: options.create,
|
|
43
|
+
addPair: options.addPair,
|
|
44
|
+
has: options.has,
|
|
45
|
+
keys: options.keys,
|
|
46
|
+
get: options.get,
|
|
47
|
+
finalize: options.finalize ?? ((carrier) => carrier),
|
|
48
|
+
carrierIsResult,
|
|
49
|
+
identify: options.identify,
|
|
50
|
+
represent: options.represent ?? ((data) => data),
|
|
51
|
+
representTagName: options.representTagName ?? (() => tagName)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var strTag = defineScalarTag("tag:yaml.org,2002:str", {
|
|
55
|
+
resolve: (source) => source,
|
|
56
|
+
identify: (data) => typeof data === "string"
|
|
57
|
+
});
|
|
58
|
+
var NULL_VALUES$1 = [
|
|
59
|
+
"",
|
|
60
|
+
"~",
|
|
61
|
+
"null",
|
|
62
|
+
"Null",
|
|
63
|
+
"NULL"
|
|
64
|
+
];
|
|
65
|
+
var nullCoreTag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
66
|
+
implicit: true,
|
|
67
|
+
implicitFirstChars: [
|
|
68
|
+
"",
|
|
69
|
+
"~",
|
|
70
|
+
"n",
|
|
71
|
+
"N"
|
|
72
|
+
],
|
|
73
|
+
resolve: (source) => {
|
|
74
|
+
if (NULL_VALUES$1.indexOf(source) !== -1) return null;
|
|
75
|
+
return NOT_RESOLVED;
|
|
76
|
+
},
|
|
77
|
+
identify: (object) => object === null,
|
|
78
|
+
represent: () => "null"
|
|
79
|
+
});
|
|
80
|
+
var nullJsonTag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
81
|
+
implicit: true,
|
|
82
|
+
implicitFirstChars: ["n"],
|
|
83
|
+
resolve: (source, isExplicit) => {
|
|
84
|
+
if (source === "null" || isExplicit && source === "") return null;
|
|
85
|
+
return NOT_RESOLVED;
|
|
86
|
+
},
|
|
87
|
+
identify: (object) => object === null,
|
|
88
|
+
represent: () => "null"
|
|
89
|
+
});
|
|
90
|
+
var NULL_VALUES = [
|
|
91
|
+
"",
|
|
92
|
+
"~",
|
|
93
|
+
"null",
|
|
94
|
+
"Null",
|
|
95
|
+
"NULL"
|
|
96
|
+
];
|
|
97
|
+
var nullYaml11Tag = defineScalarTag("tag:yaml.org,2002:null", {
|
|
98
|
+
implicit: true,
|
|
99
|
+
implicitFirstChars: [
|
|
100
|
+
"",
|
|
101
|
+
"~",
|
|
102
|
+
"n",
|
|
103
|
+
"N"
|
|
104
|
+
],
|
|
105
|
+
resolve: (source) => {
|
|
106
|
+
if (NULL_VALUES.indexOf(source) !== -1) return null;
|
|
107
|
+
return NOT_RESOLVED;
|
|
108
|
+
},
|
|
109
|
+
identify: (object) => object === null,
|
|
110
|
+
represent: () => "null"
|
|
111
|
+
});
|
|
112
|
+
var TRUE_VALUES$2 = [
|
|
113
|
+
"true",
|
|
114
|
+
"True",
|
|
115
|
+
"TRUE"
|
|
116
|
+
];
|
|
117
|
+
var FALSE_VALUES$2 = [
|
|
118
|
+
"false",
|
|
119
|
+
"False",
|
|
120
|
+
"FALSE"
|
|
121
|
+
];
|
|
122
|
+
var boolCoreTag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
123
|
+
implicit: true,
|
|
124
|
+
implicitFirstChars: [
|
|
125
|
+
"t",
|
|
126
|
+
"T",
|
|
127
|
+
"f",
|
|
128
|
+
"F"
|
|
129
|
+
],
|
|
130
|
+
resolve: (source) => {
|
|
131
|
+
if (TRUE_VALUES$2.indexOf(source) !== -1) return true;
|
|
132
|
+
if (FALSE_VALUES$2.indexOf(source) !== -1) return false;
|
|
133
|
+
return NOT_RESOLVED;
|
|
134
|
+
},
|
|
135
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
136
|
+
represent: (object) => object ? "true" : "false"
|
|
137
|
+
});
|
|
138
|
+
var TRUE_VALUES$1 = ["true"];
|
|
139
|
+
var FALSE_VALUES$1 = ["false"];
|
|
140
|
+
var boolJsonTag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
141
|
+
implicit: true,
|
|
142
|
+
implicitFirstChars: ["t", "f"],
|
|
143
|
+
resolve: (source) => {
|
|
144
|
+
if (TRUE_VALUES$1.indexOf(source) !== -1) return true;
|
|
145
|
+
if (FALSE_VALUES$1.indexOf(source) !== -1) return false;
|
|
146
|
+
return NOT_RESOLVED;
|
|
147
|
+
},
|
|
148
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
149
|
+
represent: (object) => object ? "true" : "false"
|
|
150
|
+
});
|
|
151
|
+
var TRUE_VALUES = [
|
|
152
|
+
"true",
|
|
153
|
+
"True",
|
|
154
|
+
"TRUE",
|
|
155
|
+
"y",
|
|
156
|
+
"Y",
|
|
157
|
+
"yes",
|
|
158
|
+
"Yes",
|
|
159
|
+
"YES",
|
|
160
|
+
"on",
|
|
161
|
+
"On",
|
|
162
|
+
"ON"
|
|
163
|
+
];
|
|
164
|
+
var FALSE_VALUES = [
|
|
165
|
+
"false",
|
|
166
|
+
"False",
|
|
167
|
+
"FALSE",
|
|
168
|
+
"n",
|
|
169
|
+
"N",
|
|
170
|
+
"no",
|
|
171
|
+
"No",
|
|
172
|
+
"NO",
|
|
173
|
+
"off",
|
|
174
|
+
"Off",
|
|
175
|
+
"OFF"
|
|
176
|
+
];
|
|
177
|
+
var boolYaml11Tag = defineScalarTag("tag:yaml.org,2002:bool", {
|
|
178
|
+
implicit: true,
|
|
179
|
+
implicitFirstChars: [
|
|
180
|
+
"y",
|
|
181
|
+
"Y",
|
|
182
|
+
"n",
|
|
183
|
+
"N",
|
|
184
|
+
"t",
|
|
185
|
+
"T",
|
|
186
|
+
"f",
|
|
187
|
+
"F",
|
|
188
|
+
"o",
|
|
189
|
+
"O"
|
|
190
|
+
],
|
|
191
|
+
resolve: (source) => {
|
|
192
|
+
if (TRUE_VALUES.indexOf(source) !== -1) return true;
|
|
193
|
+
if (FALSE_VALUES.indexOf(source) !== -1) return false;
|
|
194
|
+
return NOT_RESOLVED;
|
|
195
|
+
},
|
|
196
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Boolean]",
|
|
197
|
+
represent: (object) => object ? "true" : "false"
|
|
198
|
+
});
|
|
199
|
+
var YAML_INTEGER_IMPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
200
|
+
var YAML_INTEGER_EXPLICIT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
201
|
+
function parseYamlInteger$2(source) {
|
|
202
|
+
let value = source;
|
|
203
|
+
let sign = 1;
|
|
204
|
+
if (value[0] === "-" || value[0] === "+") {
|
|
205
|
+
if (value[0] === "-") sign = -1;
|
|
206
|
+
value = value.slice(1);
|
|
207
|
+
}
|
|
208
|
+
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
209
|
+
if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
|
|
210
|
+
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
211
|
+
return sign * parseInt(value, 10);
|
|
212
|
+
}
|
|
213
|
+
function resolveYamlInteger$2(source, isExplicit) {
|
|
214
|
+
if (isExplicit) {
|
|
215
|
+
if (!YAML_INTEGER_EXPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
216
|
+
} else if (!YAML_INTEGER_IMPLICIT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
217
|
+
const result = parseYamlInteger$2(source);
|
|
218
|
+
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
219
|
+
}
|
|
220
|
+
var intCoreTag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
221
|
+
implicit: true,
|
|
222
|
+
implicitFirstChars: [
|
|
223
|
+
"-",
|
|
224
|
+
"+",
|
|
225
|
+
..."0123456789"
|
|
226
|
+
],
|
|
227
|
+
resolve: resolveYamlInteger$2,
|
|
228
|
+
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
229
|
+
represent: (object) => object.toString(10)
|
|
230
|
+
});
|
|
231
|
+
var YAML_INTEGER_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)$");
|
|
232
|
+
var YAML_INTEGER_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");
|
|
233
|
+
function parseYamlInteger$1(source) {
|
|
234
|
+
let value = source;
|
|
235
|
+
let sign = 1;
|
|
236
|
+
if (value[0] === "-" || value[0] === "+") {
|
|
237
|
+
if (value[0] === "-") sign = -1;
|
|
238
|
+
value = value.slice(1);
|
|
239
|
+
}
|
|
240
|
+
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
241
|
+
if (value.startsWith("0o")) return sign * parseInt(value.slice(2), 8);
|
|
242
|
+
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
243
|
+
return sign * parseInt(value, 10);
|
|
244
|
+
}
|
|
245
|
+
function resolveYamlInteger$1(source, isExplicit) {
|
|
246
|
+
if (isExplicit) {
|
|
247
|
+
if (!YAML_INTEGER_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
248
|
+
} else if (!YAML_INTEGER_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
249
|
+
const result = parseYamlInteger$1(source);
|
|
250
|
+
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
251
|
+
}
|
|
252
|
+
var intJsonTag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
253
|
+
implicit: true,
|
|
254
|
+
implicitFirstChars: ["-", ..."0123456789"],
|
|
255
|
+
resolve: resolveYamlInteger$1,
|
|
256
|
+
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
257
|
+
represent: (object) => object.toString(10)
|
|
258
|
+
});
|
|
259
|
+
var YAML_INTEGER_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");
|
|
260
|
+
function parseYamlInteger(source) {
|
|
261
|
+
let value = source.replace(/_/g, "");
|
|
262
|
+
let sign = 1;
|
|
263
|
+
if (value[0] === "-" || value[0] === "+") {
|
|
264
|
+
if (value[0] === "-") sign = -1;
|
|
265
|
+
value = value.slice(1);
|
|
266
|
+
}
|
|
267
|
+
if (value.startsWith("0b")) return sign * parseInt(value.slice(2), 2);
|
|
268
|
+
if (value.startsWith("0x")) return sign * parseInt(value.slice(2), 16);
|
|
269
|
+
if (value.includes(":")) {
|
|
270
|
+
let result = 0;
|
|
271
|
+
for (const part of value.split(":")) result = result * 60 + Number(part);
|
|
272
|
+
return sign * result;
|
|
273
|
+
}
|
|
274
|
+
if (value !== "0" && value[0] === "0") return sign * parseInt(value, 8);
|
|
275
|
+
return sign * parseInt(value, 10);
|
|
276
|
+
}
|
|
277
|
+
function resolveYamlInteger(source) {
|
|
278
|
+
if (!YAML_INTEGER_PATTERN.test(source)) return NOT_RESOLVED;
|
|
279
|
+
const result = parseYamlInteger(source);
|
|
280
|
+
return Number.isFinite(result) ? result : NOT_RESOLVED;
|
|
281
|
+
}
|
|
282
|
+
var intYaml11Tag = defineScalarTag("tag:yaml.org,2002:int", {
|
|
283
|
+
implicit: true,
|
|
284
|
+
implicitFirstChars: [
|
|
285
|
+
"-",
|
|
286
|
+
"+",
|
|
287
|
+
..."0123456789"
|
|
288
|
+
],
|
|
289
|
+
resolve: resolveYamlInteger,
|
|
290
|
+
identify: (object) => Number.isInteger(object) && !Object.is(object, -0) && object.toString(10).indexOf("e") < 0,
|
|
291
|
+
represent: (object) => object.toString(10)
|
|
292
|
+
});
|
|
293
|
+
var YAML_FLOAT_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
294
|
+
var YAML_FLOAT_SPECIAL_PATTERN$1 = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
295
|
+
function resolveYamlFloat$2(source) {
|
|
296
|
+
if (!YAML_FLOAT_PATTERN$1.test(source)) return NOT_RESOLVED;
|
|
297
|
+
let value = source.toLowerCase();
|
|
298
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
299
|
+
if ("+-".includes(value[0])) value = value.slice(1);
|
|
300
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
301
|
+
if (value === ".nan") return NaN;
|
|
302
|
+
const result = sign * parseFloat(value);
|
|
303
|
+
if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN$1.test(source)) return result;
|
|
304
|
+
return NOT_RESOLVED;
|
|
305
|
+
}
|
|
306
|
+
function representYamlFloat$2(object) {
|
|
307
|
+
if (isNaN(object)) return ".nan";
|
|
308
|
+
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
309
|
+
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
310
|
+
if (Object.is(object, -0)) return "-0.0";
|
|
311
|
+
const result = object.toString(10);
|
|
312
|
+
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
313
|
+
}
|
|
314
|
+
var floatCoreTag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
315
|
+
implicit: true,
|
|
316
|
+
implicitFirstChars: [
|
|
317
|
+
"-",
|
|
318
|
+
"+",
|
|
319
|
+
".",
|
|
320
|
+
..."0123456789"
|
|
321
|
+
],
|
|
322
|
+
resolve: resolveYamlFloat$2,
|
|
323
|
+
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
324
|
+
represent: representYamlFloat$2
|
|
325
|
+
});
|
|
326
|
+
var YAML_FLOAT_IMPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$");
|
|
327
|
+
var YAML_FLOAT_EXPLICIT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
328
|
+
function resolveYamlFloat$1(source, isExplicit) {
|
|
329
|
+
if (isExplicit) {
|
|
330
|
+
if (!YAML_FLOAT_EXPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
331
|
+
let value = source.toLowerCase();
|
|
332
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
333
|
+
if ("+-".includes(value[0])) value = value.slice(1);
|
|
334
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
335
|
+
if (value === ".nan") return NaN;
|
|
336
|
+
const result2 = sign * parseFloat(value);
|
|
337
|
+
return Number.isFinite(result2) ? result2 : NOT_RESOLVED;
|
|
338
|
+
}
|
|
339
|
+
if (!YAML_FLOAT_IMPLICIT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
340
|
+
const result = Number(source);
|
|
341
|
+
if (Number.isFinite(result)) return result;
|
|
342
|
+
return NOT_RESOLVED;
|
|
343
|
+
}
|
|
344
|
+
function representYamlFloat$1(object) {
|
|
345
|
+
if (isNaN(object)) return ".nan";
|
|
346
|
+
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
347
|
+
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
348
|
+
if (Object.is(object, -0)) return "-0.0";
|
|
349
|
+
const result = object.toString(10);
|
|
350
|
+
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
351
|
+
}
|
|
352
|
+
var floatJsonTag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
353
|
+
implicit: true,
|
|
354
|
+
implicitFirstChars: ["-", ..."0123456789"],
|
|
355
|
+
resolve: resolveYamlFloat$1,
|
|
356
|
+
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
357
|
+
represent: representYamlFloat$1
|
|
358
|
+
});
|
|
359
|
+
var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
360
|
+
var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
361
|
+
function resolveYamlFloat(source) {
|
|
362
|
+
if (!YAML_FLOAT_PATTERN.test(source)) return NOT_RESOLVED;
|
|
363
|
+
let value = source.toLowerCase().replace(/_/g, "");
|
|
364
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
365
|
+
if ("+-".includes(value[0])) value = value.slice(1);
|
|
366
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
367
|
+
if (value === ".nan") return NaN;
|
|
368
|
+
let result = 0;
|
|
369
|
+
if (value.includes(":")) {
|
|
370
|
+
for (const part of value.split(":")) result = result * 60 + Number(part);
|
|
371
|
+
result *= sign;
|
|
372
|
+
} else result = sign * parseFloat(value);
|
|
373
|
+
if (Number.isFinite(result) || YAML_FLOAT_SPECIAL_PATTERN.test(source)) return result;
|
|
374
|
+
return NOT_RESOLVED;
|
|
375
|
+
}
|
|
376
|
+
function representYamlFloat(object) {
|
|
377
|
+
if (isNaN(object)) return ".nan";
|
|
378
|
+
if (object === Number.POSITIVE_INFINITY) return ".inf";
|
|
379
|
+
if (object === Number.NEGATIVE_INFINITY) return "-.inf";
|
|
380
|
+
if (Object.is(object, -0)) return "-0.0";
|
|
381
|
+
const result = object.toString(10);
|
|
382
|
+
return /^[-+]?[0-9]+e/.test(result) ? result.replace("e", ".e") : result;
|
|
383
|
+
}
|
|
384
|
+
var floatYaml11Tag = defineScalarTag("tag:yaml.org,2002:float", {
|
|
385
|
+
implicit: true,
|
|
386
|
+
implicitFirstChars: [
|
|
387
|
+
"-",
|
|
388
|
+
"+",
|
|
389
|
+
".",
|
|
390
|
+
..."0123456789"
|
|
391
|
+
],
|
|
392
|
+
resolve: resolveYamlFloat,
|
|
393
|
+
identify: (object) => typeof object === "number" && (!Number.isInteger(object) || Object.is(object, -0) || object.toString(10).indexOf("e") >= 0),
|
|
394
|
+
represent: representYamlFloat
|
|
395
|
+
});
|
|
396
|
+
var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
|
|
397
|
+
implicit: true,
|
|
398
|
+
implicitFirstChars: ["<"],
|
|
399
|
+
resolve: (source, isExplicit) => {
|
|
400
|
+
if (source === "<<" || isExplicit && source === "") return "<<";
|
|
401
|
+
return NOT_RESOLVED;
|
|
402
|
+
},
|
|
403
|
+
identify: () => false
|
|
404
|
+
});
|
|
405
|
+
var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
406
|
+
function resolveYamlBinary(source) {
|
|
407
|
+
const input = source.replace(/\s/g, "");
|
|
408
|
+
if (input.length % 4 !== 0 || !BASE64_PATTERN.test(input)) return NOT_RESOLVED;
|
|
409
|
+
const binary = atob(input);
|
|
410
|
+
const result = new Uint8Array(binary.length);
|
|
411
|
+
for (let index = 0; index < binary.length; index++) result[index] = binary.charCodeAt(index);
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
function representYamlBinary(object) {
|
|
415
|
+
let binary = "";
|
|
416
|
+
for (let index = 0; index < object.length; index++) binary += String.fromCharCode(object[index]);
|
|
417
|
+
return btoa(binary);
|
|
418
|
+
}
|
|
419
|
+
var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
|
|
420
|
+
resolve: resolveYamlBinary,
|
|
421
|
+
identify: (object) => Object.prototype.toString.call(object) === "[object Uint8Array]",
|
|
422
|
+
represent: representYamlBinary
|
|
423
|
+
});
|
|
424
|
+
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
425
|
+
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
426
|
+
function makeUtcDate(year, month, day, hour = 0, minute = 0, second = 0, fraction = 0) {
|
|
427
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
428
|
+
date.setUTCFullYear(year, month, day);
|
|
429
|
+
return date;
|
|
430
|
+
}
|
|
431
|
+
function resolveYamlTimestamp(source) {
|
|
432
|
+
let match = YAML_DATE_REGEXP.exec(source);
|
|
433
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
|
|
434
|
+
if (match === null) return NOT_RESOLVED;
|
|
435
|
+
const year = +match[1];
|
|
436
|
+
const month = +match[2] - 1;
|
|
437
|
+
const day = +match[3];
|
|
438
|
+
if (!match[4]) {
|
|
439
|
+
const date2 = makeUtcDate(year, month, day);
|
|
440
|
+
if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month || date2.getUTCDate() !== day) return NOT_RESOLVED;
|
|
441
|
+
return date2;
|
|
442
|
+
}
|
|
443
|
+
const hour = +match[4];
|
|
444
|
+
const minute = +match[5];
|
|
445
|
+
const second = +match[6];
|
|
446
|
+
let fraction = 0;
|
|
447
|
+
if (hour > 23 || minute > 59 || second > 59) return NOT_RESOLVED;
|
|
448
|
+
if (match[7]) {
|
|
449
|
+
let value = match[7].slice(0, 3);
|
|
450
|
+
while (value.length < 3) value += "0";
|
|
451
|
+
fraction = +value;
|
|
452
|
+
}
|
|
453
|
+
const date = makeUtcDate(year, month, day, hour, minute, second, fraction);
|
|
454
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
|
|
455
|
+
if (match[9]) {
|
|
456
|
+
const offsetHour = +match[10];
|
|
457
|
+
const offsetMinute = +(match[11] || 0);
|
|
458
|
+
if (offsetHour > 23 || offsetMinute > 59) return NOT_RESOLVED;
|
|
459
|
+
const offset = (offsetHour * 60 + offsetMinute) * 6e4;
|
|
460
|
+
date.setTime(date.getTime() - (match[9] === "-" ? -offset : offset));
|
|
461
|
+
}
|
|
462
|
+
return date;
|
|
463
|
+
}
|
|
464
|
+
var timestampTag = defineScalarTag("tag:yaml.org,2002:timestamp", {
|
|
465
|
+
implicit: true,
|
|
466
|
+
implicitFirstChars: [..."0123456789"],
|
|
467
|
+
resolve: resolveYamlTimestamp,
|
|
468
|
+
identify: (object) => object instanceof Date,
|
|
469
|
+
represent: (object) => object.toISOString()
|
|
470
|
+
});
|
|
471
|
+
var seqTag = defineSequenceTag("tag:yaml.org,2002:seq", {
|
|
472
|
+
create: () => [],
|
|
473
|
+
addItem: (container, item) => {
|
|
474
|
+
container.push(item);
|
|
475
|
+
},
|
|
476
|
+
identify: Array.isArray
|
|
477
|
+
});
|
|
478
|
+
function isPlainObject(data) {
|
|
479
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) return false;
|
|
480
|
+
const prototype = Object.getPrototypeOf(data);
|
|
481
|
+
return prototype === null || prototype === Object.prototype;
|
|
482
|
+
}
|
|
483
|
+
function pick(object, keys) {
|
|
484
|
+
const result = {};
|
|
485
|
+
for (const key of keys) if (object[key] !== void 0) result[key] = object[key];
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
|
|
489
|
+
create: () => ({
|
|
490
|
+
list: [],
|
|
491
|
+
seen: /* @__PURE__ */ new Set()
|
|
492
|
+
}),
|
|
493
|
+
addItem: (carrier, item) => {
|
|
494
|
+
let key;
|
|
495
|
+
if (item instanceof Map) {
|
|
496
|
+
if (item.size !== 1) return "cannot resolve an ordered map item";
|
|
497
|
+
key = item.keys().next().value;
|
|
498
|
+
} else if (isPlainObject(item)) {
|
|
499
|
+
const itemKeys = Object.keys(item);
|
|
500
|
+
if (itemKeys.length !== 1) return "cannot resolve an ordered map item";
|
|
501
|
+
key = itemKeys[0];
|
|
502
|
+
} else return "cannot resolve an ordered map item";
|
|
503
|
+
if (carrier.seen.has(key)) return "duplicate key in ordered map";
|
|
504
|
+
carrier.seen.add(key);
|
|
505
|
+
carrier.list.push(item);
|
|
506
|
+
return "";
|
|
507
|
+
},
|
|
508
|
+
finalize: (carrier) => carrier.list,
|
|
509
|
+
identify: () => false
|
|
510
|
+
});
|
|
511
|
+
var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
512
|
+
create: () => [],
|
|
513
|
+
addItem: (container, item) => {
|
|
514
|
+
if (item instanceof Map) {
|
|
515
|
+
if (item.size !== 1) return "cannot resolve a pairs item";
|
|
516
|
+
container.push(item.entries().next().value);
|
|
517
|
+
return "";
|
|
518
|
+
}
|
|
519
|
+
if (Object.prototype.toString.call(item) !== "[object Object]") return "cannot resolve a pairs item";
|
|
520
|
+
const object = item;
|
|
521
|
+
const keys = Object.keys(object);
|
|
522
|
+
if (keys.length !== 1) return "cannot resolve a pairs item";
|
|
523
|
+
container.push([keys[0], object[keys[0]]]);
|
|
524
|
+
return "";
|
|
525
|
+
},
|
|
526
|
+
identify: () => false
|
|
527
|
+
});
|
|
528
|
+
var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
529
|
+
create: () => ({}),
|
|
530
|
+
identify: isPlainObject,
|
|
531
|
+
represent: (o) => {
|
|
532
|
+
const map = /* @__PURE__ */ new Map();
|
|
533
|
+
for (const key of Object.keys(o)) map.set(key, o[key]);
|
|
534
|
+
return map;
|
|
535
|
+
},
|
|
536
|
+
addPair: (container, key, value) => {
|
|
537
|
+
if (key !== null && typeof key === "object") return "object-based map does not support complex keys";
|
|
538
|
+
const normalizedKey = String(key);
|
|
539
|
+
if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
|
|
540
|
+
value,
|
|
541
|
+
enumerable: true,
|
|
542
|
+
configurable: true,
|
|
543
|
+
writable: true
|
|
544
|
+
});
|
|
545
|
+
else container[normalizedKey] = value;
|
|
546
|
+
return "";
|
|
547
|
+
},
|
|
548
|
+
has: (container, key) => {
|
|
549
|
+
if (key !== null && typeof key === "object") return false;
|
|
550
|
+
return Object.prototype.hasOwnProperty.call(container, String(key));
|
|
551
|
+
},
|
|
552
|
+
keys: (container) => Object.keys(container),
|
|
553
|
+
get: (container, key) => {
|
|
554
|
+
const normalizedKey = String(key);
|
|
555
|
+
if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
|
|
556
|
+
return container[normalizedKey];
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
560
|
+
create: () => /* @__PURE__ */ new Set(),
|
|
561
|
+
identify: (data) => data instanceof Set,
|
|
562
|
+
represent: (data) => {
|
|
563
|
+
const map = /* @__PURE__ */ new Map();
|
|
564
|
+
for (const key of data) map.set(key, null);
|
|
565
|
+
return map;
|
|
566
|
+
},
|
|
567
|
+
addPair: (container, key, value) => {
|
|
568
|
+
if (value !== null) return "cannot resolve a set item";
|
|
569
|
+
container.add(key);
|
|
570
|
+
return "";
|
|
571
|
+
},
|
|
572
|
+
has: (container, key) => container.has(key),
|
|
573
|
+
keys: (container) => container.keys(),
|
|
574
|
+
get: () => null
|
|
575
|
+
});
|
|
576
|
+
function createTagDefinitionMap() {
|
|
577
|
+
return {
|
|
578
|
+
scalar: /* @__PURE__ */ Object.create(null),
|
|
579
|
+
sequence: /* @__PURE__ */ Object.create(null),
|
|
580
|
+
mapping: /* @__PURE__ */ Object.create(null)
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
function createTagDefinitionListMap() {
|
|
584
|
+
return {
|
|
585
|
+
scalar: [],
|
|
586
|
+
sequence: [],
|
|
587
|
+
mapping: []
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function compileTags(tags) {
|
|
591
|
+
const result = [];
|
|
592
|
+
for (const tag of tags) {
|
|
593
|
+
let index = result.length;
|
|
594
|
+
for (let previousIndex = 0; previousIndex < result.length; previousIndex++) {
|
|
595
|
+
const previous = result[previousIndex];
|
|
596
|
+
if (previous.nodeKind === tag.nodeKind && previous.tagName === tag.tagName && previous.matchByTagPrefix === tag.matchByTagPrefix) {
|
|
597
|
+
index = previousIndex;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
result[index] = tag;
|
|
602
|
+
}
|
|
603
|
+
return result;
|
|
604
|
+
}
|
|
605
|
+
var Schema = class Schema2 {
|
|
606
|
+
tags;
|
|
607
|
+
/** @internal */
|
|
608
|
+
implicitScalarTags;
|
|
609
|
+
/**
|
|
610
|
+
* Dispatch implicit scalar resolvers by `source.charAt(0)`. Each bucket holds
|
|
611
|
+
* the resolvers that may match that key, in schema order; a key absent from
|
|
612
|
+
* the map uses
|
|
613
|
+
* {@link Schema.implicitScalarAnyFirstChar}
|
|
614
|
+
* (resolvers that declared no first-char constraint, so they apply to any
|
|
615
|
+
* first character).
|
|
616
|
+
*/
|
|
617
|
+
implicitScalarByFirstChar;
|
|
618
|
+
implicitScalarAnyFirstChar;
|
|
619
|
+
/**
|
|
620
|
+
* The default scalar tag (`!!str`), resolved once so the composer's fallback
|
|
621
|
+
* for unresolved plain scalars avoids a keyed lookup per scalar.
|
|
622
|
+
*
|
|
623
|
+
* @internal
|
|
624
|
+
*/
|
|
625
|
+
defaultScalarTag;
|
|
626
|
+
/**
|
|
627
|
+
* The default container tags (`!!seq` / `!!map`), used by the dumper: when a
|
|
628
|
+
* value is identified by its default tag, the tag is implicit and not
|
|
629
|
+
* printed. Undefined if the schema does not define them (then such values
|
|
630
|
+
* can't be dumped).
|
|
631
|
+
*
|
|
632
|
+
* @internal
|
|
633
|
+
*/
|
|
634
|
+
defaultSequenceTag;
|
|
635
|
+
/** @internal */
|
|
636
|
+
defaultMappingTag;
|
|
637
|
+
exact;
|
|
638
|
+
prefix;
|
|
639
|
+
constructor(tags) {
|
|
640
|
+
const compiledTags = compileTags(tags);
|
|
641
|
+
const implicitScalarTags = [];
|
|
642
|
+
const exact = createTagDefinitionMap();
|
|
643
|
+
const prefix = createTagDefinitionListMap();
|
|
644
|
+
for (const tag of compiledTags) {
|
|
645
|
+
if (tag.nodeKind === "scalar" && tag.implicit) {
|
|
646
|
+
if (tag.matchByTagPrefix) throw new Error("Implicit scalar tags cannot match by tag prefix");
|
|
647
|
+
implicitScalarTags.push(tag);
|
|
648
|
+
}
|
|
649
|
+
switch (tag.nodeKind) {
|
|
650
|
+
case "scalar":
|
|
651
|
+
if (tag.matchByTagPrefix) prefix.scalar.push(tag);
|
|
652
|
+
else exact.scalar[tag.tagName] = tag;
|
|
653
|
+
break;
|
|
654
|
+
case "sequence":
|
|
655
|
+
if (tag.matchByTagPrefix) prefix.sequence.push(tag);
|
|
656
|
+
else exact.sequence[tag.tagName] = tag;
|
|
657
|
+
break;
|
|
658
|
+
case "mapping":
|
|
659
|
+
if (tag.matchByTagPrefix) prefix.mapping.push(tag);
|
|
660
|
+
else exact.mapping[tag.tagName] = tag;
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
const implicitScalarAnyFirstChar = implicitScalarTags.filter((tag) => tag.implicitFirstChars === null);
|
|
665
|
+
const keys = /* @__PURE__ */ new Set();
|
|
666
|
+
for (const tag of implicitScalarTags) if (tag.implicitFirstChars !== null) for (const key of tag.implicitFirstChars) keys.add(key);
|
|
667
|
+
const implicitScalarByFirstChar = /* @__PURE__ */ new Map();
|
|
668
|
+
for (const key of keys) implicitScalarByFirstChar.set(key, implicitScalarTags.filter((tag) => tag.implicitFirstChars === null || tag.implicitFirstChars.indexOf(key) !== -1));
|
|
669
|
+
const defaultScalarTag = exact.scalar["tag:yaml.org,2002:str"];
|
|
670
|
+
if (!defaultScalarTag) throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");
|
|
671
|
+
this.tags = compiledTags;
|
|
672
|
+
this.implicitScalarTags = implicitScalarTags;
|
|
673
|
+
this.implicitScalarByFirstChar = implicitScalarByFirstChar;
|
|
674
|
+
this.implicitScalarAnyFirstChar = implicitScalarAnyFirstChar;
|
|
675
|
+
this.defaultScalarTag = defaultScalarTag;
|
|
676
|
+
this.defaultSequenceTag = exact.sequence["tag:yaml.org,2002:seq"];
|
|
677
|
+
this.defaultMappingTag = exact.mapping["tag:yaml.org,2002:map"];
|
|
678
|
+
this.exact = exact;
|
|
679
|
+
this.prefix = prefix;
|
|
680
|
+
}
|
|
681
|
+
/** @internal */
|
|
682
|
+
lookupScalarTag(tagName) {
|
|
683
|
+
const exactTag = this.exact.scalar[tagName];
|
|
684
|
+
if (exactTag) return exactTag;
|
|
685
|
+
for (const tag of this.prefix.scalar) if (tagName.startsWith(tag.tagName)) return tag;
|
|
686
|
+
}
|
|
687
|
+
/** @internal */
|
|
688
|
+
lookupSequenceTag(tagName) {
|
|
689
|
+
const exactTag = this.exact.sequence[tagName];
|
|
690
|
+
if (exactTag) return exactTag;
|
|
691
|
+
for (const tag of this.prefix.sequence) if (tagName.startsWith(tag.tagName)) return tag;
|
|
692
|
+
}
|
|
693
|
+
/** @internal */
|
|
694
|
+
lookupMappingTag(tagName) {
|
|
695
|
+
const exactTag = this.exact.mapping[tagName];
|
|
696
|
+
if (exactTag) return exactTag;
|
|
697
|
+
for (const tag of this.prefix.mapping) if (tagName.startsWith(tag.tagName)) return tag;
|
|
698
|
+
}
|
|
699
|
+
/** @internal */
|
|
700
|
+
resolveImplicitScalarTag(source) {
|
|
701
|
+
const candidates = this.implicitScalarByFirstChar.get(source.charAt(0)) ?? this.implicitScalarAnyFirstChar;
|
|
702
|
+
for (const tag2 of candidates) {
|
|
703
|
+
const value = tag2.resolve(source, false, tag2.tagName);
|
|
704
|
+
if (value !== NOT_RESOLVED) return {
|
|
705
|
+
value,
|
|
706
|
+
tag: tag2
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
const tag = this.defaultScalarTag;
|
|
710
|
+
return {
|
|
711
|
+
value: tag.resolve(source, false, tag.tagName),
|
|
712
|
+
tag
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Creates a new schema with the specified tags added. If a tag already
|
|
717
|
+
* exists, it is replaced by the specified tag.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
*
|
|
721
|
+
* ```javascript
|
|
722
|
+
* import { CORE_SCHEMA, mergeTag, realMapTag } from 'js-yaml'
|
|
723
|
+
*
|
|
724
|
+
* const schema = CORE_SCHEMA.withTags(mergeTag, realMapTag)
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
withTags(...tags) {
|
|
728
|
+
let flatTags = [];
|
|
729
|
+
for (const tag of tags) flatTags = flatTags.concat(tag);
|
|
730
|
+
return new Schema2([...this.tags, ...flatTags]);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
var FAILSAFE_SCHEMA = new Schema([
|
|
734
|
+
strTag,
|
|
735
|
+
seqTag,
|
|
736
|
+
mapTag
|
|
737
|
+
]);
|
|
738
|
+
var JSON_SCHEMA = new Schema([
|
|
739
|
+
...FAILSAFE_SCHEMA.tags,
|
|
740
|
+
nullJsonTag,
|
|
741
|
+
boolJsonTag,
|
|
742
|
+
intJsonTag,
|
|
743
|
+
floatJsonTag
|
|
744
|
+
]);
|
|
745
|
+
var CORE_SCHEMA = new Schema([
|
|
746
|
+
...FAILSAFE_SCHEMA.tags,
|
|
747
|
+
nullCoreTag,
|
|
748
|
+
boolCoreTag,
|
|
749
|
+
intCoreTag,
|
|
750
|
+
floatCoreTag
|
|
751
|
+
]);
|
|
752
|
+
var YAML11_SCHEMA = new Schema([
|
|
753
|
+
...FAILSAFE_SCHEMA.tags,
|
|
754
|
+
nullYaml11Tag,
|
|
755
|
+
boolYaml11Tag,
|
|
756
|
+
intYaml11Tag,
|
|
757
|
+
floatYaml11Tag,
|
|
758
|
+
timestampTag,
|
|
759
|
+
mergeTag,
|
|
760
|
+
binaryTag,
|
|
761
|
+
omapTag,
|
|
762
|
+
pairsTag,
|
|
763
|
+
setTag
|
|
764
|
+
]);
|
|
765
|
+
var DUMP_SCHEMA = YAML11_SCHEMA.withTags({
|
|
766
|
+
...intYaml11Tag,
|
|
767
|
+
resolve: (source, isExplicit, tagName) => {
|
|
768
|
+
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
769
|
+
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
770
|
+
}
|
|
771
|
+
}, {
|
|
772
|
+
...floatYaml11Tag,
|
|
773
|
+
resolve: (source, isExplicit, tagName) => {
|
|
774
|
+
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
775
|
+
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
var realMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
779
|
+
create: () => /* @__PURE__ */ new Map(),
|
|
780
|
+
addPair: (container, key, value) => {
|
|
781
|
+
container.set(key, value);
|
|
782
|
+
return "";
|
|
783
|
+
},
|
|
784
|
+
has: (container, key) => container.has(key),
|
|
785
|
+
keys: (container) => container.keys(),
|
|
786
|
+
get: (container, key) => container.get(key),
|
|
787
|
+
identify: (data) => data instanceof Map || isPlainObject(data),
|
|
788
|
+
represent: (data) => {
|
|
789
|
+
if (data instanceof Map) return data;
|
|
790
|
+
const map = /* @__PURE__ */ new Map();
|
|
791
|
+
const obj = data;
|
|
792
|
+
for (const key of Object.keys(obj)) map.set(key, obj[key]);
|
|
793
|
+
return map;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
function normalizeKey(key) {
|
|
797
|
+
if (Array.isArray(key)) {
|
|
798
|
+
const array = Array.prototype.slice.call(key);
|
|
799
|
+
for (let index = 0; index < array.length; index++) {
|
|
800
|
+
if (Array.isArray(array[index])) return null;
|
|
801
|
+
if (typeof array[index] === "object" && Object.prototype.toString.call(array[index]) === "[object Object]") array[index] = "[object Object]";
|
|
802
|
+
}
|
|
803
|
+
return String(array);
|
|
804
|
+
}
|
|
805
|
+
if (typeof key === "object" && Object.prototype.toString.call(key) === "[object Object]") return "[object Object]";
|
|
806
|
+
return String(key);
|
|
807
|
+
}
|
|
808
|
+
var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
809
|
+
create: () => ({}),
|
|
810
|
+
identify: isPlainObject,
|
|
811
|
+
represent: (o) => {
|
|
812
|
+
const map = /* @__PURE__ */ new Map();
|
|
813
|
+
for (const key of Object.keys(o)) map.set(key, o[key]);
|
|
814
|
+
return map;
|
|
815
|
+
},
|
|
816
|
+
addPair: (container, key, value) => {
|
|
817
|
+
const normalizedKey = normalizeKey(key);
|
|
818
|
+
if (normalizedKey === null) return "nested arrays are not supported inside keys";
|
|
819
|
+
if (normalizedKey === "__proto__") Object.defineProperty(container, normalizedKey, {
|
|
820
|
+
value,
|
|
821
|
+
enumerable: true,
|
|
822
|
+
configurable: true,
|
|
823
|
+
writable: true
|
|
824
|
+
});
|
|
825
|
+
else container[normalizedKey] = value;
|
|
826
|
+
return "";
|
|
827
|
+
},
|
|
828
|
+
has: (container, key) => {
|
|
829
|
+
const normalizedKey = normalizeKey(key);
|
|
830
|
+
return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
|
|
831
|
+
},
|
|
832
|
+
keys: (container) => Object.keys(container),
|
|
833
|
+
get: (container, key) => {
|
|
834
|
+
const normalizedKey = String(key);
|
|
835
|
+
if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
|
|
836
|
+
return container[normalizedKey];
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
var DEFAULT_SNIPPET_OPTIONS = {
|
|
840
|
+
maxLength: 79,
|
|
841
|
+
indent: 1,
|
|
842
|
+
linesBefore: 3,
|
|
843
|
+
linesAfter: 2
|
|
844
|
+
};
|
|
845
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
846
|
+
let head = "";
|
|
847
|
+
let tail = "";
|
|
848
|
+
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
849
|
+
if (position - lineStart > maxHalfLength) {
|
|
850
|
+
head = " ... ";
|
|
851
|
+
lineStart = position - maxHalfLength + head.length;
|
|
852
|
+
}
|
|
853
|
+
if (lineEnd - position > maxHalfLength) {
|
|
854
|
+
tail = " ...";
|
|
855
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
859
|
+
pos: position - lineStart + head.length
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
function padStart(string, max) {
|
|
863
|
+
return " ".repeat(Math.max(max - string.length, 0)) + string;
|
|
864
|
+
}
|
|
865
|
+
function makeSnippet(mark, options) {
|
|
866
|
+
if (!mark.buffer) return null;
|
|
867
|
+
const opts = {
|
|
868
|
+
...DEFAULT_SNIPPET_OPTIONS,
|
|
869
|
+
...options
|
|
870
|
+
};
|
|
871
|
+
const re = /\r?\n|\r|\0/g;
|
|
872
|
+
const lineStarts = [0];
|
|
873
|
+
const lineEnds = [];
|
|
874
|
+
let match;
|
|
875
|
+
let foundLineNo = -1;
|
|
876
|
+
while (match = re.exec(mark.buffer)) {
|
|
877
|
+
lineEnds.push(match.index);
|
|
878
|
+
lineStarts.push(match.index + match[0].length);
|
|
879
|
+
if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
|
|
880
|
+
}
|
|
881
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
882
|
+
let result = "";
|
|
883
|
+
const lineNoLength = Math.min(mark.line + opts.linesAfter, lineEnds.length).toString().length;
|
|
884
|
+
const maxLineLength = opts.maxLength - (opts.indent + lineNoLength + 3);
|
|
885
|
+
for (let i = 1; i <= opts.linesBefore; i++) {
|
|
886
|
+
if (foundLineNo - i < 0) break;
|
|
887
|
+
const line2 = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
888
|
+
result = `${" ".repeat(opts.indent)}${padStart((mark.line - i + 1).toString(), lineNoLength)} | ${line2.str}
|
|
889
|
+
${result}`;
|
|
890
|
+
}
|
|
891
|
+
const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
892
|
+
result += `${" ".repeat(opts.indent)}${padStart((mark.line + 1).toString(), lineNoLength)} | ${line.str}
|
|
893
|
+
`;
|
|
894
|
+
result += `${"-".repeat(opts.indent + lineNoLength + 3 + line.pos)}^
|
|
895
|
+
`;
|
|
896
|
+
for (let i = 1; i <= opts.linesAfter; i++) {
|
|
897
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
898
|
+
const line2 = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
899
|
+
result += `${" ".repeat(opts.indent)}${padStart((mark.line + i + 1).toString(), lineNoLength)} | ${line2.str}
|
|
900
|
+
`;
|
|
901
|
+
}
|
|
902
|
+
return result.replace(/\n$/, "");
|
|
903
|
+
}
|
|
904
|
+
function formatError(exception, compact) {
|
|
905
|
+
let where = "";
|
|
906
|
+
if (!exception.mark) return exception.reason;
|
|
907
|
+
if (exception.mark.name) where += `in "${exception.mark.name}" `;
|
|
908
|
+
where += `(${exception.mark.line + 1}:${exception.mark.column + 1})`;
|
|
909
|
+
if (!compact && exception.mark.snippet) where += `
|
|
910
|
+
|
|
911
|
+
${exception.mark.snippet}`;
|
|
912
|
+
return `${exception.reason} ${where}`;
|
|
913
|
+
}
|
|
914
|
+
var YAMLException = class YAMLException2 extends Error {
|
|
915
|
+
reason;
|
|
916
|
+
mark;
|
|
917
|
+
/**
|
|
918
|
+
* Optional `mark` contains source snippet data. Usually, use
|
|
919
|
+
* {@link YAMLException.throwAt} instead of passing it directly.
|
|
920
|
+
*/
|
|
921
|
+
constructor(reason, mark) {
|
|
922
|
+
super();
|
|
923
|
+
this.name = "YAMLException";
|
|
924
|
+
this.reason = reason;
|
|
925
|
+
this.mark = mark;
|
|
926
|
+
this.message = formatError(this, false);
|
|
927
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Returns the formatted error, omitting the source snippet in compact mode.
|
|
931
|
+
*/
|
|
932
|
+
toString(compact) {
|
|
933
|
+
return `${this.name}: ${formatError(this, compact)}`;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Builds a YAMLException with a source snippet and throws it. `source` is
|
|
937
|
+
* the raw input text; `position` is an offset into it.
|
|
938
|
+
*/
|
|
939
|
+
static throwAt(source, position, message, filename = "") {
|
|
940
|
+
let line = 0;
|
|
941
|
+
let lineStart = 0;
|
|
942
|
+
for (let index = 0; index < position; index++) {
|
|
943
|
+
const ch = source.charCodeAt(index);
|
|
944
|
+
if (ch === 10) {
|
|
945
|
+
line++;
|
|
946
|
+
lineStart = index + 1;
|
|
947
|
+
} else if (ch === 13) {
|
|
948
|
+
line++;
|
|
949
|
+
if (source.charCodeAt(index + 1) === 10) index++;
|
|
950
|
+
lineStart = index + 1;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
const mark = {
|
|
954
|
+
name: filename,
|
|
955
|
+
buffer: source,
|
|
956
|
+
position,
|
|
957
|
+
line,
|
|
958
|
+
column: position - lineStart
|
|
959
|
+
};
|
|
960
|
+
mark.snippet = makeSnippet(mark);
|
|
961
|
+
throw new YAMLException2(message, mark);
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
var EVENT_ID = {
|
|
965
|
+
DOCUMENT: 1,
|
|
966
|
+
SEQUENCE: 2,
|
|
967
|
+
MAPPING: 3,
|
|
968
|
+
SCALAR: 4,
|
|
969
|
+
ALIAS: 5,
|
|
970
|
+
POP: 6
|
|
971
|
+
};
|
|
972
|
+
var SCALAR_STYLE = {
|
|
973
|
+
PLAIN: 1,
|
|
974
|
+
SINGLE_QUOTED: 2,
|
|
975
|
+
DOUBLE_QUOTED: 3,
|
|
976
|
+
LITERAL_BLOCK: 4,
|
|
977
|
+
FOLDED_BLOCK: 5
|
|
978
|
+
};
|
|
979
|
+
var COLLECTION_STYLE = {
|
|
980
|
+
BLOCK: 1,
|
|
981
|
+
FLOW: 2
|
|
982
|
+
};
|
|
983
|
+
var CHOMPING_MODE = {
|
|
984
|
+
CLIP: 1,
|
|
985
|
+
STRIP: 2,
|
|
986
|
+
KEEP: 3
|
|
987
|
+
};
|
|
988
|
+
var NO_RANGE$3 = -1;
|
|
989
|
+
function simpleEscapeSequence(c) {
|
|
990
|
+
switch (c) {
|
|
991
|
+
case 48:
|
|
992
|
+
return "\0";
|
|
993
|
+
case 97:
|
|
994
|
+
return "\x07";
|
|
995
|
+
case 98:
|
|
996
|
+
return "\b";
|
|
997
|
+
case 116:
|
|
998
|
+
return " ";
|
|
999
|
+
case 9:
|
|
1000
|
+
return " ";
|
|
1001
|
+
case 110:
|
|
1002
|
+
return "\n";
|
|
1003
|
+
case 118:
|
|
1004
|
+
return "\v";
|
|
1005
|
+
case 102:
|
|
1006
|
+
return "\f";
|
|
1007
|
+
case 114:
|
|
1008
|
+
return "\r";
|
|
1009
|
+
case 101:
|
|
1010
|
+
return "\x1B";
|
|
1011
|
+
case 32:
|
|
1012
|
+
return " ";
|
|
1013
|
+
case 34:
|
|
1014
|
+
return '"';
|
|
1015
|
+
case 47:
|
|
1016
|
+
return "/";
|
|
1017
|
+
case 92:
|
|
1018
|
+
return "\\";
|
|
1019
|
+
case 78:
|
|
1020
|
+
return "\x85";
|
|
1021
|
+
case 95:
|
|
1022
|
+
return "\xA0";
|
|
1023
|
+
case 76:
|
|
1024
|
+
return "\u2028";
|
|
1025
|
+
case 80:
|
|
1026
|
+
return "\u2029";
|
|
1027
|
+
default:
|
|
1028
|
+
return "";
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
var simpleEscapeCheck = new Array(256);
|
|
1032
|
+
var simpleEscapeMap = new Array(256);
|
|
1033
|
+
for (let i = 0; i < 256; i++) {
|
|
1034
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1035
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1036
|
+
}
|
|
1037
|
+
function charFromCodepoint(c) {
|
|
1038
|
+
if (c <= 65535) return String.fromCharCode(c);
|
|
1039
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1040
|
+
}
|
|
1041
|
+
function fromHexCode$1(c) {
|
|
1042
|
+
if (c >= 48 && c <= 57) return c - 48;
|
|
1043
|
+
return (c | 32) - 97 + 10;
|
|
1044
|
+
}
|
|
1045
|
+
function escapedHexLen$1(c) {
|
|
1046
|
+
if (c === 120) return 2;
|
|
1047
|
+
if (c === 117) return 4;
|
|
1048
|
+
return 8;
|
|
1049
|
+
}
|
|
1050
|
+
function skipFoldedBreaks(input, position, end) {
|
|
1051
|
+
let breaks = 0;
|
|
1052
|
+
while (position < end) {
|
|
1053
|
+
const ch = input.charCodeAt(position);
|
|
1054
|
+
if (ch === 10) {
|
|
1055
|
+
breaks++;
|
|
1056
|
+
position++;
|
|
1057
|
+
} else if (ch === 13) {
|
|
1058
|
+
breaks++;
|
|
1059
|
+
position++;
|
|
1060
|
+
if (input.charCodeAt(position) === 10) position++;
|
|
1061
|
+
} else if (ch === 32 || ch === 9) position++;
|
|
1062
|
+
else break;
|
|
1063
|
+
}
|
|
1064
|
+
return {
|
|
1065
|
+
position,
|
|
1066
|
+
breaks
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
function foldedBreaks(count) {
|
|
1070
|
+
if (count === 1) return " ";
|
|
1071
|
+
return "\n".repeat(count - 1);
|
|
1072
|
+
}
|
|
1073
|
+
function getPlainValue(input, start, end) {
|
|
1074
|
+
let result = "";
|
|
1075
|
+
let position = start;
|
|
1076
|
+
let captureStart = start;
|
|
1077
|
+
let captureEnd = start;
|
|
1078
|
+
while (position < end) {
|
|
1079
|
+
const ch = input.charCodeAt(position);
|
|
1080
|
+
if (ch === 10 || ch === 13) {
|
|
1081
|
+
result += input.slice(captureStart, captureEnd);
|
|
1082
|
+
const fold = skipFoldedBreaks(input, position, end);
|
|
1083
|
+
result += foldedBreaks(fold.breaks);
|
|
1084
|
+
position = captureStart = captureEnd = fold.position;
|
|
1085
|
+
} else {
|
|
1086
|
+
position++;
|
|
1087
|
+
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return result + input.slice(captureStart, captureEnd);
|
|
1091
|
+
}
|
|
1092
|
+
function getSingleQuotedValue(input, start, end) {
|
|
1093
|
+
let result = "";
|
|
1094
|
+
let position = start;
|
|
1095
|
+
let captureStart = start;
|
|
1096
|
+
let captureEnd = start;
|
|
1097
|
+
while (position < end) {
|
|
1098
|
+
const ch = input.charCodeAt(position);
|
|
1099
|
+
if (ch === 39) {
|
|
1100
|
+
result += input.slice(captureStart, position) + "'";
|
|
1101
|
+
position += 2;
|
|
1102
|
+
captureStart = captureEnd = position;
|
|
1103
|
+
} else if (ch === 10 || ch === 13) {
|
|
1104
|
+
result += input.slice(captureStart, captureEnd);
|
|
1105
|
+
const fold = skipFoldedBreaks(input, position, end);
|
|
1106
|
+
result += foldedBreaks(fold.breaks);
|
|
1107
|
+
position = captureStart = captureEnd = fold.position;
|
|
1108
|
+
} else {
|
|
1109
|
+
position++;
|
|
1110
|
+
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return result + input.slice(captureStart, end);
|
|
1114
|
+
}
|
|
1115
|
+
function getDoubleQuotedValue(input, start, end) {
|
|
1116
|
+
let result = "";
|
|
1117
|
+
let position = start;
|
|
1118
|
+
let captureStart = start;
|
|
1119
|
+
let captureEnd = start;
|
|
1120
|
+
while (position < end) {
|
|
1121
|
+
const ch = input.charCodeAt(position);
|
|
1122
|
+
if (ch === 92) {
|
|
1123
|
+
result += input.slice(captureStart, position);
|
|
1124
|
+
position++;
|
|
1125
|
+
const escaped = input.charCodeAt(position);
|
|
1126
|
+
if (escaped === 10 || escaped === 13) position = skipFoldedBreaks(input, position, end).position;
|
|
1127
|
+
else if (escaped < 256 && simpleEscapeCheck[escaped]) {
|
|
1128
|
+
result += simpleEscapeMap[escaped];
|
|
1129
|
+
position++;
|
|
1130
|
+
} else {
|
|
1131
|
+
let hexLength = escapedHexLen$1(escaped);
|
|
1132
|
+
let hexResult = 0;
|
|
1133
|
+
for (; hexLength > 0; hexLength--) {
|
|
1134
|
+
position++;
|
|
1135
|
+
const digit = fromHexCode$1(input.charCodeAt(position));
|
|
1136
|
+
hexResult = (hexResult << 4) + digit;
|
|
1137
|
+
}
|
|
1138
|
+
result += charFromCodepoint(hexResult);
|
|
1139
|
+
position++;
|
|
1140
|
+
}
|
|
1141
|
+
captureStart = captureEnd = position;
|
|
1142
|
+
} else if (ch === 10 || ch === 13) {
|
|
1143
|
+
result += input.slice(captureStart, captureEnd);
|
|
1144
|
+
const fold = skipFoldedBreaks(input, position, end);
|
|
1145
|
+
result += foldedBreaks(fold.breaks);
|
|
1146
|
+
position = captureStart = captureEnd = fold.position;
|
|
1147
|
+
} else {
|
|
1148
|
+
position++;
|
|
1149
|
+
if (ch !== 32 && ch !== 9) captureEnd = position;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return result + input.slice(captureStart, end);
|
|
1153
|
+
}
|
|
1154
|
+
function getBlockValue(input, start, end, indent, chomping, folded) {
|
|
1155
|
+
const textIndent = indent < 0 ? 0 : indent;
|
|
1156
|
+
const region = input.slice(start, end).replace(/\r\n?/g, "\n");
|
|
1157
|
+
const lines = region === "" ? [] : (region.endsWith("\n") ? region.slice(0, -1) : region).split("\n");
|
|
1158
|
+
let result = "";
|
|
1159
|
+
let didReadContent = false;
|
|
1160
|
+
let emptyLines = 0;
|
|
1161
|
+
let atMoreIndented = false;
|
|
1162
|
+
for (const line of lines) {
|
|
1163
|
+
let column = 0;
|
|
1164
|
+
while (column < textIndent && line.charCodeAt(column) === 32) column++;
|
|
1165
|
+
if (indent < 0 || column >= line.length) {
|
|
1166
|
+
emptyLines++;
|
|
1167
|
+
continue;
|
|
1168
|
+
}
|
|
1169
|
+
const content = line.slice(textIndent);
|
|
1170
|
+
const first = content.charCodeAt(0);
|
|
1171
|
+
if (folded) if (first === 32 || first === 9) {
|
|
1172
|
+
atMoreIndented = true;
|
|
1173
|
+
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1174
|
+
} else if (atMoreIndented) {
|
|
1175
|
+
atMoreIndented = false;
|
|
1176
|
+
result += "\n".repeat(emptyLines + 1);
|
|
1177
|
+
} else if (emptyLines === 0) {
|
|
1178
|
+
if (didReadContent) result += " ";
|
|
1179
|
+
} else result += "\n".repeat(emptyLines);
|
|
1180
|
+
else result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1181
|
+
result += content;
|
|
1182
|
+
didReadContent = true;
|
|
1183
|
+
emptyLines = 0;
|
|
1184
|
+
}
|
|
1185
|
+
if (chomping === CHOMPING_MODE.KEEP) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1186
|
+
else if (chomping !== CHOMPING_MODE.STRIP) {
|
|
1187
|
+
if (didReadContent) result += "\n";
|
|
1188
|
+
}
|
|
1189
|
+
return result;
|
|
1190
|
+
}
|
|
1191
|
+
function getScalarValue(input, scalar) {
|
|
1192
|
+
if (scalar.valueStart === NO_RANGE$3) return "";
|
|
1193
|
+
const { valueStart, valueEnd } = scalar;
|
|
1194
|
+
if (scalar.fast) return input.slice(valueStart, valueEnd);
|
|
1195
|
+
switch (scalar.style) {
|
|
1196
|
+
case SCALAR_STYLE.SINGLE_QUOTED:
|
|
1197
|
+
return getSingleQuotedValue(input, valueStart, valueEnd);
|
|
1198
|
+
case SCALAR_STYLE.DOUBLE_QUOTED:
|
|
1199
|
+
return getDoubleQuotedValue(input, valueStart, valueEnd);
|
|
1200
|
+
case SCALAR_STYLE.LITERAL_BLOCK:
|
|
1201
|
+
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
|
|
1202
|
+
case SCALAR_STYLE.FOLDED_BLOCK:
|
|
1203
|
+
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
|
|
1204
|
+
default:
|
|
1205
|
+
return getPlainValue(input, valueStart, valueEnd);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
var DEFAULT_TAG_HANDLERS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1209
|
+
"!": "!",
|
|
1210
|
+
"!!": "tag:yaml.org,2002:"
|
|
1211
|
+
});
|
|
1212
|
+
function tagPercentEncode(source) {
|
|
1213
|
+
return encodeURI(source).replace(/!/g, "%21");
|
|
1214
|
+
}
|
|
1215
|
+
function tagNameFull(rawTag, tagHandlers) {
|
|
1216
|
+
if (rawTag.startsWith("!<") && rawTag.endsWith(">")) return decodeURIComponent(rawTag.slice(2, -1));
|
|
1217
|
+
const handleEnd = rawTag.indexOf("!", 1);
|
|
1218
|
+
const handle = handleEnd === -1 ? "!" : rawTag.slice(0, handleEnd + 1);
|
|
1219
|
+
const prefix = tagHandlers?.[handle] ?? DEFAULT_TAG_HANDLERS[handle] ?? handle;
|
|
1220
|
+
return decodeURIComponent(prefix) + decodeURIComponent(rawTag.slice(handle.length));
|
|
1221
|
+
}
|
|
1222
|
+
function tagNameShort(fullTag) {
|
|
1223
|
+
let tag = fullTag;
|
|
1224
|
+
if (tag.charCodeAt(0) === 33) {
|
|
1225
|
+
tag = tag.slice(1);
|
|
1226
|
+
return `!${tagPercentEncode(tag)}`;
|
|
1227
|
+
}
|
|
1228
|
+
if (tag.slice(0, 18) === "tag:yaml.org,2002:") return `!!${tagPercentEncode(tag.slice(18))}`;
|
|
1229
|
+
return `!<${tagPercentEncode(tag)}>`;
|
|
1230
|
+
}
|
|
1231
|
+
var NO_RANGE$2 = -1;
|
|
1232
|
+
var MERGE_TAG_NAME = "tag:yaml.org,2002:merge";
|
|
1233
|
+
var DEFAULT_CONSTRUCTOR_OPTIONS = {
|
|
1234
|
+
filename: "",
|
|
1235
|
+
schema: CORE_SCHEMA,
|
|
1236
|
+
json: false,
|
|
1237
|
+
maxTotalMergeKeys: 1e4,
|
|
1238
|
+
maxAliases: -1
|
|
1239
|
+
};
|
|
1240
|
+
function eventPosition$1(event) {
|
|
1241
|
+
if ("tagStart" in event && event.tagStart !== NO_RANGE$2) return event.tagStart;
|
|
1242
|
+
if ("anchorStart" in event && event.anchorStart !== NO_RANGE$2) return event.anchorStart;
|
|
1243
|
+
if ("valueStart" in event && event.valueStart !== NO_RANGE$2) return event.valueStart;
|
|
1244
|
+
if ("start" in event) return event.start;
|
|
1245
|
+
return 0;
|
|
1246
|
+
}
|
|
1247
|
+
function throwError$1(state, message) {
|
|
1248
|
+
YAMLException.throwAt(state.source, state.position, message, state.filename);
|
|
1249
|
+
}
|
|
1250
|
+
function finalizeCollection(state, position, tag, carrier) {
|
|
1251
|
+
try {
|
|
1252
|
+
return tag.finalize(carrier);
|
|
1253
|
+
} catch (error) {
|
|
1254
|
+
if (error instanceof YAMLException) throw error;
|
|
1255
|
+
YAMLException.throwAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
function constructScalar(state, event) {
|
|
1259
|
+
const source = getScalarValue(state.source, event);
|
|
1260
|
+
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1261
|
+
const strTag2 = state.schema.defaultScalarTag;
|
|
1262
|
+
if (rawTag !== "") {
|
|
1263
|
+
if (rawTag === "!") return {
|
|
1264
|
+
value: source,
|
|
1265
|
+
tag: strTag2
|
|
1266
|
+
};
|
|
1267
|
+
const tagName = tagNameFull(rawTag, state.tagHandlers);
|
|
1268
|
+
const scalarTag = state.schema.lookupScalarTag(tagName);
|
|
1269
|
+
if (scalarTag) {
|
|
1270
|
+
const result = scalarTag.resolve(source, true, tagName);
|
|
1271
|
+
if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1272
|
+
return {
|
|
1273
|
+
value: result,
|
|
1274
|
+
tag: scalarTag
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
const collectionTagDef = state.schema.lookupMappingTag(tagName) ?? state.schema.lookupSequenceTag(tagName);
|
|
1278
|
+
if (collectionTagDef) {
|
|
1279
|
+
if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1280
|
+
const carrier = collectionTagDef.create(tagName);
|
|
1281
|
+
return {
|
|
1282
|
+
value: collectionTagDef.carrierIsResult ? carrier : finalizeCollection(state, state.position, collectionTagDef, carrier),
|
|
1283
|
+
tag: collectionTagDef
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
throwError$1(state, `unknown scalar tag !<${tagName}>`);
|
|
1287
|
+
}
|
|
1288
|
+
if (event.style === SCALAR_STYLE.PLAIN) return state.schema.resolveImplicitScalarTag(source);
|
|
1289
|
+
return {
|
|
1290
|
+
value: strTag2.resolve(source, false, strTag2.tagName),
|
|
1291
|
+
tag: strTag2
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
function collectionTagName(state, event, defaultTagName) {
|
|
1295
|
+
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1296
|
+
return rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
|
|
1297
|
+
}
|
|
1298
|
+
function isMappingTag(tag) {
|
|
1299
|
+
return tag.nodeKind === "mapping";
|
|
1300
|
+
}
|
|
1301
|
+
function chargeMergeWork(state) {
|
|
1302
|
+
state.totalMergeKeys++;
|
|
1303
|
+
if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
|
|
1304
|
+
}
|
|
1305
|
+
function mergeKeys(state, frame, source, sourceTag) {
|
|
1306
|
+
chargeMergeWork(state);
|
|
1307
|
+
for (const sourceKey of sourceTag.keys(source)) {
|
|
1308
|
+
chargeMergeWork(state);
|
|
1309
|
+
if (frame.tag.has(frame.value, sourceKey)) continue;
|
|
1310
|
+
const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
|
|
1311
|
+
if (err) throwError$1(state, err);
|
|
1312
|
+
frame.overridable ??= /* @__PURE__ */ new Set();
|
|
1313
|
+
frame.overridable.add(sourceKey);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
function mergeSource(state, frame, source, sourceTag) {
|
|
1317
|
+
state.position = frame.keyPosition;
|
|
1318
|
+
if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
|
|
1319
|
+
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) {
|
|
1320
|
+
if (source.length > 100) throwError$1(state, "abnormal merge sequence size");
|
|
1321
|
+
for (const element of source) {
|
|
1322
|
+
const elementTag = state.nodeTags.get(element);
|
|
1323
|
+
if (!elementTag) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1324
|
+
mergeKeys(state, frame, element, elementTag);
|
|
1325
|
+
}
|
|
1326
|
+
} else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1327
|
+
}
|
|
1328
|
+
function addMappingValue(state, frame, key, value, tag) {
|
|
1329
|
+
state.position = frame.keyPosition;
|
|
1330
|
+
if (frame.keyIsMerge) {
|
|
1331
|
+
mergeSource(state, frame, value, tag);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
if (!state.json && frame.tag.has(frame.value, key) && !frame.overridable?.has(key)) throwError$1(state, "duplicated mapping key");
|
|
1335
|
+
const err = frame.tag.addPair(frame.value, key, value);
|
|
1336
|
+
if (err) throwError$1(state, err);
|
|
1337
|
+
frame.overridable?.delete(key);
|
|
1338
|
+
}
|
|
1339
|
+
function addValue(state, value, tag) {
|
|
1340
|
+
const frame = state.frames[state.frames.length - 1];
|
|
1341
|
+
if (frame.kind === "document") {
|
|
1342
|
+
frame.value = value;
|
|
1343
|
+
frame.hasValue = true;
|
|
1344
|
+
} else if (frame.kind === "sequence") {
|
|
1345
|
+
if (isMappingTag(tag)) state.nodeTags.set(value, tag);
|
|
1346
|
+
const err = frame.tag.addItem(frame.value, value, frame.index++);
|
|
1347
|
+
if (err) throwError$1(state, err);
|
|
1348
|
+
} else if (frame.hasKey) {
|
|
1349
|
+
const key = frame.key;
|
|
1350
|
+
frame.key = void 0;
|
|
1351
|
+
frame.hasKey = false;
|
|
1352
|
+
addMappingValue(state, frame, key, value, tag);
|
|
1353
|
+
} else {
|
|
1354
|
+
frame.key = value;
|
|
1355
|
+
frame.keyPosition = state.position;
|
|
1356
|
+
frame.hasKey = true;
|
|
1357
|
+
frame.keyIsMerge = tag.tagName === MERGE_TAG_NAME;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
function storeAnchor(state, event, value, tag, isValueFinal) {
|
|
1361
|
+
if (event.anchorStart !== NO_RANGE$2) {
|
|
1362
|
+
const anchor = {
|
|
1363
|
+
value,
|
|
1364
|
+
tag,
|
|
1365
|
+
isValueFinal
|
|
1366
|
+
};
|
|
1367
|
+
state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
|
|
1368
|
+
return anchor;
|
|
1369
|
+
}
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
function constructFromEvents(events, options) {
|
|
1373
|
+
const state = {
|
|
1374
|
+
...DEFAULT_CONSTRUCTOR_OPTIONS,
|
|
1375
|
+
...options,
|
|
1376
|
+
events,
|
|
1377
|
+
documents: [],
|
|
1378
|
+
eventIndex: 0,
|
|
1379
|
+
position: 0,
|
|
1380
|
+
frames: [],
|
|
1381
|
+
anchors: /* @__PURE__ */ new Map(),
|
|
1382
|
+
nodeTags: /* @__PURE__ */ new Map(),
|
|
1383
|
+
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
1384
|
+
totalMergeKeys: 0,
|
|
1385
|
+
aliasCount: 0
|
|
1386
|
+
};
|
|
1387
|
+
while (state.eventIndex < state.events.length) {
|
|
1388
|
+
const event = state.events[state.eventIndex++];
|
|
1389
|
+
state.position = eventPosition$1(event);
|
|
1390
|
+
switch (event.type) {
|
|
1391
|
+
case EVENT_ID.DOCUMENT:
|
|
1392
|
+
state.anchors = /* @__PURE__ */ new Map();
|
|
1393
|
+
state.nodeTags = /* @__PURE__ */ new Map();
|
|
1394
|
+
state.aliasCount = 0;
|
|
1395
|
+
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
1396
|
+
for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
|
|
1397
|
+
state.frames.push({
|
|
1398
|
+
kind: "document",
|
|
1399
|
+
position: state.position,
|
|
1400
|
+
value: void 0,
|
|
1401
|
+
hasValue: false
|
|
1402
|
+
});
|
|
1403
|
+
break;
|
|
1404
|
+
case EVENT_ID.SCALAR: {
|
|
1405
|
+
const { value, tag } = constructScalar(state, event);
|
|
1406
|
+
storeAnchor(state, event, value, tag, true);
|
|
1407
|
+
addValue(state, value, tag);
|
|
1408
|
+
break;
|
|
1409
|
+
}
|
|
1410
|
+
case EVENT_ID.SEQUENCE: {
|
|
1411
|
+
const tagName = collectionTagName(state, event, "tag:yaml.org,2002:seq");
|
|
1412
|
+
const tag = state.schema.lookupSequenceTag(tagName);
|
|
1413
|
+
if (!tag) throwError$1(state, `unknown sequence tag !<${tagName}>`);
|
|
1414
|
+
const value = tag.create(tagName);
|
|
1415
|
+
const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
|
|
1416
|
+
state.frames.push({
|
|
1417
|
+
kind: "sequence",
|
|
1418
|
+
position: state.position,
|
|
1419
|
+
value,
|
|
1420
|
+
tag,
|
|
1421
|
+
anchor,
|
|
1422
|
+
index: 0
|
|
1423
|
+
});
|
|
1424
|
+
break;
|
|
1425
|
+
}
|
|
1426
|
+
case EVENT_ID.MAPPING: {
|
|
1427
|
+
const tagName = collectionTagName(state, event, "tag:yaml.org,2002:map");
|
|
1428
|
+
const tag = state.schema.lookupMappingTag(tagName);
|
|
1429
|
+
if (!tag) throwError$1(state, `unknown mapping tag !<${tagName}>`);
|
|
1430
|
+
const value = tag.create(tagName);
|
|
1431
|
+
const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
|
|
1432
|
+
state.frames.push({
|
|
1433
|
+
kind: "mapping",
|
|
1434
|
+
position: state.position,
|
|
1435
|
+
value,
|
|
1436
|
+
tag,
|
|
1437
|
+
anchor,
|
|
1438
|
+
key: void 0,
|
|
1439
|
+
keyPosition: state.position,
|
|
1440
|
+
hasKey: false,
|
|
1441
|
+
keyIsMerge: false,
|
|
1442
|
+
overridable: null
|
|
1443
|
+
});
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
case EVENT_ID.ALIAS: {
|
|
1447
|
+
if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
|
|
1448
|
+
const name = state.source.slice(event.anchorStart, event.anchorEnd);
|
|
1449
|
+
const anchor = state.anchors.get(name);
|
|
1450
|
+
if (!anchor) throwError$1(state, `unidentified alias "${name}"`);
|
|
1451
|
+
if (!anchor.isValueFinal) throwError$1(state, `recursive alias "${name}" is not supported for tag ${anchor.tag.tagName} because it uses finalize()`);
|
|
1452
|
+
addValue(state, anchor.value, anchor.tag);
|
|
1453
|
+
break;
|
|
1454
|
+
}
|
|
1455
|
+
case EVENT_ID.POP: {
|
|
1456
|
+
const frame = state.frames.pop();
|
|
1457
|
+
if (frame.kind === "mapping" && frame.hasKey) {
|
|
1458
|
+
state.position = frame.keyPosition;
|
|
1459
|
+
throwError$1(state, "incomplete mapping pair in event stream");
|
|
1460
|
+
}
|
|
1461
|
+
if (frame.kind === "document") state.documents.push(frame.value);
|
|
1462
|
+
else {
|
|
1463
|
+
const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
|
|
1464
|
+
if (frame.anchor) {
|
|
1465
|
+
frame.anchor.value = value;
|
|
1466
|
+
frame.anchor.isValueFinal = true;
|
|
1467
|
+
}
|
|
1468
|
+
addValue(state, value, frame.tag);
|
|
1469
|
+
}
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
return state.documents;
|
|
1475
|
+
}
|
|
1476
|
+
var NO_RANGE$1 = -1;
|
|
1477
|
+
var HAS_OWN = Object.prototype.hasOwnProperty;
|
|
1478
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1479
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1480
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1481
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1482
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1483
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
|
|
1484
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
|
|
1485
|
+
var NS_URI_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`;
|
|
1486
|
+
var NS_TAG_CHAR = String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`;
|
|
1487
|
+
var PATTERN_TAG_URI = new RegExp(`^(?:${NS_URI_CHAR})*$`);
|
|
1488
|
+
var PATTERN_TAG_SUFFIX = new RegExp(`^(?:${NS_TAG_CHAR})+$`);
|
|
1489
|
+
var PATTERN_TAG_PREFIX = new RegExp(`^(?:!(?:${NS_URI_CHAR})*|${NS_TAG_CHAR}(?:${NS_URI_CHAR})*)$`);
|
|
1490
|
+
var DEFAULT_PARSER_OPTIONS = {
|
|
1491
|
+
filename: "",
|
|
1492
|
+
maxDepth: 100
|
|
1493
|
+
};
|
|
1494
|
+
function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
1495
|
+
state.events.push({
|
|
1496
|
+
type: EVENT_ID.DOCUMENT,
|
|
1497
|
+
explicitStart,
|
|
1498
|
+
explicitEnd,
|
|
1499
|
+
directives: state.directives
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1503
|
+
state.events.push({
|
|
1504
|
+
type: EVENT_ID.SEQUENCE,
|
|
1505
|
+
start,
|
|
1506
|
+
anchorStart,
|
|
1507
|
+
anchorEnd,
|
|
1508
|
+
tagStart,
|
|
1509
|
+
tagEnd,
|
|
1510
|
+
style
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1514
|
+
state.events.push({
|
|
1515
|
+
type: EVENT_ID.MAPPING,
|
|
1516
|
+
start,
|
|
1517
|
+
anchorStart,
|
|
1518
|
+
anchorEnd,
|
|
1519
|
+
tagStart,
|
|
1520
|
+
tagEnd,
|
|
1521
|
+
style
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
function insertFlowPairMappingEvent(state, snapshot) {
|
|
1525
|
+
state.events.splice(snapshot.eventsLength, 0, {
|
|
1526
|
+
type: EVENT_ID.MAPPING,
|
|
1527
|
+
start: snapshot.position,
|
|
1528
|
+
anchorStart: NO_RANGE$1,
|
|
1529
|
+
anchorEnd: NO_RANGE$1,
|
|
1530
|
+
tagStart: NO_RANGE$1,
|
|
1531
|
+
tagEnd: NO_RANGE$1,
|
|
1532
|
+
style: COLLECTION_STYLE.FLOW
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = CHOMPING_MODE.CLIP, indent = -1, fast = false) {
|
|
1536
|
+
state.events.push({
|
|
1537
|
+
type: EVENT_ID.SCALAR,
|
|
1538
|
+
valueStart,
|
|
1539
|
+
valueEnd,
|
|
1540
|
+
anchorStart,
|
|
1541
|
+
anchorEnd,
|
|
1542
|
+
tagStart,
|
|
1543
|
+
tagEnd,
|
|
1544
|
+
style,
|
|
1545
|
+
chomping,
|
|
1546
|
+
indent,
|
|
1547
|
+
fast
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
function addAliasEvent(state, anchorStart, anchorEnd) {
|
|
1551
|
+
state.events.push({
|
|
1552
|
+
type: EVENT_ID.ALIAS,
|
|
1553
|
+
anchorStart,
|
|
1554
|
+
anchorEnd
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
function addPopEvent(state) {
|
|
1558
|
+
state.events.push({ type: EVENT_ID.POP });
|
|
1559
|
+
}
|
|
1560
|
+
function addEmptyScalarEvent(state) {
|
|
1561
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, SCALAR_STYLE.PLAIN);
|
|
1562
|
+
}
|
|
1563
|
+
function emptyProperties() {
|
|
1564
|
+
return {
|
|
1565
|
+
anchorStart: NO_RANGE$1,
|
|
1566
|
+
anchorEnd: NO_RANGE$1,
|
|
1567
|
+
tagStart: NO_RANGE$1,
|
|
1568
|
+
tagEnd: NO_RANGE$1
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
function snapshotState(state) {
|
|
1572
|
+
return {
|
|
1573
|
+
position: state.position,
|
|
1574
|
+
line: state.line,
|
|
1575
|
+
lineStart: state.lineStart,
|
|
1576
|
+
lineIndent: state.lineIndent,
|
|
1577
|
+
firstTabInLine: state.firstTabInLine,
|
|
1578
|
+
eventsLength: state.events.length
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
function restoreState(state, snapshot) {
|
|
1582
|
+
state.position = snapshot.position;
|
|
1583
|
+
state.line = snapshot.line;
|
|
1584
|
+
state.lineStart = snapshot.lineStart;
|
|
1585
|
+
state.lineIndent = snapshot.lineIndent;
|
|
1586
|
+
state.firstTabInLine = snapshot.firstTabInLine;
|
|
1587
|
+
state.events.length = snapshot.eventsLength;
|
|
1588
|
+
}
|
|
1589
|
+
function throwError(state, message) {
|
|
1590
|
+
YAMLException.throwAt(state.input.slice(0, state.length), state.position, message, state.filename);
|
|
1591
|
+
}
|
|
1592
|
+
function isEol(c) {
|
|
1593
|
+
return c === 10 || c === 13;
|
|
1594
|
+
}
|
|
1595
|
+
function isWhiteSpace(c) {
|
|
1596
|
+
return c === 9 || c === 32;
|
|
1597
|
+
}
|
|
1598
|
+
function isWsOrEol(c) {
|
|
1599
|
+
return isWhiteSpace(c) || isEol(c);
|
|
1600
|
+
}
|
|
1601
|
+
function isWsOrEolOrEnd(c) {
|
|
1602
|
+
return c === 0 || isWsOrEol(c);
|
|
1603
|
+
}
|
|
1604
|
+
function isFlowIndicator(c) {
|
|
1605
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1606
|
+
}
|
|
1607
|
+
function fromDecimalCode(c) {
|
|
1608
|
+
return c >= 48 && c <= 57 ? c - 48 : -1;
|
|
1609
|
+
}
|
|
1610
|
+
function fromHexCode(c) {
|
|
1611
|
+
if (c >= 48 && c <= 57) return c - 48;
|
|
1612
|
+
const lc = c | 32;
|
|
1613
|
+
if (lc >= 97 && lc <= 102) return lc - 97 + 10;
|
|
1614
|
+
return -1;
|
|
1615
|
+
}
|
|
1616
|
+
function escapedHexLen(c) {
|
|
1617
|
+
if (c === 120) return 2;
|
|
1618
|
+
if (c === 117) return 4;
|
|
1619
|
+
if (c === 85) return 8;
|
|
1620
|
+
return 0;
|
|
1621
|
+
}
|
|
1622
|
+
function isSimpleEscape(c) {
|
|
1623
|
+
return c === 48 || c === 97 || c === 98 || c === 116 || c === 9 || c === 110 || c === 118 || c === 102 || c === 114 || c === 101 || c === 32 || c === 34 || c === 47 || c === 92 || c === 78 || c === 95 || c === 76 || c === 80;
|
|
1624
|
+
}
|
|
1625
|
+
function consumeLineBreak(state) {
|
|
1626
|
+
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1627
|
+
else {
|
|
1628
|
+
state.position++;
|
|
1629
|
+
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1630
|
+
}
|
|
1631
|
+
state.line++;
|
|
1632
|
+
state.lineStart = state.position;
|
|
1633
|
+
state.lineIndent = 0;
|
|
1634
|
+
state.firstTabInLine = -1;
|
|
1635
|
+
}
|
|
1636
|
+
function skipSeparationSpace(state, allowComments) {
|
|
1637
|
+
let lineBreaks = 0;
|
|
1638
|
+
let ch = state.input.charCodeAt(state.position);
|
|
1639
|
+
let hasSeparation = state.position === state.lineStart || isWsOrEol(state.input.charCodeAt(state.position - 1));
|
|
1640
|
+
while (ch !== 0) {
|
|
1641
|
+
while (isWhiteSpace(ch)) {
|
|
1642
|
+
hasSeparation = true;
|
|
1643
|
+
if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
|
|
1644
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1645
|
+
}
|
|
1646
|
+
if (allowComments && hasSeparation && ch === 35) do
|
|
1647
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1648
|
+
while (!isEol(ch) && ch !== 0);
|
|
1649
|
+
if (!isEol(ch)) break;
|
|
1650
|
+
consumeLineBreak(state);
|
|
1651
|
+
lineBreaks++;
|
|
1652
|
+
hasSeparation = true;
|
|
1653
|
+
ch = state.input.charCodeAt(state.position);
|
|
1654
|
+
while (ch === 32) {
|
|
1655
|
+
state.lineIndent++;
|
|
1656
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return lineBreaks;
|
|
1660
|
+
}
|
|
1661
|
+
function testDocumentSeparator(state, position = state.position) {
|
|
1662
|
+
const ch = state.input.charCodeAt(position);
|
|
1663
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(position + 1) && ch === state.input.charCodeAt(position + 2)) {
|
|
1664
|
+
const following = state.input.charCodeAt(position + 3);
|
|
1665
|
+
return following === 0 || isWsOrEol(following);
|
|
1666
|
+
}
|
|
1667
|
+
return false;
|
|
1668
|
+
}
|
|
1669
|
+
function skipByteOrderMark(state) {
|
|
1670
|
+
if (state.position === state.lineStart && state.input.charCodeAt(state.position) === 65279) {
|
|
1671
|
+
state.position++;
|
|
1672
|
+
state.lineStart = state.position;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
function testDocumentBoundary(state) {
|
|
1676
|
+
if (state.position !== state.lineStart) return false;
|
|
1677
|
+
if (testDocumentSeparator(state)) return true;
|
|
1678
|
+
if (state.input.charCodeAt(state.position) !== 65279) return false;
|
|
1679
|
+
const snapshot = snapshotState(state);
|
|
1680
|
+
skipByteOrderMark(state);
|
|
1681
|
+
skipSeparationSpace(state, true);
|
|
1682
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1683
|
+
const result = state.position === state.lineStart && (ch === 37 || ch === 45 && testDocumentSeparator(state));
|
|
1684
|
+
restoreState(state, snapshot);
|
|
1685
|
+
return result;
|
|
1686
|
+
}
|
|
1687
|
+
function skipUntilLineEnd(state) {
|
|
1688
|
+
let ch = state.input.charCodeAt(state.position);
|
|
1689
|
+
while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
1690
|
+
}
|
|
1691
|
+
function checkPrintable(state, start, end) {
|
|
1692
|
+
if (PATTERN_NON_PRINTABLE.test(state.input.slice(start, end))) throwError(state, "the stream contains non-printable characters");
|
|
1693
|
+
}
|
|
1694
|
+
function readTagProperty(state, props, inFlow) {
|
|
1695
|
+
if (state.input.charCodeAt(state.position) !== 33) return false;
|
|
1696
|
+
if (props.tagStart !== NO_RANGE$1) throwError(state, "duplication of a tag property");
|
|
1697
|
+
const start = state.position;
|
|
1698
|
+
let isVerbatim = false;
|
|
1699
|
+
let isNamed = false;
|
|
1700
|
+
let tagHandle = "!";
|
|
1701
|
+
let ch = state.input.charCodeAt(++state.position);
|
|
1702
|
+
if (ch === 60) {
|
|
1703
|
+
isVerbatim = true;
|
|
1704
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1705
|
+
} else if (ch === 33) {
|
|
1706
|
+
isNamed = true;
|
|
1707
|
+
tagHandle = "!!";
|
|
1708
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1709
|
+
}
|
|
1710
|
+
let suffixStart = state.position;
|
|
1711
|
+
let tagName;
|
|
1712
|
+
if (isVerbatim) {
|
|
1713
|
+
while (ch !== 0 && ch !== 62) ch = state.input.charCodeAt(++state.position);
|
|
1714
|
+
if (ch !== 62) throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1715
|
+
tagName = state.input.slice(suffixStart, state.position);
|
|
1716
|
+
state.position++;
|
|
1717
|
+
} else {
|
|
1718
|
+
while (ch !== 0 && !isWsOrEol(ch) && !(inFlow && isFlowIndicator(ch))) {
|
|
1719
|
+
if (ch === 33) if (!isNamed) {
|
|
1720
|
+
tagHandle = state.input.slice(suffixStart - 1, state.position + 1);
|
|
1721
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
|
|
1722
|
+
isNamed = true;
|
|
1723
|
+
suffixStart = state.position + 1;
|
|
1724
|
+
} else throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1725
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1726
|
+
}
|
|
1727
|
+
tagName = state.input.slice(suffixStart, state.position);
|
|
1728
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1729
|
+
}
|
|
1730
|
+
if (tagName && !(isVerbatim ? PATTERN_TAG_URI.test(tagName) : PATTERN_TAG_SUFFIX.test(tagName))) throwError(state, `tag name cannot contain such characters: ${tagName}`);
|
|
1731
|
+
if (!isVerbatim && tagHandle !== "!" && tagHandle !== "!!" && !HAS_OWN.call(state.tagHandlers, tagHandle)) throwError(state, `undeclared tag handle "${tagHandle}"`);
|
|
1732
|
+
props.tagStart = start;
|
|
1733
|
+
props.tagEnd = state.position;
|
|
1734
|
+
return true;
|
|
1735
|
+
}
|
|
1736
|
+
function readAnchorProperty(state, props) {
|
|
1737
|
+
if (state.input.charCodeAt(state.position) !== 38) return false;
|
|
1738
|
+
if (props.anchorStart !== NO_RANGE$1) throwError(state, "duplication of an anchor property");
|
|
1739
|
+
state.position++;
|
|
1740
|
+
const start = state.position;
|
|
1741
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
|
|
1742
|
+
if (state.position === start) throwError(state, "name of an anchor node must contain at least one character");
|
|
1743
|
+
props.anchorStart = start;
|
|
1744
|
+
props.anchorEnd = state.position;
|
|
1745
|
+
return true;
|
|
1746
|
+
}
|
|
1747
|
+
function readAlias(state, props) {
|
|
1748
|
+
if (state.input.charCodeAt(state.position) !== 42) return false;
|
|
1749
|
+
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) throwError(state, "alias node should not have any properties");
|
|
1750
|
+
state.position++;
|
|
1751
|
+
const start = state.position;
|
|
1752
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position)) && !isFlowIndicator(state.input.charCodeAt(state.position))) state.position++;
|
|
1753
|
+
if (state.position === start) throwError(state, "name of an alias node must contain at least one character");
|
|
1754
|
+
addAliasEvent(state, start, state.position);
|
|
1755
|
+
return true;
|
|
1756
|
+
}
|
|
1757
|
+
function readFlowScalarBreak(state, nodeIndent) {
|
|
1758
|
+
skipSeparationSpace(state, false);
|
|
1759
|
+
if (state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
|
|
1760
|
+
}
|
|
1761
|
+
function readSingleQuotedScalar(state, nodeIndent, props) {
|
|
1762
|
+
if (state.input.charCodeAt(state.position) !== 39) return false;
|
|
1763
|
+
state.position++;
|
|
1764
|
+
const start = state.position;
|
|
1765
|
+
let simple = true;
|
|
1766
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1767
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1768
|
+
if (ch === 39) {
|
|
1769
|
+
if (state.input.charCodeAt(state.position + 1) === 39) {
|
|
1770
|
+
simple = false;
|
|
1771
|
+
state.position += 2;
|
|
1772
|
+
continue;
|
|
1773
|
+
}
|
|
1774
|
+
const end = state.position;
|
|
1775
|
+
state.position++;
|
|
1776
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.SINGLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
|
|
1777
|
+
return true;
|
|
1778
|
+
}
|
|
1779
|
+
if (isEol(ch)) {
|
|
1780
|
+
simple = false;
|
|
1781
|
+
readFlowScalarBreak(state, nodeIndent);
|
|
1782
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1783
|
+
else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
|
|
1784
|
+
else state.position++;
|
|
1785
|
+
}
|
|
1786
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1787
|
+
}
|
|
1788
|
+
function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
1789
|
+
if (state.input.charCodeAt(state.position) !== 34) return false;
|
|
1790
|
+
state.position++;
|
|
1791
|
+
const start = state.position;
|
|
1792
|
+
let simple = true;
|
|
1793
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1794
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1795
|
+
if (ch === 34) {
|
|
1796
|
+
const end = state.position;
|
|
1797
|
+
state.position++;
|
|
1798
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.DOUBLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
|
|
1799
|
+
return true;
|
|
1800
|
+
}
|
|
1801
|
+
if (ch === 92) {
|
|
1802
|
+
simple = false;
|
|
1803
|
+
const escaped = state.input.charCodeAt(++state.position);
|
|
1804
|
+
if (isEol(escaped)) readFlowScalarBreak(state, nodeIndent);
|
|
1805
|
+
else if (isSimpleEscape(escaped)) state.position++;
|
|
1806
|
+
else {
|
|
1807
|
+
let hexLength = escapedHexLen(escaped);
|
|
1808
|
+
if (hexLength === 0) throwError(state, "unknown escape sequence");
|
|
1809
|
+
while (hexLength-- > 0) {
|
|
1810
|
+
state.position++;
|
|
1811
|
+
if (fromHexCode(state.input.charCodeAt(state.position)) < 0) throwError(state, "expected hexadecimal character");
|
|
1812
|
+
}
|
|
1813
|
+
state.position++;
|
|
1814
|
+
}
|
|
1815
|
+
} else if (isEol(ch)) {
|
|
1816
|
+
simple = false;
|
|
1817
|
+
readFlowScalarBreak(state, nodeIndent);
|
|
1818
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1819
|
+
else if (ch !== 9 && ch < 32) throwError(state, "expected valid JSON character");
|
|
1820
|
+
else state.position++;
|
|
1821
|
+
}
|
|
1822
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1823
|
+
}
|
|
1824
|
+
function readBlockScalar(state, parentIndent, props) {
|
|
1825
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1826
|
+
let chomping = CHOMPING_MODE.CLIP;
|
|
1827
|
+
let indent = -1;
|
|
1828
|
+
let detectedIndent = false;
|
|
1829
|
+
if (ch !== 124 && ch !== 62) return false;
|
|
1830
|
+
const style = ch === 124 ? SCALAR_STYLE.LITERAL_BLOCK : SCALAR_STYLE.FOLDED_BLOCK;
|
|
1831
|
+
state.position++;
|
|
1832
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1833
|
+
const current = state.input.charCodeAt(state.position);
|
|
1834
|
+
const digit = fromDecimalCode(current);
|
|
1835
|
+
if (current === 43 || current === 45) {
|
|
1836
|
+
if (chomping !== CHOMPING_MODE.CLIP) throwError(state, "repeat of a chomping mode identifier");
|
|
1837
|
+
chomping = current === 43 ? CHOMPING_MODE.KEEP : CHOMPING_MODE.STRIP;
|
|
1838
|
+
state.position++;
|
|
1839
|
+
} else if (digit >= 0) {
|
|
1840
|
+
if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1841
|
+
if (detectedIndent) throwError(state, "repeat of an indentation width identifier");
|
|
1842
|
+
indent = parentIndent + digit - 1;
|
|
1843
|
+
detectedIndent = true;
|
|
1844
|
+
state.position++;
|
|
1845
|
+
} else break;
|
|
1846
|
+
}
|
|
1847
|
+
let hadWhitespace = false;
|
|
1848
|
+
while (isWhiteSpace(state.input.charCodeAt(state.position))) {
|
|
1849
|
+
hadWhitespace = true;
|
|
1850
|
+
state.position++;
|
|
1851
|
+
}
|
|
1852
|
+
if (hadWhitespace && state.input.charCodeAt(state.position) === 35) skipUntilLineEnd(state);
|
|
1853
|
+
if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
|
|
1854
|
+
else if (state.input.charCodeAt(state.position) !== 0) throwError(state, "a line break is expected");
|
|
1855
|
+
let contentIndent = detectedIndent ? indent : -1;
|
|
1856
|
+
let maxLeadingIndent = 0;
|
|
1857
|
+
const valueStart = state.position;
|
|
1858
|
+
let valueEnd = state.position;
|
|
1859
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1860
|
+
const linePosition = state.position;
|
|
1861
|
+
let column = 0;
|
|
1862
|
+
while (state.input.charCodeAt(linePosition + column) === 32) column++;
|
|
1863
|
+
const first = state.input.charCodeAt(linePosition + column);
|
|
1864
|
+
if (first === 0) {
|
|
1865
|
+
if (contentIndent >= 0) {
|
|
1866
|
+
if (column > contentIndent) valueEnd = linePosition + column;
|
|
1867
|
+
} else if (column > 0) valueEnd = linePosition + column;
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
if (testDocumentBoundary(state)) break;
|
|
1871
|
+
if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
|
|
1872
|
+
if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
|
|
1873
|
+
if (first === 9 && column < parentIndent) {
|
|
1874
|
+
state.position = linePosition + column;
|
|
1875
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1876
|
+
}
|
|
1877
|
+
if (column < maxLeadingIndent) {
|
|
1878
|
+
state.position = linePosition + column;
|
|
1879
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
if (contentIndent === -1 && first !== 0 && !isEol(first) && column < parentIndent) {
|
|
1883
|
+
state.lineIndent = column;
|
|
1884
|
+
state.position = linePosition + column;
|
|
1885
|
+
break;
|
|
1886
|
+
}
|
|
1887
|
+
if (!detectedIndent && first !== 0 && !isEol(first) && contentIndent === -1) contentIndent = column;
|
|
1888
|
+
const requiredIndent = contentIndent === -1 ? parentIndent + 1 : contentIndent;
|
|
1889
|
+
if (first !== 0 && !isEol(first) && column < requiredIndent) {
|
|
1890
|
+
state.lineIndent = column;
|
|
1891
|
+
state.position = linePosition + column;
|
|
1892
|
+
break;
|
|
1893
|
+
}
|
|
1894
|
+
skipUntilLineEnd(state);
|
|
1895
|
+
valueEnd = state.position;
|
|
1896
|
+
if (isEol(state.input.charCodeAt(state.position))) {
|
|
1897
|
+
consumeLineBreak(state);
|
|
1898
|
+
valueEnd = state.position;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
checkPrintable(state, valueStart, valueEnd);
|
|
1902
|
+
addScalarEvent(state, valueStart, valueEnd, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, style, chomping, contentIndent);
|
|
1903
|
+
return true;
|
|
1904
|
+
}
|
|
1905
|
+
function canStartPlainScalar(state, nodeContext) {
|
|
1906
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1907
|
+
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
1908
|
+
if (ch === 0 || isWsOrEol(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96 || inFlow && isFlowIndicator(ch)) return false;
|
|
1909
|
+
if (ch === 63 || ch === 45) {
|
|
1910
|
+
const following = state.input.charCodeAt(state.position + 1);
|
|
1911
|
+
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) return false;
|
|
1912
|
+
}
|
|
1913
|
+
return true;
|
|
1914
|
+
}
|
|
1915
|
+
function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
1916
|
+
if (!canStartPlainScalar(state, nodeContext)) return false;
|
|
1917
|
+
const start = state.position;
|
|
1918
|
+
let end = state.position;
|
|
1919
|
+
let ch = state.input.charCodeAt(state.position);
|
|
1920
|
+
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
1921
|
+
let multiline = false;
|
|
1922
|
+
while (ch !== 0) {
|
|
1923
|
+
if (testDocumentBoundary(state)) break;
|
|
1924
|
+
if (ch === 58) {
|
|
1925
|
+
const following = state.input.charCodeAt(state.position + 1);
|
|
1926
|
+
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
|
|
1927
|
+
} else if (ch === 35) {
|
|
1928
|
+
if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
|
|
1929
|
+
} else if (inFlow && isFlowIndicator(ch)) break;
|
|
1930
|
+
else if (isEol(ch)) {
|
|
1931
|
+
const savedPosition = state.position;
|
|
1932
|
+
const savedLine = state.line;
|
|
1933
|
+
const savedLineStart = state.lineStart;
|
|
1934
|
+
const savedLineIndent = state.lineIndent;
|
|
1935
|
+
skipSeparationSpace(state, false);
|
|
1936
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1937
|
+
multiline = true;
|
|
1938
|
+
ch = state.input.charCodeAt(state.position);
|
|
1939
|
+
continue;
|
|
1940
|
+
}
|
|
1941
|
+
state.position = savedPosition;
|
|
1942
|
+
state.line = savedLine;
|
|
1943
|
+
state.lineStart = savedLineStart;
|
|
1944
|
+
state.lineIndent = savedLineIndent;
|
|
1945
|
+
break;
|
|
1946
|
+
}
|
|
1947
|
+
if (!isWhiteSpace(ch)) end = state.position + 1;
|
|
1948
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1949
|
+
}
|
|
1950
|
+
if (end === start) return false;
|
|
1951
|
+
checkPrintable(state, start, end);
|
|
1952
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN, CHOMPING_MODE.CLIP, -1, !multiline);
|
|
1953
|
+
return true;
|
|
1954
|
+
}
|
|
1955
|
+
function skipFlowSeparationSpace(state, nodeIndent) {
|
|
1956
|
+
const startLine = state.line;
|
|
1957
|
+
skipSeparationSpace(state, true);
|
|
1958
|
+
if (state.line > startLine && state.lineIndent < nodeIndent || state.firstTabInLine !== -1 && state.lineIndent < nodeIndent) throwError(state, "deficient indentation");
|
|
1959
|
+
}
|
|
1960
|
+
function readFlowCollection(state, nodeIndent, props) {
|
|
1961
|
+
const ch = state.input.charCodeAt(state.position);
|
|
1962
|
+
const isMapping = ch === 123;
|
|
1963
|
+
const start = state.position;
|
|
1964
|
+
let readNext = true;
|
|
1965
|
+
if (ch !== 91 && ch !== 123) return false;
|
|
1966
|
+
const terminator = isMapping ? 125 : 93;
|
|
1967
|
+
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
|
|
1968
|
+
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
|
|
1969
|
+
state.position++;
|
|
1970
|
+
while (state.input.charCodeAt(state.position) !== 0) {
|
|
1971
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
1972
|
+
let ch2 = state.input.charCodeAt(state.position);
|
|
1973
|
+
if (ch2 === terminator) {
|
|
1974
|
+
state.position++;
|
|
1975
|
+
addPopEvent(state);
|
|
1976
|
+
return true;
|
|
1977
|
+
} else if (!readNext) throwError(state, "missed comma between flow collection entries");
|
|
1978
|
+
else if (ch2 === 44) throwError(state, "expected the node content, but found ','");
|
|
1979
|
+
let isPair = false;
|
|
1980
|
+
let isExplicitPair = false;
|
|
1981
|
+
if (ch2 === 63 && isWsOrEol(state.input.charCodeAt(state.position + 1))) {
|
|
1982
|
+
isPair = isExplicitPair = true;
|
|
1983
|
+
state.position += 1;
|
|
1984
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
1985
|
+
}
|
|
1986
|
+
const entryLine = state.line;
|
|
1987
|
+
const entryStart = snapshotState(state);
|
|
1988
|
+
const keyWasRead = parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1989
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
1990
|
+
ch2 = state.input.charCodeAt(state.position);
|
|
1991
|
+
if ((isMapping || isExplicitPair || state.line === entryLine) && ch2 === 58) {
|
|
1992
|
+
isPair = true;
|
|
1993
|
+
state.position++;
|
|
1994
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
1995
|
+
if (!isMapping) {
|
|
1996
|
+
insertFlowPairMappingEvent(state, entryStart);
|
|
1997
|
+
if (!keyWasRead) addEmptyScalarEvent(state);
|
|
1998
|
+
} else if (!keyWasRead) addEmptyScalarEvent(state);
|
|
1999
|
+
if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) addEmptyScalarEvent(state);
|
|
2000
|
+
skipFlowSeparationSpace(state, nodeIndent);
|
|
2001
|
+
if (!isMapping) addPopEvent(state);
|
|
2002
|
+
} else if (isMapping && isPair) {
|
|
2003
|
+
if (!keyWasRead) addEmptyScalarEvent(state);
|
|
2004
|
+
addEmptyScalarEvent(state);
|
|
2005
|
+
} else if (isMapping) addEmptyScalarEvent(state);
|
|
2006
|
+
else if (isPair) {
|
|
2007
|
+
insertFlowPairMappingEvent(state, entryStart);
|
|
2008
|
+
if (!keyWasRead) addEmptyScalarEvent(state);
|
|
2009
|
+
addEmptyScalarEvent(state);
|
|
2010
|
+
addPopEvent(state);
|
|
2011
|
+
}
|
|
2012
|
+
ch2 = state.input.charCodeAt(state.position);
|
|
2013
|
+
if (ch2 === 44) {
|
|
2014
|
+
readNext = true;
|
|
2015
|
+
state.position++;
|
|
2016
|
+
} else readNext = false;
|
|
2017
|
+
}
|
|
2018
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
2019
|
+
}
|
|
2020
|
+
function readBlockSequence(state, nodeIndent, props) {
|
|
2021
|
+
if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
|
|
2022
|
+
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2023
|
+
while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
|
|
2024
|
+
if (state.firstTabInLine !== -1) {
|
|
2025
|
+
state.position = state.firstTabInLine;
|
|
2026
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2027
|
+
}
|
|
2028
|
+
const entryLine = state.line;
|
|
2029
|
+
state.position++;
|
|
2030
|
+
const hadBreak = skipSeparationSpace(state, true) > 0;
|
|
2031
|
+
if (state.firstTabInLine !== -1 && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
|
|
2032
|
+
if (hadBreak && state.lineIndent <= nodeIndent) addEmptyScalarEvent(state);
|
|
2033
|
+
else parseNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
2034
|
+
skipSeparationSpace(state, true);
|
|
2035
|
+
if (state.lineIndent < nodeIndent || state.position >= state.length) break;
|
|
2036
|
+
if (state.lineIndent > nodeIndent) throwError(state, "bad indentation of a sequence entry");
|
|
2037
|
+
if (state.line === entryLine && state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) throwError(state, "bad indentation of a sequence entry");
|
|
2038
|
+
}
|
|
2039
|
+
addPopEvent(state);
|
|
2040
|
+
return true;
|
|
2041
|
+
}
|
|
2042
|
+
function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
2043
|
+
let atExplicitKey = false;
|
|
2044
|
+
let detected = false;
|
|
2045
|
+
let mappingOpened = false;
|
|
2046
|
+
let pendingExplicitKey = false;
|
|
2047
|
+
if (state.firstTabInLine !== -1) return false;
|
|
2048
|
+
let ch = state.input.charCodeAt(state.position);
|
|
2049
|
+
while (ch !== 0) {
|
|
2050
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
2051
|
+
state.position = state.firstTabInLine;
|
|
2052
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
2053
|
+
}
|
|
2054
|
+
const following = state.input.charCodeAt(state.position + 1);
|
|
2055
|
+
const entryLine = state.line;
|
|
2056
|
+
if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
|
|
2057
|
+
if (!mappingOpened) {
|
|
2058
|
+
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2059
|
+
mappingOpened = true;
|
|
2060
|
+
}
|
|
2061
|
+
if (ch === 63) {
|
|
2062
|
+
if (atExplicitKey) addEmptyScalarEvent(state);
|
|
2063
|
+
detected = true;
|
|
2064
|
+
atExplicitKey = true;
|
|
2065
|
+
} else if (atExplicitKey) atExplicitKey = false;
|
|
2066
|
+
else {
|
|
2067
|
+
addEmptyScalarEvent(state);
|
|
2068
|
+
detected = true;
|
|
2069
|
+
atExplicitKey = false;
|
|
2070
|
+
}
|
|
2071
|
+
state.position += 1;
|
|
2072
|
+
pendingExplicitKey = true;
|
|
2073
|
+
} else {
|
|
2074
|
+
if (atExplicitKey) {
|
|
2075
|
+
addEmptyScalarEvent(state);
|
|
2076
|
+
atExplicitKey = false;
|
|
2077
|
+
}
|
|
2078
|
+
const beforeKey = snapshotState(state);
|
|
2079
|
+
if (!parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
|
|
2080
|
+
if (state.line === entryLine) {
|
|
2081
|
+
ch = state.input.charCodeAt(state.position);
|
|
2082
|
+
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2083
|
+
if (ch === 58) {
|
|
2084
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2085
|
+
if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2086
|
+
if (!mappingOpened) {
|
|
2087
|
+
restoreState(state, beforeKey);
|
|
2088
|
+
addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2089
|
+
mappingOpened = true;
|
|
2090
|
+
parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
|
|
2091
|
+
ch = state.input.charCodeAt(state.position);
|
|
2092
|
+
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2093
|
+
state.position++;
|
|
2094
|
+
}
|
|
2095
|
+
detected = true;
|
|
2096
|
+
atExplicitKey = false;
|
|
2097
|
+
pendingExplicitKey = false;
|
|
2098
|
+
} else if (detected) throwError(state, "expected ':' after a mapping key");
|
|
2099
|
+
else {
|
|
2100
|
+
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
|
|
2101
|
+
restoreState(state, beforeKey);
|
|
2102
|
+
return false;
|
|
2103
|
+
}
|
|
2104
|
+
return true;
|
|
2105
|
+
}
|
|
2106
|
+
} else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
2107
|
+
else {
|
|
2108
|
+
if (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1) {
|
|
2109
|
+
restoreState(state, beforeKey);
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
return true;
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
if (parseNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, pendingExplicitKey)) pendingExplicitKey = false;
|
|
2116
|
+
if (!atExplicitKey) {
|
|
2117
|
+
if (pendingExplicitKey) {
|
|
2118
|
+
addEmptyScalarEvent(state);
|
|
2119
|
+
pendingExplicitKey = false;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
skipSeparationSpace(state, true);
|
|
2123
|
+
ch = state.input.charCodeAt(state.position);
|
|
2124
|
+
if ((state.line === entryLine || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
|
|
2125
|
+
else if (state.lineIndent < nodeIndent) break;
|
|
2126
|
+
}
|
|
2127
|
+
if (!detected) return false;
|
|
2128
|
+
if (atExplicitKey) addEmptyScalarEvent(state);
|
|
2129
|
+
if (mappingOpened) addPopEvent(state);
|
|
2130
|
+
return true;
|
|
2131
|
+
}
|
|
2132
|
+
function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact, allowPropertyMapping = true) {
|
|
2133
|
+
if (state.depth >= state.maxDepth) throwError(state, `nesting exceeded maxDepth (${state.maxDepth})`);
|
|
2134
|
+
state.depth++;
|
|
2135
|
+
let indentStatus = 1;
|
|
2136
|
+
let atNewLine = false;
|
|
2137
|
+
let hasContent = false;
|
|
2138
|
+
let propertyStart = null;
|
|
2139
|
+
const props = emptyProperties();
|
|
2140
|
+
let allowBlockScalars = nodeContext === CONTEXT_BLOCK_OUT || nodeContext === CONTEXT_BLOCK_IN;
|
|
2141
|
+
let allowBlockCollections = allowBlockScalars;
|
|
2142
|
+
const allowBlockStyles = allowBlockScalars;
|
|
2143
|
+
if (allowToSeek && skipSeparationSpace(state, true)) {
|
|
2144
|
+
atNewLine = true;
|
|
2145
|
+
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
2146
|
+
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2147
|
+
else indentStatus = -1;
|
|
2148
|
+
}
|
|
2149
|
+
if (indentStatus === 1) while (true) {
|
|
2150
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2151
|
+
const propertyState = snapshotState(state);
|
|
2152
|
+
if (atNewLine && indentStatus !== 1 && (ch === 33 || ch === 38)) break;
|
|
2153
|
+
if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
|
|
2154
|
+
const fallbackState = snapshotState(state);
|
|
2155
|
+
const flowIndent = parentIndent + 1;
|
|
2156
|
+
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type === EVENT_ID.MAPPING) {
|
|
2157
|
+
state.depth--;
|
|
2158
|
+
return true;
|
|
2159
|
+
}
|
|
2160
|
+
restoreState(state, fallbackState);
|
|
2161
|
+
}
|
|
2162
|
+
if (atNewLine && (ch === 33 && props.tagStart !== NO_RANGE$1 || ch === 38 && props.anchorStart !== NO_RANGE$1)) break;
|
|
2163
|
+
if (!readTagProperty(state, props, nodeContext === CONTEXT_FLOW_IN) && !readAnchorProperty(state, props)) break;
|
|
2164
|
+
if (propertyStart === null) propertyStart = propertyState;
|
|
2165
|
+
if (skipSeparationSpace(state, true)) {
|
|
2166
|
+
atNewLine = true;
|
|
2167
|
+
allowBlockCollections = allowBlockStyles;
|
|
2168
|
+
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
2169
|
+
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2170
|
+
else indentStatus = -1;
|
|
2171
|
+
} else allowBlockCollections = false;
|
|
2172
|
+
}
|
|
2173
|
+
if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
|
|
2174
|
+
if (indentStatus === 1 || nodeContext === CONTEXT_BLOCK_OUT) {
|
|
2175
|
+
const flowIndent = nodeContext === CONTEXT_FLOW_IN || nodeContext === CONTEXT_FLOW_OUT ? parentIndent : parentIndent + 1;
|
|
2176
|
+
const blockIndent = state.position - state.lineStart;
|
|
2177
|
+
if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent, props) || readBlockMapping(state, blockIndent, flowIndent, props)) || readFlowCollection(state, flowIndent, props)) hasContent = true;
|
|
2178
|
+
else {
|
|
2179
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2180
|
+
if (propertyStart !== null && allowPropertyMapping && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62) {
|
|
2181
|
+
const fallbackState = snapshotState(state);
|
|
2182
|
+
const propertyIndent = propertyStart.position - propertyStart.lineStart;
|
|
2183
|
+
restoreState(state, propertyStart);
|
|
2184
|
+
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type === EVENT_ID.MAPPING) hasContent = true;
|
|
2185
|
+
else restoreState(state, fallbackState);
|
|
2186
|
+
}
|
|
2187
|
+
if (!hasContent && (allowBlockScalars && readBlockScalar(state, flowIndent, props) || readSingleQuotedScalar(state, flowIndent, props) || readDoubleQuotedScalar(state, flowIndent, props) || readAlias(state, props) || readPlainScalar(state, flowIndent, nodeContext, props))) hasContent = true;
|
|
2188
|
+
}
|
|
2189
|
+
else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent, props);
|
|
2190
|
+
}
|
|
2191
|
+
allowBlockScalars = allowBlockScalars && !hasContent;
|
|
2192
|
+
if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
|
|
2193
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN);
|
|
2194
|
+
hasContent = true;
|
|
2195
|
+
}
|
|
2196
|
+
state.depth--;
|
|
2197
|
+
return hasContent || props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1;
|
|
2198
|
+
}
|
|
2199
|
+
function readDirective(state) {
|
|
2200
|
+
if (state.lineIndent > 0 || state.input.charCodeAt(state.position) !== 37) return false;
|
|
2201
|
+
state.position++;
|
|
2202
|
+
const nameStart = state.position;
|
|
2203
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
|
|
2204
|
+
const name = state.input.slice(nameStart, state.position);
|
|
2205
|
+
const args = [];
|
|
2206
|
+
if (name.length === 0) throwError(state, "directive name must not be less than one character in length");
|
|
2207
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isEol(state.input.charCodeAt(state.position))) {
|
|
2208
|
+
while (isWhiteSpace(state.input.charCodeAt(state.position))) state.position++;
|
|
2209
|
+
if (state.input.charCodeAt(state.position) === 35 || isEol(state.input.charCodeAt(state.position)) || state.input.charCodeAt(state.position) === 0) break;
|
|
2210
|
+
const start = state.position;
|
|
2211
|
+
while (state.input.charCodeAt(state.position) !== 0 && !isWsOrEol(state.input.charCodeAt(state.position))) state.position++;
|
|
2212
|
+
args.push(state.input.slice(start, state.position));
|
|
2213
|
+
}
|
|
2214
|
+
if (isEol(state.input.charCodeAt(state.position))) consumeLineBreak(state);
|
|
2215
|
+
if (name === "YAML") {
|
|
2216
|
+
if (state.directives.some((directive) => directive.kind === "yaml")) throwError(state, "duplication of %YAML directive");
|
|
2217
|
+
if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
|
|
2218
|
+
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
2219
|
+
if (match === null) throwError(state, "ill-formed argument of the YAML directive");
|
|
2220
|
+
if (parseInt(match[1], 10) !== 1) throwError(state, "unacceptable YAML version of the document");
|
|
2221
|
+
state.directives.push({
|
|
2222
|
+
kind: "yaml",
|
|
2223
|
+
version: args[0]
|
|
2224
|
+
});
|
|
2225
|
+
} else if (name === "TAG") {
|
|
2226
|
+
if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
|
|
2227
|
+
const [handle, prefix] = args;
|
|
2228
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
2229
|
+
if (HAS_OWN.call(state.tagHandlers, handle)) throwError(state, `there is a previously declared suffix for "${handle}" tag handle`);
|
|
2230
|
+
if (!PATTERN_TAG_PREFIX.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
2231
|
+
state.tagHandlers[handle] = prefix;
|
|
2232
|
+
state.directives.push({
|
|
2233
|
+
kind: "tag",
|
|
2234
|
+
handle,
|
|
2235
|
+
prefix
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
return true;
|
|
2239
|
+
}
|
|
2240
|
+
function readDocument(state) {
|
|
2241
|
+
state.directives = [];
|
|
2242
|
+
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
2243
|
+
let hasDirectives = false;
|
|
2244
|
+
skipSeparationSpace(state, true);
|
|
2245
|
+
while (readDirective(state)) {
|
|
2246
|
+
hasDirectives = true;
|
|
2247
|
+
skipSeparationSpace(state, true);
|
|
2248
|
+
}
|
|
2249
|
+
let explicitStart = false;
|
|
2250
|
+
let explicitEnd = false;
|
|
2251
|
+
let allowCompact = true;
|
|
2252
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 3))) {
|
|
2253
|
+
explicitStart = true;
|
|
2254
|
+
const markerLine = state.line;
|
|
2255
|
+
state.position += 3;
|
|
2256
|
+
skipSeparationSpace(state, true);
|
|
2257
|
+
allowCompact = state.line > markerLine;
|
|
2258
|
+
} else if (hasDirectives) throwError(state, "directives end mark is expected");
|
|
2259
|
+
const documentEventIndex = state.events.length;
|
|
2260
|
+
if (!explicitStart && state.position === state.lineStart && state.input.charCodeAt(state.position) === 46 && testDocumentSeparator(state)) {
|
|
2261
|
+
state.position += 3;
|
|
2262
|
+
skipSeparationSpace(state, true);
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
addDocumentEvent(state, explicitStart, false);
|
|
2266
|
+
if (!parseNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, allowCompact, allowCompact)) addEmptyScalarEvent(state);
|
|
2267
|
+
skipSeparationSpace(state, true);
|
|
2268
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2269
|
+
explicitEnd = state.input.charCodeAt(state.position) === 46;
|
|
2270
|
+
if (explicitEnd) {
|
|
2271
|
+
const markerLine = state.line;
|
|
2272
|
+
state.position += 3;
|
|
2273
|
+
skipSeparationSpace(state, true);
|
|
2274
|
+
if (state.line === markerLine && state.position < state.length) throwError(state, "end of the stream or a document separator is expected");
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
const documentEvent = state.events[documentEventIndex];
|
|
2278
|
+
if (documentEvent?.type === EVENT_ID.DOCUMENT) documentEvent.explicitEnd = explicitEnd;
|
|
2279
|
+
addPopEvent(state);
|
|
2280
|
+
if (!explicitEnd && state.position < state.length && !testDocumentBoundary(state)) throwError(state, "end of the stream or a document separator is expected");
|
|
2281
|
+
}
|
|
2282
|
+
function parseEvents(input, options) {
|
|
2283
|
+
const length = input.length;
|
|
2284
|
+
const state = {
|
|
2285
|
+
...DEFAULT_PARSER_OPTIONS,
|
|
2286
|
+
...options,
|
|
2287
|
+
input: `${input}\0`,
|
|
2288
|
+
length,
|
|
2289
|
+
position: 0,
|
|
2290
|
+
line: 0,
|
|
2291
|
+
lineStart: 0,
|
|
2292
|
+
lineIndent: 0,
|
|
2293
|
+
firstTabInLine: -1,
|
|
2294
|
+
depth: 0,
|
|
2295
|
+
directives: [],
|
|
2296
|
+
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
2297
|
+
events: []
|
|
2298
|
+
};
|
|
2299
|
+
const nullpos = input.indexOf("\0");
|
|
2300
|
+
if (nullpos !== -1) YAMLException.throwAt(input, nullpos, "null byte is not allowed in input", state.filename);
|
|
2301
|
+
while (state.position < state.length) {
|
|
2302
|
+
skipByteOrderMark(state);
|
|
2303
|
+
skipSeparationSpace(state, true);
|
|
2304
|
+
if (state.position >= state.length) break;
|
|
2305
|
+
const documentStart = state.position;
|
|
2306
|
+
readDocument(state);
|
|
2307
|
+
if (state.position === documentStart)
|
|
2308
|
+
throwError(state, "can not read a document");
|
|
2309
|
+
}
|
|
2310
|
+
return state.events;
|
|
2311
|
+
}
|
|
2312
|
+
var DEFAULT_LOAD_OPTIONS = {
|
|
2313
|
+
...DEFAULT_PARSER_OPTIONS,
|
|
2314
|
+
...DEFAULT_CONSTRUCTOR_OPTIONS
|
|
2315
|
+
};
|
|
2316
|
+
function loadDocuments(input, options = {}) {
|
|
2317
|
+
const opts = {
|
|
2318
|
+
...DEFAULT_LOAD_OPTIONS,
|
|
2319
|
+
...options
|
|
2320
|
+
};
|
|
2321
|
+
const source = String(input);
|
|
2322
|
+
const PARSER_OPT_KEYS = Object.keys(DEFAULT_PARSER_OPTIONS);
|
|
2323
|
+
const CONSTRUCTOR_OPT_KEYS = Object.keys(DEFAULT_CONSTRUCTOR_OPTIONS);
|
|
2324
|
+
return constructFromEvents(parseEvents(source, pick(opts, PARSER_OPT_KEYS)), {
|
|
2325
|
+
...pick(opts, CONSTRUCTOR_OPT_KEYS),
|
|
2326
|
+
source
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
function load(input, options) {
|
|
2330
|
+
const documents = loadDocuments(input, options);
|
|
2331
|
+
if (documents.length === 0) throw new YAMLException("expected a document, but the input is empty");
|
|
2332
|
+
if (documents.length === 1) return documents[0];
|
|
2333
|
+
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2334
|
+
}
|
|
2335
|
+
var INVALID = /* @__PURE__ */ Symbol("INVALID");
|
|
2336
|
+
function buildRepresentTypes(schema) {
|
|
2337
|
+
const defaultTags = new Set([
|
|
2338
|
+
schema.defaultScalarTag,
|
|
2339
|
+
schema.defaultSequenceTag,
|
|
2340
|
+
schema.defaultMappingTag
|
|
2341
|
+
].filter((t) => t !== void 0));
|
|
2342
|
+
const implicitScalars = schema.implicitScalarTags;
|
|
2343
|
+
const explicitTags = schema.tags.filter((t) => !(t.nodeKind === "scalar" && t.implicit) && !defaultTags.has(t));
|
|
2344
|
+
const defaultTagsLast = schema.tags.filter((t) => defaultTags.has(t));
|
|
2345
|
+
return [
|
|
2346
|
+
...implicitScalars.map((tag) => ({
|
|
2347
|
+
tag,
|
|
2348
|
+
implicitTag: true
|
|
2349
|
+
})),
|
|
2350
|
+
...explicitTags.map((tag) => ({
|
|
2351
|
+
tag,
|
|
2352
|
+
implicitTag: false
|
|
2353
|
+
})),
|
|
2354
|
+
...defaultTagsLast.map((tag) => ({
|
|
2355
|
+
tag,
|
|
2356
|
+
implicitTag: true
|
|
2357
|
+
}))
|
|
2358
|
+
];
|
|
2359
|
+
}
|
|
2360
|
+
function matchTag(state, object) {
|
|
2361
|
+
for (let index = 0, length = state.representTypes.length; index < length; index += 1) {
|
|
2362
|
+
const { tag, implicitTag } = state.representTypes[index];
|
|
2363
|
+
if (tag.identify(object)) {
|
|
2364
|
+
let tagName;
|
|
2365
|
+
if (tag.matchByTagPrefix) tagName = tag.representTagName(object);
|
|
2366
|
+
else tagName = tag.tagName;
|
|
2367
|
+
return {
|
|
2368
|
+
tag,
|
|
2369
|
+
tagName,
|
|
2370
|
+
implicitTag
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
return null;
|
|
2375
|
+
}
|
|
2376
|
+
function build(state, object) {
|
|
2377
|
+
if (!state.noRefs && object !== null && typeof object === "object") {
|
|
2378
|
+
const existing = state.refs.get(object);
|
|
2379
|
+
if (existing) {
|
|
2380
|
+
if (existing.anchor === void 0) existing.anchor = `ref_${state.refCounter++}`;
|
|
2381
|
+
return {
|
|
2382
|
+
kind: "alias",
|
|
2383
|
+
anchor: existing.anchor
|
|
2384
|
+
};
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
const matched = matchTag(state, object);
|
|
2388
|
+
if (!matched) {
|
|
2389
|
+
if (object === void 0) return INVALID;
|
|
2390
|
+
if (state.skipInvalid) return INVALID;
|
|
2391
|
+
throw new YAMLException(`unacceptable kind of an object to dump ${Object.prototype.toString.call(object)}`);
|
|
2392
|
+
}
|
|
2393
|
+
const { tag, tagName, implicitTag } = matched;
|
|
2394
|
+
const nodeTagName = implicitTag ? tagName : tagNameShort(tagName);
|
|
2395
|
+
if (tag.nodeKind === "scalar") return {
|
|
2396
|
+
kind: "scalar",
|
|
2397
|
+
tag: nodeTagName,
|
|
2398
|
+
tagged: !implicitTag,
|
|
2399
|
+
style: SCALAR_STYLE.PLAIN,
|
|
2400
|
+
value: tag.represent(object)
|
|
2401
|
+
};
|
|
2402
|
+
if (tag.nodeKind === "sequence") {
|
|
2403
|
+
const container = tag.represent(object);
|
|
2404
|
+
const node2 = {
|
|
2405
|
+
kind: "sequence",
|
|
2406
|
+
tag: nodeTagName,
|
|
2407
|
+
tagged: !implicitTag,
|
|
2408
|
+
style: COLLECTION_STYLE.BLOCK,
|
|
2409
|
+
items: []
|
|
2410
|
+
};
|
|
2411
|
+
if (!state.noRefs) state.refs.set(object, node2);
|
|
2412
|
+
for (let index = 0, length = container.length; index < length; index += 1) {
|
|
2413
|
+
let item = build(state, container[index]);
|
|
2414
|
+
if (item === INVALID && container[index] === void 0) item = build(state, null);
|
|
2415
|
+
if (item === INVALID) continue;
|
|
2416
|
+
node2.items.push(item);
|
|
2417
|
+
}
|
|
2418
|
+
return node2;
|
|
2419
|
+
}
|
|
2420
|
+
const map = tag.represent(object);
|
|
2421
|
+
const node = {
|
|
2422
|
+
kind: "mapping",
|
|
2423
|
+
tag: nodeTagName,
|
|
2424
|
+
tagged: !implicitTag,
|
|
2425
|
+
style: COLLECTION_STYLE.BLOCK,
|
|
2426
|
+
items: []
|
|
2427
|
+
};
|
|
2428
|
+
if (!state.noRefs) state.refs.set(object, node);
|
|
2429
|
+
for (const [objectKey, objectValue] of map) {
|
|
2430
|
+
const key = build(state, objectKey);
|
|
2431
|
+
if (key === INVALID) continue;
|
|
2432
|
+
const value = build(state, objectValue);
|
|
2433
|
+
if (value === INVALID) continue;
|
|
2434
|
+
node.items.push({
|
|
2435
|
+
key,
|
|
2436
|
+
value
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2439
|
+
return node;
|
|
2440
|
+
}
|
|
2441
|
+
function jsToAst(input, schema, options = {}) {
|
|
2442
|
+
const root = build({
|
|
2443
|
+
representTypes: buildRepresentTypes(schema),
|
|
2444
|
+
noRefs: options.noRefs ?? false,
|
|
2445
|
+
skipInvalid: options.skipInvalid ?? false,
|
|
2446
|
+
refs: /* @__PURE__ */ new Map(),
|
|
2447
|
+
refCounter: 0
|
|
2448
|
+
}, input);
|
|
2449
|
+
return [{
|
|
2450
|
+
contents: root === INVALID ? null : root,
|
|
2451
|
+
directives: []
|
|
2452
|
+
}];
|
|
2453
|
+
}
|
|
2454
|
+
var VISIT_BREAK = /* @__PURE__ */ Symbol("visit:break");
|
|
2455
|
+
var VISIT_SKIP = /* @__PURE__ */ Symbol("visit:skip");
|
|
2456
|
+
function visitNode(node, visitor, ctx) {
|
|
2457
|
+
const control = visitor(node, ctx);
|
|
2458
|
+
if (control === VISIT_BREAK) return true;
|
|
2459
|
+
if (control === VISIT_SKIP) return false;
|
|
2460
|
+
const depth = ctx.depth + 1;
|
|
2461
|
+
switch (node.kind) {
|
|
2462
|
+
case "sequence":
|
|
2463
|
+
for (const item of node.items) if (visitNode(item, visitor, {
|
|
2464
|
+
depth,
|
|
2465
|
+
parent: node,
|
|
2466
|
+
isKey: false
|
|
2467
|
+
})) return true;
|
|
2468
|
+
break;
|
|
2469
|
+
case "mapping":
|
|
2470
|
+
for (const { key, value } of node.items) {
|
|
2471
|
+
if (visitNode(key, visitor, {
|
|
2472
|
+
depth,
|
|
2473
|
+
parent: node,
|
|
2474
|
+
isKey: true
|
|
2475
|
+
})) return true;
|
|
2476
|
+
if (visitNode(value, visitor, {
|
|
2477
|
+
depth,
|
|
2478
|
+
parent: node,
|
|
2479
|
+
isKey: false
|
|
2480
|
+
})) return true;
|
|
2481
|
+
}
|
|
2482
|
+
break;
|
|
2483
|
+
}
|
|
2484
|
+
return false;
|
|
2485
|
+
}
|
|
2486
|
+
function visit(documents, visitor) {
|
|
2487
|
+
for (const doc of documents) if (doc.contents && visitNode(doc.contents, visitor, {
|
|
2488
|
+
depth: 0,
|
|
2489
|
+
parent: null,
|
|
2490
|
+
isKey: false
|
|
2491
|
+
})) return;
|
|
2492
|
+
}
|
|
2493
|
+
function hasBit(mask, bit) {
|
|
2494
|
+
return (mask & 1 << bit) !== 0;
|
|
2495
|
+
}
|
|
2496
|
+
var DEFAULT_SCALAR_STYLE_RULES = {
|
|
2497
|
+
applyQuoteFlowKeysOption,
|
|
2498
|
+
doubleQuoteForInvisibles,
|
|
2499
|
+
doubleQuoteWhitespaceOnly,
|
|
2500
|
+
applyForceQuotesOption,
|
|
2501
|
+
tryLongOrMultilineAsBlock,
|
|
2502
|
+
quoteInvalidPlain,
|
|
2503
|
+
fallbackToDoubleQuoted
|
|
2504
|
+
};
|
|
2505
|
+
function _preferredQuotedStyle(layout) {
|
|
2506
|
+
if (layout.presenterOptions.quoteStyle === "single" && hasBit(layout.allowedStylesMask, SCALAR_STYLE.SINGLE_QUOTED)) return SCALAR_STYLE.SINGLE_QUOTED;
|
|
2507
|
+
return SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2508
|
+
}
|
|
2509
|
+
function applyQuoteFlowKeysOption(layout) {
|
|
2510
|
+
if (!layout.presenterOptions.quoteFlowKeys) return;
|
|
2511
|
+
if (!layout.isKey || !layout.flowOnly || layout.style !== SCALAR_STYLE.PLAIN) return;
|
|
2512
|
+
layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2513
|
+
}
|
|
2514
|
+
function doubleQuoteForInvisibles(layout) {
|
|
2515
|
+
if (layout.style === SCALAR_STYLE.PLAIN && /[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2516
|
+
}
|
|
2517
|
+
function doubleQuoteWhitespaceOnly(layout) {
|
|
2518
|
+
if (layout.style === SCALAR_STYLE.PLAIN && /^\s+$/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2519
|
+
}
|
|
2520
|
+
function applyForceQuotesOption(layout) {
|
|
2521
|
+
if (!layout.presenterOptions.forceQuotes) return;
|
|
2522
|
+
if (layout.isKey || layout.style !== SCALAR_STYLE.PLAIN) return;
|
|
2523
|
+
if (layout.node.tag !== layout.presenterOptions.schema.defaultScalarTag.tagName) return;
|
|
2524
|
+
layout.style = layout.node.value.includes("\n") ? SCALAR_STYLE.DOUBLE_QUOTED : _preferredQuotedStyle(layout);
|
|
2525
|
+
}
|
|
2526
|
+
function tryLongOrMultilineAsBlock(layout) {
|
|
2527
|
+
if (layout.style !== SCALAR_STYLE.PLAIN || layout.isKey) return;
|
|
2528
|
+
const value = layout.node.value;
|
|
2529
|
+
const multiline = value.indexOf("\n") !== -1;
|
|
2530
|
+
if (!hasBit(layout.allowedStylesMask, SCALAR_STYLE.LITERAL_BLOCK)) {
|
|
2531
|
+
if (multiline) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2534
|
+
const w = layout.presenterOptions.lineWidth;
|
|
2535
|
+
if (w === -1) {
|
|
2536
|
+
if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2537
|
+
return;
|
|
2538
|
+
}
|
|
2539
|
+
const availableWidth = Math.max(Math.min(w, 40), w - layout.shiftOfContent);
|
|
2540
|
+
let position = 0;
|
|
2541
|
+
let shouldFold = false;
|
|
2542
|
+
while (position <= value.length) {
|
|
2543
|
+
let lineEnd = value.length;
|
|
2544
|
+
const nextLineBreak = value.indexOf("\n", position);
|
|
2545
|
+
if (nextLineBreak !== -1) lineEnd = nextLineBreak;
|
|
2546
|
+
const line = value.slice(position, lineEnd);
|
|
2547
|
+
if (line.length > availableWidth && line[0] !== " " && / [^ \t]/.test(line)) shouldFold = true;
|
|
2548
|
+
if (nextLineBreak === -1) break;
|
|
2549
|
+
position = nextLineBreak + 1;
|
|
2550
|
+
}
|
|
2551
|
+
if (shouldFold) layout.style = SCALAR_STYLE.FOLDED_BLOCK;
|
|
2552
|
+
else if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2553
|
+
}
|
|
2554
|
+
function quoteInvalidPlain(layout) {
|
|
2555
|
+
if (layout.style === SCALAR_STYLE.PLAIN && !hasBit(layout.allowedStylesMask, SCALAR_STYLE.PLAIN)) layout.style = _preferredQuotedStyle(layout);
|
|
2556
|
+
}
|
|
2557
|
+
function fallbackToDoubleQuoted(layout) {
|
|
2558
|
+
if (!hasBit(layout.allowedStylesMask, layout.style)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2559
|
+
}
|
|
2560
|
+
function setBit(mask, bit) {
|
|
2561
|
+
return mask | 1 << bit;
|
|
2562
|
+
}
|
|
2563
|
+
var SRC_C_PRINTABLE = "[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]";
|
|
2564
|
+
var SRC_B_CHAR = "[\\n\\r]";
|
|
2565
|
+
var SRC_C_BYTE_ORDER_MARK = "\\uFEFF";
|
|
2566
|
+
var SRC_S_WHITE = "[ \\t]";
|
|
2567
|
+
var SRC_NB_CHAR = `(?:(?!(?:${SRC_B_CHAR}|${SRC_C_BYTE_ORDER_MARK}))${SRC_C_PRINTABLE})`;
|
|
2568
|
+
var SRC_NS_CHAR = `(?:(?!${SRC_S_WHITE})${SRC_NB_CHAR})`;
|
|
2569
|
+
var SRC_NB_JSON = "[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]";
|
|
2570
|
+
var SRC_C_INDICATOR = "[-?:,\\[\\]{}#&*!|>'\"%@`]";
|
|
2571
|
+
var SRC_C_FLOW_INDICATOR = "[,\\[\\]{}]";
|
|
2572
|
+
var SRC_NS_PLAIN_SAFE_FLOW_OUT = SRC_NS_CHAR;
|
|
2573
|
+
var SRC_NS_PLAIN_SAFE_FLOW_IN = `(?:(?!${SRC_C_FLOW_INDICATOR})${SRC_NS_CHAR})`;
|
|
2574
|
+
var SRC_NS_PLAIN_FIRST_FLOW_OUT = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))`;
|
|
2575
|
+
var SRC_NS_PLAIN_FIRST_FLOW_IN = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))`;
|
|
2576
|
+
var SRC_NS_PLAIN_CHAR_FLOW_OUT = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_OUT})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))#*`;
|
|
2577
|
+
var SRC_NS_PLAIN_CHAR_FLOW_IN = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_IN})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))#*`;
|
|
2578
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_OUT})*`;
|
|
2579
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_IN})*`;
|
|
2580
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_OUT = `${SRC_NS_PLAIN_FIRST_FLOW_OUT}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
2581
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_IN = `${SRC_NS_PLAIN_FIRST_FLOW_IN}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
2582
|
+
var SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_OUT;
|
|
2583
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_IN;
|
|
2584
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_OUT}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
2585
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_IN}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
2586
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT = `${SRC_NS_PLAIN_ONE_LINE_FLOW_OUT}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT})*`;
|
|
2587
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_IN = `${SRC_NS_PLAIN_ONE_LINE_FLOW_IN}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN})*`;
|
|
2588
|
+
var NS_PLAIN_FLOW_OUT = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT})$`, "u");
|
|
2589
|
+
var NS_PLAIN_FLOW_IN = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_IN})$`, "u");
|
|
2590
|
+
var NS_PLAIN_BLOCK_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY})$`, "u");
|
|
2591
|
+
var NS_PLAIN_FLOW_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_FLOW_KEY})$`, "u");
|
|
2592
|
+
var NB_SINGLE_ONE_LINE = new RegExp(`^(?:${SRC_NB_JSON})*$`, "u");
|
|
2593
|
+
var NB_SINGLE_MULTI_LINE = new RegExp(`^(?:${SRC_NB_JSON}|\\n)*$`, "u");
|
|
2594
|
+
var BLOCK_SCALAR_CONTENT = new RegExp(`^(?:${SRC_NB_CHAR}|\\n)*$`, "u");
|
|
2595
|
+
var C_FORBIDDEN_FIRST_LINE = /^(?:---|\.\.\.)(?=$|[ \t\n\r])/;
|
|
2596
|
+
var C_FORBIDDEN_CONTENT = /^(?:---|\.\.\.)(?=$|[ \t\n\r])/m;
|
|
2597
|
+
function canUsePlain(layout) {
|
|
2598
|
+
const str = layout.node.value;
|
|
2599
|
+
if (str !== "") {
|
|
2600
|
+
if (!(layout.isKey ? layout.flowOnly ? NS_PLAIN_FLOW_KEY : NS_PLAIN_BLOCK_KEY : layout.flowOnly ? NS_PLAIN_FLOW_IN : NS_PLAIN_FLOW_OUT).test(str)) return false;
|
|
2601
|
+
if (layout.shiftOfFirstLine === 0 && C_FORBIDDEN_FIRST_LINE.test(str)) return false;
|
|
2602
|
+
if (layout.shiftOfContent === 0) {
|
|
2603
|
+
const firstLineBreak = str.indexOf("\n");
|
|
2604
|
+
if (firstLineBreak !== -1) {
|
|
2605
|
+
const content = str.slice(firstLineBreak + 1);
|
|
2606
|
+
if (C_FORBIDDEN_CONTENT.test(content)) return false;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
const resolvedTag = layout.presenterOptions.schema.resolveImplicitScalarTag(str).tag.tagName;
|
|
2611
|
+
if (!layout.node.tagged && resolvedTag !== layout.node.tag) return false;
|
|
2612
|
+
if (!layout.node.tagged && str === "=" && resolvedTag === layout.presenterOptions.schema.defaultScalarTag.tagName) return false;
|
|
2613
|
+
return true;
|
|
2614
|
+
}
|
|
2615
|
+
function canUseSingleQuoted(layout) {
|
|
2616
|
+
const str = layout.node.value;
|
|
2617
|
+
if (!(layout.isKey ? NB_SINGLE_ONE_LINE : NB_SINGLE_MULTI_LINE).test(str)) return false;
|
|
2618
|
+
if (/[ \t]\n|\n[ \t]/.test(str)) return false;
|
|
2619
|
+
if (!layout.isKey && layout.shiftOfContent === 0) {
|
|
2620
|
+
const firstLineBreak = str.indexOf("\n");
|
|
2621
|
+
if (firstLineBreak !== -1 && C_FORBIDDEN_CONTENT.test(str.slice(firstLineBreak + 1))) return false;
|
|
2622
|
+
}
|
|
2623
|
+
return true;
|
|
2624
|
+
}
|
|
2625
|
+
function canUseBlock(layout) {
|
|
2626
|
+
if (layout.flowOnly || !BLOCK_SCALAR_CONTENT.test(layout.node.value)) return false;
|
|
2627
|
+
const contentIndent = layout.shiftOfContent - layout.shiftOfParent;
|
|
2628
|
+
if (contentIndent < 1) return false;
|
|
2629
|
+
if (contentIndent > 9 && /^\n* /.test(layout.node.value)) return false;
|
|
2630
|
+
if (layout.shiftOfContent === 0 && C_FORBIDDEN_CONTENT.test(layout.node.value)) return false;
|
|
2631
|
+
return true;
|
|
2632
|
+
}
|
|
2633
|
+
function detectAllowedStyles(layout) {
|
|
2634
|
+
let mask = setBit(0, SCALAR_STYLE.DOUBLE_QUOTED);
|
|
2635
|
+
if (canUsePlain(layout)) mask = setBit(mask, SCALAR_STYLE.PLAIN);
|
|
2636
|
+
if (canUseSingleQuoted(layout)) mask = setBit(mask, SCALAR_STYLE.SINGLE_QUOTED);
|
|
2637
|
+
if (canUseBlock(layout)) mask = setBit(setBit(mask, SCALAR_STYLE.LITERAL_BLOCK), SCALAR_STYLE.FOLDED_BLOCK);
|
|
2638
|
+
layout.allowedStylesMask = mask;
|
|
2639
|
+
}
|
|
2640
|
+
function renderScalar(layout) {
|
|
2641
|
+
switch (layout.style) {
|
|
2642
|
+
case SCALAR_STYLE.PLAIN:
|
|
2643
|
+
return renderPlain(layout);
|
|
2644
|
+
case SCALAR_STYLE.SINGLE_QUOTED:
|
|
2645
|
+
return renderSingleQuoted(layout);
|
|
2646
|
+
case SCALAR_STYLE.LITERAL_BLOCK:
|
|
2647
|
+
return renderLiteralBlock(layout);
|
|
2648
|
+
case SCALAR_STYLE.FOLDED_BLOCK:
|
|
2649
|
+
return renderFoldedBlock(layout);
|
|
2650
|
+
case SCALAR_STYLE.DOUBLE_QUOTED:
|
|
2651
|
+
return renderDoubleQuoted(layout);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
function renderPlain(layout) {
|
|
2655
|
+
return encodeFlowBreaks(layout.node.value, layout.shiftOfContent);
|
|
2656
|
+
}
|
|
2657
|
+
function renderSingleQuoted(layout) {
|
|
2658
|
+
return `'${encodeFlowBreaks(layout.node.value, layout.shiftOfContent).replace(/'/g, "''")}'`;
|
|
2659
|
+
}
|
|
2660
|
+
function renderLiteralBlock(layout) {
|
|
2661
|
+
const value = layout.node.value;
|
|
2662
|
+
return "|" + blockHeader(value, layout.shiftOfParent, layout.shiftOfContent) + dropEndingNewline(indentString(value, layout.shiftOfContent));
|
|
2663
|
+
}
|
|
2664
|
+
function renderFoldedBlock(layout) {
|
|
2665
|
+
const value = layout.node.value;
|
|
2666
|
+
const w = layout.presenterOptions.lineWidth;
|
|
2667
|
+
let availableWidth = Infinity;
|
|
2668
|
+
if (w !== -1) availableWidth = Math.max(Math.min(w, 40), w - layout.shiftOfContent);
|
|
2669
|
+
return ">" + blockHeader(value, layout.shiftOfParent, layout.shiftOfContent) + dropEndingNewline(indentString(foldBlockScalar(value, availableWidth), layout.shiftOfContent));
|
|
2670
|
+
}
|
|
2671
|
+
function renderDoubleQuoted(layout) {
|
|
2672
|
+
return `"${escapeString(layout.node.value)}"`;
|
|
2673
|
+
}
|
|
2674
|
+
function encodeFlowBreaks(string, shiftOfContent) {
|
|
2675
|
+
let nextLF = string.indexOf("\n");
|
|
2676
|
+
if (nextLF === -1) return string;
|
|
2677
|
+
const pad = " ".repeat(shiftOfContent);
|
|
2678
|
+
let result = string.slice(0, nextLF);
|
|
2679
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
|
2680
|
+
lineRe.lastIndex = nextLF;
|
|
2681
|
+
let match;
|
|
2682
|
+
while (match = lineRe.exec(string)) {
|
|
2683
|
+
const breaks = match[1].length;
|
|
2684
|
+
const line = match[2];
|
|
2685
|
+
result += "\n".repeat(breaks + 1) + pad + line;
|
|
2686
|
+
}
|
|
2687
|
+
return result;
|
|
2688
|
+
}
|
|
2689
|
+
function indentString(string, spaces) {
|
|
2690
|
+
const indent = " ".repeat(spaces);
|
|
2691
|
+
let position = 0;
|
|
2692
|
+
let result = "";
|
|
2693
|
+
const length = string.length;
|
|
2694
|
+
while (position < length) {
|
|
2695
|
+
let line;
|
|
2696
|
+
const next = string.indexOf("\n", position);
|
|
2697
|
+
if (next === -1) {
|
|
2698
|
+
line = string.slice(position);
|
|
2699
|
+
position = length;
|
|
2700
|
+
} else {
|
|
2701
|
+
line = string.slice(position, next + 1);
|
|
2702
|
+
position = next + 1;
|
|
2703
|
+
}
|
|
2704
|
+
if (line.length && line !== "\n") result += indent;
|
|
2705
|
+
result += line;
|
|
2706
|
+
}
|
|
2707
|
+
return result;
|
|
2708
|
+
}
|
|
2709
|
+
function needIndentIndicator(string) {
|
|
2710
|
+
return /^\n* /.test(string);
|
|
2711
|
+
}
|
|
2712
|
+
function blockHeader(string, shiftOfParent, shiftOfContent) {
|
|
2713
|
+
const indentIndicator = needIndentIndicator(string) ? String(shiftOfContent - shiftOfParent) : "";
|
|
2714
|
+
const clip = string[string.length - 1] === "\n";
|
|
2715
|
+
return `${indentIndicator}${clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-"}
|
|
2716
|
+
`;
|
|
2717
|
+
}
|
|
2718
|
+
function dropEndingNewline(string) {
|
|
2719
|
+
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2720
|
+
}
|
|
2721
|
+
function isMoreIndented(char) {
|
|
2722
|
+
return char === " " || char === " ";
|
|
2723
|
+
}
|
|
2724
|
+
function foldLine(line, width) {
|
|
2725
|
+
if (line === "" || isMoreIndented(line[0])) return line;
|
|
2726
|
+
const breakRe = / [^ \t]/g;
|
|
2727
|
+
let match;
|
|
2728
|
+
let start = 0;
|
|
2729
|
+
let end;
|
|
2730
|
+
let curr = 0;
|
|
2731
|
+
let next = 0;
|
|
2732
|
+
let result = "";
|
|
2733
|
+
while (match = breakRe.exec(line)) {
|
|
2734
|
+
next = match.index;
|
|
2735
|
+
if (next - start > width) {
|
|
2736
|
+
end = curr > start ? curr : next;
|
|
2737
|
+
result += `
|
|
2738
|
+
${line.slice(start, end)}`;
|
|
2739
|
+
start = end + 1;
|
|
2740
|
+
}
|
|
2741
|
+
curr = next;
|
|
2742
|
+
}
|
|
2743
|
+
result += "\n";
|
|
2744
|
+
if (line.length - start > width && curr > start) result += `${line.slice(start, curr)}
|
|
2745
|
+
${line.slice(curr + 1)}`;
|
|
2746
|
+
else result += line.slice(start);
|
|
2747
|
+
return result.slice(1);
|
|
2748
|
+
}
|
|
2749
|
+
function foldBlockScalar(string, width) {
|
|
2750
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
|
2751
|
+
let nextLF = string.indexOf("\n");
|
|
2752
|
+
if (nextLF === -1) nextLF = string.length;
|
|
2753
|
+
lineRe.lastIndex = nextLF;
|
|
2754
|
+
let result = foldLine(string.slice(0, nextLF), width);
|
|
2755
|
+
let prevMoreIndented = string[0] === "\n" || isMoreIndented(string[0]);
|
|
2756
|
+
let moreIndented;
|
|
2757
|
+
let match;
|
|
2758
|
+
while (match = lineRe.exec(string)) {
|
|
2759
|
+
const prefix = match[1];
|
|
2760
|
+
const line = match[2];
|
|
2761
|
+
moreIndented = line !== "" && isMoreIndented(line[0]);
|
|
2762
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2763
|
+
prevMoreIndented = moreIndented;
|
|
2764
|
+
}
|
|
2765
|
+
return result;
|
|
2766
|
+
}
|
|
2767
|
+
var CHARACTERS_TO_ESCAPE = /["\\\x00-\x1F\x7F-\xA0\u2028\u2029\uD800-\uDFFF\uFEFF\uFFFE\uFFFF]/gu;
|
|
2768
|
+
function escapeCharacter(character) {
|
|
2769
|
+
switch (character) {
|
|
2770
|
+
case "\0":
|
|
2771
|
+
return "\\0";
|
|
2772
|
+
case "\x07":
|
|
2773
|
+
return "\\a";
|
|
2774
|
+
case "\b":
|
|
2775
|
+
return "\\b";
|
|
2776
|
+
case " ":
|
|
2777
|
+
return "\\t";
|
|
2778
|
+
case "\n":
|
|
2779
|
+
return "\\n";
|
|
2780
|
+
case "\v":
|
|
2781
|
+
return "\\v";
|
|
2782
|
+
case "\f":
|
|
2783
|
+
return "\\f";
|
|
2784
|
+
case "\r":
|
|
2785
|
+
return "\\r";
|
|
2786
|
+
case "\x1B":
|
|
2787
|
+
return "\\e";
|
|
2788
|
+
case '"':
|
|
2789
|
+
return '\\"';
|
|
2790
|
+
case "\\":
|
|
2791
|
+
return "\\\\";
|
|
2792
|
+
case "\x85":
|
|
2793
|
+
return "\\N";
|
|
2794
|
+
case "\xA0":
|
|
2795
|
+
return "\\_";
|
|
2796
|
+
case "\u2028":
|
|
2797
|
+
return "\\L";
|
|
2798
|
+
case "\u2029":
|
|
2799
|
+
return "\\P";
|
|
2800
|
+
}
|
|
2801
|
+
const code = character.charCodeAt(0);
|
|
2802
|
+
const hex = code.toString(16).toUpperCase();
|
|
2803
|
+
if (code <= 255) return `\\x${"0".repeat(2 - hex.length)}${hex}`;
|
|
2804
|
+
return `\\u${"0".repeat(4 - hex.length)}${hex}`;
|
|
2805
|
+
}
|
|
2806
|
+
function escapeString(string) {
|
|
2807
|
+
return string.replace(CHARACTERS_TO_ESCAPE, escapeCharacter);
|
|
2808
|
+
}
|
|
2809
|
+
var CHAR_LINE_FEED = 10;
|
|
2810
|
+
var DEFAULT_PRESENTER_OPTIONS = {
|
|
2811
|
+
indent: 2,
|
|
2812
|
+
seqNoIndent: false,
|
|
2813
|
+
seqInlineFirst: true,
|
|
2814
|
+
lineWidth: 80,
|
|
2815
|
+
flowBracketPadding: false,
|
|
2816
|
+
flowSkipCommaSpace: false,
|
|
2817
|
+
flowSkipColonSpace: false,
|
|
2818
|
+
quoteFlowKeys: false,
|
|
2819
|
+
quoteStyle: "single",
|
|
2820
|
+
forceQuotes: false,
|
|
2821
|
+
scalarStyleRules: Object.keys(DEFAULT_SCALAR_STYLE_RULES).map((name) => Reflect.get(DEFAULT_SCALAR_STYLE_RULES, name)),
|
|
2822
|
+
tagBeforeAnchor: false
|
|
2823
|
+
};
|
|
2824
|
+
function nodeTagShort(node) {
|
|
2825
|
+
return node.tagged ? node.tag : tagNameShort(node.tag);
|
|
2826
|
+
}
|
|
2827
|
+
function createPresenterState(options) {
|
|
2828
|
+
const opts = {
|
|
2829
|
+
...DEFAULT_PRESENTER_OPTIONS,
|
|
2830
|
+
...options
|
|
2831
|
+
};
|
|
2832
|
+
if (opts.flowSkipColonSpace) opts.quoteFlowKeys = true;
|
|
2833
|
+
return {
|
|
2834
|
+
...opts,
|
|
2835
|
+
defaultScalarTagName: opts.schema.defaultScalarTag.tagName,
|
|
2836
|
+
openEnded: false
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
function generateNextLine(state, level) {
|
|
2840
|
+
return `
|
|
2841
|
+
${" ".repeat(state.indent * level)}`;
|
|
2842
|
+
}
|
|
2843
|
+
function scalarLayout(state, node, parent, level, isKey, flowOnly) {
|
|
2844
|
+
return {
|
|
2845
|
+
node,
|
|
2846
|
+
parent,
|
|
2847
|
+
level,
|
|
2848
|
+
isKey,
|
|
2849
|
+
flowOnly,
|
|
2850
|
+
shiftOfParent: level === 0 ? -1 : state.indent * (level - 1),
|
|
2851
|
+
shiftOfContent: state.indent * Math.max(1, level),
|
|
2852
|
+
shiftOfFirstLine: level === 0 ? 0 : state.indent * level,
|
|
2853
|
+
presenterOptions: state,
|
|
2854
|
+
allowedStylesMask: 0,
|
|
2855
|
+
style: node.style
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
function writeFlowSequence(state, level, node) {
|
|
2859
|
+
let result = "";
|
|
2860
|
+
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
2861
|
+
const item = writeNode(state, level, node.items[index], node, {}).text;
|
|
2862
|
+
if (index > 0) result += `,${!state.flowSkipCommaSpace ? " " : ""}`;
|
|
2863
|
+
result += item;
|
|
2864
|
+
}
|
|
2865
|
+
const pad = state.flowBracketPadding && node.items.length > 0 ? " " : "";
|
|
2866
|
+
return `[${pad}${result}${pad}]`;
|
|
2867
|
+
}
|
|
2868
|
+
function writeBlockSequence(state, level, node, compact) {
|
|
2869
|
+
let result = "";
|
|
2870
|
+
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
2871
|
+
const item = writeNode(state, level + 1, node.items[index], node, {
|
|
2872
|
+
block: true,
|
|
2873
|
+
compact: state.seqInlineFirst,
|
|
2874
|
+
isblockseq: true
|
|
2875
|
+
}).text;
|
|
2876
|
+
if (!compact || result !== "") result += generateNextLine(state, level);
|
|
2877
|
+
if (item === "" || CHAR_LINE_FEED === item.charCodeAt(0)) result += "-";
|
|
2878
|
+
else result += "- ";
|
|
2879
|
+
result += item;
|
|
2880
|
+
}
|
|
2881
|
+
return result;
|
|
2882
|
+
}
|
|
2883
|
+
function writeFlowMapping(state, level, node) {
|
|
2884
|
+
let result = "";
|
|
2885
|
+
for (const { key, value } of node.items) {
|
|
2886
|
+
let pairBuffer = "";
|
|
2887
|
+
if (result !== "") pairBuffer += `,${!state.flowSkipCommaSpace ? " " : ""}`;
|
|
2888
|
+
const keyRender = writeNode(state, level, key, node, { iskey: true });
|
|
2889
|
+
const keyText = keyRender.text;
|
|
2890
|
+
const valueText = writeNode(state, level, value, node, {}).text;
|
|
2891
|
+
const sep = state.flowSkipColonSpace || valueText === "" ? "" : " ";
|
|
2892
|
+
const keyIsBareProps = key.kind === "scalar" && keyRender.noBody && (key.tagged || key.anchor !== void 0);
|
|
2893
|
+
const keyColonSep = key.kind === "alias" || keyIsBareProps ? " " : "";
|
|
2894
|
+
pairBuffer += `${keyText}${keyColonSep}:${sep}${valueText}`;
|
|
2895
|
+
result += pairBuffer;
|
|
2896
|
+
}
|
|
2897
|
+
const pad = state.flowBracketPadding && result !== "" ? " " : "";
|
|
2898
|
+
return `{${pad}${result}${pad}}`;
|
|
2899
|
+
}
|
|
2900
|
+
function writeBlockMapping(state, level, node, compact) {
|
|
2901
|
+
let result = "";
|
|
2902
|
+
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
2903
|
+
let pairBuffer = "";
|
|
2904
|
+
if (!compact || result !== "") pairBuffer += generateNextLine(state, level);
|
|
2905
|
+
const { key, value } = node.items[index];
|
|
2906
|
+
const keyIsBlock = (key.kind === "mapping" || key.kind === "sequence") && key.style === COLLECTION_STYLE.BLOCK && key.items.length !== 0 || key.kind === "scalar" && (key.style === SCALAR_STYLE.LITERAL_BLOCK || key.style === SCALAR_STYLE.FOLDED_BLOCK);
|
|
2907
|
+
const keyRender = keyIsBlock ? writeNode(state, level + 1, key, node, {
|
|
2908
|
+
block: true,
|
|
2909
|
+
compact: true,
|
|
2910
|
+
isblockseq: !cannotBeCompact(state, key, level + 1)
|
|
2911
|
+
}) : writeNode(state, level + 1, key, node, {
|
|
2912
|
+
block: true,
|
|
2913
|
+
compact: true,
|
|
2914
|
+
iskey: true
|
|
2915
|
+
});
|
|
2916
|
+
const keyText = keyRender.text;
|
|
2917
|
+
const keyHasLineBreak = key.kind === "scalar" && key.value.indexOf("\n") !== -1;
|
|
2918
|
+
const keyIsTooLong = keyText.length > 1024 && /^[\s\S]{1025}/u.test(keyText);
|
|
2919
|
+
const explicitPair = keyIsBlock || keyHasLineBreak || keyIsTooLong;
|
|
2920
|
+
if (explicitPair) if (keyText && CHAR_LINE_FEED === keyText.charCodeAt(0)) pairBuffer += "?";
|
|
2921
|
+
else pairBuffer += "? ";
|
|
2922
|
+
pairBuffer += keyText;
|
|
2923
|
+
if (explicitPair) pairBuffer += generateNextLine(state, level);
|
|
2924
|
+
const valueText = writeNode(state, level + 1, value, node, {
|
|
2925
|
+
block: true,
|
|
2926
|
+
compact: explicitPair,
|
|
2927
|
+
isblockseq: explicitPair && !cannotBeCompact(state, value, level + 1)
|
|
2928
|
+
}).text;
|
|
2929
|
+
const keyIsBareProps = key.kind === "scalar" && keyRender.noBody && (key.tagged || key.anchor !== void 0);
|
|
2930
|
+
const keyColonSep = !explicitPair && (key.kind === "alias" || keyIsBareProps) ? " " : "";
|
|
2931
|
+
if (valueText === "" || CHAR_LINE_FEED === valueText.charCodeAt(0)) pairBuffer += `${keyColonSep}:`;
|
|
2932
|
+
else pairBuffer += `${keyColonSep}: `;
|
|
2933
|
+
pairBuffer += valueText;
|
|
2934
|
+
result += pairBuffer;
|
|
2935
|
+
}
|
|
2936
|
+
return result;
|
|
2937
|
+
}
|
|
2938
|
+
function cannotBeCompact(state, node, level) {
|
|
2939
|
+
if (node.kind === "alias") return true;
|
|
2940
|
+
return node.tagged || node.anchor !== void 0 || state.indent < 2 && level > 0;
|
|
2941
|
+
}
|
|
2942
|
+
function writeNode(state, level, node, parent, ctx) {
|
|
2943
|
+
if (node.kind === "alias") {
|
|
2944
|
+
state.openEnded = false;
|
|
2945
|
+
return {
|
|
2946
|
+
text: `*${node.anchor}`,
|
|
2947
|
+
noBody: false
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
const { block = false, iskey = false, isblockseq = false } = ctx;
|
|
2951
|
+
let compact = ctx.compact ?? false;
|
|
2952
|
+
const hasAnchor = node.anchor !== void 0;
|
|
2953
|
+
if (cannotBeCompact(state, node, level)) compact = false;
|
|
2954
|
+
let body;
|
|
2955
|
+
let shouldPrintTag = node.tagged;
|
|
2956
|
+
const useBlockCollection = block && (node.kind === "mapping" || node.kind === "sequence") && node.style === COLLECTION_STYLE.BLOCK && node.items.length !== 0;
|
|
2957
|
+
if (node.kind === "mapping") if (useBlockCollection) body = writeBlockMapping(state, level, node, compact);
|
|
2958
|
+
else body = writeFlowMapping(state, level, node);
|
|
2959
|
+
else if (node.kind === "sequence") if (useBlockCollection) if (state.seqNoIndent && !isblockseq && level > 0) body = writeBlockSequence(state, level - 1, node, compact);
|
|
2960
|
+
else body = writeBlockSequence(state, level, node, compact);
|
|
2961
|
+
else body = writeFlowSequence(state, level, node);
|
|
2962
|
+
else {
|
|
2963
|
+
const layout = scalarLayout(state, node, parent, level, iskey, !block);
|
|
2964
|
+
detectAllowedStyles(layout);
|
|
2965
|
+
for (const rule of state.scalarStyleRules) rule(layout);
|
|
2966
|
+
body = renderScalar(layout);
|
|
2967
|
+
state.openEnded = (layout.style === SCALAR_STYLE.LITERAL_BLOCK || layout.style === SCALAR_STYLE.FOLDED_BLOCK) && (node.value === "\n" || node.value.endsWith("\n\n"));
|
|
2968
|
+
shouldPrintTag = node.tagged || body === "" && layout.flowOnly && parent?.kind === "sequence" && !hasAnchor || layout.style !== SCALAR_STYLE.PLAIN && node.tag !== state.defaultScalarTagName;
|
|
2969
|
+
}
|
|
2970
|
+
if ((node.kind === "mapping" || node.kind === "sequence") && !useBlockCollection) state.openEnded = false;
|
|
2971
|
+
if (useBlockCollection && compact && level > 0 && state.indent > 2) body = `${" ".repeat(state.indent - 2)}${body}`;
|
|
2972
|
+
const noBody = body === "";
|
|
2973
|
+
let text = body;
|
|
2974
|
+
if (shouldPrintTag || hasAnchor) {
|
|
2975
|
+
const props = [];
|
|
2976
|
+
const tag = shouldPrintTag ? nodeTagShort(node) : null;
|
|
2977
|
+
const anchor = hasAnchor ? `&${node.anchor}` : null;
|
|
2978
|
+
if (state.tagBeforeAnchor) {
|
|
2979
|
+
if (tag !== null) props.push(tag);
|
|
2980
|
+
if (anchor !== null) props.push(anchor);
|
|
2981
|
+
} else {
|
|
2982
|
+
if (anchor !== null) props.push(anchor);
|
|
2983
|
+
if (tag !== null) props.push(tag);
|
|
2984
|
+
}
|
|
2985
|
+
const sep = body === "" || body.charCodeAt(0) === CHAR_LINE_FEED ? "" : " ";
|
|
2986
|
+
text = `${props.join(" ")}${sep}${body}`;
|
|
2987
|
+
}
|
|
2988
|
+
return {
|
|
2989
|
+
text,
|
|
2990
|
+
noBody
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
function rootStartsOwnLine(node) {
|
|
2994
|
+
return (node.kind === "sequence" || node.kind === "mapping") && node.style === COLLECTION_STYLE.BLOCK && node.items.length !== 0 && !node.tagged && node.anchor === void 0;
|
|
2995
|
+
}
|
|
2996
|
+
function writeDocumentDirectives(doc) {
|
|
2997
|
+
let result = "";
|
|
2998
|
+
for (const directive of doc.directives) {
|
|
2999
|
+
if (directive.kind === "yaml") {
|
|
3000
|
+
result += `%YAML ${directive.version}
|
|
3001
|
+
`;
|
|
3002
|
+
continue;
|
|
3003
|
+
}
|
|
3004
|
+
const { handle, prefix } = directive;
|
|
3005
|
+
result += `%TAG ${handle} ${prefix}
|
|
3006
|
+
`;
|
|
3007
|
+
}
|
|
3008
|
+
return result;
|
|
3009
|
+
}
|
|
3010
|
+
function present(documents, options) {
|
|
3011
|
+
const state = createPresenterState(options);
|
|
3012
|
+
let result = "";
|
|
3013
|
+
let previousEnded = false;
|
|
3014
|
+
for (let index = 0; index < documents.length; index += 1) {
|
|
3015
|
+
const doc = documents[index];
|
|
3016
|
+
state.openEnded = false;
|
|
3017
|
+
const directives = writeDocumentDirectives(doc);
|
|
3018
|
+
const hasDirectives = directives !== "";
|
|
3019
|
+
const marker = doc.explicitStart || hasDirectives || index > 0 && !previousEnded;
|
|
3020
|
+
result += directives;
|
|
3021
|
+
if (doc.contents === null) {
|
|
3022
|
+
if (marker) result += "---\n";
|
|
3023
|
+
} else if (marker) {
|
|
3024
|
+
const body = writeNode(state, 0, doc.contents, null, {
|
|
3025
|
+
block: true,
|
|
3026
|
+
compact: true
|
|
3027
|
+
}).text;
|
|
3028
|
+
const sep = body === "" ? "" : hasDirectives || rootStartsOwnLine(doc.contents) ? "\n" : " ";
|
|
3029
|
+
result += `---${sep}${body}
|
|
3030
|
+
`;
|
|
3031
|
+
} else result += writeNode(state, 0, doc.contents, null, {
|
|
3032
|
+
block: true,
|
|
3033
|
+
compact: true
|
|
3034
|
+
}).text + "\n";
|
|
3035
|
+
previousEnded = doc.explicitEnd || state.openEnded;
|
|
3036
|
+
if (previousEnded) result += "...\n";
|
|
3037
|
+
}
|
|
3038
|
+
return result;
|
|
3039
|
+
}
|
|
3040
|
+
var DEFAULT_DUMP_OPTIONS = {
|
|
3041
|
+
...DEFAULT_PRESENTER_OPTIONS,
|
|
3042
|
+
schema: DUMP_SCHEMA,
|
|
3043
|
+
skipInvalid: false,
|
|
3044
|
+
noRefs: false,
|
|
3045
|
+
flowLevel: -1,
|
|
3046
|
+
sortKeys: false,
|
|
3047
|
+
transform: () => {
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
function defaultCompareFn(a, b) {
|
|
3051
|
+
const x = String(a);
|
|
3052
|
+
const y = String(b);
|
|
3053
|
+
if (x < y) return -1;
|
|
3054
|
+
if (x > y) return 1;
|
|
3055
|
+
return 0;
|
|
3056
|
+
}
|
|
3057
|
+
function dump(input, options = {}) {
|
|
3058
|
+
const opts = {
|
|
3059
|
+
...DEFAULT_DUMP_OPTIONS,
|
|
3060
|
+
...options
|
|
3061
|
+
};
|
|
3062
|
+
const documents = jsToAst(input, opts.schema, {
|
|
3063
|
+
noRefs: opts.noRefs,
|
|
3064
|
+
skipInvalid: opts.skipInvalid
|
|
3065
|
+
});
|
|
3066
|
+
if (opts.flowLevel >= 0) visit(documents, (node, ctx) => {
|
|
3067
|
+
if (ctx.depth < opts.flowLevel) return;
|
|
3068
|
+
if (node.kind === "sequence" || node.kind === "mapping") node.style = COLLECTION_STYLE.FLOW;
|
|
3069
|
+
return VISIT_SKIP;
|
|
3070
|
+
});
|
|
3071
|
+
if (opts.sortKeys) {
|
|
3072
|
+
const compareFn = opts.sortKeys === true ? defaultCompareFn : opts.sortKeys;
|
|
3073
|
+
visit(documents, (node) => {
|
|
3074
|
+
if (node.kind !== "mapping") return;
|
|
3075
|
+
node.items.sort((a, b) => compareFn(a.key.kind === "scalar" ? a.key.value : "", b.key.kind === "scalar" ? b.key.value : ""));
|
|
3076
|
+
});
|
|
3077
|
+
}
|
|
3078
|
+
opts.transform(documents);
|
|
3079
|
+
return present(documents, {
|
|
3080
|
+
...pick(opts, Object.keys(DEFAULT_PRESENTER_OPTIONS)),
|
|
3081
|
+
schema: opts.schema
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
var EVENT_DOCUMENT = EVENT_ID.DOCUMENT;
|
|
3085
|
+
var EVENT_SEQUENCE = EVENT_ID.SEQUENCE;
|
|
3086
|
+
var EVENT_MAPPING = EVENT_ID.MAPPING;
|
|
3087
|
+
var EVENT_SCALAR = EVENT_ID.SCALAR;
|
|
3088
|
+
var EVENT_ALIAS = EVENT_ID.ALIAS;
|
|
3089
|
+
var EVENT_POP = EVENT_ID.POP;
|
|
3090
|
+
var SCALAR_STYLE_PLAIN = SCALAR_STYLE.PLAIN;
|
|
3091
|
+
var SCALAR_STYLE_SINGLE_QUOTED = SCALAR_STYLE.SINGLE_QUOTED;
|
|
3092
|
+
var SCALAR_STYLE_DOUBLE_QUOTED = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3093
|
+
var SCALAR_STYLE_LITERAL_BLOCK = SCALAR_STYLE.LITERAL_BLOCK;
|
|
3094
|
+
var SCALAR_STYLE_FOLDED_BLOCK = SCALAR_STYLE.FOLDED_BLOCK;
|
|
3095
|
+
var COLLECTION_STYLE_BLOCK = COLLECTION_STYLE.BLOCK;
|
|
3096
|
+
var COLLECTION_STYLE_FLOW = COLLECTION_STYLE.FLOW;
|
|
3097
|
+
var CHOMPING_CLIP = CHOMPING_MODE.CLIP;
|
|
3098
|
+
var CHOMPING_STRIP = CHOMPING_MODE.STRIP;
|
|
3099
|
+
var CHOMPING_KEEP = CHOMPING_MODE.KEEP;
|
|
3100
|
+
|
|
3101
|
+
export {
|
|
3102
|
+
load,
|
|
3103
|
+
dump
|
|
3104
|
+
};
|
|
3105
|
+
/*! Bundled license information:
|
|
3106
|
+
|
|
3107
|
+
js-yaml/dist/js-yaml.mjs:
|
|
3108
|
+
(*! js-yaml 5.4.2 https://github.com/nodeca/js-yaml @license MIT *)
|
|
3109
|
+
*/
|