eliscript 0.1.3 → 0.1.4
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/COPYING.RUNTIME +93 -0
- package/README.md +15 -3
- package/bin/eliscript-test +29 -0
- package/bootstrap/backends/README.md +5 -4
- package/bootstrap/backends/binary.eli +89 -22
- package/bootstrap/backends/capabilities.eli +9 -4
- package/bootstrap/backends/managed-layout.eli +93 -81
- package/bootstrap/backends/managed.eli +651 -125
- package/bootstrap/backends/native.eli +1791 -324
- package/bootstrap/backends/numeric.eli +71 -7
- package/bootstrap/backends/sha256.eli +165 -68
- package/bootstrap/backends/wasm.eli +461 -52
- package/bootstrap/compiler/analyzer.eli +692 -2
- package/bootstrap/compiler/compiler.eli +16 -3
- package/bootstrap/compiler/emitter.eli +80 -35
- package/bootstrap/compiler/project.eli +175 -1
- package/bootstrap/compiler/transient-analysis.eli +2 -2
- package/bootstrap/host/build.eli +1 -0
- package/bootstrap/host/build.mjs +1 -1
- package/bootstrap/host/build.mjs.map +1 -1
- package/bootstrap/host/bun.mjs +7 -9
- package/bootstrap/host/bun.mjs.map +1 -1
- package/bootstrap/host/check-cli-ground.eli +47 -5
- package/bootstrap/host/check-cli-ground.mjs +60 -19
- package/bootstrap/host/check-cli-ground.mjs.map +1 -1
- package/bootstrap/host/check-cli.mjs +41 -1
- package/bootstrap/host/check-cli.mjs.map +1 -1
- package/bootstrap/host/compiler-session.eli +136 -22
- package/bootstrap/host/eliscript-cli.mjs +1 -1
- package/bootstrap/host/eliscript-cli.mjs.map +1 -1
- package/bootstrap/host/evaluation-cli.eli +33 -1
- package/bootstrap/host/evaluation-cli.mjs +65 -28
- package/bootstrap/host/evaluation-cli.mjs.map +1 -1
- package/bootstrap/host/evaluation.eli +651 -42
- package/bootstrap/host/evaluation.mjs +884 -72
- package/bootstrap/host/evaluation.mjs.map +1 -1
- package/bootstrap/host/project-cli-ground.eli +6 -1
- package/bootstrap/host/project-cli-ground.mjs +33 -32
- package/bootstrap/host/project-cli-ground.mjs.map +1 -1
- package/bootstrap/host/project-cli.mjs +1 -1
- package/bootstrap/host/project-cli.mjs.map +1 -1
- package/bootstrap/host/project-ground.eli +266 -45
- package/bootstrap/host/project-ground.mjs +429 -159
- package/bootstrap/host/project-ground.mjs.map +1 -1
- package/bootstrap/host/project.mjs +30 -40
- package/bootstrap/host/project.mjs.map +1 -1
- package/bootstrap/host/test-cli.eli +379 -0
- package/bootstrap/host/test-cli.mjs +494 -0
- package/bootstrap/host/test-cli.mjs.map +1 -0
- package/browser/README.md +7 -0
- package/browser/host.mjs +21 -29
- package/browser/host.mjs.map +1 -1
- package/browser/worker.mjs +7 -9
- package/browser/worker.mjs.map +1 -1
- package/compiler/eliscript-analyzer.el +694 -0
- package/compiler/eliscript-cli.el +66 -22
- package/compiler/eliscript-emitter.el +67 -43
- package/compiler/eliscript-ir-emitter.el +71 -36
- package/compiler/eliscript-project.el +360 -80
- package/compiler/eliscript-transient-analysis.el +5 -5
- package/compiler/eliscript.el +6 -0
- package/dist/backends/binary.mjs +148 -26
- package/dist/backends/binary.mjs.map +1 -1
- package/dist/backends/capabilities.mjs +11 -4
- package/dist/backends/capabilities.mjs.map +1 -1
- package/dist/backends/elf.mjs +4 -4
- package/dist/backends/elf.mjs.map +1 -1
- package/dist/backends/managed-layout.mjs +53 -56
- package/dist/backends/managed-layout.mjs.map +1 -1
- package/dist/backends/managed.mjs +1116 -375
- package/dist/backends/managed.mjs.map +1 -1
- package/dist/backends/memory.mjs +24 -26
- package/dist/backends/memory.mjs.map +1 -1
- package/dist/backends/native.mjs +2529 -434
- package/dist/backends/native.mjs.map +1 -1
- package/dist/backends/numeric.mjs +140 -33
- package/dist/backends/numeric.mjs.map +1 -1
- package/dist/backends/optimize.mjs +2 -2
- package/dist/backends/optimize.mjs.map +1 -1
- package/dist/backends/regexp.mjs +33 -35
- package/dist/backends/regexp.mjs.map +1 -1
- package/dist/backends/sha256.mjs +159 -59
- package/dist/backends/sha256.mjs.map +1 -1
- package/dist/backends/wasm.mjs +609 -73
- package/dist/backends/wasm.mjs.map +1 -1
- package/dist/bootstrap/analyzer.mjs +1018 -2
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +30 -23
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +206 -161
- package/dist/bootstrap/emitter.mjs.macro-origins.json +16 -16
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +27 -31
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +22 -24
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/project.mjs +246 -1
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +2 -2
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/source-map.mjs +34 -48
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +2 -2
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +106 -106
- package/dist/browser/host.mjs +21 -29
- package/dist/browser/loader.js +1 -1
- package/dist/browser/worker.mjs +95 -95
- package/dist/compiler-artifact.json +1 -1
- package/dist/host/compiler-session.mjs +405 -228
- package/dist/host/compiler-session.mjs.map +1 -1
- package/dist/host/compiler-tools.mjs +44 -46
- package/dist/host/compiler-tools.mjs.map +1 -1
- package/dist/literal-sources/runtime/core/array-map.eli +45 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +22 -2
- package/dist/literal-sources/runtime/core/collection.eli +282 -23
- package/dist/literal-sources/runtime/core/data-text.eli +196 -13
- package/dist/literal-sources/runtime/core/data.eli +1 -1
- package/dist/literal-sources/runtime/core/identifier.eli +1 -1
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +822 -44
- package/dist/literal-sources/runtime/core/list.eli +1 -1
- package/dist/literal-sources/runtime/core/map.eli +1 -1
- package/dist/literal-sources/runtime/core/metadata-internals.eli +2 -2
- package/dist/literal-sources/runtime/core/metadata.eli +2 -2
- package/dist/literal-sources/{stdlib/core/object.eli → runtime/core/object-impl.eli} +6 -6
- package/dist/literal-sources/runtime/core/object.eli +1 -1
- package/dist/literal-sources/runtime/core/order.eli +3 -3
- package/dist/literal-sources/runtime/core/persistent-kind.eli +1 -1
- package/dist/literal-sources/{stdlib/core/protocol.eli → runtime/core/protocol-impl.eli} +2 -2
- package/dist/literal-sources/runtime/core/protocol.eli +5 -3
- package/dist/literal-sources/runtime/core/queue.eli +1 -1
- package/dist/literal-sources/runtime/core/record.eli +3 -3
- package/dist/literal-sources/runtime/core/regex.eli +2 -2
- package/dist/literal-sources/runtime/core/sequence.eli +1 -1
- package/dist/literal-sources/runtime/core/set-algebra.eli +1 -1
- package/dist/literal-sources/runtime/core/set.eli +1 -1
- package/dist/literal-sources/runtime/core/sorted.eli +4 -4
- package/dist/literal-sources/{stdlib/core/text.eli → runtime/core/text-impl.eli} +2 -2
- package/dist/literal-sources/runtime/core/text.eli +1 -1
- package/dist/literal-sources/runtime/core/transducer.eli +24 -2
- package/dist/literal-sources/runtime/core/transient.eli +7 -5
- package/dist/literal-sources/runtime/core/type.eli +1 -1
- package/dist/literal-sources/runtime/core/value-internals.eli +3 -3
- package/dist/literal-sources/runtime/core/value.eli +2 -2
- package/dist/literal-sources/runtime/core/vector.eli +5 -2
- package/dist/literal-sources/{stdlib → runtime/managed}/managed-literal-protocols.eli +100 -34
- package/dist/literal-sources/{stdlib → runtime/managed}/managed-literals.eli +406 -81
- package/{stdlib → dist/literal-sources/runtime/managed}/managed-queue-state.eli +1 -1
- package/{stdlib → dist/literal-sources/runtime/managed}/managed-sorted-state.eli +1 -1
- package/dist/literal-sources/runtime/managed/managed-transient-state.eli +1206 -0
- package/{stdlib → dist/literal-sources/runtime/managed}/managed-value-state.eli +30 -6
- package/dist/literal-sources/{stdlib → runtime/managed}/managed-vector-view-state.eli +1 -1
- package/dist/literal-sources/runtime/wire/http-rpc.eli +1 -1
- package/dist/literal-sources/runtime/wire/markdown.eli +1 -1
- package/dist/literal-sources/runtime/wire/schema.eli +1 -1
- package/dist/literal-sources/stdlib/bit.eli +89 -1
- package/dist/literal-sources/stdlib/data.eli +522 -0
- package/dist/literal-sources/stdlib/interop/object.eli +39 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +60 -21
- package/dist/literal-sources/stdlib/persistent-map.eli +335 -324
- package/dist/literal-sources/stdlib/persistent-set.eli +8 -6
- package/dist/literal-sources/stdlib/persistent-vector.eli +18 -18
- package/dist/literal-sources/stdlib/protocol.eli +63 -0
- package/{stdlib/core → dist/literal-sources/stdlib}/set.eli +8 -8
- package/dist/literal-sources/stdlib/string.eli +362 -0
- package/dist/runtime/lisp/async-runtime.mjs +55 -59
- package/dist/runtime/lisp/async-runtime.mjs.map +1 -1
- package/dist/runtime/lisp/builtins.mjs +232 -280
- package/dist/runtime/lisp/builtins.mjs.map +1 -1
- package/dist/runtime/lisp/cli.mjs +159 -167
- package/dist/runtime/lisp/cli.mjs.map +1 -1
- package/dist/runtime/lisp/compiler.mjs +359 -419
- package/dist/runtime/lisp/compiler.mjs.map +1 -1
- package/dist/runtime/lisp/core.mjs +24 -24
- package/dist/runtime/lisp/core.mjs.map +1 -1
- package/dist/runtime/lisp/evaluator.mjs +315 -385
- package/dist/runtime/lisp/evaluator.mjs.map +1 -1
- package/dist/runtime/lisp/extensions.mjs +85 -103
- package/dist/runtime/lisp/extensions.mjs.map +1 -1
- package/dist/runtime/lisp/host-io.mjs +106 -122
- package/dist/runtime/lisp/host-io.mjs.map +1 -1
- package/dist/runtime/lisp/io-worker.mjs +117 -135
- package/dist/runtime/lisp/io-worker.mjs.map +1 -1
- package/dist/runtime/lisp/keymap.mjs +5 -5
- package/dist/runtime/lisp/keymap.mjs.map +1 -1
- package/dist/runtime/lisp/macros-forms.mjs +49 -51
- package/dist/runtime/lisp/macros-forms.mjs.map +1 -1
- package/dist/runtime/lisp/reader-format.mjs +31 -31
- package/dist/runtime/lisp/reader-format.mjs.map +1 -1
- package/dist/runtime/lisp/regexp-buffer.mjs +9 -9
- package/dist/runtime/lisp/regexp-buffer.mjs.map +1 -1
- package/dist/runtime/math.mjs +32 -38
- package/dist/runtime/math.mjs.map +1 -1
- package/dist/runtime/number-radix.mjs +5 -7
- package/dist/runtime/number-radix.mjs.map +1 -1
- package/dist/runtime/primitives.mjs +81 -46
- package/dist/runtime/primitives.mjs.macro-origins.json +294 -44
- package/dist/runtime/primitives.mjs.map +1 -1
- package/dist/runtime/unicode-case.mjs +6 -6
- package/dist/runtime/unicode-case.mjs.map +1 -1
- package/dist/runtime.eli +3068 -1882
- package/dist/stage3-release.json +1 -1
- package/dist/stdlib/async.mjs +1838 -0
- package/dist/stdlib/bit.mjs +116 -0
- package/dist/stdlib/collection.mjs +193 -0
- package/dist/stdlib/core.mjs +28 -0
- package/dist/stdlib/data-text.mjs +54 -0
- package/dist/stdlib/data.mjs +601 -0
- package/dist/stdlib/devtools.mjs +565 -0
- package/dist/stdlib/diff.mjs +180 -0
- package/dist/stdlib/fn.mjs +164 -0
- package/dist/stdlib/hierarchy.mjs +189 -0
- package/dist/stdlib/identifier.mjs +33 -0
- package/dist/stdlib/interop/js.mjs +706 -0
- package/dist/stdlib/interop/object.mjs +40 -0
- package/dist/stdlib/json.mjs +843 -0
- package/dist/stdlib/lazy-sequence.mjs +117 -0
- package/dist/stdlib/math.mjs +386 -0
- package/dist/stdlib/meta.mjs +21 -0
- package/dist/stdlib/multimethod.mjs +345 -0
- package/dist/stdlib/numeric.mjs +327 -0
- package/dist/stdlib/order.mjs +194 -0
- package/dist/stdlib/persistent-list.mjs +171 -0
- package/dist/stdlib/persistent-map.mjs +781 -0
- package/dist/stdlib/persistent-queue.mjs +44 -0
- package/dist/stdlib/persistent-set.mjs +225 -0
- package/dist/stdlib/persistent-vector.mjs +316 -0
- package/dist/stdlib/portable/data-text.mjs +1094 -0
- package/dist/stdlib/portable/data.mjs +62 -0
- package/dist/stdlib/portable/identifier.mjs +179 -0
- package/dist/stdlib/portable/metadata.mjs +63 -0
- package/dist/stdlib/portable/object.mjs +140 -0
- package/dist/stdlib/portable/sequence.mjs +142 -0
- package/dist/stdlib/portable/text.mjs +111 -0
- package/dist/stdlib/pprint.mjs +807 -0
- package/dist/stdlib/protocol.mjs +61 -0
- package/dist/stdlib/record.mjs +25 -0
- package/dist/stdlib/regex.mjs +115 -0
- package/dist/stdlib/result.mjs +198 -0
- package/dist/stdlib/schema.mjs +2828 -0
- package/dist/stdlib/seq.mjs +913 -0
- package/dist/stdlib/set.mjs +317 -0
- package/dist/stdlib/sorted.mjs +56 -0
- package/dist/stdlib/state.mjs +451 -0
- package/dist/stdlib/string.mjs +494 -0
- package/dist/stdlib/tap.mjs +187 -0
- package/dist/stdlib/test.mjs +669 -0
- package/dist/stdlib/time.mjs +522 -0
- package/dist/stdlib/transducer.mjs +85 -0
- package/dist/stdlib/transient.mjs +32 -0
- package/dist/stdlib/type.mjs +28 -0
- package/dist/stdlib/uuid.mjs +377 -0
- package/dist/stdlib/value.mjs +334 -0
- package/dist/stdlib/walk.mjs +243 -0
- package/dist/stdlib/wire/gepo.mjs +28 -0
- package/dist/stdlib/wire/mdp.mjs +13 -0
- package/dist/stdlib/wire/mds.mjs +10 -0
- package/dist/stdlib/zipper.mjs +1025 -0
- package/editor/README.md +15 -0
- package/editor/eliscript-data.el +221 -8
- package/editor/eliscript-mode.el +207 -48
- package/editor/eliscript-runtime.el +6 -3
- package/package.json +49 -15
- package/platform/README.md +6 -0
- package/platform/browser.mjs +10 -12
- package/platform/browser.mjs.map +1 -1
- package/runtime/README.md +12 -5
- package/runtime/core/array-map.eli +538 -0
- package/runtime/core/array-map.mjs +651 -0
- package/runtime/core/array-map.mjs.map +1 -0
- package/runtime/core/collection-internals.eli +85 -33
- package/runtime/core/collection-internals.mjs +245 -193
- package/runtime/core/collection-internals.mjs.map +1 -1
- package/runtime/core/collection.eli +105 -3
- package/runtime/core/collection.mjs +190 -53
- package/runtime/core/collection.mjs.map +1 -1
- package/runtime/core/data-text.eli +224 -16
- package/runtime/core/data-text.mjs +345 -83
- package/runtime/core/data-text.mjs.map +1 -1
- package/runtime/core/data.eli +50 -33
- package/runtime/core/data.mjs +72 -36
- package/runtime/core/data.mjs.map +1 -1
- package/runtime/core/identifier.mjs +15 -19
- package/runtime/core/identifier.mjs.map +1 -1
- package/runtime/core/lazy-sequence.eli +885 -15
- package/runtime/core/lazy-sequence.mjs +1265 -38
- package/runtime/core/lazy-sequence.mjs.map +1 -1
- package/runtime/core/map-internals.eli +209 -1
- package/runtime/core/map-internals.mjs +359 -71
- package/runtime/core/map-internals.mjs.map +1 -1
- package/runtime/core/map.eli +75 -7
- package/runtime/core/map.mjs +122 -47
- package/runtime/core/map.mjs.map +1 -1
- package/{stdlib/core/object.eli → runtime/core/object-impl.eli} +6 -6
- package/runtime/core/object-impl.mjs +5 -5
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/order.eli +15 -3
- package/runtime/core/order.mjs +23 -8
- package/runtime/core/order.mjs.map +1 -1
- package/runtime/core/persistent-kind.mjs +9 -13
- package/runtime/core/persistent-kind.mjs.map +1 -1
- package/runtime/core/protocol-error.mjs +9 -11
- package/runtime/core/protocol-error.mjs.map +1 -1
- package/{stdlib/core/protocol.eli → runtime/core/protocol-impl.eli} +2 -2
- package/runtime/core/protocol-impl.mjs +10 -10
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/queue.mjs +14 -16
- package/runtime/core/queue.mjs.map +1 -1
- package/runtime/core/record.eli +2 -2
- package/runtime/core/record.mjs +13 -17
- package/runtime/core/record.mjs.map +1 -1
- package/runtime/core/regex.mjs +18 -22
- package/runtime/core/regex.mjs.map +1 -1
- package/runtime/core/sequence.eli +33 -31
- package/runtime/core/sequence.mjs +60 -93
- package/runtime/core/sequence.mjs.map +1 -1
- package/runtime/core/set.eli +53 -27
- package/runtime/core/set.mjs +113 -82
- package/runtime/core/set.mjs.map +1 -1
- package/runtime/core/sorted.mjs +91 -108
- package/runtime/core/sorted.mjs.map +1 -1
- package/{stdlib/core/text.eli → runtime/core/text-impl.eli} +2 -2
- package/runtime/core/text-impl.mjs +1 -1
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/transducer.eli +24 -0
- package/runtime/core/transducer.mjs +27 -1
- package/runtime/core/transducer.mjs.map +1 -1
- package/runtime/core/transient-internals.eli +12 -4
- package/runtime/core/transient-internals.mjs +19 -6
- package/runtime/core/transient-internals.mjs.map +1 -1
- package/runtime/core/transient.eli +31 -0
- package/runtime/core/transient.mjs +33 -2
- package/runtime/core/transient.mjs.map +1 -1
- package/runtime/core/value-internals.mjs +29 -35
- package/runtime/core/value-internals.mjs.map +1 -1
- package/runtime/core/vector.eli +73 -20
- package/runtime/core/vector.mjs +159 -156
- package/runtime/core/vector.mjs.map +1 -1
- package/runtime/literals.eli +16 -9
- package/runtime/literals.mjs +25 -9
- package/runtime/literals.mjs.map +1 -1
- package/{stdlib → runtime/managed}/managed-literal-protocols.eli +100 -34
- package/{stdlib → runtime/managed}/managed-literals.eli +406 -81
- package/{dist/literal-sources/stdlib → runtime/managed}/managed-queue-state.eli +1 -1
- package/runtime/managed/managed-runtime-array-map.eli +45 -0
- package/{stdlib → runtime/managed}/managed-runtime-collection-internals.eli +22 -2
- package/{stdlib → runtime/managed}/managed-runtime-collection.eli +282 -23
- package/{stdlib → runtime/managed}/managed-runtime-data-text.eli +196 -13
- package/{stdlib → runtime/managed}/managed-runtime-data.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-identifier.eli +1 -1
- package/runtime/managed/managed-runtime-lazy-sequence.eli +935 -0
- package/{stdlib → runtime/managed}/managed-runtime-list.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-map.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-metadata-internals.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-metadata.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-object.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-order.eli +3 -3
- package/{stdlib → runtime/managed}/managed-runtime-persistent-kind.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-protocol.eli +5 -3
- package/{stdlib → runtime/managed}/managed-runtime-queue.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-record.eli +3 -3
- package/{stdlib → runtime/managed}/managed-runtime-regex.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-sequence.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-set-algebra.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-set.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-sorted.eli +4 -4
- package/{stdlib → runtime/managed}/managed-runtime-text.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-transducer.eli +24 -2
- package/{stdlib → runtime/managed}/managed-runtime-transient.eli +7 -5
- package/{stdlib → runtime/managed}/managed-runtime-type.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-value-internals.eli +3 -3
- package/{stdlib → runtime/managed}/managed-runtime-value.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-vector.eli +5 -2
- package/{dist/literal-sources/stdlib → runtime/managed}/managed-sorted-state.eli +1 -1
- package/runtime/managed/managed-transient-state.eli +1206 -0
- package/{dist/literal-sources/stdlib → runtime/managed}/managed-value-state.eli +30 -6
- package/{stdlib → runtime/managed}/managed-vector-view-state.eli +1 -1
- package/{stdlib → runtime/managed}/managed-wire-http-rpc.eli +1 -1
- package/{stdlib → runtime/managed}/managed-wire-markdown.eli +1 -1
- package/{stdlib → runtime/managed}/managed-wire-schema.eli +1 -1
- package/runtime/math.mjs +32 -38
- package/runtime/math.mjs.map +1 -1
- package/runtime/number-radix.mjs +5 -7
- package/runtime/number-radix.mjs.map +1 -1
- package/runtime/primitives.eli +19 -6
- package/runtime/primitives.mjs +81 -46
- package/runtime/primitives.mjs.map +1 -1
- package/runtime/source-mapping.mjs +17 -23
- package/runtime/source-mapping.mjs.map +1 -1
- package/runtime/testing/map.eli +70 -41
- package/runtime/testing/map.mjs +57 -34
- package/runtime/testing/map.mjs.map +1 -1
- package/runtime/unicode-case.mjs +6 -6
- package/runtime/unicode-case.mjs.map +1 -1
- package/runtime/wire/http-rpc.mjs +12 -18
- package/runtime/wire/http-rpc.mjs.map +1 -1
- package/runtime/wire/markdown.mjs +42 -42
- package/runtime/wire/markdown.mjs.map +1 -1
- package/runtime/wire/schema.mjs +13 -13
- package/runtime/wire/schema.mjs.map +1 -1
- package/runtime/worker-value-codec.mjs +5 -7
- package/runtime/worker-value-codec.mjs.map +1 -1
- package/runtime/worker-value-stream.mjs +128 -135
- package/runtime/worker-value-stream.mjs.map +1 -1
- package/runtime/worker.mjs +75 -89
- package/runtime/worker.mjs.map +1 -1
- package/stdlib/README.md +25 -18
- package/stdlib/async.eli +1245 -0
- package/stdlib/bit.eli +89 -1
- package/stdlib/bit.mjs +89 -2
- package/stdlib/bit.mjs.map +1 -1
- package/stdlib/{core/collection.eli → collection.eli} +39 -4
- package/stdlib/core.eli +956 -0
- package/stdlib/data-text.eli +62 -1091
- package/stdlib/data.eli +517 -37
- package/stdlib/devtools.eli +399 -0
- package/stdlib/diff.eli +134 -0
- package/stdlib/{function.eli → fn.eli} +1 -1
- package/stdlib/identifier.eli +21 -136
- package/stdlib/interop/object.eli +39 -0
- package/stdlib/{core/lazy-sequence.eli → lazy-sequence.eli} +28 -2
- package/stdlib/math.eli +267 -0
- package/stdlib/{core/metadata.eli → meta.eli} +2 -2
- package/stdlib/{core/order.eli → order.eli} +6 -6
- package/stdlib/persistent-list.eli +60 -21
- package/stdlib/persistent-map.eli +335 -324
- package/stdlib/persistent-set.eli +8 -6
- package/stdlib/persistent-vector.eli +18 -18
- package/stdlib/portable/data-text.eli +1092 -0
- package/stdlib/portable/data.eli +42 -0
- package/stdlib/portable/identifier.eli +147 -0
- package/stdlib/{metadata.eli → portable/metadata.eli} +5 -5
- package/stdlib/{object.eli → portable/object.eli} +1 -1
- package/stdlib/{sequence.eli → portable/sequence.eli} +1 -1
- package/stdlib/{text.eli → portable/text.eli} +1 -1
- package/stdlib/pprint.eli +588 -0
- package/stdlib/protocol.eli +63 -0
- package/stdlib/{core/record.eli → record.eli} +2 -2
- package/stdlib/regex.eli +70 -0
- package/stdlib/result.eli +53 -44
- package/stdlib/schema.eli +1886 -0
- package/stdlib/{core/seq.eli → seq.eli} +97 -90
- package/{dist/literal-sources/stdlib/core → stdlib}/set.eli +8 -8
- package/stdlib/{core/sorted.eli → sorted.eli} +2 -2
- package/stdlib/{state/atom.eli → state.eli} +137 -7
- package/stdlib/string.eli +362 -0
- package/stdlib/tap.eli +135 -0
- package/stdlib/test.eli +566 -0
- package/stdlib/time.eli +419 -0
- package/stdlib/{core/transducer.eli → transducer.eli} +4 -2
- package/stdlib/{core/transient.eli → transient.eli} +11 -5
- package/stdlib/{core/type.eli → type.eli} +2 -2
- package/stdlib/uuid.eli +288 -0
- package/stdlib/{core/walk.eli → walk.eli} +6 -6
- package/stdlib/{gepo.eli → wire/gepo.eli} +2 -2
- package/stdlib/{mdp.eli → wire/mdp.eli} +2 -2
- package/stdlib/{mds.eli → wire/mds.eli} +2 -2
- package/stdlib/{core/zipper.eli → zipper.eli} +179 -138
- package/tests/helpers/wasm-managed-math-node.mjs +495 -582
- package/tools/acceptance/check-ground.mjs +106 -132
- package/tools/acceptance/check.mjs +16 -16
- package/tools/acceptance/retained-performance-snapshot.mjs +265 -149
- package/tools/acceptance/retained-soak.mjs +5 -7
- package/tools/acceptance/retained-transient.mjs +5 -7
- package/tools/backends/build.mjs +373 -95
- package/tools/backends/compiler-bootstrap.mjs +271 -317
- package/tools/backends/compiler-browser.mjs +7 -9
- package/tools/backends/compiler-build.mjs +77 -97
- package/tools/backends/compiler-cli-ground.mjs +47 -47
- package/tools/backends/compiler-data-transport.mjs +27 -31
- package/tools/backends/compiler-host-iteration.mjs +13 -21
- package/tools/backends/compiler-host-record.mjs +28 -34
- package/tools/backends/compiler-metadata.mjs +145 -53
- package/tools/backends/compiler-package-ground.mjs +39 -47
- package/tools/backends/compiler-package-loader.mjs +164 -206
- package/tools/backends/compiler-session.mjs +432 -324
- package/tools/backends/compiler-worker.mjs +79 -89
- package/tools/backends/dist/bootstrap-js-stages.mjs +17 -19
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -1
- package/tools/backends/dist/managed-ir-inventory.mjs +1 -1
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -1
- package/tools/backends/dist/release-cli.mjs +151 -22
- package/tools/backends/dist/release-cli.mjs.map +1 -1
- package/tools/backends/dist/run-artifact.mjs +54 -76
- package/tools/backends/dist/run-artifact.mjs.map +1 -1
- package/tools/backends/managed-foreign-binding.mjs +370 -114
- package/tools/backends/managed-host-ground.mjs +14 -17
- package/tools/backends/managed-host-lifecycle.mjs +42 -53
- package/tools/backends/managed-host-object-realm.mjs +121 -111
- package/tools/backends/managed-host-proxy.mjs +5 -7
- package/tools/backends/managed-host-runtime.mjs +6295 -4350
- package/tools/backends/managed-host.mjs +234 -188
- package/tools/backends/managed-layout.mjs +53 -56
- package/tools/backends/managed-module-graph-ground.mjs +488 -568
- package/tools/backends/managed-module-graph.mjs +62 -76
- package/tools/backends/managed-runtime-host-ground.mjs +352 -400
- package/tools/backends/managed-runtime.mjs +227 -266
- package/tools/backends/managed-source-view-ground.mjs +165 -161
- package/tools/backends/managed-source-view.mjs +415 -154
- package/tools/backends/native-managed-runtime.mjs +96 -138
- package/tools/backends/native-memory.mjs +1122 -742
- package/tools/backends/native-node-ffi.mjs +2439 -0
- package/tools/backends/native-node-memory.mjs +793 -383
- package/tools/backends/native-node-runner.mjs +1458 -579
- package/tools/backends/native-node-watchdog.mjs +12 -14
- package/tools/backends/native-node-worker.mjs +46 -50
- package/tools/backends/stage3-targets.mjs +2 -2
- package/tools/bootstrap-runtime.el +4 -4
- package/tools/collections/transient-builder-benchmark.mjs +17 -17
- package/tools/project/check-cli.eli +27 -3
- package/tools/project/project-cli.eli +1 -1
- package/tools/testing/maintained-suite-source.mjs +5 -7
- package/tools/testing/maintained-suite-source.mjs.map +1 -1
- package/dist/literal-sources/stdlib/core/data.eli +0 -306
- package/dist/literal-sources/stdlib/managed-transient-state.eli +0 -353
- package/stdlib/core/data-text.eli +0 -16
- package/stdlib/core/data.eli +0 -306
- package/stdlib/core/identifier.eli +0 -32
- package/stdlib/core/regex.eli +0 -17
- package/stdlib/deferred.eli +0 -70
- package/stdlib/managed-runtime-lazy-sequence.eli +0 -157
- package/stdlib/managed-transient-state.eli +0 -353
- /package/{stdlib → runtime/managed}/managed-protocol-error.eli +0 -0
- /package/{stdlib → runtime/managed}/managed-runtime-literals.eli +0 -0
- /package/{stdlib → runtime/managed}/managed-runtime-truth.eli +0 -0
- /package/{stdlib → runtime/managed}/managed-testing-value.eli +0 -0
|
@@ -0,0 +1,1838 @@
|
|
|
1
|
+
// Generated by Eliscript. Do not edit.
|
|
2
|
+
import { tdz as __eliscript_tdz_error, immutable as __eliscript_const_error } from "eliscript/runtime/errors.mjs";
|
|
3
|
+
var __eliscript_tdz_ready_0;
|
|
4
|
+
var __eliscript_tdz_ready_1;
|
|
5
|
+
var __eliscript_tdz_ready_2;
|
|
6
|
+
function __eliscript_tdz_write_2(__eliscript_tdz_value_2) { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("fallback_async_bindings"); return (fallback_async_bindings = __eliscript_tdz_value_2); }
|
|
7
|
+
var __eliscript_tdz_ready_3;
|
|
8
|
+
var __eliscript_tdz_ready_4;
|
|
9
|
+
var __eliscript_tdz_ready_5;
|
|
10
|
+
var __eliscript_tdz_ready_6;
|
|
11
|
+
var __eliscript_tdz_ready_7;
|
|
12
|
+
var __eliscript_tdz_ready_8;
|
|
13
|
+
var __eliscript_tdz_ready_9;
|
|
14
|
+
import "eliscript/runtime/unicode-case.mjs";
|
|
15
|
+
import "eliscript/runtime/math.mjs";
|
|
16
|
+
import { __eliscript_to_number, __eliscript_numeric_decrement, __eliscript_numeric_relation, __eliscript_numeric_sub, __eliscript_numeric_mul, __eliscript_numeric_div, __eliscript_numeric_rem, __eliscript_numeric_and, __eliscript_numeric_or, __eliscript_numeric_xor, __eliscript_numeric_shl, __eliscript_numeric_shr, __eliscript_numeric_ushr, __eliscript_numeric_neg, __eliscript_numeric_int32, __eliscript_numeric_uint32, __eliscript_numeric_not } from "eliscript/runtime/prelude.mjs";
|
|
17
|
+
import { valueType as __eliscript_value_type } from "eliscript/runtime/primitives.mjs";
|
|
18
|
+
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
19
|
+
|
|
20
|
+
import * as Collection from "../../runtime/core/collection.mjs";
|
|
21
|
+
import {keyword} from "../../runtime/core/identifier.mjs";
|
|
22
|
+
import {EMPTY_MAP} from "../../runtime/core/map.mjs";
|
|
23
|
+
import {persistentVector} from "../../runtime/core/vector.mjs";
|
|
24
|
+
const KW_DEFAULT = keyword("default");
|
|
25
|
+
__eliscript_tdz_ready_0 = true;
|
|
26
|
+
const MISSING = ({});
|
|
27
|
+
__eliscript_tdz_ready_1 = true;
|
|
28
|
+
let fallback_async_bindings = EMPTY_MAP;
|
|
29
|
+
__eliscript_tdz_ready_2 = true;
|
|
30
|
+
const async_local_storage = (() => {
|
|
31
|
+
try {
|
|
32
|
+
{
|
|
33
|
+
const __eliscript_value_1 = typeof process !== 'undefined' ? process : null;
|
|
34
|
+
{
|
|
35
|
+
let proc = __eliscript_value_1;
|
|
36
|
+
if ((__eliscript_truthy(proc) && (__eliscript_value_type((proc)["getBuiltinModule"]) === "function"))) {
|
|
37
|
+
{
|
|
38
|
+
let mod = (proc)["getBuiltinModule"]("node:async_hooks");
|
|
39
|
+
let ALS = (__eliscript_truthy(mod) ? (mod)["AsyncLocalStorage"] : null);
|
|
40
|
+
if (__eliscript_truthy(ALS)) {
|
|
41
|
+
return new (ALS)();
|
|
42
|
+
} else {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch (_err) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
__eliscript_tdz_ready_3 = true;
|
|
56
|
+
function truthy_QMARK_(value) {
|
|
57
|
+
return (!((value === null) || (value === undefined) || (value === false)));
|
|
58
|
+
}
|
|
59
|
+
function read_opt(options, k1, k2 = null, fallback = null) {
|
|
60
|
+
if ((options == null)) {
|
|
61
|
+
return fallback;
|
|
62
|
+
} else {
|
|
63
|
+
if (__eliscript_truthy(Collection.isMap(options))) {
|
|
64
|
+
{
|
|
65
|
+
let v1 = Collection.get(options, keyword(k1), (__eliscript_tdz_ready_1 === true ? MISSING : __eliscript_tdz_error("MISSING")));
|
|
66
|
+
if (!((v1 === (__eliscript_tdz_ready_1 === true ? MISSING : __eliscript_tdz_error("MISSING"))))) {
|
|
67
|
+
return v1;
|
|
68
|
+
} else {
|
|
69
|
+
{
|
|
70
|
+
let s1 = Collection.get(options, k1, (__eliscript_tdz_ready_1 === true ? MISSING : __eliscript_tdz_error("MISSING")));
|
|
71
|
+
if (!((s1 === (__eliscript_tdz_ready_1 === true ? MISSING : __eliscript_tdz_error("MISSING"))))) {
|
|
72
|
+
return s1;
|
|
73
|
+
} else {
|
|
74
|
+
if (!((k2 == null))) {
|
|
75
|
+
{
|
|
76
|
+
let v2 = Collection.get(options, keyword(k2), (__eliscript_tdz_ready_1 === true ? MISSING : __eliscript_tdz_error("MISSING")));
|
|
77
|
+
if (!((v2 === (__eliscript_tdz_ready_1 === true ? MISSING : __eliscript_tdz_error("MISSING"))))) {
|
|
78
|
+
return v2;
|
|
79
|
+
} else {
|
|
80
|
+
return Collection.get(options, k2, fallback);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
return fallback;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
if ((__eliscript_value_type(options) === "object")) {
|
|
92
|
+
if (__eliscript_truthy(Object.hasOwn(options, k1))) {
|
|
93
|
+
return (options)[k1];
|
|
94
|
+
} else {
|
|
95
|
+
if ((!((k2 == null)) && __eliscript_truthy(Object.hasOwn(options, k2)))) {
|
|
96
|
+
return (options)[k2];
|
|
97
|
+
} else {
|
|
98
|
+
return fallback;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
return fallback;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function has_opt_QMARK_(options, key_name) {
|
|
108
|
+
if ((options == null)) {
|
|
109
|
+
return false;
|
|
110
|
+
} else {
|
|
111
|
+
if (__eliscript_truthy(Collection.isMap(options))) {
|
|
112
|
+
return ((__eliscript_value_2) => (__eliscript_truthy(__eliscript_value_2) ? __eliscript_value_2 : Collection.contains(options, key_name)))(Collection.contains(options, keyword(key_name)));
|
|
113
|
+
} else {
|
|
114
|
+
if ((__eliscript_value_type(options) === "object")) {
|
|
115
|
+
return Object.hasOwn(options, key_name);
|
|
116
|
+
} else {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function current_async_bindings() {
|
|
123
|
+
if (!(((__eliscript_tdz_ready_3 === true ? async_local_storage : __eliscript_tdz_error("async_local_storage")) === null))) {
|
|
124
|
+
{
|
|
125
|
+
let store = ((__eliscript_tdz_ready_3 === true ? async_local_storage : __eliscript_tdz_error("async_local_storage")))["getStore"]();
|
|
126
|
+
if ((store === undefined)) {
|
|
127
|
+
return (__eliscript_tdz_ready_2 === true ? fallback_async_bindings : __eliscript_tdz_error("fallback_async_bindings"));
|
|
128
|
+
} else {
|
|
129
|
+
return store;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
return (__eliscript_tdz_ready_2 === true ? fallback_async_bindings : __eliscript_tdz_error("fallback_async_bindings"));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function merge_bindings(base, extra) {
|
|
137
|
+
if ((extra == null)) {
|
|
138
|
+
return base;
|
|
139
|
+
} else {
|
|
140
|
+
if (__eliscript_truthy(Collection.isMap(extra))) {
|
|
141
|
+
{
|
|
142
|
+
let entries = [];
|
|
143
|
+
let next = base;
|
|
144
|
+
let i = 0;
|
|
145
|
+
Collection.reduceKV(extra, ((_acc, k, v) => {
|
|
146
|
+
(entries)["push"]([k, v]);
|
|
147
|
+
return null;
|
|
148
|
+
}), null);
|
|
149
|
+
while (__eliscript_numeric_relation("<", i, ((entries) ?? []).length)) {
|
|
150
|
+
{
|
|
151
|
+
let pair = (entries)[i];
|
|
152
|
+
((next = Collection.assoc(next, (pair)[0], (pair)[1])));
|
|
153
|
+
}
|
|
154
|
+
((i = (i + 1)));
|
|
155
|
+
}
|
|
156
|
+
return next;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
if ((__eliscript_value_type(extra) === "object")) {
|
|
160
|
+
{
|
|
161
|
+
let ks = Object.keys(extra);
|
|
162
|
+
let next = base;
|
|
163
|
+
let i = 0;
|
|
164
|
+
while (__eliscript_numeric_relation("<", i, ((ks) ?? []).length)) {
|
|
165
|
+
{
|
|
166
|
+
let k = (ks)[i];
|
|
167
|
+
((next = Collection.assoc(next, keyword(k), (extra)[k])));
|
|
168
|
+
}
|
|
169
|
+
((i = (i + 1)));
|
|
170
|
+
}
|
|
171
|
+
return next;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
return ((__eliscript_value_3) => { throw __eliscript_value_3; })(new (globalThis.TypeError)("with-async-bindings expects a map or object"));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function run_with_bindings(captured, thunk, ...args) {
|
|
180
|
+
if (!(((__eliscript_tdz_ready_3 === true ? async_local_storage : __eliscript_tdz_error("async_local_storage")) === null))) {
|
|
181
|
+
return ((__eliscript_tdz_ready_3 === true ? async_local_storage : __eliscript_tdz_error("async_local_storage")))["run"](captured, (() => {
|
|
182
|
+
return thunk(...(args ?? []));
|
|
183
|
+
}));
|
|
184
|
+
} else {
|
|
185
|
+
{
|
|
186
|
+
let prev = (__eliscript_tdz_ready_2 === true ? fallback_async_bindings : __eliscript_tdz_error("fallback_async_bindings"));
|
|
187
|
+
(__eliscript_tdz_write_2(captured));
|
|
188
|
+
try {
|
|
189
|
+
{
|
|
190
|
+
let res = thunk(...(args ?? []));
|
|
191
|
+
if ((__eliscript_truthy(res) && (__eliscript_value_type((res)["then"]) === "function"))) {
|
|
192
|
+
return (res)["finally"]((() => {
|
|
193
|
+
return (__eliscript_tdz_write_2(prev));
|
|
194
|
+
}));
|
|
195
|
+
} else {
|
|
196
|
+
(__eliscript_tdz_write_2(prev));
|
|
197
|
+
return res;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch (err) {
|
|
201
|
+
(__eliscript_tdz_write_2(prev));
|
|
202
|
+
return ((__eliscript_value_4) => { throw __eliscript_value_4; })(err);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function with_async_bindings(bindings, thunk) {
|
|
208
|
+
if ((!(__eliscript_value_type(thunk) === "function"))) {
|
|
209
|
+
((__eliscript_value_5) => { throw __eliscript_value_5; })(new (globalThis.TypeError)("with-async-bindings expects a thunk function"));
|
|
210
|
+
}
|
|
211
|
+
{
|
|
212
|
+
let merged = merge_bindings(current_async_bindings(), bindings);
|
|
213
|
+
return run_with_bindings(merged, thunk);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const ChannelBuffer = (class ChannelBuffer { constructor(kind, capacity) { this.kind = kind; this.capacity = capacity; this.items = []; Object.freeze(this); } });
|
|
217
|
+
__eliscript_tdz_ready_4 = true;
|
|
218
|
+
function buffer_QMARK_(value) {
|
|
219
|
+
return value instanceof ChannelBuffer;
|
|
220
|
+
}
|
|
221
|
+
function buffer(n) {
|
|
222
|
+
if ((!(__eliscript_truthy(Number.isSafeInteger(n)) && __eliscript_numeric_relation(">=", n, 0)))) {
|
|
223
|
+
((__eliscript_value_6) => { throw __eliscript_value_6; })(new (globalThis.RangeError)("buffer capacity must be a non-negative safe integer"));
|
|
224
|
+
}
|
|
225
|
+
return new ((__eliscript_tdz_ready_4 === true ? ChannelBuffer : __eliscript_tdz_error("ChannelBuffer")))("fixed", n);
|
|
226
|
+
}
|
|
227
|
+
function dropping_buffer(n) {
|
|
228
|
+
if ((!(__eliscript_truthy(Number.isSafeInteger(n)) && __eliscript_numeric_relation(">=", n, 1)))) {
|
|
229
|
+
((__eliscript_value_7) => { throw __eliscript_value_7; })(new (globalThis.RangeError)("dropping-buffer capacity must be >= 1"));
|
|
230
|
+
}
|
|
231
|
+
return new ((__eliscript_tdz_ready_4 === true ? ChannelBuffer : __eliscript_tdz_error("ChannelBuffer")))("dropping", n);
|
|
232
|
+
}
|
|
233
|
+
function sliding_buffer(n) {
|
|
234
|
+
if ((!(__eliscript_truthy(Number.isSafeInteger(n)) && __eliscript_numeric_relation(">=", n, 1)))) {
|
|
235
|
+
((__eliscript_value_8) => { throw __eliscript_value_8; })(new (globalThis.RangeError)("sliding-buffer capacity must be >= 1"));
|
|
236
|
+
}
|
|
237
|
+
return new ((__eliscript_tdz_ready_4 === true ? ChannelBuffer : __eliscript_tdz_error("ChannelBuffer")))("sliding", n);
|
|
238
|
+
}
|
|
239
|
+
function buffer_count(buf) {
|
|
240
|
+
return (((buf)["items"]) ?? []).length;
|
|
241
|
+
}
|
|
242
|
+
function buffer_full_QMARK_(buf) {
|
|
243
|
+
{
|
|
244
|
+
let kind = (buf)["kind"];
|
|
245
|
+
if ((kind === "fixed")) {
|
|
246
|
+
return __eliscript_numeric_relation(">=", (((buf)["items"]) ?? []).length, (buf)["capacity"]);
|
|
247
|
+
} else {
|
|
248
|
+
if (((kind === "dropping") || (kind === "sliding"))) {
|
|
249
|
+
return false;
|
|
250
|
+
} else {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function buffer_add_BANG_(buf, val) {
|
|
257
|
+
{
|
|
258
|
+
let kind = (buf)["kind"];
|
|
259
|
+
let items = (buf)["items"];
|
|
260
|
+
let cap = (buf)["capacity"];
|
|
261
|
+
if ((kind === "dropping")) {
|
|
262
|
+
if (__eliscript_numeric_relation("<", ((items) ?? []).length, cap)) {
|
|
263
|
+
return (items)["push"](val);
|
|
264
|
+
} else {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
if ((kind === "sliding")) {
|
|
269
|
+
if (__eliscript_numeric_relation(">=", ((items) ?? []).length, cap)) {
|
|
270
|
+
(items)["shift"]();
|
|
271
|
+
}
|
|
272
|
+
return (items)["push"](val);
|
|
273
|
+
} else {
|
|
274
|
+
return (items)["push"](val);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function buffer_remove_BANG_(buf) {
|
|
280
|
+
return ((buf)["items"])["shift"]();
|
|
281
|
+
}
|
|
282
|
+
const AsyncChannel = (class AsyncChannel { constructor(buf, xform, exHandler) { this.buf = buf; this.closed = false; this.takes = []; this.puts = []; this.xform = xform || null; this.exHandler = exHandler || null; this.xformCompleted = false; } });
|
|
283
|
+
__eliscript_tdz_ready_5 = true;
|
|
284
|
+
function chan_QMARK_(value) {
|
|
285
|
+
return value instanceof AsyncChannel;
|
|
286
|
+
}
|
|
287
|
+
function require_chan(value, op) {
|
|
288
|
+
if ((!__eliscript_truthy(chan_QMARK_(value)))) {
|
|
289
|
+
((__eliscript_value_9) => { throw __eliscript_value_9; })(new (globalThis.TypeError)((String(op) + String(" expects a channel"))));
|
|
290
|
+
}
|
|
291
|
+
return value;
|
|
292
|
+
}
|
|
293
|
+
function default_ex_handler(err) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
function make_channel_rf(ch) {
|
|
297
|
+
return ((...args) => {
|
|
298
|
+
{
|
|
299
|
+
let argc = ((args) ?? []).length;
|
|
300
|
+
if ((argc === 0)) {
|
|
301
|
+
return (ch)["buf"];
|
|
302
|
+
} else {
|
|
303
|
+
if ((argc === 1)) {
|
|
304
|
+
return (args)[0];
|
|
305
|
+
} else {
|
|
306
|
+
buffer_add_BANG_((ch)["buf"], (args)[1]);
|
|
307
|
+
return (args)[0];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function chan(buf_or_n = null, xform = null, ex_handler = null) {
|
|
314
|
+
{
|
|
315
|
+
let buf = null;
|
|
316
|
+
if ((buf_or_n == null)) {
|
|
317
|
+
((buf = null));
|
|
318
|
+
} else {
|
|
319
|
+
if (__eliscript_truthy(Number.isSafeInteger(buf_or_n))) {
|
|
320
|
+
if (__eliscript_numeric_relation("<", buf_or_n, 0)) {
|
|
321
|
+
((__eliscript_value_10) => { throw __eliscript_value_10; })(new (globalThis.RangeError)("channel buffer size must be >= 0"));
|
|
322
|
+
}
|
|
323
|
+
if (__eliscript_numeric_relation(">", buf_or_n, 0)) {
|
|
324
|
+
((buf = buffer(buf_or_n)));
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
if (__eliscript_truthy(buffer_QMARK_(buf_or_n))) {
|
|
328
|
+
((buf = buf_or_n));
|
|
329
|
+
} else {
|
|
330
|
+
((__eliscript_value_11) => { throw __eliscript_value_11; })(new (globalThis.TypeError)("chan buffer must be nil, integer, or Buffer"));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if ((!((xform == null)) && !((__eliscript_value_type(xform) === "function")))) {
|
|
335
|
+
((__eliscript_value_12) => { throw __eliscript_value_12; })(new (globalThis.TypeError)("chan xform must be a transducer function"));
|
|
336
|
+
}
|
|
337
|
+
if ((!((ex_handler == null)) && !((__eliscript_value_type(ex_handler) === "function")))) {
|
|
338
|
+
((__eliscript_value_13) => { throw __eliscript_value_13; })(new (globalThis.TypeError)("chan ex-handler must be a function"));
|
|
339
|
+
}
|
|
340
|
+
if ((!((xform == null)) && (buf === null))) {
|
|
341
|
+
((buf = buffer(1)));
|
|
342
|
+
}
|
|
343
|
+
{
|
|
344
|
+
let ch = new ((__eliscript_tdz_ready_5 === true ? AsyncChannel : __eliscript_tdz_error("AsyncChannel")))(buf, null, ((ex_handler == null) ? default_ex_handler : ex_handler));
|
|
345
|
+
if (!((xform == null))) {
|
|
346
|
+
{
|
|
347
|
+
let step = xform(make_channel_rf(ch));
|
|
348
|
+
((ch)["xform"] = step);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return ch;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function closed_QMARK_(ch) {
|
|
356
|
+
return (require_chan(ch, "closed?"))["closed"];
|
|
357
|
+
}
|
|
358
|
+
function handler_active_QMARK_(h) {
|
|
359
|
+
return ((h)["lock"])["active"];
|
|
360
|
+
}
|
|
361
|
+
function commit_handler(h) {
|
|
362
|
+
{
|
|
363
|
+
let lock = (h)["lock"];
|
|
364
|
+
if (__eliscript_truthy((lock)["active"])) {
|
|
365
|
+
((lock)["active"] = false);
|
|
366
|
+
return true;
|
|
367
|
+
} else {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function pop_active_BANG_(queue) {
|
|
373
|
+
{
|
|
374
|
+
let found = null;
|
|
375
|
+
while (((found === null) && __eliscript_numeric_relation(">", ((queue) ?? []).length, 0))) {
|
|
376
|
+
{
|
|
377
|
+
let h = (queue)["shift"]();
|
|
378
|
+
if (__eliscript_truthy(handler_active_QMARK_(h))) {
|
|
379
|
+
((found = h));
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return found;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
function commit_next_active_BANG_(queue) {
|
|
387
|
+
{
|
|
388
|
+
let found = null;
|
|
389
|
+
while (((found === null) && __eliscript_numeric_relation(">", ((queue) ?? []).length, 0))) {
|
|
390
|
+
{
|
|
391
|
+
let h = (queue)["shift"]();
|
|
392
|
+
if (__eliscript_truthy(commit_handler(h))) {
|
|
393
|
+
((found = h));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return found;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function invoke_waiter(waiter, arg) {
|
|
401
|
+
{
|
|
402
|
+
let bindings = (waiter)["bindings"];
|
|
403
|
+
let cb = (waiter)["fn"];
|
|
404
|
+
if (!((bindings === null))) {
|
|
405
|
+
return run_with_bindings(bindings, cb, arg);
|
|
406
|
+
} else {
|
|
407
|
+
return cb(arg);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function drain_buffer_to_takers_BANG_(ch) {
|
|
412
|
+
{
|
|
413
|
+
let buf = (ch)["buf"];
|
|
414
|
+
if (!((buf === null))) {
|
|
415
|
+
{
|
|
416
|
+
let keep_going = true;
|
|
417
|
+
while ((__eliscript_truthy(keep_going) && __eliscript_numeric_relation(">", buffer_count(buf), 0))) {
|
|
418
|
+
{
|
|
419
|
+
let taker = commit_next_active_BANG_((ch)["takes"]);
|
|
420
|
+
if ((taker === null)) {
|
|
421
|
+
((keep_going = false));
|
|
422
|
+
} else {
|
|
423
|
+
invoke_waiter(taker, buffer_remove_BANG_(buf));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function run_xform_step(ch, val) {
|
|
435
|
+
{
|
|
436
|
+
let xf = (ch)["xform"];
|
|
437
|
+
let exh = (ch)["exHandler"];
|
|
438
|
+
let should_close = false;
|
|
439
|
+
try {
|
|
440
|
+
{
|
|
441
|
+
let res = xf((ch)["buf"], val);
|
|
442
|
+
if (__eliscript_truthy(Collection.isReduced(res))) {
|
|
443
|
+
((should_close = true));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
} catch (err) {
|
|
447
|
+
{
|
|
448
|
+
let recovered = exh(err);
|
|
449
|
+
if ((!(recovered == null))) {
|
|
450
|
+
buffer_add_BANG_((ch)["buf"], recovered);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
drain_buffer_to_takers_BANG_(ch);
|
|
455
|
+
return should_close;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function drain_waiters_on_close_BANG_(ch) {
|
|
459
|
+
{
|
|
460
|
+
let takes = (ch)["takes"];
|
|
461
|
+
let puts = (ch)["puts"];
|
|
462
|
+
while (__eliscript_numeric_relation(">", ((takes) ?? []).length, 0)) {
|
|
463
|
+
{
|
|
464
|
+
let taker = commit_next_active_BANG_(takes);
|
|
465
|
+
if ((!(taker === null))) {
|
|
466
|
+
invoke_waiter(taker, null);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
while (__eliscript_numeric_relation(">", ((puts) ?? []).length, 0)) {
|
|
471
|
+
{
|
|
472
|
+
let putter = commit_next_active_BANG_(puts);
|
|
473
|
+
if ((!(putter === null))) {
|
|
474
|
+
invoke_waiter(putter, false);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function close_BANG_(ch) {
|
|
482
|
+
require_chan(ch, "close!");
|
|
483
|
+
if ((!__eliscript_truthy((ch)["closed"]))) {
|
|
484
|
+
((ch)["closed"] = true);
|
|
485
|
+
{
|
|
486
|
+
let xf = (ch)["xform"];
|
|
487
|
+
let buf = (ch)["buf"];
|
|
488
|
+
if ((!((xf === null)) && !(__eliscript_truthy((ch)["xformCompleted"])))) {
|
|
489
|
+
((ch)["xformCompleted"] = true);
|
|
490
|
+
try {
|
|
491
|
+
xf(buf);
|
|
492
|
+
} catch (err) {
|
|
493
|
+
{
|
|
494
|
+
let recovered = ((ch)["exHandler"])(err);
|
|
495
|
+
if ((!(recovered == null))) {
|
|
496
|
+
buffer_add_BANG_(buf, recovered);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
drain_buffer_to_takers_BANG_(ch);
|
|
502
|
+
}
|
|
503
|
+
drain_waiters_on_close_BANG_(ch);
|
|
504
|
+
}
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
function pump_buffer_BANG_(ch) {
|
|
508
|
+
{
|
|
509
|
+
let buf = (ch)["buf"];
|
|
510
|
+
if ((!((buf === null)) && !(__eliscript_truthy((ch)["closed"])))) {
|
|
511
|
+
{
|
|
512
|
+
let puts = (ch)["puts"];
|
|
513
|
+
while ((!(__eliscript_truthy((ch)["closed"])) && !(__eliscript_truthy(buffer_full_QMARK_(buf))) && __eliscript_numeric_relation(">", ((puts) ?? []).length, 0))) {
|
|
514
|
+
{
|
|
515
|
+
let putter = commit_next_active_BANG_(puts);
|
|
516
|
+
if ((!(putter === null))) {
|
|
517
|
+
{
|
|
518
|
+
let val = (putter)["val"];
|
|
519
|
+
if (((ch)["xform"] === null)) {
|
|
520
|
+
buffer_add_BANG_(buf, val);
|
|
521
|
+
invoke_waiter(putter, true);
|
|
522
|
+
drain_buffer_to_takers_BANG_(ch);
|
|
523
|
+
} else {
|
|
524
|
+
{
|
|
525
|
+
let stop = run_xform_step(ch, val);
|
|
526
|
+
invoke_waiter(putter, true);
|
|
527
|
+
if (__eliscript_truthy(stop)) {
|
|
528
|
+
close_BANG_(ch);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
} else {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function try_put_with_lock_BANG_(ch, val, putter) {
|
|
544
|
+
require_chan(ch, "put!");
|
|
545
|
+
if ((val == null)) {
|
|
546
|
+
((__eliscript_value_14) => { throw __eliscript_value_14; })(new (globalThis.TypeError)("cannot put nil or undefined onto a channel"));
|
|
547
|
+
}
|
|
548
|
+
if (__eliscript_truthy((ch)["closed"])) {
|
|
549
|
+
if (__eliscript_truthy(commit_handler(putter))) {
|
|
550
|
+
return ({"done": true, "accepted": false});
|
|
551
|
+
} else {
|
|
552
|
+
return ({"done": true, "accepted": false});
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
if ((((ch)["buf"] === null) && ((ch)["xform"] === null))) {
|
|
556
|
+
{
|
|
557
|
+
let taker = pop_active_BANG_((ch)["takes"]);
|
|
558
|
+
if ((taker === null)) {
|
|
559
|
+
return ({"done": false});
|
|
560
|
+
} else {
|
|
561
|
+
if (__eliscript_truthy(commit_handler(putter))) {
|
|
562
|
+
if (__eliscript_truthy(commit_handler(taker))) {
|
|
563
|
+
invoke_waiter(taker, val);
|
|
564
|
+
return ({"done": true, "accepted": true});
|
|
565
|
+
} else {
|
|
566
|
+
(((putter)["lock"])["active"] = true);
|
|
567
|
+
return try_put_with_lock_BANG_(ch, val, putter);
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
((ch)["takes"])["unshift"](taker);
|
|
571
|
+
return ({"done": true, "accepted": false});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
} else {
|
|
576
|
+
{
|
|
577
|
+
let buf = (ch)["buf"];
|
|
578
|
+
if (__eliscript_truthy(buffer_full_QMARK_(buf))) {
|
|
579
|
+
return ({"done": false});
|
|
580
|
+
} else {
|
|
581
|
+
if (__eliscript_truthy(commit_handler(putter))) {
|
|
582
|
+
if (((ch)["xform"] === null)) {
|
|
583
|
+
if (((buffer_count(buf) === 0) && __eliscript_numeric_relation(">", (((ch)["takes"]) ?? []).length, 0))) {
|
|
584
|
+
{
|
|
585
|
+
let taker = commit_next_active_BANG_((ch)["takes"]);
|
|
586
|
+
if (!((taker === null))) {
|
|
587
|
+
invoke_waiter(taker, val);
|
|
588
|
+
} else {
|
|
589
|
+
buffer_add_BANG_(buf, val);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
buffer_add_BANG_(buf, val);
|
|
594
|
+
drain_buffer_to_takers_BANG_(ch);
|
|
595
|
+
}
|
|
596
|
+
} else {
|
|
597
|
+
if (__eliscript_truthy(run_xform_step(ch, val))) {
|
|
598
|
+
close_BANG_(ch);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return ({"done": true, "accepted": true});
|
|
602
|
+
} else {
|
|
603
|
+
return ({"done": true, "accepted": false});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function try_take_with_lock_BANG_(ch, taker) {
|
|
611
|
+
require_chan(ch, "take!");
|
|
612
|
+
{
|
|
613
|
+
let buf = (ch)["buf"];
|
|
614
|
+
if ((!((buf === null)) && __eliscript_numeric_relation(">", buffer_count(buf), 0))) {
|
|
615
|
+
if (__eliscript_truthy(commit_handler(taker))) {
|
|
616
|
+
{
|
|
617
|
+
let val = buffer_remove_BANG_(buf);
|
|
618
|
+
pump_buffer_BANG_(ch);
|
|
619
|
+
return ({"done": true, "value": val});
|
|
620
|
+
}
|
|
621
|
+
} else {
|
|
622
|
+
return ({"done": true, "value": null});
|
|
623
|
+
}
|
|
624
|
+
} else {
|
|
625
|
+
if (__eliscript_truthy((ch)["closed"])) {
|
|
626
|
+
if (__eliscript_truthy(commit_handler(taker))) {
|
|
627
|
+
return ({"done": true, "value": null});
|
|
628
|
+
} else {
|
|
629
|
+
return ({"done": true, "value": null});
|
|
630
|
+
}
|
|
631
|
+
} else {
|
|
632
|
+
{
|
|
633
|
+
let found = false;
|
|
634
|
+
let res_val = null;
|
|
635
|
+
while ((!(__eliscript_truthy(found)) && __eliscript_numeric_relation(">", (((ch)["puts"]) ?? []).length, 0))) {
|
|
636
|
+
{
|
|
637
|
+
let putter = pop_active_BANG_((ch)["puts"]);
|
|
638
|
+
if ((!((putter === null)) && __eliscript_truthy(commit_handler(taker)))) {
|
|
639
|
+
if (__eliscript_truthy(commit_handler(putter))) {
|
|
640
|
+
((found = true), (res_val = (putter)["val"]));
|
|
641
|
+
invoke_waiter(putter, true);
|
|
642
|
+
} else {
|
|
643
|
+
(((taker)["lock"])["active"] = true);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (__eliscript_truthy(found)) {
|
|
649
|
+
return ({"done": true, "value": res_val});
|
|
650
|
+
} else {
|
|
651
|
+
return ({"done": false});
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function make_waiter(lock, fn, val = null) {
|
|
659
|
+
return ({"lock": lock, "fn": fn, "val": val, "bindings": current_async_bindings()});
|
|
660
|
+
}
|
|
661
|
+
function offer_BANG_(ch, val) {
|
|
662
|
+
require_chan(ch, "offer!");
|
|
663
|
+
if ((val == null)) {
|
|
664
|
+
((__eliscript_value_15) => { throw __eliscript_value_15; })(new (globalThis.TypeError)("cannot offer nil or undefined onto a channel"));
|
|
665
|
+
}
|
|
666
|
+
{
|
|
667
|
+
let lock = ({"active": true});
|
|
668
|
+
let waiter = make_waiter(lock, ((_v) => {
|
|
669
|
+
return null;
|
|
670
|
+
}), val);
|
|
671
|
+
let res = try_put_with_lock_BANG_(ch, val, waiter);
|
|
672
|
+
if (__eliscript_truthy((res)["done"])) {
|
|
673
|
+
return (res)["accepted"];
|
|
674
|
+
} else {
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function poll_BANG_(ch) {
|
|
680
|
+
require_chan(ch, "poll!");
|
|
681
|
+
{
|
|
682
|
+
let lock = ({"active": true});
|
|
683
|
+
let waiter = make_waiter(lock, ((_v) => {
|
|
684
|
+
return null;
|
|
685
|
+
}));
|
|
686
|
+
let res = try_take_with_lock_BANG_(ch, waiter);
|
|
687
|
+
if (__eliscript_truthy((res)["done"])) {
|
|
688
|
+
return (res)["value"];
|
|
689
|
+
} else {
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
function put_BANG_(ch, val, on_complete = null) {
|
|
695
|
+
require_chan(ch, "put!");
|
|
696
|
+
if ((val == null)) {
|
|
697
|
+
((__eliscript_value_16) => { throw __eliscript_value_16; })(new (globalThis.TypeError)("cannot put nil or undefined onto a channel"));
|
|
698
|
+
}
|
|
699
|
+
return new (globalThis.Promise)(((resolve) => {
|
|
700
|
+
{
|
|
701
|
+
let lock = ({"active": true});
|
|
702
|
+
let done_fn = ((accepted) => {
|
|
703
|
+
if ((!(on_complete == null))) {
|
|
704
|
+
on_complete(accepted);
|
|
705
|
+
}
|
|
706
|
+
return resolve(accepted);
|
|
707
|
+
});
|
|
708
|
+
let waiter = make_waiter(lock, done_fn, val);
|
|
709
|
+
let res = try_put_with_lock_BANG_(ch, val, waiter);
|
|
710
|
+
if (__eliscript_truthy((res)["done"])) {
|
|
711
|
+
return done_fn((res)["accepted"]);
|
|
712
|
+
} else {
|
|
713
|
+
return ((ch)["puts"])["push"](waiter);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}));
|
|
717
|
+
}
|
|
718
|
+
function take_BANG_(ch, on_complete = null) {
|
|
719
|
+
require_chan(ch, "take!");
|
|
720
|
+
return new (globalThis.Promise)(((resolve) => {
|
|
721
|
+
{
|
|
722
|
+
let lock = ({"active": true});
|
|
723
|
+
let done_fn = ((val) => {
|
|
724
|
+
if ((!(on_complete == null))) {
|
|
725
|
+
on_complete(val);
|
|
726
|
+
}
|
|
727
|
+
return resolve(val);
|
|
728
|
+
});
|
|
729
|
+
let waiter = make_waiter(lock, done_fn);
|
|
730
|
+
let res = try_take_with_lock_BANG_(ch, waiter);
|
|
731
|
+
if (__eliscript_truthy((res)["done"])) {
|
|
732
|
+
return done_fn((res)["value"]);
|
|
733
|
+
} else {
|
|
734
|
+
return ((ch)["takes"])["push"](waiter);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}));
|
|
738
|
+
}
|
|
739
|
+
function timeout(ms) {
|
|
740
|
+
{
|
|
741
|
+
let dur = Math.max(0, ((ms == null) ? 0 : ms));
|
|
742
|
+
let ch = chan();
|
|
743
|
+
globalThis.setTimeout((() => {
|
|
744
|
+
return close_BANG_(ch);
|
|
745
|
+
}), dur);
|
|
746
|
+
return ch;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
function to_chan_BANG_(coll) {
|
|
750
|
+
{
|
|
751
|
+
let items = [];
|
|
752
|
+
if ((coll == null)) {
|
|
753
|
+
null;
|
|
754
|
+
} else {
|
|
755
|
+
if (__eliscript_truthy(Array.isArray(coll))) {
|
|
756
|
+
{
|
|
757
|
+
let i = 0;
|
|
758
|
+
while (__eliscript_numeric_relation("<", i, ((coll) ?? []).length)) {
|
|
759
|
+
(items)["push"]((coll)[i]);
|
|
760
|
+
((i = (i + 1)));
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
if (__eliscript_truthy(Collection.isSeqable(coll))) {
|
|
765
|
+
Collection.reduce(coll, ((_a, v) => {
|
|
766
|
+
(items)["push"](v);
|
|
767
|
+
return null;
|
|
768
|
+
}), null);
|
|
769
|
+
} else {
|
|
770
|
+
((__eliscript_value_17) => { throw __eliscript_value_17; })(new (globalThis.TypeError)("to-chan! expects a seqable collection or array"));
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
{
|
|
775
|
+
let ch = chan(Math.max(1, ((items) ?? []).length));
|
|
776
|
+
let i = 0;
|
|
777
|
+
while (__eliscript_numeric_relation("<", i, ((items) ?? []).length)) {
|
|
778
|
+
offer_BANG_(ch, (items)[i]);
|
|
779
|
+
((i = (i + 1)));
|
|
780
|
+
}
|
|
781
|
+
close_BANG_(ch);
|
|
782
|
+
return ch;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
async function onto_chan_BANG_(ch, coll, close_QMARK_ = null) {
|
|
787
|
+
return (await (async (should_close, items) => {
|
|
788
|
+
if ((coll == null)) {
|
|
789
|
+
null;
|
|
790
|
+
} else {
|
|
791
|
+
if (__eliscript_truthy(Array.isArray(coll))) {
|
|
792
|
+
((items = coll));
|
|
793
|
+
} else {
|
|
794
|
+
if (__eliscript_truthy(Collection.isSeqable(coll))) {
|
|
795
|
+
Collection.reduce(coll, ((_a, v) => {
|
|
796
|
+
(items)["push"](v);
|
|
797
|
+
return null;
|
|
798
|
+
}), null);
|
|
799
|
+
} else {
|
|
800
|
+
((__eliscript_value_18) => { throw __eliscript_value_18; })(new (globalThis.TypeError)("onto-chan! expects a seqable collection or array"));
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
(await (async (i, open) => {
|
|
805
|
+
return (await (async () => {
|
|
806
|
+
while ((__eliscript_truthy(open) && __eliscript_numeric_relation("<", i, ((items) ?? []).length))) {
|
|
807
|
+
((open = await (put_BANG_(ch, (items)[i]))));
|
|
808
|
+
((i = (i + 1)));
|
|
809
|
+
}
|
|
810
|
+
return null;
|
|
811
|
+
})());
|
|
812
|
+
})(0, true));
|
|
813
|
+
if (__eliscript_truthy(should_close)) {
|
|
814
|
+
close_BANG_(ch);
|
|
815
|
+
}
|
|
816
|
+
return ch;
|
|
817
|
+
})(((close_QMARK_ == null) ? true : truthy_QMARK_(close_QMARK_)), []));
|
|
818
|
+
}
|
|
819
|
+
function normalize_alts_ports(ports) {
|
|
820
|
+
{
|
|
821
|
+
let raw = (__eliscript_truthy(Array.isArray(ports)) ? ports : (__eliscript_truthy(Collection.isSeqable(ports)) ? ((arr) => {
|
|
822
|
+
Collection.reduce(ports, ((_a, p) => {
|
|
823
|
+
(arr)["push"](p);
|
|
824
|
+
return null;
|
|
825
|
+
}), null);
|
|
826
|
+
return arr;
|
|
827
|
+
})([]) : ((__eliscript_value_19) => { throw __eliscript_value_19; })(new (globalThis.TypeError)("alts! expects an array or vector of ports"))));
|
|
828
|
+
if ((((raw) ?? []).length === 0)) {
|
|
829
|
+
((__eliscript_value_20) => { throw __eliscript_value_20; })(new (globalThis.RangeError)("alts! requires at least one port"));
|
|
830
|
+
}
|
|
831
|
+
return (raw)["map"](((entry) => {
|
|
832
|
+
if (__eliscript_truthy(chan_QMARK_(entry))) {
|
|
833
|
+
return ({"kind": "take", "ch": entry, "port": entry});
|
|
834
|
+
} else {
|
|
835
|
+
if ((__eliscript_truthy(Array.isArray(entry)) || __eliscript_truthy(Collection.isVector(entry)))) {
|
|
836
|
+
{
|
|
837
|
+
let arr = (__eliscript_truthy(Array.isArray(entry)) ? entry : ((tmp) => {
|
|
838
|
+
Collection.reduce(entry, ((_a, v) => {
|
|
839
|
+
(tmp)["push"](v);
|
|
840
|
+
return null;
|
|
841
|
+
}), null);
|
|
842
|
+
return tmp;
|
|
843
|
+
})([]));
|
|
844
|
+
let _check = ((!(((arr) ?? []).length === 2)) ? ((__eliscript_value_21) => { throw __eliscript_value_21; })(new (globalThis.TypeError)("alts! put port must be [ch val]")) : null);
|
|
845
|
+
let ch = require_chan((arr)[0], "alts!");
|
|
846
|
+
let val = (arr)[1];
|
|
847
|
+
if ((val == null)) {
|
|
848
|
+
((__eliscript_value_22) => { throw __eliscript_value_22; })(new (globalThis.TypeError)("alts! cannot put nil or undefined onto channel"));
|
|
849
|
+
}
|
|
850
|
+
return ({"kind": "put", "ch": ch, "val": val, "port": entry});
|
|
851
|
+
}
|
|
852
|
+
} else {
|
|
853
|
+
return ((__eliscript_value_23) => { throw __eliscript_value_23; })(new (globalThis.TypeError)("alts! port must be channel or [channel value]"));
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}));
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
function shuffle_indices(n) {
|
|
860
|
+
{
|
|
861
|
+
let indices = [];
|
|
862
|
+
let i = 0;
|
|
863
|
+
while (__eliscript_numeric_relation("<", i, n)) {
|
|
864
|
+
(indices)["push"](i);
|
|
865
|
+
((i = (i + 1)));
|
|
866
|
+
}
|
|
867
|
+
{
|
|
868
|
+
let j = __eliscript_numeric_decrement(n);
|
|
869
|
+
while (__eliscript_numeric_relation(">", j, 0)) {
|
|
870
|
+
{
|
|
871
|
+
let k = Math.floor(__eliscript_numeric_mul(Math.random(), (j + 1)));
|
|
872
|
+
let tmp = (indices)[j];
|
|
873
|
+
((indices)[j] = (indices)[k]);
|
|
874
|
+
((indices)[k] = tmp);
|
|
875
|
+
}
|
|
876
|
+
((j = __eliscript_numeric_decrement(j)));
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
return indices;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function alts_BANG_(ports, options = null) {
|
|
883
|
+
{
|
|
884
|
+
let normalized = normalize_alts_ports(ports);
|
|
885
|
+
let priority_QMARK_ = truthy_QMARK_(read_opt(options, "priority", null, false));
|
|
886
|
+
let has_default_QMARK_ = has_opt_QMARK_(options, "default");
|
|
887
|
+
let default_val = (__eliscript_truthy(has_default_QMARK_) ? read_opt(options, "default", null, null) : null);
|
|
888
|
+
let n = ((normalized) ?? []).length;
|
|
889
|
+
let order = (__eliscript_truthy(priority_QMARK_) ? ((arr, i) => {
|
|
890
|
+
while (__eliscript_numeric_relation("<", i, n)) {
|
|
891
|
+
(arr)["push"](i);
|
|
892
|
+
((i = (i + 1)));
|
|
893
|
+
}
|
|
894
|
+
return arr;
|
|
895
|
+
})([], 0) : shuffle_indices(n));
|
|
896
|
+
return new (globalThis.Promise)(((resolve) => {
|
|
897
|
+
{
|
|
898
|
+
let lock = ({"active": true});
|
|
899
|
+
let settled = false;
|
|
900
|
+
let idx = 0;
|
|
901
|
+
while ((!(__eliscript_truthy(settled)) && __eliscript_numeric_relation("<", idx, n))) {
|
|
902
|
+
{
|
|
903
|
+
let spec = (normalized)[(order)[idx]];
|
|
904
|
+
let ch = (spec)["ch"];
|
|
905
|
+
let port = (spec)["port"];
|
|
906
|
+
if (((spec)["kind"] === "take")) {
|
|
907
|
+
{
|
|
908
|
+
let waiter = make_waiter(lock, ((v) => {
|
|
909
|
+
return resolve(persistentVector(v, ch));
|
|
910
|
+
}));
|
|
911
|
+
let res = try_take_with_lock_BANG_(ch, waiter);
|
|
912
|
+
if (__eliscript_truthy((res)["done"])) {
|
|
913
|
+
((settled = true));
|
|
914
|
+
resolve(persistentVector((res)["value"], ch));
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
} else {
|
|
918
|
+
{
|
|
919
|
+
let waiter = make_waiter(lock, ((ok) => {
|
|
920
|
+
return resolve(persistentVector(ok, ch));
|
|
921
|
+
}), (spec)["val"]);
|
|
922
|
+
let res = try_put_with_lock_BANG_(ch, (spec)["val"], waiter);
|
|
923
|
+
if (__eliscript_truthy((res)["done"])) {
|
|
924
|
+
((settled = true));
|
|
925
|
+
resolve(persistentVector((res)["accepted"], ch));
|
|
926
|
+
}
|
|
927
|
+
if ((!(port == null))) {
|
|
928
|
+
null;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
((idx = (idx + 1)));
|
|
934
|
+
}
|
|
935
|
+
if (!(__eliscript_truthy(settled))) {
|
|
936
|
+
if ((__eliscript_truthy(has_default_QMARK_) && __eliscript_truthy(commit_handler(({"lock": lock}))))) {
|
|
937
|
+
return resolve(persistentVector(default_val, (__eliscript_tdz_ready_0 === true ? KW_DEFAULT : __eliscript_tdz_error("KW_DEFAULT"))));
|
|
938
|
+
} else {
|
|
939
|
+
{
|
|
940
|
+
let pi = 0;
|
|
941
|
+
while (__eliscript_numeric_relation("<", pi, n)) {
|
|
942
|
+
{
|
|
943
|
+
let spec = (normalized)[(order)[pi]];
|
|
944
|
+
let ch = (spec)["ch"];
|
|
945
|
+
if (((spec)["kind"] === "take")) {
|
|
946
|
+
((ch)["takes"])["push"](make_waiter(lock, ((v) => {
|
|
947
|
+
return resolve(persistentVector(v, ch));
|
|
948
|
+
})));
|
|
949
|
+
} else {
|
|
950
|
+
((ch)["puts"])["push"](make_waiter(lock, ((ok) => {
|
|
951
|
+
return resolve(persistentVector(ok, ch));
|
|
952
|
+
}), (spec)["val"]));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
((pi = (pi + 1)));
|
|
956
|
+
}
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
} else {
|
|
961
|
+
return null;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}));
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const AsyncScope = (class AsyncScope { constructor() { this.cancelled = false; this.reason = null; this.tasks = []; this.channels = []; this.listeners = []; this.aborted = typeof AbortController === 'function' ? new AbortController() : null; } });
|
|
968
|
+
__eliscript_tdz_ready_6 = true;
|
|
969
|
+
function scope_cancelled_QMARK_(scope) {
|
|
970
|
+
return (scope)["cancelled"];
|
|
971
|
+
}
|
|
972
|
+
function scope_signal(scope) {
|
|
973
|
+
{
|
|
974
|
+
let ctrl = (scope)["aborted"];
|
|
975
|
+
if ((ctrl === null)) {
|
|
976
|
+
return null;
|
|
977
|
+
} else {
|
|
978
|
+
return (ctrl)["signal"];
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
function scope_cancel_BANG_(scope, reason = null) {
|
|
983
|
+
if ((!__eliscript_truthy((scope)["cancelled"]))) {
|
|
984
|
+
((scope)["cancelled"] = true);
|
|
985
|
+
((scope)["reason"] = ((reason == null) ? new (globalThis.Error)("Async scope cancelled") : reason));
|
|
986
|
+
{
|
|
987
|
+
let ctrl = (scope)["aborted"];
|
|
988
|
+
if ((!(ctrl === null))) {
|
|
989
|
+
(ctrl)["abort"]((scope)["reason"]);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
{
|
|
993
|
+
let channels = (scope)["channels"];
|
|
994
|
+
let i = 0;
|
|
995
|
+
while (__eliscript_numeric_relation("<", i, ((channels) ?? []).length)) {
|
|
996
|
+
close_BANG_((channels)[i]);
|
|
997
|
+
((i = (i + 1)));
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
{
|
|
1001
|
+
let listeners = (scope)["listeners"];
|
|
1002
|
+
let j = 0;
|
|
1003
|
+
while (__eliscript_numeric_relation("<", j, ((listeners) ?? []).length)) {
|
|
1004
|
+
try {
|
|
1005
|
+
((listeners)[j])((scope)["reason"]);
|
|
1006
|
+
} catch (_err) {
|
|
1007
|
+
null;
|
|
1008
|
+
}
|
|
1009
|
+
((j = (j + 1)));
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return null;
|
|
1014
|
+
}
|
|
1015
|
+
function scope_channel(scope, buf_or_n = null, xform = null, ex_handler = null) {
|
|
1016
|
+
{
|
|
1017
|
+
let ch = chan(buf_or_n, xform, ex_handler);
|
|
1018
|
+
if (__eliscript_truthy((scope)["cancelled"])) {
|
|
1019
|
+
close_BANG_(ch);
|
|
1020
|
+
} else {
|
|
1021
|
+
((scope)["channels"])["push"](ch);
|
|
1022
|
+
}
|
|
1023
|
+
return ch;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
function scope_spawn(scope, task_fn) {
|
|
1027
|
+
if ((!(__eliscript_value_type(task_fn) === "function"))) {
|
|
1028
|
+
((__eliscript_value_24) => { throw __eliscript_value_24; })(new (globalThis.TypeError)("scope-spawn expects a function"));
|
|
1029
|
+
}
|
|
1030
|
+
{
|
|
1031
|
+
let captured = current_async_bindings();
|
|
1032
|
+
if (__eliscript_truthy((scope)["cancelled"])) {
|
|
1033
|
+
return Promise.resolve(null);
|
|
1034
|
+
} else {
|
|
1035
|
+
{
|
|
1036
|
+
let p = Promise.resolve();
|
|
1037
|
+
{
|
|
1038
|
+
let task_promise = ((p)["then"]((() => {
|
|
1039
|
+
if (__eliscript_truthy((scope)["cancelled"])) {
|
|
1040
|
+
((__eliscript_value_25) => { throw __eliscript_value_25; })((scope)["reason"]);
|
|
1041
|
+
}
|
|
1042
|
+
return run_with_bindings(captured, task_fn);
|
|
1043
|
+
})))["catch"](((err) => {
|
|
1044
|
+
if ((!__eliscript_truthy((scope)["cancelled"]))) {
|
|
1045
|
+
scope_cancel_BANG_(scope, err);
|
|
1046
|
+
((scope)["firstError"] = err);
|
|
1047
|
+
}
|
|
1048
|
+
return ((__eliscript_value_26) => { throw __eliscript_value_26; })(err);
|
|
1049
|
+
}));
|
|
1050
|
+
((scope)["tasks"])["push"](task_promise);
|
|
1051
|
+
return task_promise;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
async function with_async_scope(body_fn) {
|
|
1058
|
+
if ((!(__eliscript_value_type(body_fn) === "function"))) {
|
|
1059
|
+
((__eliscript_value_27) => { throw __eliscript_value_27; })(new (globalThis.TypeError)("with-async-scope expects a function"));
|
|
1060
|
+
}
|
|
1061
|
+
return (await (async (scope, body_err, has_body_err, result) => {
|
|
1062
|
+
(await (async () => {
|
|
1063
|
+
try {
|
|
1064
|
+
return ((result = await (body_fn(scope))));
|
|
1065
|
+
} catch (err) {
|
|
1066
|
+
((body_err = err), (has_body_err = true));
|
|
1067
|
+
return scope_cancel_BANG_(scope, err);
|
|
1068
|
+
}
|
|
1069
|
+
})());
|
|
1070
|
+
((settled) => {
|
|
1071
|
+
{
|
|
1072
|
+
let channels = (scope)["channels"];
|
|
1073
|
+
let ci = 0;
|
|
1074
|
+
while (__eliscript_numeric_relation("<", ci, ((channels) ?? []).length)) {
|
|
1075
|
+
close_BANG_((channels)[ci]);
|
|
1076
|
+
((ci = (ci + 1)));
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (__eliscript_truthy(has_body_err)) {
|
|
1080
|
+
((__eliscript_value_28) => { throw __eliscript_value_28; })(body_err);
|
|
1081
|
+
}
|
|
1082
|
+
if ((!((scope)["firstError"] === null))) {
|
|
1083
|
+
((__eliscript_value_29) => { throw __eliscript_value_29; })((scope)["firstError"]);
|
|
1084
|
+
}
|
|
1085
|
+
{
|
|
1086
|
+
let i = 0;
|
|
1087
|
+
while (__eliscript_numeric_relation("<", i, ((settled) ?? []).length)) {
|
|
1088
|
+
{
|
|
1089
|
+
let s = (settled)[i];
|
|
1090
|
+
if (((s)["status"] === "rejected")) {
|
|
1091
|
+
((__eliscript_value_30) => { throw __eliscript_value_30; })((s)["reason"]);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
((i = (i + 1)));
|
|
1095
|
+
}
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
1098
|
+
})(await (Promise.allSettled((scope)["tasks"])));
|
|
1099
|
+
return result;
|
|
1100
|
+
})(new ((__eliscript_tdz_ready_6 === true ? AsyncScope : __eliscript_tdz_error("AsyncScope")))(), null, false, null));
|
|
1101
|
+
}
|
|
1102
|
+
function pipe(from, to, close_QMARK_ = null) {
|
|
1103
|
+
{
|
|
1104
|
+
let should_close = ((close_QMARK_ == null) ? true : truthy_QMARK_(close_QMARK_));
|
|
1105
|
+
(((() => {
|
|
1106
|
+
{
|
|
1107
|
+
let step = null;
|
|
1108
|
+
((step = (() => {
|
|
1109
|
+
return (take_BANG_(from))["then"](((v) => {
|
|
1110
|
+
if ((v === null)) {
|
|
1111
|
+
if (__eliscript_truthy(should_close)) {
|
|
1112
|
+
return close_BANG_(to);
|
|
1113
|
+
} else {
|
|
1114
|
+
return null;
|
|
1115
|
+
}
|
|
1116
|
+
} else {
|
|
1117
|
+
return (put_BANG_(to, v))["then"](((ok) => {
|
|
1118
|
+
if (__eliscript_truthy(ok)) {
|
|
1119
|
+
return step();
|
|
1120
|
+
} else {
|
|
1121
|
+
return null;
|
|
1122
|
+
}
|
|
1123
|
+
}));
|
|
1124
|
+
}
|
|
1125
|
+
}));
|
|
1126
|
+
})));
|
|
1127
|
+
return step();
|
|
1128
|
+
}
|
|
1129
|
+
}))())["catch"](((_err) => {
|
|
1130
|
+
return null;
|
|
1131
|
+
}));
|
|
1132
|
+
return to;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
function run_xf_to_array(xf, ex_handler, v) {
|
|
1136
|
+
{
|
|
1137
|
+
let out = [];
|
|
1138
|
+
let step_fn = xf(((...args) => {
|
|
1139
|
+
{
|
|
1140
|
+
let argc = ((args) ?? []).length;
|
|
1141
|
+
if ((argc === 0)) {
|
|
1142
|
+
return [];
|
|
1143
|
+
} else {
|
|
1144
|
+
if ((argc === 1)) {
|
|
1145
|
+
return (args)[0];
|
|
1146
|
+
} else {
|
|
1147
|
+
((args)[0])["push"]((args)[1]);
|
|
1148
|
+
return (args)[0];
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}));
|
|
1153
|
+
try {
|
|
1154
|
+
{
|
|
1155
|
+
let r1 = step_fn(out, v);
|
|
1156
|
+
{
|
|
1157
|
+
let unr = (__eliscript_truthy(Collection.isReduced(r1)) ? Collection.unreduced(r1) : r1);
|
|
1158
|
+
step_fn(unr);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
} catch (err) {
|
|
1162
|
+
{
|
|
1163
|
+
let recovered = ex_handler(err);
|
|
1164
|
+
if ((!(recovered == null))) {
|
|
1165
|
+
(out)["push"](recovered);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return out;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function host_map_QMARK_(x) {
|
|
1173
|
+
return x instanceof globalThis.Map;
|
|
1174
|
+
}
|
|
1175
|
+
function pipeline_STAR_(mode, parallelism, to, fn_or_xf, from, close_QMARK_, ex_handler) {
|
|
1176
|
+
if ((!(__eliscript_truthy(Number.isSafeInteger(parallelism)) && __eliscript_numeric_relation(">=", parallelism, 1)))) {
|
|
1177
|
+
((__eliscript_value_31) => { throw __eliscript_value_31; })(new (globalThis.RangeError)("pipeline parallelism n must be >= 1"));
|
|
1178
|
+
}
|
|
1179
|
+
{
|
|
1180
|
+
let should_close = ((close_QMARK_ == null) ? true : truthy_QMARK_(close_QMARK_));
|
|
1181
|
+
let exh = ((ex_handler == null) ? default_ex_handler : ex_handler);
|
|
1182
|
+
let jobs = chan(parallelism);
|
|
1183
|
+
let results = chan(parallelism);
|
|
1184
|
+
let stopped = false;
|
|
1185
|
+
((() => {
|
|
1186
|
+
{
|
|
1187
|
+
let feed_step = null;
|
|
1188
|
+
((feed_step = (() => {
|
|
1189
|
+
if ((!__eliscript_truthy(stopped))) {
|
|
1190
|
+
return (take_BANG_(from))["then"](((v) => {
|
|
1191
|
+
if ((__eliscript_truthy(stopped) || (v === null))) {
|
|
1192
|
+
close_BANG_(jobs);
|
|
1193
|
+
return close_BANG_(results);
|
|
1194
|
+
} else {
|
|
1195
|
+
{
|
|
1196
|
+
let res_ch = chan(1);
|
|
1197
|
+
return (put_BANG_(jobs, ({"val": v, "res": res_ch})))["then"](((ok1) => {
|
|
1198
|
+
if (__eliscript_truthy(ok1)) {
|
|
1199
|
+
return (put_BANG_(results, res_ch))["then"](((ok2) => {
|
|
1200
|
+
if (__eliscript_truthy(ok2)) {
|
|
1201
|
+
return feed_step();
|
|
1202
|
+
} else {
|
|
1203
|
+
return null;
|
|
1204
|
+
}
|
|
1205
|
+
}));
|
|
1206
|
+
} else {
|
|
1207
|
+
return close_BANG_(res_ch);
|
|
1208
|
+
}
|
|
1209
|
+
}));
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}));
|
|
1213
|
+
} else {
|
|
1214
|
+
return null;
|
|
1215
|
+
}
|
|
1216
|
+
})));
|
|
1217
|
+
return feed_step();
|
|
1218
|
+
}
|
|
1219
|
+
}))();
|
|
1220
|
+
{
|
|
1221
|
+
let wi = 0;
|
|
1222
|
+
while (__eliscript_numeric_relation("<", wi, parallelism)) {
|
|
1223
|
+
((() => {
|
|
1224
|
+
{
|
|
1225
|
+
let work_step = null;
|
|
1226
|
+
((work_step = (() => {
|
|
1227
|
+
return (take_BANG_(jobs))["then"](((job) => {
|
|
1228
|
+
if ((!(job === null))) {
|
|
1229
|
+
{
|
|
1230
|
+
let val = (job)["val"];
|
|
1231
|
+
let res_ch = (job)["res"];
|
|
1232
|
+
if ((mode === "sync")) {
|
|
1233
|
+
{
|
|
1234
|
+
let items = run_xf_to_array(fn_or_xf, exh, val);
|
|
1235
|
+
return (onto_chan_BANG_(res_ch, items, true))["then"]((() => {
|
|
1236
|
+
return work_step();
|
|
1237
|
+
}));
|
|
1238
|
+
}
|
|
1239
|
+
} else {
|
|
1240
|
+
try {
|
|
1241
|
+
{
|
|
1242
|
+
let maybe_p = fn_or_xf(val, res_ch);
|
|
1243
|
+
if ((__eliscript_truthy(maybe_p) && (__eliscript_value_type((maybe_p)["then"]) === "function"))) {
|
|
1244
|
+
return (maybe_p)["then"]((() => {
|
|
1245
|
+
return work_step();
|
|
1246
|
+
}), (() => {
|
|
1247
|
+
close_BANG_(res_ch);
|
|
1248
|
+
return work_step();
|
|
1249
|
+
}));
|
|
1250
|
+
} else {
|
|
1251
|
+
return work_step();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
} catch (_err) {
|
|
1255
|
+
close_BANG_(res_ch);
|
|
1256
|
+
return work_step();
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
} else {
|
|
1261
|
+
return null;
|
|
1262
|
+
}
|
|
1263
|
+
}));
|
|
1264
|
+
})));
|
|
1265
|
+
return work_step();
|
|
1266
|
+
}
|
|
1267
|
+
}))();
|
|
1268
|
+
((wi = (wi + 1)));
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
((() => {
|
|
1272
|
+
{
|
|
1273
|
+
let collect_outer = null;
|
|
1274
|
+
let drain_res = null;
|
|
1275
|
+
((drain_res = ((res_ch) => {
|
|
1276
|
+
return (take_BANG_(res_ch))["then"](((item) => {
|
|
1277
|
+
if ((item === null)) {
|
|
1278
|
+
return collect_outer();
|
|
1279
|
+
} else {
|
|
1280
|
+
return (put_BANG_(to, item))["then"](((ok) => {
|
|
1281
|
+
if (__eliscript_truthy(ok)) {
|
|
1282
|
+
return drain_res(res_ch);
|
|
1283
|
+
} else {
|
|
1284
|
+
((stopped = true));
|
|
1285
|
+
close_BANG_(jobs);
|
|
1286
|
+
return close_BANG_(results);
|
|
1287
|
+
}
|
|
1288
|
+
}));
|
|
1289
|
+
}
|
|
1290
|
+
}));
|
|
1291
|
+
})));
|
|
1292
|
+
((collect_outer = (() => {
|
|
1293
|
+
return (take_BANG_(results))["then"](((res_ch) => {
|
|
1294
|
+
if ((res_ch === null)) {
|
|
1295
|
+
if (__eliscript_truthy(should_close)) {
|
|
1296
|
+
return close_BANG_(to);
|
|
1297
|
+
} else {
|
|
1298
|
+
return null;
|
|
1299
|
+
}
|
|
1300
|
+
} else {
|
|
1301
|
+
return drain_res(res_ch);
|
|
1302
|
+
}
|
|
1303
|
+
}));
|
|
1304
|
+
})));
|
|
1305
|
+
return collect_outer();
|
|
1306
|
+
}
|
|
1307
|
+
}))();
|
|
1308
|
+
return to;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function pipeline(n, to, xf, from, close_QMARK_ = null, ex_handler = null) {
|
|
1312
|
+
if ((!(__eliscript_value_type(xf) === "function"))) {
|
|
1313
|
+
((__eliscript_value_32) => { throw __eliscript_value_32; })(new (globalThis.TypeError)("pipeline expects a transducer function"));
|
|
1314
|
+
}
|
|
1315
|
+
return pipeline_STAR_("sync", n, to, xf, from, close_QMARK_, ex_handler);
|
|
1316
|
+
}
|
|
1317
|
+
function pipeline_async(n, to, af, from, close_QMARK_ = null) {
|
|
1318
|
+
if ((!(__eliscript_value_type(af) === "function"))) {
|
|
1319
|
+
((__eliscript_value_33) => { throw __eliscript_value_33; })(new (globalThis.TypeError)("pipeline-async expects an async function"));
|
|
1320
|
+
}
|
|
1321
|
+
return pipeline_STAR_("async", n, to, af, from, close_QMARK_, null);
|
|
1322
|
+
}
|
|
1323
|
+
function merge(chs, buf_or_n = null) {
|
|
1324
|
+
{
|
|
1325
|
+
let arr = (__eliscript_truthy(Array.isArray(chs)) ? chs : (__eliscript_truthy(Collection.isSeqable(chs)) ? ((tmp) => {
|
|
1326
|
+
Collection.reduce(chs, ((_a, c) => {
|
|
1327
|
+
(tmp)["push"](c);
|
|
1328
|
+
return null;
|
|
1329
|
+
}), null);
|
|
1330
|
+
return tmp;
|
|
1331
|
+
})([]) : ((__eliscript_value_34) => { throw __eliscript_value_34; })(new (globalThis.TypeError)("merge expects an array or collection of channels"))));
|
|
1332
|
+
let out = chan(buf_or_n);
|
|
1333
|
+
let remaining = ((arr) ?? []).length;
|
|
1334
|
+
if ((remaining === 0)) {
|
|
1335
|
+
close_BANG_(out);
|
|
1336
|
+
} else {
|
|
1337
|
+
{
|
|
1338
|
+
let i = 0;
|
|
1339
|
+
while (__eliscript_numeric_relation("<", i, ((arr) ?? []).length)) {
|
|
1340
|
+
{
|
|
1341
|
+
let src = require_chan((arr)[i], "merge");
|
|
1342
|
+
(((ch_src) => {
|
|
1343
|
+
{
|
|
1344
|
+
let pump = null;
|
|
1345
|
+
((pump = (() => {
|
|
1346
|
+
return (take_BANG_(ch_src))["then"](((v) => {
|
|
1347
|
+
if ((v === null)) {
|
|
1348
|
+
((remaining = __eliscript_numeric_decrement(remaining)));
|
|
1349
|
+
if ((remaining === 0)) {
|
|
1350
|
+
return close_BANG_(out);
|
|
1351
|
+
} else {
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
} else {
|
|
1355
|
+
return (put_BANG_(out, v))["then"](((ok) => {
|
|
1356
|
+
if (__eliscript_truthy(ok)) {
|
|
1357
|
+
return pump();
|
|
1358
|
+
} else {
|
|
1359
|
+
return null;
|
|
1360
|
+
}
|
|
1361
|
+
}));
|
|
1362
|
+
}
|
|
1363
|
+
}));
|
|
1364
|
+
})));
|
|
1365
|
+
return pump();
|
|
1366
|
+
}
|
|
1367
|
+
}))(src);
|
|
1368
|
+
}
|
|
1369
|
+
((i = (i + 1)));
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return out;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
function split(pred, ch, t_buf = null, f_buf = null) {
|
|
1377
|
+
if ((!(__eliscript_value_type(pred) === "function"))) {
|
|
1378
|
+
((__eliscript_value_35) => { throw __eliscript_value_35; })(new (globalThis.TypeError)("split expects a predicate function"));
|
|
1379
|
+
}
|
|
1380
|
+
require_chan(ch, "split");
|
|
1381
|
+
{
|
|
1382
|
+
let t_ch = chan(t_buf);
|
|
1383
|
+
let f_ch = chan(f_buf);
|
|
1384
|
+
((() => {
|
|
1385
|
+
{
|
|
1386
|
+
let step = null;
|
|
1387
|
+
((step = (() => {
|
|
1388
|
+
return (take_BANG_(ch))["then"](((v) => {
|
|
1389
|
+
if ((v === null)) {
|
|
1390
|
+
close_BANG_(t_ch);
|
|
1391
|
+
return close_BANG_(f_ch);
|
|
1392
|
+
} else {
|
|
1393
|
+
{
|
|
1394
|
+
let target = (__eliscript_truthy(truthy_QMARK_(pred(v))) ? t_ch : f_ch);
|
|
1395
|
+
return (put_BANG_(target, v))["then"](((_ok) => {
|
|
1396
|
+
if ((!(__eliscript_truthy(closed_QMARK_(t_ch)) && __eliscript_truthy(closed_QMARK_(f_ch))))) {
|
|
1397
|
+
return step();
|
|
1398
|
+
} else {
|
|
1399
|
+
return null;
|
|
1400
|
+
}
|
|
1401
|
+
}));
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}));
|
|
1405
|
+
})));
|
|
1406
|
+
return step();
|
|
1407
|
+
}
|
|
1408
|
+
}))();
|
|
1409
|
+
return persistentVector(t_ch, f_ch);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
const ChannelMult = (class ChannelMult { constructor(ch) { this.ch = ch; this.taps = []; this.done = false; } });
|
|
1413
|
+
__eliscript_tdz_ready_7 = true;
|
|
1414
|
+
function mult_QMARK_(value) {
|
|
1415
|
+
return value instanceof ChannelMult;
|
|
1416
|
+
}
|
|
1417
|
+
function mult(ch) {
|
|
1418
|
+
require_chan(ch, "mult");
|
|
1419
|
+
{
|
|
1420
|
+
let m = new ((__eliscript_tdz_ready_7 === true ? ChannelMult : __eliscript_tdz_error("ChannelMult")))(ch);
|
|
1421
|
+
((() => {
|
|
1422
|
+
{
|
|
1423
|
+
let step = null;
|
|
1424
|
+
((step = (() => {
|
|
1425
|
+
return (take_BANG_(ch))["then"](((v) => {
|
|
1426
|
+
if ((v === null)) {
|
|
1427
|
+
((m)["done"] = true);
|
|
1428
|
+
{
|
|
1429
|
+
let taps = ((m)["taps"])["slice"]();
|
|
1430
|
+
let i = 0;
|
|
1431
|
+
while (__eliscript_numeric_relation("<", i, ((taps) ?? []).length)) {
|
|
1432
|
+
{
|
|
1433
|
+
let entry = (taps)[i];
|
|
1434
|
+
if (__eliscript_truthy((entry)["close"])) {
|
|
1435
|
+
close_BANG_((entry)["ch"]);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
((i = (i + 1)));
|
|
1439
|
+
}
|
|
1440
|
+
return null;
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1443
|
+
{
|
|
1444
|
+
let taps = ((m)["taps"])["slice"]();
|
|
1445
|
+
if ((((taps) ?? []).length === 0)) {
|
|
1446
|
+
return step();
|
|
1447
|
+
} else {
|
|
1448
|
+
{
|
|
1449
|
+
let puts = [];
|
|
1450
|
+
let i = 0;
|
|
1451
|
+
while (__eliscript_numeric_relation("<", i, ((taps) ?? []).length)) {
|
|
1452
|
+
{
|
|
1453
|
+
let entry = (taps)[i];
|
|
1454
|
+
(puts)["push"]((put_BANG_((entry)["ch"], v))["then"](((ok) => {
|
|
1455
|
+
if ((!__eliscript_truthy(ok))) {
|
|
1456
|
+
return untap(m, (entry)["ch"]);
|
|
1457
|
+
} else {
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
})));
|
|
1461
|
+
}
|
|
1462
|
+
((i = (i + 1)));
|
|
1463
|
+
}
|
|
1464
|
+
return (Promise.all(puts))["then"]((() => {
|
|
1465
|
+
return step();
|
|
1466
|
+
}));
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}));
|
|
1472
|
+
})));
|
|
1473
|
+
return step();
|
|
1474
|
+
}
|
|
1475
|
+
}))();
|
|
1476
|
+
return m;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
function tap(m, ch, close_QMARK_ = null) {
|
|
1480
|
+
if ((!__eliscript_truthy(mult_QMARK_(m)))) {
|
|
1481
|
+
((__eliscript_value_36) => { throw __eliscript_value_36; })(new (globalThis.TypeError)("tap expects a mult"));
|
|
1482
|
+
}
|
|
1483
|
+
require_chan(ch, "tap");
|
|
1484
|
+
{
|
|
1485
|
+
let should_close = ((close_QMARK_ == null) ? true : truthy_QMARK_(close_QMARK_));
|
|
1486
|
+
if (__eliscript_truthy((m)["done"])) {
|
|
1487
|
+
if (__eliscript_truthy(should_close)) {
|
|
1488
|
+
close_BANG_(ch);
|
|
1489
|
+
}
|
|
1490
|
+
} else {
|
|
1491
|
+
{
|
|
1492
|
+
let taps = (m)["taps"];
|
|
1493
|
+
let found = false;
|
|
1494
|
+
let i = 0;
|
|
1495
|
+
while (__eliscript_numeric_relation("<", i, ((taps) ?? []).length)) {
|
|
1496
|
+
if ((((taps)[i])["ch"] === ch)) {
|
|
1497
|
+
(((taps)[i])["close"] = should_close);
|
|
1498
|
+
((found = true));
|
|
1499
|
+
}
|
|
1500
|
+
((i = (i + 1)));
|
|
1501
|
+
}
|
|
1502
|
+
if ((!__eliscript_truthy(found))) {
|
|
1503
|
+
(taps)["push"](({"ch": ch, "close": should_close}));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
return ch;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
function untap(m, ch) {
|
|
1511
|
+
if ((!__eliscript_truthy(mult_QMARK_(m)))) {
|
|
1512
|
+
((__eliscript_value_37) => { throw __eliscript_value_37; })(new (globalThis.TypeError)("untap expects a mult"));
|
|
1513
|
+
}
|
|
1514
|
+
((m)["taps"] = ((m)["taps"])["filter"](((entry) => {
|
|
1515
|
+
return (!((entry)["ch"] === ch));
|
|
1516
|
+
})));
|
|
1517
|
+
return null;
|
|
1518
|
+
}
|
|
1519
|
+
function untap_all(m) {
|
|
1520
|
+
if ((!__eliscript_truthy(mult_QMARK_(m)))) {
|
|
1521
|
+
((__eliscript_value_38) => { throw __eliscript_value_38; })(new (globalThis.TypeError)("untap-all expects a mult"));
|
|
1522
|
+
}
|
|
1523
|
+
((m)["taps"] = []);
|
|
1524
|
+
return null;
|
|
1525
|
+
}
|
|
1526
|
+
const ChannelPub = (class ChannelPub { constructor(ch, topicFn, bufFn) { this.ch = ch; this.topicFn = topicFn; this.bufFn = bufFn; this.mults = EMPTY_MAP; this.done = false; } });
|
|
1527
|
+
__eliscript_tdz_ready_8 = true;
|
|
1528
|
+
function pub_QMARK_(value) {
|
|
1529
|
+
return value instanceof ChannelPub;
|
|
1530
|
+
}
|
|
1531
|
+
function ensure_topic_mult(p, topic) {
|
|
1532
|
+
{
|
|
1533
|
+
let existing = Collection.get((p)["mults"], topic, null);
|
|
1534
|
+
if (!((existing === null))) {
|
|
1535
|
+
return existing;
|
|
1536
|
+
} else {
|
|
1537
|
+
{
|
|
1538
|
+
let buf = (((p)["bufFn"] === null) ? null : ((p)["bufFn"])(topic));
|
|
1539
|
+
let tch = chan(buf);
|
|
1540
|
+
let m = mult(tch);
|
|
1541
|
+
((p)["mults"] = Collection.assoc((p)["mults"], topic, ({"ch": tch, "mult": m})));
|
|
1542
|
+
return Collection.get((p)["mults"], topic);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
function pub(ch, topic_fn, buf_fn = null) {
|
|
1548
|
+
require_chan(ch, "pub");
|
|
1549
|
+
if ((!(__eliscript_value_type(topic_fn) === "function"))) {
|
|
1550
|
+
((__eliscript_value_39) => { throw __eliscript_value_39; })(new (globalThis.TypeError)("pub expects a topic function"));
|
|
1551
|
+
}
|
|
1552
|
+
{
|
|
1553
|
+
let p = new ((__eliscript_tdz_ready_8 === true ? ChannelPub : __eliscript_tdz_error("ChannelPub")))(ch, topic_fn, ((buf_fn == null) ? null : buf_fn));
|
|
1554
|
+
((() => {
|
|
1555
|
+
{
|
|
1556
|
+
let step = null;
|
|
1557
|
+
((step = (() => {
|
|
1558
|
+
return (take_BANG_(ch))["then"](((v) => {
|
|
1559
|
+
if ((v === null)) {
|
|
1560
|
+
((p)["done"] = true);
|
|
1561
|
+
{
|
|
1562
|
+
let topic_chs = [];
|
|
1563
|
+
let i = 0;
|
|
1564
|
+
Collection.reduceKV((p)["mults"], ((_a, _k, entry) => {
|
|
1565
|
+
(topic_chs)["push"]((entry)["ch"]);
|
|
1566
|
+
return null;
|
|
1567
|
+
}), null);
|
|
1568
|
+
while (__eliscript_numeric_relation("<", i, ((topic_chs) ?? []).length)) {
|
|
1569
|
+
close_BANG_((topic_chs)[i]);
|
|
1570
|
+
((i = (i + 1)));
|
|
1571
|
+
}
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
} else {
|
|
1575
|
+
{
|
|
1576
|
+
let topic = topic_fn(v);
|
|
1577
|
+
let entry = Collection.get((p)["mults"], topic, null);
|
|
1578
|
+
if ((entry === null)) {
|
|
1579
|
+
return step();
|
|
1580
|
+
} else {
|
|
1581
|
+
return (put_BANG_((entry)["ch"], v))["then"](((_ok) => {
|
|
1582
|
+
return step();
|
|
1583
|
+
}));
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}));
|
|
1588
|
+
})));
|
|
1589
|
+
return step();
|
|
1590
|
+
}
|
|
1591
|
+
}))();
|
|
1592
|
+
return p;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
function sub(p, topic, ch, close_QMARK_ = null) {
|
|
1596
|
+
if ((!__eliscript_truthy(pub_QMARK_(p)))) {
|
|
1597
|
+
((__eliscript_value_40) => { throw __eliscript_value_40; })(new (globalThis.TypeError)("sub expects a pub"));
|
|
1598
|
+
}
|
|
1599
|
+
require_chan(ch, "sub");
|
|
1600
|
+
{
|
|
1601
|
+
let should_close = ((close_QMARK_ == null) ? true : truthy_QMARK_(close_QMARK_));
|
|
1602
|
+
if (__eliscript_truthy((p)["done"])) {
|
|
1603
|
+
if (__eliscript_truthy(should_close)) {
|
|
1604
|
+
close_BANG_(ch);
|
|
1605
|
+
}
|
|
1606
|
+
} else {
|
|
1607
|
+
{
|
|
1608
|
+
let entry = ensure_topic_mult(p, topic);
|
|
1609
|
+
tap((entry)["mult"], ch, should_close);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
return ch;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
function unsub(p, topic, ch) {
|
|
1616
|
+
if ((!__eliscript_truthy(pub_QMARK_(p)))) {
|
|
1617
|
+
((__eliscript_value_41) => { throw __eliscript_value_41; })(new (globalThis.TypeError)("unsub expects a pub"));
|
|
1618
|
+
}
|
|
1619
|
+
{
|
|
1620
|
+
let entry = Collection.get((p)["mults"], topic, null);
|
|
1621
|
+
if ((!(entry === null))) {
|
|
1622
|
+
untap((entry)["mult"], ch);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
return null;
|
|
1626
|
+
}
|
|
1627
|
+
function unsub_all(p, topic = null) {
|
|
1628
|
+
if ((!__eliscript_truthy(pub_QMARK_(p)))) {
|
|
1629
|
+
((__eliscript_value_42) => { throw __eliscript_value_42; })(new (globalThis.TypeError)("unsub-all expects a pub"));
|
|
1630
|
+
}
|
|
1631
|
+
if (!((topic == null))) {
|
|
1632
|
+
{
|
|
1633
|
+
let entry = Collection.get((p)["mults"], topic, null);
|
|
1634
|
+
if ((!(entry === null))) {
|
|
1635
|
+
untap_all((entry)["mult"]);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
} else {
|
|
1639
|
+
{
|
|
1640
|
+
let all_mults = [];
|
|
1641
|
+
let i = 0;
|
|
1642
|
+
Collection.reduceKV((p)["mults"], ((_a, _k, entry) => {
|
|
1643
|
+
(all_mults)["push"]((entry)["mult"]);
|
|
1644
|
+
return null;
|
|
1645
|
+
}), null);
|
|
1646
|
+
while (__eliscript_numeric_relation("<", i, ((all_mults) ?? []).length)) {
|
|
1647
|
+
untap_all((all_mults)[i]);
|
|
1648
|
+
((i = (i + 1)));
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
return null;
|
|
1653
|
+
}
|
|
1654
|
+
const ChannelMix = (class ChannelMix { constructor(out) { this.out = out; this.inputs = new globalThis.Map(); this.soloMode = 'mute'; this.wakeCh = null; this.running = true; } });
|
|
1655
|
+
__eliscript_tdz_ready_9 = true;
|
|
1656
|
+
function mix_QMARK_(value) {
|
|
1657
|
+
return value instanceof ChannelMix;
|
|
1658
|
+
}
|
|
1659
|
+
function read_mix_state(opts) {
|
|
1660
|
+
{
|
|
1661
|
+
let s = ({"mute": false, "pause": false, "solo": false});
|
|
1662
|
+
if (!((opts == null))) {
|
|
1663
|
+
((s)["mute"] = truthy_QMARK_(read_opt(opts, "mute", null, false)));
|
|
1664
|
+
((s)["pause"] = truthy_QMARK_(read_opt(opts, "pause", null, false)));
|
|
1665
|
+
((s)["solo"] = truthy_QMARK_(read_opt(opts, "solo", null, false)));
|
|
1666
|
+
}
|
|
1667
|
+
return s;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
function mix_wake_BANG_(m) {
|
|
1671
|
+
{
|
|
1672
|
+
let old = (m)["wakeCh"];
|
|
1673
|
+
if ((!(old === null))) {
|
|
1674
|
+
close_BANG_(old);
|
|
1675
|
+
}
|
|
1676
|
+
return ((m)["wakeCh"] = chan());
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
function mix_run_loop(m) {
|
|
1680
|
+
{
|
|
1681
|
+
let step = null;
|
|
1682
|
+
((step = (() => {
|
|
1683
|
+
if ((__eliscript_truthy((m)["running"]) && !(__eliscript_truthy(closed_QMARK_((m)["out"]))))) {
|
|
1684
|
+
{
|
|
1685
|
+
let any_solo = false;
|
|
1686
|
+
let solo_mode_val = (m)["soloMode"];
|
|
1687
|
+
let active_ports = [];
|
|
1688
|
+
let state_by_ch = new (globalThis.Map)();
|
|
1689
|
+
let entries = Array.from(((m)["inputs"])["entries"]());
|
|
1690
|
+
let i = 0;
|
|
1691
|
+
while (__eliscript_numeric_relation("<", i, ((entries) ?? []).length)) {
|
|
1692
|
+
if (__eliscript_truthy((((entries)[i])[1])["solo"])) {
|
|
1693
|
+
((any_solo = true));
|
|
1694
|
+
}
|
|
1695
|
+
((i = (i + 1)));
|
|
1696
|
+
}
|
|
1697
|
+
((i = 0));
|
|
1698
|
+
while (__eliscript_numeric_relation("<", i, ((entries) ?? []).length)) {
|
|
1699
|
+
{
|
|
1700
|
+
let pair = (entries)[i];
|
|
1701
|
+
let ch = (pair)[0];
|
|
1702
|
+
let st = (pair)[1];
|
|
1703
|
+
let solo_QMARK_ = (st)["solo"];
|
|
1704
|
+
let paused_QMARK_ = (st)["pause"];
|
|
1705
|
+
let effectively_paused = ((__eliscript_value_43) => (__eliscript_truthy(__eliscript_value_43) ? __eliscript_value_43 : ((__eliscript_value_44) => (__eliscript_truthy(__eliscript_value_44) ? ((!__eliscript_truthy(solo_QMARK_)) && (solo_mode_val === "pause")) : __eliscript_value_44))(any_solo)))(paused_QMARK_);
|
|
1706
|
+
let effectively_muted = ((__eliscript_value_45) => (__eliscript_truthy(__eliscript_value_45) ? __eliscript_value_45 : ((__eliscript_value_46) => (__eliscript_truthy(__eliscript_value_46) ? ((!__eliscript_truthy(solo_QMARK_)) && (solo_mode_val === "mute")) : __eliscript_value_46))(any_solo)))((st)["mute"]);
|
|
1707
|
+
if ((!__eliscript_truthy(effectively_paused))) {
|
|
1708
|
+
(state_by_ch)["set"](ch, ({"muted": effectively_muted}));
|
|
1709
|
+
(active_ports)["push"](ch);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
((i = (i + 1)));
|
|
1713
|
+
}
|
|
1714
|
+
{
|
|
1715
|
+
let wake = (m)["wakeCh"];
|
|
1716
|
+
(active_ports)["push"](wake);
|
|
1717
|
+
return (alts_BANG_(active_ports))["then"](((pair) => {
|
|
1718
|
+
{
|
|
1719
|
+
let val = (pair)["nth"](0);
|
|
1720
|
+
let win_ch = (pair)["nth"](1);
|
|
1721
|
+
if ((win_ch === wake)) {
|
|
1722
|
+
return step();
|
|
1723
|
+
} else {
|
|
1724
|
+
if ((val === null)) {
|
|
1725
|
+
((m)["inputs"])["delete"](win_ch);
|
|
1726
|
+
return step();
|
|
1727
|
+
} else {
|
|
1728
|
+
{
|
|
1729
|
+
let info = (state_by_ch)["get"](win_ch);
|
|
1730
|
+
if ((__eliscript_truthy(info) && __eliscript_truthy((info)["muted"]))) {
|
|
1731
|
+
return step();
|
|
1732
|
+
} else {
|
|
1733
|
+
return (put_BANG_((m)["out"], val))["then"](((ok) => {
|
|
1734
|
+
if (__eliscript_truthy(ok)) {
|
|
1735
|
+
return step();
|
|
1736
|
+
} else {
|
|
1737
|
+
return null;
|
|
1738
|
+
}
|
|
1739
|
+
}));
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}));
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
} else {
|
|
1749
|
+
return null;
|
|
1750
|
+
}
|
|
1751
|
+
})));
|
|
1752
|
+
return step();
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
function mix(out) {
|
|
1756
|
+
require_chan(out, "mix");
|
|
1757
|
+
{
|
|
1758
|
+
let m = new ((__eliscript_tdz_ready_9 === true ? ChannelMix : __eliscript_tdz_error("ChannelMix")))(out);
|
|
1759
|
+
((m)["wakeCh"] = chan());
|
|
1760
|
+
mix_run_loop(m);
|
|
1761
|
+
return m;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
function admix(m, ch) {
|
|
1765
|
+
if ((!__eliscript_truthy(mix_QMARK_(m)))) {
|
|
1766
|
+
((__eliscript_value_47) => { throw __eliscript_value_47; })(new (globalThis.TypeError)("admix expects a mix"));
|
|
1767
|
+
}
|
|
1768
|
+
require_chan(ch, "admix");
|
|
1769
|
+
if ((!__eliscript_truthy(((m)["inputs"])["has"](ch)))) {
|
|
1770
|
+
((m)["inputs"])["set"](ch, read_mix_state(null));
|
|
1771
|
+
mix_wake_BANG_(m);
|
|
1772
|
+
}
|
|
1773
|
+
return m;
|
|
1774
|
+
}
|
|
1775
|
+
function unmix(m, ch) {
|
|
1776
|
+
if ((!__eliscript_truthy(mix_QMARK_(m)))) {
|
|
1777
|
+
((__eliscript_value_48) => { throw __eliscript_value_48; })(new (globalThis.TypeError)("unmix expects a mix"));
|
|
1778
|
+
}
|
|
1779
|
+
if (__eliscript_truthy(((m)["inputs"])["delete"](ch))) {
|
|
1780
|
+
mix_wake_BANG_(m);
|
|
1781
|
+
}
|
|
1782
|
+
return m;
|
|
1783
|
+
}
|
|
1784
|
+
function unmix_all(m) {
|
|
1785
|
+
if ((!__eliscript_truthy(mix_QMARK_(m)))) {
|
|
1786
|
+
((__eliscript_value_49) => { throw __eliscript_value_49; })(new (globalThis.TypeError)("unmix-all expects a mix"));
|
|
1787
|
+
}
|
|
1788
|
+
((m)["inputs"])["clear"]();
|
|
1789
|
+
mix_wake_BANG_(m);
|
|
1790
|
+
return m;
|
|
1791
|
+
}
|
|
1792
|
+
function solo_mode(m, mode) {
|
|
1793
|
+
if ((!__eliscript_truthy(mix_QMARK_(m)))) {
|
|
1794
|
+
((__eliscript_value_50) => { throw __eliscript_value_50; })(new (globalThis.TypeError)("solo-mode expects a mix"));
|
|
1795
|
+
}
|
|
1796
|
+
{
|
|
1797
|
+
let name = ((mode === "mute") ? "mute" : ((mode === "pause") ? "pause" : (((String(mode)) === ":mute") ? "mute" : (((String(mode)) === ":pause") ? "pause" : ((__eliscript_value_51) => { throw __eliscript_value_51; })(new (globalThis.RangeError)("solo-mode must be :mute or :pause"))))));
|
|
1798
|
+
((m)["soloMode"] = name);
|
|
1799
|
+
mix_wake_BANG_(m);
|
|
1800
|
+
}
|
|
1801
|
+
return m;
|
|
1802
|
+
}
|
|
1803
|
+
function toggle(m, state_map) {
|
|
1804
|
+
if ((!__eliscript_truthy(mix_QMARK_(m)))) {
|
|
1805
|
+
((__eliscript_value_52) => { throw __eliscript_value_52; })(new (globalThis.TypeError)("toggle expects a mix"));
|
|
1806
|
+
}
|
|
1807
|
+
{
|
|
1808
|
+
let pairs = [];
|
|
1809
|
+
let i = 0;
|
|
1810
|
+
if (__eliscript_truthy(Collection.isMap(state_map))) {
|
|
1811
|
+
Collection.reduceKV(state_map, ((_a, k, v) => {
|
|
1812
|
+
(pairs)["push"]([k, v]);
|
|
1813
|
+
return null;
|
|
1814
|
+
}), null);
|
|
1815
|
+
} else {
|
|
1816
|
+
if (__eliscript_truthy(host_map_QMARK_(state_map))) {
|
|
1817
|
+
(state_map)["forEach"](((v, k) => {
|
|
1818
|
+
return (pairs)["push"]([k, v]);
|
|
1819
|
+
}));
|
|
1820
|
+
} else {
|
|
1821
|
+
((__eliscript_value_53) => { throw __eliscript_value_53; })(new (globalThis.TypeError)("toggle expects a map of channels to state maps"));
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
while (__eliscript_numeric_relation("<", i, ((pairs) ?? []).length)) {
|
|
1825
|
+
{
|
|
1826
|
+
let pair = (pairs)[i];
|
|
1827
|
+
let ch = require_chan((pair)[0], "toggle");
|
|
1828
|
+
let next_st = read_mix_state((pair)[1]);
|
|
1829
|
+
((m)["inputs"])["set"](ch, next_st);
|
|
1830
|
+
}
|
|
1831
|
+
((i = (i + 1)));
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
mix_wake_BANG_(m);
|
|
1835
|
+
return m;
|
|
1836
|
+
}
|
|
1837
|
+
export {AsyncChannel, AsyncScope, ChannelBuffer, ChannelMix, ChannelMult, ChannelPub, admix, alts_BANG_, buffer, buffer_count, buffer_full_QMARK_, buffer_QMARK_, chan, chan_QMARK_, close_BANG_, closed_QMARK_, current_async_bindings, dropping_buffer, merge, mix, mix_QMARK_, mult, mult_QMARK_, offer_BANG_, onto_chan_BANG_, pipe, pipeline, pipeline_async, poll_BANG_, pub, pub_QMARK_, put_BANG_, scope_cancel_BANG_, scope_cancelled_QMARK_, scope_channel, scope_signal, scope_spawn, sliding_buffer, solo_mode, split, sub, take_BANG_, tap, timeout, to_chan_BANG_, toggle, unmix, unmix_all, unsub, unsub_all, untap, untap_all, with_async_bindings, with_async_scope};
|
|
1838
|
+
//# sourceMappingURL=async.mjs.map
|