@b9g/crank 0.7.4 → 0.7.6

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/html.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"html.js","sources":["../src/html.ts"],"sourcesContent":["import {Portal, Renderer} from \"./crank.js\";\nimport type {ElementValue, RenderAdapter} from \"./crank.js\";\nimport {camelToKebabCase, formatStyleValue} from \"./_css.js\";\n\nconst voidTags = new Set([\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"command\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"keygen\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\nfunction escape(text: string): string {\n\treturn text.replace(/[&<>\"']/g, (match) => {\n\t\tswitch (match) {\n\t\t\tcase \"&\":\n\t\t\t\treturn \"&amp;\";\n\t\t\tcase \"<\":\n\t\t\t\treturn \"&lt;\";\n\t\t\tcase \">\":\n\t\t\t\treturn \"&gt;\";\n\t\t\tcase '\"':\n\t\t\t\treturn \"&quot;\";\n\t\t\tcase \"'\":\n\t\t\t\treturn \"&#039;\";\n\t\t\tdefault:\n\t\t\t\treturn \"\";\n\t\t}\n\t});\n}\n\nfunction printStyleObject(style: Record<string, any>): string {\n\tconst cssStrings = [];\n\tfor (const [name, value] of Object.entries(style)) {\n\t\tif (value != null) {\n\t\t\tconst cssName = camelToKebabCase(name);\n\t\t\tconst cssValue = formatStyleValue(cssName, value);\n\t\t\tcssStrings.push(`${cssName}:${cssValue};`);\n\t\t}\n\t}\n\n\treturn cssStrings.join(\"\");\n}\n\nfunction printAttrs(props: Record<string, any>): string {\n\tconst attrs: string[] = [];\n\tfor (let [name, value] of Object.entries(props)) {\n\t\tif (name === \"innerHTML\" || name.startsWith(\"prop:\")) {\n\t\t\tcontinue;\n\t\t} else if (name === \"style\") {\n\t\t\tif (typeof value === \"string\") {\n\t\t\t\tattrs.push(`style=\"${escape(value)}\"`);\n\t\t\t} else if (typeof value === \"object\" && value !== null) {\n\t\t\t\tattrs.push(`style=\"${escape(printStyleObject(value))}\"`);\n\t\t\t}\n\t\t} else if (name === \"className\") {\n\t\t\tif (\"class\" in props || typeof value !== \"string\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattrs.push(`class=\"${escape(value)}\"`);\n\t\t} else if (name === \"class\") {\n\t\t\tif (typeof value === \"string\") {\n\t\t\t\tattrs.push(`class=\"${escape(value)}\"`);\n\t\t\t} else if (typeof value === \"object\" && value !== null) {\n\t\t\t\t// class={{\"foo bar\": true, \"baz\": false}} syntax\n\t\t\t\tconst classes = Object.keys(value)\n\t\t\t\t\t.filter((k) => value[k])\n\t\t\t\t\t.join(\" \");\n\t\t\t\tif (classes) {\n\t\t\t\t\tattrs.push(`class=\"${escape(classes)}\"`);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (name.startsWith(\"attr:\")) {\n\t\t\t\tname = name.slice(\"attr:\".length);\n\t\t\t}\n\t\t\tif (typeof value === \"string\") {\n\t\t\t\tattrs.push(`${escape(name)}=\"${escape(value)}\"`);\n\t\t\t} else if (typeof value === \"number\") {\n\t\t\t\tattrs.push(`${escape(name)}=\"${value}\"`);\n\t\t\t} else if (value === true) {\n\t\t\t\tattrs.push(`${escape(name)}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn attrs.join(\" \");\n}\n\n/**\n * The equivalent of DOM Node for the HTML Renderer. Not to be confused with\n * the DOM's Text node. It's just an object with value string so that\n * we can reference the value of the HTML by reference, not value.\n *\n * TextNode is never actually\n */\ninterface TextNode {\n\tvalue?: string;\n}\n\nfunction join(children: Array<TextNode | string>): string {\n\tlet result = \"\";\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst child = children[i];\n\t\tresult += typeof child === \"string\" ? child : child.value;\n\t}\n\n\treturn result;\n}\n\nexport const impl: Partial<\n\tRenderAdapter<TextNode, undefined, TextNode, string>\n> = {\n\tcreate(): TextNode {\n\t\treturn {value: \"\"};\n\t},\n\n\ttext({value}: {value: string}): TextNode {\n\t\treturn {value: escape(value)};\n\t},\n\n\tread(value: ElementValue<TextNode>): string {\n\t\tif (Array.isArray(value)) {\n\t\t\treturn join(value);\n\t\t} else if (typeof value === \"undefined\") {\n\t\t\treturn \"\";\n\t\t} else if (typeof value === \"string\") {\n\t\t\treturn value;\n\t\t} else {\n\t\t\treturn value.value || \"\";\n\t\t}\n\t},\n\n\tarrange({\n\t\ttag,\n\t\ttagName,\n\t\tnode,\n\t\tprops,\n\t\tchildren,\n\t}: {\n\t\ttag: string | symbol;\n\t\ttagName: string;\n\t\tnode: TextNode;\n\t\tprops: Record<string, any>;\n\t\tchildren: Array<TextNode | string>;\n\t\troot: TextNode | undefined;\n\t}): void {\n\t\tif (tag === Portal) {\n\t\t\treturn;\n\t\t} else if (typeof tag !== \"string\") {\n\t\t\tthrow new Error(`Unknown tag: ${tagName}`);\n\t\t}\n\n\t\tconst attrs = printAttrs(props);\n\t\tconst open = `<${tag}${attrs.length ? \" \" : \"\"}${attrs}>`;\n\t\tlet result: string;\n\t\tif (voidTags.has(tag)) {\n\t\t\tresult = open;\n\t\t} else {\n\t\t\tconst close = `</${tag}>`;\n\t\t\tconst contents =\n\t\t\t\t\"innerHTML\" in props ? props[\"innerHTML\"] : join(children);\n\t\t\tresult = `${open}${contents}${close}`;\n\t\t}\n\n\t\tnode.value = result;\n\t},\n};\n\nexport class HTMLRenderer extends Renderer<TextNode, undefined, any, string> {\n\tconstructor() {\n\t\tsuper(impl);\n\t}\n}\n\nexport const renderer = new HTMLRenderer();\n\ndeclare global {\n\tmodule Crank {\n\t\tinterface EventMap extends GlobalEventHandlersEventMap {}\n\t}\n}\n"],"names":[],"mappings":";;;;AAIA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,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A,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0C,CAAA;AAC3E,CAAA,CAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA;QACC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA,CAAA,CAAA,CAAI,CAAC;IACZ;AACA;AAEM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA;;"}
1
+ {"version":3,"file":"html.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.cjs","sources":["../src/jsx-runtime.ts"],"sourcesContent":["// This file is provided for compatibility reasons with the JSX automatic\n// runtime. Besides automatic imports, the JSX automatic runtime provides no\n// actual advantage over the createElement transform.\nimport {createElement} from \"./crank.js\";\n\nfunction jsxAdapter(tag: any, props: Record<string, any>, key: any) {\n\t// The new JSX transform extracts the key from props for performance reasons,\n\t// but key is not a special property in Crank.\n\tprops.key = key;\n\treturn createElement(tag, props);\n}\n\nexport const Fragment = \"\";\nexport const jsx = jsxAdapter;\nexport const jsxs = jsxAdapter;\nexport const jsxDEV = jsxAdapter;\n"],"names":["createElement"],"mappings":";;;;AAAA;AACA;AACA;AAGA,SAAS,UAAU,CAAC,GAAQ,EAAE,KAA0B,EAAE,GAAQ,EAAA;;;AAGjE,IAAA,KAAK,CAAC,GAAG,GAAG,GAAG;AACf,IAAA,OAAOA,mBAAa,CAAC,GAAG,EAAE,KAAK,CAAC;AACjC;AAEO,MAAM,QAAQ,GAAG;AACjB,MAAM,GAAG,GAAG;AACZ,MAAM,IAAI,GAAG;AACb,MAAM,MAAM,GAAG;;;;;;;"}
1
+ {"version":3,"file":"jsx-runtime.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","sources":["../src/jsx-runtime.ts"],"sourcesContent":["// This file is provided for compatibility reasons with the JSX automatic\n// runtime. Besides automatic imports, the JSX automatic runtime provides no\n// actual advantage over the createElement transform.\nimport {createElement} from \"./crank.js\";\n\nfunction jsxAdapter(tag: any, props: Record<string, any>, key: any) {\n\t// The new JSX transform extracts the key from props for performance reasons,\n\t// but key is not a special property in Crank.\n\tprops.key = key;\n\treturn createElement(tag, props);\n}\n\nexport const Fragment = \"\";\nexport const jsx = jsxAdapter;\nexport const jsxs = jsxAdapter;\nexport const jsxDEV = jsxAdapter;\n"],"names":[],"mappings":";;;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA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CAAG,CAAA,CAAE,KAAK,CAAC;AACjC;AAEO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,QAAQ,CAAA,CAAA,CAAG,CAAA,CAAA;AACjB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,GAAG,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,IAAI,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,MAAM,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
1
+ {"version":3,"file":"jsx-runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
package/jsx-tag.cjs CHANGED
@@ -8,7 +8,17 @@ function jsx(spans, ...expressions) {
8
8
  let parseResult = cache.get(key);
9
9
  if (parseResult == null) {
10
10
  parseResult = parse(spans.raw);
11
- cache.set(key, parseResult);
11
+ let hasError = false;
12
+ for (let i = 0; i < parseResult.targets.length; i++) {
13
+ const t = parseResult.targets[i];
14
+ if (t && t.type === "error") {
15
+ hasError = true;
16
+ break;
17
+ }
18
+ }
19
+ if (!hasError) {
20
+ cache.set(key, parseResult);
21
+ }
12
22
  }
13
23
  const { element, targets } = parseResult;
14
24
  for (let i = 0; i < expressions.length; i++) {
@@ -16,12 +26,15 @@ function jsx(spans, ...expressions) {
16
26
  const target = targets[i];
17
27
  if (target) {
18
28
  if (target.type === "error") {
19
- throw new SyntaxError(target.message.replace("${}", formatTagForError(exp)));
29
+ const msg = target.message.replace("${}", formatTagForError(exp));
30
+ throw new SyntaxError(target.spanIndex != null && target.charIndex != null
31
+ ? formatSyntaxError(msg, spans.raw, target.spanIndex, target.charIndex)
32
+ : msg);
20
33
  }
21
34
  target.value = exp;
22
35
  }
23
36
  }
24
- return build(element);
37
+ return build(element, parseResult.spans);
25
38
  }
26
39
  /** Alias for `jsx` template tag. */
27
40
  const html = jsx;
@@ -113,16 +126,20 @@ function parse(spans) {
113
126
  type: "tag",
114
127
  slash: closingSlash,
115
128
  value: tagName,
129
+ spanIndex: s,
130
+ charIndex: match.index,
116
131
  };
117
132
  if (!stack.length) {
118
133
  if (end !== span.length) {
119
- throw new SyntaxError(`Unmatched closing tag "${tagName}"`);
134
+ throw new SyntaxError(formatSyntaxError(`Unmatched closing tag "${tagName}"`, spans, s, match.index));
120
135
  }
121
136
  // ERROR EXPRESSION
122
137
  expressionTarget = {
123
138
  type: "error",
124
139
  message: "Unmatched closing tag ${}",
125
140
  value: null,
141
+ spanIndex: s,
142
+ charIndex: match.index,
126
143
  };
127
144
  }
128
145
  else {
@@ -141,6 +158,8 @@ function parse(spans) {
141
158
  type: "tag",
142
159
  slash: "",
143
160
  value: tagName,
161
+ spanIndex: s,
162
+ charIndex: match.index,
144
163
  },
145
164
  close: null,
146
165
  props: [],
@@ -175,7 +194,7 @@ function parse(spans) {
175
194
  if (match) {
176
195
  const [, tagEnd, spread, name, equals, string] = match;
177
196
  if (i < match.index) {
178
- throw new SyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``);
197
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``, spans, s, i));
179
198
  }
180
199
  if (tagEnd) {
181
200
  if (tagEnd[0] === "/") {
@@ -194,7 +213,7 @@ function parse(spans) {
194
213
  // SPREAD PROP EXPRESSION
195
214
  expressionTarget = value;
196
215
  if (!(expressing && end === span.length)) {
197
- throw new SyntaxError('Expression expected after "..."');
216
+ throw new SyntaxError(formatSyntaxError('Expression expected after "..."', spans, s, match.index));
198
217
  }
199
218
  }
200
219
  else if (name) {
@@ -204,14 +223,14 @@ function parse(spans) {
204
223
  value = { type: "value", value: true };
205
224
  }
206
225
  else if (end < span.length) {
207
- throw new SyntaxError(`Unexpected text \`${span.slice(end, end + 20)}\``);
226
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(end, end + 20)}\``, spans, s, end));
208
227
  }
209
228
  else {
210
229
  value = { type: "value", value: null };
211
230
  // PROP EXPRESSION
212
231
  expressionTarget = value;
213
232
  if (!(expressing && end === span.length)) {
214
- throw new SyntaxError(`Expression expected for prop "${name}"`);
233
+ throw new SyntaxError(formatSyntaxError(`Expression expected for prop "${name}"`, spans, s, match.index));
215
234
  }
216
235
  }
217
236
  }
@@ -237,10 +256,10 @@ function parse(spans) {
237
256
  else {
238
257
  if (!expressing) {
239
258
  if (i === span.length) {
240
- throw new SyntaxError(`Expected props but reached end of document`);
259
+ throw new SyntaxError(formatSyntaxError(`Expected props but reached end of document`, spans, s, i));
241
260
  }
242
261
  else {
243
- throw new SyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``);
262
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``, spans, s, i));
244
263
  }
245
264
  }
246
265
  // Unexpected expression errors are handled in the outer loop.
@@ -255,13 +274,13 @@ function parse(spans) {
255
274
  // We're in a closing tag and looking for the >.
256
275
  if (match) {
257
276
  if (i < match.index) {
258
- throw new SyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``);
277
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``, spans, s, i));
259
278
  }
