@lightspeed-js/core 0.4.0 → 0.4.2
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/compile.js +6 -4
- package/dist/index.js +22 -5
- package/dist/ssg.js +32 -15
- package/dist/vite.js +32 -15
- package/package.json +1 -1
package/dist/compile.js
CHANGED
|
@@ -345,15 +345,17 @@ function transformRules(css, scopes, scopeId, renames) {
|
|
|
345
345
|
const bodyEnd = matchBrace(css, i);
|
|
346
346
|
const body = css.slice(i + 1, bodyEnd);
|
|
347
347
|
i = bodyEnd + 1;
|
|
348
|
-
const
|
|
348
|
+
const leading = /^(?:\s|\/\*[\s\S]*?\*\/)*/.exec(prelude.text)?.[0] ?? "";
|
|
349
|
+
const rule = prelude.text.slice(leading.length);
|
|
350
|
+
const trimmed = rule.trim();
|
|
349
351
|
if (trimmed.startsWith("@")) {
|
|
350
352
|
const name = trimmed.split(/[\s({]/)[0].toLowerCase();
|
|
351
353
|
if (name.endsWith("keyframes")) {
|
|
352
|
-
out += `${renameKeyframe(
|
|
354
|
+
out += `${leading}${renameKeyframe(rule, scopeId)}{${body}}`;
|
|
353
355
|
} else if (NESTED_AT_RULES.has(name)) {
|
|
354
|
-
out += `${
|
|
356
|
+
out += `${leading}${rule}{${transformRules(body, scopes, scopeId, renames)}}`;
|
|
355
357
|
} else {
|
|
356
|
-
out += `${
|
|
358
|
+
out += `${leading}${rule}{${body}}`;
|
|
357
359
|
}
|
|
358
360
|
continue;
|
|
359
361
|
}
|
package/dist/index.js
CHANGED
|
@@ -1330,7 +1330,11 @@ class Mounter {
|
|
|
1330
1330
|
};
|
|
1331
1331
|
if (adopt) {
|
|
1332
1332
|
const adopted = [];
|
|
1333
|
-
if (
|
|
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
|
}
|
|
@@ -1491,6 +1495,8 @@ class Mounter {
|
|
|
1491
1495
|
const children = Array.from(node.childNodes);
|
|
1492
1496
|
for (let i = 0;i < children.length; i++) {
|
|
1493
1497
|
const child = children[i];
|
|
1498
|
+
if (child.parentNode !== node)
|
|
1499
|
+
continue;
|
|
1494
1500
|
if (!isMarkerStart(child)) {
|
|
1495
1501
|
this.collect(child, context, skip, markers);
|
|
1496
1502
|
continue;
|
|
@@ -1588,9 +1594,15 @@ class Mounter {
|
|
|
1588
1594
|
d = found.length;
|
|
1589
1595
|
continue;
|
|
1590
1596
|
}
|
|
1597
|
+
const name = found[d].data.slice(SLOT_MARK.length);
|
|
1598
|
+
const region = [];
|
|
1599
|
+
d++;
|
|
1591
1600
|
while (d < found.length && !isSlotEnd(found[d]))
|
|
1592
|
-
d
|
|
1601
|
+
region.push(found[d++]);
|
|
1593
1602
|
d++;
|
|
1603
|
+
if (context.rootSlots && !this.adoptNodes(context.rootSlots.get(name) ?? [], region, context, markers)) {
|
|
1604
|
+
return false;
|
|
1605
|
+
}
|
|
1594
1606
|
continue;
|
|
1595
1607
|
}
|
|
1596
1608
|
const target = found[d++];
|
|
@@ -2637,6 +2649,7 @@ class LightspeedRuntime {
|
|
|
2637
2649
|
fail(`Error executing logic for ${instance.id}:`, error);
|
|
2638
2650
|
}
|
|
2639
2651
|
}
|
|
2652
|
+
this.runUpdateCallbacks(instance);
|
|
2640
2653
|
this.instances.set(instanceId, instance);
|
|
2641
2654
|
return instance;
|
|
2642
2655
|
}
|
|
@@ -2667,8 +2680,6 @@ class LightspeedRuntime {
|
|
|
2667
2680
|
instance.addLogicCleanup(callback);
|
|
2668
2681
|
},
|
|
2669
2682
|
onUpdate: (callback) => {
|
|
2670
|
-
if (this.ssg)
|
|
2671
|
-
return;
|
|
2672
2683
|
instance.updateCallbacks.push(callback);
|
|
2673
2684
|
},
|
|
2674
2685
|
defineProps: (propsDefinition) => {
|
|
@@ -3031,7 +3042,13 @@ function createLightspeedApp(options) {
|
|
|
3031
3042
|
return new LightspeedRuntime(options);
|
|
3032
3043
|
}
|
|
3033
3044
|
function serializeNodes(nodes) {
|
|
3034
|
-
|
|
3045
|
+
const document2 = nodes[0]?.ownerDocument;
|
|
3046
|
+
if (!document2)
|
|
3047
|
+
return "";
|
|
3048
|
+
const template = document2.createElement("template");
|
|
3049
|
+
for (const node of nodes)
|
|
3050
|
+
template.content.appendChild(node.cloneNode(true));
|
|
3051
|
+
return template.innerHTML;
|
|
3035
3052
|
}
|
|
3036
3053
|
// src/runtime/helpers.ts
|
|
3037
3054
|
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 (
|
|
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
|
}
|
|
@@ -1514,6 +1518,8 @@ class Mounter {
|
|
|
1514
1518
|
const children = Array.from(node.childNodes);
|
|
1515
1519
|
for (let i = 0;i < children.length; i++) {
|
|
1516
1520
|
const child = children[i];
|
|
1521
|
+
if (child.parentNode !== node)
|
|
1522
|
+
continue;
|
|
1517
1523
|
if (!isMarkerStart(child)) {
|
|
1518
1524
|
this.collect(child, context, skip, markers);
|
|
1519
1525
|
continue;
|
|
@@ -1611,9 +1617,15 @@ class Mounter {
|
|
|
1611
1617
|
d = found.length;
|
|
1612
1618
|
continue;
|
|
1613
1619
|
}
|
|
1620
|
+
const name = found[d].data.slice(SLOT_MARK.length);
|
|
1621
|
+
const region = [];
|
|
1622
|
+
d++;
|
|
1614
1623
|
while (d < found.length && !isSlotEnd(found[d]))
|
|
1615
|
-
d
|
|
1624
|
+
region.push(found[d++]);
|
|
1616
1625
|
d++;
|
|
1626
|
+
if (context.rootSlots && !this.adoptNodes(context.rootSlots.get(name) ?? [], region, context, markers)) {
|
|
1627
|
+
return false;
|
|
1628
|
+
}
|
|
1617
1629
|
continue;
|
|
1618
1630
|
}
|
|
1619
1631
|
const target = found[d++];
|
|
@@ -2745,6 +2757,7 @@ class LightspeedRuntime {
|
|
|
2745
2757
|
fail(`Error executing logic for ${instance.id}:`, error);
|
|
2746
2758
|
}
|
|
2747
2759
|
}
|
|
2760
|
+
this.runUpdateCallbacks(instance);
|
|
2748
2761
|
this.instances.set(instanceId, instance);
|
|
2749
2762
|
return instance;
|
|
2750
2763
|
}
|
|
@@ -2775,8 +2788,6 @@ class LightspeedRuntime {
|
|
|
2775
2788
|
instance.addLogicCleanup(callback);
|
|
2776
2789
|
},
|
|
2777
2790
|
onUpdate: (callback) => {
|
|
2778
|
-
if (this.ssg)
|
|
2779
|
-
return;
|
|
2780
2791
|
instance.updateCallbacks.push(callback);
|
|
2781
2792
|
},
|
|
2782
2793
|
defineProps: (propsDefinition) => {
|
|
@@ -3136,7 +3147,13 @@ class LightspeedRuntime {
|
|
|
3136
3147
|
}
|
|
3137
3148
|
}
|
|
3138
3149
|
function serializeNodes(nodes) {
|
|
3139
|
-
|
|
3150
|
+
const document2 = nodes[0]?.ownerDocument;
|
|
3151
|
+
if (!document2)
|
|
3152
|
+
return "";
|
|
3153
|
+
const template = document2.createElement("template");
|
|
3154
|
+
for (const node of nodes)
|
|
3155
|
+
template.content.appendChild(node.cloneNode(true));
|
|
3156
|
+
return template.innerHTML;
|
|
3140
3157
|
}
|
|
3141
3158
|
|
|
3142
3159
|
// src/ssg/render.ts
|
|
@@ -3434,13 +3451,11 @@ function allComments(document2) {
|
|
|
3434
3451
|
return comments;
|
|
3435
3452
|
}
|
|
3436
3453
|
function serialiseBetween(start, end) {
|
|
3437
|
-
|
|
3438
|
-
let current = start.nextSibling;
|
|
3439
|
-
|
|
3440
|
-
html += current.nodeType === 1 ? current.outerHTML : current.textContent ?? "";
|
|
3441
|
-
current = current.nextSibling;
|
|
3454
|
+
const template = start.ownerDocument.createElement("template");
|
|
3455
|
+
for (let current = start.nextSibling;current && current !== end; current = current.nextSibling) {
|
|
3456
|
+
template.content.appendChild(current.cloneNode(true));
|
|
3442
3457
|
}
|
|
3443
|
-
return
|
|
3458
|
+
return template.innerHTML;
|
|
3444
3459
|
}
|
|
3445
3460
|
// src/compile/expressions.ts
|
|
3446
3461
|
function expressionKey(expr, params) {
|
|
@@ -3943,15 +3958,17 @@ function transformRules(css, scopes, scopeId, renames) {
|
|
|
3943
3958
|
const bodyEnd = matchBrace(css, i);
|
|
3944
3959
|
const body = css.slice(i + 1, bodyEnd);
|
|
3945
3960
|
i = bodyEnd + 1;
|
|
3946
|
-
const
|
|
3961
|
+
const leading = /^(?:\s|\/\*[\s\S]*?\*\/)*/.exec(prelude.text)?.[0] ?? "";
|
|
3962
|
+
const rule = prelude.text.slice(leading.length);
|
|
3963
|
+
const trimmed = rule.trim();
|
|
3947
3964
|
if (trimmed.startsWith("@")) {
|
|
3948
3965
|
const name = trimmed.split(/[\s({]/)[0].toLowerCase();
|
|
3949
3966
|
if (name.endsWith("keyframes")) {
|
|
3950
|
-
out += `${renameKeyframe(
|
|
3967
|
+
out += `${leading}${renameKeyframe(rule, scopeId)}{${body}}`;
|
|
3951
3968
|
} else if (NESTED_AT_RULES.has(name)) {
|
|
3952
|
-
out += `${
|
|
3969
|
+
out += `${leading}${rule}{${transformRules(body, scopes, scopeId, renames)}}`;
|
|
3953
3970
|
} else {
|
|
3954
|
-
out += `${
|
|
3971
|
+
out += `${leading}${rule}{${body}}`;
|
|
3955
3972
|
}
|
|
3956
3973
|
continue;
|
|
3957
3974
|
}
|
package/dist/vite.js
CHANGED
|
@@ -784,7 +784,11 @@ class Mounter {
|
|
|
784
784
|
};
|
|
785
785
|
if (adopt) {
|
|
786
786
|
const adopted = [];
|
|
787
|
-
if (
|
|
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
|
}
|
|
@@ -945,6 +949,8 @@ class Mounter {
|
|
|
945
949
|
const children = Array.from(node.childNodes);
|
|
946
950
|
for (let i = 0;i < children.length; i++) {
|
|
947
951
|
const child = children[i];
|
|
952
|
+
if (child.parentNode !== node)
|
|
953
|
+
continue;
|
|
948
954
|
if (!isMarkerStart(child)) {
|
|
949
955
|
this.collect(child, context, skip, markers);
|
|
950
956
|
continue;
|
|
@@ -1042,9 +1048,15 @@ class Mounter {
|
|
|
1042
1048
|
d = found.length;
|
|
1043
1049
|
continue;
|
|
1044
1050
|
}
|
|
1051
|
+
const name = found[d].data.slice(SLOT_MARK.length);
|
|
1052
|
+
const region = [];
|
|
1053
|
+
d++;
|
|
1045
1054
|
while (d < found.length && !isSlotEnd(found[d]))
|
|
1046
|
-
d
|
|
1055
|
+
region.push(found[d++]);
|
|
1047
1056
|
d++;
|
|
1057
|
+
if (context.rootSlots && !this.adoptNodes(context.rootSlots.get(name) ?? [], region, context, markers)) {
|
|
1058
|
+
return false;
|
|
1059
|
+
}
|
|
1048
1060
|
continue;
|
|
1049
1061
|
}
|
|
1050
1062
|
const target = found[d++];
|
|
@@ -2207,15 +2219,17 @@ function transformRules(css, scopes, scopeId, renames) {
|
|
|
2207
2219
|
const bodyEnd = matchBrace(css, i);
|
|
2208
2220
|
const body = css.slice(i + 1, bodyEnd);
|
|
2209
2221
|
i = bodyEnd + 1;
|
|
2210
|
-
const
|
|
2222
|
+
const leading = /^(?:\s|\/\*[\s\S]*?\*\/)*/.exec(prelude.text)?.[0] ?? "";
|
|
2223
|
+
const rule = prelude.text.slice(leading.length);
|
|
2224
|
+
const trimmed = rule.trim();
|
|
2211
2225
|
if (trimmed.startsWith("@")) {
|
|
2212
2226
|
const name = trimmed.split(/[\s({]/)[0].toLowerCase();
|
|
2213
2227
|
if (name.endsWith("keyframes")) {
|
|
2214
|
-
out += `${renameKeyframe(
|
|
2228
|
+
out += `${leading}${renameKeyframe(rule, scopeId)}{${body}}`;
|
|
2215
2229
|
} else if (NESTED_AT_RULES.has(name)) {
|
|
2216
|
-
out += `${
|
|
2230
|
+
out += `${leading}${rule}{${transformRules(body, scopes, scopeId, renames)}}`;
|
|
2217
2231
|
} else {
|
|
2218
|
-
out += `${
|
|
2232
|
+
out += `${leading}${rule}{${body}}`;
|
|
2219
2233
|
}
|
|
2220
2234
|
continue;
|
|
2221
2235
|
}
|
|
@@ -4134,6 +4148,7 @@ class LightspeedRuntime {
|
|
|
4134
4148
|
fail(`Error executing logic for ${instance.id}:`, error);
|
|
4135
4149
|
}
|
|
4136
4150
|
}
|
|
4151
|
+
this.runUpdateCallbacks(instance);
|
|
4137
4152
|
this.instances.set(instanceId, instance);
|
|
4138
4153
|
return instance;
|
|
4139
4154
|
}
|
|
@@ -4164,8 +4179,6 @@ class LightspeedRuntime {
|
|
|
4164
4179
|
instance.addLogicCleanup(callback);
|
|
4165
4180
|
},
|
|
4166
4181
|
onUpdate: (callback) => {
|
|
4167
|
-
if (this.ssg)
|
|
4168
|
-
return;
|
|
4169
4182
|
instance.updateCallbacks.push(callback);
|
|
4170
4183
|
},
|
|
4171
4184
|
defineProps: (propsDefinition) => {
|
|
@@ -4525,7 +4538,13 @@ class LightspeedRuntime {
|
|
|
4525
4538
|
}
|
|
4526
4539
|
}
|
|
4527
4540
|
function serializeNodes(nodes) {
|
|
4528
|
-
|
|
4541
|
+
const document2 = nodes[0]?.ownerDocument;
|
|
4542
|
+
if (!document2)
|
|
4543
|
+
return "";
|
|
4544
|
+
const template = document2.createElement("template");
|
|
4545
|
+
for (const node of nodes)
|
|
4546
|
+
template.content.appendChild(node.cloneNode(true));
|
|
4547
|
+
return template.innerHTML;
|
|
4529
4548
|
}
|
|
4530
4549
|
|
|
4531
4550
|
// src/ssg/render.ts
|
|
@@ -4823,13 +4842,11 @@ function allComments(document2) {
|
|
|
4823
4842
|
return comments;
|
|
4824
4843
|
}
|
|
4825
4844
|
function serialiseBetween(start, end) {
|
|
4826
|
-
|
|
4827
|
-
let current = start.nextSibling;
|
|
4828
|
-
|
|
4829
|
-
html += current.nodeType === 1 ? current.outerHTML : current.textContent ?? "";
|
|
4830
|
-
current = current.nextSibling;
|
|
4845
|
+
const template = start.ownerDocument.createElement("template");
|
|
4846
|
+
for (let current = start.nextSibling;current && current !== end; current = current.nextSibling) {
|
|
4847
|
+
template.content.appendChild(current.cloneNode(true));
|
|
4831
4848
|
}
|
|
4832
|
-
return
|
|
4849
|
+
return template.innerHTML;
|
|
4833
4850
|
}
|
|
4834
4851
|
|
|
4835
4852
|
// src/vite/layout.ts
|