@absolutejs/absolute 0.19.0-beta.1077 → 0.19.0-beta.1079
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/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +239 -3
- package/dist/angular/index.js.map +5 -4
- package/dist/angular/server.js +239 -3
- package/dist/angular/server.js.map +5 -4
- package/dist/build.js +246 -8
- package/dist/build.js.map +6 -5
- package/dist/cli/index.js +242 -3
- package/dist/index.js +246 -8
- package/dist/index.js.map +6 -5
- package/dist/islands/index.js +239 -3
- package/dist/islands/index.js.map +5 -4
- package/dist/react/index.js +239 -3
- package/dist/react/index.js.map +5 -4
- package/dist/src/build/maskLiterals.d.ts +25 -0
- package/dist/svelte/index.js +239 -3
- package/dist/svelte/index.js.map +5 -4
- package/dist/vue/index.js +239 -3
- package/dist/vue/index.js.map +5 -4
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Shields non-code spans from the regex/text-based import rewriters.
|
|
2
|
+
*
|
|
3
|
+
* The import rewriters (rewriteReactImports, rewriteImportsPlugin, the native
|
|
4
|
+
* Zig scanner, and compile's runtime-specifier rewrite) replace `from "X"` /
|
|
5
|
+
* `import "X"` / `import("X")` / `require("X")` across the whole file text. That
|
|
6
|
+
* text scan can't tell a real import from the *text* `from 'X'` sitting inside a
|
|
7
|
+
* template literal / data string (an example-code snippet a page renders) or a
|
|
8
|
+
* comment — so it rewrites the snippet's specifier too. The browser bundle then
|
|
9
|
+
* diverges from the SSR pre-render → React hydration mismatch on the code block.
|
|
10
|
+
*
|
|
11
|
+
* Fix: before rewriting, replace template literals, comments, and non-specifier
|
|
12
|
+
* string literals with opaque placeholders; rewrite; then restore them verbatim.
|
|
13
|
+
* String literals that ARE real import specifiers (those right after
|
|
14
|
+
* `from`/`import`, or inside `import(`/`require(`) are left untouched, so real
|
|
15
|
+
* import rewriting is unaffected. Regex literals are skipped (copied verbatim)
|
|
16
|
+
* so their contents can't be misread as strings/templates.
|
|
17
|
+
*
|
|
18
|
+
* Usage: `const { masked, restore } = maskLiterals(src)`, run the existing
|
|
19
|
+
* rewriter on `masked`, then `restore(rewritten)`.
|
|
20
|
+
*/
|
|
21
|
+
export type MaskedSource = {
|
|
22
|
+
masked: string;
|
|
23
|
+
restore: (rewritten: string) => string;
|
|
24
|
+
};
|
|
25
|
+
export declare const maskLiterals: (src: string) => MaskedSource;
|
package/dist/svelte/index.js
CHANGED
|
@@ -2760,6 +2760,240 @@ var init_islandSsr = __esm(() => {
|
|
|
2760
2760
|
LEADING_HOISTED_RESOURCE_RE = /^\s*(?:<link\b[^>]*\/?>|<meta\b[^>]*\/?>|<title\b[^>]*>[\s\S]*?<\/title>|<style\b[^>]*>[\s\S]*?<\/style>|<script\b[^>]*>[\s\S]*?<\/script>)/i;
|
|
2761
2761
|
});
|
|
2762
2762
|
|
|
2763
|
+
// src/build/maskLiterals.ts
|
|
2764
|
+
var SENTINEL, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
|
|
2765
|
+
const n = src.length;
|
|
2766
|
+
const pieces = [];
|
|
2767
|
+
let out = "";
|
|
2768
|
+
let i = 0;
|
|
2769
|
+
let prevChar = "";
|
|
2770
|
+
let prevWord = "";
|
|
2771
|
+
let prevWasSpace = false;
|
|
2772
|
+
let wordBeforeParen = "";
|
|
2773
|
+
const mask = (text) => {
|
|
2774
|
+
out += SENTINEL + pieces.length + SENTINEL;
|
|
2775
|
+
pieces.push(text);
|
|
2776
|
+
prevChar = ")";
|
|
2777
|
+
prevWord = "";
|
|
2778
|
+
prevWasSpace = false;
|
|
2779
|
+
};
|
|
2780
|
+
const endOfString = (start) => {
|
|
2781
|
+
const q = src[start];
|
|
2782
|
+
let j = start + 1;
|
|
2783
|
+
while (j < n) {
|
|
2784
|
+
const c = src[j];
|
|
2785
|
+
if (c === "\\") {
|
|
2786
|
+
j += 2;
|
|
2787
|
+
continue;
|
|
2788
|
+
}
|
|
2789
|
+
if (c === q)
|
|
2790
|
+
return j + 1;
|
|
2791
|
+
if (c === `
|
|
2792
|
+
`)
|
|
2793
|
+
return j;
|
|
2794
|
+
j++;
|
|
2795
|
+
}
|
|
2796
|
+
return j;
|
|
2797
|
+
};
|
|
2798
|
+
const endOfInterp = (start) => {
|
|
2799
|
+
let j = start;
|
|
2800
|
+
let depth = 1;
|
|
2801
|
+
while (j < n && depth > 0) {
|
|
2802
|
+
const c = src[j];
|
|
2803
|
+
if (c === "\\") {
|
|
2804
|
+
j += 2;
|
|
2805
|
+
continue;
|
|
2806
|
+
}
|
|
2807
|
+
if (c === "`") {
|
|
2808
|
+
j = endOfTemplate(j);
|
|
2809
|
+
continue;
|
|
2810
|
+
}
|
|
2811
|
+
if (c === '"' || c === "'") {
|
|
2812
|
+
j = endOfString(j);
|
|
2813
|
+
continue;
|
|
2814
|
+
}
|
|
2815
|
+
if (c === "/" && src[j + 1] === "/") {
|
|
2816
|
+
const nl = src.indexOf(`
|
|
2817
|
+
`, j);
|
|
2818
|
+
j = nl < 0 ? n : nl;
|
|
2819
|
+
continue;
|
|
2820
|
+
}
|
|
2821
|
+
if (c === "/" && src[j + 1] === "*") {
|
|
2822
|
+
const e = src.indexOf("*/", j + 2);
|
|
2823
|
+
j = e < 0 ? n : e + 2;
|
|
2824
|
+
continue;
|
|
2825
|
+
}
|
|
2826
|
+
if (c === "{")
|
|
2827
|
+
depth++;
|
|
2828
|
+
else if (c === "}")
|
|
2829
|
+
depth--;
|
|
2830
|
+
j++;
|
|
2831
|
+
}
|
|
2832
|
+
return j;
|
|
2833
|
+
};
|
|
2834
|
+
function endOfTemplate(start) {
|
|
2835
|
+
let j = start + 1;
|
|
2836
|
+
while (j < n) {
|
|
2837
|
+
const c = src[j];
|
|
2838
|
+
if (c === "\\") {
|
|
2839
|
+
j += 2;
|
|
2840
|
+
continue;
|
|
2841
|
+
}
|
|
2842
|
+
if (c === "`")
|
|
2843
|
+
return j + 1;
|
|
2844
|
+
if (c === "$" && src[j + 1] === "{") {
|
|
2845
|
+
j = endOfInterp(j + 2);
|
|
2846
|
+
continue;
|
|
2847
|
+
}
|
|
2848
|
+
j++;
|
|
2849
|
+
}
|
|
2850
|
+
return j;
|
|
2851
|
+
}
|
|
2852
|
+
const endOfRegex = (start) => {
|
|
2853
|
+
let j = start + 1;
|
|
2854
|
+
let inClass = false;
|
|
2855
|
+
while (j < n) {
|
|
2856
|
+
const c = src[j];
|
|
2857
|
+
if (c === "\\") {
|
|
2858
|
+
j += 2;
|
|
2859
|
+
continue;
|
|
2860
|
+
}
|
|
2861
|
+
if (c === `
|
|
2862
|
+
`)
|
|
2863
|
+
return -1;
|
|
2864
|
+
if (c === "[")
|
|
2865
|
+
inClass = true;
|
|
2866
|
+
else if (c === "]")
|
|
2867
|
+
inClass = false;
|
|
2868
|
+
else if (c === "/" && !inClass) {
|
|
2869
|
+
j++;
|
|
2870
|
+
break;
|
|
2871
|
+
}
|
|
2872
|
+
j++;
|
|
2873
|
+
}
|
|
2874
|
+
while (j < n && /[a-z]/i.test(src[j] ?? ""))
|
|
2875
|
+
j++;
|
|
2876
|
+
return j;
|
|
2877
|
+
};
|
|
2878
|
+
while (i < n) {
|
|
2879
|
+
const c = src[i];
|
|
2880
|
+
const c2 = src[i + 1];
|
|
2881
|
+
if (c === "/" && c2 === "/") {
|
|
2882
|
+
out += "//";
|
|
2883
|
+
i += 2;
|
|
2884
|
+
const s = i;
|
|
2885
|
+
while (i < n && src[i] !== `
|
|
2886
|
+
`)
|
|
2887
|
+
i++;
|
|
2888
|
+
mask(src.slice(s, i));
|
|
2889
|
+
continue;
|
|
2890
|
+
}
|
|
2891
|
+
if (c === "/" && c2 === "*") {
|
|
2892
|
+
out += "/*";
|
|
2893
|
+
i += 2;
|
|
2894
|
+
const e = src.indexOf("*/", i);
|
|
2895
|
+
const end = e < 0 ? n : e;
|
|
2896
|
+
mask(src.slice(i, end));
|
|
2897
|
+
i = end < n ? end + 2 : n;
|
|
2898
|
+
if (end < n)
|
|
2899
|
+
out += "*/";
|
|
2900
|
+
continue;
|
|
2901
|
+
}
|
|
2902
|
+
if (c === "`") {
|
|
2903
|
+
const end = endOfTemplate(i);
|
|
2904
|
+
mask(src.slice(i, end));
|
|
2905
|
+
i = end;
|
|
2906
|
+
continue;
|
|
2907
|
+
}
|
|
2908
|
+
if (c === '"' || c === "'") {
|
|
2909
|
+
const end = endOfString(i);
|
|
2910
|
+
const isSpecifier = prevWord === "from" || prevWord === "import" || prevChar === "(" && (wordBeforeParen === "import" || wordBeforeParen === "require");
|
|
2911
|
+
if (isSpecifier) {
|
|
2912
|
+
out += src.slice(i, end);
|
|
2913
|
+
prevChar = '"';
|
|
2914
|
+
prevWord = "";
|
|
2915
|
+
prevWasSpace = false;
|
|
2916
|
+
} else {
|
|
2917
|
+
mask(src.slice(i, end));
|
|
2918
|
+
}
|
|
2919
|
+
i = end;
|
|
2920
|
+
continue;
|
|
2921
|
+
}
|
|
2922
|
+
if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
|
|
2923
|
+
const end = endOfRegex(i);
|
|
2924
|
+
if (end > 0) {
|
|
2925
|
+
out += src.slice(i, end);
|
|
2926
|
+
i = end;
|
|
2927
|
+
prevChar = ")";
|
|
2928
|
+
prevWord = "";
|
|
2929
|
+
prevWasSpace = false;
|
|
2930
|
+
continue;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
out += c;
|
|
2934
|
+
i++;
|
|
2935
|
+
if (c === " " || c === "\t" || c === "\r" || c === `
|
|
2936
|
+
`) {
|
|
2937
|
+
prevWasSpace = true;
|
|
2938
|
+
continue;
|
|
2939
|
+
}
|
|
2940
|
+
if (isIdentChar(c)) {
|
|
2941
|
+
const contiguous = isIdentChar(prevChar) && !prevWasSpace;
|
|
2942
|
+
prevWord = contiguous ? prevWord + c : c;
|
|
2943
|
+
} else {
|
|
2944
|
+
if (c === "(")
|
|
2945
|
+
wordBeforeParen = prevWord;
|
|
2946
|
+
prevWord = "";
|
|
2947
|
+
}
|
|
2948
|
+
prevChar = c;
|
|
2949
|
+
prevWasSpace = false;
|
|
2950
|
+
}
|
|
2951
|
+
const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
|
|
2952
|
+
const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
|
|
2953
|
+
return { masked: out, restore };
|
|
2954
|
+
};
|
|
2955
|
+
var init_maskLiterals = __esm(() => {
|
|
2956
|
+
SENTINEL = String.fromCharCode(57344);
|
|
2957
|
+
REGEX_OK_AFTER_CHAR = new Set([
|
|
2958
|
+
"(",
|
|
2959
|
+
",",
|
|
2960
|
+
"=",
|
|
2961
|
+
":",
|
|
2962
|
+
"[",
|
|
2963
|
+
"!",
|
|
2964
|
+
"&",
|
|
2965
|
+
"|",
|
|
2966
|
+
"?",
|
|
2967
|
+
"{",
|
|
2968
|
+
"}",
|
|
2969
|
+
";",
|
|
2970
|
+
"+",
|
|
2971
|
+
"-",
|
|
2972
|
+
"*",
|
|
2973
|
+
"/",
|
|
2974
|
+
"%",
|
|
2975
|
+
"^",
|
|
2976
|
+
"~",
|
|
2977
|
+
"<",
|
|
2978
|
+
">"
|
|
2979
|
+
]);
|
|
2980
|
+
REGEX_OK_AFTER_WORD = new Set([
|
|
2981
|
+
"return",
|
|
2982
|
+
"typeof",
|
|
2983
|
+
"instanceof",
|
|
2984
|
+
"in",
|
|
2985
|
+
"of",
|
|
2986
|
+
"new",
|
|
2987
|
+
"delete",
|
|
2988
|
+
"void",
|
|
2989
|
+
"do",
|
|
2990
|
+
"else",
|
|
2991
|
+
"yield",
|
|
2992
|
+
"await",
|
|
2993
|
+
"case"
|
|
2994
|
+
]);
|
|
2995
|
+
});
|
|
2996
|
+
|
|
2763
2997
|
// src/build/nativeRewrite.ts
|
|
2764
2998
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
2765
2999
|
import { platform, arch } from "os";
|
|
@@ -2850,8 +3084,9 @@ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewrite
|
|
|
2850
3084
|
if (Object.keys(vendorPaths).length === 0)
|
|
2851
3085
|
return content;
|
|
2852
3086
|
const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
|
|
2853
|
-
const
|
|
2854
|
-
|
|
3087
|
+
const { masked, restore } = maskLiterals(content);
|
|
3088
|
+
const native = nativeRewriteImports(masked, replacements);
|
|
3089
|
+
return restore(native ?? jsRewriteImports(masked, replacements));
|
|
2855
3090
|
}, fixMissingReExportNamespacesInContent = (content) => {
|
|
2856
3091
|
const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
|
|
2857
3092
|
REEXPORT_PATTERN.lastIndex = 0;
|
|
@@ -2997,6 +3232,7 @@ ${content}`;
|
|
|
2997
3232
|
return result;
|
|
2998
3233
|
};
|
|
2999
3234
|
var init_rewriteImportsPlugin = __esm(() => {
|
|
3235
|
+
init_maskLiterals();
|
|
3000
3236
|
init_nativeRewrite();
|
|
3001
3237
|
});
|
|
3002
3238
|
|
|
@@ -4413,5 +4649,5 @@ export {
|
|
|
4413
4649
|
createTypedIsland
|
|
4414
4650
|
};
|
|
4415
4651
|
|
|
4416
|
-
//# debugId=
|
|
4652
|
+
//# debugId=60861DEB9D7F3C6864756E2164756E21
|
|
4417
4653
|
//# sourceMappingURL=index.js.map
|