@rindo/core 4.20.0 → 4.22.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.
Files changed (40) hide show
  1. package/cli/index.cjs +1 -1
  2. package/cli/index.js +1 -1
  3. package/cli/package.json +1 -1
  4. package/compiler/lib.es2023.array.d.ts +5 -5
  5. package/compiler/package.json +1 -1
  6. package/compiler/rindo.js +3534 -273
  7. package/dev-server/client/index.js +1 -1
  8. package/dev-server/client/package.json +1 -1
  9. package/dev-server/connector.html +2 -2
  10. package/dev-server/index.js +1 -1
  11. package/dev-server/package.json +1 -1
  12. package/dev-server/server-process.js +2 -2
  13. package/internal/app-data/index.cjs +1 -1
  14. package/internal/app-data/index.js +1 -1
  15. package/internal/app-data/package.json +1 -1
  16. package/internal/client/index.js +25 -13
  17. package/internal/client/package.json +1 -1
  18. package/internal/client/patch-browser.js +1 -1
  19. package/internal/hydrate/index.js +27 -19
  20. package/internal/hydrate/package.json +1 -1
  21. package/internal/hydrate/runner.d.ts +10 -4
  22. package/internal/hydrate/runner.js +389 -239
  23. package/internal/package.json +1 -1
  24. package/internal/rindo-public-compiler.d.ts +43 -4
  25. package/internal/rindo-public-runtime.d.ts +4 -0
  26. package/internal/testing/index.js +24 -12
  27. package/internal/testing/package.json +1 -1
  28. package/mock-doc/index.cjs +32 -1
  29. package/mock-doc/index.d.ts +8 -0
  30. package/mock-doc/index.js +32 -1
  31. package/mock-doc/package.json +1 -1
  32. package/package.json +9 -7
  33. package/screenshot/index.js +1 -1
  34. package/screenshot/package.json +1 -1
  35. package/screenshot/pixel-match.js +1 -1
  36. package/sys/node/index.js +47 -45
  37. package/sys/node/package.json +1 -1
  38. package/sys/node/worker.js +2 -2
  39. package/testing/index.js +39 -1
  40. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Rindo Hydrate Runner v4.20.0 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Hydrate Runner v4.22.0 | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -12,6 +12,7 @@ var CONTENT_REF_ID = "r";
12
12
  var ORG_LOCATION_ID = "o";
13
13
  var SLOT_NODE_ID = "s";
14
14
  var TEXT_NODE_ID = "t";
15
+ var HYDRATE_ID = "s-id";
15
16
  var XLINK_NS = "http://www.w3.org/1999/xlink";
16
17
 
17
18
  // src/mock-doc/attribute.ts
