Spec explorer data endpoint, spec file finder, browser render test (failing)

- Add spec-explorer-data-by-slug helper with _SPEC_SLUG_MAP
- _find_spec_file searches spec/, web/, shared/sx/ref/ directories
- defpage specs-explore-page uses :data for server-side data fetch
- test_evaluator_renders_in_browser: failing test for client-side rendering
  (client re-evaluates defpage content, find-spec unavailable — pre-existing)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 17:36:21 +00:00
parent 71c2003a60
commit fac97883f9
6 changed files with 100 additions and 15 deletions

View File

@@ -0,0 +1,18 @@
const path = require("path");
const fs = require("fs");
require(path.join(__dirname, "../_build/default/browser/sx_browser.bc.js"));
require(path.join(__dirname, "sx-platform.js"));
const K = globalThis.SxKernel;
for (const n of ["signals","deps","page-helpers","router","adapter-html"])
K.loadSource(fs.readFileSync(path.join(__dirname,`../../../web/${n}.sx`),"utf8"));
K.loadSource(fs.readFileSync("/tmp/comp_defs.txt","utf8"));
const pageSx = fs.readFileSync("/tmp/page_sx.txt","utf8");
const parsed = K.parse(pageSx);
const html = K.renderToHtml(parsed[0]);
if (typeof html === "string" && !html.startsWith("Error:")) {
console.log("SUCCESS! Rendered", html.length, "chars of HTML");
console.log("Preview:", html.substring(0, 200));
} else {
console.log("Error:", html);
}

View File

@@ -0,0 +1,25 @@
const path = require("path");
const fs = require("fs");
require(path.join(__dirname, "../_build/default/browser/sx_browser.bc.js"));
require(path.join(__dirname, "sx-platform.js"));
const K = globalThis.SxKernel;
for (const n of ["signals","deps","page-helpers","router","adapter-html"])
K.loadSource(fs.readFileSync(path.join(__dirname,`../../../web/${n}.sx`),"utf8"));
// Test signal basics
const tests = [
'(signal 42)',
'(let ((s (signal 42))) (deref s))',
'(let ((s (signal 42))) (reset! s 100) (deref s))',
'(let ((s (signal 10))) (swap! s (fn (v) (* v 2))) (deref s))',
'(let ((s (signal 0))) (computed (fn () (+ (deref s) 1))))',
'(let ((idx (signal 0))) (let ((c (computed (fn () (+ (deref idx) 10))))) (deref c)))',
];
for (const t of tests) {
const r = K.eval(t);
const s = JSON.stringify(r);
console.log(`${t.substring(0,60)}`);
console.log(` => ${s && s.length > 100 ? s.substring(0,100) + '...' : s}`);
console.log();
}