260
279
  matcher = CHILDREN_RE;
261
280
  }
262
281
  else {
263
282
  if (!expressing) {
264
- throw new SyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``);
283
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``, spans, s, i));
265
284
  }
266
285
  }
267
286
  break;
@@ -277,7 +296,7 @@ function parse(spans) {
277
296
  }
278
297
  else {
279
298
  if (!expressing) {
280
- throw new SyntaxError(`Missing \`${matcher === CLOSING_SINGLE_QUOTE_RE ? "'" : '"'}\``);
299
+ throw new SyntaxError(formatSyntaxError(`Missing \`${matcher === CLOSING_SINGLE_QUOTE_RE ? "'" : '"'}\``, spans, s, i));
281
300
  }
282
301
  }
283
302
  break;
@@ -288,7 +307,7 @@ function parse(spans) {
288
307
  }
289
308
  else {
290
309
  if (!expressing) {
291
- throw new SyntaxError("Expected `-->` but reached end of template");
310
+ throw new SyntaxError(formatSyntaxError("Expected `-->` but reached end of template", spans, s, i));
292
311
  }
293
312
  }
294
313
  break;
@@ -322,40 +341,45 @@ function parse(spans) {
322
341
  targets.push(null);
323
342
  break;
324
343
  default:
325
- throw new SyntaxError("Unexpected expression");
344
+ throw new SyntaxError(formatSyntaxError("Unexpected expression", spans, s, spans[s].length));
326
345
  }
