Release 2.7.0: executable handbooks and native user-site workflows

This commit is contained in:
cflmy committed 2026-11-10 17:03:06 +08:00
1 parent aa0c4d0f55
commit d9aef957f7
562 files changed
+21064 -20387

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "marqdo-wasm"
version = "2.6.0"
version = "2.7.0"
edition = "2021"
license = "Apache-2.0"
description = "Marqdo interpreter as WebAssembly (browser host bridge)"
+3 -1
View File
@@ -11,7 +11,7 @@ Raw `cdylib` exports — no `wasm-bindgen` CLI required.
```bash
# from repo root (C5 size profile)
marqdo wasm build -o examples/browser-hello
marqdo call skills/marqdo-dev/index.mq.md build_browser --effects plugin,process.exec,fs.write --fs-root . --json
# or:
cargo build -p marqdo-wasm --target wasm32-unknown-unknown --profile release-wasm
```
@@ -19,3 +19,5 @@ cargo build -p marqdo-wasm --target wasm32-unknown-unknown --profile release-was
Prints size in KiB; runs `wasm-opt -Oz` when Binaryen is on `PATH`.
See [doc/design/browser-marqdo-wasm.md](../../doc/design/browser-marqdo-wasm.md).
Use the maintained [browser-app](../../examples/browser-app/index.mq.md) for a runnable native Document and browser program. The ABI counter fixture lives in tests/wasm/counter.mq.md, with no independent HTML demo host. The former browser-hello and browser-media directories were retired in 2.7.0; their host capabilities remain documented in lib/browser.mq.md.
+43 -19
View File
@@ -228,28 +228,52 @@ function applyStyle(el, styleVal) {
}
export function renderListItems(spec) {
const tag = String(spec.tag || "li");
const rootTag = String(spec.tag || "li");
const items = Array.isArray(spec.items) ? spec.items : [];
return items
.map((it) => {
if (it == null) return "";
if (typeof it === "string" || typeof it === "number") {
return `<${tag}>${escapeHtml(String(it))}</${tag}>`;
}
if (!isPlainObject(it)) return "";
const text = it.text != null ? String(it.text) : it.html != null ? null : "";
const cls = it.class != null ? ` class="${escapeAttr(String(it.class))}"` : "";
let attrs = "";
if (isPlainObject(it.attrs)) {
for (const [k, v] of Object.entries(it.attrs)) {
if (v === null || v === false) continue;
attrs += ` ${escapeAttr(k)}="${escapeAttr(String(v))}"`;
let count = 0;
const render = (item, fallbackTag, depth) => {
if (depth > 32 || ++count > 10000) throw new Error("render_list: structural limit exceeded");
if (item == null) return "";
if (typeof item !== "string" && typeof item !== "number" && !isPlainObject(item)) return "";
const record = isPlainObject(item) ? item : { text: String(item) };
const tag = String(record.tag || fallbackTag);
if (!/^[a-z][a-z0-9-]*$/i.test(tag) ||
/^(script|style|iframe|object|embed|link|meta|base)$/i.test(tag)) {
throw new Error("render_list: unsupported element name");
}
let attrs = record.class != null ? ` class="${escapeAttr(String(record.class))}"` : "";
if (isPlainObject(record.attrs)) {
for (const [key, value] of Object.entries(record.attrs)) {
if (!/^[a-z_:][a-z0-9_.:-]*$/i.test(key) || /^on/i.test(key)) {
throw new Error("render_list: invalid attribute name");
}
if (value === null || value === false) continue;
if (!["string", "number", "boolean"].includes(typeof value)) throw new Error("render_list: attributes must be scalar");
if (/^(href|src|action|formaction)$/i.test(key) &&
/^[\s\u0000-\u0020]*(javascript|vbscript|data)[\s\u0000-\u0020]*:/i.test(String(value))) {
throw new Error("render_list: unsupported URL");
}
attrs += ` ${key}="${escapeAttr(String(value))}"`;
}
const inner = it.html != null ? String(it.html) : escapeHtml(text ?? "");
return `<${tag}${cls}${attrs}>${inner}</${tag}>`;
})
.join("");
}
let inner;
if (record.children != null) {
if (!Array.isArray(record.children) || record.text != null || record.html != null) {
throw new Error("render_list: children must be an unambiguous record list");
}
inner = record.children.map(child => render(child, "span", depth + 1)).join("");
} else {
// Preserve the existing explicit HTML escape hatch. Ordinary business
// values use text/children and never become source or markup.
inner = record.html != null ? String(record.html) : escapeHtml(String(record.text ?? ""));
}
if (/^(input|img|br|hr|area|col|source|wbr)$/i.test(tag)) {
if (inner) throw new Error("render_list: void elements cannot have content");
return `<${tag}${attrs}>`;
}
return `<${tag}${attrs}>${inner}</${tag}>`;
};
return items.map(item => render(item, rootTag, 0)).join("");
}
function escapeHtml(s) {