@vuebro/loader-sfc 2.3.13 → 2.3.14
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.
|
@@ -23457,13 +23457,17 @@ var oP = (function() {
|
|
|
23457
23457
|
})(t(0, s, "", []).toString(16), 8);
|
|
23458
23458
|
}, zl;
|
|
23459
23459
|
})();
|
|
23460
|
-
const aP = n_(oP), Ug = async (e, t = "") => {
|
|
23460
|
+
const aP = n_(oP), Ug = async (e, t = "text") => {
|
|
23461
23461
|
try {
|
|
23462
23462
|
const s = await fetch(e);
|
|
23463
|
-
if (s.ok)
|
|
23463
|
+
if (s.ok) {
|
|
23464
|
+
const n = s[t];
|
|
23465
|
+
if (typeof n == "function") return await n();
|
|
23466
|
+
throw new Error(`Invalid resolver "${t}"`);
|
|
23467
|
+
}
|
|
23464
23468
|
throw new Error(`Response status: ${s.status.toString()}`);
|
|
23465
23469
|
} catch (s) {
|
|
23466
|
-
|
|
23470
|
+
bo.error(s);
|
|
23467
23471
|
}
|
|
23468
23472
|
}, $g = async (e) => {
|
|
23469
23473
|
const t = URL.createObjectURL(new Blob([e], { type: "application/javascript" }));
|
|
@@ -23473,13 +23477,13 @@ const aP = n_(oP), Ug = async (e, t = "") => {
|
|
|
23473
23477
|
URL.revokeObjectURL(t);
|
|
23474
23478
|
}
|
|
23475
23479
|
}, cP = async (e, { scriptOptions: { templateOptions: { compilerOptions: { expressionPlugins: t, ...s } = {}, ...n } = {}, ...i } = {}, parseOptions: o, styleOptions: c } = {}) => {
|
|
23476
|
-
const l = `data-v-${aP(e)}`, { errors: p, descriptor: d } = Jy(await Ug(e
|
|
23480
|
+
const l = `data-v-${aP(e)}`, { errors: p, descriptor: d } = Jy(await Ug(e) ?? "<template></template>", { filename: e, ...o }), { scriptSetup: g, template: f, slotted: v, script: m, styles: y } = d, T = new Set([m, g].filter((Y) => Y !== null).flatMap(({ lang: Y = "js" }) => [.../[jt]sx$/.test(Y) ? ["jsx"] : [], .../tsx?$/.test(Y) ? ["typescript"] : []])), { content: b = "", ast: E } = f ?? {};
|
|
23477
23481
|
let w = "";
|
|
23478
23482
|
const C = [], A = document.getElementById(l) instanceof HTMLStyleElement ? Promise.resolve([]) : Promise.all(y.map(async ({ scoped: Y = !1, content: le, module: J, src: $ }) => {
|
|
23479
23483
|
const ie = !!J;
|
|
23480
23484
|
if (ie && !w) return w = "<style module> is not supported in the playground.", "";
|
|
23481
23485
|
{
|
|
23482
|
-
const { errors: Q, code: se } = await $E({ source: $ ? await Ug($) : le, filename: e, modules: ie, scoped: Y, id: l, ...c });
|
|
23486
|
+
const { errors: Q, code: se } = await $E({ source: $ ? await Ug($) ?? "" : le, filename: e, modules: ie, scoped: Y, id: l, ...c });
|
|
23483
23487
|
return C.push(...Q), se;
|
|
23484
23488
|
}
|
|
23485
23489
|
})), O = { expressionPlugins: [.../* @__PURE__ */ new Set([...t ?? [], ...T])], scopeId: l, filename: e, slotted: v, ...s }, D = { scoped: y.some(({ scoped: Y }) => Y), compilerOptions: O, filename: e, slotted: v, id: l, ...n }, N = { templateOptions: D, id: l, ...i }, j = { transforms: [...T], jsxRuntime: "preserve" }, { warnings: U, bindings: X, content: z } = m || g ? Iw(d, N) : {};
|
package/dist/loader-sfc.js
CHANGED
|
@@ -2,17 +2,21 @@ import { compileStyleAsync, compileTemplate, compileScript, parse, } from "vue/c
|
|
|
2
2
|
import { consola } from "consola/browser";
|
|
3
3
|
import { transform } from "sucrase";
|
|
4
4
|
import hash from "hash-sum";
|
|
5
|
-
const
|
|
5
|
+
const fetching = async (input, resolver = "text") => {
|
|
6
6
|
try {
|
|
7
7
|
const response = await fetch(input);
|
|
8
|
-
if (response.ok)
|
|
9
|
-
|
|
8
|
+
if (response.ok) {
|
|
9
|
+
const method = response[resolver];
|
|
10
|
+
if (typeof method === "function")
|
|
11
|
+
return await method();
|
|
12
|
+
else
|
|
13
|
+
throw new Error(`Invalid resolver "${resolver}"`);
|
|
14
|
+
}
|
|
10
15
|
else
|
|
11
16
|
throw new Error(`Response status: ${response.status.toString()}`);
|
|
12
17
|
}
|
|
13
18
|
catch (error) {
|
|
14
19
|
consola.error(error);
|
|
15
|
-
return text;
|
|
16
20
|
}
|
|
17
21
|
}, inject = async (code) => {
|
|
18
22
|
const objectURL = URL.createObjectURL(new Blob([code], { type: "application/javascript" }));
|
|
@@ -25,7 +29,7 @@ const fetchText = async (input, text = "") => {
|
|
|
25
29
|
};
|
|
26
30
|
export default async (filename, { scriptOptions: { templateOptions: { compilerOptions: { expressionPlugins, ...restCompilerOptions } = {}, ...restTemplateOptions } = {}, ...restScriptOptions } = {}, parseOptions, styleOptions, } = {}) => {
|
|
27
31
|
const id = `data-v-${hash(filename)}`;
|
|
28
|
-
const { errors: parseErrors, descriptor } = parse(await
|
|
32
|
+
const { errors: parseErrors, descriptor } = parse((await fetching(filename)) ?? "<template></template>", { filename, ...parseOptions });
|
|
29
33
|
const { scriptSetup, template, slotted, script, styles } = descriptor;
|
|
30
34
|
const langs = new Set([script, scriptSetup]
|
|
31
35
|
.filter((scriptBlock) => scriptBlock !== null)
|
|
@@ -44,7 +48,7 @@ export default async (filename, { scriptOptions: { templateOptions: { compilerOp
|
|
|
44
48
|
}
|
|
45
49
|
else {
|
|
46
50
|
const { errors, code } = await compileStyleAsync({
|
|
47
|
-
source: src ? await
|
|
51
|
+
source: src ? ((await fetching(src)) ?? "") : content,
|
|
48
52
|
filename,
|
|
49
53
|
modules,
|
|
50
54
|
scoped,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuebro/loader-sfc",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.14",
|
|
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",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"@rollup/plugin-terser": "^0.4.4",
|
|
42
42
|
"@types/hash-sum": "^1.0.2",
|
|
43
43
|
"@types/node": "^24.9.1",
|
|
44
|
-
"@vuebro/configs": "^1.1.
|
|
44
|
+
"@vuebro/configs": "^1.1.41"
|
|
45
45
|
}
|
|
46
46
|
}
|