327
346
  }
328
347
  else if (expressionTarget) {
329
- throw new SyntaxError("Expression expected");
348
+ throw new SyntaxError(formatSyntaxError("Expression expected", spans, s, spans[s].length));
330
349
  }
331
350
  lineStart = false;
332
351
  }
333
352
  if (stack.length) {
334
353
  const ti = targets.indexOf(element.open);
335
354
  if (ti === -1) {
336
- throw new SyntaxError(`Unmatched opening tag "${element.open.value}"`);
355
+ throw new SyntaxError(formatSyntaxError(`Unmatched opening tag "${element.open.value}"`, spans, element.open.spanIndex ?? 0, element.open.charIndex ?? 0));
337
356
  }
338
357
  targets[ti] = {
339
358
  type: "error",
340
359
  message: "Unmatched opening tag ${}",
341
360
  value: null,
361
+ spanIndex: element.open.spanIndex,
362
+ charIndex: element.open.charIndex,
342
363
  };
343
364
  }
344
365
  if (element.children.length === 1 && element.children[0].type === "element") {
345
366
  element = element.children[0];
346
367
  }
347
- return { element, targets };
368
+ return { element, targets, spans };
348
369
  }
349
- function build(parsed) {
370
+ function build(parsed, spans) {
350
371
  if (parsed.close !== null &&
351
372
  parsed.close.slash !== "//" &&
352
373
  parsed.open.value !== parsed.close.value) {
353
- throw new SyntaxError(`Unmatched closing tag ${formatTagForError(parsed.close.value)}, expected ${formatTagForError(parsed.open.value)}`);
374
+ const msg = `Unmatched closing tag ${formatTagForError(parsed.close.value)}, expected ${formatTagForError(parsed.open.value)}`;
375
+ throw new SyntaxError(spans && parsed.close.spanIndex != null && parsed.close.charIndex != null
376
+ ? formatSyntaxError(msg, spans, parsed.close.spanIndex, parsed.close.charIndex)
377
+ : msg);
354
378
  }
355
379
  const children = [];
356
380
  for (let i = 0; i < parsed.children.length; i++) {
357
381
  const child = parsed.children[i];
358
- children.push(child.type === "element" ? build(child) : child.value);
382
+ children.push(child.type === "element" ? build(child, spans) : child.value);
359
383
  }
360
384
  let props = parsed.props.length ? {} : null;
361
385
  for (let i = 0; i < parsed.props.length; i++) {
@@ -426,7 +450,48 @@ function formatTagForError(tag) {
426
450
  ? `"${tag}"`
427
451
  : JSON.stringify(tag);
428
452
  }
453
+ function formatSyntaxError(message, spans, spanIndex, charIndex) {
454
+ // Reconstruct full template source with ${} placeholders
455
+ let source = spans[0];
456
+ for (let i = 1; i < spans.length; i++) {
457
+ source += "${}" + spans[i];
458
+ }
459
+ // Compute absolute offset
460
+ let offset = 0;
461
+ for (let i = 0; i < spanIndex; i++) {
462
+ offset += spans[i].length + 3; // 3 = "${}".length
463
+ }
464
+ offset += charIndex;
465
+ // Split into lines and find line/column
466
+ const lines = source.split(/\n/);
467
+ let line = 0;
468
+ let col = offset;
469
+ for (let i = 0; i < lines.length; i++) {
470
+ if (col <= lines[i].length) {
471
+ line = i;
472
+ break;
473
+ }
474
+ col -= lines[i].length + 1; // +1 for the newline
475
+ }
476
+ // Build context lines
477
+ let result = `${message}\n\n`;
478
+ const start = Math.max(0, line - 1);
479
+ const end = Math.min(lines.length - 1, line + 1);
480
+ const gutterWidth = String(end + 1).length;
481
+ for (let i = start; i <= end; i++) {
482
+ const num = String(i + 1).padStart(gutterWidth);
483
+ if (i === line) {
484
+ result += `> ${num} | ${lines[i]}\n`;
485
+ result += ` ${" ".repeat(gutterWidth)} | ${" ".repeat(col)}^\n`;
486
+ }
487
+ else {
488
+ result += ` ${num} | ${lines[i]}\n`;
489
+ }
490
+ }
491
+ return result.trimEnd();
492
+ }
429
493
 
430
494
  exports.html = html;
431
495
  exports.jsx = jsx;
496
+ exports.parse = parse;
432
497
  //# sourceMappingURL=jsx-tag.cjs.map
package/jsx-tag.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-tag.cjs","sources":["../src/jsx-tag.ts"],"sourcesContent":["import {createElement} from \"./crank.js\";\nimport type {Element} from \"./crank.js\";\n\nconst cache = new Map<string, ParseResult>();\nexport function jsx(\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/** Alias for `jsx` template tag. */\nexport const html = jsx;\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 and have to\n\t\t\t\t\t\t\t\t\t// remove the backslash.\n\t\t\t\t\t\t\t\t\t// jsx` \\\n\t\t\t\t\t\t\t\t\t// `\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// jsx`<!-- ${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// jsx`<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 createElement(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\t? `\"${tag}\"`\n\t\t\t: JSON.stringify(tag);\n}\n"],"names":["createElement"],"mappings":";;;;AAGA,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB;SAC5B,GAAG,CAClB,KAA2B,EAC3B,GAAG,WAA2B,EAAA;IAE9B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;IACrC,IAAI,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AAChC,IAAA,IAAI,WAAW,IAAI,IAAI,EAAE;AACxB,QAAA,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9B,QAAA,KAAK,CAAC,GAAG,CAAC,GAAG,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/jsx-tag.js CHANGED
@@ -7,7 +7,17 @@ function jsx(spans, ...expressions) {
7
7
  let parseResult = cache.get(key);
8
8
  if (parseResult == null) {
9
9
  parseResult = parse(spans.raw);
10
- cache.set(key, parseResult);
10
+ let hasError = false;
11
+ for (let i = 0; i < parseResult.targets.length; i++) {
12
+ const t = parseResult.targets[i];
13
+ if (t && t.type === "error") {
14
+ hasError = true;
15
+ break;
16
+ }
17
+ }
18
+ if (!hasError) {
19
+ cache.set(key, parseResult);
20
+ }
11
21
  }
12
22
  const { element, targets } = parseResult;
13
23
  for (let i = 0; i < expressions.length; i++) {
@@ -15,12 +25,15 @@ function jsx(spans, ...expressions) {
15
25
  const target = targets[i];
16
26
  if (target) {
17
27
  if (target.type === "error") {
18
- throw new SyntaxError(target.message.replace("${}", formatTagForError(exp)));
28
+ const msg = target.message.replace("${}", formatTagForError(exp));
29
+ throw new SyntaxError(target.spanIndex != null && target.charIndex != null
30
+ ? formatSyntaxError(msg, spans.raw, target.spanIndex, target.charIndex)
31
+ : msg);
19
32
  }
20
33
  target.value = exp;
21
34
  }
22
35
  }
23
- return build(element);
36
+ return build(element, parseResult.spans);
24
37
  }
25
38
  /** Alias for `jsx` template tag. */
26
39
  const html = jsx;
@@ -112,16 +125,20 @@ function parse(spans) {
112
125
  type: "tag",
113
126
  slash: closingSlash,
114
127
  value: tagName,
128
+ spanIndex: s,
129
+ charIndex: match.index,
115
130
  };
116
131
  if (!stack.length) {
117
132
  if (end !== span.length) {
118
- throw new SyntaxError(`Unmatched closing tag "${tagName}"`);
133
+ throw new SyntaxError(formatSyntaxError(`Unmatched closing tag "${tagName}"`, spans, s, match.index));
119
134
  }
120
135
  // ERROR EXPRESSION
121
136
  expressionTarget = {
122
137
  type: "error",
123
138
  message: "Unmatched closing tag ${}",
124
139
  value: null,
140
+ spanIndex: s,
141
+ charIndex: match.index,
125
142
  };
126
143
  }
127
144
  else {
@@ -140,6 +157,8 @@ function parse(spans) {
140
157
  type: "tag",
141
158
  slash: "",
142
159
  value: tagName,
160
+ spanIndex: s,
161
+ charIndex: match.index,
143
162
  },
144
163
  close: null,
145
164
  props: [],
@@ -174,7 +193,7 @@ function parse(spans) {
174
193
  if (match) {
175
194
  const [, tagEnd, spread, name, equals, string] = match;
176
195
  if (i < match.index) {
177
- throw new SyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``);
196
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``, spans, s, i));
178
197
  }
179
198
  if (tagEnd) {
180
199
  if (tagEnd[0] === "/") {
@@ -193,7 +212,7 @@ function parse(spans) {
193
212
  // SPREAD PROP EXPRESSION
194
213
  expressionTarget = value;
195
214
  if (!(expressing && end === span.length)) {
196
- throw new SyntaxError('Expression expected after "..."');
215
+ throw new SyntaxError(formatSyntaxError('Expression expected after "..."', spans, s, match.index));
197
216
  }
198
217
  }
199
218
  else if (name) {
@@ -203,14 +222,14 @@ function parse(spans) {
203
222
  value = { type: "value", value: true };
204
223
  }
205
224
  else if (end < span.length) {
206
- throw new SyntaxError(`Unexpected text \`${span.slice(end, end + 20)}\``);
225
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(end, end + 20)}\``, spans, s, end));
207
226
  }
208
227
  else {
209
228
  value = { type: "value", value: null };
210
229
  // PROP EXPRESSION
211
230
  expressionTarget = value;
212
231
  if (!(expressing && end === span.length)) {
213
- throw new SyntaxError(`Expression expected for prop "${name}"`);
232
+ throw new SyntaxError(formatSyntaxError(`Expression expected for prop "${name}"`, spans, s, match.index));
214
233
  }
215
234
  }
216
235
  }
@@ -236,10 +255,10 @@ function parse(spans) {
236
255
  else {
237
256
  if (!expressing) {
238
257
  if (i === span.length) {
239
- throw new SyntaxError(`Expected props but reached end of document`);
258
+ throw new SyntaxError(formatSyntaxError(`Expected props but reached end of document`, spans, s, i));
240
259
  }
241
260
  else {
242
- throw new SyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``);
261
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``, spans, s, i));
243
262
  }
244
263
  }
245
264
  // Unexpected expression errors are handled in the outer loop.
@@ -254,13 +273,13 @@ function parse(spans) {
254
273
  // We're in a closing tag and looking for the >.
255
274
  if (match) {
256
275
  if (i < match.index) {
257
- throw new SyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``);
276
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, match.index).trim()}\``, spans, s, i));
258
277
  }
