@rindo/core 4.27.0 → 4.27.1

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Rindo Hydrate Platform v4.27.0 | MIT Licensed | https://rindojs.web.app
2
+ Rindo Hydrate Platform v4.27.1 | MIT Licensed | https://rindojs.web.app
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -59,9 +59,9 @@ var isComplexType = (o) => {
59
59
  };
60
60
 
61
61
  // src/utils/query-nonce-meta-tag-content.ts
62
- function queryNonceMetaTagContent(doc2) {
62
+ function queryNonceMetaTagContent(doc) {
63
63
  var _a, _b, _c;
64
- return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
64
+ return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
65
65
  }
66
66
 
67
67
  // src/utils/regular-expression.ts
@@ -916,8 +916,8 @@ var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
916
916
  delete hostElm["s-sc"];
917
917
  }
918
918
  }
919
- if (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size) {
920
- initializeDocumentHydrate(doc.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
919
+ if (win.document && (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size)) {
920
+ initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
921
921
  }
922
922
  hostElm[HYDRATE_ID] = hostId;
923
923
  hostElm.removeAttribute(HYDRATE_ID);
@@ -1243,8 +1243,8 @@ function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNod
1243
1243
  childVNode.$name$ = slotName || null;
1244
1244
  childVNode.$tag$ = "slot";
1245
1245
  const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
1246
- if (BUILD6.shadowDom && shadowRootNodes) {
1247
- const slot = childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1246
+ if (BUILD6.shadowDom && shadowRootNodes && win.document) {
1247
+ const slot = childVNode.$elm$ = win.document.createElement(childVNode.$tag$);
1248
1248
  if (childVNode.$name$) {
1249
1249
  childVNode.$elm$.setAttribute("name", slotName);
1250
1250
  }
@@ -1727,10 +1727,10 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1727
1727
  var _a;
1728
1728
  const scopeId2 = getScopeId(cmpMeta, mode);
1729
1729
  const style = styles.get(scopeId2);
1730
- if (!BUILD10.attachStyles) {
1730
+ if (!BUILD10.attachStyles || !win.document) {
1731
1731
  return scopeId2;
1732
1732
  }
1733
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
1733
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
1734
1734
  if (style) {
1735
1735
  if (typeof style === "string") {
1736
1736
  styleContainerNode = styleContainerNode.head || styleContainerNode;
@@ -1743,9 +1743,9 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
1743
1743
  if (BUILD10.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`))) {
1744
1744
  styleElm.innerHTML = style;
1745
1745
  } else {
1746
- styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || doc.createElement("style");
1746
+ styleElm = document.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`) || win.document.createElement("style");
1747
1747
  styleElm.innerHTML = style;
1748
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
1748
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
1749
1749
  if (nonce != null) {
1750
1750
  styleElm.setAttribute("nonce", nonce);
1751
1751
  }
@@ -1813,7 +1813,10 @@ var attachStyles = (hostRef) => {
1813
1813
  var getScopeId = (cmp, mode) => "sc-" + (BUILD10.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + "-" + mode : cmp.$tagName$);
1814
1814
  var convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, "$1{");
1815
1815
  var hydrateScopedToShadow = () => {
1816
- const styles2 = doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1816
+ if (!win.document) {
1817
+ return;
1818
+ }
1819
+ const styles2 = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1817
1820
  let i2 = 0;
1818
1821
  for (; i2 < styles2.length; i2++) {
1819
1822
  registerStyle(styles2[i2].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles2[i2].innerHTML), true);
@@ -2030,9 +2033,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2030
2033
  );
2031
2034
  }
2032
2035
  if (BUILD13.vdomText && newVNode2.$text$ !== null) {
2033
- elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
2036
+ elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
2034
2037
  } else if (BUILD13.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
2035
- elm = newVNode2.$elm$ = BUILD13.isDebug || BUILD13.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
2038
+ elm = newVNode2.$elm$ = BUILD13.isDebug || BUILD13.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : win.document.createTextNode("");
2036
2039
  if (BUILD13.vdomAttribute) {
2037
2040
  updateElement(null, newVNode2, isSvgMode);
2038
2041
  }
@@ -2040,10 +2043,15 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2040
2043
  if (BUILD13.svg && !isSvgMode) {
2041
2044
  isSvgMode = newVNode2.$tag$ === "svg";
2042
2045
  }
2043
- elm = newVNode2.$elm$ = BUILD13.svg ? doc.createElementNS(
2046
+ if (!win.document) {
2047
+ throw new Error(
2048
+ "You are trying to render a Rindo component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
2049
+ );
2050
+ }
2051
+ elm = newVNode2.$elm$ = BUILD13.svg ? win.document.createElementNS(
2044
2052
  isSvgMode ? SVG_NS : HTML_NS,
2045
2053
  !useNativeShadowDom && BUILD13.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
2046
- ) : doc.createElement(
2054
+ ) : win.document.createElement(
2047
2055
  !useNativeShadowDom && BUILD13.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
2048
2056
  );
2049
2057
  if (BUILD13.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
@@ -2478,8 +2486,8 @@ render() {
2478
2486
  markSlotContentForRelocation(rootVnode.$elm$);
2479
2487
  for (const relocateData of relocateNodes) {
2480
2488
  const nodeToRelocate = relocateData.$nodeToRelocate$;
2481
- if (!nodeToRelocate["s-ol"]) {
2482
- const orgLocationNode = BUILD13.isDebug || BUILD13.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
2489
+ if (!nodeToRelocate["s-ol"] && win.document) {
2490
+ const orgLocationNode = BUILD13.isDebug || BUILD13.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : win.document.createTextNode("");
2483
2491
  orgLocationNode["s-nr"] = nodeToRelocate;
2484
2492
  insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
2485
2493
  }
@@ -2550,10 +2558,10 @@ render() {
2550
2558
  }
2551
2559
  contentRef = void 0;
2552
2560
  };
2553
- var slotReferenceDebugNode = (slotVNode) => doc.createComment(
2561
+ var slotReferenceDebugNode = (slotVNode) => win.document.createComment(
2554
2562
  `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
2555
2563
  );
2556
- var originalLocationDebugNode = (nodeToRelocate) => doc.createComment(
2564
+ var originalLocationDebugNode = (nodeToRelocate) => win.document.createComment(
2557
2565
  `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
2558
2566
  );
2559
2567
 
@@ -3234,7 +3242,10 @@ var connectedCallback = (elm) => {
3234
3242
  }
3235
3243
  };
3236
3244
  var setContentReference = (elm) => {
3237
- const contentRefElm = elm["s-cr"] = doc.createComment(
3245
+ if (!win.document) {
3246
+ return;
3247
+ }
3248
+ const contentRefElm = elm["s-cr"] = win.document.createComment(
3238
3249
  BUILD18.isDebug ? `content-ref (host=${elm.localName})` : ""
3239
3250
  );
3240
3251
  contentRefElm["s-cn"] = true;
@@ -3408,18 +3419,22 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3408
3419
  performance.mark("st:app:start");
3409
3420
  }
3410
3421
  installDevTools();
3422
+ if (!win.document) {
3423
+ console.warn("Rindo: No document found. Skipping bootstrapping lazy components.");
3424
+ return;
3425
+ }
3411
3426
  const endBootstrap = createTime("bootstrapLazy");
3412
3427
  const cmpTags = [];
3413
3428
  const exclude = options.exclude || [];
3414
3429
  const customElements2 = win.customElements;
3415
- const head = doc.head;
3430
+ const head = win.document.head;
3416
3431
  const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
3417
- const dataStyles = /* @__PURE__ */ doc.createElement("style");
3432
+ const dataStyles = /* @__PURE__ */ win.document.createElement("style");
3418
3433
  const deferredConnectedCallbacks = [];
3419
3434
  let appLoadFallback;
3420
3435
  let isBootstrapping = true;
3421
3436
  Object.assign(plt, options);
3422
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", doc.baseURI).href;
3437
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", win.document.baseURI).href;
3423
3438
  if (BUILD21.asyncQueue) {
3424
3439
  if (options.syncQueue) {
3425
3440
  plt.$flags$ |= 4 /* queueSync */;
@@ -3569,7 +3584,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
3569
3584
  }
3570
3585
  if (dataStyles.innerHTML.length) {
3571
3586
  dataStyles.setAttribute("data-styles", "");
3572
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(doc);
3587
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
3573
3588
  if (nonce != null) {
3574
3589
  dataStyles.setAttribute("nonce", nonce);
3575
3590
  }
@@ -3595,7 +3610,7 @@ var Fragment = (_, children) => children;
3595
3610
  // src/runtime/host-listener.ts
3596
3611
  import { BUILD as BUILD22 } from "@rindo/core/internal/app-data";
3597
3612
  var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
3598
- if (BUILD22.hostListener && listeners) {
3613
+ if (BUILD22.hostListener && listeners && win.document) {
3599
3614
  if (BUILD22.hostListenerTargetParent) {
3600
3615
  if (attachParentListeners) {
3601
3616
  listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
@@ -3604,7 +3619,7 @@ var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =>
3604
3619
  }
3605
3620
  }
3606
3621
  listeners.map(([flags, name, method]) => {
3607
- const target = BUILD22.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
3622
+ const target = BUILD22.hostListenerTarget ? getHostListenerTarget(win.document, elm, flags) : elm;
3608
3623
  const handler = hostListenerProxy(hostRef, method);
3609
3624
  const opts = hostListenerOpts(flags);
3610
3625
  plt.ael(target, name, handler, opts);
@@ -3628,12 +3643,19 @@ var hostListenerProxy = (hostRef, methodName) => (ev) => {
3628
3643
  consoleError(e, hostRef.$hostElement$);
3629
3644
  }
3630
3645
  };
3631
- var getHostListenerTarget = (elm, flags) => {
3632
- if (BUILD22.hostListenerTargetDocument && flags & 4 /* TargetDocument */) return doc;
3633
- if (BUILD22.hostListenerTargetWindow && flags & 8 /* TargetWindow */) return win;
3634
- if (BUILD22.hostListenerTargetBody && flags & 16 /* TargetBody */) return doc.body;
3635
- if (BUILD22.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement)
3646
+ var getHostListenerTarget = (doc, elm, flags) => {
3647
+ if (BUILD22.hostListenerTargetDocument && flags & 4 /* TargetDocument */) {
3648
+ return doc;
3649
+ }
3650
+ if (BUILD22.hostListenerTargetWindow && flags & 8 /* TargetWindow */) {
3651
+ return win;
3652
+ }
3653
+ if (BUILD22.hostListenerTargetBody && flags & 16 /* TargetBody */) {
3654
+ return doc.body;
3655
+ }
3656
+ if (BUILD22.hostListenerTargetParent && flags & 32 /* TargetParent */ && elm.parentElement) {
3636
3657
  return elm.parentElement;
3658
+ }
3637
3659
  return elm;
3638
3660
  };
3639
3661
  var hostListenerOpts = (flags) => supportsListenerOptions ? {
@@ -3645,12 +3667,12 @@ var hostListenerOpts = (flags) => supportsListenerOptions ? {
3645
3667
  var setNonce = (nonce) => plt.$nonce$ = nonce;
3646
3668
 
3647
3669
  // src/runtime/vdom/vdom-annotations.ts
3648
- var insertVdomAnnotations = (doc2, staticComponents) => {
3649
- if (doc2 != null) {
3650
- const docData = RINDO_DOC_DATA in doc2 ? doc2[RINDO_DOC_DATA] : { ...DEFAULT_DOC_DATA };
3670
+ var insertVdomAnnotations = (doc, staticComponents) => {
3671
+ if (doc != null) {
3672
+ const docData = RINDO_DOC_DATA in doc ? doc[RINDO_DOC_DATA] : { ...DEFAULT_DOC_DATA };
3651
3673
  docData.staticComponents = new Set(staticComponents);
3652
3674
  const orgLocationNodes = [];
3653
- parseVNodeAnnotations(doc2, doc2.body, docData, orgLocationNodes);
3675
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3654
3676
  orgLocationNodes.forEach((orgLocationNode) => {
3655
3677
  var _a;
3656
3678
  if (orgLocationNode != null && orgLocationNode["s-nr"]) {
@@ -3676,11 +3698,11 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
3676
3698
  return;
3677
3699
  }
3678
3700
  }
3679
- const commentBeforeTextNode = doc2.createComment(childId);
3701
+ const commentBeforeTextNode = doc.createComment(childId);
3680
3702
  commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3681
3703
  insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
3682
3704
  } else if (nodeRef.nodeType === 8 /* CommentNode */) {
3683
- const commentBeforeTextNode = doc2.createComment(childId);
3705
+ const commentBeforeTextNode = doc.createComment(childId);
3684
3706
  commentBeforeTextNode.nodeValue = `${COMMENT_NODE_ID}.${childId}`;
3685
3707
  nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3686
3708
  }
@@ -3699,7 +3721,7 @@ var insertVdomAnnotations = (doc2, staticComponents) => {
3699
3721
  });
3700
3722
  }
3701
3723
  };
3702
- var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
3724
+ var parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3703
3725
  var _a;
3704
3726
  if (node == null) {
3705
3727
  return;
@@ -3715,13 +3737,13 @@ var parseVNodeAnnotations = (doc2, node, docData, orgLocationNodes) => {
3715
3737
  const cmpData = {
3716
3738
  nodeIds: 0
3717
3739
  };
3718
- insertVNodeAnnotations(doc2, childNode, hostRef.$vnode$, docData, cmpData);
3740
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3719
3741
  }
3720
- parseVNodeAnnotations(doc2, childNode, docData, orgLocationNodes);
3742
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3721
3743
  });
3722
3744
  }
3723
3745
  };
3724
- var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
3746
+ var insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3725
3747
  if (vnode != null) {
3726
3748
  const hostId = ++docData.hostIds;
3727
3749
  hostElm.setAttribute(HYDRATE_ID, hostId);
@@ -3731,7 +3753,7 @@ var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
3731
3753
  if (vnode.$children$ != null) {
3732
3754
  const depth = 0;
3733
3755
  vnode.$children$.forEach((vnodeChild, index) => {
3734
- insertChildVNodeAnnotations(doc2, vnodeChild, cmpData, hostId, depth, index);
3756
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3735
3757
  });
3736
3758
  }
3737
3759
  if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
@@ -3752,7 +3774,7 @@ var insertVNodeAnnotations = (doc2, hostElm, vnode, docData, cmpData) => {
3752
3774
  }
3753
3775
  }
3754
3776
  };
3755
- var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, index) => {
3777
+ var insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3756
3778
  const childElm = vnodeChild.$elm$;
3757
3779
  if (childElm == null) {
3758
3780
  return;
@@ -3771,7 +3793,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
3771
3793
  const nodeName = parentNode == null ? void 0 : parentNode.nodeName;
3772
3794
  if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
3773
3795
  const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3774
- const commentBeforeTextNode = doc2.createComment(textNodeId);
3796
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3775
3797
  insertBefore(parentNode, commentBeforeTextNode, childElm);
3776
3798
  }
3777
3799
  } else if (childElm.nodeType === 8 /* CommentNode */) {
@@ -3784,7 +3806,7 @@ var insertChildVNodeAnnotations = (doc2, vnodeChild, cmpData, hostId, depth, ind
3784
3806
  if (vnodeChild.$children$ != null) {
3785
3807
  const childDepth = depth + 1;
3786
3808
  vnodeChild.$children$.forEach((vnode, index2) => {
3787
- insertChildVNodeAnnotations(doc2, vnode, cmpData, hostId, childDepth, index2);
3809
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index2);
3788
3810
  });
3789
3811
  }
3790
3812
  };
@@ -4015,7 +4037,7 @@ function hydrateApp(win2, opts, results, afterHydrate, resolve) {
4015
4037
  return elm;
4016
4038
  };
4017
4039
  tmrId = globalThis.setTimeout(timeoutExceeded, opts.timeout);
4018
- plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", doc.baseURI).href;
4040
+ plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", win2.document.baseURI).href;
4019
4041
  globalScripts();
4020
4042
  patchChild2(win2.document.body);
4021
4043
  waitLoop2().then(hydratedComplete).catch(hydratedError);
@@ -4229,7 +4251,6 @@ var registerComponents = (Cstrs) => {
4229
4251
  }
4230
4252
  };
4231
4253
  var win = window;
4232
- var doc = win.document;
4233
4254
  var readTask = (cb) => {
4234
4255
  nextTick(() => {
4235
4256
  try {
@@ -4333,7 +4354,6 @@ export {
4333
4354
  createEvent,
4334
4355
  defineCustomElement,
4335
4356
  disconnectedCallback,
4336
- doc,
4337
4357
  forceModeUpdate,
4338
4358
  forceUpdate,
4339
4359
  getAssetPath,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rindo/core/internal/hydrate",
3
- "version": "4.27.0",
3
+ "version": "4.27.1",
4
4
  "description": "Rindo internal hydrate platform to be imported by the Rindo Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true