@@ -320,8 +321,8 @@ function jsCaseToCssCase(str) {
320
321
 
321
322
  // src/mock-doc/custom-element-registry.ts
322
323
  var MockCustomElementRegistry = class {
323
- constructor(win) {
324
- this.win = win;
324
+ constructor(win2) {
325
+ this.win = win2;
325
326
  }
326
327
  define(tagName, cstr, options) {
327
328
  if (tagName.toLowerCase() !== tagName) {
@@ -343,19 +344,19 @@ var MockCustomElementRegistry = class {
343
344
  this.__whenDefined.delete(tagName);
344
345
  }
345
346
  }
346
- const doc = this.win.document;
347
- if (doc != null) {
348
- const hosts = doc.querySelectorAll(tagName);
347
+ const doc2 = this.win.document;
348
+ if (doc2 != null) {
349
+ const hosts = doc2.querySelectorAll(tagName);
349
350
  hosts.forEach((host) => {
350
351
  if (upgradedElements.has(host) === false) {
351
- tempDisableCallbacks.add(doc);
352
- const upgradedCmp = createCustomElement(this, doc, tagName);
352
+ tempDisableCallbacks.add(doc2);
353
+ const upgradedCmp = createCustomElement(this, doc2, tagName);
353
354
  for (let i = 0; i < host.childNodes.length; i++) {
354
355
  const childNode = host.childNodes[i];
355
356
  childNode.remove();
356
357
  upgradedCmp.appendChild(childNode);
357
358
  }
358
- tempDisableCallbacks.delete(doc);
359
+ tempDisableCallbacks.delete(doc2);
359
360
  if (proxyElements.has(host)) {
360
361
  proxyElements.set(host, upgradedCmp);
361
362
  }
@@ -409,8 +410,8 @@ var MockCustomElementRegistry = class {
409
410
  });
410
411
  }
411
412
  };
412
- function createCustomElement(customElements, ownerDocument, tagName) {
413
- const Cstr = customElements.get(tagName);
413
+ function createCustomElement(customElements2, ownerDocument, tagName) {
414
+ const Cstr = customElements2.get(tagName);
414
415
  if (Cstr != null) {
415
416
  const cmp = new Cstr(ownerDocument);
416
417
  cmp.nodeName = tagName.toUpperCase();
@@ -458,8 +459,8 @@ function connectNode(ownerDocument, node) {
458
459
  node.ownerDocument = ownerDocument;
459
460
  if (node.nodeType === 1 /* ELEMENT_NODE */) {
460
461
  if (ownerDocument != null && node.nodeName.includes("-")) {
461
- const win = ownerDocument.defaultView;
462
- if (win != null && typeof node.connectedCallback === "function" && node.isConnected) {
462
+ const win2 = ownerDocument.defaultView;
463
+ if (win2 != null && typeof node.connectedCallback === "function" && node.isConnected) {
463
464
  fireConnectedCallback(node);
464
465
  }
465
466
  const shadowRoot = node.shadowRoot;
@@ -4867,7 +4868,7 @@ var OpenElementStack = class {
4867
4868
  get currentTmplContentOrNode() {
4868
4869
  return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
4869
4870
  }
4870
- constructor(document, treeAdapter, handler) {
4871
+ constructor(document2, treeAdapter, handler) {
4871
4872
  this.treeAdapter = treeAdapter;
4872
4873
  this.handler = handler;
4873
4874
  this.items = [];
@@ -4875,7 +4876,7 @@ var OpenElementStack = class {
4875
4876
  this.stackTop = -1;
4876
4877
  this.tmplCount = 0;
4877
4878
  this.currentTagId = TAG_ID.UNKNOWN;
4878
- this.current = document;
4879
+ this.current = document2;
4879
4880
  }
4880
4881
  //Index of element
4881
4882
  _indexOf(element) {
@@ -5292,8 +5293,8 @@ var defaultTreeAdapter = {
5292
5293
  getTemplateContent(templateElement) {
5293
5294
  return templateElement.content;
5294
5295
  },
5295
- setDocumentType(document, name, publicId, systemId) {
5296
- const doctypeNode = document.childNodes.find((node) => node.nodeName === "#documentType");
5296
+ setDocumentType(document2, name, publicId, systemId) {
5297
+ const doctypeNode = document2.childNodes.find((node) => node.nodeName === "#documentType");
5297
5298
  if (doctypeNode) {
5298
5299
  doctypeNode.name = name;
5299
5300
  doctypeNode.publicId = publicId;
@@ -5306,14 +5307,14 @@ var defaultTreeAdapter = {
5306
5307
  systemId,
5307
5308
  parentNode: null
5308
5309
  };
5309
- defaultTreeAdapter.appendChild(document, node);
5310
+ defaultTreeAdapter.appendChild(document2, node);
5310
5311
  }
5311
5312
  },
5312
- setDocumentMode(document, mode) {
5313
- document.mode = mode;
5313
+ setDocumentMode(document2, mode) {
5314
+ document2.mode = mode;
5314
5315
  },
5315
- getDocumentMode(document) {
5316
- return document.mode;
5316
+ getDocumentMode(document2) {
5317
+ return document2.mode;
5317
5318
  },
5318
5319
  detachNode(node) {
5319
5320
  if (node.parentNode) {
@@ -5794,7 +5795,7 @@ var defaultParserOptions = {
5794
5795
  onParseError: null
5795
5796
  };
5796
5797
  var Parser = class {
5797
- constructor(options, document, fragmentContext = null, scriptHandler = null) {
5798
+ constructor(options, document2, fragmentContext = null, scriptHandler = null) {
5798
5799
  this.fragmentContext = fragmentContext;
5799
5800
  this.scriptHandler = scriptHandler;
5800
5801
  this.currentToken = null;
@@ -5819,7 +5820,7 @@ var Parser = class {
5819
5820
  if (this.onParseError) {
5820
5821
  this.options.sourceCodeLocationInfo = true;
5821
5822
  }
5822
- this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument();
5823
+ this.document = document2 !== null && document2 !== void 0 ? document2 : this.treeAdapter.createDocument();
5823
5824
  this.tokenizer = new Tokenizer(this.options, this);
5824
5825
  this.activeFormattingElements = new FormattingElementList(this.treeAdapter);
5825
5826
  this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : TAG_ID.UNKNOWN;
@@ -8796,11 +8797,11 @@ function parseFragment(fragmentContext, html, options) {
8796
8797
  // src/mock-doc/parse-util.ts
8797
8798
  var docParser = /* @__PURE__ */ new WeakMap();
8798
8799
  function parseDocumentUtil(ownerDocument, html) {
8799
- const doc = parse(html.trim(), getParser(ownerDocument));
8800
- doc.documentElement = doc.firstElementChild;
8801
- doc.head = doc.documentElement.firstElementChild;
8802
- doc.body = doc.head.nextElementSibling;
8803
- return doc;
8800
+ const doc2 = parse(html.trim(), getParser(ownerDocument));
8801
+ doc2.documentElement = doc2.firstElementChild;
8802
+ doc2.head = doc2.documentElement.firstElementChild;
8803
+ doc2.body = doc2.head.nextElementSibling;
8804
+ return doc2;
8804
8805
  }
8805
8806
  function parseFragmentUtil(ownerDocument, html) {
8806
8807
  if (typeof html === "string") {
@@ -8818,9 +8819,9 @@ function getParser(ownerDocument) {
8818
8819
  }
8819
8820
  const treeAdapter = {
8820
8821
  createDocument() {
8821
- const doc = ownerDocument.createElement("#document" /* DOCUMENT_NODE */);
8822
- doc["x-mode"] = "no-quirks";
8823
- return doc;
8822
+ const doc2 = ownerDocument.createElement("#document" /* DOCUMENT_NODE */);
8823
+ doc2["x-mode"] = "no-quirks";
8824
+ return doc2;
8824
8825
  },
8825
8826
  setNodeSourceCodeLocation(node, location2) {
8826
8827
  node.sourceCodeLocation = location2;
@@ -8858,22 +8859,22 @@ function getParser(ownerDocument) {
8858
8859
  getTemplateContent(templateElement) {
8859
8860
  return templateElement.content;
8860
8861
  },
8861
- setDocumentType(doc, name, publicId, systemId) {
8862
- let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10 /* DOCUMENT_TYPE_NODE */);
8862
+ setDocumentType(doc2, name, publicId, systemId) {
8863
+ let doctypeNode = doc2.childNodes.find((n) => n.nodeType === 10 /* DOCUMENT_TYPE_NODE */);
8863
8864
  if (doctypeNode == null) {
8864
8865
  doctypeNode = ownerDocument.createDocumentTypeNode();
8865
- doc.insertBefore(doctypeNode, doc.firstChild);
8866
+ doc2.insertBefore(doctypeNode, doc2.firstChild);
8866
8867
  }
8867
8868
  doctypeNode.nodeValue = "!DOCTYPE";
8868
8869
  doctypeNode["x-name"] = name;
8869
8870
  doctypeNode["x-publicId"] = publicId;
8870
8871
  doctypeNode["x-systemId"] = systemId;
8871
8872
  },
8872
- setDocumentMode(doc, mode) {
8873
- doc["x-mode"] = mode;
8873
+ setDocumentMode(doc2, mode) {
8874
+ doc2["x-mode"] = mode;
8874
8875
  },
8875
- getDocumentMode(doc) {
8876
- return doc["x-mode"];
8876
+ getDocumentMode(doc2) {
8877
+ return doc2["x-mode"];
8877
8878
  },
8878
8879
  detachNode(node) {
8879
8880
  node.remove();
@@ -9005,9 +9006,9 @@ var jquery_default = (
9005
9006
  nodeName: "HTML"
9006
9007
  }
9007
9008
  }
9008
- }, function(window, noGlobal) {
9009
+ }, function(window2, noGlobal) {
9009
9010
  "use strict";
9010
- if (!window.document) {
9011
+ if (!window2.document) {
9011
9012
  throw new Error("jQuery requires a window with a document");
9012
9013
  }
9013
9014
  var arr = [];
@@ -9042,16 +9043,16 @@ var jquery_default = (
9042
9043
  }
9043
9044
  return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj;
9044
9045
  }
9045
- var document = window.document;
9046
+ var document2 = window2.document;
9046
9047
  var preservedScriptAttributes = {
9047
9048
  type: true,
9048
9049
  src: true,
9049
9050
  nonce: true,
9050
9051
  noModule: true
9051
9052
  };
9052
- function DOMEval(code, node, doc) {
9053
- doc = doc || document;
9054
- var i2, script = doc.createElement("script");
9053
+ function DOMEval(code, node, doc2) {
9054
+ doc2 = doc2 || document2;
9055
+ var i2, script = doc2.createElement("script");
9055
9056
  script.text = code;
9056
9057
  if (node) {
9057
9058
  for (i2 in preservedScriptAttributes) {
@@ -9060,7 +9061,7 @@ var jquery_default = (
9060
9061
  }
9061
9062
  }
9062
9063
  }
9063
- doc.head.appendChild(script).parentNode.removeChild(script);
9064
+ doc2.head.appendChild(script).parentNode.removeChild(script);
9064
9065
  }
9065
9066
  const jQuery = {};
9066
9067
  var version = "4.0.0-pre+9352011a7.dirty +selector", rhtmlSuffix = /HTML$/i, jQueryOrig = function(selector, context) {
@@ -9197,8 +9198,8 @@ var jquery_default = (
9197
9198
  },
9198
9199
  // Evaluates a script in a provided context; falls back to the global one
9199
9200
  // if not specified.
9200
- globalEval: function(code, options, doc) {
9201
- DOMEval(code, { nonce: options && options.nonce }, doc);
9201
+ globalEval: function(code, options, doc2) {
9202
+ DOMEval(code, { nonce: options && options.nonce }, doc2);
9202
9203
  },
9203
9204
  each: function(obj, callback) {
9204
9205
  var length, i2 = 0;
@@ -9325,9 +9326,9 @@ var jquery_default = (
9325
9326
  }
9326
9327
  var pop = arr.pop;
9327
9328
  var whitespace = "[\\x20\\t\\r\\n\\f]";
9328
- var isIE = document.documentMode;
9329
+ var isIE = document2.documentMode;
9329
9330
  try {
9330
- document.querySelector(":has(*,:jqfake)");
9331
+ document2.querySelector(":has(*,:jqfake)");
9331
9332
  support.cssHas = false;
9332
9333
  } catch (e) {
9333
9334
  support.cssHas = true;
@@ -9359,7 +9360,7 @@ var jquery_default = (
9359
9360
  var rleadingCombinator = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*");
9360
9361
  var rdescend = new RegExp(whitespace + "|>");
9361
9362
  var rsibling = /[+~]/;
9362
- var documentElement = document.documentElement;
9363
+ var documentElement = document2.documentElement;
9363
9364
  var matches2 = documentElement.matches || documentElement.msMatchesSelector;
9364
9365
  function createCache() {
9365
9366
  var keys = [];
@@ -9528,10 +9529,10 @@ var jquery_default = (
9528
9529
  1
9529
9530
  );
9530
9531
  if (compare & 1) {
9531
- if (a == document || a.ownerDocument == document && jQuery.contains(document, a)) {
9532
+ if (a == document2 || a.ownerDocument == document2 && jQuery.contains(document2, a)) {
9532
9533
  return -1;
9533
9534
  }
9534
- if (b == document || b.ownerDocument == document && jQuery.contains(document, b)) {
9535
+ if (b == document2 || b.ownerDocument == document2 && jQuery.contains(document2, b)) {
9535
9536
  return 1;
9536
9537
  }
9537
9538
  return 0;
@@ -9687,14 +9688,14 @@ var jquery_default = (
9687
9688
  });
9688
9689
  }
9689
9690
  function setDocument(node) {
9690
- var subWindow, doc = node ? node.ownerDocument || node : document;
9691
- if (doc == document$1 || doc.nodeType !== 9) {
9691
+ var subWindow, doc2 = node ? node.ownerDocument || node : document2;
9692
+ if (doc2 == document$1 || doc2.nodeType !== 9) {
9692
9693
  return;
9693
9694
  }
9694
- document$1 = doc;
9695
+ document$1 = doc2;
9695
9696
  documentElement$1 = document$1.documentElement;
9696
9697
  documentIsHTML = !jQuery.isXMLDoc(document$1);
9697
- if (isIE && document != document$1 && (subWindow = document$1.defaultView) && subWindow.top !== subWindow) {
9698
+ if (isIE && document2 != document$1 && (subWindow = document$1.defaultView) && subWindow.top !== subWindow) {
9698
9699
  subWindow.addEventListener("unload", unloadHandler);
9699
9700
  }
9700
9701
  }
@@ -9925,7 +9926,7 @@ var jquery_default = (
9925
9926
  }),
9926
9927
  // Miscellaneous
9927
9928
  target: function(elem) {
9928
- var hash = window.location && window.location.hash;
9929
+ var hash = window2.location && window2.location.hash;
9929
9930
  return hash && hash.slice(1) === elem.id;
9930
9931
  },
9931
9932
  root: function(elem) {
@@ -10565,6 +10566,13 @@ style="${cssText}">`;
10565
10566
  output.indent = output.indent + ((_h = opts.indentSpaces) != null ? _h : 0);
10566
10567
  }
10567
10568
  for (let i = 0; i < childNodeLength; i++) {
10569
+ const sId = node.attributes.getNamedItem(HYDRATE_ID);
10570
+ const isRindoDeclarativeShadowDOM = childNodes[i].nodeName.toLowerCase() === "template" && sId;
10571
+ if (isRindoDeclarativeShadowDOM) {
10572
+ yield `
10573
+ ${" ".repeat(output.indent)}<!--r.${sId.value}-->`;
10574
+ continue;
10575
+ }
10568
10576
  yield* streamToHtml(childNodes[i], opts, output);
10569
10577
  }
10570
10578
  if (ignoreTag === false) {
@@ -11915,9 +11923,9 @@ function createElement(ownerDocument, tagName) {
11915
11923
  return new MockUListElement(ownerDocument);
11916
11924
  }
11917
11925
  if (ownerDocument != null && tagName.includes("-")) {
11918
- const win = ownerDocument.defaultView;
11919
- if (win != null && win.customElements != null) {
11920
- return createCustomElement(win.customElements, ownerDocument, tagName);
11926
+ const win2 = ownerDocument.defaultView;
11927
+ if (win2 != null && win2.customElements != null) {
11928
+ return createCustomElement(win2.customElements, ownerDocument, tagName);
11921
11929
  }
11922
11930
  }
11923
11931
  return new MockHTMLElement(ownerDocument, tagName);
@@ -11980,6 +11988,11 @@ patchPropAttributes(
11980
11988
  type: "submit"
11981
11989
  }
11982
11990
  );
11991
+ Object.defineProperty(MockButtonElement.prototype, "form", {
11992
+ get() {
11993
+ return this.hasAttribute("form") ? this.getAttribute("form") : null;
11994
+ }
11995
+ });
11983
11996
  var MockImageElement = class extends MockHTMLElement {
11984
11997
  constructor(ownerDocument) {
11985
11998
  super(ownerDocument, "img");
@@ -12334,9 +12347,9 @@ var CanvasRenderingContext = class {
12334
12347
  }
12335
12348
  clearRect() {
12336
12349
  }
12337
- getImageData(_, __, w, h) {
12350
+ getImageData(_, __, w, h2) {
12338
12351
  return {
12339
- data: new Array(w * h * 4)
12352
+ data: new Array(w * h2 * 4)
12340
12353
  };
12341
12354
  }
12342
12355
  toDataURL() {
@@ -12398,9 +12411,9 @@ var MockCanvasElement = class extends MockHTMLElement {
12398
12411
  function fullUrl(elm, attrName) {
12399
12412
  const val = elm.getAttribute(attrName) || "";
12400
12413
  if (elm.ownerDocument != null) {
12401
- const win = elm.ownerDocument.defaultView;
12402
- if (win != null) {
12403
- const loc = win.location;
12414
+ const win2 = elm.ownerDocument.defaultView;
12415
+ if (win2 != null) {
12416
+ const loc = win2.location;
12404
12417
  if (loc != null) {
12405
12418
  try {
12406
12419
  const url = new URL(val, loc.href);
@@ -13005,6 +13018,21 @@ function resetPerformance(perf) {
13005
13018
  }
13006
13019
  }
13007
13020
 
13021
+ // src/mock-doc/resize-observer.ts
13022
+ var MockResizeObserver = class {
13023
+ constructor() {
13024
+ }
13025
+ disconnect() {
13026
+ }
13027
+ observe() {
13028
+ }
13029
+ takeRecords() {
13030
+ return [];
13031
+ }
13032
+ unobserve() {
13033
+ }
13034
+ };
13035
+
13008
13036
  // src/mock-doc/storage.ts
13009
13037
  var MockStorage = class {
13010
13038
  constructor() {
@@ -13105,10 +13133,10 @@ var MockWindow = class {
13105
13133
  }
13106
13134
  get Document() {
13107
13135
  if (this.__docCstr == null) {
13108
- const win = this;
13136
+ const win2 = this;
13109
13137
  this.__docCstr = class extends MockDocument {
13110
13138
  constructor() {
13111
- super(false, win);
13139
+ super(false, win2);
13112
13140
  throw new Error("Illegal constructor: cannot construct Document");
13113
13141
  }
13114
13142
  };
@@ -13244,6 +13272,9 @@ var MockWindow = class {
13244
13272
  get IntersectionObserver() {
13245
13273
  return MockIntersectionObserver;
13246
13274
  }
13275
+ get ResizeObserver() {
13276
+ return MockResizeObserver;
13277
+ }
13247
13278
  get localStorage() {
13248
13279
  if (this.__localStorage == null) {
13249
13280
  this.__localStorage = new MockStorage();
@@ -13625,14 +13656,14 @@ var MockWindow = class {
13625
13656
  }
13626
13657
  };
13627
13658
  addGlobalsToWindowPrototype(MockWindow.prototype);
13628
- function resetWindowDefaults(win) {
13629
- win.__clearInterval = nativeClearInterval;
13630
- win.__clearTimeout = nativeClearTimeout;
13631
- win.__setInterval = nativeSetInterval;
13632
- win.__setTimeout = nativeSetTimeout;
13633
- win.__maxTimeout = 3e4;
13634
- win.__allowInterval = true;
13635
- win.URL = nativeURL;
13659
+ function resetWindowDefaults(win2) {
13660
+ win2.__clearInterval = nativeClearInterval;
13661
+ win2.__clearTimeout = nativeClearTimeout;
13662
+ win2.__setInterval = nativeSetInterval;
13663
+ win2.__setTimeout = nativeSetTimeout;
13664
+ win2.__maxTimeout = 3e4;
13665
+ win2.__allowInterval = true;
13666
+ win2.URL = nativeURL;
13636
13667
  }
13637
13668
  function cloneWindow(srcWin, opts = {}) {
13638
13669
  if (srcWin == null) {
@@ -13651,72 +13682,72 @@ function cloneWindow(srcWin, opts = {}) {
13651
13682
  }
13652
13683
  return clonedWin;
13653
13684
  }
13654
- function constrainTimeouts(win) {
13655
- win.__allowInterval = false;
13656
- win.__maxTimeout = 0;
13685
+ function constrainTimeouts(win2) {
13686
+ win2.__allowInterval = false;
13687
+ win2.__maxTimeout = 0;
13657
13688
  }
13658
- function resetWindow(win) {
13659
- if (win != null) {
13660
- if (win.__timeouts) {
13661
- win.__timeouts.forEach((timeoutId) => {
13689
+ function resetWindow(win2) {
13690
+ if (win2 != null) {
13691
+ if (win2.__timeouts) {
13692
+ win2.__timeouts.forEach((timeoutId) => {
13662
13693
  nativeClearInterval(timeoutId);
13663
13694
  nativeClearTimeout(timeoutId);
13664
13695
  });
13665
- win.__timeouts.clear();
13696
+ win2.__timeouts.clear();
13666
13697
  }
13667
- if (win.customElements && win.customElements.clear) {
13668
- win.customElements.clear();
13698
+ if (win2.customElements && win2.customElements.clear) {
13699
+ win2.customElements.clear();
13669
13700
  }
13670
- resetDocument(win.document);
13671
- resetPerformance(win.performance);
13672
- for (const key in win) {
13673
- if (win.hasOwnProperty(key) && key !== "document" && key !== "performance" && key !== "customElements") {
13674
- delete win[key];
13701
+ resetDocument(win2.document);
13702
+ resetPerformance(win2.performance);
13703
+ for (const key in win2) {
13704
+ if (win2.hasOwnProperty(key) && key !== "document" && key !== "performance" && key !== "customElements") {
13705
+ delete win2[key];
13675
13706
  }
13676
13707
  }
13677
- resetWindowDefaults(win);
13678
- resetWindowDimensions(win);
13679
- resetEventListeners(win);
13680
- if (win.document != null) {
13708
+ resetWindowDefaults(win2);
13709
+ resetWindowDimensions(win2);
13710
+ resetEventListeners(win2);
13711
+ if (win2.document != null) {
13681
13712
  try {
13682
- win.document.defaultView = win;
13713
+ win2.document.defaultView = win2;
13683
13714
  } catch (e) {
13684
13715
  }
13685
13716
  }
13686
- win.fetch = null;
13687
- win.Headers = null;
13688
- win.Request = null;
13689
- win.Response = null;
13690
- win.FetchError = null;
13717
+ win2.fetch = null;
13718
+ win2.Headers = null;
13719
+ win2.Request = null;
13720
+ win2.Response = null;
13721
+ win2.FetchError = null;
13691
13722
  }
13692
13723
  }
13693
- function resetWindowDimensions(win) {
13724
+ function resetWindowDimensions(win2) {
13694
13725
  try {
13695
- win.devicePixelRatio = 1;
13696
- win.innerHeight = 768;
13697
- win.innerWidth = 1366;
13698
- win.pageXOffset = 0;
13699
- win.pageYOffset = 0;
13700
- win.screenLeft = 0;
13701
- win.screenTop = 0;
13702
- win.screenX = 0;
13703
- win.screenY = 0;
13704
- win.scrollX = 0;
13705
- win.scrollY = 0;
13706
- win.screen = {
13707
- availHeight: win.innerHeight,
13726
+ win2.devicePixelRatio = 1;
13727
+ win2.innerHeight = 768;
13728
+ win2.innerWidth = 1366;
13729
+ win2.pageXOffset = 0;
13730
+ win2.pageYOffset = 0;
13731
+ win2.screenLeft = 0;
13732
+ win2.screenTop = 0;
13733
+ win2.screenX = 0;
13734
+ win2.screenY = 0;
13735
+ win2.scrollX = 0;
13736
+ win2.scrollY = 0;
13737
+ win2.screen = {
13738
+ availHeight: win2.innerHeight,
13708
13739
  availLeft: 0,
13709
13740
  availTop: 0,
13710
- availWidth: win.innerWidth,
13741
+ availWidth: win2.innerWidth,
13711
13742
  colorDepth: 24,
13712
- height: win.innerHeight,
13743
+ height: win2.innerHeight,
13713
13744
  keepAwake: false,
13714
13745
  orientation: {
13715
13746
  angle: 0,
13716
13747
  type: "portrait-primary"
13717
13748
  },
13718
13749
  pixelDepth: 24,
13719
- width: win.innerWidth
13750
+ width: win2.innerWidth
13720
13751
  };
13721
13752
  } catch (e) {
13722
13753
  }
@@ -13724,11 +13755,11 @@ function resetWindowDimensions(win) {
13724
13755
 
13725
13756
  // src/mock-doc/document.ts
13726
13757
  var MockDocument = class _MockDocument extends MockHTMLElement {
13727
- constructor(html = null, win = null) {
13758
+ constructor(html = null, win2 = null) {
13728
13759
  super(null, null);
13729
13760
  this.nodeName = "#document" /* DOCUMENT_NODE */;
13730
13761
  this.nodeType = 9 /* DOCUMENT_NODE */;
13731
- this.defaultView = win;
13762
+ this.defaultView = win2;
13732
13763
  this.cookie = "";
13733
13764
  this.referrer = "";
13734
13765
  this.appendChild(this.createDocumentTypeNode());
@@ -13875,10 +13906,10 @@ var MockDocument = class _MockDocument extends MockHTMLElement {
13875
13906
  }
13876
13907
  createElement(tagName) {
13877
13908
  if (tagName === "#document" /* DOCUMENT_NODE */) {
13878
- const doc = new _MockDocument(false);
13879
- doc.nodeName = tagName;
13880
- doc.parentNode = null;
13881
- return doc;
13909
+ const doc2 = new _MockDocument(false);
13910
+ doc2.nodeName = tagName;
13911
+ doc2.parentNode = null;
13912
+ return doc2;
13882
13913
  }
13883
13914
  return createElement(this, tagName);
13884
13915
  }
@@ -13918,10 +13949,10 @@ var MockDocument = class _MockDocument extends MockHTMLElement {
13918
13949
  title.textContent = value;
13919
13950
  }
13920
13951
  };
13921
- function resetDocument(doc) {
13922
- if (doc != null) {
13923
- resetEventListeners(doc);
13924
- const documentElement = doc.documentElement;
13952
+ function resetDocument(doc2) {
13953
+ if (doc2 != null) {
13954
+ resetEventListeners(doc2);
13955
+ const documentElement = doc2.documentElement;
13925
13956
  if (documentElement != null) {
13926
13957
  resetElement(documentElement);
13927
13958
  for (let i = 0, ii = documentElement.childNodes.length; i < ii; i++) {
@@ -13930,25 +13961,25 @@ function resetDocument(doc) {
13930
13961
  childNode.childNodes.length = 0;
13931
13962
  }
13932
13963
  }
13933
- for (const key in doc) {
13934
- if (doc.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) {
13935
- delete doc[key];
13964
+ for (const key in doc2) {
13965
+ if (doc2.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) {
13966
+ delete doc2[key];
13936
13967
  }
13937
13968
  }
13938
13969
  try {
13939
- doc.nodeName = "#document" /* DOCUMENT_NODE */;
13970
+ doc2.nodeName = "#document" /* DOCUMENT_NODE */;
13940
13971
  } catch (e) {
13941
13972
  }
13942
13973
  try {
13943
- doc.nodeType = 9 /* DOCUMENT_NODE */;
13974
+ doc2.nodeType = 9 /* DOCUMENT_NODE */;
13944
13975
  } catch (e) {
13945
13976
  }
13946
13977
  try {
13947
- doc.cookie = "";
13978
+ doc2.cookie = "";
13948
13979
  } catch (e) {
13949
13980
  }
13950
13981
  try {
13951
- doc.referrer = "";
13982
+ doc2.referrer = "";
13952
13983
  } catch (e) {
13953
13984
  }
13954
13985
  }
@@ -14004,14 +14035,65 @@ function createWindowFromHtml(templateHtml, uniqueId) {
14004
14035
  templateWindow = new MockWindow(templateHtml);
14005
14036
  templateWindows.set(uniqueId, templateWindow);
14006
14037
  }
14007
- const win = cloneWindow(templateWindow);
14008
- return win;
14038
+ const win2 = cloneWindow(templateWindow);
14039
+ return win2;
14009
14040
  }
14010
14041
 
14011
14042
  // src/hydrate/runner/render.ts
14012
14043
  import { Readable } from "stream";
14013
14044
  import { hydrateFactory } from "@rindo/core/hydrate-factory";
14014
14045
 
14046
+ // src/client/client-build.ts
14047
+ import { BUILD } from "@rindo/core/internal/app-data";
14048
+ var Build = {
14049
+ isDev: BUILD.isDev ? true : false,
14050
+ isBrowser: true,
14051
+ isServer: false,
14052
+ isTesting: BUILD.isTesting ? true : false
14053
+ };
14054
+
14055
+ // src/client/client-host-ref.ts
14056
+ import { BUILD as BUILD2 } from "@rindo/core/internal/app-data";
14057
+ var hostRefs = BUILD2.hotModuleReplacement ? window.__RINDO_HOSTREFS__ || (window.__RINDO_HOSTREFS__ = /* @__PURE__ */ new WeakMap()) : /* @__PURE__ */ new WeakMap();
14058
+
14059
+ // src/client/client-load-module.ts
14060
+ import { BUILD as BUILD4 } from "@rindo/core/internal/app-data";
14061
+
14062
+ // src/client/client-log.ts
14063
+ import { BUILD as BUILD3 } from "@rindo/core/internal/app-data";
14064
+ var RINDO_DEV_MODE = BUILD3.isTesting ? ["RINDO:"] : [
14065
+ "%crindo",
14066
+ "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"
14067
+ ];
14068
+
14069
+ // src/client/client-style.ts
14070
+ var modeResolutionChain = [];
14071
+
14072
+ // src/client/client-task-queue.ts
14073
+ import { BUILD as BUILD6 } from "@rindo/core/internal/app-data";
14074
+
14075
+ // src/client/client-window.ts
14076
+ import { BUILD as BUILD5 } from "@rindo/core/internal/app-data";
14077
+ var win = typeof window !== "undefined" ? window : {};
14078
+ var doc = win.document || { head: {} };
14079
+ var H = win.HTMLElement || class {
14080
+ };
14081
+ var supportsShadow = BUILD5.shadowDom;
14082
+ var supportsConstructableStylesheets = BUILD5.constructableCSS ? /* @__PURE__ */ (() => {
14083
+ try {
14084
+ new CSSStyleSheet();
14085
+ return typeof new CSSStyleSheet().replaceSync === "function";
14086
+ } catch (e) {
14087
+ }
14088
+ return false;
14089
+ })() : false;
14090
+
14091
+ // src/client/index.ts
14092
+ import { BUILD as BUILD27, Env, NAMESPACE as NAMESPACE2 } from "@rindo/core/internal/app-data";
14093
+
14094
+ // src/runtime/bootstrap-custom-element.ts
14095
+ import { BUILD as BUILD24 } from "@rindo/core/internal/app-data";
14096
+
14015
14097
  // src/utils/helpers.ts
14016
14098
  var isString = (v) => typeof v === "string";
14017
14099
 
@@ -14102,15 +14184,77 @@ var unwrapErr = (result) => {
14102
14184
  }
14103
14185
  };
14104
14186
 
14187
+ // src/runtime/connected-callback.ts
14188
+ import { BUILD as BUILD21 } from "@rindo/core/internal/app-data";
14189
+
14190
+ // src/runtime/client-hydrate.ts
14191
+ import { BUILD as BUILD9 } from "@rindo/core/internal/app-data";
14192
+
14193
+ // src/runtime/profile.ts
14194
+ import { BUILD as BUILD7 } from "@rindo/core/internal/app-data";
14195
+
14196
+ // src/runtime/vdom/h.ts
14197
+ import { BUILD as BUILD8 } from "@rindo/core/internal/app-data";
14198
+
14199
+ // src/runtime/initialize-component.ts
14200
+ import { BUILD as BUILD20 } from "@rindo/core/internal/app-data";
14201
+
14202
+ // src/runtime/mode.ts
14203
+ var setMode = (handler) => modeResolutionChain.push(handler);
14204
+
14205
+ // src/runtime/proxy-component.ts
14206
+ import { BUILD as BUILD19 } from "@rindo/core/internal/app-data";
14207
+
14208
+ // src/runtime/set-value.ts
14209
+ import { BUILD as BUILD18 } from "@rindo/core/internal/app-data";
14210
+
14211
+ // src/runtime/parse-property-value.ts
14212
+ import { BUILD as BUILD10 } from "@rindo/core/internal/app-data";
14213
+
14214
+ // src/runtime/update-component.ts
14215
+ import { BUILD as BUILD17, NAMESPACE } from "@rindo/core/internal/app-data";
14216
+
14217
+ // src/runtime/event-emitter.ts
14218
+ import { BUILD as BUILD12 } from "@rindo/core/internal/app-data";
14219
+
14220
+ // src/runtime/element.ts
14221
+ import { BUILD as BUILD11 } from "@rindo/core/internal/app-data";
14222
+
14223
+ // src/runtime/styles.ts
14224
+ import { BUILD as BUILD13 } from "@rindo/core/internal/app-data";
14225
+
14226
+ // src/runtime/vdom/vdom-render.ts
14227
+ import { BUILD as BUILD16 } from "@rindo/core/internal/app-data";
14228
+
14229
+ // src/runtime/vdom/update-element.ts
14230
+ import { BUILD as BUILD15 } from "@rindo/core/internal/app-data";
14231
+
14232
+ // src/runtime/vdom/set-accessor.ts
14233
+ import { BUILD as BUILD14 } from "@rindo/core/internal/app-data";
14234
+ var CAPTURE_EVENT_SUFFIX = "Capture";
14235
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
14236
+
14237
+ // src/runtime/disconnected-callback.ts
14238
+ import { BUILD as BUILD22 } from "@rindo/core/internal/app-data";
14239
+
14240
+ // src/runtime/dom-extras.ts
14241
+ import { BUILD as BUILD23 } from "@rindo/core/internal/app-data";
14242
+
14243
+ // src/runtime/bootstrap-lazy.ts
14244
+ import { BUILD as BUILD25 } from "@rindo/core/internal/app-data";
14245
+
14246
+ // src/runtime/host-listener.ts
14247
+ import { BUILD as BUILD26 } from "@rindo/core/internal/app-data";
14248
+
14105
14249
  // src/compiler/html/canonical-link.ts
14106
- var updateCanonicalLink = (doc, href) => {
14250
+ var updateCanonicalLink = (doc2, href) => {
14107
14251
  var _a2;
14108
- let canonicalLinkElm = doc.head.querySelector('link[rel="canonical"]');
14252
+ let canonicalLinkElm = doc2.head.querySelector('link[rel="canonical"]');
14109
14253
  if (typeof href === "string") {
14110
14254
  if (canonicalLinkElm == null) {
14111
- canonicalLinkElm = doc.createElement("link");
14255
+ canonicalLinkElm = doc2.createElement("link");
14112
14256
  canonicalLinkElm.setAttribute("rel", "canonical");
14113
- doc.head.appendChild(canonicalLinkElm);
14257
+ doc2.head.appendChild(canonicalLinkElm);
14114
14258
  }
14115
14259
  canonicalLinkElm.setAttribute("href", href);
14116
14260
  } else {
@@ -14124,11 +14268,11 @@ var updateCanonicalLink = (doc, href) => {
14124
14268
  };
14125
14269
 
14126
14270
  // src/compiler/html/relocate-meta-charset.ts
14127
- var relocateMetaCharset = (doc) => {
14128
- const head = doc.head;
14271
+ var relocateMetaCharset = (doc2) => {
14272
+ const head = doc2.head;
14129
14273
  let charsetElm = head.querySelector("meta[charset]");
14130
14274
  if (charsetElm == null) {
14131
- charsetElm = doc.createElement("meta");
14275
+ charsetElm = doc2.createElement("meta");
14132
14276
  charsetElm.setAttribute("charset", "utf-8");
14133
14277
  } else {
14134
14278
  charsetElm.remove();
@@ -14403,13 +14547,13 @@ var parseCss = (css, filePath) => {
14403
14547
  const m = match(/^@([-\w]+)?document *([^{]+)/);
14404
14548
  if (!m) return null;
14405
14549
  const vendor = trim(m[1]);
14406
- const doc = trim(m[2]);
14550
+ const doc2 = trim(m[2]);
14407
14551
  if (!open()) return error(`@document missing '{'`);
14408
14552
  const style = comments().concat(rules());
14409
14553
  if (!close()) return error(`@document missing '}'`);
14410
14554
  return pos({
14411
14555
  type: 3 /* Document */,
14412
- document: doc,
14556
+ document: doc2,
14413
14557
  vendor,
14414
14558
  rules: style
14415
14559
  });
@@ -14735,11 +14879,11 @@ var serializeCssPage = (opts, node) => {
14735
14879
  };
14736
14880
  var serializeCssDocument = (opts, node) => {
14737
14881
  const documentCss = serializeCssMapVisit(opts, node.rules);
14738
- const doc = "@" + (node.vendor || "") + "document " + node.document;
14882
+ const doc2 = "@" + (node.vendor || "") + "document " + node.document;
14739
14883
  if (documentCss === "") {
14740
14884
  return "";
14741
14885
  }
14742
- return doc + "{" + documentCss + "}";
14886
+ return doc2 + "{" + documentCss + "}";
14743
14887
  };
14744
14888
  var serializeCssMapVisit = (opts, nodes) => {
14745
14889
  let rtn = "";
@@ -14837,12 +14981,12 @@ var collectUsedSelectors = (usedSelectors, elm) => {
14837
14981
  };
14838
14982
 
14839
14983
  // src/compiler/html/remove-unused-styles.ts
14840
- var removeUnusedStyles = (doc, diagnostics) => {
14984
+ var removeUnusedStyles = (doc2, diagnostics) => {
14841
14985
  try {
14842
- const styleElms = doc.head.querySelectorAll(`style[data-styles]`);
14986
+ const styleElms = doc2.head.querySelectorAll(`style[data-styles]`);
14843
14987
  const styleLen = styleElms.length;
14844
14988
  if (styleLen > 0) {
14845
- const usedSelectors = getUsedSelectors(doc.documentElement);
14989
+ const usedSelectors = getUsedSelectors(doc2.documentElement);
14846
14990
  for (let i = 0; i < styleLen; i++) {
14847
14991
  removeUnusedStyleText(usedSelectors, diagnostics, styleElms[i]);
14848
14992
  }
@@ -14975,49 +15119,49 @@ function collectAttributes(node) {
14975
15119
  var SKIP_ATTRS = /* @__PURE__ */ new Set(["s-id", "c-id"]);
14976
15120
 
14977
15121
  // src/hydrate/runner/patch-dom-implementation.ts
14978
- function patchDomImplementation(doc, opts) {
14979
- let win;
14980
- if (doc.defaultView != null) {
15122
+ function patchDomImplementation(doc2, opts) {
15123
+ let win2;
15124
+ if (doc2.defaultView != null) {
14981
15125
  opts.destroyWindow = true;
14982
- patchWindow(doc.defaultView);
14983
- win = doc.defaultView;
15126
+ patchWindow(doc2.defaultView);
15127
+ win2 = doc2.defaultView;
14984
15128
  } else {
14985
15129
  opts.destroyWindow = true;
14986
15130
  opts.destroyDocument = false;
14987
- win = new MockWindow(false);
15131
+ win2 = new MockWindow(false);
14988
15132
  }
14989
- if (win.document !== doc) {
14990
- win.document = doc;
15133
+ if (win2.document !== doc2) {
15134
+ win2.document = doc2;
14991
15135
  }
14992
- if (doc.defaultView !== win) {
14993
- doc.defaultView = win;
15136
+ if (doc2.defaultView !== win2) {
15137
+ doc2.defaultView = win2;
14994
15138
  }
14995
- const HTMLElement = doc.documentElement.constructor.prototype;
14996
- if (typeof HTMLElement.getRootNode !== "function") {
14997
- const elm = doc.createElement("unknown-element");
15139
+ const HTMLElement2 = doc2.documentElement.constructor.prototype;
15140
+ if (typeof HTMLElement2.getRootNode !== "function") {
15141
+ const elm = doc2.createElement("unknown-element");
14998
15142
  const HTMLUnknownElement = elm.constructor.prototype;
14999
15143
  HTMLUnknownElement.getRootNode = getRootNode;
15000
15144
  }
15001
- if (typeof doc.createEvent === "function") {
15002
- const CustomEvent = doc.createEvent("CustomEvent").constructor;
15003
- if (win.CustomEvent !== CustomEvent) {
15004
- win.CustomEvent = CustomEvent;
15145
+ if (typeof doc2.createEvent === "function") {
15146
+ const CustomEvent2 = doc2.createEvent("CustomEvent").constructor;
15147
+ if (win2.CustomEvent !== CustomEvent2) {
15148
+ win2.CustomEvent = CustomEvent2;
15005
15149
  }
15006
15150
  }
15007
15151
  try {
15008
- win.__rindo_baseURI = doc.baseURI;
15152
+ win2.__rindo_baseURI = doc2.baseURI;
15009
15153
  } catch (e) {
15010
- Object.defineProperty(doc, "baseURI", {
15154
+ Object.defineProperty(doc2, "baseURI", {
15011
15155
  get() {
15012
- const baseElm = doc.querySelector("base[href]");
15156
+ const baseElm = doc2.querySelector("base[href]");
15013
15157
  if (baseElm) {
15014
- return new URL(baseElm.getAttribute("href"), win.location.href).href;
15158
+ return new URL(baseElm.getAttribute("href"), win2.location.href).href;
15015
15159
  }
15016
- return win.location.href;
15160
+ return win2.location.href;
15017
15161
  }
15018
15162
  });
15019
15163
  }
15020
- return win;
15164
+ return win2;
15021
15165
  }
15022
15166
  function getRootNode(opts) {
15023
15167
  const isComposed = opts != null && opts.composed === true;
@@ -15170,10 +15314,10 @@ function renderCatchError(results, err2) {
15170
15314
  }
15171
15315
 
15172
15316
  // src/hydrate/runner/runtime-log.ts
15173
- function runtimeLogging(win, opts, results) {
15317
+ function runtimeLogging(win2, opts, results) {
15174
15318
  try {
15175
- const pathname = win.location.pathname;
15176
- win.console.error = (...msgs) => {
15319
+ const pathname = win2.location.pathname;
15320
+ win2.console.error = (...msgs) => {
15177
15321
  const errMsg = msgs.reduce((errMsg2, m) => {
15178
15322
  if (m) {
15179
15323
  if (m.stack != null) {
@@ -15193,7 +15337,7 @@ function runtimeLogging(win, opts, results) {
15193
15337
  }
15194
15338
  }
15195
15339
  };
15196
- win.console.debug = (...msgs) => {
15340
+ win2.console.debug = (...msgs) => {
15197
15341
  renderBuildDiagnostic(results, "debug", "Hydrate Debug", [...msgs].join(", "));
15198
15342
  if (opts.runtimeLogging) {
15199
15343
  runtimeLog(pathname, "debug", msgs);
@@ -15201,7 +15345,7 @@ function runtimeLogging(win, opts, results) {
15201
15345
  };
15202
15346
  if (opts.runtimeLogging) {
15203
15347
  ["log", "warn", "assert", "info", "trace"].forEach((type) => {
15204
- win.console[type] = (...msgs) => {
15348
+ win2.console[type] = (...msgs) => {
15205
15349
  runtimeLog(pathname, type, msgs);
15206
15350
  };
15207
15351
  });
@@ -15215,58 +15359,58 @@ function runtimeLog(pathname, type, msgs) {
15215
15359
  }
15216
15360
 
15217
15361
  // src/hydrate/runner/window-initialize.ts
15218
- function initializeWindow(win, doc, opts, results) {
15362
+ function initializeWindow(win2, doc2, opts, results) {
15219
15363
  if (typeof opts.url === "string") {
15220
15364
  try {
15221
- win.location.href = opts.url;
15365
+ win2.location.href = opts.url;
15222
15366
  } catch (e) {
15223
15367
  }
15224
15368
  }
15225
15369
  if (typeof opts.userAgent === "string") {
15226
15370
  try {
15227
- win.navigator.userAgent = opts.userAgent;
15371
+ win2.navigator.userAgent = opts.userAgent;
15228
15372
  } catch (e) {
15229
15373
  }
15230
15374
  }
15231
15375
  if (typeof opts.cookie === "string") {
15232
15376
  try {
15233
- doc.cookie = opts.cookie;
15377
+ doc2.cookie = opts.cookie;
15234
15378
  } catch (e) {
15235
15379
  }
15236
15380
  }
15237
15381
  if (typeof opts.referrer === "string") {
15238
15382
  try {
15239
- doc.referrer = opts.referrer;
15383
+ doc2.referrer = opts.referrer;
15240
15384
  } catch (e) {
15241
15385
  }
15242
15386
  }
15243
15387
  if (typeof opts.direction === "string") {
15244
15388
  try {
15245
- doc.documentElement.setAttribute("dir", opts.direction);
15389
+ doc2.documentElement.setAttribute("dir", opts.direction);
15246
15390
  } catch (e) {
15247
15391
  }
15248
15392
  }
15249
15393
  if (typeof opts.language === "string") {
15250
15394
  try {
15251
- doc.documentElement.setAttribute("lang", opts.language);
15395
+ doc2.documentElement.setAttribute("lang", opts.language);
15252
15396
  } catch (e) {
15253
15397
  }
15254
15398
  }
15255
15399
  if (typeof opts.buildId === "string") {
15256
15400
  try {
15257
- doc.documentElement.setAttribute("data-rindo-build", opts.buildId);
15401
+ doc2.documentElement.setAttribute("data-rindo-build", opts.buildId);
15258
15402
  } catch (e) {
15259
15403
  }
15260
15404
  }
15261
15405
  try {
15262
- win.customElements = null;
15406
+ win2.customElements = null;
15263
15407
  } catch (e) {
15264
15408
  }
15265
15409
  if (opts.constrainTimeouts) {
15266
- constrainTimeouts(win);
15410
+ constrainTimeouts(win2);
15267
15411
  }
15268
- runtimeLogging(win, opts, results);
15269
- return win;
15412
+ runtimeLogging(win2, opts, results);
15413
+ return win2;
15270
15414
  }
15271
15415
 
15272
15416
  // src/hydrate/runner/render.ts
@@ -15283,44 +15427,44 @@ function renderToString(html, options, asStream) {
15283
15427
  opts.constrainTimeouts = false;
15284
15428
  return hydrateDocument(html, opts, asStream);
15285
15429
  }
15286
- function hydrateDocument(doc, options, asStream) {
15430
+ function hydrateDocument(doc2, options, asStream) {
15287
15431
  const opts = normalizeHydrateOptions(options);
15288
- let win = null;
15432
+ let win2 = null;
15289
15433
  const results = generateHydrateResults(opts);
15290
15434
  if (hasError(results.diagnostics)) {
15291
15435
  return Promise.resolve(results);
15292
15436
  }
15293
- if (typeof doc === "string") {
15437
+ if (typeof doc2 === "string") {
15294
15438
  try {
15295
15439
  opts.destroyWindow = true;
15296
15440
  opts.destroyDocument = true;
15297
- win = new MockWindow(doc);
15441
+ win2 = new MockWindow(doc2);
15298
15442
  if (!asStream) {
15299
- return render(win, opts, results).then(() => results);
15443
+ return render(win2, opts, results).then(() => results);
15300
15444
  }
15301
- return renderStream(win, opts, results);
15445
+ return renderStream(win2, opts, results);
15302
15446
  } catch (e) {
15303
- if (win && win.close) {
15304
- win.close();
15447
+ if (win2 && win2.close) {
15448
+ win2.close();
15305
15449
  }
15306
- win = null;
15450
+ win2 = null;
15307
15451
  renderCatchError(results, e);
15308
15452
  return Promise.resolve(results);
15309
15453
  }
15310
15454
  }
15311
- if (isValidDocument(doc)) {
15455
+ if (isValidDocument(doc2)) {
15312
15456
  try {
15313
15457
  opts.destroyDocument = false;
15314
- win = patchDomImplementation(doc, opts);
15458
+ win2 = patchDomImplementation(doc2, opts);
15315
15459
  if (!asStream) {
15316
- return render(win, opts, results).then(() => results);
15460
+ return render(win2, opts, results).then(() => results);
15317
15461
  }
15318
- return renderStream(win, opts, results);
15462
+ return renderStream(win2, opts, results);
15319
15463
  } catch (e) {
15320
- if (win && win.close) {
15321
- win.close();
15464
+ if (win2 && win2.close) {
15465
+ win2.close();
15322
15466
  }
15323
- win = null;
15467
+ win2 = null;
15324
15468
  renderCatchError(results, e);
15325
15469
  return Promise.resolve(results);
15326
15470
  }
@@ -15328,75 +15472,81 @@ function hydrateDocument(doc, options, asStream) {
15328
15472
  renderBuildError(results, `Invalid html or document. Must be either a valid "html" string, or DOM "document".`);
15329
15473
  return Promise.resolve(results);
15330
15474
  }
15331
- async function render(win, opts, results) {
15475
+ async function render(win2, opts, results) {
15332
15476
  if ("process" in globalThis && typeof process.on === "function" && !process.__rindoErrors) {
15333
15477
  process.__rindoErrors = true;
15334
15478
  process.on("unhandledRejection", (e) => {
15335
15479
  console.log("unhandledRejection", e);
15336
15480
  });
15337
15481
  }
15338
- initializeWindow(win, win.document, opts, results);
15482
+ initializeWindow(win2, win2.document, opts, results);
15339
15483
  const beforeHydrateFn = typeof opts.beforeHydrate === "function" ? opts.beforeHydrate : NOOP;
15340
15484
  try {
15341
- await Promise.resolve(beforeHydrateFn(win.document));
15342
- return new Promise((resolve) => hydrateFactory(win, opts, results, afterHydrate, resolve));
15485
+ await Promise.resolve(beforeHydrateFn(win2.document));
15486
+ return new Promise((resolve) => {
15487
+ if (Array.isArray(opts.modes)) {
15488
+ modeResolutionChain.length = 0;
15489
+ opts.modes.forEach((mode) => setMode(mode));
15490
+ }
15491
+ return hydrateFactory(win2, opts, results, afterHydrate, resolve);
15492
+ });
15343
15493
  } catch (e) {
15344
15494
  renderCatchError(results, e);
15345
- return finalizeHydrate(win, win.document, opts, results);
15495
+ return finalizeHydrate(win2, win2.document, opts, results);
15346
15496
  }
15347
15497
  }
15348
- function renderStream(win, opts, results) {
15498
+ function renderStream(win2, opts, results) {
15349
15499
  async function* processRender() {
15350
- const renderResult = await render(win, opts, results);
15500
+ const renderResult = await render(win2, opts, results);
15351
15501
  yield renderResult.html;
15352
15502
  }
15353
15503
  return Readable.from(processRender());
15354
15504
  }
15355
- async function afterHydrate(win, opts, results, resolve) {
15505
+ async function afterHydrate(win2, opts, results, resolve) {
15356
15506
  const afterHydrateFn = typeof opts.afterHydrate === "function" ? opts.afterHydrate : NOOP;
15357
15507
  try {
15358
- await Promise.resolve(afterHydrateFn(win.document));
15359
- return resolve(finalizeHydrate(win, win.document, opts, results));
15508
+ await Promise.resolve(afterHydrateFn(win2.document));
15509
+ return resolve(finalizeHydrate(win2, win2.document, opts, results));
15360
15510
  } catch (e) {
15361
15511
  renderCatchError(results, e);
15362
- return resolve(finalizeHydrate(win, win.document, opts, results));
15512
+ return resolve(finalizeHydrate(win2, win2.document, opts, results));
15363
15513
  }
15364
15514
  }
15365
- function finalizeHydrate(win, doc, opts, results) {
15515
+ function finalizeHydrate(win2, doc2, opts, results) {
15366
15516
  try {
15367
- inspectElement(results, doc.documentElement, 0);
15517
+ inspectElement(results, doc2.documentElement, 0);
15368
15518
  if (opts.removeUnusedStyles !== false) {
15369
15519
  try {
15370
- removeUnusedStyles(doc, results.diagnostics);
15520
+ removeUnusedStyles(doc2, results.diagnostics);
15371
15521
  } catch (e) {
15372
15522
  renderCatchError(results, e);
15373
15523
  }
15374
15524
  }
15375
15525
  if (typeof opts.title === "string") {
15376
15526
  try {
15377
- doc.title = opts.title;
15527
+ doc2.title = opts.title;
15378
15528
  } catch (e) {
15379
15529
  renderCatchError(results, e);
15380
15530
  }
15381
15531
  }
15382
- results.title = doc.title;
15532
+ results.title = doc2.title;
15383
15533
  if (opts.removeScripts) {
15384
- removeScripts(doc.documentElement);
15534
+ removeScripts(doc2.documentElement);
15385
15535
  }
15386
15536
  try {
15387
- updateCanonicalLink(doc, opts.canonicalUrl);
15537
+ updateCanonicalLink(doc2, opts.canonicalUrl);
15388
15538
  } catch (e) {
15389
15539
  renderCatchError(results, e);
15390
15540
  }
15391
15541
  try {
15392
- relocateMetaCharset(doc);
15542
+ relocateMetaCharset(doc2);
15393
15543
  } catch (e) {
15394
15544
  }
15395
15545
  if (!hasError(results.diagnostics)) {
15396
15546
  results.httpStatus = 200;
15397
15547
  }
15398
15548
  try {
15399
- const metaStatus = doc.head.querySelector('meta[http-equiv="status"]');
15549
+ const metaStatus = doc2.head.querySelector('meta[http-equiv="status"]');
15400
15550
  if (metaStatus != null) {
15401
15551
  const metaStatusContent = metaStatus.getAttribute("content");
15402
15552
  if (metaStatusContent && metaStatusContent.length > 0) {
@@ -15406,35 +15556,35 @@ function finalizeHydrate(win, doc, opts, results) {
15406
15556
  } catch (e) {
15407
15557
  }
15408
15558
  if (opts.clientHydrateAnnotations) {
15409
- doc.documentElement.classList.add("hydrated");
15559
+ doc2.documentElement.classList.add("hydrated");
15410
15560
  }
15411
15561
  if (opts.serializeToHtml) {
15412
- results.html = serializeDocumentToString(doc, opts);
15562
+ results.html = serializeDocumentToString(doc2, opts);
15413
15563
  }
15414
15564
  } catch (e) {
15415
15565
  renderCatchError(results, e);
15416
15566
  }
15417
- destroyWindow(win, doc, opts, results);
15567
+ destroyWindow(win2, doc2, opts, results);
15418
15568
  return results;
15419
15569
  }
15420
- function destroyWindow(win, doc, opts, results) {
15570
+ function destroyWindow(win2, doc2, opts, results) {
15421
15571
  if (!opts.destroyWindow) {
15422
15572
  return;
15423
15573
  }
15424
15574
  try {
15425
15575
  if (!opts.destroyDocument) {
15426
- win.document = null;
15427
- doc.defaultView = null;
15576
+ win2.document = null;
15577
+ doc2.defaultView = null;
15428
15578
  }
15429
- if (win.close) {
15430
- win.close();
15579
+ if (win2.close) {
15580
+ win2.close();
15431
15581
  }
15432
15582
  } catch (e) {
15433
15583
  renderCatchError(results, e);
15434
15584
  }
15435
15585
  }
15436
- function serializeDocumentToString(doc, opts) {
15437
- return serializeNodeToHtml(doc, {
15586
+ function serializeDocumentToString(doc2, opts) {
15587
+ return serializeNodeToHtml(doc2, {
15438
15588
  approximateLineWidth: opts.approximateLineWidth,
15439
15589
  outerHtml: false,
15440
15590
  prettyHtml: opts.prettyHtml,
@@ -15446,8 +15596,8 @@ function serializeDocumentToString(doc, opts) {
15446
15596
  fullDocument: opts.fullDocument
15447
15597
  });
15448
15598
  }
15449
- function isValidDocument(doc) {
15450
- return doc != null && doc.nodeType === 9 && doc.documentElement != null && doc.documentElement.nodeType === 1 && doc.body != null && doc.body.nodeType === 1;
15599
+ function isValidDocument(doc2) {
15600
+ return doc2 != null && doc2.nodeType === 9 && doc2.documentElement != null && doc2.documentElement.nodeType === 1 && doc2.body != null && doc2.body.nodeType === 1;
15451
15601
  }
15452
15602
  function removeScripts(elm) {
15453
15603
  const children = elm.children;