sx: step 11 — migrate prolog hook + add worker plugin
Move `hs-prolog-hook` / `hs-set-prolog-hook!` / `prolog` out of
`lib/hyperscript/runtime.sx` into a self-contained plugin file at
`lib/hyperscript/plugins/prolog.sx`. The API surface is preserved —
`lib/prolog/hs-bridge.sx::pl-install-hs-hook!` still calls
`hs-set-prolog-hook!` exactly as before, just resolved to the plugin
file's binding rather than runtime.sx's.
Move the E39 worker stub registration out of `lib/hyperscript/parser.sx`
into `lib/hyperscript/plugins/worker.sx`. The plugin calls
`(hs-register-feature! "worker" ...)` at file load time. Behaviour is
identical — `worker MyWorker ...` raises the same helpful "plugin not
installed" error, just routed through the registry from a separate
file. The pre-existing `behavioral` test for the helpful error
("raises a helpful error when the worker plugin is not installed")
still passes via the new path.
Wire-up:
- OCaml `bin/run_tests.ml`: load `plugins/worker.sx` and
`plugins/prolog.sx` after `runtime.sx`, before `integration.sx`.
- JS `tests/hs-kernel-eval.js`: extend HS module list with
`hs-worker` / `hs-prolog`; add `HS_PLUGINS` resolver branch so the
`hs-` prefix maps to `lib/hyperscript/plugins/`.
- WASM `hosts/ocaml/browser/bundle.sh`: copy plugin files into
`dist/sx/hs-<name>.sx`.
- WASM `hosts/ocaml/browser/compile-modules.js`: add `hs-worker` /
`hs-prolog` to `FILES`, `HS_DEPS`, and `HS_LAZY` so the lazy loader
resolves them on first reference.
- Worker plugin carries a sentinel `(define hs-worker-loaded? true)`
so `extractDefines` indexes it in the module manifest (the lazy
loader skips files with no defines).
Mirrors `shared/static/wasm/sx/hs-{parser,runtime}.sx` are byte-identical
to source; new mirrors `hs-{prolog,worker}.sx` written via sx_write_file.
OCaml: 4545 passed, 1339 failed — matches baseline.
JS: 2591 passed, 2465 failed — matches baseline.
Smoke tests: `(prolog ...)` raises "prolog hook not installed" cleanly,
`(hs-set-prolog-hook! ...)` then `(prolog ...)` returns the hook result,
`(hs-compile "worker MyWorker def noop() end end")` raises the worker
stub error via the registry path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -946,9 +946,12 @@
|
||||
"hs-ident-start?",
|
||||
"hs-ident-char?",
|
||||
"hs-ws?",
|
||||
"hs-hex-digit?",
|
||||
"hs-hex-val",
|
||||
"hs-keywords",
|
||||
"hs-keyword?",
|
||||
"hs-tokenize"
|
||||
"hs-tokenize",
|
||||
"hs-tokenize-template"
|
||||
]
|
||||
},
|
||||
"hs-parser": {
|
||||
@@ -958,7 +961,9 @@
|
||||
],
|
||||
"exports": [
|
||||
"hs-parse",
|
||||
"hs-compile"
|
||||
"hs-span-mode",
|
||||
"hs-compile",
|
||||
"hs-parse-ast"
|
||||
]
|
||||
},
|
||||
"hs-compiler": {
|
||||
@@ -969,6 +974,7 @@
|
||||
],
|
||||
"exports": [
|
||||
"hs-to-sx",
|
||||
"hs-receiver-selector",
|
||||
"hs-to-sx-from-source"
|
||||
]
|
||||
},
|
||||
@@ -981,30 +987,50 @@
|
||||
],
|
||||
"exports": [
|
||||
"hs-each",
|
||||
"meta",
|
||||
"hs-on-every",
|
||||
"_hs-on-caller",
|
||||
"hs-on",
|
||||
"hs-on-every",
|
||||
"hs-on-intersection-attach!",
|
||||
"hs-on-mutation-attach!",
|
||||
"hs-init",
|
||||
"hs-wait",
|
||||
"hs-wait-for",
|
||||
"hs-settle",
|
||||
"hs-toggle-class!",
|
||||
"hs-toggle-var-cycle!",
|
||||
"hs-toggle-between!",
|
||||
"hs-toggle-style!",
|
||||
"hs-toggle-style-between!",
|
||||
"hs-toggle-style-cycle!",
|
||||
"hs-take!",
|
||||
"hs-put!",
|
||||
"hs-add-to!",
|
||||
"hs-remove-from!",
|
||||
"hs-splice-at!",
|
||||
"hs-index",
|
||||
"hs-put-at!",
|
||||
"hs-dict-without",
|
||||
"hs-set-on!",
|
||||
"hs-navigate!",
|
||||
"hs-ask",
|
||||
"hs-answer",
|
||||
"hs-answer-alert",
|
||||
"hs-scroll!",
|
||||
"hs-halt!",
|
||||
"hs-select!",
|
||||
"hs-get-selection",
|
||||
"hs-reset!",
|
||||
"hs-next",
|
||||
"hs-previous",
|
||||
"_hs-last-query-sel",
|
||||
"hs-null-raise!",
|
||||
"hs-empty-raise!",
|
||||
"hs-query-all-checked",
|
||||
"hs-dispatch!",
|
||||
"hs-query-all",
|
||||
"hs-query-all-in",
|
||||
"hs-list-set",
|
||||
"hs-to-number",
|
||||
"hs-query-first",
|
||||
"hs-query-last",
|
||||
"hs-first",
|
||||
@@ -1014,44 +1040,150 @@
|
||||
"hs-repeat-while",
|
||||
"hs-repeat-until",
|
||||
"hs-for-each",
|
||||
"hs-sender",
|
||||
"hs-host-to-sx",
|
||||
"hs-fetch-impl",
|
||||
"hs-fetch",
|
||||
"hs-fetch-no-throw",
|
||||
"hs-json-escape",
|
||||
"hs-json-stringify",
|
||||
"hs-coerce",
|
||||
"hs-gather-form-nodes",
|
||||
"hs-values-from-nodes",
|
||||
"hs-value-of-node",
|
||||
"hs-select-multi-values",
|
||||
"hs-values-absorb",
|
||||
"hs-as-values",
|
||||
"hs-default?",
|
||||
"hs-array-set!",
|
||||
"hs-add",
|
||||
"hs-make",
|
||||
"hs-install",
|
||||
"hs-measure",
|
||||
"hs-transition",
|
||||
"hs-transition-from",
|
||||
"hs-type-check",
|
||||
"hs-type-check-strict",
|
||||
"hs-strict-eq",
|
||||
"hs-id=",
|
||||
"hs-eq-ignore-case",
|
||||
"hs-starts-with?",
|
||||
"hs-ends-with?",
|
||||
"hs-scoped-set!",
|
||||
"hs-scoped-get",
|
||||
"hs-precedes?",
|
||||
"hs-follows?",
|
||||
"hs-starts-with-ic?",
|
||||
"hs-ends-with-ic?",
|
||||
"hs-matches-ignore-case?",
|
||||
"hs-contains-ignore-case?",
|
||||
"hs-falsy?",
|
||||
"hs-matches?",
|
||||
"hs-contains?",
|
||||
"hs-in?",
|
||||
"hs-in-bool?",
|
||||
"hs-is",
|
||||
"precedes?",
|
||||
"hs-empty?",
|
||||
"hs-empty-like",
|
||||
"hs-empty-target!",
|
||||
"hs-morph-char",
|
||||
"hs-morph-index-from",
|
||||
"hs-morph-sws",
|
||||
"hs-morph-read-until",
|
||||
"hs-morph-parse-attrs",
|
||||
"hs-morph-parse-element",
|
||||
"hs-morph-parse-children",
|
||||
"hs-morph-apply-attrs",
|
||||
"hs-morph-build-children",
|
||||
"hs-morph-build-child",
|
||||
"hs-morph!",
|
||||
"hs-open!",
|
||||
"hs-close!",
|
||||
"hs-hide!",
|
||||
"hs-show!",
|
||||
"hs-show-when!",
|
||||
"hs-hide-when!",
|
||||
"hs-first",
|
||||
"hs-last",
|
||||
"hs-template",
|
||||
"hs-make-object",
|
||||
"hs-strip-order-deep",
|
||||
"hs-method-call",
|
||||
"hs-beep",
|
||||
"hs-prop-is",
|
||||
"hs-slice",
|
||||
"hs-pick-first",
|
||||
"hs-pick-last",
|
||||
"hs-pick-random",
|
||||
"hs-pick-items",
|
||||
"hs-pick-match",
|
||||
"hs-pick-matches",
|
||||
"hs-sorted-by",
|
||||
"hs-sorted-by-desc",
|
||||
"hs-split-by",
|
||||
"hs-joined-by",
|
||||
"hs-sorted-by",
|
||||
"hs-sorted-by-desc"
|
||||
"hs-sorted-by",
|
||||
"hs-sorted-by-desc",
|
||||
"hs-dom-has-var?",
|
||||
"hs-dom-get-var-raw",
|
||||
"hs-dom-set-var-raw!",
|
||||
"hs-dom-resolve-start",
|
||||
"hs-dom-walk",
|
||||
"hs-dom-find-owner",
|
||||
"hs-dom-get",
|
||||
"hs-dom-set!",
|
||||
"_hs-dom-watchers",
|
||||
"hs-dom-watch!",
|
||||
"hs-dom-fire-watchers!",
|
||||
"hs-null-error!",
|
||||
"hs-named-target",
|
||||
"hs-named-target-list",
|
||||
"hs-query-named-all",
|
||||
"hs-dom-is-ancestor?",
|
||||
"hs-win-call",
|
||||
"hs-source-for",
|
||||
"hs-line-for",
|
||||
"hs-node-get",
|
||||
"hs-src",
|
||||
"hs-src-at",
|
||||
"hs-line-at",
|
||||
"hs-js-exec",
|
||||
"hs-raw->api-token",
|
||||
"hs-eof-sentinel",
|
||||
"hs-tokens-of",
|
||||
"hs-stream-token",
|
||||
"hs-stream-consume",
|
||||
"hs-stream-has-more",
|
||||
"hs-token-type",
|
||||
"hs-token-value",
|
||||
"hs-token-op?",
|
||||
"hs-try-json-parse",
|
||||
"hs-socket-normalise-url",
|
||||
"hs-socket-bind-name!",
|
||||
"hs-socket-resolve-rpc!",
|
||||
"hs-socket-register!"
|
||||
]
|
||||
},
|
||||
"hs-worker": {
|
||||
"file": "hs-worker.sxbc",
|
||||
"deps": [
|
||||
"hs-tokenizer",
|
||||
"hs-parser"
|
||||
],
|
||||
"exports": [
|
||||
"hs-worker-loaded?"
|
||||
]
|
||||
},
|
||||
"hs-prolog": {
|
||||
"file": "hs-prolog.sxbc",
|
||||
"deps": [
|
||||
"hs-tokenizer",
|
||||
"hs-parser",
|
||||
"hs-compiler",
|
||||
"hs-runtime"
|
||||
],
|
||||
"exports": [
|
||||
"hs-prolog-hook",
|
||||
"hs-set-prolog-hook!",
|
||||
"prolog"
|
||||
]
|
||||
},
|
||||
"hs-integration": {
|
||||
@@ -1060,10 +1192,15 @@
|
||||
"hs-tokenizer",
|
||||
"hs-parser",
|
||||
"hs-compiler",
|
||||
"hs-runtime"
|
||||
"hs-runtime",
|
||||
"hs-worker",
|
||||
"hs-prolog"
|
||||
],
|
||||
"exports": [
|
||||
"hs-register-scripts!",
|
||||
"hs-scripting-disabled?",
|
||||
"hs-activate!",
|
||||
"hs-deactivate!",
|
||||
"hs-boot!",
|
||||
"hs-boot-subtree!"
|
||||
]
|
||||
@@ -1075,6 +1212,8 @@
|
||||
"hs-parser",
|
||||
"hs-compiler",
|
||||
"hs-runtime",
|
||||
"hs-worker",
|
||||
"hs-prolog",
|
||||
"hs-integration"
|
||||
],
|
||||
"exports": [
|
||||
@@ -1158,6 +1297,8 @@
|
||||
"hs-parser",
|
||||
"hs-compiler",
|
||||
"hs-runtime",
|
||||
"hs-worker",
|
||||
"hs-prolog",
|
||||
"hs-integration",
|
||||
"hs-htmx"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user