bend!-call from the WAT tier
- New WAT import: (import "env" "bend_call"). The host loader supplies
a sync XMLHttpRequest that POSTs the payload to a configured URL
(workers only — sync XHR isn't allowed on main thread).
- New primitive (bend!-call "<payload>") returns the response as a
lumbda string. Works in playground and REPL once the bend URL is
saved in the new top bar.
- bendUrl persists in plain localStorage (not encrypted — it's a
server address, not a secret).
- Tests stub the import with a no-op so unit / integration / functional
suites keep instantiating cleanly.
Playground + REPL zoom 133% by default
- html { zoom: 1.33 } so the styleguide sizes read comfortably without
requiring browser-level zoom.
Free-form default = cross-tier assertion runner in Lisp
- The default editor content for "free form" is now a small assertion
framework matching tests/functional.lsp's PASS/FAIL convention. A
starter the user can extend, runs identically on the three tiers.
C tier + Python tier (bend) are wired through the runner stub; full
bend integration in those tiers comes next once their loaders learn
about setBendUrl.
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
// wasm/app/runner.js
|
|
// Tier runner — wraps the three loaders. Exposes a per-tier API so the
|
|
// SPA can iterate, time, and render a live elapsed-ms counter between
|
|
// the eval start and finish.
|
|
|
|
import { createPythonTier } from "./python/lumbda-py.js";
|
|
import { createCTier } from "./c/lumbda-c.loader.js";
|
|
import { createAsmTier } from "./asm/lumbda-asm.loader.js";
|
|
|
|
const cache = {};
|
|
const config = { bendUrl: null };
|
|
|
|
export function setBendUrl(url) {
|
|
config.bendUrl = url || null;
|
|
// Propagate to already-loaded tiers.
|
|
for (const t of Object.values(cache)) {
|
|
if (t && t.setBendUrl) t.setBendUrl(config.bendUrl);
|
|
}
|
|
}
|
|
|
|
export async function getTier(name, onLoad) {
|
|
if (cache[name]) return cache[name];
|
|
if (onLoad) onLoad(name);
|
|
if (name === "python") cache[name] = await createPythonTier();
|
|
else if (name === "c") cache[name] = await createCTier();
|
|
else if (name === "asm") cache[name] = await createAsmTier();
|
|
else throw new Error(`unknown tier: ${name}`);
|
|
if (cache[name].setBendUrl) cache[name].setBendUrl(config.bendUrl);
|
|
return cache[name];
|
|
}
|
|
|
|
export async function evalOnTier(name, src, onLoad) {
|
|
const tier = await getTier(name, onLoad);
|
|
return tier.evalLisp(src);
|
|
}
|