@vuebro/loader-sfc 2.3.17 → 2.3.19
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/loader-sfc.esm-browser.prod.js +14 -15
- package/dist/loader-sfc.js +29 -34
- package/package.json +2 -2
|
@@ -23687,7 +23687,7 @@ var GP = Object.defineProperty, zg = Object.getOwnPropertySymbols, XP = Object.p
|
|
|
23687
23687
|
Gg(Gg({}, Ph), su), lr.parse;
|
|
23688
23688
|
const Xg = async (e) => {
|
|
23689
23689
|
try {
|
|
23690
|
-
return await kv(e);
|
|
23690
|
+
return await kv(e, { responseType: "text" });
|
|
23691
23691
|
} catch (t) {
|
|
23692
23692
|
co.error(t);
|
|
23693
23693
|
}
|
|
@@ -23699,32 +23699,31 @@ const Xg = async (e) => {
|
|
|
23699
23699
|
URL.revokeObjectURL(t);
|
|
23700
23700
|
}
|
|
23701
23701
|
}, JP = async (e, { parseOptions: t, scriptOptions: { templateOptions: { compilerOptions: { expressionPlugins: s, ...n } = {}, ...i } = {}, ...o } = {}, styleOptions: c } = {}) => {
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
const C = [], A = document.getElementById(l) instanceof HTMLStyleElement ? Promise.resolve([]) : Promise.all(g.map(async ({ content: Y, module: le, scoped: J = !1, src: $ }) => {
|
|
23702
|
+
let l = "";
|
|
23703
|
+
const p = `data-v-${zT(e)}`, d = [], { descriptor: f, errors: m } = ib(await Xg(e) ?? "<template></template>", { filename: e, ...t }), { script: x, scriptSetup: g, slotted: y, styles: v, template: b } = f, E = new Set([x, g].filter((Y) => Y !== null).flatMap(({ lang: Y = "js" }) => [.../[jt]sx$/.test(Y) ? ["jsx"] : [], .../tsx?$/.test(Y) ? ["typescript"] : []])), w = { expressionPlugins: [.../* @__PURE__ */ new Set([...s ?? [], ...E])], filename: e, scopeId: p, slotted: y, ...n }, C = { compilerOptions: w, filename: e, id: p, scoped: v.some(({ scoped: Y }) => Y), slotted: y, ...i }, A = { id: p, templateOptions: C, ...o }, O = document.getElementById(p) instanceof HTMLStyleElement ? Promise.resolve([]) : Promise.all(v.map(async ({ content: Y, module: le, scoped: J = !1, src: $ }) => {
|
|
23705
23704
|
const ie = !!le;
|
|
23706
|
-
if (ie && !
|
|
23705
|
+
if (ie && !l) return l = "<style module> is not supported in the playground.", "";
|
|
23707
23706
|
{
|
|
23708
|
-
const { code: Q, errors: se } = await sP({ filename: e, id:
|
|
23709
|
-
return
|
|
23707
|
+
const { code: Q, errors: se } = await sP({ filename: e, id: p, modules: ie, scoped: J, source: $ ? await Xg($) ?? "" : Y, ...c });
|
|
23708
|
+
return d.push(...se), Q;
|
|
23710
23709
|
}
|
|
23711
|
-
})),
|
|
23712
|
-
U && (
|
|
23713
|
-
const { code: V, errors: F, tips: q } = !
|
|
23714
|
-
[...
|
|
23710
|
+
})), D = { jsxRuntime: "preserve", transforms: [...E] }, { ast: N, content: j = "" } = b ?? {}, { bindings: U, content: X, warnings: W } = x || g ? WP(f, A) : {};
|
|
23711
|
+
U && (w.bindingMetadata = U);
|
|
23712
|
+
const { code: V, errors: F, tips: q } = !b || g && A.inlineTemplate ? {} : l0({ ...N, filename: e, id: p, source: j, ...C });
|
|
23713
|
+
[...m, ...F ?? [], ...d].forEach((Y) => {
|
|
23715
23714
|
co.error(Y);
|
|
23716
|
-
}), [...W ?? [], ...
|
|
23715
|
+
}), [...W ?? [], ...l ? [l] : []].forEach((Y) => {
|
|
23717
23716
|
co.warn(Y);
|
|
23718
23717
|
}), [...q ?? []].forEach((Y) => {
|
|
23719
23718
|
co.info(Y);
|
|
23720
23719
|
});
|
|
23721
|
-
const [G, ee, ae] = await Promise.all([
|
|
23720
|
+
const [G, ee, ae] = await Promise.all([O, X ? Kg(E.size ? nd(X, D).code : X) : Promise.resolve(void 0), V ? Kg(E.size ? nd(V, D).code : V) : Promise.resolve(void 0)]), be = G.join(`
|
|
23722
23721
|
`).trim();
|
|
23723
23722
|
if (be) {
|
|
23724
23723
|
const Y = document.createElement("style");
|
|
23725
|
-
Y.id =
|
|
23724
|
+
Y.id = p, Y.textContent = be, document.head.appendChild(Y);
|
|
23726
23725
|
}
|
|
23727
|
-
return { __scopeId:
|
|
23726
|
+
return { __scopeId: p, ...ee?.default, ...ae };
|
|
23728
23727
|
};
|
|
23729
23728
|
export {
|
|
23730
23729
|
JP as default
|
package/dist/loader-sfc.js
CHANGED
|
@@ -5,11 +5,12 @@ import { transform } from "sucrase";
|
|
|
5
5
|
import { compileScript, compileStyleAsync, compileTemplate, parse, } from "vue/compiler-sfc";
|
|
6
6
|
const fetching = async (input) => {
|
|
7
7
|
try {
|
|
8
|
-
return await ofetch(input);
|
|
8
|
+
return await ofetch(input, { responseType: "text" });
|
|
9
9
|
}
|
|
10
10
|
catch (error) {
|
|
11
11
|
consola.error(error);
|
|
12
12
|
}
|
|
13
|
+
return;
|
|
13
14
|
}, inject = async (code) => {
|
|
14
15
|
const objectURL = URL.createObjectURL(new Blob([code], { type: "application/javascript" }));
|
|
15
16
|
try {
|
|
@@ -20,39 +21,14 @@ const fetching = async (input) => {
|
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
export default async (filename, { parseOptions, scriptOptions: { templateOptions: { compilerOptions: { expressionPlugins, ...restCompilerOptions } = {}, ...restTemplateOptions } = {}, ...restScriptOptions } = {}, styleOptions, } = {}) => {
|
|
23
|
-
|
|
24
|
-
const { descriptor, errors: parseErrors } = parse((await fetching(filename)) ?? "<template></template>", { filename, ...parseOptions });
|
|
25
|
-
const { script, scriptSetup, slotted, styles, template } = descriptor;
|
|
24
|
+
let styleWarning = "";
|
|
25
|
+
const id = `data-v-${hash(filename)}`, styleErrors = [], { descriptor, errors: parseErrors } = parse((await fetching(filename)) ?? "<template></template>", { filename, ...parseOptions }), { script, scriptSetup, slotted, styles, template } = descriptor;
|
|
26
26
|
const langs = new Set([script, scriptSetup]
|
|
27
27
|
.filter((scriptBlock) => scriptBlock !== null)
|
|
28
28
|
.flatMap(({ lang = "js" }) => [
|
|
29
29
|
...(/[jt]sx$/.test(lang) ? ["jsx"] : []),
|
|
30
30
|
...(/tsx?$/.test(lang) ? ["typescript"] : []),
|
|
31
|
-
])),
|
|
32
|
-
let styleWarning = "";
|
|
33
|
-
const styleErrors = [];
|
|
34
|
-
const style = !(document.getElementById(id) instanceof HTMLStyleElement)
|
|
35
|
-
? Promise.all(styles.map(async ({ content, module, scoped = false, src }) => {
|
|
36
|
-
const modules = !!module;
|
|
37
|
-
if (modules && !styleWarning) {
|
|
38
|
-
styleWarning = "<style module> is not supported in the playground.";
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
const { code, errors } = await compileStyleAsync({
|
|
43
|
-
filename,
|
|
44
|
-
id,
|
|
45
|
-
modules,
|
|
46
|
-
scoped,
|
|
47
|
-
source: src ? ((await fetching(src)) ?? "") : content,
|
|
48
|
-
...styleOptions,
|
|
49
|
-
});
|
|
50
|
-
styleErrors.push(...errors);
|
|
51
|
-
return code;
|
|
52
|
-
}
|
|
53
|
-
}))
|
|
54
|
-
: Promise.resolve([]);
|
|
55
|
-
const compilerOptions = {
|
|
31
|
+
])), compilerOptions = {
|
|
56
32
|
expressionPlugins: [
|
|
57
33
|
...new Set([...(expressionPlugins ?? []), ...langs]),
|
|
58
34
|
],
|
|
@@ -71,11 +47,31 @@ export default async (filename, { parseOptions, scriptOptions: { templateOptions
|
|
|
71
47
|
id,
|
|
72
48
|
templateOptions,
|
|
73
49
|
...restScriptOptions,
|
|
74
|
-
},
|
|
50
|
+
}, style = !(document.getElementById(id) instanceof HTMLStyleElement)
|
|
51
|
+
? Promise.all(styles.map(async ({ content, module, scoped = false, src }) => {
|
|
52
|
+
const modules = !!module;
|
|
53
|
+
if (modules && !styleWarning) {
|
|
54
|
+
styleWarning =
|
|
55
|
+
"<style module> is not supported in the playground.";
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const { code, errors } = await compileStyleAsync({
|
|
60
|
+
filename,
|
|
61
|
+
id,
|
|
62
|
+
modules,
|
|
63
|
+
scoped,
|
|
64
|
+
source: src ? ((await fetching(src)) ?? "") : content,
|
|
65
|
+
...styleOptions,
|
|
66
|
+
});
|
|
67
|
+
styleErrors.push(...errors);
|
|
68
|
+
return code;
|
|
69
|
+
}
|
|
70
|
+
}))
|
|
71
|
+
: Promise.resolve([]), sucraseOptions = {
|
|
75
72
|
jsxRuntime: "preserve",
|
|
76
73
|
transforms: [...langs],
|
|
77
|
-
};
|
|
78
|
-
const { bindings, content, warnings: scriptWarnings, } = script || scriptSetup ? compileScript(descriptor, scriptOptions) : {};
|
|
74
|
+
}, { ast, content: source = "" } = template ?? {}, { bindings, content, warnings: scriptWarnings, } = script || scriptSetup ? compileScript(descriptor, scriptOptions) : {};
|
|
79
75
|
if (bindings)
|
|
80
76
|
compilerOptions.bindingMetadata = bindings;
|
|
81
77
|
const { code, errors: templateErrors, tips: templateTips, } = template && (!scriptSetup || !scriptOptions.inlineTemplate)
|
|
@@ -104,8 +100,7 @@ export default async (filename, { parseOptions, scriptOptions: { templateOptions
|
|
|
104
100
|
code
|
|
105
101
|
? inject(langs.size ? transform(code, sucraseOptions).code : code)
|
|
106
102
|
: Promise.resolve(undefined),
|
|
107
|
-
]);
|
|
108
|
-
const textContent = styleResult.join("\n").trim();
|
|
103
|
+
]), textContent = styleResult.join("\n").trim();
|
|
109
104
|
if (textContent) {
|
|
110
105
|
const el = document.createElement("style");
|
|
111
106
|
el.id = id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuebro/loader-sfc",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.19",
|
|
4
4
|
"description": "Vue3 Single File Component (SFC) loader. Load .vue files directly from your browser without any build step.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@rollup/plugin-terser": "^0.4.4",
|
|
45
45
|
"@types/hash-sum": "^1.0.2",
|
|
46
46
|
"@types/node": "^24.9.2",
|
|
47
|
-
"@vuebro/configs": "^1.1.
|
|
47
|
+
"@vuebro/configs": "^1.1.56",
|
|
48
48
|
"eslint": "^9.39.0",
|
|
49
49
|
"vite": "^7.1.12"
|
|
50
50
|
}
|