@plasius/learning-runtime 0.0.0-stage → 0.1.3
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 +170 -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.js
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import {
|
|
2
|
+
serializeProjectJson
|
|
3
|
+
} from "./chunk-2YWUDCGJ.js";
|
|
4
|
+
|
|
5
|
+
// src/web-html.ts
|
|
6
|
+
import { Parser } from "parse5";
|
|
7
|
+
|
|
8
|
+
// src/web-model.ts
|
|
9
|
+
var WEB_PROJECT_LIMITS = Object.freeze({
|
|
10
|
+
htmlCharacters: 24e3,
|
|
11
|
+
cssCharacters: 16e3,
|
|
12
|
+
templateNodes: 256,
|
|
13
|
+
templateDepth: 20,
|
|
14
|
+
attributes: 16,
|
|
15
|
+
attributeCharacters: 240,
|
|
16
|
+
cssNodes: 2048,
|
|
17
|
+
cssDepth: 16,
|
|
18
|
+
repeatedItems: 50,
|
|
19
|
+
projectedNodes: 768,
|
|
20
|
+
outputCharacters: 64e3
|
|
21
|
+
});
|
|
22
|
+
var WebProjectError = class extends Error {
|
|
23
|
+
constructor(code) {
|
|
24
|
+
super(`Web project: ${code}`);
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.name = "WebProjectError";
|
|
27
|
+
}
|
|
28
|
+
code;
|
|
29
|
+
};
|
|
30
|
+
var WEB_TAGS = /* @__PURE__ */ new Set([
|
|
31
|
+
"main",
|
|
32
|
+
"section",
|
|
33
|
+
"article",
|
|
34
|
+
"aside",
|
|
35
|
+
"header",
|
|
36
|
+
"footer",
|
|
37
|
+
"nav",
|
|
38
|
+
"div",
|
|
39
|
+
"span",
|
|
40
|
+
"p",
|
|
41
|
+
"h1",
|
|
42
|
+
"h2",
|
|
43
|
+
"h3",
|
|
44
|
+
"h4",
|
|
45
|
+
"h5",
|
|
46
|
+
"h6",
|
|
47
|
+
"strong",
|
|
48
|
+
"em",
|
|
49
|
+
"small",
|
|
50
|
+
"code",
|
|
51
|
+
"pre",
|
|
52
|
+
"blockquote",
|
|
53
|
+
"ul",
|
|
54
|
+
"ol",
|
|
55
|
+
"li",
|
|
56
|
+
"dl",
|
|
57
|
+
"dt",
|
|
58
|
+
"dd",
|
|
59
|
+
"table",
|
|
60
|
+
"caption",
|
|
61
|
+
"thead",
|
|
62
|
+
"tbody",
|
|
63
|
+
"tfoot",
|
|
64
|
+
"tr",
|
|
65
|
+
"th",
|
|
66
|
+
"td",
|
|
67
|
+
"form",
|
|
68
|
+
"fieldset",
|
|
69
|
+
"legend",
|
|
70
|
+
"label",
|
|
71
|
+
"input",
|
|
72
|
+
"textarea",
|
|
73
|
+
"select",
|
|
74
|
+
"option",
|
|
75
|
+
"button",
|
|
76
|
+
"output",
|
|
77
|
+
"progress",
|
|
78
|
+
"meter",
|
|
79
|
+
"br",
|
|
80
|
+
"hr",
|
|
81
|
+
"details",
|
|
82
|
+
"summary"
|
|
83
|
+
]);
|
|
84
|
+
var WEB_VOID_TAGS = /* @__PURE__ */ new Set(["input", "br", "hr"]);
|
|
85
|
+
var WEB_CONTROLS = /* @__PURE__ */ new Set(["input", "textarea", "select", "button"]);
|
|
86
|
+
var WEB_INPUT_TYPES = /* @__PURE__ */ new Set(["text", "number", "range", "checkbox"]);
|
|
87
|
+
var WEB_BINDINGS = /* @__PURE__ */ new Set(["text", "value", "checked", "disabled", "pressed", "invalid", "label", "if"]);
|
|
88
|
+
var forbiddenNames = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
89
|
+
function webIdentifier(value) {
|
|
90
|
+
return /^[a-zA-Z][a-zA-Z0-9_-]{0,47}$/u.test(value) && !forbiddenNames.has(value);
|
|
91
|
+
}
|
|
92
|
+
function webPath(value) {
|
|
93
|
+
const parts = value.split(".");
|
|
94
|
+
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));
|
|
95
|
+
}
|
|
96
|
+
var webSourceError = () => {
|
|
97
|
+
throw new WebProjectError("INVALID_SOURCE");
|
|
98
|
+
};
|
|
99
|
+
var webLimitError = () => {
|
|
100
|
+
throw new WebProjectError("LIMIT_EXCEEDED");
|
|
101
|
+
};
|
|
102
|
+
var webViewError = () => {
|
|
103
|
+
throw new WebProjectError("INVALID_VIEW");
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/web-html.ts
|
|
107
|
+
var globalText = /* @__PURE__ */ new Set(["title", "aria-label", "aria-description"]);
|
|
108
|
+
var references = /* @__PURE__ */ new Set(["for", "aria-labelledby", "aria-describedby", "aria-controls"]);
|
|
109
|
+
var booleanAttributes = /* @__PURE__ */ new Set(["hidden", "disabled", "checked", "required", "readonly", "selected", "open", "novalidate"]);
|
|
110
|
+
var numericAttributes = /* @__PURE__ */ new Set(["min", "max", "step", "value", "maxlength", "rows", "cols", "colspan", "rowspan"]);
|
|
111
|
+
var roles = /* @__PURE__ */ new Set(["status", "alert", "group", "region", "list", "listitem", "note", "progressbar", "presentation", "none"]);
|
|
112
|
+
function attributes(tag, values) {
|
|
113
|
+
if (values.length > WEB_PROJECT_LIMITS.attributes) return webLimitError();
|
|
114
|
+
const output = {};
|
|
115
|
+
for (const { name, value, namespace } of values) {
|
|
116
|
+
if (namespace || Object.hasOwn(output, name) || value.length > WEB_PROJECT_LIMITS.attributeCharacters || [...value].some((character) => character.charCodeAt(0) < 32 && ![9, 10, 13].includes(character.charCodeAt(0)))) return webSourceError();
|
|
117
|
+
if (name.startsWith("data-")) {
|
|
118
|
+
const key = name.slice(5);
|
|
119
|
+
if (key === "action") {
|
|
120
|
+
if (!webIdentifier(value) || tag !== "button" && tag !== "form") return webSourceError();
|
|
121
|
+
} else if (key === "repeat" || key === "id" || WEB_BINDINGS.has(key)) {
|
|
122
|
+
if (!webPath(value)) return webSourceError();
|
|
123
|
+
if (key === "checked" && tag !== "input") return webSourceError();
|
|
124
|
+
if (key === "disabled" && !WEB_CONTROLS.has(tag)) return webSourceError();
|
|
125
|
+
if (key === "invalid" && !["input", "textarea", "select"].includes(tag)) return webSourceError();
|
|
126
|
+
if (key === "pressed" && tag !== "button") return webSourceError();
|
|
127
|
+
if (key === "value" && !["input", "textarea", "select", "progress", "meter", "output"].includes(tag)) return webSourceError();
|
|
128
|
+
if ((key === "text" || key === "repeat") && WEB_VOID_TAGS.has(tag)) return webSourceError();
|
|
129
|
+
} else return webSourceError();
|
|
130
|
+
} else if (name === "id" || name === "name") {
|
|
131
|
+
if (!webIdentifier(value) || name === "name" && !["input", "textarea", "select"].includes(tag)) return webSourceError();
|
|
132
|
+
} else if (name === "class") {
|
|
133
|
+
const names = value.trim().split(/\s+/u);
|
|
134
|
+
if (names.length > 16 || !names.every(webIdentifier)) return webSourceError();
|
|
135
|
+
} else if (globalText.has(name)) {
|
|
136
|
+
if (!value.trim()) return webSourceError();
|
|
137
|
+
} else if (references.has(name)) {
|
|
138
|
+
if (!value.split(/\s+/u).every(webIdentifier) || name === "for" && tag !== "label") return webSourceError();
|
|
139
|
+
} else if (booleanAttributes.has(name)) {
|
|
140
|
+
if (value !== "" && value !== name) return webSourceError();
|
|
141
|
+
if (["disabled", "required", "readonly"].includes(name) && !WEB_CONTROLS.has(tag)) return webSourceError();
|
|
142
|
+
if (name === "checked" && tag !== "input") return webSourceError();
|
|
143
|
+
if (name === "selected" && tag !== "option") return webSourceError();
|
|
144
|
+
if (name === "open" && tag !== "details") return webSourceError();
|
|
145
|
+
if (name === "novalidate" && tag !== "form") return webSourceError();
|
|
146
|
+
} else if (name === "type") {
|
|
147
|
+
if (tag === "input" ? !WEB_INPUT_TYPES.has(value) : tag !== "button" || !["button", "submit"].includes(value)) return webSourceError();
|
|
148
|
+
} else if (name === "value" && ["input", "option"].includes(tag)) {
|
|
149
|
+
} else if (numericAttributes.has(name)) {
|
|
150
|
+
if (!/^-?(?:0|[1-9]\d{0,3})(?:\.\d{1,3})?$/u.test(value) || Math.abs(Number(value)) > 1e3) return webSourceError();
|
|
151
|
+
} else if (name === "placeholder" && ["input", "textarea"].includes(tag)) {
|
|
152
|
+
if (value.length > 160) return webSourceError();
|
|
153
|
+
} else if (name === "role") {
|
|
154
|
+
if (!roles.has(value)) return webSourceError();
|
|
155
|
+
} else if (name === "aria-live") {
|
|
156
|
+
if (!["polite", "assertive", "off"].includes(value)) return webSourceError();
|
|
157
|
+
} else if (["aria-atomic", "aria-pressed", "aria-expanded", "aria-hidden", "aria-required", "aria-invalid"].includes(name)) {
|
|
158
|
+
if (!["true", "false"].includes(value)) return webSourceError();
|
|
159
|
+
} else if (name === "tabindex") {
|
|
160
|
+
if (value !== "0" && value !== "-1") return webSourceError();
|
|
161
|
+
} else if (name === "scope" && tag === "th") {
|
|
162
|
+
if (!["row", "col", "rowgroup", "colgroup"].includes(value)) return webSourceError();
|
|
163
|
+
} else return webSourceError();
|
|
164
|
+
output[name] = value;
|
|
165
|
+
}
|
|
166
|
+
if (output["data-id"] && !output["data-action"]) return webSourceError();
|
|
167
|
+
if ((output.checked !== void 0 || output["data-checked"]) && output.type !== "checkbox") return webSourceError();
|
|
168
|
+
if (tag === "button" && output["data-action"] && output.type !== "button") return webSourceError();
|
|
169
|
+
return output;
|
|
170
|
+
}
|
|
171
|
+
function parseWebHtml(html, checkOpen) {
|
|
172
|
+
const parser = Parser.getFragmentParser(null, { scriptingEnabled: false, onParseError: webSourceError });
|
|
173
|
+
const start = parser.onStartTag.bind(parser);
|
|
174
|
+
const end = parser.onEndTag.bind(parser);
|
|
175
|
+
let tokens = 0;
|
|
176
|
+
parser.onStartTag = (token) => {
|
|
177
|
+
checkOpen();
|
|
178
|
+
if (++tokens > WEB_PROJECT_LIMITS.templateNodes) return webLimitError();
|
|
179
|
+
if (!WEB_TAGS.has(token.tagName)) return webSourceError();
|
|
180
|
+
attributes(token.tagName, token.attrs);
|
|
181
|
+
start(token);
|
|
182
|
+
};
|
|
183
|
+
parser.onEndTag = (token) => {
|
|
184
|
+
checkOpen();
|
|
185
|
+
if (!WEB_TAGS.has(token.tagName)) return webSourceError();
|
|
186
|
+
end(token);
|
|
187
|
+
};
|
|
188
|
+
parser.onDoctype = webSourceError;
|
|
189
|
+
parser.tokenizer.write(html, true);
|
|
190
|
+
const ids = /* @__PURE__ */ new Set();
|
|
191
|
+
let count = 0;
|
|
192
|
+
function convert(node, depth, repeating) {
|
|
193
|
+
checkOpen();
|
|
194
|
+
if (++count > WEB_PROJECT_LIMITS.templateNodes || depth > WEB_PROJECT_LIMITS.templateDepth) return webLimitError();
|
|
195
|
+
if (node.nodeName === "#comment") return [];
|
|
196
|
+
if ("value" in node) return [{ kind: "text", text: node.value }];
|
|
197
|
+
if (!("tagName" in node) || node.namespaceURI !== "http://www.w3.org/1999/xhtml" || !WEB_TAGS.has(node.tagName)) return webSourceError();
|
|
198
|
+
const attrs = attributes(node.tagName, node.attrs);
|
|
199
|
+
const repeat = attrs["data-repeat"];
|
|
200
|
+
if (attrs.id) {
|
|
201
|
+
if (repeating || repeat || ids.has(attrs.id)) return webSourceError();
|
|
202
|
+
ids.add(attrs.id);
|
|
203
|
+
}
|
|
204
|
+
const bindings = {};
|
|
205
|
+
for (const binding of WEB_BINDINGS) if (attrs[`data-${binding}`]) bindings[binding] = attrs[`data-${binding}`];
|
|
206
|
+
const action = attrs["data-action"] ? { type: attrs["data-action"], ...attrs["data-id"] ? { idPath: attrs["data-id"] } : {} } : void 0;
|
|
207
|
+
const field = attrs.name ? { name: attrs.name, type: node.tagName === "input" ? attrs.type ?? "text" : node.tagName } : void 0;
|
|
208
|
+
const safeAttributes = Object.fromEntries(Object.entries(attrs).filter(([name]) => !name.startsWith("data-")));
|
|
209
|
+
return [{
|
|
210
|
+
kind: "element",
|
|
211
|
+
tag: node.tagName,
|
|
212
|
+
attributes: safeAttributes,
|
|
213
|
+
bindings,
|
|
214
|
+
children: node.childNodes.flatMap((child) => convert(child, depth + 1, repeating || !!repeat)),
|
|
215
|
+
...repeat ? { repeat } : {},
|
|
216
|
+
...action ? { action } : {},
|
|
217
|
+
...field ? { field } : {}
|
|
218
|
+
}];
|
|
219
|
+
}
|
|
220
|
+
return parser.getFragment().childNodes.flatMap((node) => convert(node, 1, false));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/web-css.ts
|
|
224
|
+
import { generate, lexer, parse, walk } from "css-tree";
|
|
225
|
+
var properties = /* @__PURE__ */ new Set([
|
|
226
|
+
"display",
|
|
227
|
+
"gap",
|
|
228
|
+
"row-gap",
|
|
229
|
+
"column-gap",
|
|
230
|
+
"grid-template-columns",
|
|
231
|
+
"grid-template-rows",
|
|
232
|
+
"grid-column",
|
|
233
|
+
"grid-row",
|
|
234
|
+
"align-items",
|
|
235
|
+
"align-content",
|
|
236
|
+
"justify-items",
|
|
237
|
+
"justify-content",
|
|
238
|
+
"flex",
|
|
239
|
+
"flex-direction",
|
|
240
|
+
"flex-wrap",
|
|
241
|
+
"flex-grow",
|
|
242
|
+
"flex-shrink",
|
|
243
|
+
"flex-basis",
|
|
244
|
+
"order",
|
|
245
|
+
"width",
|
|
246
|
+
"min-width",
|
|
247
|
+
"max-width",
|
|
248
|
+
"height",
|
|
249
|
+
"min-height",
|
|
250
|
+
"max-height",
|
|
251
|
+
"margin",
|
|
252
|
+
"margin-top",
|
|
253
|
+
"margin-right",
|
|
254
|
+
"margin-bottom",
|
|
255
|
+
"margin-left",
|
|
256
|
+
"margin-inline",
|
|
257
|
+
"margin-block",
|
|
258
|
+
"padding",
|
|
259
|
+
"padding-top",
|
|
260
|
+
"padding-right",
|
|
261
|
+
"padding-bottom",
|
|
262
|
+
"padding-left",
|
|
263
|
+
"padding-inline",
|
|
264
|
+
"padding-block",
|
|
265
|
+
"box-sizing",
|
|
266
|
+
"border",
|
|
267
|
+
"border-width",
|
|
268
|
+
"border-style",
|
|
269
|
+
"border-color",
|
|
270
|
+
"border-radius",
|
|
271
|
+
"border-collapse",
|
|
272
|
+
"border-spacing",
|
|
273
|
+
"color",
|
|
274
|
+
"background-color",
|
|
275
|
+
"font-family",
|
|
276
|
+
"font-size",
|
|
277
|
+
"font-weight",
|
|
278
|
+
"font-style",
|
|
279
|
+
"line-height",
|
|
280
|
+
"letter-spacing",
|
|
281
|
+
"text-align",
|
|
282
|
+
"text-decoration",
|
|
283
|
+
"text-transform",
|
|
284
|
+
"white-space",
|
|
285
|
+
"overflow-wrap",
|
|
286
|
+
"word-break",
|
|
287
|
+
"vertical-align",
|
|
288
|
+
"list-style-type",
|
|
289
|
+
"outline",
|
|
290
|
+
"outline-width",
|
|
291
|
+
"outline-style",
|
|
292
|
+
"outline-color",
|
|
293
|
+
"outline-offset",
|
|
294
|
+
"opacity",
|
|
295
|
+
"visibility",
|
|
296
|
+
"overflow",
|
|
297
|
+
"overflow-x",
|
|
298
|
+
"overflow-y",
|
|
299
|
+
"cursor",
|
|
300
|
+
"transition-property",
|
|
301
|
+
"transition-duration",
|
|
302
|
+
"transition-timing-function"
|
|
303
|
+
]);
|
|
304
|
+
var functions = /* @__PURE__ */ new Set(["rgb", "rgba", "hsl", "hsla", "var", "min", "max", "clamp", "calc", "repeat", "minmax", "fit-content", "steps", "cubic-bezier"]);
|
|
305
|
+
var pseudoClasses = /* @__PURE__ */ new Set([
|
|
306
|
+
"root",
|
|
307
|
+
"hover",
|
|
308
|
+
"focus",
|
|
309
|
+
"focus-visible",
|
|
310
|
+
"focus-within",
|
|
311
|
+
"active",
|
|
312
|
+
"checked",
|
|
313
|
+
"disabled",
|
|
314
|
+
"enabled",
|
|
315
|
+
"first-child",
|
|
316
|
+
"last-child",
|
|
317
|
+
"nth-child",
|
|
318
|
+
"nth-of-type",
|
|
319
|
+
"empty",
|
|
320
|
+
"not"
|
|
321
|
+
]);
|
|
322
|
+
var units = /* @__PURE__ */ new Set(["px", "em", "rem", "ch", "fr", "s", "ms", "deg"]);
|
|
323
|
+
function parseWebCss(css, checkOpen) {
|
|
324
|
+
checkOpen();
|
|
325
|
+
const ast = parse(css, { positions: false, parseCustomProperty: true, onParseError: webSourceError });
|
|
326
|
+
let nodes = 0;
|
|
327
|
+
let depth = 0;
|
|
328
|
+
const declarations = [];
|
|
329
|
+
walk(ast, {
|
|
330
|
+
enter(node) {
|
|
331
|
+
checkOpen();
|
|
332
|
+
if (++nodes > WEB_PROJECT_LIMITS.cssNodes || ++depth > WEB_PROJECT_LIMITS.cssDepth) return webLimitError();
|
|
333
|
+
if (["Raw", "Url"].includes(node.type)) return webSourceError();
|
|
334
|
+
if (node.type === "Atrule") {
|
|
335
|
+
if (node.name !== "media" || !node.prelude || !node.block) return webSourceError();
|
|
336
|
+
const query = generate(node.prelude).replace(/\s+/gu, "");
|
|
337
|
+
if (!/^\((?:min-width|max-width):\d{1,4}(?:px|rem)\)$/u.test(query) && !/^\(prefers-reduced-motion:(?:reduce|no-preference)\)$/u.test(query) && !/^\(prefers-color-scheme:(?:light|dark)\)$/u.test(query)) return webSourceError();
|
|
338
|
+
}
|
|
339
|
+
if (node.type === "Declaration") {
|
|
340
|
+
if (node.important) return webSourceError();
|
|
341
|
+
const custom = /^--[a-z][a-z0-9-]{0,31}$/u.test(node.property);
|
|
342
|
+
if (!custom && !properties.has(node.property)) return webSourceError();
|
|
343
|
+
if (!custom) declarations.push(node);
|
|
344
|
+
}
|
|
345
|
+
if (node.type === "Function" && !functions.has(node.name)) return webSourceError();
|
|
346
|
+
if (node.type === "PseudoClassSelector" && !pseudoClasses.has(node.name)) return webSourceError();
|
|
347
|
+
if (node.type === "PseudoElementSelector") return webSourceError();
|
|
348
|
+
if (node.type === "AttributeSelector") {
|
|
349
|
+
const name = node.name.name;
|
|
350
|
+
const value = node.value?.type === "String" ? node.value.value : node.value?.name;
|
|
351
|
+
if (node.matcher !== "=" || node.flags || typeof value !== "string" || !["aria-pressed", "aria-expanded", "aria-invalid", "aria-required"].includes(name) && name !== "type" || !(name === "type" ? ["text", "number", "range", "checkbox", "button", "submit"].includes(value) : ["true", "false"].includes(value))) return webSourceError();
|
|
352
|
+
}
|
|
353
|
+
if (node.type === "Dimension" || node.type === "Number" || node.type === "Percentage") {
|
|
354
|
+
const value = Number(node.value);
|
|
355
|
+
if (!Number.isFinite(value) || Math.abs(value) > 4096) return webSourceError();
|
|
356
|
+
if (node.type === "Dimension" && (!units.has(node.unit) || node.unit === "s" && (value < 0 || value > 2) || node.unit === "ms" && (value < 0 || value > 2e3))) return webSourceError();
|
|
357
|
+
}
|
|
358
|
+
if (node.type === "Function" && node.name === "repeat") {
|
|
359
|
+
const first = node.children.first;
|
|
360
|
+
if (!first || (first.type === "Number" ? !Number.isInteger(Number(first.value)) || Number(first.value) < 1 || Number(first.value) > 12 : first.type !== "Identifier" || !["auto-fit", "auto-fill"].includes(first.name))) return webSourceError();
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
leave() {
|
|
364
|
+
depth -= 1;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
for (const declaration of declarations) {
|
|
368
|
+
checkOpen();
|
|
369
|
+
let variable = false;
|
|
370
|
+
walk(declaration.value, (candidate) => {
|
|
371
|
+
if (candidate.type === "Function" && candidate.name === "var") variable = true;
|
|
372
|
+
});
|
|
373
|
+
if (!variable && !lexer.matchProperty(declaration.property, declaration.value).matched) return webSourceError();
|
|
374
|
+
}
|
|
375
|
+
checkOpen();
|
|
376
|
+
const result = generate(ast);
|
|
377
|
+
if (result.length > WEB_PROJECT_LIMITS.cssCharacters) return webLimitError();
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/web.ts
|
|
382
|
+
function ownPath(value, path) {
|
|
383
|
+
let current = value;
|
|
384
|
+
for (const key of path.split(".")) {
|
|
385
|
+
if (current === null || typeof current !== "object" || Array.isArray(current) || !Object.hasOwn(current, key)) return webViewError();
|
|
386
|
+
current = current[key];
|
|
387
|
+
}
|
|
388
|
+
return current;
|
|
389
|
+
}
|
|
390
|
+
var scalarText = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : webViewError();
|
|
391
|
+
var bool = (value) => typeof value === "boolean" ? value : webViewError();
|
|
392
|
+
function createWebProject(source, options = {}) {
|
|
393
|
+
let snapshot;
|
|
394
|
+
try {
|
|
395
|
+
snapshot = JSON.parse(serializeProjectJson(source));
|
|
396
|
+
} catch {
|
|
397
|
+
return webSourceError();
|
|
398
|
+
}
|
|
399
|
+
if (!snapshot || typeof snapshot !== "object" || Array.isArray(snapshot) || Object.keys(snapshot).length !== 2 || typeof snapshot.html !== "string" || typeof snapshot.css !== "string" || (snapshot.html + snapshot.css).includes("\0")) return webSourceError();
|
|
400
|
+
if (snapshot.html.length > WEB_PROJECT_LIMITS.htmlCharacters || snapshot.css.length > WEB_PROJECT_LIMITS.cssCharacters) return webLimitError();
|
|
401
|
+
if (!options || typeof options !== "object" || Array.isArray(options) || Object.getPrototypeOf(options) !== Object.prototype && Object.getPrototypeOf(options) !== null || Object.getOwnPropertySymbols(options).length) return webSourceError();
|
|
402
|
+
const descriptors = Object.getOwnPropertyDescriptors(options);
|
|
403
|
+
if (Object.entries(descriptors).some(([key, descriptor]) => key !== "signal" || descriptor.get || descriptor.set || !descriptor.enumerable)) return webSourceError();
|
|
404
|
+
const signal = descriptors.signal?.value;
|
|
405
|
+
if (signal !== void 0 && !(signal instanceof AbortSignal)) return webSourceError();
|
|
406
|
+
let closed = signal?.aborted === true;
|
|
407
|
+
const checkOpen = () => {
|
|
408
|
+
if (closed || signal?.aborted) throw new WebProjectError("CLOSED");
|
|
409
|
+
};
|
|
410
|
+
let template = [];
|
|
411
|
+
let css = "";
|
|
412
|
+
const dispose = () => {
|
|
413
|
+
closed = true;
|
|
414
|
+
template = [];
|
|
415
|
+
css = "";
|
|
416
|
+
signal?.removeEventListener("abort", dispose);
|
|
417
|
+
};
|
|
418
|
+
try {
|
|
419
|
+
checkOpen();
|
|
420
|
+
template = parseWebHtml(snapshot.html, checkOpen);
|
|
421
|
+
css = parseWebCss(snapshot.css, checkOpen);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
dispose();
|
|
424
|
+
if (error instanceof WebProjectError) throw error;
|
|
425
|
+
return webSourceError();
|
|
426
|
+
}
|
|
427
|
+
signal?.addEventListener("abort", dispose, { once: true });
|
|
428
|
+
return {
|
|
429
|
+
get closed() {
|
|
430
|
+
return closed;
|
|
431
|
+
},
|
|
432
|
+
get template() {
|
|
433
|
+
checkOpen();
|
|
434
|
+
return structuredClone(template);
|
|
435
|
+
},
|
|
436
|
+
dispose,
|
|
437
|
+
render(value) {
|
|
438
|
+
checkOpen();
|
|
439
|
+
try {
|
|
440
|
+
let project2 = function(node, context, skipRepeat = false) {
|
|
441
|
+
checkOpen();
|
|
442
|
+
if (++nodes > WEB_PROJECT_LIMITS.projectedNodes) return webLimitError();
|
|
443
|
+
if (node.kind === "text") return [{ ...node }];
|
|
444
|
+
if (node.repeat && !skipRepeat) {
|
|
445
|
+
const items = ownPath(context, node.repeat);
|
|
446
|
+
if (!Array.isArray(items)) return webViewError();
|
|
447
|
+
if (items.length > WEB_PROJECT_LIMITS.repeatedItems) return webLimitError();
|
|
448
|
+
const ids = /* @__PURE__ */ new Set();
|
|
449
|
+
return items.flatMap((item) => {
|
|
450
|
+
const id = ownPath(item, "id");
|
|
451
|
+
if (typeof id !== "string" || !id.trim() || id.length > 128 || ids.has(id)) return webViewError();
|
|
452
|
+
ids.add(id);
|
|
453
|
+
return project2(node, item, true);
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (node.bindings.if && !bool(ownPath(context, node.bindings.if))) return [];
|
|
457
|
+
const attributes2 = { ...node.attributes };
|
|
458
|
+
for (const [binding, path] of Object.entries(node.bindings)) {
|
|
459
|
+
if (["text", "if"].includes(binding)) continue;
|
|
460
|
+
const data = ownPath(context, path);
|
|
461
|
+
if (binding === "disabled" || binding === "checked") {
|
|
462
|
+
if (bool(data)) attributes2[binding] = "";
|
|
463
|
+
else delete attributes2[binding];
|
|
464
|
+
} else if (binding === "pressed" || binding === "invalid") attributes2[`aria-${binding}`] = String(bool(data));
|
|
465
|
+
else if (binding === "label") {
|
|
466
|
+
const label = scalarText(data);
|
|
467
|
+
if (!label.trim() || label.length > WEB_PROJECT_LIMITS.attributeCharacters) return webViewError();
|
|
468
|
+
attributes2["aria-label"] = label;
|
|
469
|
+
} else {
|
|
470
|
+
const value2 = scalarText(data);
|
|
471
|
+
if (value2.length > 2e3) return webLimitError();
|
|
472
|
+
attributes2.value = value2;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (node.bindings.text && ++nodes > WEB_PROJECT_LIMITS.projectedNodes) return webLimitError();
|
|
476
|
+
const children = node.bindings.text ? [{ kind: "text", text: scalarText(ownPath(context, node.bindings.text)) }] : node.children.flatMap((child) => project2(child, context));
|
|
477
|
+
const action = actionFor(node, context);
|
|
478
|
+
return [{
|
|
479
|
+
kind: "element",
|
|
480
|
+
tag: node.tag,
|
|
481
|
+
attributes: attributes2,
|
|
482
|
+
children,
|
|
483
|
+
...action ? { action } : {},
|
|
484
|
+
...node.field ? { field: { ...node.field } } : {}
|
|
485
|
+
}];
|
|
486
|
+
};
|
|
487
|
+
var project = project2;
|
|
488
|
+
const view = JSON.parse(serializeProjectJson(value));
|
|
489
|
+
if (view === null || typeof view !== "object" || Array.isArray(view)) return webViewError();
|
|
490
|
+
let nodes = 0;
|
|
491
|
+
const result = { nodes: template.flatMap((node) => project2(node, view)), css };
|
|
492
|
+
if (JSON.stringify(result).length > WEB_PROJECT_LIMITS.outputCharacters) return webLimitError();
|
|
493
|
+
return result;
|
|
494
|
+
} catch (error) {
|
|
495
|
+
if (error instanceof WebProjectError) throw error;
|
|
496
|
+
return webViewError();
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function actionFor(node, context) {
|
|
502
|
+
if (!node.action) return void 0;
|
|
503
|
+
if (!node.action.idPath) return { type: node.action.type };
|
|
504
|
+
const id = ownPath(context, node.action.idPath);
|
|
505
|
+
if (typeof id !== "string" || !id.trim() || id.length > 128) return webViewError();
|
|
506
|
+
return { type: node.action.type, id };
|
|
507
|
+
}
|
|
508
|
+
export {
|
|
509
|
+
WEB_PROJECT_LIMITS,
|
|
510
|
+
WebProjectError,
|
|
511
|
+
createWebProject
|
|
512
|
+
};
|
|
513
|
+
//# sourceMappingURL=web.js.map
|
package/dist/web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web-html.ts","../src/web-model.ts","../src/web-css.ts","../src/web.ts"],"sourcesContent":["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","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"],"mappings":";;;;;AAAA,SAAS,cAA0C;;;ACA5C,IAAM,qBAAqB,OAAO,OAAO;AAAA,EAAE,gBAAgB;AAAA,EAAO,eAAe;AAAA,EACtF,eAAe;AAAA,EAAK,eAAe;AAAA,EAAI,YAAY;AAAA,EAAI,qBAAqB;AAAA,EAC5E,UAAU;AAAA,EAAM,UAAU;AAAA,EAAI,eAAe;AAAA,EAAI,gBAAgB;AAAA,EAAK,kBAAkB;AAAM,CAAC;AAE1F,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YAAqB,MAAuE;AAC1F,UAAM,gBAAgB,IAAI,EAAE;AADT;AACY,SAAK,OAAO;AAAA,EAC7C;AAAA,EAFqB;AAGvB;AAEO,IAAM,WAAW,oBAAI,IAAI;AAAA,EAAC;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAW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