@stacksjs/stx 0.2.464 → 0.2.466
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/{chunk-hhsynd7c.js → chunk-01zwbzyw.js} +319 -159
- package/dist/{chunk-dqdggvq4.js → chunk-0adxpd3e.js} +18 -18
- package/dist/{chunk-nkxa7men.js → chunk-1rbabtw0.js} +1 -1
- package/dist/{chunk-0fvz8wad.js → chunk-24xhcqt9.js} +1 -1
- package/dist/{chunk-raqqq3mm.js → chunk-45ffx66n.js} +1 -1
- package/dist/{chunk-jr3g08vs.js → chunk-4rnncksa.js} +1 -1
- package/dist/{chunk-kmb9qrdg.js → chunk-5xsd1dw1.js} +1 -1
- package/dist/{chunk-938g2a3d.js → chunk-6qsvh58v.js} +1 -1
- package/dist/{chunk-zhexga43.js → chunk-6xd9qbve.js} +1 -1
- package/dist/{chunk-mfxf378k.js → chunk-812sn7d5.js} +2 -2
- package/dist/{chunk-5yn0gpcj.js → chunk-8bpyr4az.js} +10 -10
- package/dist/{chunk-d1x5r4p6.js → chunk-8bsz3ky4.js} +1 -1
- package/dist/{chunk-wvxj6r2a.js → chunk-9zx4p42m.js} +1 -1
- package/dist/{chunk-y9j2kf3k.js → chunk-ars3cbs5.js} +5 -5
- package/dist/{chunk-tsg7bj9p.js → chunk-bnemhyg2.js} +1 -1
- package/dist/{chunk-pw34r8r5.js → chunk-cmej3vrr.js} +1 -1
- package/dist/{chunk-mxtah7y5.js → chunk-d78wbjkz.js} +1 -1
- package/dist/{chunk-nwwzf7h1.js → chunk-eanwntq4.js} +1 -1
- package/dist/{chunk-tesmv3m9.js → chunk-ebp212na.js} +2 -2
- package/dist/{chunk-y8mx0hab.js → chunk-f9c58ag8.js} +2 -2
- package/dist/{chunk-a35c060g.js → chunk-fads0sap.js} +1 -1
- package/dist/{chunk-q316y302.js → chunk-fmtyrdgg.js} +1 -1
- package/dist/{chunk-1p5ge6fq.js → chunk-gmccacxc.js} +1 -1
- package/dist/{chunk-d9360m89.js → chunk-h074e6w3.js} +1 -1
- package/dist/{chunk-vhdemrec.js → chunk-h6ayvmaj.js} +1 -1
- package/dist/{chunk-39q77svv.js → chunk-hra6t4ch.js} +1 -1
- package/dist/chunk-jkf5k215.js +17 -0
- package/dist/{chunk-txkfp4v5.js → chunk-k8smv0at.js} +1 -1
- package/dist/{chunk-jmhhv817.js → chunk-kax708d4.js} +1 -1
- package/dist/{chunk-tzjqtweb.js → chunk-kca543an.js} +1 -1
- package/dist/{chunk-bp53x03f.js → chunk-kkrmhb5b.js} +1 -1
- package/dist/chunk-m08fk6ds.js +12 -0
- package/dist/{chunk-4yjtwjrw.js → chunk-mdkj4jj1.js} +1 -1
- package/dist/chunk-n39zm07w.js +2 -0
- package/dist/{chunk-xbm2gcb6.js → chunk-na5evt2b.js} +1 -1
- package/dist/{chunk-ajqwjevt.js → chunk-pbfwbtg4.js} +1 -1
- package/dist/{chunk-ccy6avqe.js → chunk-pyqh70k2.js} +1 -1
- package/dist/{chunk-r5gyx7ch.js → chunk-q7bs39wj.js} +1 -1
- package/dist/{chunk-krsdcjxk.js → chunk-rdp06c4s.js} +1 -1
- package/dist/{chunk-0yba08sr.js → chunk-rx3rxfrj.js} +1 -1
- package/dist/{chunk-etjw0he9.js → chunk-sz1s3k89.js} +1 -1
- package/dist/{chunk-eegxyqk3.js → chunk-t2hkwjvd.js} +1 -1
- package/dist/{chunk-mxt11ejx.js → chunk-tejeej39.js} +1 -1
- package/dist/{chunk-qr15ksz9.js → chunk-v6qxmac5.js} +1 -1
- package/dist/{chunk-tkakxkbx.js → chunk-vcjfwjr8.js} +1 -1
- package/dist/{chunk-dcv6absa.js → chunk-w7m1w5qt.js} +1 -1
- package/dist/{chunk-ng61wjke.js → chunk-wfqnxb38.js} +1 -1
- package/dist/{chunk-sprx02g0.js → chunk-wx25t40k.js} +1 -1
- package/dist/{chunk-raeyd6e5.js → chunk-xk3wf5sh.js} +1 -1
- package/dist/{chunk-rjm3n62n.js → chunk-xk5972g0.js} +1 -1
- package/dist/{chunk-skjwh35r.js → chunk-y63bv55f.js} +1 -1
- package/dist/{chunk-627af18j.js → chunk-zr2trjex.js} +1 -1
- package/dist/cli.js +9 -9
- package/dist/client-script-bundler.d.ts +10 -0
- package/dist/client-script-bundler.js +10 -4
- package/dist/composable-loader.js +5 -2
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/runtime/native-host.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +318 -158
- package/dist/ssg.js +2 -2
- package/dist/strip-literals.js +23 -8
- package/package.json +5 -5
- package/dist/chunk-kdk0jy1h.js +0 -17
- package/dist/chunk-xek78ez1.js +0 -2
- package/dist/chunk-y3cqh2jv.js +0 -12
|
@@ -290,8 +290,8 @@ export function queueClientBundleBuild(task) {
|
|
|
290
290
|
return result;
|
|
291
291
|
}
|
|
292
292
|
export async function bundleClientScript(code, filePath, options = {}) {
|
|
293
|
-
const projectRoot = options.projectRoot || process.cwd(), serverApi = (await loadStxConfig(projectRoot)).serverApi, minify = options.minify ?? !1, externalizeUserModules = options.externalizeUserModules ?? !0, cacheDir = options.cacheDir || stateDir(projectRoot, "bundle-cache"), hasher = new Bun.CryptoHasher("md5");
|
|
294
|
-
hasher.update(`${BUNDLE_CACHE_VERSION}\x00${cacheEngineFingerprint()}\x00${JSON.stringify(serverApi ?? !1)}\x00${externalizeUserModules ? "registry" : "inline"}\x00${code}\x00${filePath}`);
|
|
293
|
+
const projectRoot = options.projectRoot || process.cwd(), serverApi = (await loadStxConfig(projectRoot)).serverApi, minify = options.minify ?? !1, externalizeUserModules = options.externalizeUserModules ?? !0, expose = options.expose?.length ? [...new Set(options.expose)].sort() : void 0, cacheDir = options.cacheDir || stateDir(projectRoot, "bundle-cache"), hasher = new Bun.CryptoHasher("md5");
|
|
294
|
+
hasher.update(`${BUNDLE_CACHE_VERSION}\x00${cacheEngineFingerprint()}\x00${JSON.stringify(serverApi ?? !1)}\x00${externalizeUserModules ? "registry" : "inline"}\x00${expose ? expose.join(",") : "*"}\x00${code}\x00${filePath}`);
|
|
295
295
|
const hash = hasher.digest("hex").slice(0, 12), cachePath = path.join(cacheDir, `${hash}.js`), remembered = bundleMemo.get(cachePath);
|
|
296
296
|
if (remembered) {
|
|
297
297
|
if (depsUnchanged(remembered.files) && remembered.files.every((dep) => !isPrivateClientSource(dep.path, projectRoot, serverApi))) {
|
|
@@ -342,7 +342,7 @@ export async function bundleClientScript(code, filePath, options = {}) {
|
|
|
342
342
|
options.collectInputs.push(...(bundleMemo.get(cachePath)?.files ?? []).map((dep) => dep.path));
|
|
343
343
|
return shared;
|
|
344
344
|
}
|
|
345
|
-
const build = queueClientBundleBuild(() => buildBundle(code, filePath, { projectRoot, minify, cacheDir, hash, cachePath, depsPath, collectInputs: options.collectInputs, externalizeUserModules, serverApi }));
|
|
345
|
+
const build = queueClientBundleBuild(() => buildBundle(code, filePath, { projectRoot, minify, cacheDir, hash, cachePath, depsPath, collectInputs: options.collectInputs, externalizeUserModules, serverApi, expose }));
|
|
346
346
|
inFlightBundles.set(hash, build);
|
|
347
347
|
try {
|
|
348
348
|
return await build;
|
|
@@ -381,7 +381,7 @@ async function buildBundle(code, filePath, options) {
|
|
|
381
381
|
continue;
|
|
382
382
|
declNames.add(dm[2]);
|
|
383
383
|
}
|
|
384
|
-
const importRegex = /^[ \t]*import\
|
|
384
|
+
const importRegex = /^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;
|
|
385
385
|
while ((dm = importRegex.exec(strippedForScan)) !== null) {
|
|
386
386
|
if (!isTopLevel(dm.index))
|
|
387
387
|
continue;
|
|
@@ -451,6 +451,12 @@ export { ${[...declNames].join(", ")} }` : "";
|
|
|
451
451
|
if (/^[A-Za-z_$][\w$]*$/.test(name))
|
|
452
452
|
exposedBindings.push([name, name]);
|
|
453
453
|
}
|
|
454
|
+
if (options.expose) {
|
|
455
|
+
const wanted = new Set(options.expose);
|
|
456
|
+
for (let i = exposedBindings.length - 1;i >= 0; i--)
|
|
457
|
+
if (!wanted.has(exposedBindings[i][0]))
|
|
458
|
+
exposedBindings.splice(i, 1);
|
|
459
|
+
}
|
|
454
460
|
const registryReads = [];
|
|
455
461
|
bundled = rewriteRegistryImports(normalizeRegistrySpecifiers(bundled, registrySpecifiers), registryReads);
|
|
456
462
|
const externalImports = bundled.match(/^\s*import\s+[^;]+;?\s*$/gm) || [];
|
|
@@ -154,14 +154,17 @@ export async function getComposableScript(composablesDir, pageSource, extraSourc
|
|
|
154
154
|
for (const match of code.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))
|
|
155
155
|
if (match[1])
|
|
156
156
|
declaredNames.add(match[1]);
|
|
157
|
+
const ownExports = [];
|
|
157
158
|
try {
|
|
158
159
|
for (const name of transpiler.scan(code).exports)
|
|
159
|
-
if (name !== "default")
|
|
160
|
+
if (name !== "default") {
|
|
160
161
|
exportedNames.add(name);
|
|
162
|
+
ownExports.push(name);
|
|
163
|
+
}
|
|
161
164
|
} catch {}
|
|
162
165
|
code = transformStoreImports(code);
|
|
163
166
|
if (hasUserImports(code)) {
|
|
164
|
-
code = await bundleClientScript(code, file, { projectRoot: process.cwd(), externalizeUserModules: !1 });
|
|
167
|
+
code = await bundleClientScript(code, file, { projectRoot: process.cwd(), externalizeUserModules: !1, expose: ownExports });
|
|
165
168
|
code = stripStxRuntimeImports(code);
|
|
166
169
|
}
|
|
167
170
|
code = stripModuleImports(code);
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Br,$o,Eo}from"./chunk-2tn3dkcy.js";import"./chunk-ynvce0q6.js";import"./chunk-2n5pjbw9.js";import"./chunk-88px183j.js";import"./chunk-2jbyks2t.js";import"./chunk-pf0d8y9n.js";import"./chunk-
|
|
2
|
+
import{Br,$o,Eo}from"./chunk-2tn3dkcy.js";import"./chunk-ynvce0q6.js";import"./chunk-2n5pjbw9.js";import"./chunk-88px183j.js";import"./chunk-2jbyks2t.js";import"./chunk-pf0d8y9n.js";import"./chunk-0adxpd3e.js";import"./chunk-v83bpj84.js";import"./chunk-y36av1ac.js";import"./chunk-zydg3wgt.js";import"./chunk-wfqnxb38.js";import"./chunk-jz7pvh7b.js";import"./chunk-0trfbqa7.js";import{lu,bo,uu,du,wo,jr,vo,pu,xo,fu,gu,So,ko,Co}from"./chunk-rdp06c4s.js";import"./chunk-812sn7d5.js";import"./chunk-d2zw2e5m.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
package/dist/craft.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Br,$o,Eo}from"./chunk-2tn3dkcy.js";import"./chunk-ynvce0q6.js";import"./chunk-2n5pjbw9.js";import"./chunk-88px183j.js";import"./chunk-2jbyks2t.js";import"./chunk-pf0d8y9n.js";import"./chunk-
|
|
2
|
+
import{Br,$o,Eo}from"./chunk-2tn3dkcy.js";import"./chunk-ynvce0q6.js";import"./chunk-2n5pjbw9.js";import"./chunk-88px183j.js";import"./chunk-2jbyks2t.js";import"./chunk-pf0d8y9n.js";import"./chunk-0adxpd3e.js";import"./chunk-v83bpj84.js";import"./chunk-y36av1ac.js";import"./chunk-zydg3wgt.js";import"./chunk-wfqnxb38.js";import"./chunk-jz7pvh7b.js";import"./chunk-0trfbqa7.js";import{lu,bo,uu,du,wo,jr,vo,pu,xo,fu,gu,So,ko,Co}from"./chunk-rdp06c4s.js";import"./chunk-812sn7d5.js";import"./chunk-d2zw2e5m.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
@@ -217,7 +217,7 @@ export function createNativeHost(options) {
|
|
|
217
217
|
function setConnected(node, connected) {
|
|
218
218
|
if ("isConnected" in node)
|
|
219
219
|
node.isConnected = connected;
|
|
220
|
-
|
|
220
|
+
descriptorOf(node)?.children.forEach((child) => setConnected(child, connected));
|
|
221
221
|
}
|
|
222
222
|
function removeFromBindingParent(node) {
|
|
223
223
|
const owner = node.__stxOwner;
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Pn,Ie,Oo,Ma}from"./chunk-d3mpxr3s.js";import{An,Fr,Ia,Da,Oa}from"./chunk-tpvc8xnk.js";import{Po,Io,Do,Aa,Pa}from"./chunk-v3yqeh15.js";import{oe,ft,zr}from"./chunk-vg7wfkt5.js";import{jc,Bc,Fc,zc,ur,od}from"./chunk-e15a8txv.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-xk5972g0.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|