@lucidkiln/core 1.7.1 → 1.9.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/CHANGELOG.md +44 -0
- package/dist/ast-DzzSn9tS.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/{environment-BQipJ3kg.d.ts → environment-DcH713WK.d.ts} +12 -3
- package/dist/environment-DcH713WK.d.ts.map +1 -0
- package/dist/{format-Cgjx6D1j.js → format-B5w2QhSr.js} +272 -24
- package/dist/format-B5w2QhSr.js.map +1 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +441 -1366
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{parser-BZpRlGWi.js → parser-CRWl5Lka.js} +131 -64
- package/dist/parser-CRWl5Lka.js.map +1 -0
- package/dist/{source-DxHQeBEo.js → source-DcWmJzQW.js} +1259 -34
- package/dist/source-DcWmJzQW.js.map +1 -0
- package/dist/syntax.js +1 -1
- package/package.json +1 -1
- package/dist/environment-BQipJ3kg.d.ts.map +0 -1
- package/dist/format-Cgjx6D1j.js.map +0 -1
- package/dist/parser-BZpRlGWi.js.map +0 -1
- package/dist/source-DxHQeBEo.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as contentStart } from "./parser-
|
|
1
|
+
import { n as contentStart } from "./parser-CRWl5Lka.js";
|
|
2
2
|
//#region src/errors.ts
|
|
3
3
|
/** Creates a diagnostic for a span of a source. */
|
|
4
4
|
const createDiagnostic = (source, code, message, span, severity = "error") => ({
|
|
@@ -145,6 +145,1116 @@ const resolveTemplateName = (name, from) => {
|
|
|
145
145
|
return segments.join("/");
|
|
146
146
|
};
|
|
147
147
|
//#endregion
|
|
148
|
+
//#region src/html/data.ts
|
|
149
|
+
/** Obsolete elements in the HTML standard, by what to use instead. */
|
|
150
|
+
const OBSOLETE = new Map(Object.entries({
|
|
151
|
+
"Use <abbr> instead": ["acronym"],
|
|
152
|
+
"Use <object> or <embed> instead": ["applet"],
|
|
153
|
+
"Use CSS instead": [
|
|
154
|
+
"basefont",
|
|
155
|
+
"big",
|
|
156
|
+
"blink",
|
|
157
|
+
"center",
|
|
158
|
+
"font",
|
|
159
|
+
"marquee",
|
|
160
|
+
"multicol",
|
|
161
|
+
"nobr",
|
|
162
|
+
"spacer"
|
|
163
|
+
],
|
|
164
|
+
"Use <audio> instead": ["bgsound"],
|
|
165
|
+
"Use <ul> instead": ["dir"],
|
|
166
|
+
"Use <iframe>, or a layout with CSS, instead": [
|
|
167
|
+
"frame",
|
|
168
|
+
"frameset",
|
|
169
|
+
"noframes"
|
|
170
|
+
],
|
|
171
|
+
"Use a form with a text field instead": ["isindex"],
|
|
172
|
+
"Use the Web Crypto API instead": ["keygen"],
|
|
173
|
+
"Use <pre> and <code> instead": [
|
|
174
|
+
"listing",
|
|
175
|
+
"plaintext",
|
|
176
|
+
"xmp"
|
|
177
|
+
],
|
|
178
|
+
"Use a <button> inside <menu> instead": ["menuitem"],
|
|
179
|
+
"Remove it": ["nextid"],
|
|
180
|
+
"Use fallback content inside <object> instead": ["noembed"],
|
|
181
|
+
"Use attributes on <object> instead": ["param"],
|
|
182
|
+
"Use <ruby> with <rt> instead": ["rb", "rtc"],
|
|
183
|
+
"Use <s>, or <del> for removed text, instead": ["strike"],
|
|
184
|
+
"Use <code>, <kbd> or <samp> instead": ["tt"]
|
|
185
|
+
}).flatMap(([advice, names]) => names.map((name) => [name, advice])));
|
|
186
|
+
/** States and properties from WAI-ARIA 1.2, plus those the 1.3 draft adds. */
|
|
187
|
+
const ARIA_ATTRIBUTES = new Set([
|
|
188
|
+
"activedescendant",
|
|
189
|
+
"atomic",
|
|
190
|
+
"autocomplete",
|
|
191
|
+
"braillelabel",
|
|
192
|
+
"brailleroledescription",
|
|
193
|
+
"busy",
|
|
194
|
+
"checked",
|
|
195
|
+
"colcount",
|
|
196
|
+
"colindex",
|
|
197
|
+
"colindextext",
|
|
198
|
+
"colspan",
|
|
199
|
+
"controls",
|
|
200
|
+
"current",
|
|
201
|
+
"describedby",
|
|
202
|
+
"description",
|
|
203
|
+
"details",
|
|
204
|
+
"disabled",
|
|
205
|
+
"dropeffect",
|
|
206
|
+
"errormessage",
|
|
207
|
+
"expanded",
|
|
208
|
+
"flowto",
|
|
209
|
+
"grabbed",
|
|
210
|
+
"haspopup",
|
|
211
|
+
"hidden",
|
|
212
|
+
"invalid",
|
|
213
|
+
"keyshortcuts",
|
|
214
|
+
"label",
|
|
215
|
+
"labelledby",
|
|
216
|
+
"level",
|
|
217
|
+
"live",
|
|
218
|
+
"modal",
|
|
219
|
+
"multiline",
|
|
220
|
+
"multiselectable",
|
|
221
|
+
"orientation",
|
|
222
|
+
"owns",
|
|
223
|
+
"placeholder",
|
|
224
|
+
"posinset",
|
|
225
|
+
"pressed",
|
|
226
|
+
"readonly",
|
|
227
|
+
"relevant",
|
|
228
|
+
"required",
|
|
229
|
+
"roledescription",
|
|
230
|
+
"rowcount",
|
|
231
|
+
"rowindex",
|
|
232
|
+
"rowindextext",
|
|
233
|
+
"rowspan",
|
|
234
|
+
"selected",
|
|
235
|
+
"setsize",
|
|
236
|
+
"sort",
|
|
237
|
+
"valuemax",
|
|
238
|
+
"valuemin",
|
|
239
|
+
"valuenow",
|
|
240
|
+
"valuetext"
|
|
241
|
+
].map((name) => `aria-${name}`));
|
|
242
|
+
/** Roles from WAI-ARIA 1.2, plus those the 1.3 draft adds. */
|
|
243
|
+
const ROLES = /* @__PURE__ */ new Set([
|
|
244
|
+
"alert",
|
|
245
|
+
"alertdialog",
|
|
246
|
+
"application",
|
|
247
|
+
"article",
|
|
248
|
+
"banner",
|
|
249
|
+
"blockquote",
|
|
250
|
+
"button",
|
|
251
|
+
"caption",
|
|
252
|
+
"cell",
|
|
253
|
+
"checkbox",
|
|
254
|
+
"code",
|
|
255
|
+
"columnheader",
|
|
256
|
+
"combobox",
|
|
257
|
+
"comment",
|
|
258
|
+
"complementary",
|
|
259
|
+
"contentinfo",
|
|
260
|
+
"definition",
|
|
261
|
+
"deletion",
|
|
262
|
+
"dialog",
|
|
263
|
+
"directory",
|
|
264
|
+
"document",
|
|
265
|
+
"emphasis",
|
|
266
|
+
"feed",
|
|
267
|
+
"figure",
|
|
268
|
+
"form",
|
|
269
|
+
"generic",
|
|
270
|
+
"grid",
|
|
271
|
+
"gridcell",
|
|
272
|
+
"group",
|
|
273
|
+
"heading",
|
|
274
|
+
"image",
|
|
275
|
+
"img",
|
|
276
|
+
"insertion",
|
|
277
|
+
"link",
|
|
278
|
+
"list",
|
|
279
|
+
"listbox",
|
|
280
|
+
"listitem",
|
|
281
|
+
"log",
|
|
282
|
+
"main",
|
|
283
|
+
"mark",
|
|
284
|
+
"marquee",
|
|
285
|
+
"math",
|
|
286
|
+
"menu",
|
|
287
|
+
"menubar",
|
|
288
|
+
"menuitem",
|
|
289
|
+
"menuitemcheckbox",
|
|
290
|
+
"menuitemradio",
|
|
291
|
+
"meter",
|
|
292
|
+
"navigation",
|
|
293
|
+
"none",
|
|
294
|
+
"note",
|
|
295
|
+
"option",
|
|
296
|
+
"paragraph",
|
|
297
|
+
"presentation",
|
|
298
|
+
"progressbar",
|
|
299
|
+
"radio",
|
|
300
|
+
"radiogroup",
|
|
301
|
+
"region",
|
|
302
|
+
"row",
|
|
303
|
+
"rowgroup",
|
|
304
|
+
"rowheader",
|
|
305
|
+
"scrollbar",
|
|
306
|
+
"search",
|
|
307
|
+
"searchbox",
|
|
308
|
+
"sectionfooter",
|
|
309
|
+
"sectionheader",
|
|
310
|
+
"separator",
|
|
311
|
+
"slider",
|
|
312
|
+
"spinbutton",
|
|
313
|
+
"status",
|
|
314
|
+
"strong",
|
|
315
|
+
"subscript",
|
|
316
|
+
"suggestion",
|
|
317
|
+
"superscript",
|
|
318
|
+
"switch",
|
|
319
|
+
"tab",
|
|
320
|
+
"table",
|
|
321
|
+
"tablist",
|
|
322
|
+
"tabpanel",
|
|
323
|
+
"term",
|
|
324
|
+
"textbox",
|
|
325
|
+
"time",
|
|
326
|
+
"timer",
|
|
327
|
+
"toolbar",
|
|
328
|
+
"tooltip",
|
|
329
|
+
"tree",
|
|
330
|
+
"treegrid",
|
|
331
|
+
"treeitem"
|
|
332
|
+
]);
|
|
333
|
+
/** Roles that only organise the ARIA spec. Pages must not use them. */
|
|
334
|
+
const ABSTRACT_ROLES = /* @__PURE__ */ new Set([
|
|
335
|
+
"command",
|
|
336
|
+
"composite",
|
|
337
|
+
"input",
|
|
338
|
+
"landmark",
|
|
339
|
+
"range",
|
|
340
|
+
"roletype",
|
|
341
|
+
"section",
|
|
342
|
+
"sectionhead",
|
|
343
|
+
"select",
|
|
344
|
+
"structure",
|
|
345
|
+
"widget",
|
|
346
|
+
"window"
|
|
347
|
+
]);
|
|
348
|
+
/** Elements whose content is text, so tags inside them aren't elements. */
|
|
349
|
+
const RAW_TEXT = /* @__PURE__ */ new Set([
|
|
350
|
+
"script",
|
|
351
|
+
"style",
|
|
352
|
+
"textarea",
|
|
353
|
+
"title",
|
|
354
|
+
"xmp",
|
|
355
|
+
"iframe",
|
|
356
|
+
"noembed",
|
|
357
|
+
"noframes",
|
|
358
|
+
"plaintext"
|
|
359
|
+
]);
|
|
360
|
+
/** Elements whose content follows SVG or MathML rules instead of HTML's. */
|
|
361
|
+
const FOREIGN = /* @__PURE__ */ new Set(["svg", "math"]);
|
|
362
|
+
/** Elements with no content or end tag. */
|
|
363
|
+
const VOID = /* @__PURE__ */ new Set([
|
|
364
|
+
"area",
|
|
365
|
+
"base",
|
|
366
|
+
"basefont",
|
|
367
|
+
"bgsound",
|
|
368
|
+
"br",
|
|
369
|
+
"col",
|
|
370
|
+
"embed",
|
|
371
|
+
"frame",
|
|
372
|
+
"hr",
|
|
373
|
+
"img",
|
|
374
|
+
"input",
|
|
375
|
+
"keygen",
|
|
376
|
+
"link",
|
|
377
|
+
"meta",
|
|
378
|
+
"param",
|
|
379
|
+
"source",
|
|
380
|
+
"track",
|
|
381
|
+
"wbr"
|
|
382
|
+
]);
|
|
383
|
+
/** What each obsolete attribute is replaced by, by element. Attributes missing from an element's list use CSS. */
|
|
384
|
+
const CSS = "Use CSS instead";
|
|
385
|
+
const REMOVE = "Remove it";
|
|
386
|
+
const USE_ID = "Use id instead";
|
|
387
|
+
const presentational = (...names) => Object.fromEntries(names.map((name) => [name, CSS]));
|
|
388
|
+
const cellAttributes = presentational("align", "bgcolor", "char", "charoff", "height", "nowrap", "valign", "width");
|
|
389
|
+
const rowGroupAttributes = presentational("align", "char", "charoff", "valign");
|
|
390
|
+
const OBSOLETE_ATTRIBUTES = {
|
|
391
|
+
a: {
|
|
392
|
+
charset: REMOVE,
|
|
393
|
+
coords: "Use <area> instead",
|
|
394
|
+
methods: REMOVE,
|
|
395
|
+
name: USE_ID,
|
|
396
|
+
rev: "Use rel instead",
|
|
397
|
+
shape: "Use <area> instead",
|
|
398
|
+
urn: REMOVE
|
|
399
|
+
},
|
|
400
|
+
area: {
|
|
401
|
+
nohref: "Leave out href instead",
|
|
402
|
+
type: REMOVE
|
|
403
|
+
},
|
|
404
|
+
body: presentational("alink", "background", "bgcolor", "bottommargin", "leftmargin", "link", "marginbottom", "marginheight", "marginleft", "marginright", "margintop", "marginwidth", "rightmargin", "text", "topmargin", "vlink"),
|
|
405
|
+
br: presentational("clear"),
|
|
406
|
+
caption: presentational("align"),
|
|
407
|
+
col: presentational("align", "char", "charoff", "valign", "width"),
|
|
408
|
+
div: presentational("align"),
|
|
409
|
+
dl: presentational("compact"),
|
|
410
|
+
embed: {
|
|
411
|
+
...presentational("align", "hspace", "vspace"),
|
|
412
|
+
name: USE_ID
|
|
413
|
+
},
|
|
414
|
+
head: { profile: REMOVE },
|
|
415
|
+
hr: presentational("align", "color", "noshade", "size", "width"),
|
|
416
|
+
html: {
|
|
417
|
+
manifest: "Use a service worker instead",
|
|
418
|
+
version: REMOVE
|
|
419
|
+
},
|
|
420
|
+
...Object.fromEntries([
|
|
421
|
+
"h1",
|
|
422
|
+
"h2",
|
|
423
|
+
"h3",
|
|
424
|
+
"h4",
|
|
425
|
+
"h5",
|
|
426
|
+
"h6",
|
|
427
|
+
"legend",
|
|
428
|
+
"p"
|
|
429
|
+
].map((name) => [name, presentational("align")])),
|
|
430
|
+
iframe: {
|
|
431
|
+
...presentational("align", "allowtransparency", "frameborder", "framespacing", "hspace", "marginheight", "marginwidth", "scrolling", "vspace"),
|
|
432
|
+
longdesc: "Link to the description instead"
|
|
433
|
+
},
|
|
434
|
+
img: {
|
|
435
|
+
...presentational("align", "border", "hspace", "vspace"),
|
|
436
|
+
longdesc: "Link to the description instead",
|
|
437
|
+
lowsrc: "Use srcset instead",
|
|
438
|
+
name: USE_ID
|
|
439
|
+
},
|
|
440
|
+
input: {
|
|
441
|
+
...presentational("align", "hspace", "vspace"),
|
|
442
|
+
ismap: "Use <img> for image maps instead",
|
|
443
|
+
usemap: "Use <img> for image maps instead"
|
|
444
|
+
},
|
|
445
|
+
li: presentational("type"),
|
|
446
|
+
link: {
|
|
447
|
+
charset: REMOVE,
|
|
448
|
+
rev: "Use rel instead",
|
|
449
|
+
target: REMOVE
|
|
450
|
+
},
|
|
451
|
+
menu: presentational("compact"),
|
|
452
|
+
meta: { scheme: REMOVE },
|
|
453
|
+
object: {
|
|
454
|
+
...presentational("align", "border", "hspace", "vspace"),
|
|
455
|
+
archive: "Use data and type instead",
|
|
456
|
+
classid: "Use data and type instead",
|
|
457
|
+
code: "Use data and type instead",
|
|
458
|
+
codebase: "Use data and type instead",
|
|
459
|
+
codetype: "Use data and type instead",
|
|
460
|
+
declare: REMOVE,
|
|
461
|
+
standby: REMOVE
|
|
462
|
+
},
|
|
463
|
+
ol: presentational("compact"),
|
|
464
|
+
option: { name: USE_ID },
|
|
465
|
+
pre: presentational("width"),
|
|
466
|
+
script: {
|
|
467
|
+
charset: REMOVE,
|
|
468
|
+
event: REMOVE,
|
|
469
|
+
for: REMOVE,
|
|
470
|
+
language: REMOVE
|
|
471
|
+
},
|
|
472
|
+
table: {
|
|
473
|
+
...presentational("align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "width"),
|
|
474
|
+
summary: "Use <caption> instead"
|
|
475
|
+
},
|
|
476
|
+
tbody: rowGroupAttributes,
|
|
477
|
+
thead: rowGroupAttributes,
|
|
478
|
+
tfoot: rowGroupAttributes,
|
|
479
|
+
tr: {
|
|
480
|
+
...rowGroupAttributes,
|
|
481
|
+
bgcolor: CSS
|
|
482
|
+
},
|
|
483
|
+
td: {
|
|
484
|
+
...cellAttributes,
|
|
485
|
+
abbr: "Use <th> with abbr instead",
|
|
486
|
+
axis: "Use scope on <th> instead",
|
|
487
|
+
scope: "Use <th> instead"
|
|
488
|
+
},
|
|
489
|
+
th: {
|
|
490
|
+
...cellAttributes,
|
|
491
|
+
axis: "Use scope instead"
|
|
492
|
+
},
|
|
493
|
+
ul: presentational("compact", "type")
|
|
494
|
+
};
|
|
495
|
+
const FORM_METHODS = [
|
|
496
|
+
"get",
|
|
497
|
+
"post",
|
|
498
|
+
"dialog"
|
|
499
|
+
];
|
|
500
|
+
const ENCTYPES = [
|
|
501
|
+
"application/x-www-form-urlencoded",
|
|
502
|
+
"multipart/form-data",
|
|
503
|
+
"text/plain"
|
|
504
|
+
];
|
|
505
|
+
const TARGETS = [
|
|
506
|
+
"_blank",
|
|
507
|
+
"_parent",
|
|
508
|
+
"_self",
|
|
509
|
+
"_top",
|
|
510
|
+
"_unfencedTop"
|
|
511
|
+
];
|
|
512
|
+
/** A target that isn't a keyword is a name, and names can't start with `_`. */
|
|
513
|
+
const targetName = (value) => !value.startsWith("_");
|
|
514
|
+
const ATTRIBUTE_VALUES = {
|
|
515
|
+
type: [
|
|
516
|
+
{
|
|
517
|
+
on: ["input"],
|
|
518
|
+
values: [
|
|
519
|
+
"button",
|
|
520
|
+
"checkbox",
|
|
521
|
+
"color",
|
|
522
|
+
"date",
|
|
523
|
+
"datetime-local",
|
|
524
|
+
"email",
|
|
525
|
+
"file",
|
|
526
|
+
"hidden",
|
|
527
|
+
"image",
|
|
528
|
+
"month",
|
|
529
|
+
"number",
|
|
530
|
+
"password",
|
|
531
|
+
"radio",
|
|
532
|
+
"range",
|
|
533
|
+
"reset",
|
|
534
|
+
"search",
|
|
535
|
+
"submit",
|
|
536
|
+
"tel",
|
|
537
|
+
"text",
|
|
538
|
+
"time",
|
|
539
|
+
"url",
|
|
540
|
+
"week"
|
|
541
|
+
]
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
on: ["button"],
|
|
545
|
+
values: [
|
|
546
|
+
"button",
|
|
547
|
+
"reset",
|
|
548
|
+
"submit"
|
|
549
|
+
]
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
on: ["ol"],
|
|
553
|
+
values: [
|
|
554
|
+
"1",
|
|
555
|
+
"a",
|
|
556
|
+
"A",
|
|
557
|
+
"i",
|
|
558
|
+
"I"
|
|
559
|
+
],
|
|
560
|
+
caseSensitive: true
|
|
561
|
+
}
|
|
562
|
+
],
|
|
563
|
+
method: [{
|
|
564
|
+
on: ["form"],
|
|
565
|
+
values: FORM_METHODS
|
|
566
|
+
}],
|
|
567
|
+
formmethod: [{
|
|
568
|
+
on: ["button", "input"],
|
|
569
|
+
values: FORM_METHODS
|
|
570
|
+
}],
|
|
571
|
+
enctype: [{
|
|
572
|
+
on: ["form"],
|
|
573
|
+
values: ENCTYPES
|
|
574
|
+
}],
|
|
575
|
+
formenctype: [{
|
|
576
|
+
on: ["button", "input"],
|
|
577
|
+
values: ENCTYPES
|
|
578
|
+
}],
|
|
579
|
+
autocomplete: [{
|
|
580
|
+
on: ["form"],
|
|
581
|
+
values: ["on", "off"]
|
|
582
|
+
}],
|
|
583
|
+
loading: [{
|
|
584
|
+
on: ["img", "iframe"],
|
|
585
|
+
values: ["eager", "lazy"]
|
|
586
|
+
}],
|
|
587
|
+
decoding: [{
|
|
588
|
+
on: ["img"],
|
|
589
|
+
values: [
|
|
590
|
+
"async",
|
|
591
|
+
"auto",
|
|
592
|
+
"sync"
|
|
593
|
+
]
|
|
594
|
+
}],
|
|
595
|
+
fetchpriority: [{
|
|
596
|
+
on: [
|
|
597
|
+
"img",
|
|
598
|
+
"iframe",
|
|
599
|
+
"link",
|
|
600
|
+
"script"
|
|
601
|
+
],
|
|
602
|
+
values: [
|
|
603
|
+
"auto",
|
|
604
|
+
"high",
|
|
605
|
+
"low"
|
|
606
|
+
]
|
|
607
|
+
}],
|
|
608
|
+
crossorigin: [{
|
|
609
|
+
on: [
|
|
610
|
+
"audio",
|
|
611
|
+
"img",
|
|
612
|
+
"link",
|
|
613
|
+
"script",
|
|
614
|
+
"video"
|
|
615
|
+
],
|
|
616
|
+
values: [
|
|
617
|
+
"",
|
|
618
|
+
"anonymous",
|
|
619
|
+
"use-credentials"
|
|
620
|
+
]
|
|
621
|
+
}],
|
|
622
|
+
referrerpolicy: [{
|
|
623
|
+
on: [
|
|
624
|
+
"a",
|
|
625
|
+
"area",
|
|
626
|
+
"iframe",
|
|
627
|
+
"img",
|
|
628
|
+
"link",
|
|
629
|
+
"script"
|
|
630
|
+
],
|
|
631
|
+
values: [
|
|
632
|
+
"",
|
|
633
|
+
"no-referrer",
|
|
634
|
+
"no-referrer-when-downgrade",
|
|
635
|
+
"origin",
|
|
636
|
+
"origin-when-cross-origin",
|
|
637
|
+
"same-origin",
|
|
638
|
+
"strict-origin",
|
|
639
|
+
"strict-origin-when-cross-origin",
|
|
640
|
+
"unsafe-url"
|
|
641
|
+
]
|
|
642
|
+
}],
|
|
643
|
+
target: [{
|
|
644
|
+
on: [
|
|
645
|
+
"a",
|
|
646
|
+
"area",
|
|
647
|
+
"base",
|
|
648
|
+
"form"
|
|
649
|
+
],
|
|
650
|
+
values: TARGETS,
|
|
651
|
+
other: targetName
|
|
652
|
+
}],
|
|
653
|
+
formtarget: [{
|
|
654
|
+
on: ["button", "input"],
|
|
655
|
+
values: TARGETS,
|
|
656
|
+
other: targetName
|
|
657
|
+
}],
|
|
658
|
+
preload: [{
|
|
659
|
+
on: ["audio", "video"],
|
|
660
|
+
values: [
|
|
661
|
+
"",
|
|
662
|
+
"auto",
|
|
663
|
+
"metadata",
|
|
664
|
+
"none"
|
|
665
|
+
]
|
|
666
|
+
}],
|
|
667
|
+
scope: [{
|
|
668
|
+
on: ["th"],
|
|
669
|
+
values: [
|
|
670
|
+
"col",
|
|
671
|
+
"colgroup",
|
|
672
|
+
"row",
|
|
673
|
+
"rowgroup"
|
|
674
|
+
]
|
|
675
|
+
}],
|
|
676
|
+
kind: [{
|
|
677
|
+
on: ["track"],
|
|
678
|
+
values: [
|
|
679
|
+
"captions",
|
|
680
|
+
"chapters",
|
|
681
|
+
"descriptions",
|
|
682
|
+
"metadata",
|
|
683
|
+
"subtitles"
|
|
684
|
+
]
|
|
685
|
+
}],
|
|
686
|
+
wrap: [{
|
|
687
|
+
on: ["textarea"],
|
|
688
|
+
values: ["hard", "soft"]
|
|
689
|
+
}],
|
|
690
|
+
shape: [{
|
|
691
|
+
on: ["area"],
|
|
692
|
+
values: [
|
|
693
|
+
"circle",
|
|
694
|
+
"default",
|
|
695
|
+
"poly",
|
|
696
|
+
"rect"
|
|
697
|
+
]
|
|
698
|
+
}],
|
|
699
|
+
capture: [{
|
|
700
|
+
on: ["input"],
|
|
701
|
+
values: ["environment", "user"]
|
|
702
|
+
}],
|
|
703
|
+
sandbox: [{
|
|
704
|
+
on: ["iframe"],
|
|
705
|
+
tokens: true,
|
|
706
|
+
values: [
|
|
707
|
+
"allow-downloads",
|
|
708
|
+
"allow-forms",
|
|
709
|
+
"allow-modals",
|
|
710
|
+
"allow-orientation-lock",
|
|
711
|
+
"allow-pointer-lock",
|
|
712
|
+
"allow-popups",
|
|
713
|
+
"allow-popups-to-escape-sandbox",
|
|
714
|
+
"allow-presentation",
|
|
715
|
+
"allow-same-origin",
|
|
716
|
+
"allow-scripts",
|
|
717
|
+
"allow-storage-access-by-user-activation",
|
|
718
|
+
"allow-top-navigation",
|
|
719
|
+
"allow-top-navigation-by-user-activation",
|
|
720
|
+
"allow-top-navigation-to-custom-protocols"
|
|
721
|
+
]
|
|
722
|
+
}],
|
|
723
|
+
blocking: [{
|
|
724
|
+
on: [
|
|
725
|
+
"link",
|
|
726
|
+
"script",
|
|
727
|
+
"style"
|
|
728
|
+
],
|
|
729
|
+
tokens: true,
|
|
730
|
+
values: ["render"]
|
|
731
|
+
}],
|
|
732
|
+
popovertargetaction: [{
|
|
733
|
+
on: ["button", "input"],
|
|
734
|
+
values: [
|
|
735
|
+
"hide",
|
|
736
|
+
"show",
|
|
737
|
+
"toggle"
|
|
738
|
+
]
|
|
739
|
+
}],
|
|
740
|
+
command: [{
|
|
741
|
+
on: ["button"],
|
|
742
|
+
values: [
|
|
743
|
+
"close",
|
|
744
|
+
"hide-popover",
|
|
745
|
+
"request-close",
|
|
746
|
+
"show-modal",
|
|
747
|
+
"show-popover",
|
|
748
|
+
"toggle-popover"
|
|
749
|
+
],
|
|
750
|
+
other: (value) => value.startsWith("--")
|
|
751
|
+
}],
|
|
752
|
+
shadowrootmode: [{
|
|
753
|
+
on: ["template"],
|
|
754
|
+
values: ["closed", "open"]
|
|
755
|
+
}],
|
|
756
|
+
dir: [{
|
|
757
|
+
on: "*",
|
|
758
|
+
values: [
|
|
759
|
+
"auto",
|
|
760
|
+
"ltr",
|
|
761
|
+
"rtl"
|
|
762
|
+
]
|
|
763
|
+
}],
|
|
764
|
+
hidden: [{
|
|
765
|
+
on: "*",
|
|
766
|
+
values: [
|
|
767
|
+
"",
|
|
768
|
+
"hidden",
|
|
769
|
+
"until-found"
|
|
770
|
+
]
|
|
771
|
+
}],
|
|
772
|
+
contenteditable: [{
|
|
773
|
+
on: "*",
|
|
774
|
+
values: [
|
|
775
|
+
"",
|
|
776
|
+
"false",
|
|
777
|
+
"plaintext-only",
|
|
778
|
+
"true"
|
|
779
|
+
]
|
|
780
|
+
}],
|
|
781
|
+
draggable: [{
|
|
782
|
+
on: "*",
|
|
783
|
+
values: ["false", "true"]
|
|
784
|
+
}],
|
|
785
|
+
spellcheck: [{
|
|
786
|
+
on: "*",
|
|
787
|
+
values: [
|
|
788
|
+
"",
|
|
789
|
+
"false",
|
|
790
|
+
"true"
|
|
791
|
+
]
|
|
792
|
+
}],
|
|
793
|
+
translate: [{
|
|
794
|
+
on: "*",
|
|
795
|
+
values: [
|
|
796
|
+
"",
|
|
797
|
+
"no",
|
|
798
|
+
"yes"
|
|
799
|
+
]
|
|
800
|
+
}],
|
|
801
|
+
autocapitalize: [{
|
|
802
|
+
on: "*",
|
|
803
|
+
values: [
|
|
804
|
+
"characters",
|
|
805
|
+
"none",
|
|
806
|
+
"off",
|
|
807
|
+
"on",
|
|
808
|
+
"sentences",
|
|
809
|
+
"words"
|
|
810
|
+
]
|
|
811
|
+
}],
|
|
812
|
+
inputmode: [{
|
|
813
|
+
on: "*",
|
|
814
|
+
values: [
|
|
815
|
+
"decimal",
|
|
816
|
+
"email",
|
|
817
|
+
"none",
|
|
818
|
+
"numeric",
|
|
819
|
+
"search",
|
|
820
|
+
"tel",
|
|
821
|
+
"text",
|
|
822
|
+
"url"
|
|
823
|
+
]
|
|
824
|
+
}],
|
|
825
|
+
enterkeyhint: [{
|
|
826
|
+
on: "*",
|
|
827
|
+
values: [
|
|
828
|
+
"done",
|
|
829
|
+
"enter",
|
|
830
|
+
"go",
|
|
831
|
+
"next",
|
|
832
|
+
"previous",
|
|
833
|
+
"search",
|
|
834
|
+
"send"
|
|
835
|
+
]
|
|
836
|
+
}],
|
|
837
|
+
popover: [{
|
|
838
|
+
on: "*",
|
|
839
|
+
values: [
|
|
840
|
+
"",
|
|
841
|
+
"auto",
|
|
842
|
+
"hint",
|
|
843
|
+
"manual"
|
|
844
|
+
]
|
|
845
|
+
}]
|
|
846
|
+
};
|
|
847
|
+
/** Boolean attributes, which are on whenever they are present, by the elements that have them. `*` is any element. */
|
|
848
|
+
const BOOLEAN_ATTRIBUTES = {
|
|
849
|
+
allowfullscreen: ["iframe"],
|
|
850
|
+
async: ["script"],
|
|
851
|
+
autofocus: "*",
|
|
852
|
+
autoplay: ["audio", "video"],
|
|
853
|
+
checked: ["input"],
|
|
854
|
+
controls: ["audio", "video"],
|
|
855
|
+
default: ["track"],
|
|
856
|
+
defer: ["script"],
|
|
857
|
+
disabled: [
|
|
858
|
+
"button",
|
|
859
|
+
"fieldset",
|
|
860
|
+
"input",
|
|
861
|
+
"link",
|
|
862
|
+
"optgroup",
|
|
863
|
+
"option",
|
|
864
|
+
"select",
|
|
865
|
+
"textarea"
|
|
866
|
+
],
|
|
867
|
+
formnovalidate: ["button", "input"],
|
|
868
|
+
inert: "*",
|
|
869
|
+
ismap: ["img"],
|
|
870
|
+
itemscope: "*",
|
|
871
|
+
loop: ["audio", "video"],
|
|
872
|
+
multiple: ["input", "select"],
|
|
873
|
+
muted: ["audio", "video"],
|
|
874
|
+
nomodule: ["script"],
|
|
875
|
+
novalidate: ["form"],
|
|
876
|
+
open: ["details", "dialog"],
|
|
877
|
+
playsinline: ["video"],
|
|
878
|
+
readonly: ["input", "textarea"],
|
|
879
|
+
required: [
|
|
880
|
+
"input",
|
|
881
|
+
"select",
|
|
882
|
+
"textarea"
|
|
883
|
+
],
|
|
884
|
+
reversed: ["ol"],
|
|
885
|
+
selected: ["option"],
|
|
886
|
+
shadowrootclonable: ["template"],
|
|
887
|
+
shadowrootdelegatesfocus: ["template"],
|
|
888
|
+
shadowrootserializable: ["template"]
|
|
889
|
+
};
|
|
890
|
+
/** Roles elements always have, whatever their attributes. Lists are left out; see the docs on `html-redundant-role`. */
|
|
891
|
+
const IMPLICIT_ROLES = {
|
|
892
|
+
article: "article",
|
|
893
|
+
aside: "complementary",
|
|
894
|
+
blockquote: "blockquote",
|
|
895
|
+
button: "button",
|
|
896
|
+
caption: "caption",
|
|
897
|
+
code: "code",
|
|
898
|
+
datalist: "listbox",
|
|
899
|
+
del: "deletion",
|
|
900
|
+
details: "group",
|
|
901
|
+
dfn: "term",
|
|
902
|
+
dialog: "dialog",
|
|
903
|
+
em: "emphasis",
|
|
904
|
+
fieldset: "group",
|
|
905
|
+
figure: "figure",
|
|
906
|
+
h1: "heading",
|
|
907
|
+
h2: "heading",
|
|
908
|
+
h3: "heading",
|
|
909
|
+
h4: "heading",
|
|
910
|
+
h5: "heading",
|
|
911
|
+
h6: "heading",
|
|
912
|
+
hr: "separator",
|
|
913
|
+
html: "document",
|
|
914
|
+
ins: "insertion",
|
|
915
|
+
main: "main",
|
|
916
|
+
meter: "meter",
|
|
917
|
+
nav: "navigation",
|
|
918
|
+
optgroup: "group",
|
|
919
|
+
option: "option",
|
|
920
|
+
output: "status",
|
|
921
|
+
p: "paragraph",
|
|
922
|
+
progress: "progressbar",
|
|
923
|
+
search: "search",
|
|
924
|
+
strong: "strong",
|
|
925
|
+
sub: "subscript",
|
|
926
|
+
sup: "superscript",
|
|
927
|
+
table: "table",
|
|
928
|
+
tbody: "rowgroup",
|
|
929
|
+
textarea: "textbox",
|
|
930
|
+
tfoot: "rowgroup",
|
|
931
|
+
thead: "rowgroup",
|
|
932
|
+
time: "time",
|
|
933
|
+
tr: "row"
|
|
934
|
+
};
|
|
935
|
+
/** The roles `<input>` has for each `type`, when the role doesn't depend on other attributes. */
|
|
936
|
+
const INPUT_ROLES = {
|
|
937
|
+
button: "button",
|
|
938
|
+
checkbox: "checkbox",
|
|
939
|
+
image: "button",
|
|
940
|
+
number: "spinbutton",
|
|
941
|
+
radio: "radio",
|
|
942
|
+
range: "slider",
|
|
943
|
+
reset: "button",
|
|
944
|
+
submit: "button"
|
|
945
|
+
};
|
|
946
|
+
const HEADINGS = /* @__PURE__ */ new Set([
|
|
947
|
+
"h1",
|
|
948
|
+
"h2",
|
|
949
|
+
"h3",
|
|
950
|
+
"h4",
|
|
951
|
+
"h5",
|
|
952
|
+
"h6"
|
|
953
|
+
]);
|
|
954
|
+
/** Elements that aren't phrasing content. Starting one ends an open `<p>`. */
|
|
955
|
+
const FLOW = /* @__PURE__ */ new Set([
|
|
956
|
+
"address",
|
|
957
|
+
"article",
|
|
958
|
+
"aside",
|
|
959
|
+
"blockquote",
|
|
960
|
+
"center",
|
|
961
|
+
"dd",
|
|
962
|
+
"details",
|
|
963
|
+
"dialog",
|
|
964
|
+
"dir",
|
|
965
|
+
"div",
|
|
966
|
+
"dl",
|
|
967
|
+
"dt",
|
|
968
|
+
"fieldset",
|
|
969
|
+
"figcaption",
|
|
970
|
+
"figure",
|
|
971
|
+
"footer",
|
|
972
|
+
"form",
|
|
973
|
+
...HEADINGS,
|
|
974
|
+
"header",
|
|
975
|
+
"hgroup",
|
|
976
|
+
"hr",
|
|
977
|
+
"li",
|
|
978
|
+
"listing",
|
|
979
|
+
"main",
|
|
980
|
+
"menu",
|
|
981
|
+
"nav",
|
|
982
|
+
"ol",
|
|
983
|
+
"p",
|
|
984
|
+
"plaintext",
|
|
985
|
+
"pre",
|
|
986
|
+
"search",
|
|
987
|
+
"section",
|
|
988
|
+
"summary",
|
|
989
|
+
"table",
|
|
990
|
+
"ul",
|
|
991
|
+
"xmp"
|
|
992
|
+
]);
|
|
993
|
+
/** Elements that only hold phrasing content: text and inline elements. `<p>` is left out, since the browser ends it. */
|
|
994
|
+
const PHRASING_ONLY = /* @__PURE__ */ new Set([
|
|
995
|
+
"abbr",
|
|
996
|
+
"b",
|
|
997
|
+
"bdi",
|
|
998
|
+
"bdo",
|
|
999
|
+
"button",
|
|
1000
|
+
"cite",
|
|
1001
|
+
"code",
|
|
1002
|
+
"data",
|
|
1003
|
+
"dfn",
|
|
1004
|
+
"em",
|
|
1005
|
+
...HEADINGS,
|
|
1006
|
+
"i",
|
|
1007
|
+
"kbd",
|
|
1008
|
+
"label",
|
|
1009
|
+
"legend",
|
|
1010
|
+
"mark",
|
|
1011
|
+
"meter",
|
|
1012
|
+
"output",
|
|
1013
|
+
"pre",
|
|
1014
|
+
"progress",
|
|
1015
|
+
"q",
|
|
1016
|
+
"rp",
|
|
1017
|
+
"rt",
|
|
1018
|
+
"ruby",
|
|
1019
|
+
"s",
|
|
1020
|
+
"samp",
|
|
1021
|
+
"small",
|
|
1022
|
+
"span",
|
|
1023
|
+
"strong",
|
|
1024
|
+
"sub",
|
|
1025
|
+
"summary",
|
|
1026
|
+
"sup",
|
|
1027
|
+
"time",
|
|
1028
|
+
"u",
|
|
1029
|
+
"var"
|
|
1030
|
+
]);
|
|
1031
|
+
/** Elements that take the content model of their parent, so their parent decides what they may hold. */
|
|
1032
|
+
const TRANSPARENT = /* @__PURE__ */ new Set([
|
|
1033
|
+
"a",
|
|
1034
|
+
"audio",
|
|
1035
|
+
"canvas",
|
|
1036
|
+
"del",
|
|
1037
|
+
"ins",
|
|
1038
|
+
"map",
|
|
1039
|
+
"noscript",
|
|
1040
|
+
"object",
|
|
1041
|
+
"slot",
|
|
1042
|
+
"video"
|
|
1043
|
+
]);
|
|
1044
|
+
const SCRIPT_SUPPORTING = ["script", "template"];
|
|
1045
|
+
const TABLE_PARTS = [
|
|
1046
|
+
"caption",
|
|
1047
|
+
"colgroup",
|
|
1048
|
+
"col",
|
|
1049
|
+
"thead",
|
|
1050
|
+
"tbody",
|
|
1051
|
+
"tfoot",
|
|
1052
|
+
"tr"
|
|
1053
|
+
];
|
|
1054
|
+
/**
|
|
1055
|
+
* Elements that browsers show on a line or in a box of their own, so text either side of their tags doesn't join into
|
|
1056
|
+
* one word: `FLOW`, and the parts of tables, selects, fieldsets and the document. Other elements, including custom ones,
|
|
1057
|
+
* show inline.
|
|
1058
|
+
*/
|
|
1059
|
+
const BLOCK = /* @__PURE__ */ new Set([
|
|
1060
|
+
...FLOW,
|
|
1061
|
+
...TABLE_PARTS,
|
|
1062
|
+
"td",
|
|
1063
|
+
"th",
|
|
1064
|
+
"optgroup",
|
|
1065
|
+
"option",
|
|
1066
|
+
"legend",
|
|
1067
|
+
"html",
|
|
1068
|
+
"head",
|
|
1069
|
+
"title",
|
|
1070
|
+
"body"
|
|
1071
|
+
]);
|
|
1072
|
+
/** Elements that only hold certain children. */
|
|
1073
|
+
const ONLY_CHILDREN = {
|
|
1074
|
+
ul: ["li", ...SCRIPT_SUPPORTING],
|
|
1075
|
+
ol: ["li", ...SCRIPT_SUPPORTING],
|
|
1076
|
+
menu: ["li", ...SCRIPT_SUPPORTING],
|
|
1077
|
+
dl: [
|
|
1078
|
+
"dt",
|
|
1079
|
+
"dd",
|
|
1080
|
+
"div",
|
|
1081
|
+
...SCRIPT_SUPPORTING
|
|
1082
|
+
],
|
|
1083
|
+
table: [...TABLE_PARTS, ...SCRIPT_SUPPORTING],
|
|
1084
|
+
thead: ["tr", ...SCRIPT_SUPPORTING],
|
|
1085
|
+
tbody: ["tr", ...SCRIPT_SUPPORTING],
|
|
1086
|
+
tfoot: ["tr", ...SCRIPT_SUPPORTING],
|
|
1087
|
+
tr: [
|
|
1088
|
+
"td",
|
|
1089
|
+
"th",
|
|
1090
|
+
...SCRIPT_SUPPORTING
|
|
1091
|
+
],
|
|
1092
|
+
colgroup: ["col", "template"],
|
|
1093
|
+
picture: [
|
|
1094
|
+
"source",
|
|
1095
|
+
"img",
|
|
1096
|
+
...SCRIPT_SUPPORTING
|
|
1097
|
+
],
|
|
1098
|
+
hgroup: [
|
|
1099
|
+
"p",
|
|
1100
|
+
...HEADINGS,
|
|
1101
|
+
...SCRIPT_SUPPORTING
|
|
1102
|
+
]
|
|
1103
|
+
};
|
|
1104
|
+
/** What `<head>` holds. Anything else ends it, since `</head>` can be left out. */
|
|
1105
|
+
const METADATA = /* @__PURE__ */ new Set([
|
|
1106
|
+
"base",
|
|
1107
|
+
"link",
|
|
1108
|
+
"meta",
|
|
1109
|
+
"noscript",
|
|
1110
|
+
"script",
|
|
1111
|
+
"style",
|
|
1112
|
+
"template",
|
|
1113
|
+
"title"
|
|
1114
|
+
]);
|
|
1115
|
+
/** Elements that must sit directly inside certain parents. */
|
|
1116
|
+
const REQUIRED_PARENTS = {
|
|
1117
|
+
li: [
|
|
1118
|
+
"ul",
|
|
1119
|
+
"ol",
|
|
1120
|
+
"menu"
|
|
1121
|
+
],
|
|
1122
|
+
dt: ["dl", "div"],
|
|
1123
|
+
dd: ["dl", "div"],
|
|
1124
|
+
tr: [
|
|
1125
|
+
"table",
|
|
1126
|
+
"thead",
|
|
1127
|
+
"tbody",
|
|
1128
|
+
"tfoot"
|
|
1129
|
+
],
|
|
1130
|
+
td: ["tr"],
|
|
1131
|
+
th: ["tr"],
|
|
1132
|
+
thead: ["table"],
|
|
1133
|
+
tbody: ["table"],
|
|
1134
|
+
tfoot: ["table"],
|
|
1135
|
+
caption: ["table"],
|
|
1136
|
+
colgroup: ["table"],
|
|
1137
|
+
col: ["colgroup", "table"],
|
|
1138
|
+
summary: ["details"],
|
|
1139
|
+
legend: ["fieldset", "optgroup"],
|
|
1140
|
+
figcaption: ["figure"],
|
|
1141
|
+
source: [
|
|
1142
|
+
"picture",
|
|
1143
|
+
"audio",
|
|
1144
|
+
"video"
|
|
1145
|
+
],
|
|
1146
|
+
track: ["audio", "video"],
|
|
1147
|
+
rt: ["ruby"],
|
|
1148
|
+
rp: ["ruby"]
|
|
1149
|
+
};
|
|
1150
|
+
/** Elements that must be the first child of their parent. */
|
|
1151
|
+
const FIRST_CHILD = {
|
|
1152
|
+
summary: "details",
|
|
1153
|
+
legend: "fieldset"
|
|
1154
|
+
};
|
|
1155
|
+
/** Where `<main>` may go, besides custom elements. */
|
|
1156
|
+
const MAIN_PARENTS = /* @__PURE__ */ new Set([
|
|
1157
|
+
"html",
|
|
1158
|
+
"body",
|
|
1159
|
+
"div",
|
|
1160
|
+
"form",
|
|
1161
|
+
"template"
|
|
1162
|
+
]);
|
|
1163
|
+
/**
|
|
1164
|
+
* The "special" elements of the HTML parser, which stop it looking further for an `<li>`, `<dd>` or `<dt>` to end.
|
|
1165
|
+
* `address`, `div` and `p` are left out, as the parser looks past them.
|
|
1166
|
+
*/
|
|
1167
|
+
const SPECIAL = /* @__PURE__ */ new Set([
|
|
1168
|
+
"applet",
|
|
1169
|
+
"area",
|
|
1170
|
+
"article",
|
|
1171
|
+
"aside",
|
|
1172
|
+
"base",
|
|
1173
|
+
"basefont",
|
|
1174
|
+
"bgsound",
|
|
1175
|
+
"blockquote",
|
|
1176
|
+
"body",
|
|
1177
|
+
"br",
|
|
1178
|
+
"button",
|
|
1179
|
+
"caption",
|
|
1180
|
+
"center",
|
|
1181
|
+
"col",
|
|
1182
|
+
"colgroup",
|
|
1183
|
+
"dd",
|
|
1184
|
+
"details",
|
|
1185
|
+
"dir",
|
|
1186
|
+
"dl",
|
|
1187
|
+
"dt",
|
|
1188
|
+
"embed",
|
|
1189
|
+
"fieldset",
|
|
1190
|
+
"figcaption",
|
|
1191
|
+
"figure",
|
|
1192
|
+
"footer",
|
|
1193
|
+
"form",
|
|
1194
|
+
"frame",
|
|
1195
|
+
"frameset",
|
|
1196
|
+
...HEADINGS,
|
|
1197
|
+
"head",
|
|
1198
|
+
"header",
|
|
1199
|
+
"hgroup",
|
|
1200
|
+
"hr",
|
|
1201
|
+
"html",
|
|
1202
|
+
"iframe",
|
|
1203
|
+
"img",
|
|
1204
|
+
"input",
|
|
1205
|
+
"keygen",
|
|
1206
|
+
"li",
|
|
1207
|
+
"link",
|
|
1208
|
+
"listing",
|
|
1209
|
+
"main",
|
|
1210
|
+
"marquee",
|
|
1211
|
+
"menu",
|
|
1212
|
+
"meta",
|
|
1213
|
+
"nav",
|
|
1214
|
+
"noembed",
|
|
1215
|
+
"noframes",
|
|
1216
|
+
"noscript",
|
|
1217
|
+
"object",
|
|
1218
|
+
"ol",
|
|
1219
|
+
"param",
|
|
1220
|
+
"plaintext",
|
|
1221
|
+
"pre",
|
|
1222
|
+
"script",
|
|
1223
|
+
"search",
|
|
1224
|
+
"section",
|
|
1225
|
+
"select",
|
|
1226
|
+
"source",
|
|
1227
|
+
"style",
|
|
1228
|
+
"summary",
|
|
1229
|
+
"table",
|
|
1230
|
+
"tbody",
|
|
1231
|
+
"td",
|
|
1232
|
+
"template",
|
|
1233
|
+
"textarea",
|
|
1234
|
+
"tfoot",
|
|
1235
|
+
"th",
|
|
1236
|
+
"thead",
|
|
1237
|
+
"title",
|
|
1238
|
+
"tr",
|
|
1239
|
+
"track",
|
|
1240
|
+
"ul",
|
|
1241
|
+
"wbr",
|
|
1242
|
+
"xmp"
|
|
1243
|
+
]);
|
|
1244
|
+
/** Elements that end the search for an open `<p>` or `<button>`: the parser's "button scope". */
|
|
1245
|
+
const BUTTON_SCOPE = /* @__PURE__ */ new Set([
|
|
1246
|
+
"applet",
|
|
1247
|
+
"button",
|
|
1248
|
+
"caption",
|
|
1249
|
+
"html",
|
|
1250
|
+
"marquee",
|
|
1251
|
+
"object",
|
|
1252
|
+
"table",
|
|
1253
|
+
"td",
|
|
1254
|
+
"template",
|
|
1255
|
+
"th"
|
|
1256
|
+
]);
|
|
1257
|
+
//#endregion
|
|
148
1258
|
//#region src/runtime/escape.ts
|
|
149
1259
|
/** Throws a `KilnIssue`, which the call site locates. */
|
|
150
1260
|
const tooLong = (limit) => issue("limit-output", `Escaping made a string longer than the output limit of ${limit}`);
|
|
@@ -295,13 +1405,19 @@ const distance = (a, b) => {
|
|
|
295
1405
|
}
|
|
296
1406
|
return at(a.length, b.length);
|
|
297
1407
|
};
|
|
1408
|
+
/** Names longer than this get no hint, since each candidate costs the product of the two lengths to compare. */
|
|
1409
|
+
const MAX_NAME_LENGTH = 64;
|
|
298
1410
|
/** Returns a `Did you mean "x"?` hint for the closest candidate, or undefined if none is close. */
|
|
299
1411
|
const suggest = (name, candidates) => {
|
|
1412
|
+
if (name.length > MAX_NAME_LENGTH) return void 0;
|
|
1413
|
+
const lower = name.toLowerCase();
|
|
300
1414
|
let best;
|
|
301
1415
|
let bestDistance = Math.max(1, Math.floor(name.length / 3)) + 1;
|
|
302
1416
|
for (const candidate of candidates) {
|
|
303
1417
|
if (candidate === name) continue;
|
|
304
|
-
const
|
|
1418
|
+
const other = candidate.toLowerCase();
|
|
1419
|
+
if (Math.abs(other.length - lower.length) >= bestDistance) continue;
|
|
1420
|
+
const score = distance(lower, other);
|
|
305
1421
|
if (score < bestDistance) {
|
|
306
1422
|
best = candidate;
|
|
307
1423
|
bestDistance = score;
|
|
@@ -398,6 +1514,7 @@ var RenderState = class {
|
|
|
398
1514
|
timeZone;
|
|
399
1515
|
userState;
|
|
400
1516
|
signal;
|
|
1517
|
+
/** Steps counted so far. A streamed island's state counts up to `maxSteps` through the lease it holds. */
|
|
401
1518
|
steps = 0;
|
|
402
1519
|
/** Parts of the render running ahead of a part that waits, and not joined yet. See `ahead.ts`. */
|
|
403
1520
|
ahead = 0;
|
|
@@ -424,6 +1541,13 @@ var RenderState = class {
|
|
|
424
1541
|
streamed = null;
|
|
425
1542
|
/** Whether the `<kiln-island>` script is in the render's output yet. */
|
|
426
1543
|
islandScript = false;
|
|
1544
|
+
/**
|
|
1545
|
+
* For a streamed island's state, the page's state, which lends it steps a lease at a time. Null otherwise. See
|
|
1546
|
+
* `moreSteps`.
|
|
1547
|
+
*/
|
|
1548
|
+
page = null;
|
|
1549
|
+
/** The streamed islands still rendering, which may hold steps this state lent them. Made at the first island. */
|
|
1550
|
+
islandStates = null;
|
|
427
1551
|
constructor(env, globals, maxSteps, maxSize, maxDepth, locale, timeZone, userState, signal) {
|
|
428
1552
|
this.env = env;
|
|
429
1553
|
this.globals = globals;
|
|
@@ -444,12 +1568,16 @@ var RenderState = class {
|
|
|
444
1568
|
*/
|
|
445
1569
|
var Capture = class {
|
|
446
1570
|
outer;
|
|
1571
|
+
parent;
|
|
447
1572
|
section;
|
|
448
1573
|
behind;
|
|
449
1574
|
/** The additions made in it, and the captures started in it, in order. Made when the first is. */
|
|
450
1575
|
additions = null;
|
|
451
|
-
|
|
1576
|
+
/** Whether it is in `outer` yet. One running ahead goes in once the part before it is done. */
|
|
1577
|
+
linked = true;
|
|
1578
|
+
constructor(outer, parent, section, behind) {
|
|
452
1579
|
this.outer = outer;
|
|
1580
|
+
this.parent = parent;
|
|
453
1581
|
this.section = section;
|
|
454
1582
|
this.behind = behind;
|
|
455
1583
|
}
|
|
@@ -462,7 +1590,7 @@ const additionLog = (run) => {
|
|
|
462
1590
|
/** Starts a capture inside `run`'s. With `section`, it is a cached section. */
|
|
463
1591
|
const startCapture = (run, section) => {
|
|
464
1592
|
const outer = additionLog(run);
|
|
465
|
-
const capture = new Capture(outer, section ?? run.capture?.section ?? null, run.capture?.behind ?? null);
|
|
1593
|
+
const capture = new Capture(outer, run.capture, section ?? run.capture?.section ?? null, run.capture?.behind ?? null);
|
|
466
1594
|
outer.push(capture);
|
|
467
1595
|
return capture;
|
|
468
1596
|
};
|
|
@@ -527,6 +1655,7 @@ var Run = class Run {
|
|
|
527
1655
|
timeZone: this.state.timeZone,
|
|
528
1656
|
template: this.template.name,
|
|
529
1657
|
signal: this.state.signal,
|
|
1658
|
+
cached: Boolean(this.capture?.section),
|
|
530
1659
|
tagCache: (...tags) => {
|
|
531
1660
|
const section = this.capture?.section;
|
|
532
1661
|
for (const tag of tags) {
|
|
@@ -591,20 +1720,25 @@ const recordAddition = (run, span, addition, front = false) => {
|
|
|
591
1720
|
/**
|
|
592
1721
|
* After a `flush` closes outlets, fails for content a part running ahead added to one of them before then. Every part
|
|
593
1722
|
* before the flush is done and in the log by now, so content outside the log comes after the flush in the template,
|
|
594
|
-
* where adding to a closed outlet is an error.
|
|
1723
|
+
* where adding to a closed outlet is an error. Content in the log is checked, so it is dropped from `late`.
|
|
595
1724
|
*/
|
|
596
1725
|
const checkLate = (state) => {
|
|
597
1726
|
const late = state.late;
|
|
598
1727
|
if (late === null) return;
|
|
599
|
-
|
|
600
|
-
for (const
|
|
601
|
-
if (
|
|
1728
|
+
let kept = null;
|
|
1729
|
+
for (const entry of late) {
|
|
1730
|
+
if (inLog(entry.run.capture)) continue;
|
|
1731
|
+
const { addition, run, span } = entry;
|
|
602
1732
|
const mark = state.outlets?.get(addition.outlet);
|
|
603
|
-
if (mark
|
|
604
|
-
|
|
605
|
-
throw closedError(run, span, addition.outlet);
|
|
1733
|
+
if (mark !== void 0 && mark.content !== null && (addition.once === null || !state.once?.has(addition.once))) throw closedError(run, span, addition.outlet);
|
|
1734
|
+
(kept ??= []).push(entry);
|
|
606
1735
|
}
|
|
607
|
-
state.late =
|
|
1736
|
+
state.late = kept;
|
|
1737
|
+
};
|
|
1738
|
+
/** Whether additions made in `capture` are in the render's log: it and every capture around it are linked. */
|
|
1739
|
+
const inLog = (capture) => {
|
|
1740
|
+
for (let at = capture; at !== null; at = at.parent) if (!at.linked) return false;
|
|
1741
|
+
return true;
|
|
608
1742
|
};
|
|
609
1743
|
const closedError = (run, span, outlet) => fail(run, span, "outlet-closed", `Outlet "${outlet}" was closed by "flush", so content can't be added to it any more`);
|
|
610
1744
|
/** Closes every outlet reached so far, fixing its content. */
|
|
@@ -663,6 +1797,11 @@ const takeOutput = (state, output) => {
|
|
|
663
1797
|
const NOTHING = () => {};
|
|
664
1798
|
/** Whether parts may start early ahead of a part that waits: the render runs fewer parts ahead than it may. */
|
|
665
1799
|
const mayRunAhead = (state) => state.ahead < 64;
|
|
1800
|
+
/** Puts a capture that ran ahead in its place in the log, once the part before it is done. */
|
|
1801
|
+
const link = (log, capture) => {
|
|
1802
|
+
log.push(capture);
|
|
1803
|
+
capture.linked = true;
|
|
1804
|
+
};
|
|
666
1805
|
/**
|
|
667
1806
|
* Starts `rest` while `pending`, the promise of the part before it, waits, and returns a promise for both. Rejects with
|
|
668
1807
|
* the part's error when it fails, or else with the rest's, after both settle, so a failed render has nothing still
|
|
@@ -673,10 +1812,11 @@ const runAhead = (run, out, pending, rest, span) => {
|
|
|
673
1812
|
state.ahead++;
|
|
674
1813
|
const log = additionLog(run);
|
|
675
1814
|
const outer = run.capture;
|
|
676
|
-
const capture = new Capture(log, outer?.section ?? null, {
|
|
1815
|
+
const capture = new Capture(log, outer, outer?.section ?? null, {
|
|
677
1816
|
part: pending,
|
|
678
1817
|
previous: outer?.behind ?? null
|
|
679
1818
|
});
|
|
1819
|
+
capture.linked = false;
|
|
680
1820
|
const ahead = {
|
|
681
1821
|
s: "",
|
|
682
1822
|
ahead: out.ahead ?? {
|
|
@@ -702,10 +1842,10 @@ const runAhead = (run, out, pending, rest, span) => {
|
|
|
702
1842
|
}
|
|
703
1843
|
};
|
|
704
1844
|
pending.then(() => {
|
|
705
|
-
log
|
|
1845
|
+
link(log, capture);
|
|
706
1846
|
settle();
|
|
707
1847
|
}, (error) => {
|
|
708
|
-
log
|
|
1848
|
+
link(log, capture);
|
|
709
1849
|
failure = { error };
|
|
710
1850
|
settle();
|
|
711
1851
|
});
|
|
@@ -836,7 +1976,7 @@ const passesFrom = (run, out, pending, from, to, pass, span, ahead) => {
|
|
|
836
1976
|
};
|
|
837
1977
|
const done = () => {
|
|
838
1978
|
settled[at] = true;
|
|
839
|
-
while (linked < captures.length && settled[linked] === true) log
|
|
1979
|
+
while (linked < captures.length && settled[linked] === true) link(log, captures[linked++]);
|
|
840
1980
|
if (--left === 0) finish();
|
|
841
1981
|
};
|
|
842
1982
|
part.then(done, (error) => {
|
|
@@ -849,7 +1989,8 @@ const passesFrom = (run, out, pending, from, to, pass, span, ahead) => {
|
|
|
849
1989
|
while (index < to) {
|
|
850
1990
|
const at = segments.length + 1;
|
|
851
1991
|
state.ahead++;
|
|
852
|
-
const capture = new Capture(log, section, behind);
|
|
1992
|
+
const capture = new Capture(log, outer, section, behind);
|
|
1993
|
+
capture.linked = false;
|
|
853
1994
|
const segment = {
|
|
854
1995
|
s: "",
|
|
855
1996
|
ahead: group
|
|
@@ -968,6 +2109,11 @@ const exposedMembers = (proto) => {
|
|
|
968
2109
|
};
|
|
969
2110
|
//#endregion
|
|
970
2111
|
//#region src/runtime/values.ts
|
|
2112
|
+
/**
|
|
2113
|
+
* Lists and hashes nested deeper than this are refused by `json`, `dump`, `urlEncode` and island props, so they can't
|
|
2114
|
+
* overflow the stack.
|
|
2115
|
+
*/
|
|
2116
|
+
const MAX_DATA_DEPTH = 1e3;
|
|
971
2117
|
/** Returned by guarded lookups for a variable or property that does not exist. Never escapes into template values. */
|
|
972
2118
|
const MISSING = Symbol("kiln.missing");
|
|
973
2119
|
/** Checks for an object literal or a null-prototype object, which Kiln treats as a hash. */
|
|
@@ -1116,8 +2262,7 @@ const valueLabel = (value) => {
|
|
|
1116
2262
|
};
|
|
1117
2263
|
/**
|
|
1118
2264
|
* Arrow functions written in templates, each mapped to the version built-ins call. Built-ins that take callbacks accept
|
|
1119
|
-
* only these, never functions found in data.
|
|
1120
|
-
* `hold`.
|
|
2265
|
+
* only these, never functions found in data.
|
|
1121
2266
|
*/
|
|
1122
2267
|
const templateFunctions = /* @__PURE__ */ new WeakMap();
|
|
1123
2268
|
/** A class instance prints only when its class exposes `toString`. */
|
|
@@ -1252,10 +2397,59 @@ const locating = (run, span, produce, host) => {
|
|
|
1252
2397
|
throw locate(run, span, error, host);
|
|
1253
2398
|
}
|
|
1254
2399
|
};
|
|
2400
|
+
/** Starts a streamed island's counting, with no lease yet: its first step takes one. */
|
|
2401
|
+
const lendSteps = (page, island) => {
|
|
2402
|
+
island.page = page;
|
|
2403
|
+
island.steps = island.maxSteps;
|
|
2404
|
+
(page.islandStates ??= []).push(island);
|
|
2405
|
+
};
|
|
2406
|
+
/** Takes back the steps an island holds and hasn't counted, so it takes a new lease at its next step. */
|
|
2407
|
+
const reclaimLease = (page, island) => {
|
|
2408
|
+
const unused = island.maxSteps - island.steps;
|
|
2409
|
+
if (unused > 0) {
|
|
2410
|
+
page.steps -= unused;
|
|
2411
|
+
island.steps = island.maxSteps;
|
|
2412
|
+
}
|
|
2413
|
+
};
|
|
2414
|
+
/** Takes back every lease `page`'s islands hold and haven't counted. */
|
|
2415
|
+
const reclaimLeases = (page) => {
|
|
2416
|
+
for (const island of page.islandStates ?? []) reclaimLease(page, island);
|
|
2417
|
+
};
|
|
2418
|
+
/** Gives back the steps a finished island hasn't counted. */
|
|
2419
|
+
const returnSteps = (island) => {
|
|
2420
|
+
const page = island.page;
|
|
2421
|
+
const islands = page?.islandStates;
|
|
2422
|
+
if (!page || !islands) return;
|
|
2423
|
+
reclaimLease(page, island);
|
|
2424
|
+
const index = islands.indexOf(island);
|
|
2425
|
+
if (index !== -1) islands.splice(index, 1);
|
|
2426
|
+
};
|
|
2427
|
+
/**
|
|
2428
|
+
* Called once `state.steps` passes `maxSteps`. Takes back leases or takes a new one, and returns whether the render
|
|
2429
|
+
* can carry on, with `state.steps` within `maxSteps` again.
|
|
2430
|
+
*/
|
|
2431
|
+
const moreSteps = (state) => {
|
|
2432
|
+
const page = state.page;
|
|
2433
|
+
if (page === null) {
|
|
2434
|
+
if (state.islandStates === null) return false;
|
|
2435
|
+
reclaimLeases(state);
|
|
2436
|
+
return state.steps <= state.maxSteps;
|
|
2437
|
+
}
|
|
2438
|
+
const needed = state.steps - state.maxSteps;
|
|
2439
|
+
if (page.maxSteps - page.steps < needed) reclaimLeases(page);
|
|
2440
|
+
const left = page.maxSteps - page.steps;
|
|
2441
|
+
if (left < needed) return false;
|
|
2442
|
+
const grant = needed + Math.floor((left - needed) / 2);
|
|
2443
|
+
page.steps += grant;
|
|
2444
|
+
state.steps -= grant;
|
|
2445
|
+
return true;
|
|
2446
|
+
};
|
|
2447
|
+
/** The `limit-steps` error, located at `span`. */
|
|
2448
|
+
const stepError = (run, span) => fail(run, span, "limit-steps", `Render stopped after ${run.state.maxSteps} steps`);
|
|
1255
2449
|
/** Counts one step against `maxSteps`, and checks the abort signal. */
|
|
1256
2450
|
const step = (run, span) => {
|
|
1257
2451
|
const state = run.state;
|
|
1258
|
-
if (++state.steps > state.maxSteps) throw
|
|
2452
|
+
if (++state.steps > state.maxSteps && !moreSteps(state)) throw stepError(run, span);
|
|
1259
2453
|
if (state.signal?.aborted) throw fail(run, span, "aborted", "Render was aborted");
|
|
1260
2454
|
};
|
|
1261
2455
|
/**
|
|
@@ -1266,13 +2460,13 @@ const step = (run, span) => {
|
|
|
1266
2460
|
const consume = (run, amount) => {
|
|
1267
2461
|
const state = run.state;
|
|
1268
2462
|
state.steps += amount;
|
|
1269
|
-
if (state.steps > state.maxSteps) issue("limit-steps", `Render stopped after ${state.maxSteps} steps`);
|
|
2463
|
+
if (state.steps > state.maxSteps && !moreSteps(state)) issue("limit-steps", `Render stopped after ${state.maxSteps} steps`);
|
|
1270
2464
|
};
|
|
1271
2465
|
/** `consume`, failing at `span`. For work in proportion to a value's size, such as the variables an include passes. */
|
|
1272
2466
|
const consumeAt = (run, span, amount) => {
|
|
1273
2467
|
const state = run.state;
|
|
1274
2468
|
state.steps += amount;
|
|
1275
|
-
if (state.steps > state.maxSteps) throw
|
|
2469
|
+
if (state.steps > state.maxSteps && !moreSteps(state)) throw stepError(run, span);
|
|
1276
2470
|
};
|
|
1277
2471
|
/** Refuses strings longer than `maxOutputLength`, which could never be printed. */
|
|
1278
2472
|
const checkLength = (run, text) => {
|
|
@@ -1655,8 +2849,6 @@ const readableNames = (target) => {
|
|
|
1655
2849
|
//#region src/builtins/helpers.ts
|
|
1656
2850
|
/** Iterables from the host are read up to this many items, so an endless generator cannot hang a filter. */
|
|
1657
2851
|
const MAX_ITERABLE_ITEMS = 1e6;
|
|
1658
|
-
/** Lists and hashes nested deeper than this are refused by `json`, `dump` and `urlEncode`, so they can't overflow the stack. */
|
|
1659
|
-
const MAX_DATA_DEPTH = 1e3;
|
|
1660
2852
|
/** Refuses data nested deeper than `MAX_DATA_DEPTH`. */
|
|
1661
2853
|
const checkDepth = (depth, what) => {
|
|
1662
2854
|
if (depth > 1e3) issue("too-deep", `"${what}" cannot convert data nested more than ${MAX_DATA_DEPTH} levels deep`);
|
|
@@ -1679,6 +2871,12 @@ const mapContents = (map) => {
|
|
|
1679
2871
|
};
|
|
1680
2872
|
};
|
|
1681
2873
|
/**
|
|
2874
|
+
* A hash key as the name a filter builds a hash, query string or attribute with. A `Map`'s number, boolean and other
|
|
2875
|
+
* primitive keys convert as `String` does. An object or symbol key gives null, and is skipped, as loops with keys
|
|
2876
|
+
* skip it, since converting an object would call its methods.
|
|
2877
|
+
*/
|
|
2878
|
+
const keyName = (key) => typeof key === "string" ? key : typeof key === "object" && key !== null || typeof key === "function" || typeof key === "symbol" ? null : String(key);
|
|
2879
|
+
/**
|
|
1682
2880
|
* Values and keys of anything a filter can treat as a list. Hashes keep their keys.
|
|
1683
2881
|
*
|
|
1684
2882
|
* Every item is charged against `maxSteps`: arrays and hashes before they are read, and iterables such as generators
|
|
@@ -1896,7 +3094,8 @@ const toPlainData = (value, onCycle, { what, charge = () => {}, maxLength = Infi
|
|
|
1896
3094
|
};
|
|
1897
3095
|
charge(keys.length);
|
|
1898
3096
|
for (let i = 0; i < keys.length; i++) {
|
|
1899
|
-
const name =
|
|
3097
|
+
const name = keyName(keys[i]);
|
|
3098
|
+
if (name === null) continue;
|
|
1900
3099
|
const item = convert(values ? values[i] : getAttr(object, name), depth + 1);
|
|
1901
3100
|
if (item !== void 0 && item !== MISSING) {
|
|
1902
3101
|
grow(name.length + (indent === 0 ? 4 : 6 + (depth + 1) * indent));
|
|
@@ -1937,11 +3136,18 @@ const tagEnd = (html, from, lastDouble, lastSingle) => {
|
|
|
1937
3136
|
}
|
|
1938
3137
|
return -1;
|
|
1939
3138
|
};
|
|
3139
|
+
/** The start tag of a `<script>` or `<style>`, whose content browsers never read as HTML. */
|
|
3140
|
+
const RAW_TEXT_START = /<(script|style)[\s/>]/iy;
|
|
3141
|
+
const SCRIPT_END = /<\/script[\s/>]/gi;
|
|
3142
|
+
const STYLE_END = /<\/style[\s/>]/gi;
|
|
1940
3143
|
/**
|
|
1941
3144
|
* Splits HTML into tags and comments, given to `onTag`, and the text between them, given to `onText`, in one linear
|
|
1942
3145
|
* pass. A `<` that doesn't start a tag that closes is text.
|
|
3146
|
+
*
|
|
3147
|
+
* With `rawText`, a `<script>` or `<style>` start tag and its content, up to the end tag or the end of the HTML, go
|
|
3148
|
+
* to `onTag` as one piece, since browsers don't decode entities or find tags in them.
|
|
1943
3149
|
*/
|
|
1944
|
-
const scanHtml = (html, onText, onTag) => {
|
|
3150
|
+
const scanHtml = (html, onText, onTag, rawText = false) => {
|
|
1945
3151
|
const lastDouble = html.lastIndexOf("\"");
|
|
1946
3152
|
const lastSingle = html.lastIndexOf("'");
|
|
1947
3153
|
let index = 0;
|
|
@@ -1950,6 +3156,15 @@ const scanHtml = (html, onText, onTag) => {
|
|
|
1950
3156
|
let tagsCanClose = true;
|
|
1951
3157
|
const tag = (open, end) => {
|
|
1952
3158
|
if (textStart < open) onText(html.slice(textStart, open));
|
|
3159
|
+
if (rawText && (html.charCodeAt(open + 1) | 32) === 115) {
|
|
3160
|
+
RAW_TEXT_START.lastIndex = open;
|
|
3161
|
+
const name = RAW_TEXT_START.exec(html)?.[1];
|
|
3162
|
+
if (name !== void 0) {
|
|
3163
|
+
const closer = name.toLowerCase() === "script" ? SCRIPT_END : STYLE_END;
|
|
3164
|
+
closer.lastIndex = end;
|
|
3165
|
+
end = closer.exec(html)?.index ?? html.length;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
1953
3168
|
onTag(html.slice(open, end));
|
|
1954
3169
|
index = textStart = end;
|
|
1955
3170
|
};
|
|
@@ -2045,12 +3260,12 @@ const decodeSequences = (text, strategy) => {
|
|
|
2045
3260
|
};
|
|
2046
3261
|
/**
|
|
2047
3262
|
* Splits markup into its decoded text and the pieces string filters keep as they are. HTML markup keeps its tags,
|
|
2048
|
-
* comments and the entities the escapers don't write. Other markup is all text.
|
|
3263
|
+
* comments, `<script>` and `<style>` elements, and the entities the escapers don't write. Other markup is all text.
|
|
2049
3264
|
*/
|
|
2050
3265
|
const toPieces = (markup) => {
|
|
2051
3266
|
if (!isHtmlStrategy(markup.strategy)) return [decodeSequences(markup.value, markup.strategy)];
|
|
2052
3267
|
const pieces = [];
|
|
2053
|
-
scanHtml(markup.value, (text) => decodeEntities(text, pieces), (tag) => pieces.push(new Kept(tag)));
|
|
3268
|
+
scanHtml(markup.value, (text) => decodeEntities(text, pieces), (tag) => pieces.push(new Kept(tag)), true);
|
|
2054
3269
|
return pieces;
|
|
2055
3270
|
};
|
|
2056
3271
|
/** Joins pieces back into markup, escaping the text with the markup's strategy. */
|
|
@@ -2228,7 +3443,8 @@ const builtinFunctions = {
|
|
|
2228
3443
|
const { values, keys } = entriesOf(run, target, "attrs");
|
|
2229
3444
|
let html = "";
|
|
2230
3445
|
keys.forEach((key, index) => {
|
|
2231
|
-
const name =
|
|
3446
|
+
const name = keyName(key);
|
|
3447
|
+
if (name === null) return;
|
|
2232
3448
|
if (!ATTRIBUTE_NAME.test(name)) issue("invalid-argument", `"${name}" is not a valid attribute name`);
|
|
2233
3449
|
const value = values[index];
|
|
2234
3450
|
if (value === true) {
|
|
@@ -2272,6 +3488,9 @@ const builtinTests = {
|
|
|
2272
3488
|
};
|
|
2273
3489
|
//#endregion
|
|
2274
3490
|
//#region src/source.ts
|
|
3491
|
+
/** Lines longer than this show only `FRAME_WIDTH` characters around the span in a frame. */
|
|
3492
|
+
const MAX_FRAME_LINE = 200;
|
|
3493
|
+
const FRAME_WIDTH = 120;
|
|
2275
3494
|
/**
|
|
2276
3495
|
* A template's text and resolved name.
|
|
2277
3496
|
*
|
|
@@ -2319,15 +3538,21 @@ var Source = class {
|
|
|
2319
3538
|
const lastLine = Math.min(starts.length, start.line + context);
|
|
2320
3539
|
const gutter = String(lastLine).length;
|
|
2321
3540
|
const lines = [];
|
|
3541
|
+
const from = Math.max(0, start.column - 1 - FRAME_WIDTH / 2);
|
|
2322
3542
|
for (let line = firstLine; line <= lastLine; line++) {
|
|
2323
|
-
const
|
|
3543
|
+
const full = this.#lineText(line);
|
|
3544
|
+
const long = full.length > MAX_FRAME_LINE;
|
|
3545
|
+
const shownFrom = long ? Math.min(from, full.length - FRAME_WIDTH) : 0;
|
|
3546
|
+
const shownTo = long ? shownFrom + FRAME_WIDTH : full.length;
|
|
3547
|
+
const before = shownFrom > 0 ? "…" : "";
|
|
3548
|
+
const text = `${before}${full.slice(shownFrom, shownTo)}${shownTo < full.length ? "…" : ""}`;
|
|
2324
3549
|
const number = String(line).padStart(gutter);
|
|
2325
3550
|
const marker = line === start.line ? ">" : " ";
|
|
2326
3551
|
lines.push(`${marker} ${number} | ${text}`);
|
|
2327
3552
|
if (line === start.line) {
|
|
2328
|
-
const lineEnd = this.#lineStart(line) +
|
|
3553
|
+
const lineEnd = this.#lineStart(line) + shownTo;
|
|
2329
3554
|
const width = Math.max(1, Math.min(span.end, lineEnd) - span.start);
|
|
2330
|
-
const indent =
|
|
3555
|
+
const indent = (before + full.slice(shownFrom, start.column - 1)).replace(/[^\t]/g, " ");
|
|
2331
3556
|
lines.push(` ${" ".repeat(gutter)} | ${indent}${"^".repeat(width)}`);
|
|
2332
3557
|
}
|
|
2333
3558
|
}
|
|
@@ -2353,6 +3578,6 @@ var Source = class {
|
|
|
2353
3578
|
}
|
|
2354
3579
|
};
|
|
2355
3580
|
//#endregion
|
|
2356
|
-
export {
|
|
3581
|
+
export { unhold as $, variableNames as $t, checkLength as A, VOID as An, isRoot as At, isPromise as B, takeOutput as Bt, toTime as C, ONLY_CHILDREN as Cn, unwrap as Ct, addSlotFlags as D, ROLES as Dn, lookup as Dt, readableNames as E, REQUIRED_PARENTS as En, expose as Et, embedScope as F, KilnSyntaxError as Fn, runSequence as Ft, markCaller as G, endCapture as Gt, loadTemplate as H, Run as Ht, fail as I, createDiagnostic as In, additionsIn as It, renderTemplate as J, childScope as Jt, moreSteps as K, fillScope as Kt, hold as L, issue as Ln, checkLate as Lt, consumeAt as M, resolveTemplateName as Mn, passesAhead as Mt, embed as N, KilnIssue as Nn, passesFrom as Nt, after as O, SPECIAL as On, atFront as Ot, embedKeyed as P, KilnRenderError as Pn, runAhead as Pt, stepError as Q, sectionScope as Qt, holdData as R, closeOutlets as Rt, toPlainData as S, OBSOLETE_ATTRIBUTES as Sn, typeName as St, getMethod as T, RAW_TEXT as Tn, BLOCKED_NAMES as Tt, locate as U, blockScope as Ut, lendSteps as V, RenderState as Vt, locating as W, emptyOut as Wt, silence as X, ownerOf as Xt, returnSteps as Y, lookup$1 as Yt, step as Z, sectionCopy as Zt, mapContents as _, IMPLICIT_ROLES as _n, templateFunctions as _t, operatorFunction as a, escapeUrl as an, compare as at, scanHtml as b, METADATA as bn, toStringArgument as bt, checkDepth as c, ARIA_ATTRIBUTES as cn, equals as ct, functionArgument as d, BOOLEAN_ATTRIBUTES as dn, isHashLike as dt, suggest as en, withCaller as et, insertedPiece as f, BUTTON_SCOPE as fn, isPlainObject as ft, listOf as g, HEADINGS as gn, setOwn as gt, keyName as h, FOREIGN as hn, matchesType as ht, contains as i, escapeHtml as in, MISSING as it, consume as j, TEMPLATE_EXTENSION as jn, mayRunAhead as jt, all as k, TRANSPARENT as kn, contentSets as kt, entriesOf as l, ATTRIBUTE_VALUES as ln, hashKeys as lt, isHtmlStrategy as m, FLOW as mn, mapKeys as mt, builtinFunctions as n, isSafe as nn, FORMATTERS as nt, rangeOperator as o, escapeWith as on, describeType as ot, integerArgument as p, FIRST_CHILD as pn, literalOptions as pt, passData as q, startCapture as qt, builtinTests as r, safe as rn, MAX_DATA_DEPTH as rt, Kept as s, ABSTRACT_ROLES as sn, describeValue as st, Source as t, Markup as tn, write as tt, fromPieces as u, BLOCK as un, isEmpty as ut, markupText as v, INPUT_ROLES as vn, toNumber as vt, getAttr as w, PHRASING_ONLY as wn, valueLabel as wt, toPieces as x, OBSOLETE as xn, truthy as xt, readProperty as y, MAIN_PARENTS as yn, toStr as yt, importsFor as z, recordAddition as zt };
|
|
2357
3582
|
|
|
2358
|
-
//# sourceMappingURL=source-
|
|
3583
|
+
//# sourceMappingURL=source-DcWmJzQW.js.map
|