259
278
  matcher = CHILDREN_RE;
260
279
  }
261
280
  else {
262
281
  if (!expressing) {
263
- throw new SyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``);
282
+ throw new SyntaxError(formatSyntaxError(`Unexpected text \`${span.slice(i, i + 20).trim()}\``, spans, s, i));
264
283
  }
265
284
  }
266
285
  break;
@@ -276,7 +295,7 @@ function parse(spans) {
276
295
  }
277
296
  else {
278
297
  if (!expressing) {
279
- throw new SyntaxError(`Missing \`${matcher === CLOSING_SINGLE_QUOTE_RE ? "'" : '"'}\``);
298
+ throw new SyntaxError(formatSyntaxError(`Missing \`${matcher === CLOSING_SINGLE_QUOTE_RE ? "'" : '"'}\``, spans, s, i));
280
299
  }
281
300
  }
282
301
  break;
@@ -287,7 +306,7 @@ function parse(spans) {
287
306
  }
288
307
  else {
289
308
  if (!expressing) {
290
- throw new SyntaxError("Expected `-->` but reached end of template");
309
+ throw new SyntaxError(formatSyntaxError("Expected `-->` but reached end of template", spans, s, i));
291
310
  }
292
311
  }
293
312
  break;
@@ -321,40 +340,45 @@ function parse(spans) {
321
340
  targets.push(null);
322
341
  break;
323
342
  default:
324
- throw new SyntaxError("Unexpected expression");
343
+ throw new SyntaxError(formatSyntaxError("Unexpected expression", spans, s, spans[s].length));
325
344
  }
