@b9g/crank 0.4.4 → 0.5.0-beta.0

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/xm.cjs ADDED
@@ -0,0 +1,431 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var crank = require('./crank.cjs');
6
+
7
+ const cache = new Map();
8
+ function xm(spans, ...expressions) {
9
+ const key = JSON.stringify(spans.raw);
10
+ let parseResult = cache.get(key);
11
+ if (parseResult == null) {
12
+ parseResult = parse(spans.raw);
13
+ cache.set(key, parseResult);
14
+ }
15
+ const { element, targets } = parseResult;
16
+ for (let i = 0; i < expressions.length; i++) {
17
+ const exp = expressions[i];
18
+ const target = targets[i];
19
+ if (target) {
20
+ if (target.type === "error") {
21
+ throw new SyntaxError(target.message.replace("${}", formatTagForError(exp)));
22
+ }
23
+ target.value = exp;
24
+ }
25
+ }
26
+ return build(element);
27
+ }
28
+ /**
29
+ * Matches first significant character in children mode.
30
+ *
31
+ * Group 1: newline
32
+ * Group 2: comment
33
+ * Group 3: tag
34
+ * Group 4: closing slash
35
+ * Group 5: tag name
36
+ *
37
+ * The comment group must appear first because the tag group can potentially
38
+ * match a comment, so that we can handle tag expressions where we’ve reached
39
+ * the end of a span.
40
+ */
41
+ const CHILDREN_RE = /((?:\r|\n|\r\n)\s*)|(<!--[\S\s]*?(?:-->|$))|(<\s*(\/{0,2})\s*([-_$\w]*))/g;
42
+ /**
43
+ * Matches props after element tags.
44
+ *
45
+ * Group 1: tag end
46
+ * Group 2: spread props
47
+ * Group 3: prop name
48
+ * Group 4: equals
49
+ * Group 5: prop value string
50
+ */
51
+ const PROPS_RE = /\s*(?:(\/?\s*>)|(\.\.\.\s*)|(?:([-_$\w]+)\s*(=)?\s*(?:("(\\"|[\S\s])*?(?:"|$)|'(?:\\'|[\S\s])*?(?:'|$)))?))/g;
52
+ const CLOSING_BRACKET_RE = />/g;
53
+ const CLOSING_SINGLE_QUOTE_RE = /[^\\]?'/g;
54
+ const CLOSING_DOUBLE_QUOTE_RE = /[^\\]?"/g;
55
+ const CLOSING_COMMENT_RE = /-->/g;
56
+ function parse(spans) {
57
+ let matcher = CHILDREN_RE;
58
+ const stack = [];
59
+ let element = {
60
+ type: "element",
61
+ open: { type: "tag", slash: "", value: "" },
62
+ close: null,
63
+ props: [],
64
+ children: [],
65
+ };
66
+ const targets = [];
67
+ let lineStart = true;
68
+ for (let s = 0; s < spans.length; s++) {
69
+ const span = spans[s];
70
+ // Whether or not an expression is upcoming. Used to provide better errors.
71
+ const expressing = s < spans.length - 1;
72
+ let expressionTarget = null;
73
+ for (let i = 0, end = i; i < span.length; i = end) {
74
+ matcher.lastIndex = i;
75
+ const match = matcher.exec(span);
76
+ end = match ? match.index + match[0].length : span.length;
77
+ switch (matcher) {
78
+ case CHILDREN_RE: {
79
+ if (match) {
80
+ const [, newline, comment, tag, closingSlash, tagName] = match;
81
+ if (i < match.index) {
82
+ let before = span.slice(i, match.index);
83
+ if (lineStart) {
84
+ before = before.replace(/^\s*/, "");
85
+ }
86
+ if (newline) {
87
+ if (span[Math.max(0, match.index - 1)] === "\\") {
88
+ // We preserve whitespace before escaped newlines.
89
+ // xm` \
90
+ // `
91
+ // remove the backslash from output
92
+ before = before.slice(0, -1);
93
+ }
94
+ else {
95
+ before = before.replace(/\s*$/, "");
96
+ }
97
+ }
98
+ if (before) {
99
+ element.children.push({ type: "value", value: before });
100
+ }
101
+ }
102
+ lineStart = !!newline;
103
+ if (comment) {
104
+ if (end === span.length) {
105
+ // Expression in a comment:
106
+ // xm`<!-- ${exp} -->`
107
+ matcher = CLOSING_COMMENT_RE;
108
+ }
109
+ }
110
+ else if (tag) {
111
+ if (closingSlash) {
112
+ element.close = {
113
+ type: "tag",
114
+ slash: closingSlash,
115
+ value: tagName,
116
+ };
117
+ if (!stack.length) {
118
+ if (end !== span.length) {
119
+ throw new SyntaxError(`Unmatched closing tag "${tagName}"`);
120
+ }
121
+ // ERROR EXPRESSION
122
+ expressionTarget = {
123
+ type: "error",
124
+ message: "Unmatched closing tag ${}",
125
+ value: null,
126
+ };
127
+ }
128
+ else {
129
+ if (end === span.length) {
130
+ // TAG EXPRESSION
131
+ expressionTarget = element.close;
132
+ }
133
+ element = stack.pop();
134
+ matcher = CLOSING_BRACKET_RE;
135
+ }
136
+ }
137
+ else {
138
+ const next = {
139
+ type: "element",
140
+ open: {
141
+ type: "tag",
142
+ slash: "",
143
+ value: tagName,
144
+ },
145
+ close: null,
146
+ props: [],
147
+ children: [],
148
+ };
149
+ element.children.push(next);
150
+ stack.push(element);
151
+ element = next;
152
+ matcher = PROPS_RE;
153
+ if (end === span.length) {
154
+ // TAG EXPRESSION
155
+ expressionTarget = element.open;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ else {
161
+ if (i < span.length) {
162
+ let after = span.slice(i);
163
+ if (!expressing) {
164
+ // trim trailing whitespace
165
+ after = after.replace(/\s*$/, "");
166
+ }
167
+ if (after) {
168
+ element.children.push({ type: "value", value: after });
169
+ }
170
+ }
171
+ }
172
+ break;
173
+ }
174
+ case PROPS_RE: {
175
+ if (match) {
176
+ const [, tagEnd, spread, name, equals, string] = match;
177
+ if (i < match.index) {
178
+ throw new SyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``);
179
+ }
180
+ if (tagEnd) {
181
+ if (tagEnd[0] === "/") {
182
+ // This is a self-closing element, so there will always be a
183
+ // result on the stack.
184
+ element = stack.pop();
185
+ }
186
+ matcher = CHILDREN_RE;
187
+ }
188
+ else if (spread) {
189
+ const value = {
190
+ type: "value",
191
+ value: null,
192
+ };
193
+ element.props.push(value);
194
+ // SPREAD PROP EXPRESSION
195
+ expressionTarget = value;
196
+ if (!(expressing && end === span.length)) {
197
+ throw new SyntaxError('Expression expected after "..."');
198
+ }
199
+ }
200
+ else if (name) {
201
+ let value;
202
+ if (string == null) {
203
+ if (!equals) {
204
+ value = { type: "value", value: true };
205
+ }
206
+ else if (end < span.length) {
207
+ throw new SyntaxError(`Unexpected text \`${span.slice(end, end + 20)}\``);
208
+ }
209
+ else {
210
+ value = { type: "value", value: null };
211
+ // PROP EXPRESSION
212
+ expressionTarget = value;
213
+ if (!(expressing && end === span.length)) {
214
+ throw new SyntaxError(`Expression expected for prop "${name}"`);
215
+ }
216
+ }
217
+ }
218
+ else {
219
+ const quote = string[0];
220
+ value = { type: "propString", parts: [] };
221
+ value.parts.push(string);
222
+ if (end === span.length) {
223
+ matcher =
224
+ quote === "'"
225
+ ? CLOSING_SINGLE_QUOTE_RE
226
+ : CLOSING_DOUBLE_QUOTE_RE;
227
+ }
228
+ }
229
+ const prop = {
230
+ type: "prop",
231
+ name,
232
+ value,
233
+ };
234
+ element.props.push(prop);
235
+ }
236
+ }
237
+ else {
238
+ if (!expressing) {
239
+ if (i === span.length) {
240
+ throw new SyntaxError(`Expected props but reached end of document`);
241
+ }
242
+ else {
243
+ throw new SyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``);
244
+ }
245
+ }
246
+ // Unexpected expression errors are handled in the outer loop.
247
+ //
248
+ // This would most likely be the starting point for the logic of
249
+ // prop name expressions.
250
+ // xm`<p ${name}=${value}>`
251
+ }
252
+ break;
253
+ }
254
+ case CLOSING_BRACKET_RE: {
255
+ // We’re in a closing tag and looking for the >.
256
+ if (match) {
257
+ if (i < match.index) {
258
+ throw new SyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``);
259
+ }
260
+ matcher = CHILDREN_RE;
261
+ }
262
+ else {
263
+ if (!expressing) {
264
+ throw new SyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``);
265
+ }
266
+ }
267
+ break;
268
+ }
269
+ case CLOSING_SINGLE_QUOTE_RE:
270
+ case CLOSING_DOUBLE_QUOTE_RE: {
271
+ const string = span.slice(i, end);
272
+ const prop = element.props[element.props.length - 1];
273
+ const propString = prop.value;
274
+ propString.parts.push(string);
275
+ if (match) {
276
+ matcher = PROPS_RE;
277
+ }
278
+ else {
279
+ if (!expressing) {
280
+ throw new SyntaxError(`Missing \`${matcher === CLOSING_SINGLE_QUOTE_RE ? "'" : '"'}\``);
281
+ }
282
+ }
283
+ break;
284
+ }
285
+ case CLOSING_COMMENT_RE: {
286
+ if (match) {
287
+ matcher = CHILDREN_RE;
288
+ }
289
+ else {
290
+ if (!expressing) {
291
+ throw new SyntaxError("Expected `-->` but reached end of template");
292
+ }
293
+ }
294
+ break;
295
+ }
296
+ }
297
+ }
298
+ if (expressing) {
299
+ if (expressionTarget) {
300
+ targets.push(expressionTarget);
301
+ if (expressionTarget.type === "error") {
302
+ break;
303
+ }
304
+ continue;
305
+ }
306
+ switch (matcher) {
307
+ case CHILDREN_RE: {
308
+ const target = { type: "value", value: null };
309
+ element.children.push(target);
310
+ targets.push(target);
311
+ break;
312
+ }
313
+ case CLOSING_SINGLE_QUOTE_RE:
314
+ case CLOSING_DOUBLE_QUOTE_RE: {
315
+ const prop = element.props[element.props.length - 1];
316
+ const target = { type: "value", value: null };
317
+ prop.value.parts.push(target);
318
+ targets.push(target);
319
+ break;
320
+ }
321
+ case CLOSING_COMMENT_RE:
322
+ targets.push(null);
323
+ break;
324
+ default:
325
+ throw new SyntaxError("Unexpected expression");
326
+ }
327
+ }
328
+ else if (expressionTarget) {
329
+ throw new SyntaxError("Expression expected");
330
+ }
331
+ lineStart = false;
332
+ }
333
+ if (stack.length) {
334
+ const ti = targets.indexOf(element.open);
335
+ if (ti === -1) {
336
+ throw new SyntaxError(`Unmatched opening tag "${element.open.value}"`);
337
+ }
338
+ targets[ti] = {
339
+ type: "error",
340
+ message: "Unmatched opening tag ${}",
341
+ value: null,
342
+ };
343
+ }
344
+ if (element.children.length === 1 && element.children[0].type === "element") {
345
+ element = element.children[0];
346
+ }
347
+ return { element, targets };
348
+ }
349
+ function build(parsed) {
350
+ if (parsed.close !== null &&
351
+ parsed.close.slash !== "//" &&
352
+ parsed.open.value !== parsed.close.value) {
353
+ throw new SyntaxError(`Unmatched closing tag ${formatTagForError(parsed.close.value)}, expected ${formatTagForError(parsed.open.value)}`);
354
+ }
355
+ const children = [];
356
+ for (let i = 0; i < parsed.children.length; i++) {
357
+ const child = parsed.children[i];
358
+ children.push(child.type === "element" ? build(child) : child.value);
359
+ }
360
+ let props = parsed.props.length ? {} : null;
361
+ for (let i = 0; i < parsed.props.length; i++) {
362
+ const prop = parsed.props[i];
363
+ if (prop.type === "prop") {
364
+ let value;
365
+ if (prop.value.type === "value") {
366
+ value = prop.value.value;
367
+ }
368
+ else {
369
+ let string = "";
370
+ for (let i = 0; i < prop.value.parts.length; i++) {
371
+ const part = prop.value.parts[i];
372
+ if (typeof part === "string") {
373
+ string += part;
374
+ }
375
+ else if (typeof part.value !== "boolean" && part.value != null) {
376
+ string +=
377
+ typeof part.value === "string" ? part.value : String(part.value);
378
+ }
379
+ }
380
+ value = string
381
+ // remove quotes
382
+ .slice(1, -1)
383
+ // unescape things
384
+ // adapted from https://stackoverflow.com/a/57330383/1825413
385
+ .replace(/\\x[0-9a-f]{2}|\\u[0-9a-f]{4}|\\u\{[0-9a-f]+\}|\\./gi, (match) => {
386
+ switch (match[1]) {
387
+ case "b":
388
+ return "\b";
389
+ case "f":
390
+ return "\f";
391
+ case "n":
392
+ return "\n";
393
+ case "r":
394
+ return "\r";
395
+ case "t":
396
+ return "\t";
397
+ case "v":
398
+ return "\v";
399
+ case "x":
400
+ return String.fromCharCode(parseInt(match.slice(2), 16));
401
+ case "u":
402
+ if (match[2] === "{") {
403
+ return String.fromCodePoint(parseInt(match.slice(3, -1), 16));
404
+ }
405
+ return String.fromCharCode(parseInt(match.slice(2), 16));
406
+ case "0":
407
+ return "\0";
408
+ default:
409
+ return match.slice(1);
410
+ }
411
+ });
412
+ }
413
+ props[prop.name] = value;
414
+ }
415
+ else {
416
+ // spread prop
417
+ props = { ...props, ...prop.value };
418
+ }
419
+ }
420
+ return crank.c(parsed.open.value, props, ...children);
421
+ }
422
+ function formatTagForError(tag) {
423
+ return typeof tag === "function"
424
+ ? tag.name + "()"
425
+ : typeof tag === "string"
426
+ ? `"${tag}"`
427
+ : JSON.stringify(tag);
428
+ }
429
+
430
+ exports.xm = xm;
431
+ //# sourceMappingURL=xm.cjs.map
package/xm.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xm.cjs","sources":["../src/xm.ts"],"sourcesContent":["import {c} from \"./crank.js\";\nimport type {Element} from \"./crank.js\";\n\nconst cache = new Map<string, ParseResult>();\nexport function xm(\n\tspans: TemplateStringsArray,\n\t...expressions: Array<unknown>\n): Element {\n\tconst key = JSON.stringify(spans.raw);\n\tlet parseResult = cache.get(key);\n\tif (parseResult == null) {\n\t\tparseResult = parse(spans.raw);\n\t\tcache.set(key, parseResult);\n\t}\n\n\tconst {element, targets} = parseResult;\n\tfor (let i = 0; i < expressions.length; i++) {\n\t\tconst exp = expressions[i];\n\t\tconst target = targets[i];\n\t\tif (target) {\n\t\t\tif (target.type === \"error\") {\n\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\ttarget.message.replace(\"${}\", formatTagForError(exp)),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\ttarget.value = exp;\n\t\t}\n\t}\n\n\treturn build(element);\n}\n\n// Type definitions for a bare-bones AST\ninterface ParseElement {\n\ttype: \"element\";\n\topen: ParseTag;\n\tclose: ParseTag | null;\n\t// ParseValue is used to represent spread props.\n\tprops: Array<ParseProp | ParseValue>;\n\tchildren: Array<ParseElement | ParseValue>;\n}\n\ninterface ParseValue {\n\ttype: \"value\";\n\tvalue: any;\n}\n\ninterface ParseTag {\n\ttype: \"tag\";\n\tslash: string;\n\tvalue: any;\n}\n\ninterface ParseProp {\n\ttype: \"prop\";\n\tname: string;\n\tvalue: ParseValue | ParsePropString;\n}\n\ninterface ParsePropString {\n\ttype: \"propString\";\n\tparts: Array<string | ParseValue>;\n}\n\ninterface ParseError {\n\ttype: \"error\";\n\tmessage: string;\n\tvalue: any;\n}\n\n// The parse result includes an array of targets, references to objects in the\n// parse tree whose `value` property is overwritten with expressions when the\n// template function is called. By separating the logic of parsing static\n// template spans from the handling of dynamic expressions, we can cache parse\n// results for successive calls.\ntype ExpressionTarget = ParseValue | ParseTag | ParseProp | ParseError;\n\ninterface ParseResult {\n\telement: ParseElement;\n\ttargets: Array<ExpressionTarget | null>;\n}\n\n/**\n * Matches first significant character in children mode.\n *\n * Group 1: newline\n * Group 2: comment\n * Group 3: tag\n * Group 4: closing slash\n * Group 5: tag name\n *\n * The comment group must appear first because the tag group can potentially\n * match a comment, so that we can handle tag expressions where we’ve reached\n * the end of a span.\n */\nconst CHILDREN_RE =\n\t/((?:\\r|\\n|\\r\\n)\\s*)|(<!--[\\S\\s]*?(?:-->|$))|(<\\s*(\\/{0,2})\\s*([-_$\\w]*))/g;\n\n/**\n * Matches props after element tags.\n *\n * Group 1: tag end\n * Group 2: spread props\n * Group 3: prop name\n * Group 4: equals\n * Group 5: prop value string\n */\nconst PROPS_RE =\n\t/\\s*(?:(\\/?\\s*>)|(\\.\\.\\.\\s*)|(?:([-_$\\w]+)\\s*(=)?\\s*(?:(\"(\\\\\"|[\\S\\s])*?(?:\"|$)|'(?:\\\\'|[\\S\\s])*?(?:'|$)))?))/g;\n\nconst CLOSING_BRACKET_RE = />/g;\n\nconst CLOSING_SINGLE_QUOTE_RE = /[^\\\\]?'/g;\n\nconst CLOSING_DOUBLE_QUOTE_RE = /[^\\\\]?\"/g;\n\nconst CLOSING_COMMENT_RE = /-->/g;\n\nfunction parse(spans: ArrayLike<string>): ParseResult {\n\tlet matcher = CHILDREN_RE;\n\tconst stack: Array<ParseElement> = [];\n\tlet element: ParseElement = {\n\t\ttype: \"element\",\n\t\topen: {type: \"tag\", slash: \"\", value: \"\"},\n\t\tclose: null,\n\t\tprops: [],\n\t\tchildren: [],\n\t};\n\n\tconst targets: Array<ExpressionTarget | null> = [];\n\tlet lineStart = true;\n\tfor (let s = 0; s < spans.length; s++) {\n\t\tconst span = spans[s];\n\t\t// Whether or not an expression is upcoming. Used to provide better errors.\n\t\tconst expressing = s < spans.length - 1;\n\t\tlet expressionTarget: ExpressionTarget | null = null;\n\t\tfor (let i = 0, end = i; i < span.length; i = end) {\n\t\t\tmatcher.lastIndex = i;\n\t\t\tconst match = matcher.exec(span);\n\t\t\tend = match ? match.index + match[0].length : span.length;\n\t\t\tswitch (matcher) {\n\t\t\t\tcase CHILDREN_RE: {\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tconst [, newline, comment, tag, closingSlash, tagName] = match;\n\t\t\t\t\t\tif (i < match.index) {\n\t\t\t\t\t\t\tlet before = span.slice(i, match.index);\n\t\t\t\t\t\t\tif (lineStart) {\n\t\t\t\t\t\t\t\tbefore = before.replace(/^\\s*/, \"\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (newline) {\n\t\t\t\t\t\t\t\tif (span[Math.max(0, match.index - 1)] === \"\\\\\") {\n\t\t\t\t\t\t\t\t\t// We preserve whitespace before escaped newlines.\n\t\t\t\t\t\t\t\t\t// xm` \\\n\t\t\t\t\t\t\t\t\t// `\n\t\t\t\t\t\t\t\t\t// remove the backslash from output\n\t\t\t\t\t\t\t\t\tbefore = before.slice(0, -1);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbefore = before.replace(/\\s*$/, \"\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (before) {\n\t\t\t\t\t\t\t\telement.children.push({type: \"value\", value: before});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlineStart = !!newline;\n\t\t\t\t\t\tif (comment) {\n\t\t\t\t\t\t\tif (end === span.length) {\n\t\t\t\t\t\t\t\t// Expression in a comment:\n\t\t\t\t\t\t\t\t// xm`<!-- ${exp} -->`\n\t\t\t\t\t\t\t\tmatcher = CLOSING_COMMENT_RE;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (tag) {\n\t\t\t\t\t\t\tif (closingSlash) {\n\t\t\t\t\t\t\t\telement.close = {\n\t\t\t\t\t\t\t\t\ttype: \"tag\",\n\t\t\t\t\t\t\t\t\tslash: closingSlash,\n\t\t\t\t\t\t\t\t\tvalue: tagName,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (!stack.length) {\n\t\t\t\t\t\t\t\t\tif (end !== span.length) {\n\t\t\t\t\t\t\t\t\t\tthrow new SyntaxError(`Unmatched closing tag \"${tagName}\"`);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// ERROR EXPRESSION\n\t\t\t\t\t\t\t\t\texpressionTarget = {\n\t\t\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\t\t\tmessage: \"Unmatched closing tag ${}\",\n\t\t\t\t\t\t\t\t\t\tvalue: null,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (end === span.length) {\n\t\t\t\t\t\t\t\t\t\t// TAG EXPRESSION\n\t\t\t\t\t\t\t\t\t\texpressionTarget = element.close;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\telement = stack.pop()!;\n\t\t\t\t\t\t\t\t\tmatcher = CLOSING_BRACKET_RE;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst next: ParseElement = {\n\t\t\t\t\t\t\t\t\ttype: \"element\",\n\t\t\t\t\t\t\t\t\topen: {\n\t\t\t\t\t\t\t\t\t\ttype: \"tag\",\n\t\t\t\t\t\t\t\t\t\tslash: \"\",\n\t\t\t\t\t\t\t\t\t\tvalue: tagName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tclose: null,\n\t\t\t\t\t\t\t\t\tprops: [],\n\t\t\t\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\telement.children.push(next);\n\t\t\t\t\t\t\t\tstack.push(element);\n\t\t\t\t\t\t\t\telement = next;\n\t\t\t\t\t\t\t\tmatcher = PROPS_RE;\n\t\t\t\t\t\t\t\tif (end === span.length) {\n\t\t\t\t\t\t\t\t\t// TAG EXPRESSION\n\t\t\t\t\t\t\t\t\texpressionTarget = element.open;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (i < span.length) {\n\t\t\t\t\t\t\tlet after = span.slice(i);\n\t\t\t\t\t\t\tif (!expressing) {\n\t\t\t\t\t\t\t\t// trim trailing whitespace\n\t\t\t\t\t\t\t\tafter = after.replace(/\\s*$/, \"\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (after) {\n\t\t\t\t\t\t\t\telement.children.push({type: \"value\", value: after});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase PROPS_RE: {\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tconst [, tagEnd, spread, name, equals, string] = match;\n\t\t\t\t\t\tif (i < match.index) {\n\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t`Unexpected text \\`${span.slice(i, match.index).trim()}\\``,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (tagEnd) {\n\t\t\t\t\t\t\tif (tagEnd[0] === \"/\") {\n\t\t\t\t\t\t\t\t// This is a self-closing element, so there will always be a\n\t\t\t\t\t\t\t\t// result on the stack.\n\t\t\t\t\t\t\t\telement = stack.pop()!;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tmatcher = CHILDREN_RE;\n\t\t\t\t\t\t} else if (spread) {\n\t\t\t\t\t\t\tconst value = {\n\t\t\t\t\t\t\t\ttype: \"value\" as const,\n\t\t\t\t\t\t\t\tvalue: null,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\telement.props.push(value);\n\t\t\t\t\t\t\t// SPREAD PROP EXPRESSION\n\t\t\t\t\t\t\texpressionTarget = value;\n\t\t\t\t\t\t\tif (!(expressing && end === span.length)) {\n\t\t\t\t\t\t\t\tthrow new SyntaxError('Expression expected after \"...\"');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (name) {\n\t\t\t\t\t\t\tlet value: ParseValue | ParsePropString;\n\t\t\t\t\t\t\tif (string == null) {\n\t\t\t\t\t\t\t\tif (!equals) {\n\t\t\t\t\t\t\t\t\tvalue = {type: \"value\", value: true};\n\t\t\t\t\t\t\t\t} else if (end < span.length) {\n\t\t\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t\t\t`Unexpected text \\`${span.slice(end, end + 20)}\\``,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tvalue = {type: \"value\" as const, value: null};\n\t\t\t\t\t\t\t\t\t// PROP EXPRESSION\n\t\t\t\t\t\t\t\t\texpressionTarget = value;\n\t\t\t\t\t\t\t\t\tif (!(expressing && end === span.length)) {\n\t\t\t\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t\t\t\t`Expression expected for prop \"${name}\"`,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst quote = string[0];\n\t\t\t\t\t\t\t\tvalue = {type: \"propString\", parts: []};\n\t\t\t\t\t\t\t\tvalue.parts.push(string);\n\t\t\t\t\t\t\t\tif (end === span.length) {\n\t\t\t\t\t\t\t\t\tmatcher =\n\t\t\t\t\t\t\t\t\t\tquote === \"'\"\n\t\t\t\t\t\t\t\t\t\t\t? CLOSING_SINGLE_QUOTE_RE\n\t\t\t\t\t\t\t\t\t\t\t: CLOSING_DOUBLE_QUOTE_RE;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst prop = {\n\t\t\t\t\t\t\t\ttype: \"prop\" as const,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\telement.props.push(prop);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!expressing) {\n\t\t\t\t\t\t\tif (i === span.length) {\n\t\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t\t`Expected props but reached end of document`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t\t`Unexpected text \\`${span.slice(i, i + 20).trim()}\\``,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Unexpected expression errors are handled in the outer loop.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// This would most likely be the starting point for the logic of\n\t\t\t\t\t\t// prop name expressions.\n\t\t\t\t\t\t// xm`<p ${name}=${value}>`\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CLOSING_BRACKET_RE: {\n\t\t\t\t\t// We’re in a closing tag and looking for the >.\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tif (i < match.index) {\n\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t`Unexpected text \\`${span.slice(i, match.index).trim()}\\``,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmatcher = CHILDREN_RE;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!expressing) {\n\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t`Unexpected text \\`${span.slice(i, i + 20).trim()}\\``,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CLOSING_SINGLE_QUOTE_RE:\n\t\t\t\tcase CLOSING_DOUBLE_QUOTE_RE: {\n\t\t\t\t\tconst string = span.slice(i, end);\n\t\t\t\t\tconst prop = element.props[element.props.length - 1] as ParseProp;\n\t\t\t\t\tconst propString = prop.value as ParsePropString;\n\t\t\t\t\tpropString.parts.push(string);\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tmatcher = PROPS_RE;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!expressing) {\n\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t`Missing \\`${\n\t\t\t\t\t\t\t\t\tmatcher === CLOSING_SINGLE_QUOTE_RE ? \"'\" : '\"'\n\t\t\t\t\t\t\t\t}\\``,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CLOSING_COMMENT_RE: {\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tmatcher = CHILDREN_RE;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!expressing) {\n\t\t\t\t\t\t\tthrow new SyntaxError(\n\t\t\t\t\t\t\t\t\"Expected `-->` but reached end of template\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (expressing) {\n\t\t\tif (expressionTarget) {\n\t\t\t\ttargets.push(expressionTarget);\n\t\t\t\tif (expressionTarget.type === \"error\") {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tswitch (matcher) {\n\t\t\t\tcase CHILDREN_RE: {\n\t\t\t\t\tconst target = {type: \"value\" as const, value: null};\n\t\t\t\t\telement.children.push(target);\n\t\t\t\t\ttargets.push(target);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CLOSING_SINGLE_QUOTE_RE:\n\t\t\t\tcase CLOSING_DOUBLE_QUOTE_RE: {\n\t\t\t\t\tconst prop = element.props[element.props.length - 1] as ParseProp;\n\t\t\t\t\tconst target = {type: \"value\" as const, value: null};\n\t\t\t\t\t(prop.value as ParsePropString).parts.push(target);\n\t\t\t\t\ttargets.push(target);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase CLOSING_COMMENT_RE:\n\t\t\t\t\ttargets.push(null);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new SyntaxError(\"Unexpected expression\");\n\t\t\t}\n\t\t} else if (expressionTarget) {\n\t\t\tthrow new SyntaxError(\"Expression expected\");\n\t\t}\n\n\t\tlineStart = false;\n\t}\n\n\tif (stack.length) {\n\t\tconst ti = targets.indexOf(element.open);\n\t\tif (ti === -1) {\n\t\t\tthrow new SyntaxError(`Unmatched opening tag \"${element.open.value}\"`);\n\t\t}\n\n\t\ttargets[ti] = {\n\t\t\ttype: \"error\",\n\t\t\tmessage: \"Unmatched opening tag ${}\",\n\t\t\tvalue: null,\n\t\t};\n\t}\n\n\tif (element.children.length === 1 && element.children[0].type === \"element\") {\n\t\telement = element.children[0];\n\t}\n\n\treturn {element, targets};\n}\n\nfunction build(parsed: ParseElement): Element {\n\tif (\n\t\tparsed.close !== null &&\n\t\tparsed.close.slash !== \"//\" &&\n\t\tparsed.open.value !== parsed.close.value\n\t) {\n\t\tthrow new SyntaxError(\n\t\t\t`Unmatched closing tag ${formatTagForError(\n\t\t\t\tparsed.close.value,\n\t\t\t)}, expected ${formatTagForError(parsed.open.value)}`,\n\t\t);\n\t}\n\n\tconst children: Array<unknown> = [];\n\tfor (let i = 0; i < parsed.children.length; i++) {\n\t\tconst child = parsed.children[i];\n\t\tchildren.push(child.type === \"element\" ? build(child) : child.value);\n\t}\n\n\tlet props = parsed.props.length ? ({} as Record<string, unknown>) : null;\n\tfor (let i = 0; i < parsed.props.length; i++) {\n\t\tconst prop = parsed.props[i];\n\t\tif (prop.type === \"prop\") {\n\t\t\tlet value: any;\n\t\t\tif (prop.value.type === \"value\") {\n\t\t\t\tvalue = prop.value.value;\n\t\t\t} else {\n\t\t\t\tlet string = \"\";\n\t\t\t\tfor (let i = 0; i < prop.value.parts.length; i++) {\n\t\t\t\t\tconst part = prop.value.parts[i];\n\t\t\t\t\tif (typeof part === \"string\") {\n\t\t\t\t\t\tstring += part;\n\t\t\t\t\t} else if (typeof part.value !== \"boolean\" && part.value != null) {\n\t\t\t\t\t\tstring +=\n\t\t\t\t\t\t\ttypeof part.value === \"string\" ? part.value : String(part.value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvalue = string\n\t\t\t\t\t// remove quotes\n\t\t\t\t\t.slice(1, -1)\n\t\t\t\t\t// unescape things\n\t\t\t\t\t// adapted from https://stackoverflow.com/a/57330383/1825413\n\t\t\t\t\t.replace(\n\t\t\t\t\t\t/\\\\x[0-9a-f]{2}|\\\\u[0-9a-f]{4}|\\\\u\\{[0-9a-f]+\\}|\\\\./gi,\n\t\t\t\t\t\t(match) => {\n\t\t\t\t\t\t\tswitch (match[1]) {\n\t\t\t\t\t\t\t\tcase \"b\":\n\t\t\t\t\t\t\t\t\treturn \"\\b\";\n\t\t\t\t\t\t\t\tcase \"f\":\n\t\t\t\t\t\t\t\t\treturn \"\\f\";\n\t\t\t\t\t\t\t\tcase \"n\":\n\t\t\t\t\t\t\t\t\treturn \"\\n\";\n\t\t\t\t\t\t\t\tcase \"r\":\n\t\t\t\t\t\t\t\t\treturn \"\\r\";\n\t\t\t\t\t\t\t\tcase \"t\":\n\t\t\t\t\t\t\t\t\treturn \"\\t\";\n\t\t\t\t\t\t\t\tcase \"v\":\n\t\t\t\t\t\t\t\t\treturn \"\\v\";\n\t\t\t\t\t\t\t\tcase \"x\":\n\t\t\t\t\t\t\t\t\treturn String.fromCharCode(parseInt(match.slice(2), 16));\n\t\t\t\t\t\t\t\tcase \"u\":\n\t\t\t\t\t\t\t\t\tif (match[2] === \"{\") {\n\t\t\t\t\t\t\t\t\t\treturn String.fromCodePoint(\n\t\t\t\t\t\t\t\t\t\t\tparseInt(match.slice(3, -1), 16),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn String.fromCharCode(parseInt(match.slice(2), 16));\n\t\t\t\t\t\t\t\tcase \"0\":\n\t\t\t\t\t\t\t\t\treturn \"\\0\";\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\treturn match.slice(1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tprops![prop.name] = value;\n\t\t} else {\n\t\t\t// spread prop\n\t\t\tprops = {...props, ...(prop.value as any)};\n\t\t}\n\t}\n\n\treturn c(parsed.open.value, props, ...children);\n}\n\nfunction formatTagForError(tag: unknown): string {\n\treturn typeof tag === \"function\"\n\t\t? tag.name + \"()\"\n\t\t: typeof tag === \"string\"\n\t\t? `\"${tag}\"`\n\t\t: JSON.stringify(tag);\n}\n"],"names":["c"],"mappings":";;;;;;AAGA,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;SAC7B,EAAE,CACjB,KAA2B,EAC3B,GAAG,WAA2B,EAAA;IAE9B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,WAAW,IAAI,IAAI,EAAE;AACxB,QAAA,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,QAAA,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AAC5B,KAAA;AAED,IAAA,MAAM,EAAC,OA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,UAAE,GAAG,CAAC,IAAI,GAAG,IAAI;AACjB,UAAE,OAAO,GAAG,KAAK,QAAQ;cACvB,CAAI,CAAA,EAAA,GAAG,CAAG,CAAA,CAAA;AACZ,cAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AACxB;;;;"}
package/xm.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { Element } from "./crank.js";
2
+ export declare function xm(spans: TemplateStringsArray, ...expressions: Array<unknown>): Element;