@stacksjs/stx 0.2.172 → 0.2.173
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/cli.js +294 -294
- package/dist/craft.js +122 -122
- package/dist/pwa.js +70 -70
- package/dist/server-bindings.js +45 -1
- package/dist/ssg.js +81 -81
- package/package.json +5 -5
package/dist/server-bindings.js
CHANGED
|
@@ -20,7 +20,50 @@ const BOOLEAN_ATTRS = new Set([
|
|
|
20
20
|
"playsinline",
|
|
21
21
|
"reversed",
|
|
22
22
|
"selected"
|
|
23
|
+
]), VOID_TAGS = new Set([
|
|
24
|
+
"area",
|
|
25
|
+
"base",
|
|
26
|
+
"br",
|
|
27
|
+
"col",
|
|
28
|
+
"embed",
|
|
29
|
+
"hr",
|
|
30
|
+
"img",
|
|
31
|
+
"input",
|
|
32
|
+
"link",
|
|
33
|
+
"meta",
|
|
34
|
+
"param",
|
|
35
|
+
"source",
|
|
36
|
+
"track",
|
|
37
|
+
"wbr"
|
|
23
38
|
]);
|
|
39
|
+
function reactiveLoopRanges(template) {
|
|
40
|
+
const ranges = [], openingTag = /<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g;
|
|
41
|
+
let match;
|
|
42
|
+
while ((match = openingTag.exec(template)) !== null) {
|
|
43
|
+
const attributes = match[2] || "";
|
|
44
|
+
if (!/(?:^|\s)(?::for|x-for|v-for|@for)\s*=/.test(attributes))
|
|
45
|
+
continue;
|
|
46
|
+
const start = match.index, openingEnd = start + match[0].length, tagName = match[1].toLowerCase();
|
|
47
|
+
if (match[0].endsWith("/>") || VOID_TAGS.has(tagName)) {
|
|
48
|
+
ranges.push([start, openingEnd]);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const escapedTag = tagName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), sameTag = new RegExp(`<\\/?${escapedTag}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`, "gi");
|
|
52
|
+
sameTag.lastIndex = openingEnd;
|
|
53
|
+
let depth = 1, closingEnd = openingEnd, nested;
|
|
54
|
+
while ((nested = sameTag.exec(template)) !== null)
|
|
55
|
+
if (nested[0].startsWith("</")) {
|
|
56
|
+
depth--;
|
|
57
|
+
if (depth === 0) {
|
|
58
|
+
closingEnd = nested.index + nested[0].length;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
} else if (!nested[0].endsWith("/>"))
|
|
62
|
+
depth++;
|
|
63
|
+
ranges.push([start, closingEnd]);
|
|
64
|
+
}
|
|
65
|
+
return ranges;
|
|
66
|
+
}
|
|
24
67
|
function resolveClassBinding(value) {
|
|
25
68
|
if (typeof value === "string")
|
|
26
69
|
return value;
|
|
@@ -38,10 +81,11 @@ export function processServerBindings(template, context) {
|
|
|
38
81
|
let match;
|
|
39
82
|
while ((match = scriptStyleRegex.exec(template)) !== null)
|
|
40
83
|
protectedRanges.push([match.index, match.index + match[0].length]);
|
|
84
|
+
protectedRanges.push(...reactiveLoopRanges(template));
|
|
41
85
|
function isProtected(pos) {
|
|
42
86
|
return protectedRanges.some(([start, end]) => pos >= start && pos < end);
|
|
43
87
|
}
|
|
44
|
-
const tagRegex = /<([a-zA-Z][a-zA-Z0-9-]*)((
|
|
88
|
+
const tagRegex = /<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g, replacements = [];
|
|
45
89
|
while ((match = tagRegex.exec(output)) !== null) {
|
|
46
90
|
if (isProtected(match.index))
|
|
47
91
|
continue;
|