Restore hyperscript work on stable site base (908f4f80)

Reset to last known-good state (908f4f80) where links, stepper, and
islands all work, then recovered all hyperscript implementation,
conformance tests, behavioral tests, Playwright specs, site sandbox,
IO-aware server loading, and upstream test suite from f271c88a.

Excludes runtime changes (VM resolve hook, VmSuspended browser handler,
sx_ref.ml guard recovery) that need careful re-integration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 19:29:56 +00:00
parent 908f4f80d4
commit 7492ceac4e
55 changed files with 32933 additions and 437 deletions

View File

@@ -43,4 +43,89 @@ function trackErrors(page) {
};
}
module.exports = { BASE_URL, waitForSxReady, loadPage, trackErrors };
/**
* Universal smoke checks for any SX page.
* Runs 10 assertions that every page should pass.
* Returns { pass: boolean, failures: string[] }.
*/
async function universalSmoke(page) {
const failures = [];
const warnings = [];
// 1. Not blank — #sx-content has substantial text
const contentLen = await page.evaluate(() => {
const el = document.querySelector('#sx-content') || document.body;
return el.textContent.length;
});
if (contentLen < 50) failures.push(`blank page (${contentLen} chars)`);
// 2. Has heading (soft — some index/demo pages legitimately lack headings)
const headingCount = await page.locator('h1, h2, h3, h4').count();
if (headingCount === 0) warnings.push('no heading (h1-h4)');
// 3. Title set
const title = await page.title();
if (!title || title === 'about:blank') failures.push(`title not set: "${title}"`);
// 4. Layout intact — #sx-nav exists
const navExists = await page.locator('#sx-nav').count();
if (navExists === 0) failures.push('no #sx-nav');
// 5. No duplicate structural IDs
const dupes = await page.evaluate(() => {
const ids = ['sx-nav', 'sx-content', 'main-panel'];
return ids.filter(id => document.querySelectorAll('#' + id).length > 1);
});
if (dupes.length > 0) failures.push(`duplicate IDs: ${dupes.join(', ')}`);
// 6. No broken hrefs — no [object Object] in links
const brokenLinks = await page.evaluate(() => {
return [...document.querySelectorAll('a[href]')]
.filter(a => a.href.includes('[object Object]'))
.length;
});
if (brokenLinks > 0) failures.push(`${brokenLinks} broken [object Object] links`);
// 7. CSSX present
const cssxCount = await page.locator('style[id="sx-css"], style[data-sx-css]').count();
if (cssxCount === 0) failures.push('no CSSX style tag');
// 8. No hard SX leaks — raw dicts, raw SX elements, [object Object]
// (Unresolved components like ~tw and CSSX :tokens are expected in SSR-only mode)
const leaks = await page.evaluate(() => {
const skip = new Set();
document.querySelectorAll('code, pre, script, style, [data-sx-source]').forEach(el => {
el.querySelectorAll('*').forEach(d => skip.add(d));
skip.add(el);
});
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, {
acceptNode: (node) => {
let p = node.parentElement;
while (p) {
if (skip.has(p)) return NodeFilter.FILTER_REJECT;
p = p.parentElement;
}
return NodeFilter.FILTER_ACCEPT;
}
});
let text = '';
let n;
while (n = walker.nextNode()) text += n.textContent;
const found = [];
if (/\{:(?:type|tag|expr|spreads|attrs)\s/.test(text)) found.push('raw-dict');
if (/\((?:div|span|h[1-6]|p|a|button)\s+:(?:class|id|style)/.test(text)) found.push('raw-sx-element');
if (/\[object Object\]/.test(text)) found.push('object-Object');
return found;
});
if (leaks.length > 0) failures.push(`SX leaks: ${leaks.join(', ')}`);
// 9. No console errors (checked by caller via trackErrors)
// — intentionally not checked here; caller should use trackErrors()
// 10. Hydration (optional — pages served via route interception may not hydrate)
// — checked by caller if applicable
return { pass: failures.length === 0, failures, warnings };
}
module.exports = { BASE_URL, waitForSxReady, loadPage, trackErrors, universalSmoke };