@plasius/learning-runtime 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +169 -2
- package/dist/chunk-2YWUDCGJ.js +189 -0
- package/dist/chunk-2YWUDCGJ.js.map +1 -0
- package/dist/chunk-XDTWUCFP.js +213 -0
- package/dist/chunk-XDTWUCFP.js.map +1 -0
- package/dist/cpp.cjs +563 -0
- package/dist/cpp.cjs.map +1 -0
- package/dist/cpp.d.cts +33 -0
- package/dist/cpp.d.ts +33 -0
- package/dist/cpp.js +535 -0
- package/dist/cpp.js.map +1 -0
- package/dist/index.cjs +244 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/javascript.cjs +226 -0
- package/dist/javascript.cjs.map +1 -0
- package/dist/javascript.d.cts +45 -0
- package/dist/javascript.d.ts +45 -0
- package/dist/javascript.js +13 -0
- package/dist/javascript.js.map +1 -0
- package/dist/javascript.worker.cjs +252 -0
- package/dist/javascript.worker.cjs.map +1 -0
- package/dist/javascript.worker.d.cts +2 -0
- package/dist/javascript.worker.d.ts +2 -0
- package/dist/javascript.worker.js +50 -0
- package/dist/javascript.worker.js.map +1 -0
- package/dist/maze.cjs +242 -0
- package/dist/maze.cjs.map +1 -0
- package/dist/maze.d.cts +85 -0
- package/dist/maze.d.ts +85 -0
- package/dist/maze.js +17 -0
- package/dist/maze.js.map +1 -0
- package/dist/server.cjs +232 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +25 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.js +149 -0
- package/dist/server.js.map +1 -0
- package/dist/web.cjs +600 -0
- package/dist/web.cjs.map +1 -0
- package/dist/web.d.cts +80 -0
- package/dist/web.d.ts +80 -0
- package/dist/web.js +513 -0
- package/dist/web.js.map +1 -0
- package/package.json +115 -4
package/dist/web.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web.ts","../src/javascript.ts","../src/web-html.ts","../src/web-model.ts","../src/web-css.ts"],"sourcesContent":["import { serializeProjectJson, type ProjectJsonValue } from \"./javascript.js\";\nimport { parseWebHtml } from \"./web-html.js\";\nimport { parseWebCss } from \"./web-css.js\";\nimport { WEB_PROJECT_LIMITS, WebProjectError, webLimitError, webSourceError, webViewError,\n type WebProject, type WebProjectOptions, type WebProjection, type WebRenderNode, type WebTemplateElement, type WebTemplateNode } from \"./web-model.js\";\nexport { WEB_PROJECT_LIMITS, WebProjectError } from \"./web-model.js\";\nexport type { WebProject, WebProjectOptions, WebProjection, WebRenderNode, WebRenderElement, WebTemplateNode, WebTemplateElement, WebField } from \"./web-model.js\";\n\nfunction ownPath(value: ProjectJsonValue, path: string): ProjectJsonValue {\n let current = value;\n for (const key of path.split(\".\")) {\n if (current === null || typeof current !== \"object\" || Array.isArray(current) || !Object.hasOwn(current, key)) return webViewError();\n current = current[key]!;\n }\n return current;\n}\nconst scalarText = (value: ProjectJsonValue): string => typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" ? String(value) : webViewError();\nconst bool = (value: ProjectJsonValue): boolean => typeof value === \"boolean\" ? value : webViewError();\n\n/**\n * Compile a documented HTML/CSS subset with no DOM, network or execution effects.\n * Call inside a disposable host worker; render only its inert representation with\n * the sandbox/CSP boundary in ADR 0004. JavaScript execution remains separate.\n */\nexport function createWebProject(source: { html: string; css: string }, options: WebProjectOptions = {}): WebProject {\n let snapshot: { html: string; css: string };\n try { snapshot = JSON.parse(serializeProjectJson(source)) as typeof snapshot; } catch { return webSourceError(); }\n if (!snapshot || typeof snapshot !== \"object\" || Array.isArray(snapshot) || Object.keys(snapshot).length !== 2\n || typeof snapshot.html !== \"string\" || typeof snapshot.css !== \"string\" || (snapshot.html + snapshot.css).includes(\"\\0\")) return webSourceError();\n if (snapshot.html.length > WEB_PROJECT_LIMITS.htmlCharacters || snapshot.css.length > WEB_PROJECT_LIMITS.cssCharacters) return webLimitError();\n if (!options || typeof options !== \"object\" || Array.isArray(options)\n || (Object.getPrototypeOf(options) !== Object.prototype && Object.getPrototypeOf(options) !== null)\n || Object.getOwnPropertySymbols(options).length) return webSourceError();\n const descriptors = Object.getOwnPropertyDescriptors(options);\n if (Object.entries(descriptors).some(([key, descriptor]) => key !== \"signal\" || descriptor.get || descriptor.set || !descriptor.enumerable)) return webSourceError();\n const signal: AbortSignal | undefined = descriptors.signal?.value;\n if (signal !== undefined && !(signal instanceof AbortSignal)) return webSourceError();\n let closed = signal?.aborted === true;\n const checkOpen = () => { if (closed || signal?.aborted) throw new WebProjectError(\"CLOSED\"); };\n let template: WebTemplateNode[] = [];\n let css = \"\";\n const dispose = () => { closed = true; template = []; css = \"\"; signal?.removeEventListener(\"abort\", dispose); };\n try {\n checkOpen();\n template = parseWebHtml(snapshot.html, checkOpen);\n css = parseWebCss(snapshot.css, checkOpen);\n } catch (error) { dispose(); if (error instanceof WebProjectError) throw error; return webSourceError(); }\n signal?.addEventListener(\"abort\", dispose, { once: true });\n return {\n get closed() { return closed; },\n get template() { checkOpen(); return structuredClone(template); },\n dispose,\n render(value: unknown): WebProjection {\n checkOpen();\n try {\n const view = JSON.parse(serializeProjectJson(value)) as ProjectJsonValue;\n if (view === null || typeof view !== \"object\" || Array.isArray(view)) return webViewError();\n let nodes = 0;\n function project(node: WebTemplateNode, context: ProjectJsonValue, skipRepeat = false): WebRenderNode[] {\n checkOpen();\n if (++nodes > WEB_PROJECT_LIMITS.projectedNodes) return webLimitError();\n if (node.kind === \"text\") return [{ ...node }];\n if (node.repeat && !skipRepeat) {\n const items = ownPath(context, node.repeat);\n if (!Array.isArray(items)) return webViewError();\n if (items.length > WEB_PROJECT_LIMITS.repeatedItems) return webLimitError();\n const ids = new Set<string>();\n return items.flatMap(item => {\n const id = ownPath(item, \"id\");\n if (typeof id !== \"string\" || !id.trim() || id.length > 128 || ids.has(id)) return webViewError();\n ids.add(id);\n return project(node, item, true);\n });\n }\n if (node.bindings.if && !bool(ownPath(context, node.bindings.if))) return [];\n const attributes = { ...node.attributes };\n for (const [binding, path] of Object.entries(node.bindings)) {\n if ([\"text\", \"if\"].includes(binding)) continue;\n const data = ownPath(context, path);\n if (binding === \"disabled\" || binding === \"checked\") {\n if (bool(data)) attributes[binding] = \"\";\n else delete attributes[binding];\n } else if (binding === \"pressed\" || binding === \"invalid\") attributes[`aria-${binding}`] = String(bool(data));\n else if (binding === \"label\") {\n const label = scalarText(data);\n if (!label.trim() || label.length > WEB_PROJECT_LIMITS.attributeCharacters) return webViewError();\n attributes[\"aria-label\"] = label;\n } else {\n const value = scalarText(data);\n if (value.length > 2000) return webLimitError();\n attributes.value = value;\n }\n }\n if (node.bindings.text && ++nodes > WEB_PROJECT_LIMITS.projectedNodes) return webLimitError();\n const children: WebRenderNode[] = node.bindings.text ? [{ kind: \"text\", text: scalarText(ownPath(context, node.bindings.text)) }]\n : node.children.flatMap(child => project(child, context));\n const action = actionFor(node, context);\n return [{ kind: \"element\", tag: node.tag, attributes, children,\n ...(action ? { action } : {}), ...(node.field ? { field: { ...node.field } } : {}) }];\n }\n const result = { nodes: template.flatMap(node => project(node, view)), css };\n if (JSON.stringify(result).length > WEB_PROJECT_LIMITS.outputCharacters) return webLimitError();\n return result;\n } catch (error) {\n // A bad view can be corrected on the next reducer result; keep this parsed\n // template usable. Cancellation alone permanently closes the project.\n if (error instanceof WebProjectError) throw error;\n return webViewError();\n }\n },\n };\n}\n\nfunction actionFor(node: WebTemplateElement, context: ProjectJsonValue): { type: string; id?: string } | undefined {\n if (!node.action) return undefined;\n if (!node.action.idPath) return { type: node.action.type };\n const id = ownPath(context, node.action.idPath);\n if (typeof id !== \"string\" || !id.trim() || id.length > 128) return webViewError();\n return { type: node.action.type, id };\n}\n","import type { QuickJSContext, QuickJSHandle, QuickJSRuntime } from \"quickjs-emscripten\";\n\nexport type ProjectJsonValue = null | boolean | number | string | ProjectJsonValue[] | { [key: string]: ProjectJsonValue };\nexport const JAVASCRIPT_PROJECT_LIMITS = Object.freeze({ sourceCharacters: 64000, jsonCharacters: 64000,\n memoryBytes: 16 * 1024 * 1024, stackBytes: 256 * 1024, executionMs: 100, maximumExecutionMs: 500,\n calls: 10000, arguments: 8, jsonDepth: 20, jsonNodes: 4096 });\nexport class JavaScriptProjectRuntimeError extends Error {\n constructor(readonly code: \"INVALID_INPUT\" | \"EXECUTION_FAILED\" | \"OUTPUT_LIMIT\" | \"CALL_LIMIT\" | \"CLOSED\") {\n super(`Learning project: ${code}`); this.name = \"JavaScriptProjectRuntimeError\";\n }\n}\nexport interface JavaScriptProjectSession {\n readonly closed: boolean;\n /** Invoke a declared learner function with detached, bounded JSON data. */\n call(entry: string, args: ProjectJsonValue[]): ProjectJsonValue;\n /** Idempotent. Hosts must dispose on navigation, worker shutdown or cancellation. */\n dispose(): void;\n}\nexport interface JavaScriptProjectSessionOptions {\n executionMs?: number;\n maximumCalls?: number;\n signal?: AbortSignal;\n /** Same source, inputs and seed reproduce the same pseudo-random sequence. */\n seed?: number;\n}\nconst invalid = (): never => { throw new JavaScriptProjectRuntimeError(\"INVALID_INPUT\"); };\n\n/** Reject accessors, cycles and non-JSON values before host serialization. */\nexport function serializeProjectJson(value: unknown): string {\n const seen = new Set<object>();\n let nodes = 0;\n function visit(value: unknown, depth: number): void {\n if (++nodes > JAVASCRIPT_PROJECT_LIMITS.jsonNodes || depth > JAVASCRIPT_PROJECT_LIMITS.jsonDepth) return invalid();\n if (value === null || typeof value === \"boolean\") return;\n if (typeof value === \"string\") { if (value.length > JAVASCRIPT_PROJECT_LIMITS.jsonCharacters) return invalid(); return; }\n if (typeof value === \"number\") { if (!Number.isFinite(value)) return invalid(); return; }\n if (typeof value !== \"object\" || seen.has(value)) return invalid();\n const array = Array.isArray(value);\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== (array ? Array.prototype : Object.prototype) && prototype !== null) return invalid();\n seen.add(value);\n const descriptors = Object.getOwnPropertyDescriptors(value);\n const keys = Object.keys(descriptors);\n if (Object.getOwnPropertySymbols(value).length || keys.length > JAVASCRIPT_PROJECT_LIMITS.jsonNodes) return invalid();\n if (array && (value.length > JAVASCRIPT_PROJECT_LIMITS.jsonNodes || keys.length !== value.length + 1)) return invalid();\n for (const key of keys) {\n if (array && key === \"length\") continue;\n const descriptor = descriptors[key]!;\n if (key.length > 160 || descriptor.get || descriptor.set || !descriptor.enumerable) return invalid();\n if (array && !/^(0|[1-9][0-9]*)$/u.test(key)) return invalid();\n visit(descriptor.value, depth + 1);\n }\n seen.delete(value);\n }\n visit(value, 0);\n const json = JSON.stringify(value);\n if (json.length > JAVASCRIPT_PROJECT_LIMITS.jsonCharacters) return invalid();\n return json;\n}\n\n/**\n * Create a capability-free QuickJS session. Run this inside a disposable browser\n * worker on both browser and server, never on the browser UI or server event loop.\n * Each call gets a fresh cooperative deadline; the host must enforce its hard\n * deadline by terminating the worker. Runtime failures permanently close sessions.\n */\nexport async function createJavaScriptProjectSession(source: string, options: JavaScriptProjectSessionOptions = {}): Promise<JavaScriptProjectSession> {\n const executionMs = options.executionMs ?? JAVASCRIPT_PROJECT_LIMITS.executionMs;\n const maximumCalls = options.maximumCalls ?? JAVASCRIPT_PROJECT_LIMITS.calls;\n const seed = options.seed ?? 1;\n if (typeof source !== \"string\" || source.length > JAVASCRIPT_PROJECT_LIMITS.sourceCharacters\n || !Number.isInteger(executionMs) || executionMs < 1 || executionMs > JAVASCRIPT_PROJECT_LIMITS.maximumExecutionMs\n || !Number.isInteger(maximumCalls) || maximumCalls < 1 || maximumCalls > JAVASCRIPT_PROJECT_LIMITS.calls\n || !Number.isInteger(seed) || seed < 1 || seed > 0xffffffff) return invalid();\n options.signal?.throwIfAborted();\n const { getQuickJS } = await import(\"quickjs-emscripten\");\n const engine = await getQuickJS();\n options.signal?.throwIfAborted();\n let runtime: QuickJSRuntime | undefined;\n let context: QuickJSContext | undefined;\n const retained: QuickJSHandle[] = [];\n let closed = false;\n let deadline = Date.now() + executionMs;\n let calls = 0;\n const dispose = () => {\n if (closed) return;\n closed = true;\n options.signal?.removeEventListener(\"abort\", dispose);\n for (const handle of retained.reverse()) if (handle.alive) handle.dispose();\n if (context?.alive) context.dispose();\n if (runtime?.alive) runtime.dispose();\n };\n try {\n runtime = engine.newRuntime();\n runtime.setMemoryLimit(JAVASCRIPT_PROJECT_LIMITS.memoryBytes);\n runtime.setMaxStackSize(JAVASCRIPT_PROJECT_LIMITS.stackBytes);\n runtime.setInterruptHandler(() => Date.now() >= deadline || options.signal?.aborted === true);\n context = runtime.newContext();\n const vm = context;\n const take = (result: ReturnType<QuickJSContext[\"evalCode\"]>, handles: QuickJSHandle[]): QuickJSHandle => {\n if (result.error) { result.error.dispose(); throw new JavaScriptProjectRuntimeError(\"EXECUTION_FAILED\"); }\n handles.push(result.value); return result.value;\n };\n // Captured before learner code; later replacement of global JSON/Number cannot\n // forge the transport. No handle or host callback is exposed in the realm.\n const transport = take(vm.evalCode(`((parse, stringify, finite) => ({\n parse,\n serialize: value => stringify(value, (_key, item) => {\n const kind = typeof item;\n if (kind === 'undefined' || kind === 'function' || kind === 'symbol' || kind === 'bigint'\n || (kind === 'number' && !finite(item))) throw new Error('not-json');\n return item;\n })\n }))(JSON.parse, JSON.stringify, Number.isFinite)`), retained);\n const parse = vm.getProp(transport, \"parse\"); retained.push(parse);\n const serialize = vm.getProp(transport, \"serialize\"); retained.push(serialize);\n const deterministic = vm.evalCode(`(() => {\n let state = ${seed};\n Object.defineProperty(Math, 'random', { value: () => {\n state ^= state << 13; state ^= state >>> 17; state ^= state << 5;\n return (state >>> 0) / 4294967296;\n }, writable: false, configurable: false });\n for (const name of ['Date', 'Intl']) Object.defineProperty(globalThis, name, {\n value: undefined, writable: false, configurable: false\n });\n })()`);\n if (deterministic.error) { deterministic.error.dispose(); throw new JavaScriptProjectRuntimeError(\"EXECUTION_FAILED\"); }\n deterministic.value.dispose();\n const initialization = vm.evalCode(source, \"project.js\", { type: \"global\", strict: true });\n if (initialization.error) { initialization.error.dispose(); throw new JavaScriptProjectRuntimeError(\"EXECUTION_FAILED\"); }\n initialization.value.dispose();\n options.signal?.addEventListener(\"abort\", dispose, { once: true });\n return {\n get closed() { return closed; },\n dispose,\n call(entry, args) {\n if (closed) throw new JavaScriptProjectRuntimeError(\"CLOSED\");\n if (typeof entry !== \"string\" || !/^[A-Za-z][A-Za-z0-9_]{0,63}$/u.test(entry)\n || !Array.isArray(args) || args.length > JAVASCRIPT_PROJECT_LIMITS.arguments) return invalid();\n const json = serializeProjectJson(args);\n if (++calls > maximumCalls) { dispose(); throw new JavaScriptProjectRuntimeError(\"CALL_LIMIT\"); }\n deadline = Date.now() + executionMs;\n const handles: QuickJSHandle[] = [];\n let failed = false;\n try {\n const encoded = vm.newString(json); handles.push(encoded);\n const parsed = take(vm.callFunction(parse, vm.undefined, encoded), handles);\n const parameters = args.map((_, index) => { const handle = vm.getProp(parsed, index); handles.push(handle); return handle; });\n const fn = take(vm.evalCode(entry, \"entry.js\", { type: \"global\", strict: true }), handles);\n const result = take(vm.callFunction(fn, vm.undefined, parameters), handles);\n const serialized = take(vm.callFunction(serialize, vm.undefined, result), handles);\n const output = vm.getString(serialized);\n if (output.length > JAVASCRIPT_PROJECT_LIMITS.jsonCharacters) throw new JavaScriptProjectRuntimeError(\"OUTPUT_LIMIT\");\n const value: unknown = JSON.parse(output);\n serializeProjectJson(value);\n return value as ProjectJsonValue;\n } catch (error) {\n failed = true;\n throw error instanceof JavaScriptProjectRuntimeError ? error : new JavaScriptProjectRuntimeError(\"EXECUTION_FAILED\");\n } finally {\n for (const handle of handles.reverse()) if (handle.alive) handle.dispose();\n if (failed) dispose();\n }\n },\n };\n } catch {\n dispose();\n throw new JavaScriptProjectRuntimeError(\"EXECUTION_FAILED\");\n }\n}\n","import { Parser, type DefaultTreeAdapterMap } from \"parse5\";\nimport { WEB_BINDINGS, WEB_CONTROLS, WEB_INPUT_TYPES, WEB_PROJECT_LIMITS, WEB_TAGS, WEB_VOID_TAGS,\n webIdentifier, webLimitError, webPath, webSourceError, type WebBinding, type WebField, type WebTemplateNode } from \"./web-model.js\";\n\nconst globalText = new Set([\"title\", \"aria-label\", \"aria-description\"]);\nconst references = new Set([\"for\", \"aria-labelledby\", \"aria-describedby\", \"aria-controls\"]);\nconst booleanAttributes = new Set([\"hidden\", \"disabled\", \"checked\", \"required\", \"readonly\", \"selected\", \"open\", \"novalidate\"]);\nconst numericAttributes = new Set([\"min\", \"max\", \"step\", \"value\", \"maxlength\", \"rows\", \"cols\", \"colspan\", \"rowspan\"]);\nconst roles = new Set([\"status\", \"alert\", \"group\", \"region\", \"list\", \"listitem\", \"note\", \"progressbar\", \"presentation\", \"none\"]);\n\nfunction attributes(tag: string, values: { name: string; value: string; namespace?: string }[]) {\n if (values.length > WEB_PROJECT_LIMITS.attributes) return webLimitError();\n const output: Record<string, string> = {};\n for (const { name, value, namespace } of values) {\n if (namespace || Object.hasOwn(output, name) || value.length > WEB_PROJECT_LIMITS.attributeCharacters\n || [...value].some(character => character.charCodeAt(0) < 32 && ![9, 10, 13].includes(character.charCodeAt(0)))) return webSourceError();\n if (name.startsWith(\"data-\")) {\n const key = name.slice(5);\n if (key === \"action\") {\n if (!webIdentifier(value) || (tag !== \"button\" && tag !== \"form\")) return webSourceError();\n } else if (key === \"repeat\" || key === \"id\" || WEB_BINDINGS.has(key)) {\n if (!webPath(value)) return webSourceError();\n if (key === \"checked\" && tag !== \"input\") return webSourceError();\n if (key === \"disabled\" && !WEB_CONTROLS.has(tag)) return webSourceError();\n if (key === \"invalid\" && ![\"input\", \"textarea\", \"select\"].includes(tag)) return webSourceError();\n if (key === \"pressed\" && tag !== \"button\") return webSourceError();\n if (key === \"value\" && ![\"input\", \"textarea\", \"select\", \"progress\", \"meter\", \"output\"].includes(tag)) return webSourceError();\n if ((key === \"text\" || key === \"repeat\") && WEB_VOID_TAGS.has(tag)) return webSourceError();\n } else return webSourceError();\n } else if (name === \"id\" || name === \"name\") {\n if (!webIdentifier(value) || (name === \"name\" && ![\"input\", \"textarea\", \"select\"].includes(tag))) return webSourceError();\n } else if (name === \"class\") {\n const names = value.trim().split(/\\s+/u);\n if (names.length > 16 || !names.every(webIdentifier)) return webSourceError();\n } else if (globalText.has(name)) {\n if (!value.trim()) return webSourceError();\n } else if (references.has(name)) {\n if (!value.split(/\\s+/u).every(webIdentifier) || (name === \"for\" && tag !== \"label\")) return webSourceError();\n } else if (booleanAttributes.has(name)) {\n if (value !== \"\" && value !== name) return webSourceError();\n if ([\"disabled\", \"required\", \"readonly\"].includes(name) && !WEB_CONTROLS.has(tag)) return webSourceError();\n if (name === \"checked\" && tag !== \"input\") return webSourceError();\n if (name === \"selected\" && tag !== \"option\") return webSourceError();\n if (name === \"open\" && tag !== \"details\") return webSourceError();\n if (name === \"novalidate\" && tag !== \"form\") return webSourceError();\n } else if (name === \"type\") {\n if (tag === \"input\" ? !WEB_INPUT_TYPES.has(value) : tag !== \"button\" || ![\"button\", \"submit\"].includes(value)) return webSourceError();\n } else if (name === \"value\" && [\"input\", \"option\"].includes(tag)) {\n // Text/option values are inert form data; range constraints are assessed separately.\n } else if (numericAttributes.has(name)) {\n if (!/^-?(?:0|[1-9]\\d{0,3})(?:\\.\\d{1,3})?$/u.test(value) || Math.abs(Number(value)) > 1000) return webSourceError();\n } else if (name === \"placeholder\" && [\"input\", \"textarea\"].includes(tag)) {\n if (value.length > 160) return webSourceError();\n } else if (name === \"role\") {\n if (!roles.has(value)) return webSourceError();\n } else if (name === \"aria-live\") {\n if (![\"polite\", \"assertive\", \"off\"].includes(value)) return webSourceError();\n } else if ([\"aria-atomic\", \"aria-pressed\", \"aria-expanded\", \"aria-hidden\", \"aria-required\", \"aria-invalid\"].includes(name)) {\n if (![\"true\", \"false\"].includes(value)) return webSourceError();\n } else if (name === \"tabindex\") {\n if (value !== \"0\" && value !== \"-1\") return webSourceError();\n } else if (name === \"scope\" && tag === \"th\") {\n if (![\"row\", \"col\", \"rowgroup\", \"colgroup\"].includes(value)) return webSourceError();\n } else return webSourceError();\n output[name] = value;\n }\n if (output[\"data-id\"] && !output[\"data-action\"]) return webSourceError();\n if ((output.checked !== undefined || output[\"data-checked\"]) && output.type !== \"checkbox\") return webSourceError();\n if (tag === \"button\" && output[\"data-action\"] && output.type !== \"button\") return webSourceError();\n return output;\n}\n\n/** Parse with the HTML parser's own token stream, validating even tags it would discard. */\nexport function parseWebHtml(html: string, checkOpen: () => void): WebTemplateNode[] {\n const parser = Parser.getFragmentParser<DefaultTreeAdapterMap>(null, { scriptingEnabled: false, onParseError: webSourceError });\n const start = parser.onStartTag.bind(parser);\n const end = parser.onEndTag.bind(parser);\n let tokens = 0;\n parser.onStartTag = token => {\n checkOpen();\n if (++tokens > WEB_PROJECT_LIMITS.templateNodes) return webLimitError();\n if (!WEB_TAGS.has(token.tagName)) return webSourceError();\n attributes(token.tagName, token.attrs);\n start(token);\n };\n parser.onEndTag = token => {\n checkOpen();\n if (!WEB_TAGS.has(token.tagName)) return webSourceError();\n end(token);\n };\n parser.onDoctype = webSourceError;\n parser.tokenizer.write(html, true);\n const ids = new Set<string>();\n let count = 0;\n function convert(node: DefaultTreeAdapterMap[\"childNode\"], depth: number, repeating: boolean): WebTemplateNode[] {\n checkOpen();\n if (++count > WEB_PROJECT_LIMITS.templateNodes || depth > WEB_PROJECT_LIMITS.templateDepth) return webLimitError();\n if (node.nodeName === \"#comment\") return [];\n if (\"value\" in node) return [{ kind: \"text\", text: node.value }];\n if (!(\"tagName\" in node) || node.namespaceURI !== \"http://www.w3.org/1999/xhtml\" || !WEB_TAGS.has(node.tagName)) return webSourceError();\n const attrs = attributes(node.tagName, node.attrs);\n const repeat = attrs[\"data-repeat\"];\n if (attrs.id) {\n if (repeating || repeat || ids.has(attrs.id)) return webSourceError();\n ids.add(attrs.id);\n }\n const bindings: Partial<Record<WebBinding, string>> = {};\n for (const binding of WEB_BINDINGS) if (attrs[`data-${binding}`]) bindings[binding as WebBinding] = attrs[`data-${binding}`];\n const action = attrs[\"data-action\"] ? { type: attrs[\"data-action\"], ...(attrs[\"data-id\"] ? { idPath: attrs[\"data-id\"] } : {}) } : undefined;\n const field = attrs.name ? { name: attrs.name, type: (node.tagName === \"input\" ? attrs.type ?? \"text\" : node.tagName) as WebField[\"type\"] } : undefined;\n const safeAttributes = Object.fromEntries(Object.entries(attrs).filter(([name]) => !name.startsWith(\"data-\")));\n return [{ kind: \"element\", tag: node.tagName, attributes: safeAttributes, bindings,\n children: node.childNodes.flatMap(child => convert(child, depth + 1, repeating || !!repeat)),\n ...(repeat ? { repeat } : {}), ...(action ? { action } : {}), ...(field ? { field } : {}) }];\n }\n return parser.getFragment().childNodes.flatMap(node => convert(node, 1, false));\n}\n","export const WEB_PROJECT_LIMITS = Object.freeze({ htmlCharacters: 24000, cssCharacters: 16000,\n templateNodes: 256, templateDepth: 20, attributes: 16, attributeCharacters: 240,\n cssNodes: 2048, cssDepth: 16, repeatedItems: 50, projectedNodes: 768, outputCharacters: 64000 });\n\nexport class WebProjectError extends Error {\n constructor(readonly code: \"INVALID_SOURCE\" | \"INVALID_VIEW\" | \"LIMIT_EXCEEDED\" | \"CLOSED\") {\n super(`Web project: ${code}`); this.name = \"WebProjectError\";\n }\n}\n\nexport const WEB_TAGS = new Set([\"main\", \"section\", \"article\", \"aside\", \"header\", \"footer\", \"nav\", \"div\", \"span\", \"p\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"strong\", \"em\", \"small\", \"code\", \"pre\", \"blockquote\", \"ul\", \"ol\", \"li\",\n \"dl\", \"dt\", \"dd\", \"table\", \"caption\", \"thead\", \"tbody\", \"tfoot\", \"tr\", \"th\", \"td\", \"form\", \"fieldset\", \"legend\",\n \"label\", \"input\", \"textarea\", \"select\", \"option\", \"button\", \"output\", \"progress\", \"meter\", \"br\", \"hr\", \"details\", \"summary\"]);\nexport const WEB_VOID_TAGS = new Set([\"input\", \"br\", \"hr\"]);\nexport const WEB_CONTROLS = new Set([\"input\", \"textarea\", \"select\", \"button\"]);\nexport const WEB_INPUT_TYPES = new Set([\"text\", \"number\", \"range\", \"checkbox\"]);\nexport const WEB_BINDINGS = new Set([\"text\", \"value\", \"checked\", \"disabled\", \"pressed\", \"invalid\", \"label\", \"if\"]);\nexport type WebBinding = \"text\" | \"value\" | \"checked\" | \"disabled\" | \"pressed\" | \"invalid\" | \"label\" | \"if\";\n\nexport interface WebTextNode { kind: \"text\"; text: string }\nexport interface WebField { name: string; type: \"text\" | \"number\" | \"range\" | \"checkbox\" | \"textarea\" | \"select\" }\nexport interface WebTemplateElement {\n kind: \"element\";\n tag: string;\n attributes: Record<string, string>;\n children: WebTemplateNode[];\n bindings: Partial<Record<WebBinding, string>>;\n repeat?: string;\n action?: { type: string; idPath?: string };\n field?: WebField;\n}\nexport type WebTemplateNode = WebTextNode | WebTemplateElement;\nexport interface WebRenderElement {\n kind: \"element\";\n tag: string;\n attributes: Record<string, string>;\n children: WebRenderNode[];\n action?: { type: string; id?: string };\n field?: WebField;\n}\nexport type WebRenderNode = WebTextNode | WebRenderElement;\nexport interface WebProjection { nodes: WebRenderNode[]; css: string }\nexport interface WebProject {\n readonly closed: boolean;\n /** Detached parsed representation, for structural checks; never execute as HTML. */\n readonly template: WebTemplateNode[];\n /** Project bounded JSON view data into inert nodes and explicit action metadata. */\n render(view: unknown): WebProjection;\n dispose(): void;\n}\nexport interface WebProjectOptions { signal?: AbortSignal }\n\nconst forbiddenNames = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\nexport function webIdentifier(value: string): boolean {\n return /^[a-zA-Z][a-zA-Z0-9_-]{0,47}$/u.test(value) && !forbiddenNames.has(value);\n}\nexport function webPath(value: string): boolean {\n const parts = value.split(\".\");\n return value.length <= 128 && parts.length <= 4 && parts.every(part => /^[a-zA-Z][a-zA-Z0-9_]{0,31}$/u.test(part) && !forbiddenNames.has(part));\n}\nexport const webSourceError = (): never => { throw new WebProjectError(\"INVALID_SOURCE\"); };\nexport const webLimitError = (): never => { throw new WebProjectError(\"LIMIT_EXCEEDED\"); };\nexport const webViewError = (): never => { throw new WebProjectError(\"INVALID_VIEW\"); };\n","import { generate, lexer, parse, walk, type CssNode, type Declaration } from \"css-tree\";\nimport { WEB_PROJECT_LIMITS, webLimitError, webSourceError } from \"./web-model.js\";\n\nconst properties = new Set([\"display\", \"gap\", \"row-gap\", \"column-gap\", \"grid-template-columns\", \"grid-template-rows\",\n \"grid-column\", \"grid-row\", \"align-items\", \"align-content\", \"justify-items\", \"justify-content\", \"flex\", \"flex-direction\",\n \"flex-wrap\", \"flex-grow\", \"flex-shrink\", \"flex-basis\", \"order\", \"width\", \"min-width\", \"max-width\", \"height\", \"min-height\", \"max-height\",\n \"margin\", \"margin-top\", \"margin-right\", \"margin-bottom\", \"margin-left\", \"margin-inline\", \"margin-block\",\n \"padding\", \"padding-top\", \"padding-right\", \"padding-bottom\", \"padding-left\", \"padding-inline\", \"padding-block\",\n \"box-sizing\", \"border\", \"border-width\", \"border-style\", \"border-color\", \"border-radius\", \"border-collapse\", \"border-spacing\",\n \"color\", \"background-color\", \"font-family\", \"font-size\", \"font-weight\", \"font-style\", \"line-height\", \"letter-spacing\",\n \"text-align\", \"text-decoration\", \"text-transform\", \"white-space\", \"overflow-wrap\", \"word-break\", \"vertical-align\",\n \"list-style-type\", \"outline\", \"outline-width\", \"outline-style\", \"outline-color\", \"outline-offset\", \"opacity\", \"visibility\",\n \"overflow\", \"overflow-x\", \"overflow-y\", \"cursor\", \"transition-property\", \"transition-duration\", \"transition-timing-function\"]);\nconst functions = new Set([\"rgb\", \"rgba\", \"hsl\", \"hsla\", \"var\", \"min\", \"max\", \"clamp\", \"calc\", \"repeat\", \"minmax\", \"fit-content\", \"steps\", \"cubic-bezier\"]);\nconst pseudoClasses = new Set([\"root\", \"hover\", \"focus\", \"focus-visible\", \"focus-within\", \"active\", \"checked\", \"disabled\", \"enabled\",\n \"first-child\", \"last-child\", \"nth-child\", \"nth-of-type\", \"empty\", \"not\"]);\nconst units = new Set([\"px\", \"em\", \"rem\", \"ch\", \"fr\", \"s\", \"ms\", \"deg\"]);\n\n/** Validate a bounded stylesheet without evaluating it or loading resources. */\nexport function parseWebCss(css: string, checkOpen: () => void): string {\n checkOpen();\n const ast = parse(css, { positions: false, parseCustomProperty: true, onParseError: webSourceError });\n let nodes = 0;\n let depth = 0;\n const declarations: Declaration[] = [];\n walk(ast, {\n enter(node: CssNode) {\n checkOpen();\n if (++nodes > WEB_PROJECT_LIMITS.cssNodes || ++depth > WEB_PROJECT_LIMITS.cssDepth) return webLimitError();\n if ([\"Raw\", \"Url\"].includes(node.type)) return webSourceError();\n if (node.type === \"Atrule\") {\n if (node.name !== \"media\" || !node.prelude || !node.block) return webSourceError();\n const query = generate(node.prelude).replace(/\\s+/gu, \"\");\n if (!/^\\((?:min-width|max-width):\\d{1,4}(?:px|rem)\\)$/u.test(query)\n && !/^\\(prefers-reduced-motion:(?:reduce|no-preference)\\)$/u.test(query)\n && !/^\\(prefers-color-scheme:(?:light|dark)\\)$/u.test(query)) return webSourceError();\n }\n if (node.type === \"Declaration\") {\n if (node.important) return webSourceError();\n const custom = /^--[a-z][a-z0-9-]{0,31}$/u.test(node.property);\n if (!custom && !properties.has(node.property)) return webSourceError();\n if (!custom) declarations.push(node);\n }\n if (node.type === \"Function\" && !functions.has(node.name)) return webSourceError();\n if (node.type === \"PseudoClassSelector\" && !pseudoClasses.has(node.name)) return webSourceError();\n if (node.type === \"PseudoElementSelector\") return webSourceError();\n if (node.type === \"AttributeSelector\") {\n const name = node.name.name;\n const value = node.value?.type === \"String\" ? node.value.value : node.value?.name;\n if (node.matcher !== \"=\" || node.flags || typeof value !== \"string\"\n || (![\"aria-pressed\", \"aria-expanded\", \"aria-invalid\", \"aria-required\"].includes(name) && name !== \"type\")\n || !(name === \"type\" ? [\"text\", \"number\", \"range\", \"checkbox\", \"button\", \"submit\"].includes(value) : [\"true\", \"false\"].includes(value))) return webSourceError();\n }\n if (node.type === \"Dimension\" || node.type === \"Number\" || node.type === \"Percentage\") {\n const value = Number(node.value);\n if (!Number.isFinite(value) || Math.abs(value) > 4096) return webSourceError();\n if (node.type === \"Dimension\" && (!units.has(node.unit)\n || (node.unit === \"s\" && (value < 0 || value > 2)) || (node.unit === \"ms\" && (value < 0 || value > 2000)))) return webSourceError();\n }\n if (node.type === \"Function\" && node.name === \"repeat\") {\n const first = node.children.first;\n if (!first || (first.type === \"Number\" ? !Number.isInteger(Number(first.value)) || Number(first.value) < 1 || Number(first.value) > 12\n : first.type !== \"Identifier\" || ![\"auto-fit\", \"auto-fill\"].includes(first.name))) return webSourceError();\n }\n },\n leave() { depth -= 1; },\n });\n // Validate property grammars only after bounding the complete syntax tree.\n for (const declaration of declarations) {\n checkOpen();\n let variable = false;\n walk(declaration.value, candidate => { if (candidate.type === \"Function\" && candidate.name === \"var\") variable = true; });\n if (!variable && !lexer.matchProperty(declaration.property, declaration.value).matched) return webSourceError();\n }\n checkOpen();\n const result = generate(ast);\n if (result.length > WEB_PROJECT_LIMITS.cssCharacters) return webLimitError();\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,4BAA4B,OAAO,OAAO;AAAA,EAAE,kBAAkB;AAAA,EAAO,gBAAgB;AAAA,EAChG,aAAa,KAAK,OAAO;AAAA,EAAM,YAAY,MAAM;AAAA,EAAM,aAAa;AAAA,EAAK,oBAAoB;AAAA,EAC7F,OAAO;AAAA,EAAO,WAAW;AAAA,EAAG,WAAW;AAAA,EAAI,WAAW;AAAK,CAAC;AACvD,IAAM,gCAAN,cAA4C,MAAM;AAAA,EACvD,YAAqB,MAAuF;AAC1G,UAAM,qBAAqB,IAAI,EAAE;AADd;AACiB,SAAK,OAAO;AAAA,EAClD;AAAA,EAFqB;AAGvB;AAeA,IAAM,UAAU,MAAa;AAAE,QAAM,IAAI,8BAA8B,eAAe;AAAG;AAGlF,SAAS,qBA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,QAAM,KAAK,QAAQ,SAAS,KAAK,OAAO,MAAM;AAC9C,MAAI,OAAO,OAAO,YAAY,CAAC,GAAG,KAAK,KAAK,GAAG,SAAS,IAAK,QAAO,aAAa;AACjF,SAAO,EAAE,MAAM,KAAK,OAAO,MAAM,GAAG;AACtC;","names":["value","project","attributes","value"]}
|
package/dist/web.d.cts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
declare const WEB_PROJECT_LIMITS: Readonly<{
|
|
2
|
+
htmlCharacters: 24000;
|
|
3
|
+
cssCharacters: 16000;
|
|
4
|
+
templateNodes: 256;
|
|
5
|
+
templateDepth: 20;
|
|
6
|
+
attributes: 16;
|
|
7
|
+
attributeCharacters: 240;
|
|
8
|
+
cssNodes: 2048;
|
|
9
|
+
cssDepth: 16;
|
|
10
|
+
repeatedItems: 50;
|
|
11
|
+
projectedNodes: 768;
|
|
12
|
+
outputCharacters: 64000;
|
|
13
|
+
}>;
|
|
14
|
+
declare class WebProjectError extends Error {
|
|
15
|
+
readonly code: "INVALID_SOURCE" | "INVALID_VIEW" | "LIMIT_EXCEEDED" | "CLOSED";
|
|
16
|
+
constructor(code: "INVALID_SOURCE" | "INVALID_VIEW" | "LIMIT_EXCEEDED" | "CLOSED");
|
|
17
|
+
}
|
|
18
|
+
type WebBinding = "text" | "value" | "checked" | "disabled" | "pressed" | "invalid" | "label" | "if";
|
|
19
|
+
interface WebTextNode {
|
|
20
|
+
kind: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
interface WebField {
|
|
24
|
+
name: string;
|
|
25
|
+
type: "text" | "number" | "range" | "checkbox" | "textarea" | "select";
|
|
26
|
+
}
|
|
27
|
+
interface WebTemplateElement {
|
|
28
|
+
kind: "element";
|
|
29
|
+
tag: string;
|
|
30
|
+
attributes: Record<string, string>;
|
|
31
|
+
children: WebTemplateNode[];
|
|
32
|
+
bindings: Partial<Record<WebBinding, string>>;
|
|
33
|
+
repeat?: string;
|
|
34
|
+
action?: {
|
|
35
|
+
type: string;
|
|
36
|
+
idPath?: string;
|
|
37
|
+
};
|
|
38
|
+
field?: WebField;
|
|
39
|
+
}
|
|
40
|
+
type WebTemplateNode = WebTextNode | WebTemplateElement;
|
|
41
|
+
interface WebRenderElement {
|
|
42
|
+
kind: "element";
|
|
43
|
+
tag: string;
|
|
44
|
+
attributes: Record<string, string>;
|
|
45
|
+
children: WebRenderNode[];
|
|
46
|
+
action?: {
|
|
47
|
+
type: string;
|
|
48
|
+
id?: string;
|
|
49
|
+
};
|
|
50
|
+
field?: WebField;
|
|
51
|
+
}
|
|
52
|
+
type WebRenderNode = WebTextNode | WebRenderElement;
|
|
53
|
+
interface WebProjection {
|
|
54
|
+
nodes: WebRenderNode[];
|
|
55
|
+
css: string;
|
|
56
|
+
}
|
|
57
|
+
interface WebProject {
|
|
58
|
+
readonly closed: boolean;
|
|
59
|
+
/** Detached parsed representation, for structural checks; never execute as HTML. */
|
|
60
|
+
readonly template: WebTemplateNode[];
|
|
61
|
+
/** Project bounded JSON view data into inert nodes and explicit action metadata. */
|
|
62
|
+
render(view: unknown): WebProjection;
|
|
63
|
+
dispose(): void;
|
|
64
|
+
}
|
|
65
|
+
interface WebProjectOptions {
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Compile a documented HTML/CSS subset with no DOM, network or execution effects.
|
|
71
|
+
* Call inside a disposable host worker; render only its inert representation with
|
|
72
|
+
* the sandbox/CSP boundary in ADR 0004. JavaScript execution remains separate.
|
|
73
|
+
*/
|
|
74
|
+
declare function createWebProject(source: {
|
|
75
|
+
html: string;
|
|
76
|
+
css: string;
|
|
77
|
+
}, options?: WebProjectOptions): WebProject;
|
|
78
|
+
|
|
79
|
+
export { WEB_PROJECT_LIMITS, WebProjectError, createWebProject };
|
|
80
|
+
export type { WebField, WebProject, WebProjectOptions, WebProjection, WebRenderElement, WebRenderNode, WebTemplateElement, WebTemplateNode };
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
declare const WEB_PROJECT_LIMITS: Readonly<{
|
|
2
|
+
htmlCharacters: 24000;
|
|
3
|
+
cssCharacters: 16000;
|
|
4
|
+
templateNodes: 256;
|
|
5
|
+
templateDepth: 20;
|
|
6
|
+
attributes: 16;
|
|
7
|
+
attributeCharacters: 240;
|
|
8
|
+
cssNodes: 2048;
|
|
9
|
+
cssDepth: 16;
|
|
10
|
+
repeatedItems: 50;
|
|
11
|
+
projectedNodes: 768;
|
|
12
|
+
outputCharacters: 64000;
|
|
13
|
+
}>;
|
|
14
|
+
declare class WebProjectError extends Error {
|
|
15
|
+
readonly code: "INVALID_SOURCE" | "INVALID_VIEW" | "LIMIT_EXCEEDED" | "CLOSED";
|
|
16
|
+
constructor(code: "INVALID_SOURCE" | "INVALID_VIEW" | "LIMIT_EXCEEDED" | "CLOSED");
|
|
17
|
+
}
|
|
18
|
+
type WebBinding = "text" | "value" | "checked" | "disabled" | "pressed" | "invalid" | "label" | "if";
|
|
19
|
+
interface WebTextNode {
|
|
20
|
+
kind: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
interface WebField {
|
|
24
|
+
name: string;
|
|
25
|
+
type: "text" | "number" | "range" | "checkbox" | "textarea" | "select";
|
|
26
|
+
}
|
|
27
|
+
interface WebTemplateElement {
|
|
28
|
+
kind: "element";
|
|
29
|
+
tag: string;
|
|
30
|
+
attributes: Record<string, string>;
|
|
31
|
+
children: WebTemplateNode[];
|
|
32
|
+
bindings: Partial<Record<WebBinding, string>>;
|
|
33
|
+
repeat?: string;
|
|
34
|
+
action?: {
|
|
35
|
+
type: string;
|
|
36
|
+
idPath?: string;
|
|
37
|
+
};
|
|
38
|
+
field?: WebField;
|
|
39
|
+
}
|
|
40
|
+
type WebTemplateNode = WebTextNode | WebTemplateElement;
|
|
41
|
+
interface WebRenderElement {
|
|
42
|
+
kind: "element";
|
|
43
|
+
tag: string;
|
|
44
|
+
attributes: Record<string, string>;
|
|
45
|
+
children: WebRenderNode[];
|
|
46
|
+
action?: {
|
|
47
|
+
type: string;
|
|
48
|
+
id?: string;
|
|
49
|
+
};
|
|
50
|
+
field?: WebField;
|
|
51
|
+
}
|
|
52
|
+
type WebRenderNode = WebTextNode | WebRenderElement;
|
|
53
|
+
interface WebProjection {
|
|
54
|
+
nodes: WebRenderNode[];
|
|
55
|
+
css: string;
|
|
56
|
+
}
|
|
57
|
+
interface WebProject {
|
|
58
|
+
readonly closed: boolean;
|
|
59
|
+
/** Detached parsed representation, for structural checks; never execute as HTML. */
|
|
60
|
+
readonly template: WebTemplateNode[];
|
|
61
|
+
/** Project bounded JSON view data into inert nodes and explicit action metadata. */
|
|
62
|
+
render(view: unknown): WebProjection;
|
|
63
|
+
dispose(): void;
|
|
64
|
+
}
|
|
65
|
+
interface WebProjectOptions {
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Compile a documented HTML/CSS subset with no DOM, network or execution effects.
|
|
71
|
+
* Call inside a disposable host worker; render only its inert representation with
|
|
72
|
+
* the sandbox/CSP boundary in ADR 0004. JavaScript execution remains separate.
|
|
73
|
+
*/
|
|
74
|
+
declare function createWebProject(source: {
|
|
75
|
+
html: string;
|
|
76
|
+
css: string;
|
|
77
|
+
}, options?: WebProjectOptions): WebProject;
|
|
78
|
+
|
|
79
|
+
export { WEB_PROJECT_LIMITS, WebProjectError, createWebProject };
|
|
80
|
+
export type { WebField, WebProject, WebProjectOptions, WebProjection, WebRenderElement, WebRenderNode, WebTemplateElement, WebTemplateNode };
|