326
345
  }
327
346
  else if (expressionTarget) {
328
- throw new SyntaxError("Expression expected");
347
+ throw new SyntaxError(formatSyntaxError("Expression expected", spans, s, spans[s].length));
329
348
  }
330
349
  lineStart = false;
331
350
  }
332
351
  if (stack.length) {
333
352
  const ti = targets.indexOf(element.open);
334
353
  if (ti === -1) {
335
- throw new SyntaxError(`Unmatched opening tag "${element.open.value}"`);
354
+ throw new SyntaxError(formatSyntaxError(`Unmatched opening tag "${element.open.value}"`, spans, element.open.spanIndex ?? 0, element.open.charIndex ?? 0));
336
355
  }
337
356
  targets[ti] = {
338
357
  type: "error",
339
358
  message: "Unmatched opening tag ${}",
340
359
  value: null,
360
+ spanIndex: element.open.spanIndex,
361
+ charIndex: element.open.charIndex,
341
362
  };
342
363
  }
343
364
  if (element.children.length === 1 && element.children[0].type === "element") {
344
365
  element = element.children[0];
345
366
  }
346
- return { element, targets };
367
+ return { element, targets, spans };
347
368
  }
348
- function build(parsed) {
369
+ function build(parsed, spans) {
349
370
  if (parsed.close !== null &&
350
371
  parsed.close.slash !== "//" &&
351
372
  parsed.open.value !== parsed.close.value) {
352
- throw new SyntaxError(`Unmatched closing tag ${formatTagForError(parsed.close.value)}, expected ${formatTagForError(parsed.open.value)}`);
373
+ const msg = `Unmatched closing tag ${formatTagForError(parsed.close.value)}, expected ${formatTagForError(parsed.open.value)}`;
374
+ throw new SyntaxError(spans && parsed.close.spanIndex != null && parsed.close.charIndex != null
375
+ ? formatSyntaxError(msg, spans, parsed.close.spanIndex, parsed.close.charIndex)
376
+ : msg);
353
377
  }
354
378
  const children = [];
355
379
  for (let i = 0; i < parsed.children.length; i++) {
356
380
  const child = parsed.children[i];
357
- children.push(child.type === "element" ? build(child) : child.value);
381
+ children.push(child.type === "element" ? build(child, spans) : child.value);
358
382
  }
359
383
  let props = parsed.props.length ? {} : null;
360
384
  for (let i = 0; i < parsed.props.length; i++) {
@@ -425,6 +449,46 @@ function formatTagForError(tag) {
425
449
  ? `"${tag}"`
426
450
  : JSON.stringify(tag);
427
451
  }
452
+ function formatSyntaxError(message, spans, spanIndex, charIndex) {
453
+ // Reconstruct full template source with ${} placeholders
454
+ let source = spans[0];
455
+ for (let i = 1; i < spans.length; i++) {
456
+ source += "${}" + spans[i];
457
+ }
458
+ // Compute absolute offset
459
+ let offset = 0;
460
+ for (let i = 0; i < spanIndex; i++) {
461
+ offset += spans[i].length + 3; // 3 = "${}".length
462
+ }
463
+ offset += charIndex;
464
+ // Split into lines and find line/column
465
+ const lines = source.split(/\n/);
466
+ let line = 0;
467
+ let col = offset;
468
+ for (let i = 0; i < lines.length; i++) {
469
+ if (col <= lines[i].length) {
470
+ line = i;
471
+ break;
472
+ }
473
+ col -= lines[i].length + 1; // +1 for the newline
474
+ }
475
+ // Build context lines
476
+ let result = `${message}\n\n`;
477
+ const start = Math.max(0, line - 1);
478
+ const end = Math.min(lines.length - 1, line + 1);
479
+ const gutterWidth = String(end + 1).length;
480
+ for (let i = start; i <= end; i++) {
481
+ const num = String(i + 1).padStart(gutterWidth);
482
+ if (i === line) {
483
+ result += `> ${num} | ${lines[i]}\n`;
484
+ result += ` ${" ".repeat(gutterWidth)} | ${" ".repeat(col)}^\n`;
485
+ }
486
+ else {
487
+ result += ` ${num} | ${lines[i]}\n`;
488
+ }
489
+ }
490
+ return result.trimEnd();
491
+ }
428
492
 
429
- export { html, jsx };
493
+ export { html, jsx, parse };
430
494
  //# sourceMappingURL=jsx-tag.js.map