svelte-effect-runtime 1.1.0 → 1.2.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/chunks/{markup-DItLw1g8.js → markup-CfRiigJc.js} +43 -4
- package/dist/chunks/{markup-DItLw1g8.js.map → markup-CfRiigJc.js.map} +1 -1
- package/dist/client.js +3 -2
- package/dist/client.js.map +1 -1
- package/dist/internal/markup.js +1 -1
- package/dist/language-server.js +1 -1
- package/dist/mod.js +1 -1
- package/dist/preprocess.js +1 -1
- package/dist/root-node.js +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -12578,7 +12578,7 @@ function transformEffectMarkup(content, options) {
|
|
|
12578
12578
|
};
|
|
12579
12579
|
}
|
|
12580
12580
|
function createParseSafeMarkupSource(content) {
|
|
12581
|
-
const excludedRanges =
|
|
12581
|
+
const excludedRanges = findParseSafeMaskRanges(content);
|
|
12582
12582
|
if (excludedRanges.length === 0) return content;
|
|
12583
12583
|
let result = "";
|
|
12584
12584
|
let cursor = 0;
|
|
@@ -12691,7 +12691,10 @@ function makeAstReplacement(candidate, kind, filename) {
|
|
|
12691
12691
|
const deps = collectFreeIdentifiers(candidate.expressionText, filename);
|
|
12692
12692
|
const depsText = deps.length === 0 ? "[]" : `[${deps.join(", ")}]`;
|
|
12693
12693
|
const trimmedExpression = candidate.expressionText.trim();
|
|
12694
|
-
|
|
12694
|
+
let replacementText;
|
|
12695
|
+
if (kind === "await") replacementText = `${MARKUP_HELPER_PREFIX}Promise("${helperId}", ${depsText}, function* () { return (${trimmedExpression}); })`;
|
|
12696
|
+
else if (kind === "render") replacementText = `(${MARKUP_HELPER_PREFIX}Value("${helperId}", ${depsText}, function* () { return (${trimmedExpression}); }, undefined))()`;
|
|
12697
|
+
else replacementText = `${MARKUP_HELPER_PREFIX}Value("${helperId}", ${depsText}, function* () { return (${trimmedExpression}); }, ${kind === "each" ? "[]" : "undefined"})`;
|
|
12695
12698
|
return {
|
|
12696
12699
|
start: candidate.start,
|
|
12697
12700
|
end: candidate.end,
|
|
@@ -12706,9 +12709,11 @@ function visitNode(node, candidatesByPlaceholder, matchedPlaceholders, onReplace
|
|
|
12706
12709
|
case "ExpressionTag":
|
|
12707
12710
|
case "HtmlTag":
|
|
12708
12711
|
case "AttachTag":
|
|
12709
|
-
case "RenderTag":
|
|
12710
12712
|
emitReplacementForExpression(node.expression, "plain", candidatesByPlaceholder, matchedPlaceholders, onReplacement);
|
|
12711
12713
|
return;
|
|
12714
|
+
case "RenderTag":
|
|
12715
|
+
emitReplacementForExpression(node.expression, "render", candidatesByPlaceholder, matchedPlaceholders, onReplacement);
|
|
12716
|
+
return;
|
|
12712
12717
|
case "ConstTag":
|
|
12713
12718
|
emitReplacementForExpression(node.declaration.declarations[0]?.init, "plain", candidatesByPlaceholder, matchedPlaceholders, onReplacement);
|
|
12714
12719
|
return;
|
|
@@ -12974,6 +12979,40 @@ function findExcludedRanges(content) {
|
|
|
12974
12979
|
}
|
|
12975
12980
|
return ranges.sort((left, right) => left.start - right.start);
|
|
12976
12981
|
}
|
|
12982
|
+
function findParseSafeMaskRanges(content) {
|
|
12983
|
+
return [
|
|
12984
|
+
...findTagBodyRanges(content, "script"),
|
|
12985
|
+
...findTagBodyRanges(content, "style"),
|
|
12986
|
+
...findCommentRanges(content)
|
|
12987
|
+
].sort((left, right) => left.start - right.start);
|
|
12988
|
+
}
|
|
12989
|
+
function findTagBodyRanges(content, tagName) {
|
|
12990
|
+
const ranges = [];
|
|
12991
|
+
const pattern = new RegExp(`<${tagName}\\b[^>]*>([\\s\\S]*?)<\\/${tagName}\\s*>`, "gi");
|
|
12992
|
+
for (const match of content.matchAll(pattern)) {
|
|
12993
|
+
if (match.index === void 0) continue;
|
|
12994
|
+
const fullMatch = match[0];
|
|
12995
|
+
const body = match[1] ?? "";
|
|
12996
|
+
const openTagEnd = fullMatch.indexOf(">") + 1;
|
|
12997
|
+
const start = match.index + openTagEnd;
|
|
12998
|
+
ranges.push({
|
|
12999
|
+
start,
|
|
13000
|
+
end: start + body.length
|
|
13001
|
+
});
|
|
13002
|
+
}
|
|
13003
|
+
return ranges;
|
|
13004
|
+
}
|
|
13005
|
+
function findCommentRanges(content) {
|
|
13006
|
+
const ranges = [];
|
|
13007
|
+
for (const match of content.matchAll(/<!--[\s\S]*?-->/g)) {
|
|
13008
|
+
if (match.index === void 0) continue;
|
|
13009
|
+
ranges.push({
|
|
13010
|
+
start: match.index,
|
|
13011
|
+
end: match.index + match[0].length
|
|
13012
|
+
});
|
|
13013
|
+
}
|
|
13014
|
+
return ranges;
|
|
13015
|
+
}
|
|
12977
13016
|
function findExcludedRangeAt(ranges, index) {
|
|
12978
13017
|
return ranges.find((range) => range.start <= index && index < range.end);
|
|
12979
13018
|
}
|
|
@@ -13312,4 +13351,4 @@ function indentBlock(text, indent) {
|
|
|
13312
13351
|
//#endregion
|
|
13313
13352
|
export { transformEffectMarkup as t };
|
|
13314
13353
|
|
|
13315
|
-
//# sourceMappingURL=markup-
|
|
13354
|
+
//# sourceMappingURL=markup-CfRiigJc.js.map
|