@lightspeed-js/core 0.4.0 → 0.4.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.
package/dist/index.js CHANGED
@@ -1330,7 +1330,11 @@ class Mounter {
1330
1330
  };
1331
1331
  if (adopt) {
1332
1332
  const adopted = [];
1333
- if (this.adoptNodes(Array.from(fragment.childNodes), adopt, context, adopted)) {
1333
+ if (!parent)
1334
+ context.rootSlots = groupSlotFills(slotNodes);
1335
+ const adoptedAll = this.adoptNodes(Array.from(fragment.childNodes), adopt, context, adopted);
1336
+ delete context.rootSlots;
1337
+ if (adoptedAll) {
1334
1338
  for (const marker of adopted) {
1335
1339
  await this.mountMarker(marker, instance, context);
1336
1340
  }
@@ -1588,9 +1592,15 @@ class Mounter {
1588
1592
  d = found.length;
1589
1593
  continue;
1590
1594
  }
1595
+ const name = found[d].data.slice(SLOT_MARK.length);
1596
+ const region = [];
1597
+ d++;
1591
1598
  while (d < found.length && !isSlotEnd(found[d]))
1592
- d++;
1599
+ region.push(found[d++]);
1593
1600
  d++;
1601
+ if (context.rootSlots && !this.adoptNodes(context.rootSlots.get(name) ?? [], region, context, markers)) {
1602
+ return false;
1603
+ }
1594
1604
  continue;
1595
1605
  }
1596
1606
  const target = found[d++];
@@ -3031,7 +3041,13 @@ function createLightspeedApp(options) {
3031
3041
  return new LightspeedRuntime(options);
3032
3042
  }
3033
3043
  function serializeNodes(nodes) {
3034
- return nodes.map((node) => node.nodeType === 1 ? node.outerHTML : node.textContent ?? "").join("");
3044
+ const document2 = nodes[0]?.ownerDocument;
3045
+ if (!document2)
3046
+ return "";
3047
+ const template = document2.createElement("template");
3048
+ for (const node of nodes)
3049
+ template.content.appendChild(node.cloneNode(true));
3050
+ return template.innerHTML;
3035
3051
  }
3036
3052
  // src/runtime/helpers.ts
3037
3053
  function reactive(target) {
package/dist/ssg.js CHANGED
@@ -1353,7 +1353,11 @@ class Mounter {
1353
1353
  };
1354
1354
  if (adopt) {
1355
1355
  const adopted = [];
1356
- if (this.adoptNodes(Array.from(fragment.childNodes), adopt, context, adopted)) {
1356
+ if (!parent)
1357
+ context.rootSlots = groupSlotFills(slotNodes);
1358
+ const adoptedAll = this.adoptNodes(Array.from(fragment.childNodes), adopt, context, adopted);
1359
+ delete context.rootSlots;
1360
+ if (adoptedAll) {
1357
1361
  for (const marker of adopted) {
1358
1362
  await this.mountMarker(marker, instance, context);
1359
1363
  }
@@ -1611,9 +1615,15 @@ class Mounter {
1611
1615
  d = found.length;
1612
1616
  continue;
1613
1617
  }
1618
+ const name = found[d].data.slice(SLOT_MARK.length);
1619
+ const region = [];
1620
+ d++;
1614
1621
  while (d < found.length && !isSlotEnd(found[d]))
1615
- d++;
1622
+ region.push(found[d++]);
1616
1623
  d++;
1624
+ if (context.rootSlots && !this.adoptNodes(context.rootSlots.get(name) ?? [], region, context, markers)) {
1625
+ return false;
1626
+ }
1617
1627
  continue;
1618
1628
  }
1619
1629
  const target = found[d++];
@@ -3136,7 +3146,13 @@ class LightspeedRuntime {
3136
3146
  }
3137
3147
  }
3138
3148
  function serializeNodes(nodes) {
3139
- return nodes.map((node) => node.nodeType === 1 ? node.outerHTML : node.textContent ?? "").join("");
3149
+ const document2 = nodes[0]?.ownerDocument;
3150
+ if (!document2)
3151
+ return "";
3152
+ const template = document2.createElement("template");
3153
+ for (const node of nodes)
3154
+ template.content.appendChild(node.cloneNode(true));
3155
+ return template.innerHTML;
3140
3156
  }
3141
3157
 
3142
3158
  // src/ssg/render.ts
@@ -3434,13 +3450,11 @@ function allComments(document2) {
3434
3450
  return comments;
3435
3451
  }
3436
3452
  function serialiseBetween(start, end) {
3437
- let html = "";
3438
- let current = start.nextSibling;
3439
- while (current && current !== end) {
3440
- html += current.nodeType === 1 ? current.outerHTML : current.textContent ?? "";
3441
- current = current.nextSibling;
3453
+ const template = start.ownerDocument.createElement("template");
3454
+ for (let current = start.nextSibling;current && current !== end; current = current.nextSibling) {
3455
+ template.content.appendChild(current.cloneNode(true));
3442
3456
  }
3443
- return html;
3457
+ return template.innerHTML;
3444
3458
  }
3445
3459
  // src/compile/expressions.ts
3446
3460
  function expressionKey(expr, params) {
package/dist/vite.js CHANGED
@@ -784,7 +784,11 @@ class Mounter {
784
784
  };
785
785
  if (adopt) {
786
786
  const adopted = [];
787
- if (this.adoptNodes(Array.from(fragment.childNodes), adopt, context, adopted)) {
787
+ if (!parent)
788
+ context.rootSlots = groupSlotFills(slotNodes);
789
+ const adoptedAll = this.adoptNodes(Array.from(fragment.childNodes), adopt, context, adopted);
790
+ delete context.rootSlots;
791
+ if (adoptedAll) {
788
792
  for (const marker of adopted) {
789
793
  await this.mountMarker(marker, instance, context);
790
794
  }
@@ -1042,9 +1046,15 @@ class Mounter {
1042
1046
  d = found.length;
1043
1047
  continue;
1044
1048
  }
1049
+ const name = found[d].data.slice(SLOT_MARK.length);
1050
+ const region = [];
1051
+ d++;
1045
1052
  while (d < found.length && !isSlotEnd(found[d]))
1046
- d++;
1053
+ region.push(found[d++]);
1047
1054
  d++;
1055
+ if (context.rootSlots && !this.adoptNodes(context.rootSlots.get(name) ?? [], region, context, markers)) {
1056
+ return false;
1057
+ }
1048
1058
  continue;
1049
1059
  }
1050
1060
  const target = found[d++];
@@ -4525,7 +4535,13 @@ class LightspeedRuntime {
4525
4535
  }
4526
4536
  }
4527
4537
  function serializeNodes(nodes) {
4528
- return nodes.map((node) => node.nodeType === 1 ? node.outerHTML : node.textContent ?? "").join("");
4538
+ const document2 = nodes[0]?.ownerDocument;
4539
+ if (!document2)
4540
+ return "";
4541
+ const template = document2.createElement("template");
4542
+ for (const node of nodes)
4543
+ template.content.appendChild(node.cloneNode(true));
4544
+ return template.innerHTML;
4529
4545
  }
4530
4546
 
4531
4547
  // src/ssg/render.ts
@@ -4823,13 +4839,11 @@ function allComments(document2) {
4823
4839
  return comments;
4824
4840
  }
4825
4841
  function serialiseBetween(start, end) {
4826
- let html = "";
4827
- let current = start.nextSibling;
4828
- while (current && current !== end) {
4829
- html += current.nodeType === 1 ? current.outerHTML : current.textContent ?? "";
4830
- current = current.nextSibling;
4842
+ const template = start.ownerDocument.createElement("template");
4843
+ for (let current = start.nextSibling;current && current !== end; current = current.nextSibling) {
4844
+ template.content.appendChild(current.cloneNode(true));
4831
4845
  }
4832
- return html;
4846
+ return template.innerHTML;
4833
4847
  }
4834
4848
 
4835
4849
  // src/vite/layout.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed-js/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Lightspeed: a compile-first framework for islands of reactivity in static HTML.",
5
5
  "keywords": [
6
6
  "lightspeed",