@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,889 @@
|
|
|
1
|
+
import { ArgumentError } from "./argument-error.js";
|
|
2
|
+
import { Errno, SystemCallError } from "./errno.js";
|
|
3
|
+
import { Interrupt, SignalException } from "./signal-exception.js";
|
|
4
|
+
import { NotImplementedError } from "./not-implemented-error.js";
|
|
5
|
+
import { RuntimeError } from "./runtime-error.js";
|
|
6
|
+
import { rbExecargNew } from "./process.js";
|
|
7
|
+
import { num2long, rbCheckStringType, stringValue } from "./string/support.js";
|
|
8
|
+
const envInternal = Object.create(null);
|
|
9
|
+
const argvInternal = [];
|
|
10
|
+
export const env = envInternal;
|
|
11
|
+
export const argv = argvInternal;
|
|
12
|
+
const rbArgvInternal = [];
|
|
13
|
+
let prognameInternal = "";
|
|
14
|
+
/**
|
|
15
|
+
* MRI's `ARGV` (`rb_argv`, vendor/ruby/v3.3.11/ruby.c:2980), which
|
|
16
|
+
* `ruby_set_argv` (vendor/ruby/v3.3.11/ruby.c:2984) fills with the arguments
|
|
17
|
+
* that follow the script name.
|
|
18
|
+
*
|
|
19
|
+
* @noRailsEquivalent PERMANENT
|
|
20
|
+
*/
|
|
21
|
+
export function rbArgv() {
|
|
22
|
+
return rbArgvInternal;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* MRI's `ARGV` constant (`rb_argv`, vendor/ruby/v3.3.11/ruby.c:2980), the
|
|
26
|
+
* array `rbArgv` answers: one array for the life of the process, refilled in
|
|
27
|
+
* place when a process adapter is registered.
|
|
28
|
+
*
|
|
29
|
+
* @noRailsEquivalent PERMANENT
|
|
30
|
+
*/
|
|
31
|
+
export const ARGV = rbArgvInternal;
|
|
32
|
+
/**
|
|
33
|
+
* MRI's `$PROGRAM_NAME` / `$0` (`rb_progname`,
|
|
34
|
+
* vendor/ruby/v3.3.11/ruby.c:2970-2971): the name of the script being run.
|
|
35
|
+
*
|
|
36
|
+
* @noRailsEquivalent PERMANENT
|
|
37
|
+
*/
|
|
38
|
+
export function rbProgname() {
|
|
39
|
+
return prognameInternal;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* MRI's `$0 =` (`set_arg0`, vendor/ruby/v3.3.11/ruby.c:2842-2849), the writer
|
|
43
|
+
* half of {@link rbProgname}.
|
|
44
|
+
*
|
|
45
|
+
* @noRailsEquivalent PERMANENT
|
|
46
|
+
*/
|
|
47
|
+
export function setArg0(val) {
|
|
48
|
+
if (!currentAdapter && !tryAutoRegisterNode())
|
|
49
|
+
throw new RuntimeError("$0 not initialized");
|
|
50
|
+
prognameInternal = val;
|
|
51
|
+
}
|
|
52
|
+
let currentAdapter = null;
|
|
53
|
+
function requireAdapter() {
|
|
54
|
+
if (!currentAdapter && !tryAutoRegisterNode()) {
|
|
55
|
+
throw new Error("No process adapter configured. Call registerProcessAdapter() or run in a Node host.");
|
|
56
|
+
}
|
|
57
|
+
return currentAdapter;
|
|
58
|
+
}
|
|
59
|
+
/** @noRailsEquivalent PERMANENT */
|
|
60
|
+
export const stdout = {
|
|
61
|
+
/** @noRailsEquivalent PERMANENT */
|
|
62
|
+
write: (chunk) => requireAdapter().stdout.write(chunk),
|
|
63
|
+
/**
|
|
64
|
+
* `rb_io_flush` (`vendor/ruby/v3.3.11/io.c:2379`). The adapter stream holds no buffer.
|
|
65
|
+
*
|
|
66
|
+
* @noRailsEquivalent PERMANENT
|
|
67
|
+
*/
|
|
68
|
+
flush: () => stdout,
|
|
69
|
+
/** @noRailsEquivalent PERMANENT */
|
|
70
|
+
get isTTY() {
|
|
71
|
+
return requireAdapter().stdout.isTTY;
|
|
72
|
+
},
|
|
73
|
+
/** @noRailsEquivalent PERMANENT */
|
|
74
|
+
get columns() {
|
|
75
|
+
return requireAdapter().stdout.columns;
|
|
76
|
+
},
|
|
77
|
+
/** @noRailsEquivalent PERMANENT */
|
|
78
|
+
get rows() {
|
|
79
|
+
return requireAdapter().stdout.rows;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
/** @noRailsEquivalent PERMANENT */
|
|
83
|
+
export const stderr = {
|
|
84
|
+
/** @noRailsEquivalent PERMANENT */
|
|
85
|
+
write: (chunk) => requireAdapter().stderr.write(chunk),
|
|
86
|
+
/**
|
|
87
|
+
* `rb_io_flush` (`vendor/ruby/v3.3.11/io.c:2379`). The adapter stream holds no buffer.
|
|
88
|
+
*
|
|
89
|
+
* @noRailsEquivalent PERMANENT
|
|
90
|
+
*/
|
|
91
|
+
flush: () => stderr,
|
|
92
|
+
/** @noRailsEquivalent PERMANENT */
|
|
93
|
+
get isTTY() {
|
|
94
|
+
return requireAdapter().stderr.isTTY;
|
|
95
|
+
},
|
|
96
|
+
/** @noRailsEquivalent PERMANENT */
|
|
97
|
+
get columns() {
|
|
98
|
+
return requireAdapter().stderr.columns;
|
|
99
|
+
},
|
|
100
|
+
/** @noRailsEquivalent PERMANENT */
|
|
101
|
+
get rows() {
|
|
102
|
+
return requireAdapter().stderr.rows;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
let stdinBuffer = "";
|
|
106
|
+
let stdinLineno = 0;
|
|
107
|
+
/** `extract_getline_args` (`vendor/ruby/v3.3.11/io.c:4065-4086`), whose `$/` is `"\n"`. */
|
|
108
|
+
function extractGetlineArgs(args) {
|
|
109
|
+
let rs = "\n";
|
|
110
|
+
let lim = null;
|
|
111
|
+
if (args.length === 1) {
|
|
112
|
+
let tmp = null;
|
|
113
|
+
if (args[0] == null || (tmp = rbCheckStringType(args[0])) != null) {
|
|
114
|
+
rs = tmp;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
lim = args[0];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (2 <= args.length) {
|
|
121
|
+
rs = args[0] == null ? null : stringValue(args[0]);
|
|
122
|
+
lim = args[1];
|
|
123
|
+
}
|
|
124
|
+
return { rs, limit: lim == null ? -1 : num2long(lim) };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* `appendline`'s limit (`vendor/ruby/v3.3.11/io.c:4210-4225`): the index just past
|
|
128
|
+
* the character that brings the UTF-8 byte count to `limit`, so a character
|
|
129
|
+
* is never split, or `-1` while the buffer holds fewer bytes.
|
|
130
|
+
*/
|
|
131
|
+
function limitEnd(limit) {
|
|
132
|
+
let bytes = 0;
|
|
133
|
+
let i = 0;
|
|
134
|
+
for (const ch of stdinBuffer) {
|
|
135
|
+
const c = ch.codePointAt(0);
|
|
136
|
+
bytes += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
|
|
137
|
+
i += ch.length;
|
|
138
|
+
if (bytes >= limit)
|
|
139
|
+
return i;
|
|
140
|
+
}
|
|
141
|
+
return -1;
|
|
142
|
+
}
|
|
143
|
+
/** `swallow` (`vendor/ruby/v3.3.11/io.c:3937`): drops every leading `term`. */
|
|
144
|
+
async function swallow(term) {
|
|
145
|
+
for (;;) {
|
|
146
|
+
let i = 0;
|
|
147
|
+
while (i < stdinBuffer.length && stdinBuffer[i] === term)
|
|
148
|
+
i++;
|
|
149
|
+
stdinBuffer = stdinBuffer.slice(i);
|
|
150
|
+
if (stdinBuffer !== "")
|
|
151
|
+
return;
|
|
152
|
+
const chunk = await requireAdapter().stdin.read();
|
|
153
|
+
if (chunk == null)
|
|
154
|
+
return;
|
|
155
|
+
stdinBuffer += chunk;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** @noRailsEquivalent PERMANENT */
|
|
159
|
+
export const stdin = {
|
|
160
|
+
/** @noRailsEquivalent PERMANENT */
|
|
161
|
+
get isTTY() {
|
|
162
|
+
return requireAdapter().stdin.isTTY;
|
|
163
|
+
},
|
|
164
|
+
/** @noRailsEquivalent PERMANENT */
|
|
165
|
+
read: () => {
|
|
166
|
+
if (stdinBuffer !== "") {
|
|
167
|
+
const data = stdinBuffer;
|
|
168
|
+
stdinBuffer = "";
|
|
169
|
+
return Promise.resolve(data);
|
|
170
|
+
}
|
|
171
|
+
return requireAdapter().stdin.read();
|
|
172
|
+
},
|
|
173
|
+
/**
|
|
174
|
+
* `IO#gets` (`vendor/ruby/v3.3.11/io.c:4363` `rb_io_gets_m`) through
|
|
175
|
+
* `prepare_getline_args` (`io.c:4118-4125`) and `rb_io_getline_0`
|
|
176
|
+
* (`io.c:4128-4239`): `gets(sep = $/, limit = nil, chomp: false)`, where a
|
|
177
|
+
* lone Integer is the limit, a `nil` separator reads to end of file, `""`
|
|
178
|
+
* is paragraph mode, and `limit` counts bytes. Answers `nil` at end of file.
|
|
179
|
+
* Asynchronous, because a stdin read is; what the adapter delivered past
|
|
180
|
+
* the line is kept for the next read. `lineno` counts each line not cut by
|
|
181
|
+
* the limit (`io.c:4232-4234`). `rb_io_gets_m`'s `rb_lastline_set`
|
|
182
|
+
* (`io.c:4368`) is not ported: `$_` is a variable of the CALLER's frame,
|
|
183
|
+
* and JS has no way to write one; ARGF, whose `last_lineno` is `$.`
|
|
184
|
+
* (`io.c:4250-4258`), is not ported either.
|
|
185
|
+
*
|
|
186
|
+
* @noRailsEquivalent PERMANENT — Ruby core `IO#gets`, which Thor calls on
|
|
187
|
+
* `$stdin` (`vendor/thor/v1.4.0/lib/thor/line_editor/basic.rb:25`).
|
|
188
|
+
*/
|
|
189
|
+
async gets(...args) {
|
|
190
|
+
let chomp = false;
|
|
191
|
+
const opts = args[args.length - 1];
|
|
192
|
+
if (opts != null && typeof opts === "object" && !("toInt" in opts)) {
|
|
193
|
+
args = args.slice(0, -1);
|
|
194
|
+
const c = opts.chomp;
|
|
195
|
+
chomp = c != null && c !== false;
|
|
196
|
+
}
|
|
197
|
+
const { rs, limit } = extractGetlineArgs(args);
|
|
198
|
+
if (rs == null && limit < 0) {
|
|
199
|
+
let str = stdinBuffer;
|
|
200
|
+
stdinBuffer = "";
|
|
201
|
+
for (let chunk; (chunk = await requireAdapter().stdin.read()) != null;)
|
|
202
|
+
str += chunk;
|
|
203
|
+
if (str === "")
|
|
204
|
+
return null;
|
|
205
|
+
stdinLineno++;
|
|
206
|
+
return str;
|
|
207
|
+
}
|
|
208
|
+
else if (limit === 0) {
|
|
209
|
+
return "";
|
|
210
|
+
}
|
|
211
|
+
let rsptr = rs;
|
|
212
|
+
const rspara = rs === "";
|
|
213
|
+
if (rspara) {
|
|
214
|
+
rsptr = "\n\n";
|
|
215
|
+
await swallow("\n");
|
|
216
|
+
}
|
|
217
|
+
for (;;) {
|
|
218
|
+
const p = rsptr == null ? -1 : stdinBuffer.indexOf(rsptr);
|
|
219
|
+
const e = p === -1 ? -1 : p + rsptr.length;
|
|
220
|
+
const l = limit < 0 ? -1 : limitEnd(limit);
|
|
221
|
+
if (e !== -1 && (l === -1 || e <= l)) {
|
|
222
|
+
let str = stdinBuffer.slice(0, e);
|
|
223
|
+
stdinBuffer = stdinBuffer.slice(e);
|
|
224
|
+
if (chomp)
|
|
225
|
+
str = str.slice(0, rs === "\n" && str[p - 1] === "\r" ? p - 1 : p);
|
|
226
|
+
if (rspara)
|
|
227
|
+
await swallow("\n");
|
|
228
|
+
stdinLineno++;
|
|
229
|
+
return str;
|
|
230
|
+
}
|
|
231
|
+
if (l !== -1) {
|
|
232
|
+
const str = stdinBuffer.slice(0, l);
|
|
233
|
+
stdinBuffer = stdinBuffer.slice(l);
|
|
234
|
+
return str;
|
|
235
|
+
}
|
|
236
|
+
const chunk = await requireAdapter().stdin.read();
|
|
237
|
+
if (chunk == null) {
|
|
238
|
+
if (stdinBuffer === "")
|
|
239
|
+
return null;
|
|
240
|
+
const str = stdinBuffer;
|
|
241
|
+
stdinBuffer = "";
|
|
242
|
+
stdinLineno++;
|
|
243
|
+
return str;
|
|
244
|
+
}
|
|
245
|
+
stdinBuffer += chunk;
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* `IO#lineno` (`vendor/ruby/v3.3.11/io.c:4390` `rb_io_lineno`).
|
|
250
|
+
*
|
|
251
|
+
* @noRailsEquivalent PERMANENT — Ruby core `IO#lineno`, the counter `gets`
|
|
252
|
+
* advances.
|
|
253
|
+
*/
|
|
254
|
+
get lineno() {
|
|
255
|
+
return stdinLineno;
|
|
256
|
+
},
|
|
257
|
+
/**
|
|
258
|
+
* `IO#noecho` (`vendor/ruby/v3.3.11/ext/io/console/console.c:633`
|
|
259
|
+
* `console_noecho`): `ttymode` (`console.c:334-383`) saves the terminal
|
|
260
|
+
* mode with `getattr`, clears only the echo flags with `set_noecho`
|
|
261
|
+
* (`console.c:283-291`), yields the IO, and `setattr`s the saved mode
|
|
262
|
+
* back — after a returned promise settles, since a block that awaits a
|
|
263
|
+
* read has not finished when it returns. The adapter raises the
|
|
264
|
+
* `SystemCallError` for a mode that cannot be read, set or restored, as
|
|
265
|
+
* `ttymode`'s `rb_syserr_fail` (`console.c:365-379`) does, a failed restore
|
|
266
|
+
* even after the block completed; an adapter with no terminal control is
|
|
267
|
+
* `Errno::ENOTTY`.
|
|
268
|
+
*
|
|
269
|
+
* @noRailsEquivalent PERMANENT — `io/console`'s `IO#noecho`, which Thor
|
|
270
|
+
* calls on `$stdin` (`vendor/thor/v1.4.0/lib/thor/line_editor/basic.rb:29`).
|
|
271
|
+
*/
|
|
272
|
+
noecho(block) {
|
|
273
|
+
const io = requireAdapter().stdin;
|
|
274
|
+
if (io.getattr == null || io.setattr == null || io.setNoecho == null) {
|
|
275
|
+
throw new Errno.ENOTTY();
|
|
276
|
+
}
|
|
277
|
+
const t = io.getattr();
|
|
278
|
+
io.setNoecho();
|
|
279
|
+
const setattr = () => {
|
|
280
|
+
io.setattr(t);
|
|
281
|
+
};
|
|
282
|
+
let result;
|
|
283
|
+
try {
|
|
284
|
+
result = block(stdin);
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
setattr();
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
if (result != null && typeof result.then === "function") {
|
|
291
|
+
return Promise.resolve(result).finally(setattr);
|
|
292
|
+
}
|
|
293
|
+
setattr();
|
|
294
|
+
return result;
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
/** @noRailsEquivalent PERMANENT */
|
|
298
|
+
export function chdir(dir) {
|
|
299
|
+
requireAdapter().chdir(dir);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Mirrors: Ruby's Kernel#exit — vendor/ruby/v3.3.11/process.c:4467 `rb_f_exit`,
|
|
303
|
+
* whose status goes through `exit_status_code` (vendor/ruby/v3.3.11/process.c:4398).
|
|
304
|
+
*
|
|
305
|
+
* @noRailsEquivalent PERMANENT
|
|
306
|
+
*/
|
|
307
|
+
export function exit(code) {
|
|
308
|
+
return requireAdapter().exit(typeof code === "boolean" ? (code ? 0 : 1) : code);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* @noRailsEquivalent PERMANENT — Ruby core `Kernel#exit!`
|
|
312
|
+
* (`vendor/ruby/v3.3.11/process.c:4438`), whose status defaults to false.
|
|
313
|
+
*/
|
|
314
|
+
export function exitBang(status = false) {
|
|
315
|
+
return requireAdapter().exit(typeof status === "boolean" ? (status ? 0 : 1) : status);
|
|
316
|
+
}
|
|
317
|
+
/** @noRailsEquivalent PERMANENT */
|
|
318
|
+
export function setExitCode(code) {
|
|
319
|
+
requireAdapter().setExitCode(code);
|
|
320
|
+
}
|
|
321
|
+
/** @noRailsEquivalent PERMANENT */
|
|
322
|
+
export function setSourceMapsSupport(enabled) {
|
|
323
|
+
requireAdapter().setSourceMapsSupport?.(enabled);
|
|
324
|
+
}
|
|
325
|
+
const endProcs = [];
|
|
326
|
+
/**
|
|
327
|
+
* `rb_f_at_exit` (`vendor/ruby/v3.3.11/eval_jump.c:38`), `Kernel#at_exit`,
|
|
328
|
+
* through `rb_set_end_proc` (`:59`): the blocks run once, newest first, when
|
|
329
|
+
* the process exits.
|
|
330
|
+
*
|
|
331
|
+
* @noRailsEquivalent PERMANENT
|
|
332
|
+
*/
|
|
333
|
+
export function atExit(block) {
|
|
334
|
+
if (endProcs.length === 0) {
|
|
335
|
+
requireAdapter().onExit?.(() => {
|
|
336
|
+
for (const proc of endProcs.splice(0).reverse())
|
|
337
|
+
proc();
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
endProcs.push(block);
|
|
341
|
+
return block;
|
|
342
|
+
}
|
|
343
|
+
/** @noRailsEquivalent PERMANENT */
|
|
344
|
+
export function onSignal(name, handler) {
|
|
345
|
+
return requireAdapter().onSignal(name, handler);
|
|
346
|
+
}
|
|
347
|
+
const SIGLIST = {
|
|
348
|
+
EXIT: 0,
|
|
349
|
+
HUP: 1,
|
|
350
|
+
INT: 2,
|
|
351
|
+
QUIT: 3,
|
|
352
|
+
ILL: 4,
|
|
353
|
+
TRAP: 5,
|
|
354
|
+
ABRT: 6,
|
|
355
|
+
IOT: 6,
|
|
356
|
+
FPE: 8,
|
|
357
|
+
KILL: 9,
|
|
358
|
+
BUS: 7,
|
|
359
|
+
SEGV: 11,
|
|
360
|
+
SYS: 31,
|
|
361
|
+
PIPE: 13,
|
|
362
|
+
ALRM: 14,
|
|
363
|
+
TERM: 15,
|
|
364
|
+
URG: 23,
|
|
365
|
+
STOP: 19,
|
|
366
|
+
TSTP: 20,
|
|
367
|
+
CONT: 18,
|
|
368
|
+
CHLD: 17,
|
|
369
|
+
CLD: 17,
|
|
370
|
+
TTIN: 21,
|
|
371
|
+
TTOU: 22,
|
|
372
|
+
IO: 29,
|
|
373
|
+
XCPU: 24,
|
|
374
|
+
XFSZ: 25,
|
|
375
|
+
VTALRM: 26,
|
|
376
|
+
PROF: 27,
|
|
377
|
+
WINCH: 28,
|
|
378
|
+
USR1: 10,
|
|
379
|
+
USR2: 12,
|
|
380
|
+
PWR: 30,
|
|
381
|
+
POLL: 29,
|
|
382
|
+
};
|
|
383
|
+
/** @noRailsEquivalent PERMANENT */
|
|
384
|
+
export const NSIG = 65;
|
|
385
|
+
const traps = new Map();
|
|
386
|
+
/**
|
|
387
|
+
* MRI's `signo2signm` (vendor/ruby/v3.3.11/signal.c:283): a signal number's `siglist` name.
|
|
388
|
+
*
|
|
389
|
+
* @noRailsEquivalent PERMANENT
|
|
390
|
+
*/
|
|
391
|
+
export function signo2signm(no) {
|
|
392
|
+
for (const [signm, signo] of Object.entries(SIGLIST))
|
|
393
|
+
if (signo === no)
|
|
394
|
+
return signm;
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* MRI's `trap_signm` (vendor/ruby/v3.3.11/signal.c:1230-1243): a signal
|
|
399
|
+
* number is range-checked against `NSIG`, and a name, with or without `SIG`,
|
|
400
|
+
* is looked up in `siglist` by `signm2signo` (signal.c:210-281).
|
|
401
|
+
*
|
|
402
|
+
* @noRailsEquivalent PERMANENT
|
|
403
|
+
*/
|
|
404
|
+
export function trapSignm(vsig) {
|
|
405
|
+
if (typeof vsig === "number") {
|
|
406
|
+
if (vsig < 0 || vsig >= NSIG)
|
|
407
|
+
throw new ArgumentError(`invalid signal number (${vsig})`);
|
|
408
|
+
return vsig;
|
|
409
|
+
}
|
|
410
|
+
const nm = vsig.startsWith("SIG") ? vsig.slice(3) : vsig;
|
|
411
|
+
if (nm !== "" && Object.hasOwn(SIGLIST, nm))
|
|
412
|
+
return SIGLIST[nm];
|
|
413
|
+
throw new ArgumentError(`unsupported signal \`SIG${nm}'`);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* MRI's `reserved_signal_p` (vendor/ruby/v3.3.11/signal.c:1287): the signals `trap` refuses.
|
|
417
|
+
*
|
|
418
|
+
* @noRailsEquivalent PERMANENT
|
|
419
|
+
*/
|
|
420
|
+
export function reservedSignalP(signo) {
|
|
421
|
+
return signo === 11 || signo === 7 || signo === 4 || signo === 8 || signo === 26;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* MRI's `trap` (`sig_trap`, vendor/ruby/v3.3.11/signal.c:1348): installs
|
|
425
|
+
* `command` for `signal` (a name, with or without `SIG`, or a number, per
|
|
426
|
+
* {@link trapSignm}) in place of the previous one and answers the previous
|
|
427
|
+
* one, named as `trap` (signal.c:1247) names it. A reserved signal raises
|
|
428
|
+
* (`reserved_signal_p`, signal.c:1287), and `EXIT` (signal 0) runs its
|
|
429
|
+
* command at exit. String commands follow `trap_handler` (signal.c:1158):
|
|
430
|
+
* `""`, `IGNORE` and `SIG_IGN` ignore the signal, `SYSTEM_DEFAULT` restores
|
|
431
|
+
* the system default, `DEFAULT` and `SIG_DFL` install Ruby's own handler
|
|
432
|
+
* (`default_handler`, signal.c:1100), which raises `Interrupt` for SIGINT and
|
|
433
|
+
* `SignalException` for the other signals Ruby handles, and `EXIT` exits. A
|
|
434
|
+
* signal never trapped answers `"DEFAULT"`.
|
|
435
|
+
*
|
|
436
|
+
* @noRailsEquivalent PERMANENT
|
|
437
|
+
*/
|
|
438
|
+
export function trap(signal, command) {
|
|
439
|
+
const sig = trapSignm(signal);
|
|
440
|
+
if (reservedSignalP(sig)) {
|
|
441
|
+
throw new ArgumentError(`can't trap reserved signal: SIG${signo2signm(sig)}`);
|
|
442
|
+
}
|
|
443
|
+
const signm = `SIG${signo2signm(sig)}`;
|
|
444
|
+
const install = (handler) => {
|
|
445
|
+
if (sig === 0)
|
|
446
|
+
return atExit(handler);
|
|
447
|
+
if (sig === 9 || sig === 19)
|
|
448
|
+
throw new Errno.EINVAL(signm);
|
|
449
|
+
return onSignal(signm, handler);
|
|
450
|
+
};
|
|
451
|
+
const previous = traps.get(sig);
|
|
452
|
+
previous?.off?.();
|
|
453
|
+
let off;
|
|
454
|
+
let oldcmd;
|
|
455
|
+
if (typeof command === "function") {
|
|
456
|
+
off = install(command);
|
|
457
|
+
oldcmd = command;
|
|
458
|
+
}
|
|
459
|
+
else if (command === "" || command === "IGNORE" || command === "SIG_IGN") {
|
|
460
|
+
off = sig === 0 ? null : install(() => { });
|
|
461
|
+
oldcmd = "IGNORE";
|
|
462
|
+
}
|
|
463
|
+
else if (command === "SYSTEM_DEFAULT") {
|
|
464
|
+
off = null;
|
|
465
|
+
oldcmd = "SYSTEM_DEFAULT";
|
|
466
|
+
}
|
|
467
|
+
else if (command === "DEFAULT" || command === "SIG_DFL") {
|
|
468
|
+
if (sig === 2 ||
|
|
469
|
+
sig === 1 ||
|
|
470
|
+
sig === 3 ||
|
|
471
|
+
sig === 15 ||
|
|
472
|
+
sig === 14 ||
|
|
473
|
+
sig === 10 ||
|
|
474
|
+
sig === 12 ||
|
|
475
|
+
sig === 17) {
|
|
476
|
+
off = install(() => {
|
|
477
|
+
throw sig === 2 ? new Interrupt("") : new SignalException(signm);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
else if (sig === 13 || sig === 31) {
|
|
481
|
+
off = install(() => { });
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
off = null;
|
|
485
|
+
}
|
|
486
|
+
oldcmd = "DEFAULT";
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
off = install(() => exit());
|
|
490
|
+
oldcmd = "EXIT";
|
|
491
|
+
}
|
|
492
|
+
traps.set(sig, { command: oldcmd, off });
|
|
493
|
+
return previous?.command ?? "DEFAULT";
|
|
494
|
+
}
|
|
495
|
+
/** @noRailsEquivalent PERMANENT */
|
|
496
|
+
export class SystemExit extends Error {
|
|
497
|
+
/** @noRailsEquivalent PERMANENT */
|
|
498
|
+
status;
|
|
499
|
+
/** @noRailsEquivalent PERMANENT */
|
|
500
|
+
constructor(status, message = "exit") {
|
|
501
|
+
super(message);
|
|
502
|
+
this.name = "SystemExit";
|
|
503
|
+
this.status = status;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/** @noRailsEquivalent PERMANENT */
|
|
507
|
+
export function abort(message) {
|
|
508
|
+
if (message !== undefined)
|
|
509
|
+
stderr.write(`${message}\n`);
|
|
510
|
+
setExitCode(1);
|
|
511
|
+
throw new SystemExit(1, message);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* `Kernel#exec` (`vendor/ruby/v3.3.11/process.c:3015` `rb_f_exec`) for the
|
|
515
|
+
* `exec([env, ] command_line)` and `exec([env, ] exe_path, *args)` forms,
|
|
516
|
+
* read by `rb_execarg_new` (`process.c:2767`): a leading env Hash is laid
|
|
517
|
+
* over `ENV`, and the process is replaced by the command, which does not
|
|
518
|
+
* return. A command that cannot be run raises its `SystemCallError`
|
|
519
|
+
* (`rb_syserr_fail_str`, `process.c:3041`), and a host with no way to run one
|
|
520
|
+
* raises `rb_notimplement`'s `NotImplementedError`
|
|
521
|
+
* (`vendor/ruby/v3.3.11/error.c:3498`).
|
|
522
|
+
*
|
|
523
|
+
* @noRailsEquivalent PERMANENT — Ruby core `Kernel#exec`
|
|
524
|
+
* (`vendor/ruby/v3.3.11/process.c:3015`).
|
|
525
|
+
*/
|
|
526
|
+
export function exec(...argv) {
|
|
527
|
+
const adapter = requireAdapter();
|
|
528
|
+
if (adapter.exec === undefined) {
|
|
529
|
+
throw new NotImplementedError("exec() function is unimplemented on this machine");
|
|
530
|
+
}
|
|
531
|
+
const [prog, env, args] = rbExecargNew(argv);
|
|
532
|
+
return adapter.exec(args == null ? ["/bin/sh", "-c", prog] : [prog, ...args], env);
|
|
533
|
+
}
|
|
534
|
+
let rubyTzUptodateP = false;
|
|
535
|
+
/**
|
|
536
|
+
* MRI's `ruby_tz_uptodate_p` (`vendor/ruby/v3.3.11/time.c:702`), which
|
|
537
|
+
* `update_tz` (`time.c:753-758`) reads.
|
|
538
|
+
*
|
|
539
|
+
* @noRailsEquivalent PERMANENT
|
|
540
|
+
*/
|
|
541
|
+
export function isRubyTzUptodate() {
|
|
542
|
+
return rubyTzUptodateP;
|
|
543
|
+
}
|
|
544
|
+
/** @noRailsEquivalent PERMANENT */
|
|
545
|
+
export function setRubyTzUptodate(val) {
|
|
546
|
+
rubyTzUptodateP = val;
|
|
547
|
+
}
|
|
548
|
+
function rubyResetTimezone(_val) {
|
|
549
|
+
rubyTzUptodateP = false;
|
|
550
|
+
}
|
|
551
|
+
function resetByModifiedEnv(nam, val) {
|
|
552
|
+
if (nam === "TZ") {
|
|
553
|
+
rubyResetTimezone(val);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* MRI's `env_aset` and `env_delete` (`vendor/ruby/v3.3.11/hash.c:4975-4985,5420-5438`).
|
|
558
|
+
*
|
|
559
|
+
* @noRailsEquivalent PERMANENT
|
|
560
|
+
*/
|
|
561
|
+
export function setEnv(key, value) {
|
|
562
|
+
requireAdapter().setEnv(key, value);
|
|
563
|
+
resetByModifiedEnv(key, value);
|
|
564
|
+
if (value === undefined) {
|
|
565
|
+
delete envInternal[key];
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
envInternal[key] = value;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
/** @noRailsEquivalent PERMANENT */
|
|
572
|
+
export function registerProcessAdapter(adapter) {
|
|
573
|
+
const envSnapshot = adapter.envSnapshot();
|
|
574
|
+
const argvSnapshot = adapter.argvSnapshot();
|
|
575
|
+
currentAdapter = adapter;
|
|
576
|
+
stdinBuffer = "";
|
|
577
|
+
stdinLineno = 0;
|
|
578
|
+
for (const k of Object.keys(envInternal))
|
|
579
|
+
delete envInternal[k];
|
|
580
|
+
for (const [key, value] of Object.entries(envSnapshot)) {
|
|
581
|
+
if (value !== undefined)
|
|
582
|
+
envInternal[key] = value;
|
|
583
|
+
}
|
|
584
|
+
argvInternal.length = 0;
|
|
585
|
+
argvInternal.push(...argvSnapshot);
|
|
586
|
+
prognameInternal = argvSnapshot[1] ?? "";
|
|
587
|
+
rbArgvInternal.length = 0;
|
|
588
|
+
rbArgvInternal.push(...argvSnapshot.slice(2));
|
|
589
|
+
}
|
|
590
|
+
/** @noRailsEquivalent PERMANENT */
|
|
591
|
+
export function getProcessAdapter() {
|
|
592
|
+
return requireAdapter();
|
|
593
|
+
}
|
|
594
|
+
/** @noRailsEquivalent PERMANENT */
|
|
595
|
+
export const processAdapterConfig = {
|
|
596
|
+
/** @noRailsEquivalent PERMANENT */
|
|
597
|
+
get adapter() {
|
|
598
|
+
if (!currentAdapter)
|
|
599
|
+
return null;
|
|
600
|
+
if (currentAdapter !== nodeAutoRegistered)
|
|
601
|
+
return "custom";
|
|
602
|
+
return runtime();
|
|
603
|
+
},
|
|
604
|
+
};
|
|
605
|
+
let nodeAutoRegistered = null;
|
|
606
|
+
let nodeAttempted = false;
|
|
607
|
+
function tryAutoRegisterNode() {
|
|
608
|
+
if (currentAdapter)
|
|
609
|
+
return true;
|
|
610
|
+
if (nodeAttempted)
|
|
611
|
+
return false;
|
|
612
|
+
nodeAttempted = true;
|
|
613
|
+
const proc = globalThis.process;
|
|
614
|
+
if (!proc?.versions?.node)
|
|
615
|
+
return false;
|
|
616
|
+
const adapter = buildNodeAdapter(proc);
|
|
617
|
+
if (runtime() === "bun")
|
|
618
|
+
delete adapter.registerHooks;
|
|
619
|
+
nodeAutoRegistered = adapter;
|
|
620
|
+
registerProcessAdapter(adapter);
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
623
|
+
/** @noRailsEquivalent PERMANENT */
|
|
624
|
+
export function runtime() {
|
|
625
|
+
const proc = globalThis.process;
|
|
626
|
+
return proc?.versions?.bun ? "bun" : "node";
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* `getattr` / `setattr` / `set_noecho` (`vendor/ruby/v3.3.11/ext/io/console/console.c:252-291`)
|
|
630
|
+
* on the terminal behind fd 0. Node exposes termios only through
|
|
631
|
+
* `setRawMode`, which also clears `ICANON`, `ISIG` and `ICRNL` where
|
|
632
|
+
* `set_noecho` clears echo alone, so the flags go through `stty(1)`, whose
|
|
633
|
+
* `-g` form is the saved `conmode`. A failure raises the `SystemCallError`
|
|
634
|
+
* whose `strerror` text `stty` reported, as `rb_syserr_fail` does with the
|
|
635
|
+
* failing call's errno. A Windows console takes `console.c:289` instead,
|
|
636
|
+
* clearing `ENABLE_ECHO_INPUT` alone: Node has only `setRawMode`, which also
|
|
637
|
+
* clears `ENABLE_LINE_INPUT` and `ENABLE_PROCESSED_INPUT`, so while echo is off
|
|
638
|
+
* `read` answers a line at CR with backspace applied, and Ctrl-C runs a
|
|
639
|
+
* `SIGINT` trap or else raises `Interrupt` in the reader, as `ENABLE_PROCESSED_INPUT`
|
|
640
|
+
* delivers it. The saved `conmode` is the string `"echo"` or `"-echo"`, as the
|
|
641
|
+
* POSIX arm's is `stty -g`'s text.
|
|
642
|
+
*/
|
|
643
|
+
function stty(proc, args) {
|
|
644
|
+
const childProcess = proc.getBuiltinModule?.("node:child_process");
|
|
645
|
+
if (!proc.stdin.isTTY || childProcess == null)
|
|
646
|
+
throw new Errno.ENOTTY();
|
|
647
|
+
const result = childProcess.spawnSync("stty", args, {
|
|
648
|
+
stdio: [0, "pipe", "pipe"],
|
|
649
|
+
encoding: "utf8",
|
|
650
|
+
});
|
|
651
|
+
if (result.status === 0)
|
|
652
|
+
return String(result.stdout).trim();
|
|
653
|
+
const err = String(result.stderr ?? "")
|
|
654
|
+
.trim()
|
|
655
|
+
.split(": ")
|
|
656
|
+
.pop() ?? "";
|
|
657
|
+
if (err === "" || err === "Inappropriate ioctl for device")
|
|
658
|
+
throw new Errno.ENOTTY();
|
|
659
|
+
throw new SystemCallError(err);
|
|
660
|
+
}
|
|
661
|
+
function buildNodeAdapter(proc) {
|
|
662
|
+
const readChunk = () => new Promise((resolve, reject) => {
|
|
663
|
+
if (proc.stdin.readableEnded || proc.stdin.destroyed) {
|
|
664
|
+
resolve(null);
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
const onData = (...args) => {
|
|
668
|
+
cleanup();
|
|
669
|
+
const data = args[0];
|
|
670
|
+
resolve(typeof data === "string"
|
|
671
|
+
? data
|
|
672
|
+
: data && typeof data.toString === "function"
|
|
673
|
+
? data.toString()
|
|
674
|
+
: null);
|
|
675
|
+
};
|
|
676
|
+
const onTerminal = () => {
|
|
677
|
+
cleanup();
|
|
678
|
+
resolve(null);
|
|
679
|
+
};
|
|
680
|
+
const onError = (...args) => {
|
|
681
|
+
cleanup();
|
|
682
|
+
const err = args[0];
|
|
683
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
684
|
+
};
|
|
685
|
+
const cleanup = () => {
|
|
686
|
+
proc.stdin.pause?.();
|
|
687
|
+
proc.stdin.off("data", onData);
|
|
688
|
+
proc.stdin.off("end", onTerminal);
|
|
689
|
+
proc.stdin.off("close", onTerminal);
|
|
690
|
+
proc.stdin.off("error", onError);
|
|
691
|
+
};
|
|
692
|
+
proc.stdin.once("data", onData);
|
|
693
|
+
proc.stdin.once("end", onTerminal);
|
|
694
|
+
proc.stdin.once("close", onTerminal);
|
|
695
|
+
proc.stdin.once("error", onError);
|
|
696
|
+
});
|
|
697
|
+
const consoleMode = () => {
|
|
698
|
+
let echoInput = true;
|
|
699
|
+
let line = "";
|
|
700
|
+
let keys = "";
|
|
701
|
+
const tty = () => {
|
|
702
|
+
if (!proc.stdin.isTTY || proc.stdin.setRawMode == null)
|
|
703
|
+
throw new Errno.ENOTTY();
|
|
704
|
+
};
|
|
705
|
+
const setConsoleMode = (echo) => {
|
|
706
|
+
tty();
|
|
707
|
+
proc.stdin.setRawMode(!echo);
|
|
708
|
+
echoInput = echo;
|
|
709
|
+
};
|
|
710
|
+
return {
|
|
711
|
+
getattr: () => {
|
|
712
|
+
tty();
|
|
713
|
+
return echoInput ? "echo" : "-echo";
|
|
714
|
+
},
|
|
715
|
+
setattr: (t) => setConsoleMode(t === "echo"),
|
|
716
|
+
setNoecho: () => setConsoleMode(false),
|
|
717
|
+
read: async () => {
|
|
718
|
+
if (echoInput && keys === "")
|
|
719
|
+
return readChunk();
|
|
720
|
+
for (;;) {
|
|
721
|
+
if (keys === "") {
|
|
722
|
+
const chunk = await readChunk();
|
|
723
|
+
if (chunk == null) {
|
|
724
|
+
const rest = line;
|
|
725
|
+
line = "";
|
|
726
|
+
return rest === "" ? null : rest;
|
|
727
|
+
}
|
|
728
|
+
keys = chunk;
|
|
729
|
+
}
|
|
730
|
+
const c = keys[0];
|
|
731
|
+
keys = keys.slice(1);
|
|
732
|
+
switch (c) {
|
|
733
|
+
case "\r":
|
|
734
|
+
case "\n": {
|
|
735
|
+
if (c === "\r" && keys[0] === "\n")
|
|
736
|
+
keys = keys.slice(1);
|
|
737
|
+
const answer = `${line}\n`;
|
|
738
|
+
line = "";
|
|
739
|
+
return answer;
|
|
740
|
+
}
|
|
741
|
+
case "\b":
|
|
742
|
+
case "\x7f":
|
|
743
|
+
line = Array.from(line).slice(0, -1).join("");
|
|
744
|
+
break;
|
|
745
|
+
case "\x03":
|
|
746
|
+
line = "";
|
|
747
|
+
if (proc.listenerCount("SIGINT") > 0)
|
|
748
|
+
proc.emit("SIGINT");
|
|
749
|
+
else
|
|
750
|
+
throw new Interrupt("");
|
|
751
|
+
break;
|
|
752
|
+
default:
|
|
753
|
+
line += c;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
const windowsConsole = proc.platform === "win32" ? consoleMode() : null;
|
|
760
|
+
return {
|
|
761
|
+
envSnapshot: () => ({ ...proc.env }),
|
|
762
|
+
argvSnapshot: () => [...proc.argv],
|
|
763
|
+
cwd: () => proc.cwd(),
|
|
764
|
+
chdir: (dir) => proc.chdir(dir),
|
|
765
|
+
platform: () => proc.platform,
|
|
766
|
+
execPath: () => proc.execPath,
|
|
767
|
+
umask: () => proc.umask(),
|
|
768
|
+
pid: () => proc.pid,
|
|
769
|
+
ppid: () => proc.ppid,
|
|
770
|
+
uid: proc.getuid === undefined ? undefined : () => proc.getuid(),
|
|
771
|
+
kill: (pid, signal) => {
|
|
772
|
+
proc.kill(pid, signal);
|
|
773
|
+
},
|
|
774
|
+
signo: (name) => (proc.getBuiltinModule?.("node:os"))
|
|
775
|
+
.constants.signals[name],
|
|
776
|
+
hostname: () => (proc.getBuiltinModule?.("node:os")).hostname(),
|
|
777
|
+
setEnv: (key, value) => {
|
|
778
|
+
if (value === undefined)
|
|
779
|
+
delete proc.env[key];
|
|
780
|
+
else
|
|
781
|
+
proc.env[key] = value;
|
|
782
|
+
},
|
|
783
|
+
exit: (code) => proc.exit(code),
|
|
784
|
+
exec: (argv, env) => {
|
|
785
|
+
const childProcess = proc.getBuiltinModule?.("node:child_process");
|
|
786
|
+
if (childProcess == null) {
|
|
787
|
+
throw new NotImplementedError("exec() function is unimplemented on this machine");
|
|
788
|
+
}
|
|
789
|
+
const result = childProcess.spawnSync(argv[0], argv.slice(1), {
|
|
790
|
+
stdio: "inherit",
|
|
791
|
+
env: env ?? proc.env,
|
|
792
|
+
});
|
|
793
|
+
if (result.error !== undefined) {
|
|
794
|
+
if (result.error.code === "ENOENT")
|
|
795
|
+
throw new Errno.ENOENT(argv[0]);
|
|
796
|
+
throw new SystemCallError(`${result.error.message} - ${argv[0]}`);
|
|
797
|
+
}
|
|
798
|
+
return proc.exit(result.status ?? 1);
|
|
799
|
+
},
|
|
800
|
+
setExitCode: (code) => {
|
|
801
|
+
proc.exitCode = code;
|
|
802
|
+
},
|
|
803
|
+
setSourceMapsSupport: (enabled) => {
|
|
804
|
+
const nodeModule = proc.getBuiltinModule?.("node:module");
|
|
805
|
+
try {
|
|
806
|
+
nodeModule?.setSourceMapsSupport?.(enabled);
|
|
807
|
+
}
|
|
808
|
+
catch (e) {
|
|
809
|
+
if (e.code !== "ERR_METHOD_NOT_IMPLEMENTED")
|
|
810
|
+
throw e;
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
registerHooks: (hooks) => {
|
|
814
|
+
const nodeModule = proc.getBuiltinModule?.("node:module");
|
|
815
|
+
if (nodeModule?.registerHooks === undefined) {
|
|
816
|
+
throw new NotImplementedError("registerHooks() function is unimplemented on this machine");
|
|
817
|
+
}
|
|
818
|
+
nodeModule.registerHooks(hooks);
|
|
819
|
+
},
|
|
820
|
+
signalListenerCount: (name) => proc.listenerCount(name),
|
|
821
|
+
onExit: (handler) => {
|
|
822
|
+
proc.on("exit", handler);
|
|
823
|
+
},
|
|
824
|
+
onSignal: (name, handler) => {
|
|
825
|
+
proc.on(name, handler);
|
|
826
|
+
return () => {
|
|
827
|
+
proc.off(name, handler);
|
|
828
|
+
};
|
|
829
|
+
},
|
|
830
|
+
stdout: {
|
|
831
|
+
write: (chunk) => proc.stdout.write(chunk),
|
|
832
|
+
get isTTY() {
|
|
833
|
+
return Boolean(proc.stdout.isTTY);
|
|
834
|
+
},
|
|
835
|
+
get columns() {
|
|
836
|
+
return proc.stdout.columns;
|
|
837
|
+
},
|
|
838
|
+
get rows() {
|
|
839
|
+
return proc.stdout.rows;
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
stderr: {
|
|
843
|
+
write: (chunk) => proc.stderr.write(chunk),
|
|
844
|
+
get isTTY() {
|
|
845
|
+
return Boolean(proc.stderr.isTTY);
|
|
846
|
+
},
|
|
847
|
+
get columns() {
|
|
848
|
+
return proc.stderr.columns;
|
|
849
|
+
},
|
|
850
|
+
get rows() {
|
|
851
|
+
return proc.stderr.rows;
|
|
852
|
+
},
|
|
853
|
+
},
|
|
854
|
+
stdin: {
|
|
855
|
+
get isTTY() {
|
|
856
|
+
return Boolean(proc.stdin.isTTY);
|
|
857
|
+
},
|
|
858
|
+
getattr: () => (windowsConsole ? windowsConsole.getattr() : stty(proc, ["-g"])),
|
|
859
|
+
setattr: (t) => {
|
|
860
|
+
if (windowsConsole)
|
|
861
|
+
windowsConsole.setattr(t);
|
|
862
|
+
else
|
|
863
|
+
stty(proc, [t]);
|
|
864
|
+
},
|
|
865
|
+
setNoecho: () => {
|
|
866
|
+
if (windowsConsole)
|
|
867
|
+
windowsConsole.setNoecho();
|
|
868
|
+
else
|
|
869
|
+
stty(proc, ["-echo", "-echoe", "-echok", "-echonl"]);
|
|
870
|
+
},
|
|
871
|
+
read: () => (windowsConsole ? windowsConsole.read() : readChunk()),
|
|
872
|
+
},
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
/** @internal */
|
|
876
|
+
export function __INTERNAL_resetProcessAdapter_TEST_ONLY() {
|
|
877
|
+
currentAdapter = null;
|
|
878
|
+
nodeAutoRegistered = null;
|
|
879
|
+
nodeAttempted = false;
|
|
880
|
+
stdinBuffer = "";
|
|
881
|
+
stdinLineno = 0;
|
|
882
|
+
for (const k of Object.keys(envInternal))
|
|
883
|
+
delete envInternal[k];
|
|
884
|
+
argvInternal.length = 0;
|
|
885
|
+
prognameInternal = "";
|
|
886
|
+
rbArgvInternal.length = 0;
|
|
887
|
+
}
|
|
888
|
+
tryAutoRegisterNode();
|
|
889
|
+
//# sourceMappingURL=process-adapter.js.map
|