tutuca 0.9.28 → 0.9.29

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.
@@ -1372,13 +1372,13 @@ class IterInfo {
1372
1372
  }
1373
1373
 
1374
1374
  class ParseContext {
1375
- constructor(DOMParser, Text, Comment, nodes, events, macroNodes, frame, parent) {
1375
+ constructor(document2, Text, Comment, nodes, events, macroNodes, frame, parent) {
1376
1376
  this.nodes = nodes ?? [];
1377
1377
  this.events = events ?? [];
1378
1378
  this.macroNodes = macroNodes ?? [];
1379
1379
  this.parent = parent ?? null;
1380
1380
  this.frame = frame ?? {};
1381
- this.DOMParser = DOMParser ?? globalThis.DOMParser;
1381
+ this.document = document2 ?? globalThis.document;
1382
1382
  this.Text = Text ?? globalThis.Text;
1383
1383
  this.Comment = Comment ?? globalThis.Comment;
1384
1384
  this.cacheConstNodes = true;
@@ -1387,12 +1387,14 @@ class ParseContext {
1387
1387
  return this.frame.macroName === name || this.parent?.isInsideMacro(name);
1388
1388
  }
1389
1389
  enterMacro(macroName, macroVars, macroSlots) {
1390
- const { DOMParser: DP, Text, Comment, nodes, events, macroNodes } = this;
1390
+ const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
1391
1391
  const frame = { macroName, macroVars, macroSlots };
1392
- return new ParseContext(DP, Text, Comment, nodes, events, macroNodes, frame, this);
1392
+ return new ParseContext(document2, Text, Comment, nodes, events, macroNodes, frame, this);
1393
1393
  }
1394
- newDOMParser() {
1395
- return new this.DOMParser;
1394
+ parseHTML(html) {
1395
+ const t = this.document.createElement("template");
1396
+ t.innerHTML = html;
1397
+ return Array.from(t.content.childNodes);
1396
1398
  }
1397
1399
  addNodeIf(Class, val, extra) {
1398
1400
  if (val !== null) {
@@ -1515,7 +1517,7 @@ function compileModifiers(eventName, names) {
1515
1517
  return w(this, f, args, ctx);
1516
1518
  };
1517
1519
  }
1518
- var TextNode, CommentNode, ChildsNode, DomNode, FragmentNode, maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs), VALID_NODE_RE, _parser = null, ANode, MacroNode, RenderViewId, RenderNode, RenderItNode, RenderEachNode, RenderTextNode, RenderOnceNode, WrapperNode, ShowNode, HideNode, PushViewNameNode, SlotNode, ScopeNode, EachNode, filterAlwaysTrue = (_v, _k, _seq) => true, nullLoopWith = (seq) => ({ seq }), WRAPPER_NODES, _htmlBlockTags = "ADDRESS,ARTICLE,ASIDE,BLOCKQUOTE,CAPTION,COL,COLGROUP,DETAILS,DIALOG,DIV,DD,DL,DT,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEADER,HGROUP,HR,LEGEND,LI,MAIN,MENU,NAV,OL,P,PRE,SECTION,SUMMARY,TABLE,TBODY,TD,TFOOT,TH,THEAD,TR,UL", HTML_BLOCK_TAGS, isBlockDomNode = (n) => {
1520
+ var TextNode, CommentNode, ChildsNode, DomNode, FragmentNode, maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs), VALID_NODE_RE, ANode, MacroNode, RenderViewId, RenderNode, RenderItNode, RenderEachNode, RenderTextNode, RenderOnceNode, WrapperNode, ShowNode, HideNode, PushViewNameNode, SlotNode, ScopeNode, EachNode, filterAlwaysTrue = (_v, _k, _seq) => true, nullLoopWith = (seq) => ({ seq }), WRAPPER_NODES, _htmlBlockTags = "ADDRESS,ARTICLE,ASIDE,BLOCKQUOTE,CAPTION,COL,COLGROUP,DETAILS,DIALOG,DIV,DD,DL,DT,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEADER,HGROUP,HR,LEGEND,LI,MAIN,MENU,NAV,OL,P,PRE,SECTION,SUMMARY,TABLE,TBODY,TD,TFOOT,TH,THEAD,TR,UL", HTML_BLOCK_TAGS, isBlockDomNode = (n) => {
1519
1521
  const node = n instanceof FragmentNode ? n.childs[0] : n;
1520
1522
  return node instanceof DomNode && HTML_BLOCK_TAGS.has(node.tagName);
1521
1523
  }, isMac, fwdIfCtxPred = (pred) => (w) => (that, f, args, ctx) => pred(ctx) ? w(that, f, args, ctx) : that, fwdIfKey = (keyName) => fwdIfCtxPred((ctx) => ctx.e.key === keyName), fwdCtrl, fwdMeta, fwdAlt, metaWraps, MOD_WRAPPERS_BY_EVENT, identityModifierWrapper = (f, _ctx) => f;
@@ -1612,9 +1614,7 @@ var init_anode = __esm(() => {
1612
1614
  return this.val.toPathItem();
1613
1615
  }
1614
1616
  static parse(html, px) {
1615
- _parser ??= px.newDOMParser();
1616
- const nodes = _parser.parseFromString(html, "text/html").body.childNodes;
1617
- return ANode.fromDOM(nodes[0] ?? new px.Text(""), px);
1617
+ return ANode.fromDOM(px.parseHTML(html)[0] ?? new px.Text(""), px);
1618
1618
  }
1619
1619
  static fromDOM(node, px) {
1620
1620
  if (node instanceof px.Text)
@@ -2371,8 +2371,8 @@ var init_lint_check = __esm(() => {
2371
2371
  "dragInfo"
2372
2372
  ]);
2373
2373
  LintParseContext = class LintParseContext extends ParseContext {
2374
- constructor(DOMParser, Text, Comment) {
2375
- super(DOMParser, Text, Comment);
2374
+ constructor(document2, Text, Comment) {
2375
+ super(document2, Text, Comment);
2376
2376
  this.attrs = [];
2377
2377
  }
2378
2378
  onAttributes(attrs, wrapperAttrs, textChild, isMacroCall = false) {
@@ -8183,18 +8183,18 @@ init_lint_check();
8183
8183
  import { JSDOM } from "jsdom";
8184
8184
  async function createNodeEnv() {
8185
8185
  const dom = new JSDOM("<!DOCTYPE html><html><head></head><body></body></html>");
8186
- const { DOMParser, Text, Comment } = dom.window;
8187
- globalThis.document = dom.window.document;
8186
+ const { document: document2, Text, Comment } = dom.window;
8187
+ globalThis.document = document2;
8188
8188
 
8189
8189
  class HeadlessParseContext extends ParseContext {
8190
8190
  constructor() {
8191
- super(DOMParser, Text, Comment);
8191
+ super(document2, Text, Comment);
8192
8192
  }
8193
8193
  }
8194
8194
 
8195
8195
  class HeadlessLintParseContext extends LintParseContext {
8196
8196
  constructor() {
8197
- super(DOMParser, Text, Comment);
8197
+ super(document2, Text, Comment);
8198
8198
  }
8199
8199
  }
8200
8200
  return {
@@ -993,7 +993,6 @@ class FragmentNode extends ChildsNode {
993
993
  }
994
994
  var maybeFragment = (xs) => xs.length === 1 ? xs[0] : new FragmentNode(xs);
995
995
  var VALID_NODE_RE = /^[a-zA-Z][a-zA-Z0-9-]*$/;
996
- var _parser = null;
997
996
 
998
997
  class ANode extends BaseNode {
999
998
  constructor(nodeId, val) {
@@ -1005,9 +1004,7 @@ class ANode extends BaseNode {
1005
1004
  return this.val.toPathItem();
1006
1005
  }
1007
1006
  static parse(html, px) {
1008
- _parser ??= px.newDOMParser();
1009
- const nodes = _parser.parseFromString(html, "text/html").body.childNodes;
1010
- return ANode.fromDOM(nodes[0] ?? new px.Text(""), px);
1007
+ return ANode.fromDOM(px.parseHTML(html)[0] ?? new px.Text(""), px);
1011
1008
  }
1012
1009
  static fromDOM(node, px) {
1013
1010
  if (node instanceof px.Text)
@@ -1300,13 +1297,13 @@ var WRAPPER_NODES = {
1300
1297
  };
1301
1298
 
1302
1299
  class ParseContext {
1303
- constructor(DOMParser, Text, Comment, nodes, events, macroNodes, frame, parent) {
1300
+ constructor(document2, Text, Comment, nodes, events, macroNodes, frame, parent) {
1304
1301
  this.nodes = nodes ?? [];
1305
1302
  this.events = events ?? [];
1306
1303
  this.macroNodes = macroNodes ?? [];
1307
1304
  this.parent = parent ?? null;
1308
1305
  this.frame = frame ?? {};
1309
- this.DOMParser = DOMParser ?? globalThis.DOMParser;
1306
+ this.document = document2 ?? globalThis.document;
1310
1307
  this.Text = Text ?? globalThis.Text;
1311
1308
  this.Comment = Comment ?? globalThis.Comment;
1312
1309
  this.cacheConstNodes = true;
@@ -1315,12 +1312,14 @@ class ParseContext {
1315
1312
  return this.frame.macroName === name || this.parent?.isInsideMacro(name);
1316
1313
  }
1317
1314
  enterMacro(macroName, macroVars, macroSlots) {
1318
- const { DOMParser: DP, Text, Comment, nodes, events, macroNodes } = this;
1315
+ const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
1319
1316
  const frame = { macroName, macroVars, macroSlots };
1320
- return new ParseContext(DP, Text, Comment, nodes, events, macroNodes, frame, this);
1317
+ return new ParseContext(document2, Text, Comment, nodes, events, macroNodes, frame, this);
1321
1318
  }
1322
- newDOMParser() {
1323
- return new this.DOMParser;
1319
+ parseHTML(html) {
1320
+ const t = this.document.createElement("template");
1321
+ t.innerHTML = html;
1322
+ return Array.from(t.content.childNodes);
1324
1323
  }
1325
1324
  addNodeIf(Class, val, extra) {
1326
1325
  if (val !== null) {
@@ -1500,9 +1499,9 @@ class ParseCtxClassSetCollector extends ParseContext {
1500
1499
  }
1501
1500
  }
1502
1501
  enterMacro(macroName, macroVars, macroSlots) {
1503
- const { DOMParser: DP, Text, Comment, nodes, events, macroNodes } = this;
1502
+ const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
1504
1503
  const frame = { macroName, macroVars, macroSlots };
1505
- const v = new ParseCtxClassSetCollector(DP, Text, Comment, nodes, events, macroNodes, frame, this);
1504
+ const v = new ParseCtxClassSetCollector(document2, Text, Comment, nodes, events, macroNodes, frame, this);
1506
1505
  v.classes = this.classes;
1507
1506
  return v;
1508
1507
  }
@@ -1882,8 +1881,8 @@ class LintContext {
1882
1881
  }
1883
1882
 
1884
1883
  class LintParseContext extends ParseContext {
1885
- constructor(DOMParser, Text, Comment) {
1886
- super(DOMParser, Text, Comment);
1884
+ constructor(document2, Text, Comment) {
1885
+ super(document2, Text, Comment);
1887
1886
  this.attrs = [];
1888
1887
  }
1889
1888
  onAttributes(attrs, wrapperAttrs, textChild, isMacroCall = false) {
@@ -8564,9 +8563,9 @@ class LintClassCollectorCtx extends ParseCtxClassSetCollector {
8564
8563
  this.attrs = [];
8565
8564
  }
8566
8565
  enterMacro(macroName, macroVars, macroSlots) {
8567
- const { DOMParser: DP, Text, Comment, nodes, events, macroNodes } = this;
8566
+ const { document: document2, Text, Comment, nodes, events, macroNodes } = this;
8568
8567
  const frame = { macroName, macroVars, macroSlots };
8569
- const v = new LintClassCollectorCtx(DP, Text, Comment, nodes, events, macroNodes, frame, this);
8568
+ const v = new LintClassCollectorCtx(document2, Text, Comment, nodes, events, macroNodes, frame, this);
8570
8569
  v.classes = this.classes;
8571
8570
  v.attrs = this.attrs;
8572
8571
  return v;