eliscript 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/bootstrap/README.md +26 -0
- package/bootstrap/backends/README.md +515 -0
- package/bootstrap/backends/async.eli +230 -0
- package/bootstrap/backends/binary.eli +173 -0
- package/bootstrap/backends/capabilities.eli +74 -0
- package/bootstrap/backends/elf.eli +246 -0
- package/bootstrap/backends/managed.eli +5976 -0
- package/bootstrap/backends/memory.eli +100 -0
- package/bootstrap/backends/native.eli +2000 -0
- package/bootstrap/backends/numeric.eli +1362 -0
- package/bootstrap/backends/optimize.eli +79 -0
- package/bootstrap/backends/regexp.eli +2263 -0
- package/bootstrap/backends/sha256.eli +138 -0
- package/bootstrap/backends/wasm.eli +1161 -0
- package/bootstrap/compiler/analyzer.eli +165 -77
- package/bootstrap/compiler/compiler.eli +43 -19
- package/bootstrap/compiler/emitter.eli +780 -170
- package/bootstrap/compiler/expander.eli +136 -45
- package/bootstrap/compiler/formatter.eli +8 -1
- package/bootstrap/compiler/ir.eli +148 -45
- package/bootstrap/compiler/lower.eli +29 -2
- package/bootstrap/compiler/project.eli +51 -21
- package/bootstrap/compiler/reader.eli +128 -36
- package/bootstrap/compiler/source-map.eli +46 -4
- package/bootstrap/compiler/symbol.eli +2 -1
- package/bootstrap/compiler/syntax.eli +47 -12
- package/bootstrap/compiler/transient-analysis.eli +40 -4
- package/bootstrap/host/check-cli-legacy.mjs +163 -0
- package/bootstrap/host/check-cli.mjs +59 -158
- package/bootstrap/host/check-cli.mjs.map +1 -0
- package/bootstrap/host/compiler-session.eli +1579 -0
- package/bootstrap/host/compiler-tools.eli +513 -0
- package/bootstrap/host/eliscript-cli-legacy.mjs +37 -0
- package/bootstrap/host/eliscript-cli.mjs +53 -33
- package/bootstrap/host/eliscript-cli.mjs.map +1 -0
- package/bootstrap/host/project-cli-legacy.mjs +295 -0
- package/bootstrap/host/project-cli.mjs +74 -289
- package/bootstrap/host/project-cli.mjs.map +1 -0
- package/bootstrap/host/project-legacy.mjs +1080 -0
- package/bootstrap/host/project.mjs +210 -1060
- package/bootstrap/host/project.mjs.map +1 -0
- package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
- package/bootstrap/runtime/memory.eli +30379 -0
- package/browser/host.mjs +89 -0
- package/compiler/eliscript-analyzer.el +371 -4
- package/compiler/eliscript-cli.el +84 -1
- package/compiler/eliscript-emitter.el +1189 -256
- package/compiler/eliscript-expander.el +147 -10
- package/compiler/eliscript-ir-emitter.el +725 -208
- package/compiler/eliscript-lower.el +127 -1
- package/compiler/eliscript-portable.el +177 -51
- package/compiler/eliscript-project.el +20 -2
- package/compiler/eliscript-reader.el +141 -57
- package/compiler/eliscript-source-map.el +26 -12
- package/compiler/eliscript-transient-analysis.el +382 -19
- package/dist/backends/async.mjs +561 -0
- package/dist/backends/async.mjs.macro-origins.json +1 -0
- package/dist/backends/async.mjs.map +1 -0
- package/dist/backends/binary.mjs +381 -0
- package/dist/backends/binary.mjs.macro-origins.json +1 -0
- package/dist/backends/binary.mjs.map +1 -0
- package/dist/backends/capabilities.mjs +237 -0
- package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
- package/dist/backends/capabilities.mjs.map +1 -0
- package/dist/backends/elf.mjs +540 -0
- package/dist/backends/elf.mjs.macro-origins.json +1 -0
- package/dist/backends/elf.mjs.map +1 -0
- package/dist/backends/managed.mjs +10616 -0
- package/dist/backends/managed.mjs.macro-origins.json +1 -0
- package/dist/backends/managed.mjs.map +1 -0
- package/dist/backends/memory.mjs +278 -0
- package/dist/backends/memory.mjs.macro-origins.json +1 -0
- package/dist/backends/memory.mjs.map +1 -0
- package/dist/backends/native.mjs +4099 -0
- package/dist/backends/native.mjs.macro-origins.json +1 -0
- package/dist/backends/native.mjs.map +1 -0
- package/dist/backends/numeric.mjs +2458 -0
- package/dist/backends/numeric.mjs.macro-origins.json +1 -0
- package/dist/backends/numeric.mjs.map +1 -0
- package/dist/backends/optimize.mjs +204 -0
- package/dist/backends/optimize.mjs.macro-origins.json +1 -0
- package/dist/backends/optimize.mjs.map +1 -0
- package/dist/backends/regexp.mjs +2033 -0
- package/dist/backends/regexp.mjs.macro-origins.json +1 -0
- package/dist/backends/regexp.mjs.map +1 -0
- package/dist/backends/sha256.mjs +310 -0
- package/dist/backends/sha256.mjs.macro-origins.json +1 -0
- package/dist/backends/sha256.mjs.map +1 -0
- package/dist/backends/wasm.mjs +2258 -0
- package/dist/backends/wasm.mjs.macro-origins.json +1 -0
- package/dist/backends/wasm.mjs.map +1 -0
- package/dist/bootstrap/analyzer.mjs +1908 -776
- package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +450 -142
- package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +3083 -909
- package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +2887 -1233
- package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/formatter.mjs +582 -218
- package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/formatter.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +670 -116
- package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/lower.mjs +866 -257
- package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/lower.mjs.map +1 -1
- package/dist/bootstrap/package.json +1 -0
- package/dist/bootstrap/project.mjs +1168 -498
- package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +674 -175
- package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/runtime/math.mjs +1117 -0
- package/dist/bootstrap/runtime/math.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
- package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +430 -119
- package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/symbol.mjs +229 -53
- package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/symbol.mjs.map +1 -1
- package/dist/bootstrap/syntax.mjs +205 -7
- package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/syntax.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +1185 -489
- package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +199 -6478
- package/dist/browser/host.mjs +446 -0
- package/dist/browser/loader.js +1 -0
- package/dist/browser/loader.mjs +231 -0
- package/dist/browser/worker.mjs +60 -0
- package/dist/compiler-artifact.json +1 -0
- package/dist/host/compiler-session.mjs +2980 -0
- package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-session.mjs.map +1 -0
- package/dist/host/compiler-tools.mjs +1084 -0
- package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-tools.mjs.map +1 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
- package/dist/literal-sources/runtime/core/collection.eli +579 -0
- package/dist/literal-sources/runtime/core/data-text.eli +290 -0
- package/dist/literal-sources/runtime/core/data.eli +22 -0
- package/dist/literal-sources/runtime/core/identifier.eli +44 -0
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
- package/dist/literal-sources/runtime/core/list.eli +19 -0
- package/dist/literal-sources/runtime/core/map.eli +9 -0
- package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
- package/dist/literal-sources/runtime/core/metadata.eli +23 -0
- package/dist/literal-sources/runtime/core/object.eli +8 -0
- package/dist/literal-sources/runtime/core/order.eli +123 -0
- package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
- package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
- package/dist/literal-sources/runtime/core/protocol.eli +28 -0
- package/dist/literal-sources/runtime/core/queue.eli +9 -0
- package/dist/literal-sources/runtime/core/record.eli +191 -0
- package/dist/literal-sources/runtime/core/regex.eli +158 -0
- package/dist/literal-sources/runtime/core/sequence.eli +305 -0
- package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
- package/dist/literal-sources/runtime/core/set.eli +9 -0
- package/dist/literal-sources/runtime/core/sorted.eli +408 -0
- package/dist/literal-sources/runtime/core/text.eli +14 -0
- package/dist/literal-sources/runtime/core/transducer.eli +268 -0
- package/dist/literal-sources/runtime/core/transient.eli +17 -0
- package/dist/literal-sources/runtime/core/truth.eli +4 -0
- package/dist/literal-sources/runtime/core/type.eli +232 -0
- package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
- package/dist/literal-sources/runtime/core/value.eli +19 -0
- package/dist/literal-sources/runtime/core/vector.eli +20 -0
- package/dist/literal-sources/runtime/literals.eli +23 -0
- package/dist/literal-sources/runtime/testing/value.eli +6 -0
- package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
- package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
- package/dist/literal-sources/runtime/wire/schema.eli +193 -0
- package/dist/literal-sources/stdlib/bit.eli +36 -0
- package/dist/literal-sources/stdlib/core/data.eli +306 -0
- package/dist/literal-sources/stdlib/core/object.eli +89 -0
- package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
- package/dist/literal-sources/stdlib/core/set.eli +312 -0
- package/dist/literal-sources/stdlib/core/text.eli +103 -0
- package/dist/literal-sources/stdlib/managed-literal-protocols.eli +483 -0
- package/dist/literal-sources/stdlib/managed-literals.eli +1414 -0
- package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
- package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
- package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
- package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
- package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
- package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
- package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
- package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
- package/dist/literal-sources/stdlib/value.eli +325 -0
- package/dist/package.json +10 -0
- package/dist/runtime/math.mjs +1116 -0
- package/dist/runtime/math.mjs.macro-origins.json +1 -0
- package/dist/runtime/math.mjs.map +1 -0
- package/dist/runtime/unicode-case-data.mjs +10124 -0
- package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/runtime/unicode-case.mjs +280 -0
- package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case.mjs.map +1 -0
- package/dist/runtime.eli +30379 -0
- package/dist/stage3-release.json +1 -0
- package/editor/README.md +1 -1
- package/editor/eliscript-mode.el +1 -1
- package/editor/eliscript-repl.el +1 -1
- package/package.json +97 -10
- package/platform/http.mjs +20 -0
- package/runtime/array-text.mjs +159 -0
- package/runtime/core/map-internals.mjs +27 -9
- package/runtime/core/object-impl.mjs +26 -17
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/protocol-impl.mjs +682 -255
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/protocol.mjs +4 -0
- package/runtime/core/record.mjs +23 -2
- package/runtime/core/regex.mjs +4 -0
- package/runtime/core/sorted.mjs +53 -0
- package/runtime/core/text-impl.mjs +167 -48
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/type.mjs +75 -3
- package/runtime/core/vector.mjs +6 -0
- package/runtime/math.eli +429 -0
- package/runtime/math.mjs +1116 -0
- package/runtime/math.mjs.map +1 -0
- package/runtime/number-radix.mjs +105 -0
- package/runtime/unicode-case-data.eli +29 -0
- package/runtime/unicode-case-data.mjs +10124 -0
- package/runtime/unicode-case-data.mjs.map +1 -0
- package/runtime/unicode-case.eli +100 -0
- package/runtime/unicode-case.mjs +280 -0
- package/runtime/unicode-case.mjs.map +1 -0
- package/runtime/wire/http-rpc.mjs +168 -0
- package/runtime/wire/markdown.mjs +196 -0
- package/runtime/wire/schema.mjs +109 -0
- package/stdlib/README.md +54 -0
- package/stdlib/core/protocol.eli +81 -17
- package/stdlib/core/seq.eli +1 -1
- package/stdlib/core/zipper.eli +114 -47
- package/stdlib/gepo.eli +12 -0
- package/stdlib/interop/js.eli +56 -15
- package/stdlib/managed-literal-protocols.eli +483 -0
- package/stdlib/managed-literals.eli +1414 -0
- package/stdlib/managed-protocol-error.eli +32 -0
- package/stdlib/managed-queue-state.eli +65 -0
- package/stdlib/managed-runtime-collection-internals.eli +60 -0
- package/stdlib/managed-runtime-collection.eli +579 -0
- package/stdlib/managed-runtime-data-text.eli +290 -0
- package/stdlib/managed-runtime-data.eli +22 -0
- package/stdlib/managed-runtime-identifier.eli +44 -0
- package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
- package/stdlib/managed-runtime-list.eli +19 -0
- package/stdlib/managed-runtime-literals.eli +23 -0
- package/stdlib/managed-runtime-map.eli +9 -0
- package/stdlib/managed-runtime-metadata-internals.eli +6 -0
- package/stdlib/managed-runtime-metadata.eli +23 -0
- package/stdlib/managed-runtime-object.eli +8 -0
- package/stdlib/managed-runtime-order.eli +123 -0
- package/stdlib/managed-runtime-persistent-kind.eli +28 -0
- package/stdlib/managed-runtime-protocol.eli +28 -0
- package/stdlib/managed-runtime-queue.eli +9 -0
- package/stdlib/managed-runtime-record.eli +191 -0
- package/stdlib/managed-runtime-regex.eli +158 -0
- package/stdlib/managed-runtime-sequence.eli +305 -0
- package/stdlib/managed-runtime-set-algebra.eli +28 -0
- package/stdlib/managed-runtime-set.eli +9 -0
- package/stdlib/managed-runtime-sorted.eli +408 -0
- package/stdlib/managed-runtime-text.eli +14 -0
- package/stdlib/managed-runtime-transducer.eli +268 -0
- package/stdlib/managed-runtime-transient.eli +17 -0
- package/stdlib/managed-runtime-truth.eli +4 -0
- package/stdlib/managed-runtime-type.eli +232 -0
- package/stdlib/managed-runtime-value-internals.eli +13 -0
- package/stdlib/managed-runtime-value.eli +19 -0
- package/stdlib/managed-runtime-vector.eli +20 -0
- package/stdlib/managed-sorted-state.eli +233 -0
- package/stdlib/managed-testing-value.eli +6 -0
- package/stdlib/managed-transient-state.eli +348 -0
- package/stdlib/managed-value-state.eli +153 -0
- package/stdlib/managed-vector-view-state.eli +102 -0
- package/stdlib/managed-wire-http-rpc.eli +362 -0
- package/stdlib/managed-wire-markdown.eli +275 -0
- package/stdlib/managed-wire-schema.eli +193 -0
- package/stdlib/mdp.eli +7 -0
- package/stdlib/mds.eli +4 -0
- package/stdlib/persistent-vector.eli +23 -6
- package/tools/acceptance/check-legacy.mjs +687 -0
- package/tools/acceptance/check.eli +431 -0
- package/tools/acceptance/compile-evidence.el +49 -0
- package/tools/acceptance/finalize-legacy.mjs +498 -0
- package/tools/acceptance/finalize.eli +270 -0
- package/tools/backends/benchmark.mjs +175 -0
- package/tools/backends/build.mjs +135 -0
- package/tools/backends/compile.mjs +94 -0
- package/tools/backends/compiler-bootstrap.mjs +1001 -0
- package/tools/backends/compiler-browser.mjs +361 -0
- package/tools/backends/compiler-build.mjs +1628 -0
- package/tools/backends/compiler-cli-legacy.mjs +334 -0
- package/tools/backends/compiler-cli.mjs +29 -0
- package/tools/backends/compiler-corpus-bit.mjs +234 -0
- package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
- package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
- package/tools/backends/compiler-corpus-debugging.mjs +221 -0
- package/tools/backends/compiler-corpus-emitter.mjs +324 -0
- package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
- package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
- package/tools/backends/compiler-corpus-execution.mjs +3324 -0
- package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
- package/tools/backends/compiler-corpus-generations.mjs +208 -0
- package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
- package/tools/backends/compiler-corpus-host-context.mjs +550 -0
- package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
- package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
- package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
- package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
- package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
- package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
- package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
- package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
- package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
- package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
- package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
- package/tools/backends/compiler-corpus-matchers.mjs +173 -0
- package/tools/backends/compiler-corpus-original-program.mjs +612 -0
- package/tools/backends/compiler-corpus-process.mjs +765 -0
- package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
- package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
- package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
- package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
- package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
- package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
- package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
- package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
- package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
- package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
- package/tools/backends/compiler-corpus-reference.mjs +241 -0
- package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
- package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
- package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
- package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
- package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
- package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
- package/tools/backends/compiler-corpus.mjs +2054 -0
- package/tools/backends/compiler-debug.mjs +142 -0
- package/tools/backends/compiler-matrix.mjs +1955 -0
- package/tools/backends/compiler-metadata.mjs +203 -0
- package/tools/backends/compiler-package-browser.mjs +120 -0
- package/tools/backends/compiler-package-legacy.mjs +654 -0
- package/tools/backends/compiler-package.mjs +464 -0
- package/tools/backends/compiler-project.mjs +126 -0
- package/tools/backends/compiler-session.mjs +843 -0
- package/tools/backends/compiler-sha256.mjs +152 -0
- package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
- package/tools/backends/compiler-worker.mjs +573 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
- package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
- package/tools/backends/dist/record-grid.mjs +1256 -0
- package/tools/backends/dist/record-grid.mjs.map +1 -0
- package/tools/backends/dist/release-cli.mjs +460 -0
- package/tools/backends/dist/release-cli.mjs.map +1 -0
- package/tools/backends/dist/run-artifact.mjs +517 -0
- package/tools/backends/dist/run-artifact.mjs.map +1 -0
- package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
- package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
- package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
- package/tools/backends/managed-foreign-binding.mjs +497 -0
- package/tools/backends/managed-host-legacy.mjs +1181 -0
- package/tools/backends/managed-host-lifecycle.mjs +310 -0
- package/tools/backends/managed-host-object-provider.mjs +155 -0
- package/tools/backends/managed-host-object-realm.mjs +797 -0
- package/tools/backends/managed-host-proxy.mjs +71 -0
- package/tools/backends/managed-host-runtime.mjs +5868 -0
- package/tools/backends/managed-host.mjs +716 -0
- package/tools/backends/managed-module-graph-legacy.mjs +308 -0
- package/tools/backends/managed-module-graph.mjs +694 -0
- package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
- package/tools/backends/managed-runtime.mjs +939 -0
- package/tools/backends/managed-source-view-legacy.mjs +332 -0
- package/tools/backends/managed-source-view.mjs +959 -0
- package/tools/backends/memory-runtime.mjs +100 -0
- package/tools/backends/native-benchmark.mjs +88 -0
- package/tools/backends/native-managed-runtime.mjs +677 -0
- package/tools/backends/native-memory.mjs +768 -0
- package/tools/backends/native-node-memory.mjs +142 -0
- package/tools/backends/native-node-runner.mjs +99 -0
- package/tools/backends/native-node-watchdog.mjs +19 -0
- package/tools/backends/native-node-worker.mjs +75 -0
- package/tools/backends/stage3-targets.mjs +486 -0
- package/tools/bootstrap-command.el +13 -0
- package/tools/bootstrap-runtime.el +101 -0
- package/tools/bootstrap-seed.el +55 -0
- package/tools/project/check-cli.eli +31 -0
- package/tools/project/project-cli.eli +42 -0
- package/tools/project/project.eli +122 -0
- package/tools/runtime/unicode-case-profiles.mjs +13 -0
- package/tools/runtime/unicode-case-runtime.el +57 -0
- package/tools/testing/source-debugging-corpus-host.eli +16 -0
- package/tools/testing/source-debugging.eli +139 -0
- package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
- package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
- package/tools/testing/stdlib-bit.eli +104 -0
- package/tools/testing/stdlib-bit.mjs +255 -0
- package/bin/eliscript-bootstrap +0 -15
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Generated by Eliscript. Do not edit.
|
|
2
|
+
import { tdz as __eliscript_tdz_error, immutable as __eliscript_const_error } from "data:text/javascript;base64,Y29uc3QgRSA9IFJlZmVyZW5jZUVycm9yOyBjb25zdCBUID0gVHlwZUVycm9yOyBleHBvcnQgZnVuY3Rpb24gdGR6KG5hbWUpIHsgdGhyb3cgbmV3IEUoIkNhbm5vdCBhY2Nlc3MgJyIgKyBuYW1lICsgIicgYmVmb3JlIGluaXRpYWxpemF0aW9uIik7IH0gZXhwb3J0IGZ1bmN0aW9uIGltbXV0YWJsZSgpIHsgdGhyb3cgbmV3IFQoIkFzc2lnbm1lbnQgdG8gY29uc3RhbnQgdmFyaWFibGUuIik7IH0K";
|
|
3
|
+
var __eliscript_tdz_ready_0;
|
|
4
|
+
function __eliscript_tdz_read_0() { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("installed"); return installed; }
|
|
5
|
+
function __eliscript_tdz_write_0(__eliscript_tdz_value_0) { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("installed"); return __eliscript_const_error(); }
|
|
6
|
+
var __eliscript_tdz_ready_1;
|
|
7
|
+
function __eliscript_tdz_read_1() { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("intrinsic_string"); return intrinsic_string; }
|
|
8
|
+
function __eliscript_tdz_write_1(__eliscript_tdz_value_1) { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("intrinsic_string"); return __eliscript_const_error(); }
|
|
9
|
+
var __eliscript_tdz_ready_2;
|
|
10
|
+
function __eliscript_tdz_read_2() { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("intrinsic_code_point"); return intrinsic_code_point; }
|
|
11
|
+
function __eliscript_tdz_write_2(__eliscript_tdz_value_2) { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("intrinsic_code_point"); return __eliscript_const_error(); }
|
|
12
|
+
var __eliscript_tdz_ready_3;
|
|
13
|
+
function __eliscript_tdz_read_3() { if (__eliscript_tdz_ready_3 !== true) __eliscript_tdz_error("intrinsic_from_code_point"); return intrinsic_from_code_point; }
|
|
14
|
+
function __eliscript_tdz_write_3(__eliscript_tdz_value_3) { if (__eliscript_tdz_ready_3 !== true) __eliscript_tdz_error("intrinsic_from_code_point"); return __eliscript_const_error(); }
|
|
15
|
+
import { c as __eliscript_at, d as __eliscript_at_direct } from "data:text/javascript;base64,dmFyIG09UmVmbGVjdC5hcHBseSx0dD1OdW1iZXIucHJvdG90eXBlLnZhbHVlT2Ysaj1OdW1iZXIucHJvdG90eXBlLnRvU3RyaW5nLFU9TnVtYmVyLG50PU9iamVjdC5jcmVhdGUsaD1CaWdJbnQsZXQ9RGF0YVZpZXcsb3Q9QXJyYXlCdWZmZXIsaXQ9RGF0YVZpZXcucHJvdG90eXBlLnNldEZsb2F0NjQsSj1EYXRhVmlldy5wcm90b3R5cGUuZ2V0VWludDMyLHJ0PVJhbmdlRXJyb3I7ZnVuY3Rpb24gY3QodCxuKXtsZXQgZT1oKG4pLG89aCh0KSxpPSIiO2lmKG88MG4pbz0tbztkb3tsZXQgZj1vJWU7aT0iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltVKGYpXStpLG8vPWV9d2hpbGUobyE9PTBuKTtyZXR1cm4gdDwwPyItIitpOml9ZnVuY3Rpb24gc3QodCxuKXtsZXQgZT1uZXcgZXQobmV3IG90KDgpKTttKGl0LGUsWzAsdCwhMV0pO2xldCBvPW0oSixlLFswLCExXSksaT1tKEosZSxbNCwhMV0pLGY9bz4+PjIwJjIwNDcsYj1vJjEwNDg1NzUscD1vPj4+MzEscj1oKGIpPDwzMm58aChpKTtpZihmIT09MClyKz0xbjw8NTJuO3I8PD0ybjtsZXQgbD00bix1PWY+MSYmYj09PTAmJmk9PT0wPzFuOjJuLGs9Mm47aWYoZj49MTA3NSl7bGV0IGM9aChmLTEwNzUpO3I8PD1jLHU8PD1jLGs8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e2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9WChlLDEpLHQ9byxuPWk7Y29udGludWV9aWYodD09PU4pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9Wih5KGUsMSksITApLHQ9byxuPWk7Y29udGludWV9aWYodD09PXMpe2xldCBvPXkoZSwwKSxpPXkoZSwxKTtpZighQShvKSlyZXR1cm4gcyh0LG4sZSk7ZT1aKHkoZSwyKSwhMSksdD1vLG49aTtjb250aW51ZX1pZih0PT09RSl7bGV0IG89cyh0LG4sZSk7aWYobiE9PWomJm4hPT1LJiZuIT09eiYmbiE9PU0mJm4hPT1OJiZuIT09cyYmbiE9PUUpcmV0dXJuIG87bGV0IGk9bixmPXkoZSwwKSxiPVgoZSwxKSxwPSguLi51KT0+TChpLGYsU3QoYix1KSk7VChwLHB0LHt2YWx1ZToodSk9PnUgaW5zdGFuY2VvZiBpLGNvbmZpZ3VyYWJsZTohMH0pO2xldCByPXMoRSxwLFt2b2lkIDBdKTt1dChyLGZ0KG8pKTtsZXQgbD1hdChvKTtmb3IobGV0IHU9MDt1PGwubGVuZ3RoO3UrKylUKHIsbFt1XSxsdChvLGxbdV0pKTtyZXR1cm4gcn1yZXR1cm4gcyh0LG4sZSl9fWZ1bmN0aW9uIFJ0KHQsbil7bGV0IGU9dFtuXTtyZXR1cm4oLi4ubyk9PkwoZSx0LG8pfWZ1bmN0aW9uIEF0KHQsbiwuLi5lKXtsZXQgbz10W25dO3JldHVybiBMKG8sdCxlKX1leHBvcnR7UnQgYXMgYyxBdCBhcyBkfTs=";
|
|
16
|
+
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
17
|
+
const __eliscript_number_intrinsic = globalThis.Number;
|
|
18
|
+
const __eliscript_bigint_intrinsic = globalThis.BigInt;
|
|
19
|
+
const __eliscript_numeric_apply = globalThis.Reflect.apply;
|
|
20
|
+
const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
|
|
21
|
+
const __eliscript_numeric_error = globalThis.TypeError;
|
|
22
|
+
const __eliscript_numeric_trim = globalThis.String.prototype.trim;
|
|
23
|
+
const __eliscript_numeric_slice = globalThis.String.prototype.slice;
|
|
24
|
+
const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
|
|
25
|
+
const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
|
|
26
|
+
const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
|
|
27
|
+
const __eliscript_numeric_primitive = (value) => {
|
|
28
|
+
if (!__eliscript_numeric_object(value)) return value;
|
|
29
|
+
const exotic = value[__eliscript_numeric_symbol];
|
|
30
|
+
if (exotic !== void 0 && exotic !== null) {
|
|
31
|
+
const result = __eliscript_numeric_apply(exotic, value, ["number"]);
|
|
32
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
33
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
34
|
+
}
|
|
35
|
+
for (let index = 0; index < 2; index++) {
|
|
36
|
+
const method = value[index === 0 ? "valueOf" : "toString"];
|
|
37
|
+
if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
|
|
38
|
+
const result = __eliscript_numeric_apply(method, value, []);
|
|
39
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
43
|
+
};
|
|
44
|
+
const __eliscript_to_number = (value) => {
|
|
45
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
46
|
+
if (typeof primitive === "string") {
|
|
47
|
+
const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
|
|
48
|
+
if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
|
|
49
|
+
let first = 2;
|
|
50
|
+
while (first < text.length && text[first] === "0") first++;
|
|
51
|
+
if (first === text.length) return 0;
|
|
52
|
+
const prefix = text[1];
|
|
53
|
+
const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
|
|
54
|
+
if (text.length - first > limit) return 1 / 0;
|
|
55
|
+
const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
|
|
56
|
+
return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return __eliscript_number_intrinsic(primitive);
|
|
60
|
+
};
|
|
61
|
+
const __eliscript_numeric = (value) => {
|
|
62
|
+
if (typeof value === "number" || typeof value === "bigint") return value;
|
|
63
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
64
|
+
if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
|
|
65
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
66
|
+
};
|
|
67
|
+
const __eliscript_implicit_number = (value) => {
|
|
68
|
+
if (typeof value === "number") return value;
|
|
69
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
70
|
+
if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
|
|
71
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
72
|
+
};
|
|
73
|
+
const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
|
|
74
|
+
const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
|
|
75
|
+
const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
|
|
76
|
+
const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
|
|
77
|
+
const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
|
|
78
|
+
const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
|
|
79
|
+
const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
|
|
80
|
+
const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
|
|
81
|
+
const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
|
|
82
|
+
const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
|
|
83
|
+
const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
|
|
84
|
+
const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
|
|
85
|
+
const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
|
|
86
|
+
const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
|
|
87
|
+
const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
|
|
88
|
+
const __eliscript_numeric_relation = (operator, left, right) => {
|
|
89
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
90
|
+
if (operator === "<") return left < right;
|
|
91
|
+
if (operator === "<=") return left <= right;
|
|
92
|
+
if (operator === ">") return left > right;
|
|
93
|
+
return left >= right;
|
|
94
|
+
}
|
|
95
|
+
let a = __eliscript_numeric_primitive(left);
|
|
96
|
+
let b = __eliscript_numeric_primitive(right);
|
|
97
|
+
const x = typeof a, y = typeof b;
|
|
98
|
+
if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
|
|
99
|
+
a = __eliscript_numeric(a);
|
|
100
|
+
b = __eliscript_numeric(b);
|
|
101
|
+
}
|
|
102
|
+
if (operator === "<") return a < b;
|
|
103
|
+
if (operator === "<=") return a <= b;
|
|
104
|
+
if (operator === ">") return a > b;
|
|
105
|
+
return a >= b;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
import * as data from "./unicode-case-data.mjs";
|
|
109
|
+
const installed = new (globalThis.WeakMap)();
|
|
110
|
+
__eliscript_tdz_ready_0 = true;
|
|
111
|
+
const intrinsic_string = globalThis.String;
|
|
112
|
+
__eliscript_tdz_ready_1 = true;
|
|
113
|
+
const intrinsic_code_point = (((__eliscript_tdz_read_1()))["prototype"])["codePointAt"];
|
|
114
|
+
__eliscript_tdz_ready_2 = true;
|
|
115
|
+
const intrinsic_from_code_point = ((__eliscript_tdz_read_1()))["fromCodePoint"];
|
|
116
|
+
__eliscript_tdz_ready_3 = true;
|
|
117
|
+
function point(text, index) {
|
|
118
|
+
return __eliscript_at(Reflect, "apply")((__eliscript_tdz_read_2()), text, [index]);
|
|
119
|
+
}
|
|
120
|
+
function characters(code) {
|
|
121
|
+
return __eliscript_at(Reflect, "apply")((__eliscript_tdz_read_3()), (__eliscript_tdz_read_1()), [code]);
|
|
122
|
+
}
|
|
123
|
+
function tables(version) {
|
|
124
|
+
{
|
|
125
|
+
const __eliscript_value_1 = ((version === 15.1) ? "151" : ((version === 16) ? "160" : ((version === 17) ? "17" : ((__eliscript_value_2) => { throw __eliscript_value_2; })(new (globalThis.TypeError)("Unicode case profile must be 15.1, 16, or 17")))));
|
|
126
|
+
{
|
|
127
|
+
let suffix = __eliscript_value_1;
|
|
128
|
+
return ({"upper": [(data)[("unicode_case_data_upper_0_" + suffix)], (data)[("unicode_case_data_upper_1_" + suffix)], (data)[("unicode_case_data_upper_2_" + suffix)]], "lower": [(data)[("unicode_case_data_lower_0_" + suffix)], (data)[("unicode_case_data_lower_1_" + suffix)], (data)[("unicode_case_data_lower_2_" + suffix)]], "cased": (data)[("unicode_case_data_cased_" + suffix)], "ignorable": (data)[("unicode_case_data_case_ignorable_" + suffix)]});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function final_sigma(text, index, before, rules) {
|
|
133
|
+
{
|
|
134
|
+
const __eliscript_value_3 = before;
|
|
135
|
+
const __eliscript_value_4 = false;
|
|
136
|
+
{
|
|
137
|
+
let result = __eliscript_value_3;
|
|
138
|
+
let done = __eliscript_value_4;
|
|
139
|
+
while (((before === 1) && (!__eliscript_truthy(done)) && __eliscript_numeric_relation("<", index, ((text) ?? []).length))) {
|
|
140
|
+
{
|
|
141
|
+
const __eliscript_value_5 = point(text, index);
|
|
142
|
+
{
|
|
143
|
+
let code = __eliscript_value_5;
|
|
144
|
+
if ((((rules)["ignorable"])(code) === 0)) {
|
|
145
|
+
((done = true));
|
|
146
|
+
if ((((rules)["cased"])(code) === 1)) {
|
|
147
|
+
((result = 0));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
((index = (index + (__eliscript_numeric_relation(">", code, 65535) ? 2 : 1))));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function convert(text, upper, rules) {
|
|
159
|
+
{
|
|
160
|
+
let mapping = (rules)[(__eliscript_truthy(upper) ? "upper" : "lower")];
|
|
161
|
+
let first_map = (mapping)[0];
|
|
162
|
+
let second_map = (mapping)[1];
|
|
163
|
+
let third_map = (mapping)[2];
|
|
164
|
+
let pieces = [];
|
|
165
|
+
let chunk = "";
|
|
166
|
+
let index = 0;
|
|
167
|
+
let before = 0;
|
|
168
|
+
while (__eliscript_numeric_relation("<", index, ((text) ?? []).length)) {
|
|
169
|
+
{
|
|
170
|
+
let code = point(text, index);
|
|
171
|
+
let step = (__eliscript_numeric_relation(">", code, 65535) ? 2 : 1);
|
|
172
|
+
let first = first_map(code);
|
|
173
|
+
let second = second_map(code);
|
|
174
|
+
let third = third_map(code);
|
|
175
|
+
if (((!__eliscript_truthy(upper)) && (code === 931) && (final_sigma(text, (index + step), before, rules) === 1))) {
|
|
176
|
+
((first = 962));
|
|
177
|
+
}
|
|
178
|
+
((chunk = (chunk + characters(first))));
|
|
179
|
+
if (((__eliscript_value_6, __eliscript_value_7) => (__eliscript_value_6 !== __eliscript_value_7))(second, 0)) {
|
|
180
|
+
((chunk = (chunk + characters(second))));
|
|
181
|
+
}
|
|
182
|
+
if (((__eliscript_value_8, __eliscript_value_9) => (__eliscript_value_8 !== __eliscript_value_9))(third, 0)) {
|
|
183
|
+
((chunk = (chunk + characters(third))));
|
|
184
|
+
}
|
|
185
|
+
if (__eliscript_numeric_relation(">=", ((chunk) ?? []).length, 4096)) {
|
|
186
|
+
(pieces)["push"](chunk);
|
|
187
|
+
((chunk = ""));
|
|
188
|
+
}
|
|
189
|
+
if (((!__eliscript_truthy(upper)) && (((rules)["ignorable"])(code) === 0))) {
|
|
190
|
+
((before = ((rules)["cased"])(code)));
|
|
191
|
+
}
|
|
192
|
+
((index = (index + step)));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (__eliscript_numeric_relation(">", ((chunk) ?? []).length, 0)) {
|
|
196
|
+
(pieces)["push"](chunk);
|
|
197
|
+
}
|
|
198
|
+
return __eliscript_at_direct(pieces, "join", "");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function profile_method(name, upper, rules, string_constructor, function_prototype, type_error) {
|
|
202
|
+
{
|
|
203
|
+
const __eliscript_value_10 = (() => {
|
|
204
|
+
return undefined;
|
|
205
|
+
});
|
|
206
|
+
{
|
|
207
|
+
let target = __eliscript_value_10;
|
|
208
|
+
Object.setPrototypeOf(target, function_prototype);
|
|
209
|
+
Object.defineProperty(target, "name", ({"value": name, "configurable": true}));
|
|
210
|
+
Object.defineProperty(target, "length", ({"value": 0, "configurable": true}));
|
|
211
|
+
return new (globalThis.Proxy)(target, ({"apply": ((ignored, receiver, arguments$) => {
|
|
212
|
+
if ((receiver == null)) {
|
|
213
|
+
((__eliscript_value_11) => { throw __eliscript_value_11; })(new (type_error)(("String.prototype." + name + " called on null or undefined")));
|
|
214
|
+
}
|
|
215
|
+
if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(receiver) === "symbol")) {
|
|
216
|
+
((__eliscript_value_12) => { throw __eliscript_value_12; })(new (type_error)("Cannot convert a Symbol value to a string"));
|
|
217
|
+
}
|
|
218
|
+
{
|
|
219
|
+
const __eliscript_value_13 = __eliscript_at(Reflect, "apply")(string_constructor, undefined, [receiver]);
|
|
220
|
+
{
|
|
221
|
+
let text = __eliscript_value_13;
|
|
222
|
+
return convert(text, upper, rules);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
})}));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function installUnicodeCaseProfile(version, ...arguments$) {
|
|
230
|
+
{
|
|
231
|
+
let rules = tables(version);
|
|
232
|
+
let requested_realm = ((((arguments$) ?? []).length === 0) ? undefined : (arguments$)[0]);
|
|
233
|
+
let realm = ((requested_realm === undefined) ? globalThis.globalThis : requested_realm);
|
|
234
|
+
if ((!__eliscript_truthy(((__eliscript_value_14) => (__eliscript_truthy(__eliscript_value_14) ? ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((realm)["String"]) === "function") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((realm)["Function"]) === "function") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((realm)["TypeError"]) === "function")) : __eliscript_value_14))(realm)))) {
|
|
235
|
+
((__eliscript_value_15) => { throw __eliscript_value_15; })(new (globalThis.TypeError)("Unicode case profile requires a real String realm"));
|
|
236
|
+
}
|
|
237
|
+
{
|
|
238
|
+
let string_constructor = (realm)["String"];
|
|
239
|
+
let prototype = (string_constructor)["prototype"];
|
|
240
|
+
let function_prototype = ((realm)["Function"])["prototype"];
|
|
241
|
+
let type_error = (realm)["TypeError"];
|
|
242
|
+
let previous = ((__eliscript_tdz_read_0()))["get"](prototype);
|
|
243
|
+
if (__eliscript_truthy(((__eliscript_value_16) => (__eliscript_truthy(__eliscript_value_16) ? ((previous)["version"] === version) : __eliscript_value_16))(previous))) {
|
|
244
|
+
return previous;
|
|
245
|
+
} else {
|
|
246
|
+
{
|
|
247
|
+
const __eliscript_value_17 = ["toUpperCase", "toLowerCase"];
|
|
248
|
+
const __eliscript_value_18 = 0;
|
|
249
|
+
{
|
|
250
|
+
let names = __eliscript_value_17;
|
|
251
|
+
let index = __eliscript_value_18;
|
|
252
|
+
while (__eliscript_numeric_relation("<", index, 2)) {
|
|
253
|
+
{
|
|
254
|
+
const __eliscript_value_19 = Object.getOwnPropertyDescriptor(prototype, (names)[index]);
|
|
255
|
+
{
|
|
256
|
+
let descriptor = __eliscript_value_19;
|
|
257
|
+
if (__eliscript_truthy((__eliscript_truthy(descriptor) ? (!__eliscript_truthy((descriptor)["configurable"])) : (!__eliscript_truthy(Object.isExtensible(prototype)))))) {
|
|
258
|
+
((__eliscript_value_20) => { throw __eliscript_value_20; })(new (type_error)("Unicode case profile cannot replace a fixed String method"));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
((index = (index + 1)));
|
|
263
|
+
}
|
|
264
|
+
{
|
|
265
|
+
let upper = profile_method("toUpperCase", true, rules, string_constructor, function_prototype, type_error);
|
|
266
|
+
let lower = profile_method("toLowerCase", false, rules, string_constructor, function_prototype, type_error);
|
|
267
|
+
let state = Object.freeze(({"version": version, "upper": upper, "lower": lower}));
|
|
268
|
+
Object.defineProperty(prototype, "toUpperCase", ({"value": upper, "writable": true, "enumerable": false, "configurable": true}));
|
|
269
|
+
Object.defineProperty(prototype, "toLowerCase", ({"value": lower, "writable": true, "enumerable": false, "configurable": true}));
|
|
270
|
+
((__eliscript_tdz_read_0()))["set"](prototype, state);
|
|
271
|
+
return state;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
installUnicodeCaseProfile(17);
|
|
280
|
+
export {installUnicodeCaseProfile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime/unicode-case.mjs","sources":["runtime/unicode-case.eli"],"sourcesContent":["(module eliscript.runtime.unicode-case\n (import \"./unicode-case-data.mjs\" :as data)\n\n ;; Ordinary Eliscript JavaScript uses the same Unicode 17 default as the\n ;; owned runtime. Explicit profile selection remains available below.\n ;; Tables are derived from the one maintained Unicode-3.0 region in memory.eli.\n (defconst installed (new globalThis.WeakMap))\n (defconst intrinsic-string globalThis.String)\n (defconst intrinsic-code-point (get (get intrinsic-string :prototype) :codePointAt))\n (defconst intrinsic-from-code-point (get intrinsic-string :fromCodePoint))\n\n (defun point (text index)\n (Reflect/apply intrinsic-code-point text (js-array index)))\n (defun characters (code)\n (Reflect/apply intrinsic-from-code-point intrinsic-string (js-array code)))\n (defun tables (version)\n (let ((suffix (cond ((= version 15.1) \"151\") ((= version 16) \"160\") ((= version 17) \"17\")\n (t (throw (new globalThis.TypeError \"Unicode case profile must be 15.1, 16, or 17\"))))))\n (js-object :upper (js-array (get data (+ \"unicode_case_data_upper_0_\" suffix))\n (get data (+ \"unicode_case_data_upper_1_\" suffix)) (get data (+ \"unicode_case_data_upper_2_\" suffix)))\n :lower (js-array (get data (+ \"unicode_case_data_lower_0_\" suffix))\n (get data (+ \"unicode_case_data_lower_1_\" suffix)) (get data (+ \"unicode_case_data_lower_2_\" suffix)))\n :cased (get data (+ \"unicode_case_data_cased_\" suffix))\n :ignorable (get data (+ \"unicode_case_data_case_ignorable_\" suffix)))))\n\n (defun final-sigma (text index before rules)\n (let ((result before) (done false))\n (while (and (= before 1) (not done) (< index (js-length text)))\n (let ((code (point text index)))\n (when (= (funcall (get rules :ignorable) code) 0)\n (setq done t)\n (when (= (funcall (get rules :cased) code) 1) (setq result 0)))\n (setq index (+ index (if (> code 65535) 2 1))))) result))\n\n (defun convert (text upper rules)\n (let* ((mapping (get rules (if upper \"upper\" \"lower\")))\n (first-map (aref mapping 0)) (second-map (aref mapping 1)) (third-map (aref mapping 2))\n (pieces (js-array)) (chunk \"\") (index 0) (before 0))\n (while (< index (js-length text))\n (let* ((code (point text index)) (step (if (> code 65535) 2 1))\n (first (funcall first-map code)) (second (funcall second-map code)) (third (funcall third-map code)))\n (when (and (not upper) (= code 931) (= (final-sigma text (+ index step) before rules) 1))\n (setq first 962))\n (setq chunk (+ chunk (characters first)))\n (when (/= second 0) (setq chunk (+ chunk (characters second))))\n (when (/= third 0) (setq chunk (+ chunk (characters third))))\n (when (>= (js-length chunk) 4096) (js-call pieces :push chunk) (setq chunk \"\"))\n (when (and (not upper) (= (funcall (get rules :ignorable) code) 0))\n (setq before (funcall (get rules :cased) code)))\n (setq index (+ index step))))\n (when (> (js-length chunk) 0) (js-call pieces :push chunk))\n (js-call pieces :join \"\")))\n\n (defun profile-method (name upper rules string-constructor function-prototype type-error)\n ;; An arrow target is intrinsically nonconstructible. Proxy [[Call]] gives\n ;; Eli the actual method receiver without embedded foreign-language code.\n (let ((target (lambda () undefined)))\n (Object/setPrototypeOf target function-prototype)\n (Object/defineProperty target \"name\" (js-object :value name :configurable t))\n (Object/defineProperty target \"length\" (js-object :value 0 :configurable t))\n (new globalThis.Proxy target (js-object :apply (lambda (ignored receiver arguments)\n (when (nullish? receiver)\n (throw (new type-error (+ \"String.prototype.\" name \" called on null or undefined\"))))\n ;; String(Symbol) has a special exception to abstract ToString; the\n ;; String prototype algorithms do not have that exception.\n (when (= (value-type receiver) \"symbol\")\n (throw (new type-error \"Cannot convert a Symbol value to a string\")))\n (let ((text (Reflect/apply string-constructor undefined (js-array receiver))))\n (convert text upper rules)))))))\n\n (defun installUnicodeCaseProfile (version &rest arguments)\n (let* ((rules (tables version))\n (requested-realm (if (= (js-length arguments) 0) undefined (aref arguments 0)))\n (realm (if (undefined? requested-realm) globalThis.globalThis requested-realm)))\n (unless (and realm (= (value-type (get realm :String)) \"function\")\n (= (value-type (get realm :Function)) \"function\")\n (= (value-type (get realm :TypeError)) \"function\"))\n (throw (new globalThis.TypeError \"Unicode case profile requires a real String realm\")))\n (let* ((string-constructor (get realm :String)) (prototype (get string-constructor :prototype))\n (function-prototype (get (get realm :Function) :prototype)) (type-error (get realm :TypeError))\n (previous (js-call installed :get prototype)))\n (if (and previous (= (get previous :version) version)) previous\n (let ((names (js-array \"toUpperCase\" \"toLowerCase\")) (index 0))\n ;; Check both ordinary intrinsic properties before publishing any\n ;; method, including the deleted-property/nonextensible boundary.\n (while (< index 2)\n (let ((descriptor (Object/getOwnPropertyDescriptor prototype (aref names index))))\n (when (if descriptor (not (get descriptor :configurable)) (not (Object/isExtensible prototype)))\n (throw (new type-error \"Unicode case profile cannot replace a fixed String method\"))))\n (setq index (1+ index)))\n (let* ((upper (profile-method \"toUpperCase\" t rules string-constructor function-prototype type-error))\n (lower (profile-method \"toLowerCase\" false rules string-constructor function-prototype type-error))\n (state (Object/freeze (js-object :version version :upper upper :lower lower))))\n (Object/defineProperty prototype \"toUpperCase\" (js-object :value upper :writable t :enumerable false :configurable t))\n (Object/defineProperty prototype \"toLowerCase\" (js-object :value lower :writable t :enumerable false :configurable t))\n (js-call installed :set prototype state) state))))))\n ;; ESM evaluation installs once, before the importing user module executes.\n ;; A later import is cached, so user getters, replacements and deletion remain.\n (installUnicodeCaseProfile 17)\n (export installUnicodeCaseProfile))\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACE,YAAsC;AAKtC,kBAAoB,KAAK;;AACzB,yBAA2B;;AAC3B,6BAA+B,CAAK,CAAK,4BAAiB,cAAY;;AACtE,kCAAoC,CAAK,4BAAiB;;AAE1D,eAAc,MAAK;EACjB,OAAA,eAAC,kBAAc,4BAAqB,MAAK,CAAU;;AACrD,oBAAmB;EACjB,OAAA,eAAC,kBAAc,4BAA0B,4BAAiB,CAAU;;AACtE,gBAAe;EACb;gCAAoB,CAAC,CAAG,YAAQ,QAAM,QAAO,CAAC,CAAG,YAAQ,MAAI,QAAO,CAAC,CAAG,YAAQ,MAAI,OAC7D,0DAAO,KAAK,sBAAqB;;UADlD;MAEJ,OAAA,EAAW,SAAO,CAAU,CAAK,MAAK,CAAG,+BAA6B,UAClE,CAAK,MAAK,CAAG,+BAA6B,UAAS,CAAK,MAAK,CAAG,+BAA6B,WAC/F,SAAO,CAAU,CAAK,MAAK,CAAG,+BAA6B,UACzD,CAAK,MAAK,CAAG,+BAA6B,UAAS,CAAK,MAAK,CAAG,+BAA6B,WAC/F,SAAO,CAAK,MAAK,CAAG,6BAA2B,UAC/C,aA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CAApC;QAA8C,OAAA;;QACrD;uCAAa,CAAU,eAAc;uCAAuB;;gBAAtD;gBAA+C;YAGnD,OAAO,kCAAG,OAAM;cACd;6CAAmB,gCAAgC,WAAU,CAAM,OAAM;;sBAAnE;kBACJ,uBAAM,oBAAI,cAAW,qBAAK,CAAK,YAAW,oBAAgB,qBAAM,oBAAoB;oBAClF,4DAAO,KAAK,YAAW;;;;cAC3B,CAAM,CAAA,QAAM,CAAI;;YAClB;kBAAO,QAAQ,eAAe,eAAc,MAAE,OAAM,oBAAmB,oBAAmB;kBACnF,QAAQ,eAAe,eAAc,OAAM,OAAM,oBAAmB,oBAAmB;kBACvF,QAAQ,cAAc,EAAW,WAAS,SAAQ,SAAO,OAAM,SAAO;cAC1E,sBAAsB,WAAU,eAAc,EAAW,SAAO,OAAM,YAAU,MAAE,cAAY,OAAM,gBAAc;cAClH,sBAAsB,WAAU,eAAc,EAAW,SAAO,OAAM,YAAU,MAAE,cAAY,OAAM,gBAAc;cACnH,CAAS,4BAAU,OAAK,WAAU;cAAO,OAAA;;;;;;;;AAGpD,0BAA0B;AAC3B,QAAQ"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
const mediaType = 'text/markdown; charset=utf-8';
|
|
2
|
+
const line = value => String(value).replace(/[\r\n]/gu, ' ');
|
|
3
|
+
function path(value) {
|
|
4
|
+
if (typeof value !== 'string' || !value.startsWith('/') || /[\s?#`\\]/u.test(value) || value.includes('//') || (value !== '/' && value.endsWith('/')) || value.split('/').some(p => p === '.' || p === '..') || ['/.well-known/gepo', '/.gepo'].some(p => value === p || value.startsWith(p + '/')) || new URL(value, 'https://local.invalid').pathname !== value) throw new TypeError('Expected a canonical public operation path');
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function target(value) {
|
|
8
|
+
const url = new URL(value);
|
|
9
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) throw new TypeError('Expected an HTTP URL without credentials');
|
|
10
|
+
url.hash = ''; return url;
|
|
11
|
+
}
|
|
12
|
+
function parent(value) { return value === '/' ? null : value.slice(0, value.lastIndexOf('/')) || '/'; }
|
|
13
|
+
|
|
14
|
+
export function defineOperation(options) {
|
|
15
|
+
path(options.path);
|
|
16
|
+
if (typeof options.execute !== 'function') throw new TypeError('Operation requires an execute function');
|
|
17
|
+
return Object.freeze({ title: options.path, summary: 'Invoke this operation.', contentType: 'application/json', request: 'Body is service-defined.', success: 'Use HTTP status and response representation.', failures: [], effect: 'Service-defined.', retry: 'No automatic POST retry.', ...options });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function usageMarkdown(operation) {
|
|
21
|
+
path(operation.path);
|
|
22
|
+
return `# ${line(operation.title ?? operation.path)}\n\nPOST \`${operation.path}\` with Content-Type: ${line(operation.contentType ?? 'application/json')}.\n\nPurpose: ${line(operation.summary ?? '')}\nRequest: ${line(operation.request ?? 'Body is service-defined.')}\nSuccess: ${line(operation.success ?? 'Use HTTP status and response representation.')}\nFailures: ${line((operation.failures ?? []).join('; ') || 'Use applicable HTTP error statuses.')}\nEffect: ${line(operation.effect ?? 'Service-defined.')}\nRetry: ${line(operation.retry ?? 'No automatic POST retry.')}\n`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function tree(operations) {
|
|
26
|
+
const nodes = new Map([['/', { operation: null, children: new Set() }]]);
|
|
27
|
+
for (const operation of operations) {
|
|
28
|
+
path(operation.path);
|
|
29
|
+
if (nodes.get(operation.path)?.operation) throw new TypeError('Duplicate operation path');
|
|
30
|
+
if (!nodes.has(operation.path)) nodes.set(operation.path, { operation: null, children: new Set() });
|
|
31
|
+
nodes.get(operation.path).operation = operation;
|
|
32
|
+
let child = operation.path;
|
|
33
|
+
while (parent(child) !== null) {
|
|
34
|
+
const directory = parent(child);
|
|
35
|
+
if (!nodes.has(directory)) nodes.set(directory, { operation: null, children: new Set() });
|
|
36
|
+
nodes.get(directory).children.add(child); child = directory;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return nodes;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function pathIndexMarkdown(title, operations, location = '/') {
|
|
43
|
+
path(location);
|
|
44
|
+
const nodes = tree(operations), node = nodes.get(location);
|
|
45
|
+
if (!node) return null;
|
|
46
|
+
const children = [...node.children].sort();
|
|
47
|
+
const kind = node.operation ? (children.length ? 'operation and directory' : 'operation') : 'directory';
|
|
48
|
+
let result = `# ${line(title ?? 'Service')}\n\nGEPO 0.2\nPath: \`${location}\`\nParent: ${parent(location) === null ? 'none' : `\`${parent(location)}\``}\nKind: ${kind}\n`;
|
|
49
|
+
if (node.operation) result += `\n## Usage\n\n${usageMarkdown(node.operation)}`;
|
|
50
|
+
result += '\n## Children\n\n';
|
|
51
|
+
if (!children.length) result += node.operation ? 'No immediate child paths.\n' : 'The visible capability set is empty.\n';
|
|
52
|
+
else for (const child of children) result += `- \`${child}\` — ${line(nodes.get(child).operation?.summary ?? 'Directory')}\n`;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function discoveryCandidates(value) {
|
|
57
|
+
const url = target(value); url.search = '';
|
|
58
|
+
const root = url.origin;
|
|
59
|
+
return [...new Set([...(url.pathname !== '/' ? [`${url.href}?.gepo`] : []), `${root}/?.gepo`, `${root}/.gepo`, `${root}/.well-known/gepo`])];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function classifyDiscovery(response) {
|
|
63
|
+
if (response.status < 200 || response.status >= 300 || !response.contentType) return { accepted: false, paths: [], empty: false };
|
|
64
|
+
const type = response.contentType.split(';')[0].trim().toLowerCase();
|
|
65
|
+
if (!['text/markdown', 'text/plain'].includes(type) || !/\bGEPO\b/u.test(response.body)) return { accepted: false, paths: [], empty: false };
|
|
66
|
+
const children = response.body.split(/^## Children\s*$/mu).at(-1);
|
|
67
|
+
const paths = [...new Set([...children.matchAll(/^\s*-\s+`(\/[^`\s]*)`/gmu)].map(m => m[1]))];
|
|
68
|
+
if (!paths.length && /^Path: `\/`$/mu.test(response.body) && /^Kind: operation$/mu.test(response.body)) paths.push('/');
|
|
69
|
+
const empty = /visible capability set is empty|no visible (?:operations|capabilities)/iu.test(children);
|
|
70
|
+
return { accepted: paths.length > 0 || empty, paths, empty };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function createService({ title = 'Service', operations = [], authorize = () => true, visible = () => true } = {}) {
|
|
74
|
+
const entries = operations.map(defineOperation); tree(entries);
|
|
75
|
+
const response = (body, status = 200, headers = {}) => new Response(body, { status, headers: { 'Content-Type': mediaType, 'Cache-Control': 'private, no-store', ...headers } });
|
|
76
|
+
return async function serve(request) {
|
|
77
|
+
const url = new URL(request.url);
|
|
78
|
+
const fixedEntry = ['/.gepo', '/.well-known/gepo'].includes(url.pathname);
|
|
79
|
+
const discovery = ['GET', 'HEAD'].includes(request.method) && (url.searchParams.has('.gepo') || fixedEntry);
|
|
80
|
+
const location = fixedEntry ? '/' : url.pathname;
|
|
81
|
+
const available = [];
|
|
82
|
+
for (const operation of entries) if (await visible(request, operation)) available.push(operation);
|
|
83
|
+
const nodes = tree(available), node = nodes.get(location);
|
|
84
|
+
if (!node) return response('Unknown path', 404);
|
|
85
|
+
const permission = await authorize(request, node.operation, discovery ? 'index' : request.method === 'POST' ? 'invoke' : 'usage');
|
|
86
|
+
if (permission instanceof Response) return permission;
|
|
87
|
+
if (permission !== true) return response('Forbidden', 403);
|
|
88
|
+
const allow = node.operation && !fixedEntry ? 'GET, HEAD, OPTIONS, POST' : 'GET, HEAD, OPTIONS';
|
|
89
|
+
if (request.method === 'OPTIONS') return new Response(null, { status: 204, headers: { Allow: allow } });
|
|
90
|
+
if (request.method === 'GET' || request.method === 'HEAD') {
|
|
91
|
+
const body = discovery || !node.operation ? pathIndexMarkdown(title, available, location) : usageMarkdown(node.operation);
|
|
92
|
+
return response(request.method === 'HEAD' ? null : body);
|
|
93
|
+
}
|
|
94
|
+
if (request.method !== 'POST' || !node.operation || ['/.gepo', '/.well-known/gepo'].includes(url.pathname)) return response('Method not allowed', 405, { Allow: allow });
|
|
95
|
+
const result = await node.operation.execute(request);
|
|
96
|
+
if (!(result instanceof Response)) throw new TypeError('Operation must return a Response');
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function createClient({ fetch: transport = globalThis.fetch, headers: defaults = {}, maxBytes = 2097152, timeoutMs = 30000, classify = classifyDiscovery } = {}) {
|
|
102
|
+
if (typeof transport !== 'function' || typeof classify !== 'function' || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1) throw new TypeError('Invalid client options');
|
|
103
|
+
const defaultHeaders = new Headers(defaults);
|
|
104
|
+
async function send(url, method, body, options = {}) {
|
|
105
|
+
const headers = new Headers(defaultHeaders);
|
|
106
|
+
new Headers(options.headers).forEach((value, key) => headers.set(key, value));
|
|
107
|
+
if (!headers.has('Accept')) headers.set('Accept', 'text/markdown, text/plain;q=0.8, */*;q=0.1');
|
|
108
|
+
if (options.contentType) headers.set('Content-Type', options.contentType);
|
|
109
|
+
const controller = new AbortController();
|
|
110
|
+
const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
111
|
+
if (signal.aborted) throw signal.reason ?? new Error('HTTP request aborted');
|
|
112
|
+
const timer = setTimeout(() => controller.abort(new Error('HTTP timeout')), timeoutMs);
|
|
113
|
+
let onAbort;
|
|
114
|
+
const aborted = new Promise((resolve, reject) => {
|
|
115
|
+
onAbort = () => reject(signal.reason ?? new Error('HTTP request aborted'));
|
|
116
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
const reply = await Promise.race([aborted, transport(url.href, { method, body, headers, redirect: 'manual', signal })]);
|
|
120
|
+
if (reply.status >= 300 && reply.status < 400) { await reply.body?.cancel(); throw new Error('Redirect requires explicit caller handling'); }
|
|
121
|
+
const chunks = []; let size = 0;
|
|
122
|
+
if (reply.body) {
|
|
123
|
+
const reader = reply.body.getReader();
|
|
124
|
+
try {
|
|
125
|
+
while (true) {
|
|
126
|
+
const { done, value } = await Promise.race([aborted, reader.read()]); if (done) break;
|
|
127
|
+
size += value.byteLength;
|
|
128
|
+
if (size > maxBytes) { await reader.cancel(); throw new RangeError('HTTP response byte limit'); }
|
|
129
|
+
chunks.push(value);
|
|
130
|
+
}
|
|
131
|
+
} catch (error) { await reader.cancel().catch(() => {}); throw error; }
|
|
132
|
+
finally { reader.releaseLock(); }
|
|
133
|
+
}
|
|
134
|
+
const bytes = new Uint8Array(size); let offset = 0;
|
|
135
|
+
for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.byteLength; }
|
|
136
|
+
return { url: url.href, status: reply.status, contentType: reply.headers.get('Content-Type'), headers: reply.headers, body: new TextDecoder().decode(bytes) };
|
|
137
|
+
} finally { clearTimeout(timer); signal.removeEventListener('abort', onAbort); }
|
|
138
|
+
}
|
|
139
|
+
async function usage(value, options = {}) {
|
|
140
|
+
const url = target(value); url.searchParams.delete('.gepo');
|
|
141
|
+
return send(url, 'GET', undefined, options);
|
|
142
|
+
}
|
|
143
|
+
async function index(value, options = {}) {
|
|
144
|
+
const url = target(value); url.search = '.gepo';
|
|
145
|
+
return send(url, 'GET', undefined, options);
|
|
146
|
+
}
|
|
147
|
+
return Object.freeze({ usage, index,
|
|
148
|
+
async discover(value, options = {}) {
|
|
149
|
+
const attempts = [];
|
|
150
|
+
for (const candidate of discoveryCandidates(value)) {
|
|
151
|
+
const reply = await send(target(candidate), 'GET', undefined, options);
|
|
152
|
+
const result = await classify(reply);
|
|
153
|
+
attempts.push({ url: reply.url, status: reply.status, accepted: result.accepted });
|
|
154
|
+
if (result.accepted) return { ...reply, paths: result.paths, state: result.empty ? 'empty' : 'found', attempts };
|
|
155
|
+
}
|
|
156
|
+
return { state: 'not-found', attempts };
|
|
157
|
+
},
|
|
158
|
+
async invoke(value, body, options = {}) {
|
|
159
|
+
if (options.allowPost !== true) throw new TypeError('Invocation requires allowPost: true');
|
|
160
|
+
if (body === undefined) throw new TypeError('Invocation requires an explicit body');
|
|
161
|
+
const url = target(value);
|
|
162
|
+
if (url.searchParams.has('.gepo')) throw new TypeError('Discovery parameter is reserved');
|
|
163
|
+
const description = await usage(url, options);
|
|
164
|
+
if (description.status < 200 || description.status >= 300) throw new Error(`Usage request failed: ${description.status}`);
|
|
165
|
+
return send(url, 'POST', body, options);
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|