@qwik.dev/core
Version:
An open source framework for building instant loading web apps at any scale, without the extra effort.
1,506 lines • 116 kB
JavaScript
/**
* @license
* @qwik.dev/core/optimizer 2.0.0-beta.13-dev+cb19ff7
* Copyright QwikDev. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
*/
function jt(e = {}) {
function n(p) {
if (typeof p != "string")
throw new TypeError("Path must be a string. Received " + JSON.stringify(p));
}
function s(p, l) {
let i = "", g = 0, h = -1, S = 0, v;
for (let _ = 0; _ <= p.length; ++_) {
if (_ < p.length)
v = p.charCodeAt(_);
else {
if (v === 47)
break;
v = 47;
}
if (v === 47) {
if (!(h === _ - 1 || S === 1)) if (h !== _ - 1 && S === 2) {
if (i.length < 2 || g !== 2 || i.charCodeAt(i.length - 1) !== 46 || i.charCodeAt(i.length - 2) !== 46) {
if (i.length > 2) {
const k = i.lastIndexOf("/");
if (k !== i.length - 1) {
k === -1 ? (i = "", g = 0) : (i = i.slice(0, k), g = i.length - 1 - i.lastIndexOf("/")), h = _, S = 0;
continue;
}
} else if (i.length === 2 || i.length === 1) {
i = "", g = 0, h = _, S = 0;
continue;
}
}
l && (i.length > 0 ? i += "/.." : i = "..", g = 2);
} else
i.length > 0 ? i += "/" + p.slice(h + 1, _) : i = p.slice(h + 1, _), g = _ - h - 1;
h = _, S = 0;
} else v === 46 && S !== -1 ? ++S : S = -1;
}
return i;
}
function r(p, l) {
const i = l.dir || l.root, g = l.base || (l.name || "") + (l.ext || "");
return i ? i === l.root ? i + g : i + p + g : g;
}
const o = function(...l) {
let i = "", g = !1, h;
for (let S = l.length - 1; S >= -1 && !g; S--) {
let v;
S >= 0 ? v = l[S] : (h === void 0 && (e && typeof e.cwd == "function" ? h = e.cwd() : typeof process < "u" && typeof process.cwd == "function" ? h = process.cwd() : h = "/"), v = h), n(v), v.length !== 0 && (i = v + "/" + i, g = v.charCodeAt(0) === 47);
}
return i = s(i, !g), g ? i.length > 0 ? "/" + i : "/" : i.length > 0 ? i : ".";
}, f = function(l) {
if (n(l), l.length === 0)
return ".";
const i = l.charCodeAt(0) === 47, g = l.charCodeAt(l.length - 1) === 47;
return l = s(l, !i), l.length === 0 && !i && (l = "."), l.length > 0 && g && (l += "/"), i ? "/" + l : l;
}, c = function(l) {
return n(l), l.length > 0 && l.charCodeAt(0) === 47;
}, a = function(...l) {
if (l.length === 0)
return ".";
let i;
for (let g = 0; g < l.length; ++g) {
const h = l[g];
n(h), h.length > 0 && (i === void 0 ? i = h : i += "/" + h);
}
return i === void 0 ? "." : f(i);
}, d = function(l, i) {
if (n(l), n(i), l === i || (l = o(l), i = o(i), l === i))
return "";
let g = 1;
for (; g < l.length && l.charCodeAt(g) === 47; ++g)
;
const h = l.length, S = h - g;
let v = 1;
for (; v < i.length && i.charCodeAt(v) === 47; ++v)
;
const k = i.length - v, C = S < k ? S : k;
let $ = -1, L = 0;
for (; L <= C; ++L) {
if (L === C) {
if (k > C) {
if (i.charCodeAt(v + L) === 47)
return i.slice(v + L + 1);
if (L === 0)
return i.slice(v + L);
} else S > C && (l.charCodeAt(g + L) === 47 ? $ = L : L === 0 && ($ = 0));
break;
}
const H = l.charCodeAt(g + L), Q = i.charCodeAt(v + L);
if (H !== Q)
break;
H === 47 && ($ = L);
}
let U = "";
for (L = g + $ + 1; L <= h; ++L)
(L === h || l.charCodeAt(L) === 47) && (U.length === 0 ? U += ".." : U += "/..");
return U.length > 0 ? U + i.slice(v + $) : (v += $, i.charCodeAt(v) === 47 && ++v, i.slice(v));
}, t = function(l) {
if (n(l), l.length === 0)
return ".";
let i = l.charCodeAt(0);
const g = i === 47;
let h = -1, S = !0;
for (let v = l.length - 1; v >= 1; --v)
if (i = l.charCodeAt(v), i === 47) {
if (!S) {
h = v;
break;
}
} else
S = !1;
return h === -1 ? g ? "/" : "." : g && h === 1 ? "//" : l.slice(0, h);
}, x = function(l, i) {
if (i !== void 0 && typeof i != "string")
throw new TypeError('"ext" argument must be a string');
n(l);
let g = 0, h = -1, S = !0, v;
if (i !== void 0 && i.length > 0 && i.length <= l.length) {
if (i.length === l.length && i === l)
return "";
let _ = i.length - 1, k = -1;
for (v = l.length - 1; v >= 0; --v) {
const C = l.charCodeAt(v);
if (C === 47) {
if (!S) {
g = v + 1;
break;
}
} else
k === -1 && (S = !1, k = v + 1), _ >= 0 && (C === i.charCodeAt(_) ? --_ === -1 && (h = v) : (_ = -1, h = k));
}
return g === h ? h = k : h === -1 && (h = l.length), l.slice(g, h);
} else {
for (v = l.length - 1; v >= 0; --v)
if (l.charCodeAt(v) === 47) {
if (!S) {
g = v + 1;
break;
}
} else h === -1 && (S = !1, h = v + 1);
return h === -1 ? "" : l.slice(g, h);
}
}, I = function(l) {
n(l);
let i = -1, g = 0, h = -1, S = !0, v = 0;
for (let _ = l.length - 1; _ >= 0; --_) {
const k = l.charCodeAt(_);
if (k === 47) {
if (!S) {
g = _ + 1;
break;
}
continue;
}
h === -1 && (S = !1, h = _ + 1), k === 46 ? i === -1 ? i = _ : v !== 1 && (v = 1) : i !== -1 && (v = -1);
}
return i === -1 || h === -1 || // We saw a non-dot character immediately before the dot
v === 0 || // The (right-most) trimmed path component is exactly '..'
v === 1 && i === h - 1 && i === g + 1 ? "" : l.slice(i, h);
}, u = function(l) {
if (l === null || typeof l != "object")
throw new TypeError(
'The "pathObject" argument must be of type Object. Received type ' + typeof l
);
return r("/", l);
}, w = function(l) {
n(l);
const i = {
root: "",
dir: "",
base: "",
ext: "",
name: ""
};
if (l.length === 0)
return i;
let g = l.charCodeAt(0), h;
const S = g === 47;
S ? (i.root = "/", h = 1) : h = 0;
let v = -1, _ = 0, k = -1, C = !0, $ = l.length - 1, L = 0;
for (; $ >= h; --$) {
if (g = l.charCodeAt($), g === 47) {
if (!C) {
_ = $ + 1;
break;
}
continue;
}
k === -1 && (C = !1, k = $ + 1), g === 46 ? v === -1 ? v = $ : L !== 1 && (L = 1) : v !== -1 && (L = -1);
}
return v === -1 || k === -1 || // We saw a non-dot character immediately before the dot
L === 0 || // The (right-most) trimmed path component is exactly '..'
L === 1 && v === k - 1 && v === _ + 1 ? k !== -1 && (_ === 0 && S ? i.base = i.name = l.slice(1, k) : i.base = i.name = l.slice(_, k)) : (_ === 0 && S ? (i.name = l.slice(1, v), i.base = l.slice(1, k)) : (i.name = l.slice(_, v), i.base = l.slice(_, k)), i.ext = l.slice(v, k)), _ > 0 ? i.dir = l.slice(0, _ - 1) : S && (i.dir = "/"), i;
}, m = "/", y = ":";
return {
relative: d,
resolve: o,
parse: w,
format: u,
join: a,
isAbsolute: c,
basename: x,
normalize: f,
dirname: t,
extname: I,
delimiter: y,
sep: m,
win32: null,
posix: {
relative: d,
resolve: o,
parse: w,
format: u,
join: a,
isAbsolute: c,
basename: x,
normalize: f,
dirname: t,
extname: I,
delimiter: y,
sep: m,
win32: null,
posix: null
}
};
}
const $t = {
darwin: {
arm64: [
{
platform: "darwin",
arch: "arm64",
abi: null,
platformArchABI: "qwik.darwin-arm64.node"
}
],
x64: [
{
platform: "darwin",
arch: "x64",
abi: null,
platformArchABI: "qwik.darwin-x64.node"
}
]
},
win32: {
x64: [
{
platform: "win32",
arch: "x64",
abi: "msvc",
platformArchABI: "qwik.win32-x64-msvc.node"
}
]
},
linux: {
x64: [
{
platform: "linux",
arch: "x64",
abi: "gnu",
platformArchABI: "qwik.linux-x64-gnu.node"
}
]
}
}, Fr = {
qwik: "2.0.0-beta.13-dev+cb19ff7"
};
async function Ut() {
const e = Et(), n = {
dynamicImport: (s) => {
throw new Error(
`Qwik Optimizer sys.dynamicImport() not implemented, trying to import: "${s}"`
);
},
strictDynamicImport: (s) => {
throw new Error(
`Qwik Optimizer sys.strictDynamicImport() not implemented, trying to import: "${s}"`
);
},
path: null,
cwd: () => "/",
os: "unknown",
env: e
};
if (n.path = jt(n), n.strictDynamicImport = n.dynamicImport = (s) => import(s), e !== "webworker" && e !== "browsermain")
try {
n.path = await n.dynamicImport("node:path"), n.cwd = () => process.cwd(), n.os = process.platform;
} catch {
}
return n;
}
async function Bt(e) {
const n = Et();
if (n === "node" || n === "bun") {
const s = $t[process.platform];
if (s) {
const r = s[process.arch];
if (r)
for (const o of r)
try {
return (await e.dynamicImport("node:module")).default.createRequire(import.meta.url)(
`../bindings/${o.platformArchABI}`
);
} catch (f) {
console.warn(
`Unable to load native binding ${o.platformArchABI}. Falling back to wasm build.`,
f?.message
);
}
}
}
if (n === "node" || n === "bun") {
const s = await e.dynamicImport("node:url"), r = e.path.dirname(s.fileURLToPath(import.meta.url)), o = e.path.join(r, "..", "bindings", "qwik_wasm_bg.wasm"), f = await e.dynamicImport("../bindings/qwik.wasm.mjs"), a = await (await e.dynamicImport("node:fs")).promises.readFile(o), d = await WebAssembly.compile(a);
return await f.default(d), f;
} else {
const s = await e.dynamicImport("../bindings/qwik.wasm.mjs");
return await s.default(), s;
}
}
const Et = () => typeof Deno < "u" ? "deno" : typeof Bun < "u" ? "bun" : typeof process < "u" && typeof global < "u" && process.versions && process.versions.node ? "node" : typeof self < "u" && typeof location < "u" && typeof navigator < "u" && typeof fetch == "function" && typeof WorkerGlobalScope == "function" && typeof self.importScripts == "function" ? "webworker" : typeof window < "u" && typeof document < "u" && typeof location < "u" && typeof navigator < "u" && typeof Window == "function" && typeof fetch == "function" ? "browsermain" : "unknown", Rt = async (e = {}) => {
const n = e?.sys || await Ut(), s = e?.binding || await Bt(n);
return {
async transformModules(o) {
return At(s, o);
},
sys: n
};
}, At = (e, n) => e.transform_modules(Ft(n)), Ft = (e) => {
const n = {
minify: "simplify",
sourceMaps: !1,
transpileTs: !1,
transpileJsx: !1,
preserveFilenames: !1,
explicitExtensions: !1,
mode: "lib",
manualChunks: void 0,
scope: void 0,
regCtxName: void 0,
stripEventHandlers: !1,
rootDir: void 0,
stripExports: void 0,
stripCtxName: void 0,
isServer: void 0
};
return Object.entries(e).forEach(([s, r]) => {
r != null && (n[s] = r);
}), n.entryStrategy = e.entryStrategy?.type ?? "smart", n.manualChunks = e.entryStrategy?.manual ?? void 0, n;
}, zt = (e, n = 0) => {
for (let s = 0; s < e.length; s++) {
const r = e.charCodeAt(s);
n = (n << 5) - n + r, n |= 0;
}
return Number(Math.abs(n)).toString(36);
}, Ht = /* @__PURE__ */ new Set(["_chk", "_run", "_task", "_val"]);
function Wt(e) {
const n = e.symbols;
return Object.keys(n).sort((s, r) => {
const o = n[s], f = n[r];
if (o.ctxKind === "eventHandler" && f.ctxKind !== "eventHandler")
return -1;
if (o.ctxKind !== "eventHandler" && f.ctxKind === "eventHandler")
return 1;
if (o.ctxKind === "eventHandler" && f.ctxKind === "eventHandler") {
const c = Xe.indexOf(o.ctxName.toLowerCase()), a = Xe.indexOf(f.ctxName.toLowerCase());
if (c > -1 && a > -1) {
if (c < a)
return -1;
if (c > a)
return 1;
} else {
if (c > -1)
return -1;
if (a > -1)
return 1;
}
} else if (o.ctxKind === "function" && f.ctxKind === "function") {
const c = Ve.indexOf(o.ctxName.toLowerCase()), a = Ve.indexOf(f.ctxName.toLowerCase());
if (c > -1 && a > -1) {
if (c < a)
return -1;
if (c > a)
return 1;
} else {
if (c > -1)
return -1;
if (a > -1)
return 1;
}
}
return !o.parent && f.parent ? -1 : o.parent && !f.parent ? 1 : o.hash < f.hash ? -1 : o.hash > f.hash ? 1 : 0;
});
}
const Xe = [
// Click Events
"click",
"dblclick",
"contextmenu",
"auxclick",
// Pointer Events
"pointerdown",
"pointerup",
"pointermove",
"pointerover",
"pointerenter",
"pointerleave",
"pointerout",
"pointercancel",
"gotpointercapture",
"lostpointercapture",
// Touch Events
"touchstart",
"touchend",
"touchmove",
"touchcancel",
// Mouse Events
"mousedown",
"mouseup",
"mousemove",
"mouseenter",
"mouseleave",
"mouseover",
"mouseout",
"wheel",
// Gesture Events
"gesturestart",
"gesturechange",
"gestureend",
// Keyboard Events
"keydown",
"keyup",
"keypress",
// Input/Change Events
"input",
"change",
"search",
"invalid",
"beforeinput",
"select",
// Focus/Blur Events
"focusin",
"focusout",
"focus",
"blur",
// Form Events
"submit",
"reset",
// Scroll Events
"scroll"
].map((e) => `on${e.toLowerCase()}$`), Ve = ["useTask$", "useVisibleTask$", "component$", "useStyles$", "useStylesScoped$"].map(
(e) => e.toLowerCase()
);
function Gt(e) {
return Object.keys(e.bundles).sort(Oe);
}
function Kt(e) {
const n = Wt(e), s = {}, r = {};
for (const c of n)
s[c] = e.symbols[c], r[c] = e.mapping[c];
const o = Gt(e), f = {};
for (const c of o) {
f[c] = e.bundles[c];
const a = e.bundles[c];
Array.isArray(a.imports) && a.imports.sort(Oe), Array.isArray(a.dynamicImports) && a.dynamicImports.sort(Oe);
const d = [];
for (const t of n)
c === r[t] && d.push(t);
d.length > 0 && (d.sort(Oe), a.symbols = d);
}
return e.symbols = s, e.mapping = r, e.bundles = f, e;
}
function Oe(e, n) {
return e = e.toLocaleLowerCase(), n = n.toLocaleLowerCase(), e < n ? -1 : e > n ? 1 : 0;
}
function Ze(e) {
if (e != null && e.mapping != null && typeof e.mapping == "object" && e.symbols != null && typeof e.symbols == "object" && e.bundles != null && typeof e.bundles == "object")
return e;
}
const Qt = (e, n) => {
let s = 0;
if (e.symbols)
for (const r of e.symbols) {
let o = 1;
const f = n.symbols[r];
f && (f.ctxKind === "function" ? /(component|useStyles|useStylesScoped)/i.test(f.ctxName) ? o += 1 : /(useComputed|useTask|useVisibleTask|useOn)/i.test(f.ctxName) && (o += 2) : (o += 1, /(click|mouse|pointer|touch|key|scroll|gesture|wheel)/i.test(f.ctxName) && (o += 3))), s = Math.max(s, o);
}
return s;
};
function Jt(e) {
let n = 0;
const s = [], r = [], o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
function a(m) {
o.set(m, n), f.set(m, n), n++, s.push(m), c.add(m);
const y = e[m].imports || [];
for (const p of y)
o.has(p) ? c.has(p) && f.set(m, Math.min(f.get(m), o.get(p))) : (a(p), f.set(m, Math.min(f.get(m), f.get(p))));
if (f.get(m) === o.get(m)) {
const p = [];
let l;
do
l = s.pop(), c.delete(l), p.push(l);
while (l !== m);
r.push(p);
}
}
for (const m of Object.keys(e))
o.has(m) || a(m);
const d = /* @__PURE__ */ new Map();
r.forEach((m, y) => {
for (const p of m)
d.set(p, y);
});
const t = Array.from({ length: r.length }, () => /* @__PURE__ */ new Set());
for (const m of Object.keys(e)) {
const y = d.get(m);
for (const p of e[m].imports || []) {
const l = d.get(p);
y !== l && t[y].add(l);
}
}
const x = /* @__PURE__ */ new Set(), I = [];
function u(m) {
x.add(m);
for (const y of t[m])
x.has(y) || u(y);
I.push(m);
}
for (let m = 0; m < r.length; m++)
x.has(m) || u(m);
I.reverse();
const w = new Array(r.length).fill(0);
for (let m = 0; m < r.length; m++) {
let y = 0;
for (const p of r[m])
y += e[p].size;
w[m] = y;
}
for (let m = I.length - 1; m >= 0; m--) {
const y = I[m];
let p = w[y];
for (const l of t[y])
p += w[l];
w[y] = p;
}
for (let m = 0; m < r.length; m++) {
const y = w[m];
for (const p of r[m])
e[p].total = y;
}
}
const et = /[/\\](core|qwik)[/\\]dist[/\\]preloader\.(|c|m)js$/, tt = /[/\\](core|qwik)[/\\]dist[/\\]core(\.min|\.prod)?\.(|c|m)js$/, nt = /[/\\](core|qwik)[/\\](dist[/\\])?qwikloader(\.debug)?\.[^/]*js$/, rt = /[/\\](core|qwik)[/\\]handlers\.(|c|m)js$/;
function Yt(e, n, s, r, o, f, c) {
var I;
const a = {
version: "1",
manifestHash: "",
options: {
target: o.target,
buildMode: o.buildMode,
// don't copy the insights stuff
entryStrategy: o.entryStrategy && { type: o.entryStrategy.type }
},
core: void 0,
preloader: void 0,
qwikLoader: void 0,
bundleGraphAsset: void 0,
injections: s,
mapping: {},
bundles: {},
assets: {},
symbols: {},
bundleGraph: void 0
}, d = (u) => {
const w = r[u];
if (!w) {
console.warn(`Client manifest generation: skipping external import "${u}"`);
return;
}
return c(w.fileName);
};
let t;
const x = new Set(n.map((u) => u.name));
for (const u of Object.values(r)) {
if (u.type === "asset") {
u.fileName.endsWith("js.map") || (a.assets[u.fileName] = {
name: u.names[0],
size: u.source.length
});
continue;
}
const w = c(u.fileName), y = {
size: u.code.length,
total: -1
};
for (const h of u.exports)
x.has(h) && (!a.mapping[h] || u.exports.length !== 1) && (a.mapping[h] = w);
const p = u.imports.filter((h) => u.code.includes(e.basename(h))).map((h) => d(h)).filter(Boolean);
p.length > 0 && (y.imports = p);
const l = u.dynamicImports.filter((h) => u.code.includes(e.basename(h))).map((h) => d(h)).filter(Boolean);
l.length > 0 && (y.dynamicImports = l), u.facadeModuleId && (et.test(u.facadeModuleId) ? a.preloader = w : tt.test(u.facadeModuleId) ? a.core = w : nt.test(u.facadeModuleId) ? a.qwikLoader = w : rt.test(u.facadeModuleId) && (t = w));
const g = (u.moduleIds || Object.keys(u.modules)).filter((h) => !h.startsWith("\0")).map((h) => e.relative(o.rootDir, h));
g.length > 0 && (y.origins = g, !a.preloader && g.some((h) => et.test(h)) && (a.preloader = w), !a.core && g.some((h) => tt.test(h)) && (a.core = w), !a.qwikLoader && g.some((h) => nt.test(h)) && (a.qwikLoader = w), !t && g.some((h) => rt.test(h)) && (t = w)), a.bundles[w] = y;
}
for (const u of n) {
const w = u.name, m = a.mapping[w];
if (!m) {
f(`Note: qrl ${u.name} is not in the bundle, likely tree shaken`, a);
continue;
}
((I = a.bundles[m]).symbols || (I.symbols = [])).push(w), a.symbols[w] = {
displayName: u.displayName,
hash: u.hash,
ctxKind: u.ctxKind,
ctxName: u.ctxName,
captures: u.captures,
canonicalFilename: u.canonicalFilename,
parent: u.parent,
origin: u.origin,
loc: u.loc,
paramNames: u.paramNames,
captureNames: u.captureNames
};
}
if (t)
for (const u of Ht)
a.symbols[u] = {
origin: "Qwik core",
displayName: u,
canonicalFilename: "",
hash: u,
ctxKind: "function",
ctxName: u,
captures: !1,
parent: null,
loc: [0, 0]
}, a.mapping[u] = t;
else
console.error("Qwik core bundle not found, is Qwik actually used in this project?");
for (const u of Object.values(a.bundles)) {
const w = Qt(u, a);
u.interactivity = w;
}
return Jt(a.bundles), Kt(a);
}
const Xt = 300, Vt = 0.5 / (Xt * 1024 / 8), Zt = (e) => {
const n = e.lastIndexOf("_");
return n > -1 ? e.slice(n + 1) : e;
};
function en(e, n) {
const s = [];
if (!e.bundles)
return [];
const r = { ...e.bundles };
for (const [d, t] of Object.entries(e.mapping)) {
if (d.startsWith("_") && d.length < 10)
continue;
const x = Zt(d);
x && (r[x] = { dynamicImports: [t] });
}
if (n) {
const d = { ...e, bundles: r };
for (const t of n) {
const x = t(d);
x && Object.assign(r, x);
}
}
for (const d of Object.keys(r)) {
const t = r[d], x = t.imports?.filter((u) => r[u]) || [], I = t.dynamicImports?.filter(
// we only want to include dynamic imports that belong to the app
// e.g. not all languages supported by shiki
(u) => r[u] && // either there are qrls
(r[u].symbols || // or it's a dynamic import from the app source
r[u].origins?.some((w) => !w.includes("node_modules")))
) || [];
r[d] = {
...t,
imports: x,
dynamicImports: I
};
}
const o = new Set(Object.keys(r));
for (const d of Object.keys(r)) {
for (const t of r[d].imports)
o.delete(t);
for (const t of r[d].dynamicImports)
o.delete(t);
}
for (const d of o) {
const t = r[d];
!t.imports?.length && !t.dynamicImports?.length && delete r[d];
}
const f = Object.keys(r), c = /* @__PURE__ */ new Map(), a = (d, t, x = /* @__PURE__ */ new Set()) => {
const I = r[t];
for (const u of I.imports)
d.has(u) && d.delete(u), x.has(u) || (x.add(u), a(d, u, x));
};
for (const d of f) {
const t = r[d], x = new Set(t.imports);
for (const m of x)
a(x, m);
const I = new Set(t.dynamicImports), u = /* @__PURE__ */ new Map();
for (const m of I) {
a(I, m);
const y = r[m];
let p = 0.5;
if (p += (y.interactivity || 0) * 0.08, t.origins && y.origins) {
for (const l of t.origins)
if (y.origins.some((i) => i.startsWith(l))) {
p += 0.25;
break;
}
}
y.total > Vt && (p += p > 0.5 ? 0.02 : -0.02), y.total < 1e3 && (p += 0.15), u.set(m, Math.min(p, 0.99));
}
if (I.size > 0) {
const m = Array.from(I).sort(
(p, l) => u.get(l) - u.get(p)
);
let y = -1;
for (const p of m)
u.get(p) !== y && (y = u.get(p), x.add(-Math.round(y * 10))), x.add(p);
}
const w = s.length;
s.push(d);
for (let m = 0; m < x.size; m++)
s.push(null);
c.set(d, { index: w, deps: x });
}
for (const d of f) {
const t = c.get(d);
let { index: x, deps: I } = t;
x++;
for (const u of I) {
if (typeof u == "number") {
s[x++] = u;
continue;
}
const m = c.get(u).index;
s[x++] = m;
}
}
return s;
}
async function tn(e, n, s) {
const r = await e.dynamicImport("eslint");
let o = new r.ESLint({ cache: !0 });
if ((await o.calculateConfigForFile("no-real-file.tsx")).parser === null) {
const a = {
cache: !0,
overrideConfig: {
languageOptions: {
parserOptions: {
tsconfigRootDir: n,
project: s,
ecmaVersion: 2021,
sourceType: "module",
ecmaFeatures: {
jsx: !0
}
}
}
}
};
o = new r.ESLint(a);
}
return {
async lint(a, d, t) {
try {
const x = nn(t);
if (await o.isPathIgnored(x))
return null;
(await o.lintText(d, {
filePath: x
})).forEach((u) => {
for (const w of u.messages) {
if (w.ruleId != null && !w.ruleId.startsWith("qwik/"))
continue;
const m = rn(u.filePath, w);
a.warn(m);
}
});
} catch (x) {
console.warn(x);
}
}
};
}
function nn(e) {
return e.split("?", 2)[0];
}
function rn(e, n) {
return Object.assign(new Error(n.message), {
id: e,
plugin: "vite-plugin-eslint",
loc: {
file: e,
column: n.column,
line: n.line
},
stack: ""
});
}
async function on(e, n) {
const s = n;
let r = s.loc;
if (!s.frame && !s.plugin && (r || (r = sn(s)), r && (s.loc = r, r.file))) {
const o = await e.dynamicImport("node:fs"), { normalizePath: f } = await e.dynamicImport("vite");
s.id = f(s.loc.file);
try {
const c = o.readFileSync(s.loc.file, "utf-8");
s.frame = ln(c, s.loc);
} catch {
}
}
return n;
}
const sn = (e) => {
const n = e.stack;
if (typeof n == "string") {
const s = n.split(`
`).filter((r) => !r.includes("/node_modules/") && !r.includes("(node:"));
for (let r = 1; r < s.length; r++) {
const o = s[r].replace("file:///", "/");
if (/^\s+at/.test(o)) {
const f = o.indexOf("/"), c = o.lastIndexOf(")", f);
if (f > 0) {
const d = o.slice(f, c).split(":"), t = ot(d[d.length - 1]), x = ot(d[d.length - 2]);
return typeof t == "number" && typeof x == "number" ? (d.length -= 2, {
file: d.join(":"),
line: x,
column: t
}) : typeof t == "number" ? (d.length -= 1, {
file: d.join(":"),
line: t,
column: void 0
}) : {
file: d.join(":"),
line: void 0,
column: void 0
};
}
}
}
}
}, ee = (e) => e.startsWith("\0"), ot = (e) => {
try {
return parseInt(e, 10);
} catch {
return;
}
}, _t = /\r?\n/, it = 2;
function an(e, n) {
if (typeof n == "number")
return n;
if (n.lo != null)
return n.lo;
const s = e.split(_t), { line: r, column: o } = n;
let f = 0;
for (let c = 0; c < r - 1 && c < s.length; c++)
f += s[c].length + 1;
return f + o;
}
function ln(e, n = 0, s) {
n = an(e, n), s = s || n;
const r = e.split(_t);
let o = 0;
const f = [];
for (let c = 0; c < r.length; c++)
if (o += r[c].length + 1, o >= n) {
for (let a = c - it; a <= c + it || s > o; a++) {
if (a < 0 || a >= r.length)
continue;
const d = a + 1;
f.push(`${d}${" ".repeat(Math.max(3 - String(d).length, 0))}| ${r[a]}`);
const t = r[a].length;
if (a === c) {
const x = Math.max(n - (o - t) + 1, 0), I = Math.max(1, s > o ? t - x : s - n);
f.push(" | " + " ".repeat(x) + "^".repeat(I));
} else if (a > c) {
if (s > o) {
const x = Math.max(Math.min(s - o, t), 1);
f.push(" | " + "^".repeat(x));
}
o += t + 1;
}
}
break;
}
return f.join(`
`);
}
function cn(e) {
return e === "win32";
}
function Le(e) {
const [n, s] = e.split("?"), r = s || "";
return {
originalId: e,
pathId: n,
query: r ? `?${s}` : "",
params: new URLSearchParams(r)
};
}
const dn = ["server"], un = [
"onGet",
"onPost",
"onPut",
"onRequest",
"onDelete",
"onHead",
"onOptions",
"onPatch",
"onStaticGenerate"
], fn = [
"useServer",
"route",
"server",
"action$",
"loader$",
"zod$",
"validator$",
"globalAction$"
], pn = [
"useClient",
"useBrowser",
"useVisibleTask",
"client",
"browser",
"event$"
];
var Tt = /* @__PURE__ */ ((e) => (e.preventNavigate = "preventNavigate", e.valibot = "valibot", e.noSPA = "noSPA", e.enableRequestRewrite = "enableRequestRewrite", e.webWorker = "webWorker", e.insights = "insights", e))(Tt || {});
function Ct(e = {}) {
const n = `${Math.round(Math.random() * 899) + 100}`, s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
let c = null, a, d = () => {
};
const t = {
csr: !1,
target: "client",
buildMode: "development",
debug: !1,
rootDir: void 0,
tsconfigFileNames: ["./tsconfig.json"],
input: void 0,
outDir: void 0,
assetsDir: void 0,
resolveQwikBuild: !0,
entryStrategy: void 0,
srcDir: void 0,
ssrOutDir: void 0,
clientOutDir: void 0,
sourcemap: !!e.sourcemap,
manifestInput: null,
manifestInputPath: null,
manifestOutput: null,
transformedModuleOutput: null,
scope: null,
devTools: {
imageDevTools: !0,
clickToSource: ["Alt"]
},
inlineStylesUpToBytes: 2e4,
lint: !1,
experimental: void 0
};
let x, I;
const u = async () => {
if (!c && (c = await Rt(e), x = hn(c.sys), c.sys.env !== "browsermain" && c.sys.env !== "webworker"))
try {
I === void 0 && (I = await c.sys.dynamicImport("node:fs"));
} catch {
console.log("node:fs not available, disabling automatic manifest reading"), I = null;
}
}, w = () => {
if (!c)
throw new Error("Qwik plugin has not been initialized");
return c;
}, m = () => w().sys, y = () => w().sys.path;
let p;
const l = (E) => {
p = E;
}, i = async (E) => {
const b = Object.assign({}, E), T = w(), N = T.sys.path, D = (...O) => J(N.resolve(...O));
t.debug = !!b.debug, b.assetsDir && (t.assetsDir = b.assetsDir), b.target === "ssr" || b.target === "client" || b.target === "lib" || b.target === "test" ? t.target = b.target : t.target || (t.target = "client"), t.target === "lib" ? t.buildMode = "development" : b.buildMode === "production" || b.buildMode === "development" ? t.buildMode = b.buildMode : t.buildMode || (t.buildMode = "development"), t.csr = !!b.csr, b.entryStrategy && typeof b.entryStrategy == "object" && (t.entryStrategy = { ...b.entryStrategy }), t.entryStrategy || (t.target === "ssr" || t.target === "test" ? t.entryStrategy = { type: "hoist" } : t.target === "lib" ? t.entryStrategy = { type: "inline" } : t.buildMode === "production" ? t.entryStrategy = { type: "smart" } : t.entryStrategy = { type: "segment" }), typeof b.rootDir == "string" && (t.rootDir = b.rootDir), typeof t.rootDir != "string" && (t.rootDir || (t.rootDir = T.sys.cwd())), t.rootDir = D(T.sys.cwd(), t.rootDir);
let P = D(t.rootDir, yn);
if (typeof b.srcDir == "string" ? (t.srcDir = D(t.rootDir, b.srcDir), P = t.srcDir) : t.srcDir || (t.srcDir = P), t.srcDir = D(t.rootDir, t.srcDir), Array.isArray(b.tsconfigFileNames) && b.tsconfigFileNames.length > 0 && (t.tsconfigFileNames = b.tsconfigFileNames), !t.csr && !b.input && !t.input && (t.target === "ssr" ? t.input = [D(P, "entry.ssr")] : t.target === "client" ? t.input = [D(P, "root")] : t.input = void 0), b.outDir && (t.outDir = D(t.rootDir, b.outDir)), t.clientOutDir = D(t.rootDir, b.clientOutDir || st), t.ssrOutDir = D(t.rootDir, b.ssrOutDir || bn), t.target === "ssr" ? t.outDir || (t.outDir = t.ssrOutDir) : t.target === "lib" ? t.outDir || (t.outDir = D(t.rootDir, vn)) : t.outDir || (t.outDir = t.clientOutDir), typeof b.manifestOutput == "function" && (t.manifestOutput = b.manifestOutput), b.manifestInput && (t.manifestInput = Ze(b.manifestInput) || null), typeof b.transformedModuleOutput == "function" && (t.transformedModuleOutput = b.transformedModuleOutput), b.scope !== void 0)
t.scope = b.scope;
else if (!t.scope && I) {
let O = "";
try {
let B = t.rootDir;
for (; O = N.resolve(B, "package.json"), !await I.promises.stat(O).catch(() => !1); ) {
const M = N.resolve(B, "..");
if (M === B)
break;
B = M, O = "";
}
if (O) {
const M = await I.promises.readFile(O, "utf-8"), q = JSON.parse(M);
typeof q.name == "string" && (t.scope = q.name);
}
} catch (B) {
console.warn(
`could not read ${O || "package.json"} to determine package name, ignoring. (${B})`
);
}
}
if (typeof b.resolveQwikBuild == "boolean" && (t.resolveQwikBuild = b.resolveQwikBuild), typeof b.devTools == "object" && ("imageDevTools" in b.devTools && (t.devTools.imageDevTools = b.devTools.imageDevTools), "clickToSource" in b.devTools && (t.devTools.clickToSource = b.devTools.clickToSource)), "inlineStylesUpToBytes" in e && (typeof e.inlineStylesUpToBytes == "number" ? t.inlineStylesUpToBytes = e.inlineStylesUpToBytes : (typeof t.inlineStylesUpToBytes != "number" || t.inlineStylesUpToBytes < 0) && (t.inlineStylesUpToBytes = 0)), typeof b.lint == "boolean" && (t.lint = b.lint), "experimental" in b) {
t.experimental = void 0;
for (const O of b.experimental ?? [])
Tt[O] ? (t.experimental || (t.experimental = {}))[O] = !0 : console.error(`Qwik plugin: Unknown experimental feature: ${O}`);
}
const R = { ...t };
return t.input || (t.input = b.input), t.input && typeof t.input == "string" && (t.input = [t.input]), R;
};
let g = !1;
const h = async (E) => {
if (!g) {
g = !0;
const b = m();
if (b.env === "node") {
const T = await b.dynamicImport("node:fs");
if (!T.existsSync(t.rootDir))
throw new Error(`Qwik rootDir "${t.rootDir}" not found.`);
if (typeof t.srcDir == "string" && !T.existsSync(t.srcDir))
throw new Error(`Qwik srcDir "${t.srcDir}" not found.`);
for (const [N, D] of Object.entries(t.input || {}))
if (!await E(D))
throw new Error(`Qwik input "${D}" not found.`);
}
}
};
let S, v = !1;
const _ = async (E) => {
if (j("buildStart()", t.buildMode, t.scope, t.target, t.rootDir, t.srcDir), S = w(), v = !p, S.sys.env === "node" && t.target === "ssr" && t.lint)
try {
a = await tn(S.sys, t.rootDir, t.tsconfigFileNames);
} catch {
}
if (j("transformedOutputs.clear()"), r.clear(), o.clear(), t.target === "client") {
const b = await E.resolve("@qwik.dev/core/qwikloader.js", void 0, {
skipSelf: !0
});
b && E.emitFile({
id: b.id,
type: "chunk",
preserveSignature: "allow-extension"
});
}
}, k = (E) => p ? !!E?.ssr : t.target === "ssr" || t.target === "test";
let C = 0, $ = !1;
const L = async (E, b, T, N) => {
if (ee(b))
return;
const D = p && /^(.*)\?editor(:(\d+)(:\d+)?)?$/.exec(b);
if (D) {
if (!$) {
$ = !0, setTimeout(() => $ = !1, 500);
const [, K, z] = D, ce = await E.resolve(K, T);
if (ce) {
const ae = p.moduleGraph.getModuleById(ce.id)?.file;
if (ae) {
const te = `${ae}${z}`;
try {
console.warn(`Opening in editor: ${te}`);
const Y = (await import("launch-editor")).default;
Y(te);
} catch (Y) {
console.error(`Failed to open editor: ${Y.message}`);
}
}
}
}
return { id: "\0editor" };
}
const P = C++, R = k(N);
j(`resolveId(${P})`, `begin ${b} | ${R ? "server" : "client"} | ${T}`);
const O = T && Le(T);
if (T = O && J(O.pathId), b.startsWith(".") && O) {
const K = y(), z = K.dirname(O.pathId);
z && (b = K.resolve(z, b));
}
const B = Le(b), M = J(B.pathId);
let q;
if (
/**
* Check if we know the QRL. During regular builds, we'll encounter and build parents before
* their QRLs, so this will always match.
*/
f.get(M)
)
j(`resolveId(${P}) Resolved already known ${M}`), q = {
id: M + B.query,
moduleSideEffects: !1
};
else if (
/**
* Now the requests we handle are for one of the virtual modules, or a QRL segment that hasn't
* been transformed yet.
*/
// We test with endsWith because the dev server adds the base pathname
M.endsWith(ne)
)
t.resolveQwikBuild && (j(`resolveId(${P})`, "Resolved", ne), q = {
id: ne,
moduleSideEffects: !1
});
else if (M.endsWith(re))
j(`resolveId(${P})`, "Resolved", re), q = {
id: re,
moduleSideEffects: !1
};
else if (!p && !R && M.endsWith(ze)) {
j(`resolveId(${P})`, "Resolved", ze);
const K = await E.resolve(ze, T, {
skipSelf: !0
});
if (K)
return E.emitFile({
id: K.id,
type: "chunk",
preserveSignature: "allow-extension"
}), K;
} else if (M.endsWith(fe))
j(`resolveId(${P})`, "Resolved", fe), q = {
id: fe,
moduleSideEffects: !1
};
else {
if (!R && v && b.endsWith("@qwik.dev/core")) {
v = !1;
const z = await E.resolve("@qwik.dev/core/handlers.mjs", T, {
skipSelf: !0
});
if (!z)
throw new Error("Failed to resolve @qwik.dev/core/handlers.mjs");
E.emitFile({
id: z.id,
type: "chunk",
preserveSignature: "allow-extension"
});
}
const K = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(b)?.groups;
if (K) {
const { parent: z, name: ce, query: ae } = K, te = await E.resolve(z, T, { skipSelf: !0 });
if (te) {
const Y = te.id.split("?")[0], Me = p && T?.endsWith(".html") ? `${Y}_${ce}.js` : M;
j(`resolveId(${P})`, `resolved to QRL ${ce} of ${Y}`), f.set(Me, Y), q = {
id: Me + ae,
// QRL segments can't have side effects. Probably never useful, but it's here for consistency
moduleSideEffects: !1
};
} else
console.error(`resolveId(${P})`, `QRL parent ${z} does not exist!`);
} else if (T) {
const z = f.get(T);
if (z)
return j(`resolveId(${P}) end`, `resolving via ${z}`), E.resolve(b, z, { skipSelf: !0 });
}
}
return j(`resolveId(${P}) end`, q?.id || q), q;
};
let U = 0;
const H = async (E, b, T) => {
if (b === "\0editor")
return '"opening in editor"';
if (ee(b) || b.startsWith("/@fs/"))
return;
const N = U++, D = k(T);
if (t.resolveQwikBuild && b === ne)
return j(`load(${N})`, ne, t.buildMode), {
moduleSideEffects: !1,
code: se(D, t.target)
};
if (b === re)
return j(`load(${N})`, re, t.buildMode), {
moduleSideEffects: !1,
code: await De(D)
};
if (b === fe)
return j(`load(${N})`, fe, t.buildMode), {
moduleSideEffects: !1,
code: "export * from '@qwik.dev/core';"
};
const P = Le(b);
b = J(P.pathId);
const R = D ? o : r;
if (p && !R.has(b)) {
const B = f.get(b);
if (B) {
const M = p.moduleGraph.getModuleById(B);
if (M) {
if (j(`load(${N})`, "transforming QRL parent", B), await p.transformRequest(M.url), !R.has(b))
return j(`load(${N})`, `QRL segment ${b} not found in ${B}`), null;
} else
console.error(`load(${N})`, `${M} does not exist!`);
}
}
const O = R.get(b);
if (O) {
j(`load(${N})`, "Found", b);
const { code: B, map: M, segment: q } = O[0];
return { code: B, map: M, meta: { segment: q } };
}
return j(`load(${N})`, "Not a QRL or virtual module", b), null;
};
let Q = 0;
const ie = async function(E, b, T, N = {}) {
if (ee(T))
return;
const D = Q++, P = k(N), R = P ? o : r;
if (R.has(T))
return;
const O = w(), B = y(), { pathId: M } = Le(T), q = B.parse(M), K = q.dir, z = q.base;
if (q.ext.toLowerCase() in gn || Pt.test(M)) {
const ae = t.target === "client" || t.target === "ssr";
j(
`transform(${D})`,
`Transforming ${T} (for: ${P ? "server" : "client"}${ae ? ", strip" : ""})`
);
const te = t.target === "lib" ? "lib" : t.buildMode === "development" ? "dev" : "prod";
te !== "lib" && (b = b.replaceAll(/__EXPERIMENTAL__\.(\w+)/g, (Z, le) => t.experimental?.[le] ? "true" : "false"));
let Y = z;
t.srcDir && (Y = B.relative(t.srcDir, M)), Y = J(Y);
const Ne = t.srcDir ? t.srcDir : J(K), Me = t.entryStrategy;
let Ye;
p && (Ye = p.moduleGraph.getModuleById(M)?.url);
const de = {
input: [{ code: b, path: Y, devPath: Ye }],
entryStrategy: P ? { type: "hoist" } : Me,
minify: "simplify",
// Always enable sourcemaps in dev for click-to-source
sourceMaps: t.sourcemap || t.buildMode === "development",
transpileTs: !0,
transpileJsx: !0,
explicitExtensions: !0,
preserveFilenames: !0,
srcDir: Ne,
rootDir: t.rootDir,
mode: te,
scope: t.scope || void 0,
isServer: P
};
ae && (P ? (de.stripCtxName = pn, de.stripEventHandlers = !0, de.regCtxName = dn) : (de.stripCtxName = fn, de.stripExports = un));
const Ot = Date.now(), ue = await O.transformModules(de);
j(`transform(${D})`, `done in ${Date.now() - Ot}ms`);
const qe = ue.modules.find((Z) => !mn(Z));
d(ue.diagnostics, O, Ne), P ? ue.diagnostics.length === 0 && a && a.lint(E, b, T) : s.set(T, ue);
const Ae = /* @__PURE__ */ new Set();
for (const Z of ue.modules)
if (Z !== qe) {
const le = J(B.join(Ne, Z.path));
j(`transform(${D})`, `segment ${le}`, Z.segment.displayName), f.set(le, T), R.set(le, [Z, T]), Ae.add(le), t.target === "client" && !p && E.emitFile({
id: le,
type: "chunk",
preserveSignature: "allow-extension"
});
}
return await Promise.all([...Ae.values()].map((Z) => E.load({ id: Z }))), E.addWatchFile(T), {
code: qe.code,
map: qe.map,
meta: {
segment: qe.segment,
qwikdeps: Array.from(Ae)
}
};
}
return j(`transform(${D})`, "Not transforming", T), null;
}, W = (E) => {
const b = [], T = {
addInjection: (N) => b.push(N)
};
return T.generateManifest = async (N) => {
const P = w().sys.path, R = P.resolve(t.rootDir, t.outDir, "build"), O = (q) => P.relative(R, P.resolve(t.rootDir, t.outDir, q));
T.canonPath = O;
const B = Array.from(s.values()).flatMap((q) => q.modules).map((q) => q.segment).filter((q) => !!q), M = Yt(
P,
B,
b,
E,
t,
j,
O
);
N && Object.assign(M, N);
for (const q of Object.values(M.symbols))
q.origin && (q.origin = J(q.origin));
for (const q of Object.values(M.bundles))
q.origins && (q.origins = q.origins.sort());
return M.manifestHash = zt(JSON.stringify(M)), M;
}, T;
}, V = () => t, X = () => Array.from(r.values()).map((E) => E[0]), j = (...E) => {
t.debug && console.debug(`[QWIK PLUGIN: ${n}]`, ...E);
}, Re = (...E) => {
console.log(`[QWIK PLUGIN: ${n}]`, ...E);
}, G = (E) => {
d = E;
}, J = (E) => x(E);
function se(E, b) {
const T = t.buildMode === "development";
return `// @qwik.dev/core/build
export const isServer = ${JSON.stringify(E)};
export const isBrowser = ${JSON.stringify(!E)};
export const isDev = ${JSON.stringify(T)};
`;
}
async function De(E) {
if (!t.manifestInput && t.target === "ssr" && t.buildMode === "production" && I) {
const N = y();
let D = t.manifestInputPath || N.resolve(t.clientOutDir, He);
await I.promises.stat(D).catch(() => !1) || (D = N.resolve(t.rootDir, st, He));
try {
const P = await I.promises.readFile(D, "utf-8");
t.manifestInput = Ze(JSON.parse(P)) || null, console.info("Read client manifest from", D);
} catch (P) {
console.warn(
`
==========
Could not read Qwik client manifest ${D}.
Make sure you provide it to the qwikVite plugin via the \`manifestInput\` \`manifestInputPath\` arguments, or to the SSR renderer via the \`manifest\` argument, or define it in \`globalThis.__QWIK_MANIFEST__\` before the server bundle is loaded, or embed it in the server bundle by replacing \`globalThis.__QWIK_MANIFEST__\`.
Without the manifest, the SSR renderer will not be able to generate event handlers.
(${P})
==========
`
);
}
}
const b = E ? t.manifestInput : null;
let T = null;
return b?.manifestHash && (T = {
manifestHash: b.manifestHash,
core: b.core,
preloader: b.preloader,
qwikLoader: b.qwikLoader,
bundleGraphAsset: b.bundleGraphAsset,
injections: b.injections,
mapping: b.mapping,
bundleGraph: b.bundleGraph
}), `// @qwik-client-manifest
export const manifest = ${T ? JSON.stringify(T) : "globalThis.__QWIK_MANIFEST__"};
`;
}
function Nt(E) {
t.sourcemap = E;
}
function Mt(E) {
j("handleHotUpdate()", E.file);
for (const b of E.modules) {
const { id: T } = b;
if (T) {
j("handleHotUpdate()", `invalidate ${T}`), s.delete(T);
for (const N of [r, o])
for (const [D, [P, R]] of N)
if (R === T) {
j("handleHotUpdate()", `invalidate ${T} segment ${D}`), N.delete(D);
const O = E.server.moduleGraph.getModuleById(D);
O && E.server.moduleGraph.invalidateModule(O);
}
}
}
}
const qt = (E, { getModuleInfo: b }) => {
if (t.target === "client") {
if (
// The preloader has to stay in a separate chunk if it's a client build
// the vite preload helper must be included or to prevent breaking circular dependencies
E.endsWith("@qwik.dev/core/build") || /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(E) || E === "\0vite/preload-helper.js"
)
return "qwik-preloader";
if (
// likewise, core and handlers have to be in the same chunk so there's no import waterfall
/[/\\](core|qwik)[/\\](handlers|dist[/\\]core(\.prod|\.min)?)\.[cm]js$/.test(E)
)
return "qwik-core";
if (/[/\\](core|qwik)[/\\]dist[/\\]qwikloader\.js$/.test(E))
return "qwik-loader";
}
const T = b(E);
if (T) {
const N = T.meta.segment;
if (N) {
const { hash: D } = N, P = t.entryStrategy.manual?.[D] || N.entry;
if (P)
return P;
}
}
return null;
};
async function Lt(E, b, T, N) {
const P = await W(b).generateManifest(N);
P.platform = {
...N?.platform,
rollup: E.meta?.rollupVersion || "",
env: S.sys.env,
os: S.sys.os
}, S.sys.env === "node" && (P.platform.node = process.versions.node);
const R = en(P, T), O = E.emitFile({
type: "asset",
name: "bundle-graph.json",
source: JSON.stringify(R)
}), B = E.getFileName(O);
P.bundleGraphAsset = B, P.assets[B] = {
name: "bundle-graph.json",
size: R.length
};
const M = JSON.stringify(P, null, " ");
E.emitFile({
fileName: He,
type: "asset",
source: M
}), typeof t.manifestOutput == "function" && await t.manifestOutput(P), typeof t.transformedModuleOutput == "function" && await t.transformedModuleOutput(X());
}
return {
buildStart: _,
createOutputAnalyzer: W,
getQwikBuildModule: se,
getOptimizer: w,
getOptions: V,
getPath: y,
getSys: m,
getTransformedOutputs: X,
init: u,
load: H,
debug: j,
log: Re,
normalizeOptions: i,
normalizePath: J,
onDiagnostics: G,
resolveId: L,
transform: ie,
validateSource: h,
setSourceMapSupport: Nt,
configureServer: l,
handleHotUpdate: Mt,
manualChunks: qt,
generateManifest: Lt
};
}
const hn = (e) => (n) => typeof n == "string" ? cn(e.os) ? (n.startsWith("\\\\?\\") || /[^\u0000-\u0080]+/.test(n) || (n = n.replace(/\\/g, "/")), e.path.posix.normalize(n)) : e.path.normalize(n) : n;
function mn(e) {
return e.isEntry || e.segment;
}
const gn = {
".jsx": !0,
".ts": !0,
".tsx": !0
}, Pt = /\.qwik\.[mc]?js$/, je = "@qwik.dev/core", $e = "@qwik.dev/core/internal", ne = "@qwik.dev/core/build", Ke = "@qwik.dev/core/jsx-runtime", Qe = "@qwik.dev/core/jsx-dev-runtime", Fe = "@qwik.dev/core/server", re = "@qwik-client-manifest", ze = "@qwik.dev/core/preloader", fe = "@qwik-handlers", yn = "src", st = "dist", bn = "server", vn = "lib", He = "q-manifest.json";
async function wn(e, n, s) {
if (e.env === "browsermain" || e.env === "webworker")
return;
const r = await e.dynamicImport("node:fs");
let o = s;
for (; o; ) {
const f = e.path.join(o, "node_modules", n, "package.json");
try {
return await r.promises.access(f), r.promises.realpath(f);
} catch {
}
const c = e.path.dirname(o);
if (c === o)
break;
o = c;
}
}
function zr(e = {}) {
const n = Ct(e.optimizerOptions);
return {
name: "rollup-plugin-qwik",
api: {
getOptimizer: () => n.getOptimizer(),
getOptions: () => n.getOptions()
},
async options(r) {
await n.init();
const o = r.onwarn;
r.onwarn = (a, d) => {
a.plugin === "typescript" && a.message.includes("outputToFilesystem") || (o ? o(a, d) : d(a));
};
const f = {
csr: e.csr,
target: e.target,
buildMode: e.buildMode,
debug: e.debug,
entryStrategy: e.entryStrategy,
rootDir: e.rootDir,
srcDir: e.srcDir,
srcInputs: e.srcInputs,
input: r.input,
resolveQwikBuild: !0,
manifestOutput: e.manifestOutput,
manifestInput: e.manifestInput,
transformedModuleOutput: e.transformedModuleOutput,
inlineStylesUpToBytes: e.optimizerOptions?.inlineStylesUpToBytes,
lint: e.lint,
experimental: e.experimental
};
await n.normalizeOptions(f);
const { input: c } = n.getOptions();
return r.input = c, r;
},
output