@blazetrails/ruby-compat 0.0.0-stage → 0.1.0-alpha0.2
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 +21 -0
- package/NOTICE +6 -0
- package/README.md +440 -2
- package/dist/argument-error.d.ts +15 -0
- package/dist/argument-error.js +15 -0
- package/dist/argument-error.js.map +1 -0
- package/dist/array.d.ts +415 -0
- package/dist/array.js +1330 -0
- package/dist/array.js.map +1 -0
- package/dist/async-context-adapter.d.ts +19 -0
- package/dist/async-context-adapter.js +139 -0
- package/dist/async-context-adapter.js.map +1 -0
- package/dist/backtrace-location.d.ts +78 -0
- package/dist/backtrace-location.js +158 -0
- package/dist/backtrace-location.js.map +1 -0
- package/dist/base64.d.ts +73 -0
- package/dist/base64.js +164 -0
- package/dist/base64.js.map +1 -0
- package/dist/benchmark.d.ts +19 -0
- package/dist/benchmark.js +16 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/big-decimal.d.ts +111 -0
- package/dist/big-decimal.js +584 -0
- package/dist/big-decimal.js.map +1 -0
- package/dist/bundler.d.ts +44 -0
- package/dist/bundler.js +97 -0
- package/dist/bundler.js.map +1 -0
- package/dist/cgi.d.ts +89 -0
- package/dist/cgi.js +168 -0
- package/dist/cgi.js.map +1 -0
- package/dist/child-process-adapter.d.ts +110 -0
- package/dist/child-process-adapter.js +272 -0
- package/dist/child-process-adapter.js.map +1 -0
- package/dist/class-module.d.ts +10 -0
- package/dist/class-module.js +10 -0
- package/dist/class-module.js.map +1 -0
- package/dist/classpath.d.ts +93 -0
- package/dist/classpath.js +210 -0
- package/dist/classpath.js.map +1 -0
- package/dist/closed-queue-error.d.ts +10 -0
- package/dist/closed-queue-error.js +10 -0
- package/dist/closed-queue-error.js.map +1 -0
- package/dist/comparable.d.ts +127 -0
- package/dist/comparable.js +376 -0
- package/dist/comparable.js.map +1 -0
- package/dist/complex.d.ts +49 -0
- package/dist/complex.js +164 -0
- package/dist/complex.js.map +1 -0
- package/dist/concurrent/atomic-boolean.d.ts +24 -0
- package/dist/concurrent/atomic-boolean.js +43 -0
- package/dist/concurrent/atomic-boolean.js.map +1 -0
- package/dist/concurrent/atomic-fixnum.d.ts +21 -0
- package/dist/concurrent/atomic-fixnum.js +35 -0
- package/dist/concurrent/atomic-fixnum.js.map +1 -0
- package/dist/concurrent/count-down-latch.d.ts +20 -0
- package/dist/concurrent/count-down-latch.js +50 -0
- package/dist/concurrent/count-down-latch.js.map +1 -0
- package/dist/concurrent/cyclic-barrier.d.ts +18 -0
- package/dist/concurrent/cyclic-barrier.js +50 -0
- package/dist/concurrent/cyclic-barrier.js.map +1 -0
- package/dist/concurrent/event.d.ts +19 -0
- package/dist/concurrent/event.js +31 -0
- package/dist/concurrent/event.js.map +1 -0
- package/dist/concurrent/map.d.ts +149 -0
- package/dist/concurrent/map.js +202 -0
- package/dist/concurrent/map.js.map +1 -0
- package/dist/concurrent/read-write-lock.d.ts +25 -0
- package/dist/concurrent/read-write-lock.js +70 -0
- package/dist/concurrent/read-write-lock.js.map +1 -0
- package/dist/concurrent/semaphore.d.ts +24 -0
- package/dist/concurrent/semaphore.js +74 -0
- package/dist/concurrent/semaphore.js.map +1 -0
- package/dist/concurrent/timer-task.d.ts +52 -0
- package/dist/concurrent/timer-task.js +112 -0
- package/dist/concurrent/timer-task.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +64 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/converter-not-found-error.d.ts +14 -0
- package/dist/converter-not-found-error.js +14 -0
- package/dist/converter-not-found-error.js.map +1 -0
- package/dist/crypto-adapter.d.ts +64 -0
- package/dist/crypto-adapter.js +365 -0
- package/dist/crypto-adapter.js.map +1 -0
- package/dist/delegate.d.ts +156 -0
- package/dist/delegate.js +306 -0
- package/dist/delegate.js.map +1 -0
- package/dist/digest.d.ts +99 -0
- package/dist/digest.js +131 -0
- package/dist/digest.js.map +1 -0
- package/dist/dir.d.ts +225 -0
- package/dist/dir.js +608 -0
- package/dist/dir.js.map +1 -0
- package/dist/encoding-error.d.ts +14 -0
- package/dist/encoding-error.js +17 -0
- package/dist/encoding-error.js.map +1 -0
- package/dist/encoding.d.ts +121 -0
- package/dist/encoding.js +306 -0
- package/dist/encoding.js.map +1 -0
- package/dist/ensure.d.ts +15 -0
- package/dist/ensure.js +35 -0
- package/dist/ensure.js.map +1 -0
- package/dist/enumerable.d.ts +375 -0
- package/dist/enumerable.js +1102 -0
- package/dist/enumerable.js.map +1 -0
- package/dist/enumerator.d.ts +324 -0
- package/dist/enumerator.js +625 -0
- package/dist/enumerator.js.map +1 -0
- package/dist/eof-error.d.ts +14 -0
- package/dist/eof-error.js +14 -0
- package/dist/eof-error.js.map +1 -0
- package/dist/errno.d.ts +447 -0
- package/dist/errno.js +616 -0
- package/dist/errno.js.map +1 -0
- package/dist/exc-detailed-message.d.ts +15 -0
- package/dist/exc-detailed-message.js +106 -0
- package/dist/exc-detailed-message.js.map +1 -0
- package/dist/exc-to-s.d.ts +10 -0
- package/dist/exc-to-s.js +21 -0
- package/dist/exc-to-s.js.map +1 -0
- package/dist/exception.d.ts +44 -0
- package/dist/exception.js +115 -0
- package/dist/exception.js.map +1 -0
- package/dist/fiber-error.d.ts +12 -0
- package/dist/fiber-error.js +12 -0
- package/dist/fiber-error.js.map +1 -0
- package/dist/fiber.d.ts +51 -0
- package/dist/fiber.js +178 -0
- package/dist/fiber.js.map +1 -0
- package/dist/file-utils.d.ts +480 -0
- package/dist/file-utils.js +1824 -0
- package/dist/file-utils.js.map +1 -0
- package/dist/file.d.ts +643 -0
- package/dist/file.js +1334 -0
- package/dist/file.js.map +1 -0
- package/dist/float-domain-error.d.ts +17 -0
- package/dist/float-domain-error.js +17 -0
- package/dist/float-domain-error.js.map +1 -0
- package/dist/fork-children.d.ts +23 -0
- package/dist/fork-children.js +32 -0
- package/dist/fork-children.js.map +1 -0
- package/dist/frozen-error.d.ts +33 -0
- package/dist/frozen-error.js +41 -0
- package/dist/frozen-error.js.map +1 -0
- package/dist/fs-adapter.d.ts +158 -0
- package/dist/fs-adapter.js +253 -0
- package/dist/fs-adapter.js.map +1 -0
- package/dist/gem/deprecate.d.ts +10 -0
- package/dist/gem/deprecate.js +8 -0
- package/dist/gem/deprecate.js.map +1 -0
- package/dist/gem/requirement.d.ts +55 -0
- package/dist/gem/requirement.js +91 -0
- package/dist/gem/requirement.js.map +1 -0
- package/dist/gem/version.d.ts +50 -0
- package/dist/gem/version.js +148 -0
- package/dist/gem/version.js.map +1 -0
- package/dist/gem.d.ts +59 -0
- package/dist/gem.js +82 -0
- package/dist/gem.js.map +1 -0
- package/dist/hash.d.ts +967 -0
- package/dist/hash.js +1572 -0
- package/dist/hash.js.map +1 -0
- package/dist/http-adapter.d.ts +124 -0
- package/dist/http-adapter.js +220 -0
- package/dist/http-adapter.js.map +1 -0
- package/dist/immediate-executor.d.ts +20 -0
- package/dist/immediate-executor.js +39 -0
- package/dist/immediate-executor.js.map +1 -0
- package/dist/include.d.ts +778 -0
- package/dist/include.js +2208 -0
- package/dist/include.js.map +1 -0
- package/dist/index-error.d.ts +13 -0
- package/dist/index-error.js +13 -0
- package/dist/index-error.js.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/dist/invalid-byte-sequence-error.d.ts +62 -0
- package/dist/invalid-byte-sequence-error.js +75 -0
- package/dist/invalid-byte-sequence-error.js.map +1 -0
- package/dist/io-error.d.ts +14 -0
- package/dist/io-error.js +17 -0
- package/dist/io-error.js.map +1 -0
- package/dist/io.d.ts +867 -0
- package/dist/io.js +1960 -0
- package/dist/io.js.map +1 -0
- package/dist/ipaddr.d.ts +79 -0
- package/dist/ipaddr.js +405 -0
- package/dist/ipaddr.js.map +1 -0
- package/dist/json.d.ts +70 -0
- package/dist/json.js +181 -0
- package/dist/json.js.map +1 -0
- package/dist/kernel-catch.d.ts +59 -0
- package/dist/kernel-catch.js +184 -0
- package/dist/kernel-catch.js.map +1 -0
- package/dist/kernel-float.d.ts +19 -0
- package/dist/kernel-float.js +54 -0
- package/dist/kernel-float.js.map +1 -0
- package/dist/kernel-fork.d.ts +30 -0
- package/dist/kernel-fork.js +72 -0
- package/dist/kernel-fork.js.map +1 -0
- package/dist/kernel-format.d.ts +27 -0
- package/dist/kernel-format.js +901 -0
- package/dist/kernel-format.js.map +1 -0
- package/dist/kernel-hash.d.ts +7 -0
- package/dist/kernel-hash.js +33 -0
- package/dist/kernel-hash.js.map +1 -0
- package/dist/kernel-integer.d.ts +49 -0
- package/dist/kernel-integer.js +170 -0
- package/dist/kernel-integer.js.map +1 -0
- package/dist/kernel-rand.d.ts +16 -0
- package/dist/kernel-rand.js +237 -0
- package/dist/kernel-rand.js.map +1 -0
- package/dist/kernel-system.d.ts +39 -0
- package/dist/kernel-system.js +103 -0
- package/dist/kernel-system.js.map +1 -0
- package/dist/kernel-warn.d.ts +35 -0
- package/dist/kernel-warn.js +73 -0
- package/dist/kernel-warn.js.map +1 -0
- package/dist/key-error.d.ts +44 -0
- package/dist/key-error.js +59 -0
- package/dist/key-error.js.map +1 -0
- package/dist/keyword-splat.d.ts +41 -0
- package/dist/keyword-splat.js +65 -0
- package/dist/keyword-splat.js.map +1 -0
- package/dist/load-error.d.ts +19 -0
- package/dist/load-error.js +19 -0
- package/dist/load-error.js.map +1 -0
- package/dist/load.d.ts +128 -0
- package/dist/load.js +278 -0
- package/dist/load.js.map +1 -0
- package/dist/loaded-features.d.ts +13 -0
- package/dist/loaded-features.js +15 -0
- package/dist/loaded-features.js.map +1 -0
- package/dist/local-jump-error.d.ts +12 -0
- package/dist/local-jump-error.js +12 -0
- package/dist/local-jump-error.js.map +1 -0
- package/dist/logger/formatter.d.ts +21 -0
- package/dist/logger/formatter.js +43 -0
- package/dist/logger/formatter.js.map +1 -0
- package/dist/logger/log-device.d.ts +52 -0
- package/dist/logger/log-device.js +104 -0
- package/dist/logger/log-device.js.map +1 -0
- package/dist/logger/severity.d.ts +23 -0
- package/dist/logger/severity.js +42 -0
- package/dist/logger/severity.js.map +1 -0
- package/dist/logger.d.ts +127 -0
- package/dist/logger.js +218 -0
- package/dist/logger.js.map +1 -0
- package/dist/marshal.d.ts +83 -0
- package/dist/marshal.js +1487 -0
- package/dist/marshal.js.map +1 -0
- package/dist/match-data.d.ts +161 -0
- package/dist/match-data.js +284 -0
- package/dist/match-data.js.map +1 -0
- package/dist/method-cache.d.ts +81 -0
- package/dist/method-cache.js +109 -0
- package/dist/method-cache.js.map +1 -0
- package/dist/method-missing-proxy.d.ts +53 -0
- package/dist/method-missing-proxy.js +154 -0
- package/dist/method-missing-proxy.js.map +1 -0
- package/dist/method.d.ts +132 -0
- package/dist/method.js +320 -0
- package/dist/method.js.map +1 -0
- package/dist/monitor.d.ts +114 -0
- package/dist/monitor.js +270 -0
- package/dist/monitor.js.map +1 -0
- package/dist/mutex.d.ts +51 -0
- package/dist/mutex.js +150 -0
- package/dist/mutex.js.map +1 -0
- package/dist/name-error.d.ts +45 -0
- package/dist/name-error.js +54 -0
- package/dist/name-error.js.map +1 -0
- package/dist/net/http/exceptions.d.ts +31 -0
- package/dist/net/http/exceptions.js +46 -0
- package/dist/net/http/exceptions.js.map +1 -0
- package/dist/net/http/request.d.ts +137 -0
- package/dist/net/http/request.js +559 -0
- package/dist/net/http/request.js.map +1 -0
- package/dist/net/http/requests.d.ts +197 -0
- package/dist/net/http/requests.js +197 -0
- package/dist/net/http/requests.js.map +1 -0
- package/dist/net/http/response.d.ts +141 -0
- package/dist/net/http/response.js +416 -0
- package/dist/net/http/response.js.map +1 -0
- package/dist/net/http/responses.d.ts +345 -0
- package/dist/net/http/responses.js +486 -0
- package/dist/net/http/responses.js.map +1 -0
- package/dist/net/http.d.ts +278 -0
- package/dist/net/http.js +760 -0
- package/dist/net/http.js.map +1 -0
- package/dist/net/protocol.d.ts +227 -0
- package/dist/net/protocol.js +392 -0
- package/dist/net/protocol.js.map +1 -0
- package/dist/nil-class.d.ts +10 -0
- package/dist/nil-class.js +27 -0
- package/dist/nil-class.js.map +1 -0
- package/dist/no-method-error.d.ts +38 -0
- package/dist/no-method-error.js +45 -0
- package/dist/no-method-error.js.map +1 -0
- package/dist/not-implemented-error.d.ts +13 -0
- package/dist/not-implemented-error.js +13 -0
- package/dist/not-implemented-error.js.map +1 -0
- package/dist/numeric-class.d.ts +29 -0
- package/dist/numeric-class.js +41 -0
- package/dist/numeric-class.js.map +1 -0
- package/dist/numeric.d.ts +226 -0
- package/dist/numeric.js +848 -0
- package/dist/numeric.js.map +1 -0
- package/dist/object-space.d.ts +34 -0
- package/dist/object-space.js +152 -0
- package/dist/object-space.js.map +1 -0
- package/dist/object.d.ts +833 -0
- package/dist/object.js +2131 -0
- package/dist/object.js.map +1 -0
- package/dist/open-uri.d.ts +180 -0
- package/dist/open-uri.js +402 -0
- package/dist/open-uri.js.map +1 -0
- package/dist/open3.d.ts +69 -0
- package/dist/open3.js +134 -0
- package/dist/open3.js.map +1 -0
- package/dist/openssl.d.ts +479 -0
- package/dist/openssl.js +1052 -0
- package/dist/openssl.js.map +1 -0
- package/dist/optparse.d.ts +130 -0
- package/dist/optparse.js +457 -0
- package/dist/optparse.js.map +1 -0
- package/dist/os-adapter.d.ts +20 -0
- package/dist/os-adapter.js +95 -0
- package/dist/os-adapter.js.map +1 -0
- package/dist/pathname.d.ts +73 -0
- package/dist/pathname.js +412 -0
- package/dist/pathname.js.map +1 -0
- package/dist/pp.d.ts +60 -0
- package/dist/pp.js +195 -0
- package/dist/pp.js.map +1 -0
- package/dist/pretty-print.d.ts +89 -0
- package/dist/pretty-print.js +232 -0
- package/dist/pretty-print.js.map +1 -0
- package/dist/process-adapter.d.ts +229 -0
- package/dist/process-adapter.js +889 -0
- package/dist/process-adapter.js.map +1 -0
- package/dist/process.d.ts +202 -0
- package/dist/process.js +433 -0
- package/dist/process.js.map +1 -0
- package/dist/psych/class-loader.d.ts +92 -0
- package/dist/psych/class-loader.js +139 -0
- package/dist/psych/class-loader.js.map +1 -0
- package/dist/psych/coder.d.ts +144 -0
- package/dist/psych/coder.js +176 -0
- package/dist/psych/coder.js.map +1 -0
- package/dist/psych/core-ext.d.ts +8 -0
- package/dist/psych/core-ext.js +10 -0
- package/dist/psych/core-ext.js.map +1 -0
- package/dist/psych/emitter.d.ts +116 -0
- package/dist/psych/emitter.js +1130 -0
- package/dist/psych/emitter.js.map +1 -0
- package/dist/psych/exception.d.ts +43 -0
- package/dist/psych/exception.js +54 -0
- package/dist/psych/exception.js.map +1 -0
- package/dist/psych/handler.d.ts +59 -0
- package/dist/psych/handler.js +95 -0
- package/dist/psych/handler.js.map +1 -0
- package/dist/psych/handlers/document-stream.d.ts +17 -0
- package/dist/psych/handlers/document-stream.js +26 -0
- package/dist/psych/handlers/document-stream.js.map +1 -0
- package/dist/psych/nodes/alias.d.ts +15 -0
- package/dist/psych/nodes/alias.js +22 -0
- package/dist/psych/nodes/alias.js.map +1 -0
- package/dist/psych/nodes/document.d.ts +23 -0
- package/dist/psych/nodes/document.js +35 -0
- package/dist/psych/nodes/document.js.map +1 -0
- package/dist/psych/nodes/mapping.d.ts +25 -0
- package/dist/psych/nodes/mapping.js +35 -0
- package/dist/psych/nodes/mapping.js.map +1 -0
- package/dist/psych/nodes/node.d.ts +59 -0
- package/dist/psych/nodes/node.js +79 -0
- package/dist/psych/nodes/node.js.map +1 -0
- package/dist/psych/nodes/scalar.d.ts +35 -0
- package/dist/psych/nodes/scalar.js +47 -0
- package/dist/psych/nodes/scalar.js.map +1 -0
- package/dist/psych/nodes/sequence.d.ts +25 -0
- package/dist/psych/nodes/sequence.js +35 -0
- package/dist/psych/nodes/sequence.js.map +1 -0
- package/dist/psych/nodes/stream.d.ts +23 -0
- package/dist/psych/nodes/stream.js +31 -0
- package/dist/psych/nodes/stream.js.map +1 -0
- package/dist/psych/omap.d.ts +9 -0
- package/dist/psych/omap.js +9 -0
- package/dist/psych/omap.js.map +1 -0
- package/dist/psych/parser.d.ts +41 -0
- package/dist/psych/parser.js +139 -0
- package/dist/psych/parser.js.map +1 -0
- package/dist/psych/scalar-scanner.d.ts +31 -0
- package/dist/psych/scalar-scanner.js +169 -0
- package/dist/psych/scalar-scanner.js.map +1 -0
- package/dist/psych/syntax-error.d.ts +23 -0
- package/dist/psych/syntax-error.js +35 -0
- package/dist/psych/syntax-error.js.map +1 -0
- package/dist/psych/tree-builder.d.ts +51 -0
- package/dist/psych/tree-builder.js +118 -0
- package/dist/psych/tree-builder.js.map +1 -0
- package/dist/psych/visitors/depth-first.d.ts +27 -0
- package/dist/psych/visitors/depth-first.js +37 -0
- package/dist/psych/visitors/depth-first.js.map +1 -0
- package/dist/psych/visitors/emitter.d.ts +32 -0
- package/dist/psych/visitors/emitter.js +63 -0
- package/dist/psych/visitors/emitter.js.map +1 -0
- package/dist/psych/visitors/to-ruby.d.ts +110 -0
- package/dist/psych/visitors/to-ruby.js +396 -0
- package/dist/psych/visitors/to-ruby.js.map +1 -0
- package/dist/psych/visitors/visitor.d.ts +11 -0
- package/dist/psych/visitors/visitor.js +17 -0
- package/dist/psych/visitors/visitor.js.map +1 -0
- package/dist/psych/visitors/yaml-tree.d.ts +182 -0
- package/dist/psych/visitors/yaml-tree.js +593 -0
- package/dist/psych/visitors/yaml-tree.js.map +1 -0
- package/dist/psych-adapter.d.ts +65 -0
- package/dist/psych-adapter.js +121 -0
- package/dist/psych-adapter.js.map +1 -0
- package/dist/psych-yaml.d.ts +2 -0
- package/dist/psych-yaml.js +5 -0
- package/dist/psych-yaml.js.map +1 -0
- package/dist/psych.d.ts +257 -0
- package/dist/psych.js +332 -0
- package/dist/psych.js.map +1 -0
- package/dist/queue.d.ts +137 -0
- package/dist/queue.js +236 -0
- package/dist/queue.js.map +1 -0
- package/dist/racc/parser.d.ts +70 -0
- package/dist/racc/parser.js +206 -0
- package/dist/racc/parser.js.map +1 -0
- package/dist/range-error.d.ts +15 -0
- package/dist/range-error.js +15 -0
- package/dist/range-error.js.map +1 -0
- package/dist/range.d.ts +166 -0
- package/dist/range.js +421 -0
- package/dist/range.js.map +1 -0
- package/dist/rational.d.ts +168 -0
- package/dist/rational.js +587 -0
- package/dist/rational.js.map +1 -0
- package/dist/rb-config.d.ts +33 -0
- package/dist/rb-config.js +53 -0
- package/dist/rb-config.js.map +1 -0
- package/dist/rb-equal.d.ts +66 -0
- package/dist/rb-equal.js +262 -0
- package/dist/rb-equal.js.map +1 -0
- package/dist/rb-hash.d.ts +26 -0
- package/dist/rb-hash.js +108 -0
- package/dist/rb-hash.js.map +1 -0
- package/dist/regexp.d.ts +82 -0
- package/dist/regexp.js +191 -0
- package/dist/regexp.js.map +1 -0
- package/dist/repl-adapter.d.ts +270 -0
- package/dist/repl-adapter.js +562 -0
- package/dist/repl-adapter.js.map +1 -0
- package/dist/resolv.d.ts +30 -0
- package/dist/resolv.js +48 -0
- package/dist/resolv.js.map +1 -0
- package/dist/ruby-empty.d.ts +28 -0
- package/dist/ruby-empty.js +40 -0
- package/dist/ruby-empty.js.map +1 -0
- package/dist/ruby-platform.d.ts +39 -0
- package/dist/ruby-platform.js +49 -0
- package/dist/ruby-platform.js.map +1 -0
- package/dist/runtime-error.d.ts +15 -0
- package/dist/runtime-error.js +15 -0
- package/dist/runtime-error.js.map +1 -0
- package/dist/scheduled-task.d.ts +73 -0
- package/dist/scheduled-task.js +150 -0
- package/dist/scheduled-task.js.map +1 -0
- package/dist/secure-random.d.ts +50 -0
- package/dist/secure-random.js +141 -0
- package/dist/secure-random.js.map +1 -0
- package/dist/set.d.ts +158 -0
- package/dist/set.js +352 -0
- package/dist/set.js.map +1 -0
- package/dist/shellwords.d.ts +27 -0
- package/dist/shellwords.js +53 -0
- package/dist/shellwords.js.map +1 -0
- package/dist/signal-exception.d.ts +43 -0
- package/dist/signal-exception.js +88 -0
- package/dist/signal-exception.js.map +1 -0
- package/dist/socket.d.ts +230 -0
- package/dist/socket.js +484 -0
- package/dist/socket.js.map +1 -0
- package/dist/standard-error.d.ts +27 -0
- package/dist/standard-error.js +49 -0
- package/dist/standard-error.js.map +1 -0
- package/dist/stop-iteration.d.ts +10 -0
- package/dist/stop-iteration.js +10 -0
- package/dist/stop-iteration.js.map +1 -0
- package/dist/string/b.d.ts +19 -0
- package/dist/string/b.js +28 -0
- package/dist/string/b.js.map +1 -0
- package/dist/string/byte-methods.d.ts +57 -0
- package/dist/string/byte-methods.js +266 -0
- package/dist/string/byte-methods.js.map +1 -0
- package/dist/string/bytes.d.ts +35 -0
- package/dist/string/bytes.js +123 -0
- package/dist/string/bytes.js.map +1 -0
- package/dist/string/case-mapping.d.ts +57 -0
- package/dist/string/case-mapping.js +192 -0
- package/dist/string/case-mapping.js.map +1 -0
- package/dist/string/chomp.d.ts +15 -0
- package/dist/string/chomp.js +32 -0
- package/dist/string/chomp.js.map +1 -0
- package/dist/string/convert.d.ts +55 -0
- package/dist/string/convert.js +316 -0
- package/dist/string/convert.js.map +1 -0
- package/dist/string/delete.d.ts +14 -0
- package/dist/string/delete.js +17 -0
- package/dist/string/delete.js.map +1 -0
- package/dist/string/each.d.ts +108 -0
- package/dist/string/each.js +305 -0
- package/dist/string/each.js.map +1 -0
- package/dist/string/encode.d.ts +37 -0
- package/dist/string/encode.js +268 -0
- package/dist/string/encode.js.map +1 -0
- package/dist/string/force-encoding.d.ts +72 -0
- package/dist/string/force-encoding.js +147 -0
- package/dist/string/force-encoding.js.map +1 -0
- package/dist/string/inspect.d.ts +17 -0
- package/dist/string/inspect.js +81 -0
- package/dist/string/inspect.js.map +1 -0
- package/dist/string/method-table.d.ts +174 -0
- package/dist/string/method-table.js +805 -0
- package/dist/string/method-table.js.map +1 -0
- package/dist/string/scrub.d.ts +12 -0
- package/dist/string/scrub.js +33 -0
- package/dist/string/scrub.js.map +1 -0
- package/dist/string/slice.d.ts +26 -0
- package/dist/string/slice.js +73 -0
- package/dist/string/slice.js.map +1 -0
- package/dist/string/split.d.ts +11 -0
- package/dist/string/split.js +44 -0
- package/dist/string/split.js.map +1 -0
- package/dist/string/sub.d.ts +114 -0
- package/dist/string/sub.js +371 -0
- package/dist/string/sub.js.map +1 -0
- package/dist/string/succ.d.ts +14 -0
- package/dist/string/succ.js +118 -0
- package/dist/string/succ.js.map +1 -0
- package/dist/string/support.d.ts +142 -0
- package/dist/string/support.js +296 -0
- package/dist/string/support.js.map +1 -0
- package/dist/string/tr.d.ts +46 -0
- package/dist/string/tr.js +156 -0
- package/dist/string/tr.js.map +1 -0
- package/dist/string-io.d.ts +166 -0
- package/dist/string-io.js +248 -0
- package/dist/string-io.js.map +1 -0
- package/dist/string-scanner.d.ts +133 -0
- package/dist/string-scanner.js +248 -0
- package/dist/string-scanner.js.map +1 -0
- package/dist/struct.d.ts +54 -0
- package/dist/struct.js +222 -0
- package/dist/struct.js.map +1 -0
- package/dist/symbol.d.ts +48 -0
- package/dist/symbol.js +107 -0
- package/dist/symbol.js.map +1 -0
- package/dist/tempfile.d.ts +173 -0
- package/dist/tempfile.js +295 -0
- package/dist/tempfile.js.map +1 -0
- package/dist/temporal-tag.d.ts +23 -0
- package/dist/temporal-tag.js +29 -0
- package/dist/temporal-tag.js.map +1 -0
- package/dist/thread-error.d.ts +13 -0
- package/dist/thread-error.js +13 -0
- package/dist/thread-error.js.map +1 -0
- package/dist/thread-pool-executor.d.ts +121 -0
- package/dist/thread-pool-executor.js +254 -0
- package/dist/thread-pool-executor.js.map +1 -0
- package/dist/thread.d.ts +211 -0
- package/dist/thread.js +495 -0
- package/dist/thread.js.map +1 -0
- package/dist/timeout.d.ts +29 -0
- package/dist/timeout.js +41 -0
- package/dist/timeout.js.map +1 -0
- package/dist/tse.d.ts +40 -0
- package/dist/tse.js +66 -0
- package/dist/tse.js.map +1 -0
- package/dist/type-error.d.ts +14 -0
- package/dist/type-error.js +14 -0
- package/dist/type-error.js.map +1 -0
- package/dist/undefined-conversion-error.d.ts +10 -0
- package/dist/undefined-conversion-error.js +10 -0
- package/dist/undefined-conversion-error.js.map +1 -0
- package/dist/uri/common.d.ts +209 -0
- package/dist/uri/common.js +369 -0
- package/dist/uri/common.js.map +1 -0
- package/dist/uri/generic.d.ts +280 -0
- package/dist/uri/generic.js +806 -0
- package/dist/uri/generic.js.map +1 -0
- package/dist/uri/http.d.ts +23 -0
- package/dist/uri/http.js +30 -0
- package/dist/uri/http.js.map +1 -0
- package/dist/uri/https.d.ts +13 -0
- package/dist/uri/https.js +15 -0
- package/dist/uri/https.js.map +1 -0
- package/dist/uri/rfc2396-parser.d.ts +70 -0
- package/dist/uri/rfc2396-parser.js +264 -0
- package/dist/uri/rfc2396-parser.js.map +1 -0
- package/dist/uri/rfc3986-parser.d.ts +46 -0
- package/dist/uri/rfc3986-parser.js +171 -0
- package/dist/uri/rfc3986-parser.js.map +1 -0
- package/dist/uri.d.ts +13 -0
- package/dist/uri.js +13 -0
- package/dist/uri.js.map +1 -0
- package/dist/variable.d.ts +183 -0
- package/dist/variable.js +463 -0
- package/dist/variable.js.map +1 -0
- package/dist/verbose.d.ts +39 -0
- package/dist/verbose.js +49 -0
- package/dist/verbose.js.map +1 -0
- package/dist/yaml.d.ts +9 -0
- package/dist/yaml.js +9 -0
- package/dist/yaml.js.map +1 -0
- package/dist/zlib-adapter.d.ts +119 -0
- package/dist/zlib-adapter.js +230 -0
- package/dist/zlib-adapter.js.map +1 -0
- package/dist/zlib.d.ts +299 -0
- package/dist/zlib.js +679 -0
- package/dist/zlib.js.map +1 -0
- package/package.json +172 -3
|
@@ -0,0 +1,1130 @@
|
|
|
1
|
+
import { classpaths } from "../classpath.js";
|
|
2
|
+
import { RuntimeError } from "../runtime-error.js";
|
|
3
|
+
import { Scalar } from "./nodes/scalar.js";
|
|
4
|
+
import { Sequence } from "./nodes/sequence.js";
|
|
5
|
+
import { Mapping } from "./nodes/mapping.js";
|
|
6
|
+
const DEFAULT_TAG_DIRECTIVES = [
|
|
7
|
+
["!", "!"],
|
|
8
|
+
["!!", "tag:yaml.org,2002:"],
|
|
9
|
+
];
|
|
10
|
+
const isBreak = (c) => c === "\r" || c === "\n" || c === "\u0085" || c === "\u2028" || c === "\u2029";
|
|
11
|
+
const isSpace = (c) => c === " ";
|
|
12
|
+
const isBlank = (c) => c === " " || c === "\t";
|
|
13
|
+
const isBlankz = (c) => c === undefined || c === "\0" || isBlank(c) || isBreak(c);
|
|
14
|
+
const isAlpha = (c) => /^[0-9A-Za-z_-]$/.test(c);
|
|
15
|
+
const isBom = (c) => c === "\ufeff";
|
|
16
|
+
const isPrintable = (c) => /^[\n\x20-\x7e\xa0-\ud7ff\ue000-\ufffd]$/.test(c) && c !== "\ufeff" && c !== "\ufffe";
|
|
17
|
+
const encoder = new TextEncoder();
|
|
18
|
+
const width = (s) => encoder.encode(s).length;
|
|
19
|
+
/**
|
|
20
|
+
* `Psych::Emitter` (`vendor/ruby/v3.3.11/ext/psych/psych_emitter.c:527`), the
|
|
21
|
+
* libyaml 0.2.5 emitter (`vendor/libyaml/0.2.5/src/emitter.c`): each handler
|
|
22
|
+
* call builds a libyaml event (`psych_emitter.c`) and `yaml_emitter_emit`
|
|
23
|
+
* (`vendor/libyaml/0.2.5/src/emitter.c:281`) drives the state machine. Each
|
|
24
|
+
* private method is the `yaml_emitter_<name>` of the same name.
|
|
25
|
+
*
|
|
26
|
+
* @noRailsEquivalent PERMANENT
|
|
27
|
+
*/
|
|
28
|
+
export class Emitter {
|
|
29
|
+
io;
|
|
30
|
+
canonical = false;
|
|
31
|
+
unicode = true;
|
|
32
|
+
bestIndent = 2;
|
|
33
|
+
bestWidth = 0;
|
|
34
|
+
buffer = "";
|
|
35
|
+
states = [];
|
|
36
|
+
state = "STREAM_START";
|
|
37
|
+
events = [];
|
|
38
|
+
indents = [];
|
|
39
|
+
tagDirectives = [];
|
|
40
|
+
indent = -1;
|
|
41
|
+
flowLevel = 0;
|
|
42
|
+
rootContext = false;
|
|
43
|
+
sequenceContext = false;
|
|
44
|
+
mappingContext = false;
|
|
45
|
+
simpleKeyContext = false;
|
|
46
|
+
line = 0;
|
|
47
|
+
column = 0;
|
|
48
|
+
whitespace = false;
|
|
49
|
+
indention = false;
|
|
50
|
+
openEnded = 0;
|
|
51
|
+
anchorData = null;
|
|
52
|
+
tagData = {
|
|
53
|
+
handle: null,
|
|
54
|
+
suffix: null,
|
|
55
|
+
};
|
|
56
|
+
scalarData;
|
|
57
|
+
/** @noRailsEquivalent PERMANENT */
|
|
58
|
+
constructor(io, options = {}) {
|
|
59
|
+
if ("lineWidth" in options)
|
|
60
|
+
this.bestWidth = options.lineWidth;
|
|
61
|
+
if ("indentation" in options)
|
|
62
|
+
this.bestIndent = options.indentation;
|
|
63
|
+
if ("canonical" in options)
|
|
64
|
+
this.canonical = options.canonical === true;
|
|
65
|
+
this.io = io;
|
|
66
|
+
}
|
|
67
|
+
/** @noRailsEquivalent PERMANENT */
|
|
68
|
+
startStream(_encoding) {
|
|
69
|
+
this.emit({ type: "STREAM_START" });
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/** @noRailsEquivalent PERMANENT */
|
|
73
|
+
endStream() {
|
|
74
|
+
this.emit({ type: "STREAM_END" });
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/** @noRailsEquivalent PERMANENT */
|
|
78
|
+
startDocument(version, tagDirectives, implicit) {
|
|
79
|
+
this.emit({ type: "DOCUMENT_START", version, tagDirectives, implicit });
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/** @noRailsEquivalent PERMANENT */
|
|
83
|
+
endDocument(implicitEnd) {
|
|
84
|
+
this.emit({ type: "DOCUMENT_END", implicit: implicitEnd });
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/** @noRailsEquivalent PERMANENT */
|
|
88
|
+
scalar(value, anchor, tag, plain, quoted, style) {
|
|
89
|
+
this.emit({
|
|
90
|
+
type: "SCALAR",
|
|
91
|
+
anchor,
|
|
92
|
+
tag,
|
|
93
|
+
value,
|
|
94
|
+
plainImplicit: plain,
|
|
95
|
+
quotedImplicit: quoted,
|
|
96
|
+
style,
|
|
97
|
+
});
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
/** @noRailsEquivalent PERMANENT */
|
|
101
|
+
startSequence(anchor, tag, implicit, style) {
|
|
102
|
+
this.emit({ type: "SEQUENCE_START", anchor, tag, implicit, style });
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
/** @noRailsEquivalent PERMANENT */
|
|
106
|
+
endSequence() {
|
|
107
|
+
this.emit({ type: "SEQUENCE_END" });
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
/** @noRailsEquivalent PERMANENT */
|
|
111
|
+
startMapping(anchor, tag, implicit, style) {
|
|
112
|
+
this.emit({ type: "MAPPING_START", anchor, tag, implicit, style });
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/** @noRailsEquivalent PERMANENT */
|
|
116
|
+
endMapping() {
|
|
117
|
+
this.emit({ type: "MAPPING_END" });
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/** @noRailsEquivalent PERMANENT */
|
|
121
|
+
alias(anchor) {
|
|
122
|
+
this.emit({ type: "ALIAS", anchor });
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
emit(event) {
|
|
126
|
+
this.events.push(event);
|
|
127
|
+
while (!this.needMoreEvents()) {
|
|
128
|
+
this.analyzeEvent(this.events[0]);
|
|
129
|
+
this.stateMachine(this.events[0]);
|
|
130
|
+
this.events.shift();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
needMoreEvents() {
|
|
134
|
+
if (this.events.length === 0)
|
|
135
|
+
return true;
|
|
136
|
+
let accumulate;
|
|
137
|
+
switch (this.events[0].type) {
|
|
138
|
+
case "DOCUMENT_START":
|
|
139
|
+
accumulate = 1;
|
|
140
|
+
break;
|
|
141
|
+
case "SEQUENCE_START":
|
|
142
|
+
accumulate = 2;
|
|
143
|
+
break;
|
|
144
|
+
case "MAPPING_START":
|
|
145
|
+
accumulate = 3;
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (this.events.length > accumulate)
|
|
151
|
+
return false;
|
|
152
|
+
let level = 0;
|
|
153
|
+
for (const event of this.events) {
|
|
154
|
+
switch (event.type) {
|
|
155
|
+
case "STREAM_START":
|
|
156
|
+
case "DOCUMENT_START":
|
|
157
|
+
case "SEQUENCE_START":
|
|
158
|
+
case "MAPPING_START":
|
|
159
|
+
level += 1;
|
|
160
|
+
break;
|
|
161
|
+
case "STREAM_END":
|
|
162
|
+
case "DOCUMENT_END":
|
|
163
|
+
case "SEQUENCE_END":
|
|
164
|
+
case "MAPPING_END":
|
|
165
|
+
level -= 1;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (!level)
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
stateMachine(event) {
|
|
174
|
+
switch (this.state) {
|
|
175
|
+
case "STREAM_START":
|
|
176
|
+
return this.emitStreamStart(event);
|
|
177
|
+
case "FIRST_DOCUMENT_START":
|
|
178
|
+
return this.emitDocumentStart(event, true);
|
|
179
|
+
case "DOCUMENT_START":
|
|
180
|
+
return this.emitDocumentStart(event, false);
|
|
181
|
+
case "DOCUMENT_CONTENT":
|
|
182
|
+
return this.emitDocumentContent(event);
|
|
183
|
+
case "DOCUMENT_END":
|
|
184
|
+
return this.emitDocumentEnd(event);
|
|
185
|
+
case "FLOW_SEQUENCE_FIRST_ITEM":
|
|
186
|
+
return this.emitFlowSequenceItem(event, true);
|
|
187
|
+
case "FLOW_SEQUENCE_ITEM":
|
|
188
|
+
return this.emitFlowSequenceItem(event, false);
|
|
189
|
+
case "FLOW_MAPPING_FIRST_KEY":
|
|
190
|
+
return this.emitFlowMappingKey(event, true);
|
|
191
|
+
case "FLOW_MAPPING_KEY":
|
|
192
|
+
return this.emitFlowMappingKey(event, false);
|
|
193
|
+
case "FLOW_MAPPING_SIMPLE_VALUE":
|
|
194
|
+
return this.emitFlowMappingValue(event, true);
|
|
195
|
+
case "FLOW_MAPPING_VALUE":
|
|
196
|
+
return this.emitFlowMappingValue(event, false);
|
|
197
|
+
case "BLOCK_SEQUENCE_FIRST_ITEM":
|
|
198
|
+
return this.emitBlockSequenceItem(event, true);
|
|
199
|
+
case "BLOCK_SEQUENCE_ITEM":
|
|
200
|
+
return this.emitBlockSequenceItem(event, false);
|
|
201
|
+
case "BLOCK_MAPPING_FIRST_KEY":
|
|
202
|
+
return this.emitBlockMappingKey(event, true);
|
|
203
|
+
case "BLOCK_MAPPING_KEY":
|
|
204
|
+
return this.emitBlockMappingKey(event, false);
|
|
205
|
+
case "BLOCK_MAPPING_SIMPLE_VALUE":
|
|
206
|
+
return this.emitBlockMappingValue(event, true);
|
|
207
|
+
case "BLOCK_MAPPING_VALUE":
|
|
208
|
+
return this.emitBlockMappingValue(event, false);
|
|
209
|
+
case "END":
|
|
210
|
+
throw new RuntimeError("expected nothing after STREAM-END");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
emitStreamStart(event) {
|
|
214
|
+
this.openEnded = 0;
|
|
215
|
+
if (event.type !== "STREAM_START")
|
|
216
|
+
throw new RuntimeError("expected STREAM-START");
|
|
217
|
+
if (this.bestIndent < 2 || this.bestIndent > 9)
|
|
218
|
+
this.bestIndent = 2;
|
|
219
|
+
if (this.bestWidth >= 0 && this.bestWidth <= this.bestIndent * 2)
|
|
220
|
+
this.bestWidth = 80;
|
|
221
|
+
if (this.bestWidth < 0)
|
|
222
|
+
this.bestWidth = Infinity;
|
|
223
|
+
this.indent = -1;
|
|
224
|
+
this.line = 0;
|
|
225
|
+
this.column = 0;
|
|
226
|
+
this.whitespace = true;
|
|
227
|
+
this.indention = true;
|
|
228
|
+
this.state = "FIRST_DOCUMENT_START";
|
|
229
|
+
}
|
|
230
|
+
emitDocumentStart(event, first) {
|
|
231
|
+
if (event.type === "DOCUMENT_START") {
|
|
232
|
+
if (event.version.length > 0)
|
|
233
|
+
this.analyzeVersionDirective(event.version);
|
|
234
|
+
for (const [handle, prefix] of event.tagDirectives) {
|
|
235
|
+
this.analyzeTagDirective(handle, prefix);
|
|
236
|
+
this.appendTagDirective(handle, prefix, false);
|
|
237
|
+
}
|
|
238
|
+
for (const [handle, prefix] of DEFAULT_TAG_DIRECTIVES) {
|
|
239
|
+
this.appendTagDirective(handle, prefix, true);
|
|
240
|
+
}
|
|
241
|
+
let implicit = event.implicit;
|
|
242
|
+
if (!first || this.canonical)
|
|
243
|
+
implicit = false;
|
|
244
|
+
const hasVersion = event.version.length > 0;
|
|
245
|
+
if ((hasVersion || event.tagDirectives.length > 0) && this.openEnded) {
|
|
246
|
+
this.writeIndicator("...", true, false, false);
|
|
247
|
+
this.writeIndent();
|
|
248
|
+
}
|
|
249
|
+
this.openEnded = 0;
|
|
250
|
+
if (hasVersion) {
|
|
251
|
+
implicit = false;
|
|
252
|
+
this.writeIndicator("%YAML", true, false, false);
|
|
253
|
+
this.writeIndicator(event.version[1] === 1 ? "1.1" : "1.2", true, false, false);
|
|
254
|
+
this.writeIndent();
|
|
255
|
+
}
|
|
256
|
+
if (event.tagDirectives.length > 0) {
|
|
257
|
+
implicit = false;
|
|
258
|
+
for (const [handle, prefix] of event.tagDirectives) {
|
|
259
|
+
this.writeIndicator("%TAG", true, false, false);
|
|
260
|
+
this.writeTagHandle(handle);
|
|
261
|
+
this.writeTagContent(prefix, true);
|
|
262
|
+
this.writeIndent();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (this.checkEmptyDocument())
|
|
266
|
+
implicit = false;
|
|
267
|
+
if (!implicit) {
|
|
268
|
+
this.writeIndent();
|
|
269
|
+
this.writeIndicator("---", true, false, false);
|
|
270
|
+
if (this.canonical)
|
|
271
|
+
this.writeIndent();
|
|
272
|
+
}
|
|
273
|
+
this.state = "DOCUMENT_CONTENT";
|
|
274
|
+
this.openEnded = 0;
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
else if (event.type === "STREAM_END") {
|
|
278
|
+
if (this.openEnded === 2) {
|
|
279
|
+
this.writeIndicator("...", true, false, false);
|
|
280
|
+
this.openEnded = 0;
|
|
281
|
+
this.writeIndent();
|
|
282
|
+
}
|
|
283
|
+
this.flush();
|
|
284
|
+
this.state = "END";
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
throw new RuntimeError("expected DOCUMENT-START or STREAM-END");
|
|
288
|
+
}
|
|
289
|
+
emitDocumentContent(event) {
|
|
290
|
+
this.states.push("DOCUMENT_END");
|
|
291
|
+
this.emitNode(event, true, false, false, false);
|
|
292
|
+
}
|
|
293
|
+
emitDocumentEnd(event) {
|
|
294
|
+
if (event.type !== "DOCUMENT_END")
|
|
295
|
+
throw new RuntimeError("expected DOCUMENT-END");
|
|
296
|
+
this.writeIndent();
|
|
297
|
+
if (!event.implicit) {
|
|
298
|
+
this.writeIndicator("...", true, false, false);
|
|
299
|
+
this.openEnded = 0;
|
|
300
|
+
this.writeIndent();
|
|
301
|
+
}
|
|
302
|
+
else if (!this.openEnded) {
|
|
303
|
+
this.openEnded = 1;
|
|
304
|
+
}
|
|
305
|
+
this.flush();
|
|
306
|
+
this.state = "DOCUMENT_START";
|
|
307
|
+
this.tagDirectives = [];
|
|
308
|
+
}
|
|
309
|
+
emitFlowSequenceItem(event, first) {
|
|
310
|
+
if (first) {
|
|
311
|
+
this.writeIndicator("[", true, true, false);
|
|
312
|
+
this.increaseIndent(true, false);
|
|
313
|
+
this.flowLevel++;
|
|
314
|
+
}
|
|
315
|
+
if (event.type === "SEQUENCE_END") {
|
|
316
|
+
this.flowLevel--;
|
|
317
|
+
this.indent = this.indents.pop();
|
|
318
|
+
if (this.canonical && !first) {
|
|
319
|
+
this.writeIndicator(",", false, false, false);
|
|
320
|
+
this.writeIndent();
|
|
321
|
+
}
|
|
322
|
+
this.writeIndicator("]", false, false, false);
|
|
323
|
+
this.state = this.states.pop();
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (!first)
|
|
327
|
+
this.writeIndicator(",", false, false, false);
|
|
328
|
+
if (this.canonical || this.column > this.bestWidth)
|
|
329
|
+
this.writeIndent();
|
|
330
|
+
this.states.push("FLOW_SEQUENCE_ITEM");
|
|
331
|
+
this.emitNode(event, false, true, false, false);
|
|
332
|
+
}
|
|
333
|
+
emitFlowMappingKey(event, first) {
|
|
334
|
+
if (first) {
|
|
335
|
+
this.writeIndicator("{", true, true, false);
|
|
336
|
+
this.increaseIndent(true, false);
|
|
337
|
+
this.flowLevel++;
|
|
338
|
+
}
|
|
339
|
+
if (event.type === "MAPPING_END") {
|
|
340
|
+
this.flowLevel--;
|
|
341
|
+
this.indent = this.indents.pop();
|
|
342
|
+
if (this.canonical && !first) {
|
|
343
|
+
this.writeIndicator(",", false, false, false);
|
|
344
|
+
this.writeIndent();
|
|
345
|
+
}
|
|
346
|
+
this.writeIndicator("}", false, false, false);
|
|
347
|
+
this.state = this.states.pop();
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (!first)
|
|
351
|
+
this.writeIndicator(",", false, false, false);
|
|
352
|
+
if (this.canonical || this.column > this.bestWidth)
|
|
353
|
+
this.writeIndent();
|
|
354
|
+
if (!this.canonical && this.checkSimpleKey()) {
|
|
355
|
+
this.states.push("FLOW_MAPPING_SIMPLE_VALUE");
|
|
356
|
+
this.emitNode(event, false, false, true, true);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.writeIndicator("?", true, false, false);
|
|
360
|
+
this.states.push("FLOW_MAPPING_VALUE");
|
|
361
|
+
this.emitNode(event, false, false, true, false);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
emitFlowMappingValue(event, simple) {
|
|
365
|
+
if (simple) {
|
|
366
|
+
this.writeIndicator(":", false, false, false);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
if (this.canonical || this.column > this.bestWidth)
|
|
370
|
+
this.writeIndent();
|
|
371
|
+
this.writeIndicator(":", true, false, false);
|
|
372
|
+
}
|
|
373
|
+
this.states.push("FLOW_MAPPING_KEY");
|
|
374
|
+
this.emitNode(event, false, false, true, false);
|
|
375
|
+
}
|
|
376
|
+
emitBlockSequenceItem(event, first) {
|
|
377
|
+
if (first)
|
|
378
|
+
this.increaseIndent(false, this.mappingContext && !this.indention);
|
|
379
|
+
if (event.type === "SEQUENCE_END") {
|
|
380
|
+
this.indent = this.indents.pop();
|
|
381
|
+
this.state = this.states.pop();
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
this.writeIndent();
|
|
385
|
+
this.writeIndicator("-", true, false, true);
|
|
386
|
+
this.states.push("BLOCK_SEQUENCE_ITEM");
|
|
387
|
+
this.emitNode(event, false, true, false, false);
|
|
388
|
+
}
|
|
389
|
+
emitBlockMappingKey(event, first) {
|
|
390
|
+
if (first)
|
|
391
|
+
this.increaseIndent(false, false);
|
|
392
|
+
if (event.type === "MAPPING_END") {
|
|
393
|
+
this.indent = this.indents.pop();
|
|
394
|
+
this.state = this.states.pop();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
this.writeIndent();
|
|
398
|
+
if (this.checkSimpleKey()) {
|
|
399
|
+
this.states.push("BLOCK_MAPPING_SIMPLE_VALUE");
|
|
400
|
+
this.emitNode(event, false, false, true, true);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
this.writeIndicator("?", true, false, true);
|
|
404
|
+
this.states.push("BLOCK_MAPPING_VALUE");
|
|
405
|
+
this.emitNode(event, false, false, true, false);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
emitBlockMappingValue(event, simple) {
|
|
409
|
+
if (simple) {
|
|
410
|
+
this.writeIndicator(":", false, false, false);
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
this.writeIndent();
|
|
414
|
+
this.writeIndicator(":", true, false, true);
|
|
415
|
+
}
|
|
416
|
+
this.states.push("BLOCK_MAPPING_KEY");
|
|
417
|
+
this.emitNode(event, false, false, true, false);
|
|
418
|
+
}
|
|
419
|
+
emitNode(event, root, sequence, mapping, simpleKey) {
|
|
420
|
+
this.rootContext = root;
|
|
421
|
+
this.sequenceContext = sequence;
|
|
422
|
+
this.mappingContext = mapping;
|
|
423
|
+
this.simpleKeyContext = simpleKey;
|
|
424
|
+
switch (event.type) {
|
|
425
|
+
case "ALIAS":
|
|
426
|
+
return this.emitAlias();
|
|
427
|
+
case "SCALAR":
|
|
428
|
+
return this.emitScalar(event);
|
|
429
|
+
case "SEQUENCE_START":
|
|
430
|
+
return this.emitSequenceStart(event);
|
|
431
|
+
case "MAPPING_START":
|
|
432
|
+
return this.emitMappingStart(event);
|
|
433
|
+
default:
|
|
434
|
+
throw new RuntimeError("expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
emitAlias() {
|
|
438
|
+
this.processAnchor();
|
|
439
|
+
if (this.simpleKeyContext)
|
|
440
|
+
this.put(" ");
|
|
441
|
+
this.state = this.states.pop();
|
|
442
|
+
}
|
|
443
|
+
emitScalar(event) {
|
|
444
|
+
this.selectScalarStyle(event);
|
|
445
|
+
this.processAnchor();
|
|
446
|
+
this.processTag();
|
|
447
|
+
this.increaseIndent(true, false);
|
|
448
|
+
this.processScalar();
|
|
449
|
+
this.indent = this.indents.pop();
|
|
450
|
+
this.state = this.states.pop();
|
|
451
|
+
}
|
|
452
|
+
emitSequenceStart(event) {
|
|
453
|
+
this.processAnchor();
|
|
454
|
+
this.processTag();
|
|
455
|
+
if (this.flowLevel ||
|
|
456
|
+
this.canonical ||
|
|
457
|
+
event.style === Sequence.FLOW ||
|
|
458
|
+
this.checkEmptySequence()) {
|
|
459
|
+
this.state = "FLOW_SEQUENCE_FIRST_ITEM";
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
this.state = "BLOCK_SEQUENCE_FIRST_ITEM";
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
emitMappingStart(event) {
|
|
466
|
+
this.processAnchor();
|
|
467
|
+
this.processTag();
|
|
468
|
+
if (this.flowLevel ||
|
|
469
|
+
this.canonical ||
|
|
470
|
+
event.style === Mapping.FLOW ||
|
|
471
|
+
this.checkEmptyMapping()) {
|
|
472
|
+
this.state = "FLOW_MAPPING_FIRST_KEY";
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
this.state = "BLOCK_MAPPING_FIRST_KEY";
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
increaseIndent(flow, indentless) {
|
|
479
|
+
this.indents.push(this.indent);
|
|
480
|
+
if (this.indent < 0) {
|
|
481
|
+
this.indent = flow ? this.bestIndent : 0;
|
|
482
|
+
}
|
|
483
|
+
else if (!indentless) {
|
|
484
|
+
this.indent += this.bestIndent;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
checkEmptyDocument() {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
checkEmptySequence() {
|
|
491
|
+
if (this.events.length < 2)
|
|
492
|
+
return false;
|
|
493
|
+
return this.events[0].type === "SEQUENCE_START" && this.events[1].type === "SEQUENCE_END";
|
|
494
|
+
}
|
|
495
|
+
checkEmptyMapping() {
|
|
496
|
+
if (this.events.length < 2)
|
|
497
|
+
return false;
|
|
498
|
+
return this.events[0].type === "MAPPING_START" && this.events[1].type === "MAPPING_END";
|
|
499
|
+
}
|
|
500
|
+
checkSimpleKey() {
|
|
501
|
+
const event = this.events[0];
|
|
502
|
+
let length = 0;
|
|
503
|
+
const tagLength = width(this.tagData.handle ?? "") + width(this.tagData.suffix ?? "");
|
|
504
|
+
const anchorLength = width(this.anchorData?.anchor ?? "");
|
|
505
|
+
switch (event.type) {
|
|
506
|
+
case "ALIAS":
|
|
507
|
+
length += anchorLength;
|
|
508
|
+
break;
|
|
509
|
+
case "SCALAR":
|
|
510
|
+
if (this.scalarData.multiline)
|
|
511
|
+
return false;
|
|
512
|
+
length += anchorLength + tagLength + width(this.scalarData.value);
|
|
513
|
+
break;
|
|
514
|
+
case "SEQUENCE_START":
|
|
515
|
+
if (!this.checkEmptySequence())
|
|
516
|
+
return false;
|
|
517
|
+
length += anchorLength + tagLength;
|
|
518
|
+
break;
|
|
519
|
+
case "MAPPING_START":
|
|
520
|
+
if (!this.checkEmptyMapping())
|
|
521
|
+
return false;
|
|
522
|
+
length += anchorLength + tagLength;
|
|
523
|
+
break;
|
|
524
|
+
default:
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
if (length > 128)
|
|
528
|
+
return false;
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
selectScalarStyle(event) {
|
|
532
|
+
let style = event.style;
|
|
533
|
+
const noTag = !this.tagData.handle && !this.tagData.suffix;
|
|
534
|
+
if (noTag && !event.plainImplicit && !event.quotedImplicit) {
|
|
535
|
+
throw new RuntimeError("neither tag nor implicit flags are specified");
|
|
536
|
+
}
|
|
537
|
+
if (style === Scalar.ANY)
|
|
538
|
+
style = Scalar.PLAIN;
|
|
539
|
+
if (this.canonical)
|
|
540
|
+
style = Scalar.DOUBLE_QUOTED;
|
|
541
|
+
if (this.simpleKeyContext && this.scalarData.multiline)
|
|
542
|
+
style = Scalar.DOUBLE_QUOTED;
|
|
543
|
+
if (style === Scalar.PLAIN) {
|
|
544
|
+
if ((this.flowLevel && !this.scalarData.flowPlainAllowed) ||
|
|
545
|
+
(!this.flowLevel && !this.scalarData.blockPlainAllowed)) {
|
|
546
|
+
style = Scalar.SINGLE_QUOTED;
|
|
547
|
+
}
|
|
548
|
+
if (!this.scalarData.value.length && (this.flowLevel || this.simpleKeyContext)) {
|
|
549
|
+
style = Scalar.SINGLE_QUOTED;
|
|
550
|
+
}
|
|
551
|
+
if (noTag && !event.plainImplicit)
|
|
552
|
+
style = Scalar.SINGLE_QUOTED;
|
|
553
|
+
}
|
|
554
|
+
if (style === Scalar.SINGLE_QUOTED) {
|
|
555
|
+
if (!this.scalarData.singleQuotedAllowed)
|
|
556
|
+
style = Scalar.DOUBLE_QUOTED;
|
|
557
|
+
}
|
|
558
|
+
if (style === Scalar.LITERAL || style === Scalar.FOLDED) {
|
|
559
|
+
if (!this.scalarData.blockAllowed || this.flowLevel || this.simpleKeyContext) {
|
|
560
|
+
style = Scalar.DOUBLE_QUOTED;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (noTag && !event.quotedImplicit && style !== Scalar.PLAIN) {
|
|
564
|
+
this.tagData = { handle: "!", suffix: null };
|
|
565
|
+
}
|
|
566
|
+
this.scalarData.style = style;
|
|
567
|
+
}
|
|
568
|
+
processAnchor() {
|
|
569
|
+
if (!this.anchorData)
|
|
570
|
+
return;
|
|
571
|
+
this.writeIndicator(this.anchorData.alias ? "*" : "&", true, false, false);
|
|
572
|
+
this.writeAnchor(this.anchorData.anchor);
|
|
573
|
+
}
|
|
574
|
+
processTag() {
|
|
575
|
+
const { handle, suffix } = this.tagData;
|
|
576
|
+
if (!handle && !suffix)
|
|
577
|
+
return;
|
|
578
|
+
if (handle) {
|
|
579
|
+
this.writeTagHandle(handle);
|
|
580
|
+
if (suffix)
|
|
581
|
+
this.writeTagContent(suffix, false);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
this.writeIndicator("!<", true, false, false);
|
|
585
|
+
this.writeTagContent(suffix, false);
|
|
586
|
+
this.writeIndicator(">", false, false, false);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
processScalar() {
|
|
590
|
+
const { value, style } = this.scalarData;
|
|
591
|
+
switch (style) {
|
|
592
|
+
case Scalar.PLAIN:
|
|
593
|
+
return this.writePlainScalar(value, !this.simpleKeyContext);
|
|
594
|
+
case Scalar.SINGLE_QUOTED:
|
|
595
|
+
return this.writeSingleQuoted(value, !this.simpleKeyContext);
|
|
596
|
+
case Scalar.DOUBLE_QUOTED:
|
|
597
|
+
return this.writeDoubleQuoted(value, !this.simpleKeyContext);
|
|
598
|
+
case Scalar.LITERAL:
|
|
599
|
+
return this.writeLiteralScalar(value);
|
|
600
|
+
case Scalar.FOLDED:
|
|
601
|
+
return this.writeFoldedScalar(value);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
analyzeVersionDirective(versionDirective) {
|
|
605
|
+
if (versionDirective[0] !== 1 || (versionDirective[1] !== 1 && versionDirective[1] !== 2)) {
|
|
606
|
+
throw new RuntimeError("incompatible %YAML directive");
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
analyzeTagDirective(handle, prefix) {
|
|
610
|
+
if (!handle.length)
|
|
611
|
+
throw new RuntimeError("tag handle must not be empty");
|
|
612
|
+
if (handle[0] !== "!")
|
|
613
|
+
throw new RuntimeError("tag handle must start with '!'");
|
|
614
|
+
if (handle.at(-1) !== "!")
|
|
615
|
+
throw new RuntimeError("tag handle must end with '!'");
|
|
616
|
+
for (const c of handle.slice(1, -1)) {
|
|
617
|
+
if (!isAlpha(c)) {
|
|
618
|
+
throw new RuntimeError("tag handle must contain alphanumerical characters only");
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
if (!prefix.length)
|
|
622
|
+
throw new RuntimeError("tag prefix must not be empty");
|
|
623
|
+
}
|
|
624
|
+
appendTagDirective(handle, prefix, allowDuplicates) {
|
|
625
|
+
if (this.tagDirectives.some(([h]) => h === handle)) {
|
|
626
|
+
if (allowDuplicates)
|
|
627
|
+
return;
|
|
628
|
+
throw new RuntimeError("duplicate %TAG directive");
|
|
629
|
+
}
|
|
630
|
+
this.tagDirectives.push([handle, prefix]);
|
|
631
|
+
}
|
|
632
|
+
analyzeAnchor(anchor, alias) {
|
|
633
|
+
if (!anchor.length) {
|
|
634
|
+
throw new RuntimeError(alias ? "alias value must not be empty" : "anchor value must not be empty");
|
|
635
|
+
}
|
|
636
|
+
for (const c of anchor) {
|
|
637
|
+
if (!isAlpha(c)) {
|
|
638
|
+
throw new RuntimeError(alias
|
|
639
|
+
? "alias value must contain alphanumerical characters only"
|
|
640
|
+
: "anchor value must contain alphanumerical characters only");
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
this.anchorData = { anchor, alias };
|
|
644
|
+
}
|
|
645
|
+
analyzeTag(tag) {
|
|
646
|
+
if (!tag.length)
|
|
647
|
+
throw new RuntimeError("tag value must not be empty");
|
|
648
|
+
for (const [handle, prefix] of this.tagDirectives) {
|
|
649
|
+
if (prefix.length < tag.length && tag.startsWith(prefix)) {
|
|
650
|
+
this.tagData = { handle, suffix: tag.slice(prefix.length) };
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
this.tagData = { handle: null, suffix: tag };
|
|
655
|
+
}
|
|
656
|
+
analyzeScalar(value) {
|
|
657
|
+
const chars = Array.from(value);
|
|
658
|
+
this.scalarData = {
|
|
659
|
+
value,
|
|
660
|
+
multiline: false,
|
|
661
|
+
flowPlainAllowed: false,
|
|
662
|
+
blockPlainAllowed: true,
|
|
663
|
+
singleQuotedAllowed: true,
|
|
664
|
+
blockAllowed: false,
|
|
665
|
+
style: Scalar.ANY,
|
|
666
|
+
};
|
|
667
|
+
if (!chars.length)
|
|
668
|
+
return;
|
|
669
|
+
let blockIndicators = false;
|
|
670
|
+
let flowIndicators = false;
|
|
671
|
+
let lineBreaks = false;
|
|
672
|
+
let specialCharacters = false;
|
|
673
|
+
let leadingSpace = false;
|
|
674
|
+
let leadingBreak = false;
|
|
675
|
+
let trailingSpace = false;
|
|
676
|
+
let trailingBreak = false;
|
|
677
|
+
let breakSpace = false;
|
|
678
|
+
let spaceBreak = false;
|
|
679
|
+
let previousSpace = false;
|
|
680
|
+
let previousBreak = false;
|
|
681
|
+
if ((value.startsWith("---") || value.startsWith("...")) && chars.length >= 3) {
|
|
682
|
+
blockIndicators = true;
|
|
683
|
+
flowIndicators = true;
|
|
684
|
+
}
|
|
685
|
+
let precededByWhitespace = true;
|
|
686
|
+
let followedByWhitespace = isBlankz(chars[1]);
|
|
687
|
+
for (let i = 0; i < chars.length; i++) {
|
|
688
|
+
const c = chars[i];
|
|
689
|
+
if (i === 0) {
|
|
690
|
+
if ("#,[]{}&*!|>'\"%@`".includes(c)) {
|
|
691
|
+
flowIndicators = true;
|
|
692
|
+
blockIndicators = true;
|
|
693
|
+
}
|
|
694
|
+
if (c === "?" || c === ":") {
|
|
695
|
+
flowIndicators = true;
|
|
696
|
+
if (followedByWhitespace)
|
|
697
|
+
blockIndicators = true;
|
|
698
|
+
}
|
|
699
|
+
if (c === "-" && followedByWhitespace) {
|
|
700
|
+
flowIndicators = true;
|
|
701
|
+
blockIndicators = true;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
if (",?[]{}".includes(c))
|
|
706
|
+
flowIndicators = true;
|
|
707
|
+
if (c === ":") {
|
|
708
|
+
flowIndicators = true;
|
|
709
|
+
if (followedByWhitespace)
|
|
710
|
+
blockIndicators = true;
|
|
711
|
+
}
|
|
712
|
+
if (c === "#" && precededByWhitespace) {
|
|
713
|
+
flowIndicators = true;
|
|
714
|
+
blockIndicators = true;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (!isPrintable(c) || (c.codePointAt(0) > 0x7f && !this.unicode)) {
|
|
718
|
+
specialCharacters = true;
|
|
719
|
+
}
|
|
720
|
+
if (isBreak(c))
|
|
721
|
+
lineBreaks = true;
|
|
722
|
+
if (isSpace(c)) {
|
|
723
|
+
if (i === 0)
|
|
724
|
+
leadingSpace = true;
|
|
725
|
+
if (i === chars.length - 1)
|
|
726
|
+
trailingSpace = true;
|
|
727
|
+
if (previousBreak)
|
|
728
|
+
breakSpace = true;
|
|
729
|
+
previousSpace = true;
|
|
730
|
+
previousBreak = false;
|
|
731
|
+
}
|
|
732
|
+
else if (isBreak(c)) {
|
|
733
|
+
if (i === 0)
|
|
734
|
+
leadingBreak = true;
|
|
735
|
+
if (i === chars.length - 1)
|
|
736
|
+
trailingBreak = true;
|
|
737
|
+
if (previousSpace)
|
|
738
|
+
spaceBreak = true;
|
|
739
|
+
previousBreak = true;
|
|
740
|
+
previousSpace = false;
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
previousSpace = false;
|
|
744
|
+
previousBreak = false;
|
|
745
|
+
}
|
|
746
|
+
precededByWhitespace = isBlankz(c);
|
|
747
|
+
if (i + 1 < chars.length)
|
|
748
|
+
followedByWhitespace = isBlankz(chars[i + 2]);
|
|
749
|
+
}
|
|
750
|
+
const data = this.scalarData;
|
|
751
|
+
data.multiline = lineBreaks;
|
|
752
|
+
data.flowPlainAllowed = true;
|
|
753
|
+
data.blockPlainAllowed = true;
|
|
754
|
+
data.singleQuotedAllowed = true;
|
|
755
|
+
data.blockAllowed = true;
|
|
756
|
+
if (leadingSpace || leadingBreak || trailingSpace || trailingBreak) {
|
|
757
|
+
data.flowPlainAllowed = false;
|
|
758
|
+
data.blockPlainAllowed = false;
|
|
759
|
+
}
|
|
760
|
+
if (trailingSpace)
|
|
761
|
+
data.blockAllowed = false;
|
|
762
|
+
if (breakSpace) {
|
|
763
|
+
data.flowPlainAllowed = false;
|
|
764
|
+
data.blockPlainAllowed = false;
|
|
765
|
+
data.singleQuotedAllowed = false;
|
|
766
|
+
}
|
|
767
|
+
if (spaceBreak || specialCharacters) {
|
|
768
|
+
data.flowPlainAllowed = false;
|
|
769
|
+
data.blockPlainAllowed = false;
|
|
770
|
+
data.singleQuotedAllowed = false;
|
|
771
|
+
data.blockAllowed = false;
|
|
772
|
+
}
|
|
773
|
+
if (lineBreaks) {
|
|
774
|
+
data.flowPlainAllowed = false;
|
|
775
|
+
data.blockPlainAllowed = false;
|
|
776
|
+
}
|
|
777
|
+
if (flowIndicators)
|
|
778
|
+
data.flowPlainAllowed = false;
|
|
779
|
+
if (blockIndicators)
|
|
780
|
+
data.blockPlainAllowed = false;
|
|
781
|
+
}
|
|
782
|
+
analyzeEvent(event) {
|
|
783
|
+
this.anchorData = null;
|
|
784
|
+
this.tagData = { handle: null, suffix: null };
|
|
785
|
+
this.scalarData = {
|
|
786
|
+
value: "",
|
|
787
|
+
multiline: false,
|
|
788
|
+
flowPlainAllowed: false,
|
|
789
|
+
blockPlainAllowed: false,
|
|
790
|
+
singleQuotedAllowed: false,
|
|
791
|
+
blockAllowed: false,
|
|
792
|
+
style: Scalar.ANY,
|
|
793
|
+
};
|
|
794
|
+
switch (event.type) {
|
|
795
|
+
case "ALIAS":
|
|
796
|
+
this.analyzeAnchor(event.anchor, true);
|
|
797
|
+
return;
|
|
798
|
+
case "SCALAR":
|
|
799
|
+
if (event.anchor != null)
|
|
800
|
+
this.analyzeAnchor(event.anchor, false);
|
|
801
|
+
if (event.tag != null &&
|
|
802
|
+
(this.canonical || (!event.plainImplicit && !event.quotedImplicit))) {
|
|
803
|
+
this.analyzeTag(event.tag);
|
|
804
|
+
}
|
|
805
|
+
this.analyzeScalar(event.value);
|
|
806
|
+
return;
|
|
807
|
+
case "SEQUENCE_START":
|
|
808
|
+
case "MAPPING_START":
|
|
809
|
+
if (event.anchor != null)
|
|
810
|
+
this.analyzeAnchor(event.anchor, false);
|
|
811
|
+
if (event.tag != null && (this.canonical || !event.implicit))
|
|
812
|
+
this.analyzeTag(event.tag);
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
flush() {
|
|
817
|
+
if (!this.buffer.length)
|
|
818
|
+
return;
|
|
819
|
+
this.io.write(this.buffer);
|
|
820
|
+
this.buffer = "";
|
|
821
|
+
}
|
|
822
|
+
put(value) {
|
|
823
|
+
this.buffer += value;
|
|
824
|
+
this.column++;
|
|
825
|
+
}
|
|
826
|
+
putBreak() {
|
|
827
|
+
this.buffer += "\n";
|
|
828
|
+
this.column = 0;
|
|
829
|
+
this.line++;
|
|
830
|
+
}
|
|
831
|
+
write(c) {
|
|
832
|
+
this.buffer += c;
|
|
833
|
+
this.column++;
|
|
834
|
+
}
|
|
835
|
+
writeBreak(c) {
|
|
836
|
+
if (c === "\n") {
|
|
837
|
+
this.putBreak();
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
this.buffer += c;
|
|
841
|
+
this.column = 0;
|
|
842
|
+
this.line++;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
writeIndent() {
|
|
846
|
+
const indent = this.indent >= 0 ? this.indent : 0;
|
|
847
|
+
if (!this.indention || this.column > indent || (this.column === indent && !this.whitespace)) {
|
|
848
|
+
this.putBreak();
|
|
849
|
+
}
|
|
850
|
+
while (this.column < indent)
|
|
851
|
+
this.put(" ");
|
|
852
|
+
this.whitespace = true;
|
|
853
|
+
this.indention = true;
|
|
854
|
+
}
|
|
855
|
+
writeIndicator(indicator, needWhitespace, isWhitespace, isIndention) {
|
|
856
|
+
if (needWhitespace && !this.whitespace)
|
|
857
|
+
this.put(" ");
|
|
858
|
+
for (const c of indicator)
|
|
859
|
+
this.write(c);
|
|
860
|
+
this.whitespace = isWhitespace;
|
|
861
|
+
this.indention = this.indention && isIndention;
|
|
862
|
+
}
|
|
863
|
+
writeAnchor(value) {
|
|
864
|
+
for (const c of value)
|
|
865
|
+
this.write(c);
|
|
866
|
+
this.whitespace = false;
|
|
867
|
+
this.indention = false;
|
|
868
|
+
}
|
|
869
|
+
writeTagHandle(value) {
|
|
870
|
+
if (!this.whitespace)
|
|
871
|
+
this.put(" ");
|
|
872
|
+
for (const c of value)
|
|
873
|
+
this.write(c);
|
|
874
|
+
this.whitespace = false;
|
|
875
|
+
this.indention = false;
|
|
876
|
+
}
|
|
877
|
+
writeTagContent(value, needWhitespace) {
|
|
878
|
+
if (needWhitespace && !this.whitespace)
|
|
879
|
+
this.put(" ");
|
|
880
|
+
for (const c of value) {
|
|
881
|
+
if (isAlpha(c) || ";/?:@&=+$,_.~*'()[]".includes(c)) {
|
|
882
|
+
this.write(c);
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
for (const byte of encoder.encode(c)) {
|
|
886
|
+
this.put("%");
|
|
887
|
+
for (const digit of byte.toString(16).toUpperCase().padStart(2, "0"))
|
|
888
|
+
this.put(digit);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
this.whitespace = false;
|
|
893
|
+
this.indention = false;
|
|
894
|
+
}
|
|
895
|
+
writePlainScalar(value, allowBreaks) {
|
|
896
|
+
const chars = Array.from(value);
|
|
897
|
+
let spaces = false;
|
|
898
|
+
let breaks = false;
|
|
899
|
+
if (!this.whitespace && (chars.length || this.flowLevel))
|
|
900
|
+
this.put(" ");
|
|
901
|
+
for (let i = 0; i < chars.length; i++) {
|
|
902
|
+
const c = chars[i];
|
|
903
|
+
if (isSpace(c)) {
|
|
904
|
+
if (allowBreaks && !spaces && this.column > this.bestWidth && !isSpace(chars[i + 1])) {
|
|
905
|
+
this.writeIndent();
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
this.write(c);
|
|
909
|
+
}
|
|
910
|
+
spaces = true;
|
|
911
|
+
}
|
|
912
|
+
else if (isBreak(c)) {
|
|
913
|
+
if (!breaks && c === "\n")
|
|
914
|
+
this.putBreak();
|
|
915
|
+
this.writeBreak(c);
|
|
916
|
+
this.indention = true;
|
|
917
|
+
breaks = true;
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
if (breaks)
|
|
921
|
+
this.writeIndent();
|
|
922
|
+
this.write(c);
|
|
923
|
+
this.indention = false;
|
|
924
|
+
spaces = false;
|
|
925
|
+
breaks = false;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
this.whitespace = false;
|
|
929
|
+
this.indention = false;
|
|
930
|
+
}
|
|
931
|
+
writeSingleQuoted(value, allowBreaks) {
|
|
932
|
+
const chars = Array.from(value);
|
|
933
|
+
let spaces = false;
|
|
934
|
+
let breaks = false;
|
|
935
|
+
this.writeIndicator("'", true, false, false);
|
|
936
|
+
for (let i = 0; i < chars.length; i++) {
|
|
937
|
+
const c = chars[i];
|
|
938
|
+
if (isSpace(c)) {
|
|
939
|
+
if (allowBreaks &&
|
|
940
|
+
!spaces &&
|
|
941
|
+
this.column > this.bestWidth &&
|
|
942
|
+
i !== 0 &&
|
|
943
|
+
i !== chars.length - 1 &&
|
|
944
|
+
!isSpace(chars[i + 1])) {
|
|
945
|
+
this.writeIndent();
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
this.write(c);
|
|
949
|
+
}
|
|
950
|
+
spaces = true;
|
|
951
|
+
}
|
|
952
|
+
else if (isBreak(c)) {
|
|
953
|
+
if (!breaks && c === "\n")
|
|
954
|
+
this.putBreak();
|
|
955
|
+
this.writeBreak(c);
|
|
956
|
+
this.indention = true;
|
|
957
|
+
breaks = true;
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
if (breaks)
|
|
961
|
+
this.writeIndent();
|
|
962
|
+
if (c === "'")
|
|
963
|
+
this.put("'");
|
|
964
|
+
this.write(c);
|
|
965
|
+
this.indention = false;
|
|
966
|
+
spaces = false;
|
|
967
|
+
breaks = false;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (breaks)
|
|
971
|
+
this.writeIndent();
|
|
972
|
+
this.writeIndicator("'", false, false, false);
|
|
973
|
+
this.whitespace = false;
|
|
974
|
+
this.indention = false;
|
|
975
|
+
}
|
|
976
|
+
writeDoubleQuoted(value, allowBreaks) {
|
|
977
|
+
const chars = Array.from(value);
|
|
978
|
+
let spaces = false;
|
|
979
|
+
this.writeIndicator('"', true, false, false);
|
|
980
|
+
for (let i = 0; i < chars.length; i++) {
|
|
981
|
+
const c = chars[i];
|
|
982
|
+
if (!isPrintable(c) ||
|
|
983
|
+
(!this.unicode && c.codePointAt(0) > 0x7f) ||
|
|
984
|
+
isBom(c) ||
|
|
985
|
+
isBreak(c) ||
|
|
986
|
+
c === '"' ||
|
|
987
|
+
c === "\\") {
|
|
988
|
+
this.put("\\");
|
|
989
|
+
const code = c.codePointAt(0);
|
|
990
|
+
const ESCAPES = {
|
|
991
|
+
0x00: "0",
|
|
992
|
+
0x07: "a",
|
|
993
|
+
0x08: "b",
|
|
994
|
+
0x09: "t",
|
|
995
|
+
0x0a: "n",
|
|
996
|
+
0x0b: "v",
|
|
997
|
+
0x0c: "f",
|
|
998
|
+
0x0d: "r",
|
|
999
|
+
0x1b: "e",
|
|
1000
|
+
0x22: '"',
|
|
1001
|
+
0x5c: "\\",
|
|
1002
|
+
0x85: "N",
|
|
1003
|
+
0xa0: "_",
|
|
1004
|
+
0x2028: "L",
|
|
1005
|
+
0x2029: "P",
|
|
1006
|
+
};
|
|
1007
|
+
if (code in ESCAPES) {
|
|
1008
|
+
this.put(ESCAPES[code]);
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
const [indicator, digits] = code <= 0xff ? ["x", 2] : code <= 0xffff ? ["u", 4] : ["U", 8];
|
|
1012
|
+
this.put(indicator);
|
|
1013
|
+
for (const digit of code.toString(16).toUpperCase().padStart(digits, "0")) {
|
|
1014
|
+
this.put(digit);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
spaces = false;
|
|
1018
|
+
}
|
|
1019
|
+
else if (isSpace(c)) {
|
|
1020
|
+
if (allowBreaks &&
|
|
1021
|
+
!spaces &&
|
|
1022
|
+
this.column > this.bestWidth &&
|
|
1023
|
+
i !== 0 &&
|
|
1024
|
+
i !== chars.length - 1) {
|
|
1025
|
+
this.writeIndent();
|
|
1026
|
+
if (isSpace(chars[i + 1]))
|
|
1027
|
+
this.put("\\");
|
|
1028
|
+
}
|
|
1029
|
+
else {
|
|
1030
|
+
this.write(c);
|
|
1031
|
+
}
|
|
1032
|
+
spaces = true;
|
|
1033
|
+
}
|
|
1034
|
+
else {
|
|
1035
|
+
this.write(c);
|
|
1036
|
+
spaces = false;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
this.writeIndicator('"', false, false, false);
|
|
1040
|
+
this.whitespace = false;
|
|
1041
|
+
this.indention = false;
|
|
1042
|
+
}
|
|
1043
|
+
writeBlockScalarHints(chars) {
|
|
1044
|
+
let chompHint = null;
|
|
1045
|
+
if (isSpace(chars[0]) || isBreak(chars[0])) {
|
|
1046
|
+
this.writeIndicator(String(this.bestIndent), false, false, false);
|
|
1047
|
+
}
|
|
1048
|
+
this.openEnded = 0;
|
|
1049
|
+
if (!chars.length) {
|
|
1050
|
+
chompHint = "-";
|
|
1051
|
+
}
|
|
1052
|
+
else if (!isBreak(chars.at(-1))) {
|
|
1053
|
+
chompHint = "-";
|
|
1054
|
+
}
|
|
1055
|
+
else if (chars.length === 1) {
|
|
1056
|
+
chompHint = "+";
|
|
1057
|
+
this.openEnded = 2;
|
|
1058
|
+
}
|
|
1059
|
+
else if (isBreak(chars.at(-2))) {
|
|
1060
|
+
chompHint = "+";
|
|
1061
|
+
this.openEnded = 2;
|
|
1062
|
+
}
|
|
1063
|
+
if (chompHint)
|
|
1064
|
+
this.writeIndicator(chompHint, false, false, false);
|
|
1065
|
+
}
|
|
1066
|
+
writeLiteralScalar(value) {
|
|
1067
|
+
const chars = Array.from(value);
|
|
1068
|
+
let breaks = true;
|
|
1069
|
+
this.writeIndicator("|", true, false, false);
|
|
1070
|
+
this.writeBlockScalarHints(chars);
|
|
1071
|
+
this.putBreak();
|
|
1072
|
+
this.indention = true;
|
|
1073
|
+
this.whitespace = true;
|
|
1074
|
+
for (const c of chars) {
|
|
1075
|
+
if (isBreak(c)) {
|
|
1076
|
+
this.writeBreak(c);
|
|
1077
|
+
this.indention = true;
|
|
1078
|
+
breaks = true;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
if (breaks)
|
|
1082
|
+
this.writeIndent();
|
|
1083
|
+
this.write(c);
|
|
1084
|
+
this.indention = false;
|
|
1085
|
+
breaks = false;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
writeFoldedScalar(value) {
|
|
1090
|
+
const chars = Array.from(value);
|
|
1091
|
+
let breaks = true;
|
|
1092
|
+
let leadingSpaces = true;
|
|
1093
|
+
this.writeIndicator(">", true, false, false);
|
|
1094
|
+
this.writeBlockScalarHints(chars);
|
|
1095
|
+
this.putBreak();
|
|
1096
|
+
this.indention = true;
|
|
1097
|
+
this.whitespace = true;
|
|
1098
|
+
for (let i = 0; i < chars.length; i++) {
|
|
1099
|
+
const c = chars[i];
|
|
1100
|
+
if (isBreak(c)) {
|
|
1101
|
+
if (!breaks && !leadingSpaces && c === "\n") {
|
|
1102
|
+
let k = 0;
|
|
1103
|
+
while (isBreak(chars[i + k]))
|
|
1104
|
+
k++;
|
|
1105
|
+
if (!isBlankz(chars[i + k]))
|
|
1106
|
+
this.putBreak();
|
|
1107
|
+
}
|
|
1108
|
+
this.writeBreak(c);
|
|
1109
|
+
this.indention = true;
|
|
1110
|
+
breaks = true;
|
|
1111
|
+
}
|
|
1112
|
+
else {
|
|
1113
|
+
if (breaks) {
|
|
1114
|
+
this.writeIndent();
|
|
1115
|
+
leadingSpaces = isBlank(c);
|
|
1116
|
+
}
|
|
1117
|
+
if (!breaks && isSpace(c) && !isSpace(chars[i + 1]) && this.column > this.bestWidth) {
|
|
1118
|
+
this.writeIndent();
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
this.write(c);
|
|
1122
|
+
}
|
|
1123
|
+
this.indention = false;
|
|
1124
|
+
breaks = false;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
classpaths.set(Emitter, { path: "Psych::Emitter", permanent: true });
|
|
1130
|
+
//# sourceMappingURL=emitter.js.map
|