@stacksjs/stx 0.2.746 → 0.2.748
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-8zapr6yt.js → chunk-0k80h9hw.js} +1 -1
- package/dist/{chunk-6662t3bx.js → chunk-0xk2de0f.js} +1 -1
- package/dist/{chunk-mhn18833.js → chunk-1q726kxm.js} +1 -1
- package/dist/{chunk-zswnmzsd.js → chunk-1wqee608.js} +2 -2
- package/dist/{chunk-evphmzyh.js → chunk-1x2c002k.js} +1 -1
- package/dist/{chunk-f6gqf6v3.js → chunk-2n68bepn.js} +2 -2
- package/dist/chunk-2p91t0qh.js +2 -0
- package/dist/{chunk-evsbb3rc.js → chunk-2y669dqd.js} +1 -1
- package/dist/{chunk-n8txdhez.js → chunk-3eveprd2.js} +1 -1
- package/dist/{chunk-t7nw25st.js → chunk-3h238w91.js} +2 -2
- package/dist/{chunk-e7ke3rpn.js → chunk-4kfpm7k5.js} +1 -1
- package/dist/{chunk-a7py2qd2.js → chunk-54xfrj8m.js} +5 -5
- package/dist/{chunk-wds7pewp.js → chunk-5gndpknd.js} +1 -1
- package/dist/{chunk-y8ws4501.js → chunk-5p961dp2.js} +1 -1
- package/dist/{chunk-1wke0qfq.js → chunk-69y16gf3.js} +2 -2
- package/dist/{chunk-a46h84sz.js → chunk-738110r3.js} +1 -1
- package/dist/{chunk-wwd61ewe.js → chunk-7v4xxcc1.js} +1 -1
- package/dist/{chunk-57tpkrm5.js → chunk-7wj8cdzz.js} +1 -1
- package/dist/{chunk-hfryhf26.js → chunk-915p9d5k.js} +1 -1
- package/dist/chunk-9f3mf7qj.js +2 -0
- package/dist/chunk-aeqzgrq6.js +2 -0
- package/dist/{chunk-m7jq3907.js → chunk-anpw201a.js} +1 -1
- package/dist/chunk-ap79ecs3.js +3 -0
- package/dist/{chunk-f4y3h74q.js → chunk-aws32yq9.js} +1 -1
- package/dist/{chunk-a6p51fpw.js → chunk-be9sm3sf.js} +1 -1
- package/dist/{chunk-qx04cejf.js → chunk-c1k0f8nt.js} +1 -1
- package/dist/{chunk-8fcne6ar.js → chunk-c60wgqnf.js} +1 -1
- package/dist/{chunk-dz2hn14j.js → chunk-cwq30a2f.js} +1 -1
- package/dist/{chunk-19ayktjy.js → chunk-dngnd01p.js} +1 -1
- package/dist/{chunk-z7g92wak.js → chunk-dzfqbj6v.js} +1 -1
- package/dist/{chunk-bgt7bwm0.js → chunk-e14tnzt9.js} +1 -1
- package/dist/chunk-evfpmrvx.js +2 -0
- package/dist/{chunk-6mnebk49.js → chunk-fx12nez8.js} +1 -1
- package/dist/{chunk-9p99v0vr.js → chunk-h69yazjn.js} +2 -2
- package/dist/{chunk-xzsvx81w.js → chunk-h6zm6atc.js} +4 -4
- package/dist/{chunk-5spasxv7.js → chunk-hkn2swbq.js} +1 -1
- package/dist/{chunk-1v4w7ppq.js → chunk-hpre1xce.js} +1 -1
- package/dist/{chunk-hrd0qhj0.js → chunk-hz56qzj4.js} +1 -1
- package/dist/{chunk-yvbqhm47.js → chunk-jw7swqvf.js} +1 -1
- package/dist/{chunk-79ch0r9x.js → chunk-k0kt643q.js} +1 -1
- package/dist/{chunk-4rr35v4y.js → chunk-k0wqy6jk.js} +4 -4
- package/dist/{chunk-ed67z92f.js → chunk-kzpbd65z.js} +1 -1
- package/dist/{chunk-kkmayabs.js → chunk-mk696gth.js} +5 -5
- package/dist/chunk-njx1b3cd.js +2 -0
- package/dist/{chunk-rfa9rz3g.js → chunk-p8zsnhhe.js} +6 -6
- package/dist/{chunk-s8gc1h8e.js → chunk-pz52sq7x.js} +1 -1
- package/dist/{chunk-2g9eaq6p.js → chunk-rsaq309e.js} +1 -1
- package/dist/{chunk-xc907jck.js → chunk-s6twntcw.js} +1 -1
- package/dist/{chunk-ygs7ersb.js → chunk-s7ffpaf9.js} +1 -1
- package/dist/{chunk-0nhb2nwp.js → chunk-skm53nnd.js} +1 -1
- package/dist/chunk-snrqq3wh.js +2 -0
- package/dist/{chunk-5nqhfdj6.js → chunk-t276cc57.js} +1 -1
- package/dist/{chunk-149yxrcj.js → chunk-tftna6zb.js} +29 -29
- package/dist/chunk-tqpkpyqf.js +2 -0
- package/dist/{chunk-c8v5c5mz.js → chunk-twc23s14.js} +1 -1
- package/dist/{chunk-ykjx8zf0.js → chunk-txbre9zy.js} +1 -1
- package/dist/{chunk-xgfetnnc.js → chunk-vd84rnx9.js} +1 -1
- package/dist/chunk-vqr0afr9.js +2 -0
- package/dist/{chunk-eqbg3aj0.js → chunk-w9564he2.js} +1 -1
- package/dist/{chunk-1xen7nkk.js → chunk-x0sxzebr.js} +1 -1
- package/dist/chunk-xzszbafv.js +2 -0
- package/dist/chunk-ygb3n26r.js +2 -0
- package/dist/{chunk-dxgvah9p.js → chunk-z0zd1nxd.js} +3 -3
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/html-to-ir.d.ts +2 -0
- package/dist/native/compiler/html-to-ir.js +3 -1
- package/dist/native/compiler/icons.d.ts +4 -2
- package/dist/native/compiler/icons.js +9 -9
- package/dist/native/compiler/layout-chrome.d.ts +1 -1
- package/dist/native/compiler/layout-chrome.js +6 -4
- package/dist/native/compiler/render-screen.js +4 -1
- package/dist/native/runtime/native-host.js +11 -2
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-7vy02dt0.js +0 -2
- package/dist/chunk-91pa4mt8.js +0 -2
- package/dist/chunk-gmp889v9.js +0 -3
- package/dist/chunk-h3gk6j59.js +0 -2
- package/dist/chunk-hqfd6mmq.js +0 -2
- package/dist/chunk-j5dzthxj.js +0 -2
- package/dist/chunk-m2b0nwgp.js +0 -2
- package/dist/chunk-q1wk9j3s.js +0 -2
- package/dist/chunk-t0myqe0n.js +0 -2
- package/dist/chunk-vtjtz685.js +0 -2
- package/dist/chunk-yjdp76hr.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Im,Om}from"./chunk-4kfpm7k5.js";import"./chunk-kzpbd65z.js";import"./chunk-dngnd01p.js";import"./chunk-1xjv71dw.js";import"./chunk-2n68bepn.js";import"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import"./chunk-3h238w91.js";import"./chunk-1q726kxm.js";import"./chunk-6ew10ptg.js";import"./chunk-5f6x6fyp.js";import"./chunk-dxsdr77m.js";import"./chunk-4s1k8k2a.js";import"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{Om as clearStoreCache,Im as getStoreScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ve,Ns,Jf,xh,Yf,Sh,Nt,p,V,Z,yn,xe,Zf,ai,Qf,kh,k,eg,_h,E,Ch}from"./chunk-
|
|
2
|
+
import{ve,Ns,Jf,xh,Yf,Sh,Nt,p,V,Z,yn,xe,Zf,ai,Qf,kh,k,eg,_h,E,Ch}from"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{eg as applyFilters,Sh as clearCustomFilters,Zf as clientLoopScopes,Ns as defaultFilters,yn as escapeAttributeValue,p as escapeHtml,V as escapeHtmlValue,Z as escapeInterpolatedHtmlValue,E as evaluateExpression,ve as findMustacheEnd,Yf as getAllFilters,Qf as interpolateScriptAttributes,ai as interpolateScriptExpressions,kh as interpolateScriptsInTemplate,k as processExpressions,Jf as registerFilter,xh as registerFilters,Nt as replaceInterpolations,_h as resetRejectedExpressionWarnings,Ch as unescapeHtml,xe as usesSignalsInScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nf,rf,Te,sf,Fa,Yt,Zt,Gm,za,Qt,Jn,of,af,cf,ho,en,lf,tn,uf}from"./chunk-
|
|
2
|
+
import{nf,rf,Te,sf,Fa,Yt,Zt,Gm,za,Qt,Jn,of,af,cf,ho,en,lf,tn,uf}from"./chunk-kzpbd65z.js";import"./chunk-dngnd01p.js";import"./chunk-1xjv71dw.js";import"./chunk-3h238w91.js";import"./chunk-1q726kxm.js";import"./chunk-6ew10ptg.js";import"./chunk-5f6x6fyp.js";import"./chunk-dxsdr77m.js";import"./chunk-4s1k8k2a.js";import"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{Jn as MODULE_SPECIFIER_PREFIX,nf as bundleCacheDir,rf as bundleCacheEntryLimit,tn as bundleClientScript,Zt as clearBundleFailures,Te as clientBundleDependencies,Yt as getBundleFailures,Qt as hasUserImports,en as moduleSubstitutionKey,af as normalizeRegistrySpecifiers,lf as queueClientBundleBuild,Fa as recordBundleFailure,of as registryIdForPath,za as resolveBundlerFallback,cf as rewriteRegistryImports,Gm as setBundlerFallbackMode,sf as shouldLogBundlerDiagnostics,uf as tempBuildName,ho as withModuleSubstitutes};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yf,ns}from"./chunk-
|
|
2
|
+
import{yf,ns}from"./chunk-aws32yq9.js";import"./chunk-ap79ecs3.js";import"./chunk-bj0z4gve.js";import"./chunk-8f14cgm8.js";import{br}from"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import{nt}from"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{nt as freeIdentifiers,ns as processComponents,yf as processESImports,br as rendersAsElement};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ll,ul}from"./chunk-mk696gth.js";import"./chunk-5gndpknd.js";import"./chunk-fx12nez8.js";import"./chunk-kp2rkczm.js";import"./chunk-crk5dzxb.js";import"./chunk-7v4xxcc1.js";import"./chunk-nybty1zx.js";import"./chunk-2y669dqd.js";import"./chunk-z0zd1nxd.js";import"./chunk-888xnaex.js";import"./chunk-w1sdxmx3.js";import"./chunk-t276cc57.js";import"./chunk-amyxgejb.js";import"./chunk-rsaq309e.js";import"./chunk-w34w1hrg.js";import"./chunk-ttsrhr95.js";import"./chunk-md36aysy.js";import"./chunk-s7ffpaf9.js";import"./chunk-vyv76w55.js";import"./chunk-skm53nnd.js";import"./chunk-8fazd6fr.js";import"./chunk-pd89jnqk.js";import"./chunk-fsz9k5k0.js";import"./chunk-72hfqwvk.js";import"./chunk-78x8qfvt.js";import"./chunk-y3w2rc1y.js";import"./chunk-4kfpm7k5.js";import"./chunk-1x2c002k.js";import"./chunk-j6m7jwpv.js";import"./chunk-1wqee608.js";import"./chunk-e43cxztn.js";import"./chunk-vtmd3ssd.js";import{Jt}from"./chunk-e14tnzt9.js";import"./chunk-kzpbd65z.js";import"./chunk-dngnd01p.js";import"./chunk-1xjv71dw.js";import{Re,i}from"./chunk-54xfrj8m.js";import"./chunk-69y16gf3.js";import"./chunk-91pycazt.js";import"./chunk-cwq30a2f.js";import"./chunk-k0wqy6jk.js";import"./chunk-aws32yq9.js";import"./chunk-ap79ecs3.js";import"./chunk-bj0z4gve.js";import"./chunk-2n68bepn.js";import{be}from"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import{ir,ar}from"./chunk-0k80h9hw.js";import{us,j,a}from"./chunk-3h238w91.js";import"./chunk-1q726kxm.js";import"./chunk-6ew10ptg.js";import"./chunk-5f6x6fyp.js";import"./chunk-dxsdr77m.js";import"./chunk-4s1k8k2a.js";import{m,Me}from"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";import"./chunk-9zrbhs3p.js";import"./chunk-x0c8xq0s.js";export{us as buildWebComponents,ar as cacheTemplate,ir as checkCache,Jt as classifyAllScripts,ll as createMiddleware,ul as createRoute,j as defaultConfig,m as extractVariables,be as injectRouterScript,a as loadStxConfig,Me as processClientScript,i as processDirectives,Re as readMarkdownFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cl,Vg,El,Tl,Ug,Wg}from"./chunk-
|
|
2
|
+
import{Cl,Vg,El,Tl,Ug,Wg}from"./chunk-rsaq309e.js";import"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{Wg as applySlots,Ug as extractSlotContent,Vg as parseSlotElement,Cl as parseSlots,Tl as processSlots,El as renderSlot};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bn,ci}from"./chunk-
|
|
2
|
+
import{bn,ci}from"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";export{ci as generateRuntimeConfigTypes,bn as prepareRuntimeConfig};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ua,da,pa,fa,qm}from"./chunk-jw7swqvf.js";import"./chunk-amsbfc3y.js";import"./chunk-1wqee608.js";import"./chunk-e43cxztn.js";import"./chunk-54xfrj8m.js";import"./chunk-69y16gf3.js";import"./chunk-91pycazt.js";import"./chunk-cwq30a2f.js";import"./chunk-k0wqy6jk.js";import"./chunk-aws32yq9.js";import"./chunk-ap79ecs3.js";import"./chunk-bj0z4gve.js";import"./chunk-2n68bepn.js";import"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import"./chunk-0k80h9hw.js";import"./chunk-3h238w91.js";import"./chunk-1q726kxm.js";import"./chunk-6ew10ptg.js";import"./chunk-5f6x6fyp.js";import"./chunk-dxsdr77m.js";import"./chunk-4s1k8k2a.js";import"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{ua as buildNative,qm as default,da as findCraftBinary,fa as getAvailableFormats,pa as getAvailableTargets};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{oo,Nm,Dm}from"./chunk-1x2c002k.js";import"./chunk-kzpbd65z.js";import"./chunk-dngnd01p.js";import"./chunk-1xjv71dw.js";import"./chunk-2n68bepn.js";import"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import"./chunk-3h238w91.js";import"./chunk-1q726kxm.js";import"./chunk-6ew10ptg.js";import"./chunk-5f6x6fyp.js";import"./chunk-dxsdr77m.js";import"./chunk-4s1k8k2a.js";import"./chunk-p8zsnhhe.js";import"./chunk-3eveprd2.js";import"./chunk-nzwcbt98.js";import"./chunk-wpwh529h.js";import"./chunk-zn3c0ew5.js";import"./chunk-27agaezn.js";export{Dm as clearComposableCache,Nm as getComposableScript,oo as listComposableModules};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xn}from"./chunk-wpwh529h.js";import{W,S,Pt,It,vr,m,jc,ii,V,E}from"./chunk-
|
|
3
|
-
`}import P from"path";var Y="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Q(){let t=K()?"dev":"prod",r=v[t];if(r!==null)return r;try{let e=import.meta.require("./chunk-vnrsm0kj.js"),s=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${s()}</script>`}catch{v[t]=""}return v[t]}async function Gi(t,r){if(r===!1)return null;if(r&&typeof r==="string"){let s=P.resolve(t,r);if(await Bun.file(s).exists())return s;return null}let e=P.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function no(t,r){try{let e=await Bun.file(t).text(),s=e,a=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(a)s=a[1].trim();let i=Jt(e),o=[...i.client.map((g)=>g.fullTag),...i.signals.map((g)=>g.fullTag)],c=[],l=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=l.exec(e))!==null)c.push(u[0]);let f=s;for(let g of i.server)f=f.replace(g.fullTag,"");for(let g of i.client)f=f.replace(g.fullTag,"");f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let p="<!--__STX_PAGE_SLOT__-->";if(f=f.replace(/<slot\s*\/>/gi,p).replace(/<slot\s*>\s*<\/slot>/gi,p),!f.includes(p))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:h,extractVariables:y,defaultConfig:R,loadStxConfig:b}=await import("./chunk-
|
|
2
|
+
import{xn}from"./chunk-wpwh529h.js";import{W,S,Pt,It,vr,m,jc,ii,V,E}from"./chunk-p8zsnhhe.js";import{Jt}from"./chunk-e14tnzt9.js";import{n}from"./chunk-ap79ecs3.js";import{K}from"./chunk-byaasw3f.js";var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function U(t){let r=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,s;while((s=e.exec(t))!==null)r.push({start:s.index,end:s.index+s[0].length});return r}function I(t,r){return r.some((e)=>t>=e.start&&t<e.end)}function G(t){let r=(t||"").trim();if(!r)return null;if(/[\s>+~,:]/.test(r))return null;let e={},s=r,a=s.match(/^[a-z][\w-]*/i);if(a)e.tag=a[0].toLowerCase(),s=s.slice(a[0].length);while(s.length>0){let i=s.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(i){if(e.attr=i[1],i[3]!==void 0&&i[3]!=="")e.attrValue=i[3];s=s.slice(i[0].length);continue}let o=s.match(/^#([\w-]+)/);if(o){e.id=o[1],s=s.slice(o[0].length);continue}let c=s.match(/^\.([\w-]+)/);if(c){e.className=c[1],s=s.slice(c[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function X(t,r){if(r.attr){if(!(r.attrValue===void 0?new RegExp(`\\b${r.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${r.attr}\\s*=\\s*(["'])\\s*${r.attrValue}\\s*\\1`,"i")).test(t))return!1}if(r.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${r.id}\\s*\\1`,"i").test(t))return!1}if(r.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(r.className))return!1}return!0}function N(t,r="main"){let e=G(r);if(!e)return null;let s=/<([a-z][\w-]*)\b([^>]*)>/gi,a=U(t),i;while((i=s.exec(t))!==null){if(I(i.index,a))continue;let o=i[1].toLowerCase(),c=i[2]||"";if(c.trimEnd().endsWith("/")||z.has(o))continue;if(e.tag&&e.tag!==o)continue;if(!X(c,e))continue;let l=i[0],u=i.index+l.length,f=new RegExp(`<(/?)${o}\\b([^>]*)>`,"gi");f.lastIndex=u;let p=1,h;while((h=f.exec(t))!==null){if(I(h.index,a))continue;let y=h[1]==="/";if(!y&&(h[2]||"").trimEnd().endsWith("/"))continue;if(p+=y?-1:1,p===0)return{openTag:l,openIndex:i.index,start:u,end:h.index,tagName:o}}return null}return null}var dt="private, no-store";function Tn(t){return t.replace(/&#(\d+);/g,(r,e)=>D(Number(e),r)).replace(/&#x([0-9a-f]+);/gi,(r,e)=>D(Number.parseInt(e,16),r)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function D(t,r){if(!Number.isInteger(t)||t<0||t>1114111)return r;try{return String.fromCodePoint(t)}catch{return r}}function _e(t){return t.headers.get("X-STX-Router")==="true"}function J(t,r){if(!t)return r;return t.split(",").some((s)=>s.trim().toLowerCase()===r.toLowerCase())?t:`${t}, ${r}`}function M(t){return{Vary:J(t,"X-STX-Router")}}function k(t){return t.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function $n(t){let r=/<head\b[^>]*>([\s\S]*?)<\/head\s*>/i.exec(t)?.[1]??"",e=/<(meta|link)\b(?:[^>"']|"[^"]*"|'[^']*')*>|<title\b[^>]*>[\s\S]*?<\/title\s*>/giy,s=S(r,(i,o)=>(e.lastIndex=o,e.exec(i)?e.lastIndex:-1)),a=[];for(let{token:i}of s){if(/^<title\b/i.test(i)){a.push(`<title>${k(i.replace(/^<title\b[^>]*>|<\/title\s*>$/gi,""))}</title>`);continue}let o=Object.create(null),c=i.replace(/^<\w+\b|>$/g,"");for(let l of c.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let u=l[1].toLowerCase();if(!(u in o))o[u]=l[2]??l[3]??l[4]??""}if(/^<meta\b/i.test(i)){let l=o.property?"property":"name",u=Tn(o[l]??"").toLowerCase();if(u==="description"||/^(?:og|twitter):[\w:]+$/.test(u))a.push(`<meta ${l}="${n(u)}" content="${k(o.content??"")}">`)}else{let l=Tn(o.rel??"").toLowerCase();if(l==="canonical"||l==="alternate"&&o.hreflang)a.push(`<link rel="${l}" href="${k(o.href??"")}"${l==="alternate"?` hreflang="${k(o.hreflang)}"`:""}>`)}}return`<template data-stx-page-head="1">${a.join("")}</template>
|
|
3
|
+
`}import P from"path";var Y="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Q(){let t=K()?"dev":"prod",r=v[t];if(r!==null)return r;try{let e=import.meta.require("./chunk-vnrsm0kj.js"),s=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${s()}</script>`}catch{v[t]=""}return v[t]}async function Gi(t,r){if(r===!1)return null;if(r&&typeof r==="string"){let s=P.resolve(t,r);if(await Bun.file(s).exists())return s;return null}let e=P.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function no(t,r){try{let e=await Bun.file(t).text(),s=e,a=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(a)s=a[1].trim();let i=Jt(e),o=[...i.client.map((g)=>g.fullTag),...i.signals.map((g)=>g.fullTag)],c=[],l=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=l.exec(e))!==null)c.push(u[0]);let f=s;for(let g of i.server)f=f.replace(g.fullTag,"");for(let g of i.client)f=f.replace(g.fullTag,"");f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let p="<!--__STX_PAGE_SLOT__-->";if(f=f.replace(/<slot\s*\/>/gi,p).replace(/<slot\s*>\s*<\/slot>/gi,p),!f.includes(p))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:h,extractVariables:y,defaultConfig:R,loadStxConfig:b}=await import("./chunk-vqr0afr9.js"),A=await b(),d={__filename:t,__dirname:P.dirname(t)};for(let g of o){let C=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!g.includes("client")&&!g.includes('type="module"'))await y(C[1],d,t)}let x=await h(f,d,t,{...R,...A,...r},new Set),w=x.indexOf(p);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:x.substring(0,w),afterSlot:x.substring(w+p.length),filePath:t,shellScripts:o,shellStyles:c}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Br(t,r,e){let s,a="",i=r.match(Z);if(i){r=r.replace(i[0],"");try{let f=Buffer.from(i[1],"base64").toString("utf8"),p=f.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(p)s=p[1].trim();a=f.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let o=e||s||"stx App",c=Q(),l="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -28,5 +28,5 @@ ${c}
|
|
|
28
28
|
`));if(i.length>0)d.push(i.filter((x)=>!u.has(x)).join(`
|
|
29
29
|
`));if(R.length>0)d.push(R.filter((x)=>!u.has(x)).join(`
|
|
30
30
|
`));return d.push(y),d.join(`
|
|
31
|
-
`)}import O from"fs";import H from"path";function Ji(t,r,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:r,outputDir:e}}function Yi(t,r){let e=H.join(r,"manifest.json");O.writeFileSync(e,JSON.stringify(t,null,2))}function Zi(t){let r=H.join(t,"manifest.json");if(!O.existsSync(r))return null;try{let e=O.readFileSync(r,"utf-8"),s=JSON.parse(e);if(s.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${s.version}`),null;return s}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function T(t,r,e={}){let s=`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(e.maxAge!==void 0)s+=`; Max-Age=${e.maxAge}`;if(e.expires)s+=`; Expires=${e.expires.toUTCString()}`;if(e.path)s+=`; Path=${e.path}`;if(e.domain)s+=`; Domain=${e.domain}`;if(e.secure)s+="; Secure";if(e.httpOnly)s+="; HttpOnly";if(e.sameSite)s+=`; SameSite=${e.sameSite}`;return s}async function et(t){let r=t.headers.get("content-type")||"",e={},s=(a,i)=>{let o=e[a];if(o===void 0)e[a]=i;else if(Array.isArray(o))o.push(i);else e[a]=[o,i]};if(r.includes("multipart/form-data")){let a=await t.formData();for(let[i,o]of a.entries())if(typeof o==="string")s(i,o);return e}if(r.includes("application/x-www-form-urlencoded")){for(let[a,i]of new URLSearchParams(await t.text()).entries())s(a,i);return e}return e}function ro(t){if(!t)return!1;let r=t.toUpperCase();return r!=="GET"&&r!=="HEAD"}async function B(t,r={}){let e=r.request,s=r.method??e?.method;if(!e||!ro(s))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let a={};try{a=await et(e)}catch{}let i=await t.action({request:e,form:a,params:r.params??{},query:t.query??{},cookies:r.cookies??{}});if(i&&typeof i==="object"){let o=i,c=nt(o.cookies),l=o.redirect;if(typeof l==="string"&&l)return{redirect:l,ran:!0,...c.length>0?{cookies:c}:{}};let{cookies:u,redirect:f,...p}=o;if(Object.assign(t,p),c.length>0)return{ran:!0,cookies:c}}return{ran:!0}}function nt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let r=[];for(let[e,s]of Object.entries(t)){if(!e)continue;if(typeof s==="string"){r.push(T(e,s));continue}if(s&&typeof s==="object"){let a=s;if(typeof a.value!=="string")continue;r.push(T(e,a.value,a))}}return r}function Qi(t,r=[],e){let s=new Headers({Location:t,"Cache-Control":"no-store"});for(let a of r)s.append("Set-Cookie",a);for(let[a,i]of Object.entries(e??{}))if(a.toLowerCase()!=="location")s.set(a,i);return new Response(null,{status:303,headers:s})}async function Rn(t,r={}){let{html:e,context:s,redirect:a,cookies:i}=await rt(t,r),o=Pt(s),c=It(s);if(a)return{html:e,redirect:a,cookies:i,status:o,headers:c};let{extractStreamBoundaries:l}=await import("./chunk-
|
|
31
|
+
`)}import O from"fs";import H from"path";function Ji(t,r,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:r,outputDir:e}}function Yi(t,r){let e=H.join(r,"manifest.json");O.writeFileSync(e,JSON.stringify(t,null,2))}function Zi(t){let r=H.join(t,"manifest.json");if(!O.existsSync(r))return null;try{let e=O.readFileSync(r,"utf-8"),s=JSON.parse(e);if(s.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${s.version}`),null;return s}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function T(t,r,e={}){let s=`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(e.maxAge!==void 0)s+=`; Max-Age=${e.maxAge}`;if(e.expires)s+=`; Expires=${e.expires.toUTCString()}`;if(e.path)s+=`; Path=${e.path}`;if(e.domain)s+=`; Domain=${e.domain}`;if(e.secure)s+="; Secure";if(e.httpOnly)s+="; HttpOnly";if(e.sameSite)s+=`; SameSite=${e.sameSite}`;return s}async function et(t){let r=t.headers.get("content-type")||"",e={},s=(a,i)=>{let o=e[a];if(o===void 0)e[a]=i;else if(Array.isArray(o))o.push(i);else e[a]=[o,i]};if(r.includes("multipart/form-data")){let a=await t.formData();for(let[i,o]of a.entries())if(typeof o==="string")s(i,o);return e}if(r.includes("application/x-www-form-urlencoded")){for(let[a,i]of new URLSearchParams(await t.text()).entries())s(a,i);return e}return e}function ro(t){if(!t)return!1;let r=t.toUpperCase();return r!=="GET"&&r!=="HEAD"}async function B(t,r={}){let e=r.request,s=r.method??e?.method;if(!e||!ro(s))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let a={};try{a=await et(e)}catch{}let i=await t.action({request:e,form:a,params:r.params??{},query:t.query??{},cookies:r.cookies??{}});if(i&&typeof i==="object"){let o=i,c=nt(o.cookies),l=o.redirect;if(typeof l==="string"&&l)return{redirect:l,ran:!0,...c.length>0?{cookies:c}:{}};let{cookies:u,redirect:f,...p}=o;if(Object.assign(t,p),c.length>0)return{ran:!0,cookies:c}}return{ran:!0}}function nt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let r=[];for(let[e,s]of Object.entries(t)){if(!e)continue;if(typeof s==="string"){r.push(T(e,s));continue}if(s&&typeof s==="object"){let a=s;if(typeof a.value!=="string")continue;r.push(T(e,a.value,a))}}return r}function Qi(t,r=[],e){let s=new Headers({Location:t,"Cache-Control":"no-store"});for(let a of r)s.append("Set-Cookie",a);for(let[a,i]of Object.entries(e??{}))if(a.toLowerCase()!=="location")s.set(a,i);return new Response(null,{status:303,headers:s})}async function Rn(t,r={}){let{html:e,context:s,redirect:a,cookies:i}=await rt(t,r),o=Pt(s),c=It(s);if(a)return{html:e,redirect:a,cookies:i,status:o,headers:c};let{extractStreamBoundaries:l}=await import("./chunk-k0kt643q.js"),u=l(s),f=t.streamTemplates;if(f&&Object.keys(f).length>0){let{processDirectives:p}=await import("./chunk-njx1b3cd.js"),{defaultConfig:h}=await import("./chunk-dzfqbj6v.js"),y=s.streamBoundaries||{},R={...h,autoShell:!1},b=Object.keys(f).map((d)=>({id:d,render:async()=>{let x=typeof y[d]==="function"?await y[d]():void 0;return p(f[d],{...s,$boundary:x},t.sourceFile,R,new Set)}})),A=new Set(b.map((d)=>d.id));u=[...(u||[]).filter((d)=>!A.has(d.id)),...b]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:i,status:o,headers:c}}async function rt(t,r){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...r};if(!t.hasServerScripts&&!ii(t.html))return{html:t.html,context:e};for(let o of t.serverScriptContent)try{await m(o,e,t.sourceFile)}catch(c){if(r.__stx_strict_hydration)throw c;console.warn(`[stx] Server script error in ${t.sourceFile}:`,c)}let s=await B(e,{request:r.request,method:r.method,params:r.params??{},cookies:r.cookies??{}}),a=(o)=>{let c=o.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),l=vr(e);if(!l)return c;let u=c.indexOf("</head>");return u<0?l+c:c.slice(0,u)+l+c.slice(u)};if(s.redirect)return{html:t.html,context:e,redirect:s.redirect,cookies:s.cookies};if(!ii(t.html))return{html:a(t.html),context:e,cookies:s.cookies};let i=new Map;for(let[o,c]of Object.entries(t.placeholders))if(c.expression)try{let l=E(c.expression,e);if(c.type==="raw")i.set(o,l!==void 0&&l!==null?String(l):"");else i.set(o,l!==void 0&&l!==null?V(String(l)):"")}catch(l){if(r.__stx_strict_hydration)throw l;i.set(o,"")}return{html:a(jc(t.html,i)),context:e,cookies:s.cookies}}
|
|
32
32
|
export{dt,Tn,_e,M,$n,Gi,no,Br,Ue,Xi,Ce,Ji,Yi,Zi,ro,Qi,Rn};
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import"./chunk-wpwh529h.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import{Pe,oe}from"./chunk-
|
|
3
|
+
import"./chunk-wpwh529h.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import{Pe,oe}from"./chunk-p8zsnhhe.js";import"./chunk-nzwcbt98.js";import"./chunk-3eveprd2.js";import"./chunk-6ew10ptg.js";import"./chunk-4s1k8k2a.js";import"./chunk-3h238w91.js";import"./chunk-dxsdr77m.js";import"./chunk-5f6x6fyp.js";import"./chunk-54xfrj8m.js";import"./chunk-0k80h9hw.js";import"./chunk-69y16gf3.js";import"./chunk-aws32yq9.js";import"./chunk-k0wqy6jk.js";import"./chunk-s7ffpaf9.js";import"./chunk-kp2rkczm.js";import"./chunk-e43cxztn.js";import"./chunk-w34w1hrg.js";import"./chunk-vyv76w55.js";import"./chunk-w1sdxmx3.js";import"./chunk-crk5dzxb.js";import"./chunk-z0zd1nxd.js";import"./chunk-78x8qfvt.js";import"./chunk-t276cc57.js";import"./chunk-j6m7jwpv.js";import"./chunk-888xnaex.js";import"./chunk-8fazd6fr.js";import"./chunk-fx12nez8.js";import"./chunk-nybty1zx.js";import"./chunk-2n68bepn.js";import"./chunk-cwq30a2f.js";import"./chunk-91pycazt.js";import"./chunk-5gndpknd.js";import"./chunk-y3w2rc1y.js";import"./chunk-dngnd01p.js";import"./chunk-2y669dqd.js";import"./chunk-skm53nnd.js";import"./chunk-72hfqwvk.js";import"./chunk-pd89jnqk.js";import"./chunk-fsz9k5k0.js";import"./chunk-1xjv71dw.js";import{Yt,Zt}from"./chunk-kzpbd65z.js";import"./chunk-1x2c002k.js";import"./chunk-7v4xxcc1.js";import"./chunk-ttsrhr95.js";import"./chunk-md36aysy.js";import"./chunk-9zrbhs3p.js";import"./chunk-x0c8xq0s.js";import"./chunk-amyxgejb.js";import"./chunk-4kfpm7k5.js";import"./chunk-rsaq309e.js";import{Di,Mi,Li,ji,Gs,Bi,Fi,zi,Xs,Js,Or,Nr,Dr}from"./chunk-mk696gth.js";import"./chunk-1wqee608.js";import"./chunk-vtmd3ssd.js";import"./chunk-e14tnzt9.js";import"./chunk-ap79ecs3.js";import"./chunk-bj0z4gve.js";import"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import{nc}from"./chunk-1q726kxm.js";import{g}from"./chunk-0dve54ne.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
|
|
4
4
|
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await Nr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Or(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await ji(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:r}=await import("./chunk-3wkgd883.js");if(t==="list"){console.log(`
|
|
5
5
|
\uD83D\uDCDA Fetching available icon collections...
|
|
6
6
|
`);let s=await o(),c=Object.entries(s).sort((i,l)=>l[1].total-i[1].total);console.log(`Available collections:
|
|
7
7
|
`);for(let[i,l]of c){let d=l;console.log(` ${i.padEnd(30)} ${d.name} (${d.total} icons)`)}console.log(`
|
|
8
8
|
Total: ${c.length} collections`)}else if(t.startsWith("generate")){let s=t==="generate"?"":t.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!s)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),n.exit(1);let c=e.output||f.join(n.cwd(),"packages/collections"),i=e.icons?e.icons.split(",").map((l)=>l.trim()):void 0;await r(s,c,i),console.log(`
|
|
9
9
|
\u2713 Package generated successfully!`),console.log(`
|
|
10
|
-
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-wy8er1ps.js"),{loadConfig:s}=await import("./chunk-
|
|
10
|
+
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-wy8er1ps.js"),{loadConfig:s}=await import("./chunk-dzfqbj6v.js");console.log(`
|
|
11
11
|
\uD83D\uDD0D Running PWA audit...
|
|
12
12
|
`);let c=await s(),i=e.output||"dist",l=o(c,i);if(console.log(r(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let r=E(e.port);if(!r.isValid)F(r);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let r=I(e.timeout);if(!r.isValid)F(r)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await Dr(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let r=await import("fs");if(r.existsSync(t)&&r.statSync(t).isDirectory()){if(!await Dr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let r=await oe.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((p)=>/\[.+\]/.test(f.basename(p)));for(let p of u)if(!s.includes(p))s.push(p)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await Nr(s,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}else{if(!O(t)){let s=A(t);if(!s.isValid)F(s)}if(!await Or(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}}catch(o){console.error("Error starting dev server:",o),n.exit(1)}}),y.command("a11y [target]","Scan .stx files for accessibility issues (directory, file, or glob)").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example('stx a11y "resources/**/*.stx"').example("stx a11y resources/emails/welcome.stx").example("stx a11y --json --output a11y-report.json").action(async(t=".",e)=>{try{console.log(`Scanning ${t} for accessibility issues...`);let o=e.ignore?e.ignore.split(",").map((l)=>l.trim()):[],{results:r,scannedFiles:s}=await nc(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
|
|
13
13
|
No .stx files matched ${t}
|
|
@@ -69,7 +69,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
|
|
|
69
69
|
File not found: ${t}`),n.exit(1);if(!t.endsWith(".stx"))console.error(`
|
|
70
70
|
File must have .stx extension: ${t}`),n.exit(1)}let r=f.resolve(e.pages),s=f.resolve(e.out);if(!t&&!S.existsSync(r))console.error(`
|
|
71
71
|
Pages directory not found: ${r}`),console.log(`
|
|
72
|
-
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-
|
|
72
|
+
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-0xk2de0f.js");Zt();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
|
|
73
73
|
Build complete! (SSR)
|
|
74
74
|
`),console.log(` Pages compiled: ${i.ssr.pageCount}`),console.log(` Output: ${i.ssr.outputDir}`),console.log(` Duration: ${l}s
|
|
75
75
|
`);else if(i.ssg){if(console.log(`
|
|
@@ -84,7 +84,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
|
|
|
84
84
|
Build completed with ${i.ssg.failedCount} error(s). Fix the issues above and try again.
|
|
85
85
|
`),n.exit(1);console.log(" To preview locally:"),console.log(` cd ${e.out||"dist"} && npx serve
|
|
86
86
|
`)}}catch(o){console.error(`
|
|
87
|
-
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-
|
|
87
|
+
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-aeqzgrq6.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
|
|
88
88
|
Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:r,DeployError:s}=await import("./chunk-w07kke19.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Pe}\x1B[0m`),e.init){console.log(`
|
|
89
89
|
\uD83D\uDCDD Initializing Netlify configuration...
|
|
90
90
|
`);let i=await r({directory:t||n.cwd(),siteId:e.siteId});if(console.log(`\u2713 Created ${i.configPath}`),i.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
|
|
@@ -124,7 +124,7 @@ To view it in the development server:`),console.log(` stx dev ${t}
|
|
|
124
124
|
\uD83D\uDCDD ${f.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${f.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${f.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${f.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
|
|
125
125
|
${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.check&&!e.diff)console.log(`\u2728 Formatted ${l} files successfully`)}catch(o){console.error("Error formatting files:",o),n.exit(1)}}),y.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(t,e)=>{try{if(e.clear){oe.clear(),console.log("\u2705 Performance statistics cleared");return}let o=oe.getStats();if(Object.keys(o).length===0){if(e.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(e.json)console.log(JSON.stringify(o,null,2));else{console.log(`
|
|
126
126
|
\uD83D\uDCCA STX Performance Statistics
|
|
127
|
-
`);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-
|
|
127
|
+
`);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-evfpmrvx.js"),{resolveStxTargets:s}=await import("./chunk-8bw9yd5m.js"),c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx"],l=await s(i);if(l.length===0){console.log(`
|
|
128
128
|
No .stx files matched ${i.join(", ")}
|
|
129
129
|
`);return}let d=Di(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await r(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
|
|
130
130
|
Type-check did not run.
|
|
@@ -160,11 +160,11 @@ Press Ctrl+C to stop watching...
|
|
|
160
160
|
\uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((p)=>s[p.type]>=c).length;if(u>0)console.log(` ${f.relative(n.cwd(),a.file)} (${u} issues)`)});if(e.saveReport){let a={summary:l,results:d,generatedAt:new Date().toISOString(),commandOptions:e};await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`
|
|
161
161
|
\uD83D\uDCCB Analysis report saved to: ${e.saveReport}`)}console.log(`
|
|
162
162
|
\u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-jka3p99a.js"),r=t||"dist";try{let s=await o(r,e.out,{width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),waitMs:Number.parseInt(e.wait,10),timeoutMs:Number.parseInt(e.timeout,10),fullPage:Boolean(e.fullPage),waitSelector:e.waitSelector,format:e.format,backend:e.backend});for(let c of s)console.log(`\uD83D\uDCF8 ${c.output} (${(c.bytes/1024).toFixed(0)} KB)`);console.log(`
|
|
163
|
-
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-
|
|
163
|
+
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-2p91t0qh.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-xzszbafv.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
|
|
164
164
|
\uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
|
|
165
165
|
`);let a=await o({input:c,output:f.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?f.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:M(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
|
|
166
166
|
\uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
|
|
167
|
-
\uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-
|
|
167
|
+
\uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-h69yazjn.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-xzv8t0nd.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-6ndeycxk.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-915p9d5k.js"),c=await e({mode:"build"});if(t.update){let i=await r(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${i} snapshots`)}else{let i=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(i)),i.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:r}=await import("./chunk-tftna6zb.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-zgnqyta0.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
|
|
168
168
|
\uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
|
|
169
169
|
`);let i=S.readFileSync(r,"utf-8"),l=await o(i,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",p=f.join(d,`${a}.${u}`);S.writeFileSync(p,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.join(d,`${a}.${u}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=f.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${p}`),console.log(` Manifest: ${b}`),console.log(`
|
|
170
170
|
\uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lo,ga,ma}from"./chunk-yygtmm7t.js";import"./chunk-amsbfc3y.js";import"./chunk-wpwh529h.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import"./chunk-
|
|
2
|
+
import{lo,ga,ma}from"./chunk-yygtmm7t.js";import"./chunk-amsbfc3y.js";import"./chunk-wpwh529h.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import"./chunk-p8zsnhhe.js";import"./chunk-nzwcbt98.js";import"./chunk-3eveprd2.js";import"./chunk-6ew10ptg.js";import"./chunk-4s1k8k2a.js";import"./chunk-3h238w91.js";import"./chunk-dxsdr77m.js";import"./chunk-5f6x6fyp.js";import"./chunk-0k80h9hw.js";import"./chunk-69y16gf3.js";import"./chunk-54xfrj8m.js";import"./chunk-aws32yq9.js";import"./chunk-k0wqy6jk.js";import"./chunk-2n68bepn.js";import"./chunk-cwq30a2f.js";import"./chunk-91pycazt.js";import"./chunk-e43cxztn.js";import{Yl,ia,Hm,Vm,aa,co,Wr,ca,la,Um,Wm,ua,da,pa,fa}from"./chunk-jw7swqvf.js";import"./chunk-1wqee608.js";import"./chunk-ap79ecs3.js";import"./chunk-bj0z4gve.js";import"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import"./chunk-1q726kxm.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{lo,ga,ma}from"./chunk-yygtmm7t.js";import"./chunk-amsbfc3y.js";import"./chunk-wpwh529h.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import"./chunk-
|
|
2
|
+
import{lo,ga,ma}from"./chunk-yygtmm7t.js";import"./chunk-amsbfc3y.js";import"./chunk-wpwh529h.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import"./chunk-p8zsnhhe.js";import"./chunk-nzwcbt98.js";import"./chunk-3eveprd2.js";import"./chunk-6ew10ptg.js";import"./chunk-4s1k8k2a.js";import"./chunk-3h238w91.js";import"./chunk-dxsdr77m.js";import"./chunk-5f6x6fyp.js";import"./chunk-0k80h9hw.js";import"./chunk-69y16gf3.js";import"./chunk-54xfrj8m.js";import"./chunk-aws32yq9.js";import"./chunk-k0wqy6jk.js";import"./chunk-2n68bepn.js";import"./chunk-cwq30a2f.js";import"./chunk-91pycazt.js";import"./chunk-e43cxztn.js";import{Yl,ia,Hm,Vm,aa,co,Wr,ca,la,Um,Wm,ua,da,pa,fa}from"./chunk-jw7swqvf.js";import"./chunk-1wqee608.js";import"./chunk-ap79ecs3.js";import"./chunk-bj0z4gve.js";import"./chunk-h6zm6atc.js";import"./chunk-8f14cgm8.js";import"./chunk-1q726kxm.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(`
|
|
@@ -53,6 +53,8 @@ export type TranslationDiagnosticKind = | 'unmapped-tag'
|
|
|
53
53
|
| 'unknown-style'
|
|
54
54
|
/** A static utility class has no native style translation. */
|
|
55
55
|
| 'unknown-class'
|
|
56
|
+
/** An Iconify name has no native symbol mapping. */
|
|
57
|
+
| 'unknown-icon'
|
|
56
58
|
/** A value the IR's field cannot hold, so emitting it would brick the screen. */
|
|
57
59
|
| 'non-numeric-style'
|
|
58
60
|
/** A legacy virtual-list prop has no meaning in the shared-runtime tree. */
|
|
@@ -357,7 +357,9 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
357
357
|
delete props.src;
|
|
358
358
|
}
|
|
359
359
|
if (type === "Icon") {
|
|
360
|
-
const icon = compileClassStyles(classes).icon,
|
|
360
|
+
const icon = compileClassStyles(classes).icon, name = String(props.symbol || props.name || icon || ""), resolved = resolveIconName(name, Boolean(props.symbol));
|
|
361
|
+
if (name.trim() && !resolved.known)
|
|
362
|
+
diagnostics.push({ kind: "unknown-icon", tag, name });
|
|
361
363
|
props.symbol = resolved.symbol;
|
|
362
364
|
if (resolved.iconify)
|
|
363
365
|
props.iconify = resolved.iconify;
|
|
@@ -18,11 +18,11 @@ export declare function iconClassIn(classes: string): string | undefined;
|
|
|
18
18
|
*
|
|
19
19
|
* The table is lucide first, because that is the collection HQ uses. Entries
|
|
20
20
|
* pick the closest symbol in meaning, not in shape: `footprints` is a run, so
|
|
21
|
-
* it is `figure.run`. Anything missing falls back to
|
|
21
|
+
* it is `figure.run`. Anything missing falls back to a question mark and the compiler
|
|
22
22
|
* says which name it did not know.
|
|
23
23
|
*/
|
|
24
24
|
/** The symbol drawn for a name the table does not have. */
|
|
25
|
-
export declare const FALLBACK_SYMBOL: '
|
|
25
|
+
export declare const FALLBACK_SYMBOL: 'questionmark.square.dashed';
|
|
26
26
|
/**
|
|
27
27
|
* lucide name (without the `i-lucide-` prefix) to SF Symbol name.
|
|
28
28
|
* @defaultValue
|
|
@@ -302,6 +302,8 @@ export declare const FALLBACK_SYMBOL: 'circle';
|
|
|
302
302
|
* ```
|
|
303
303
|
*/
|
|
304
304
|
export declare const LUCIDE_TO_SF: Record<string, string>;
|
|
305
|
+
/** Semantic native equivalents, keyed by collection so names cannot collide. */
|
|
306
|
+
export declare const COLLECTION_TO_SF: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
305
307
|
export declare interface IconResolution {
|
|
306
308
|
symbol: string
|
|
307
309
|
iconify?: string
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const FALLBACK_SYMBOL = "
|
|
1
|
+
export const FALLBACK_SYMBOL = "questionmark.square.dashed", LUCIDE_TO_SF = {
|
|
2
2
|
"circle-pause": "pause.circle",
|
|
3
3
|
"cloud-alert": "exclamationmark.icloud",
|
|
4
4
|
"key-round": "key",
|
|
@@ -269,6 +269,9 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
|
|
|
269
269
|
x: "xmark",
|
|
270
270
|
"x-circle": "xmark.circle",
|
|
271
271
|
zap: "bolt"
|
|
272
|
+
}, COLLECTION_TO_SF = {
|
|
273
|
+
lucide: LUCIDE_TO_SF,
|
|
274
|
+
hugeicons: { "workout-run": "figure.run" }
|
|
272
275
|
};
|
|
273
276
|
export function resolveIconName(name, asSymbol = !1) {
|
|
274
277
|
const value = String(name ?? "").trim();
|
|
@@ -276,14 +279,11 @@ export function resolveIconName(name, asSymbol = !1) {
|
|
|
276
279
|
return { symbol: FALLBACK_SYMBOL, known: !1 };
|
|
277
280
|
if (asSymbol)
|
|
278
281
|
return { symbol: value, known: !0 };
|
|
279
|
-
const prefixed = /^i-([a-z0-9]+)-(.+)$/.exec(value) ?? /^([a-z0-9]+):(.+)$/.exec(value), collection = prefixed ? prefixed[1] : "lucide", icon = prefixed ? prefixed[2] : value;
|
|
280
|
-
if (
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (!prefixed && value.includes("."))
|
|
285
|
-
return { symbol: value, known: !0 };
|
|
286
|
-
}
|
|
282
|
+
const prefixed = /^i-([a-z0-9]+)-(.+)$/.exec(value) ?? /^([a-z0-9]+):(.+)$/.exec(value), collection = prefixed ? prefixed[1] : "lucide", icon = prefixed ? prefixed[2] : value, symbols = Object.hasOwn(COLLECTION_TO_SF, collection) ? COLLECTION_TO_SF[collection] : void 0;
|
|
283
|
+
if (symbols && Object.hasOwn(symbols, icon))
|
|
284
|
+
return { symbol: symbols[icon], iconify: `i-${collection}-${icon}`, known: !0 };
|
|
285
|
+
if (!prefixed && value.includes("."))
|
|
286
|
+
return { symbol: value, known: !0 };
|
|
287
287
|
return { symbol: FALLBACK_SYMBOL, iconify: prefixed ? value : `i-lucide-${icon}`, known: !1 };
|
|
288
288
|
}
|
|
289
289
|
export function iconClassIn(classes) {
|
|
@@ -3,4 +3,4 @@ import type { NativeLayoutChrome } from './ir';
|
|
|
3
3
|
* Take the chrome out of a rendered page: the page without it, and its links.
|
|
4
4
|
* `chrome` is null when the page marks none.
|
|
5
5
|
*/
|
|
6
|
-
export declare function extractLayoutChrome(html: string): Promise<{ html: string, chrome: NativeLayoutChrome | null }>;
|
|
6
|
+
export declare function extractLayoutChrome(html: string, onUnknownIcon?: (name: string) => void): Promise<{ html: string, chrome: NativeLayoutChrome | null }>;
|
|
@@ -4,8 +4,10 @@ function regionKind(value) {
|
|
|
4
4
|
const kind = (value ?? "").trim().toLowerCase();
|
|
5
5
|
return kind === "tabs" || kind === "bar" ? kind : "";
|
|
6
6
|
}
|
|
7
|
-
function chromeSymbol(icon) {
|
|
7
|
+
function chromeSymbol(icon, onUnknownIcon) {
|
|
8
8
|
const resolved = resolveIconName(icon);
|
|
9
|
+
if (!resolved.known && /^i-|:/.test(icon))
|
|
10
|
+
onUnknownIcon?.(icon);
|
|
9
11
|
return resolved.known || /^i-|:/.test(icon) ? resolved.symbol : icon;
|
|
10
12
|
}
|
|
11
13
|
function appPath(href) {
|
|
@@ -17,7 +19,7 @@ function appPath(href) {
|
|
|
17
19
|
function readable(text) {
|
|
18
20
|
return text.replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;/g, "'").replace(/\s+/g, " ").trim();
|
|
19
21
|
}
|
|
20
|
-
export async function extractLayoutChrome(html) {
|
|
22
|
+
export async function extractLayoutChrome(html, onUnknownIcon) {
|
|
21
23
|
if (!/\bdata-native-chrome\b/i.test(html))
|
|
22
24
|
return { html, chrome: null };
|
|
23
25
|
const regions = [], items = [], scopes = new Set, wrappers = [], preludes = [];
|
|
@@ -81,7 +83,7 @@ export async function extractLayoutChrome(html) {
|
|
|
81
83
|
title: "",
|
|
82
84
|
region,
|
|
83
85
|
label: element.getAttribute("aria-label") || element.getAttribute("title") || "",
|
|
84
|
-
...icon ? { symbol: chromeSymbol(icon) } : {}
|
|
86
|
+
...icon ? { symbol: chromeSymbol(icon, onUnknownIcon) } : {}
|
|
85
87
|
};
|
|
86
88
|
open = item;
|
|
87
89
|
element.onEndTag(() => {
|
|
@@ -101,7 +103,7 @@ export async function extractLayoutChrome(html) {
|
|
|
101
103
|
return;
|
|
102
104
|
const icon = element.getAttribute("data-native-icon") || iconClassIn(element.getAttribute("class") ?? "");
|
|
103
105
|
if (icon)
|
|
104
|
-
open.symbol = chromeSymbol(icon);
|
|
106
|
+
open.symbol = chromeSymbol(icon, onUnknownIcon);
|
|
105
107
|
}
|
|
106
108
|
}).transform(new Response(html)).text();
|
|
107
109
|
if (!marked)
|
|
@@ -34,10 +34,13 @@ export async function compileScreenSource(source, filePath, options = {}) {
|
|
|
34
34
|
_nativeHostAttrs: !0,
|
|
35
35
|
skipEventDirectives: !0,
|
|
36
36
|
_pluginComponentDirs: loaded._pluginComponentDirs ?? []
|
|
37
|
-
}, context = { ...options.context ?? {}, __stx_inject_css: !1, __stx_native_screen: !0 }, dependencies = new Set([filePath]), renderedHtml = await processDirectives(source, context, filePath, config, dependencies), { html: content, chrome } = await extractLayoutChrome(await excludeNativeSubtrees(renderedHtml)
|
|
37
|
+
}, context = { ...options.context ?? {}, __stx_inject_css: !1, __stx_native_screen: !0 }, dependencies = new Set([filePath]), renderedHtml = await processDirectives(source, context, filePath, config, dependencies), chromeDiagnostics = [], { html: content, chrome } = await extractLayoutChrome(await excludeNativeSubtrees(renderedHtml), (name) => {
|
|
38
|
+
chromeDiagnostics.push({ kind: "unknown-icon", tag: "data-native-chrome", name });
|
|
39
|
+
}), { html, manifest } = extractBindingManifest(await excludeNativeSubtrees(content)), theme = await appThemeCSS(root), { document, diagnostics } = await translateHtmlToDocument(theme ? `<style>${theme}</style>${html}` : html, {
|
|
38
40
|
source: filePath,
|
|
39
41
|
script: extractClientScript(source)
|
|
40
42
|
});
|
|
43
|
+
diagnostics.unshift(...chromeDiagnostics);
|
|
41
44
|
enterTemplatedBindings(document.root, manifest);
|
|
42
45
|
const head = context.__stx_runtime_head;
|
|
43
46
|
if (typeof head?.title === "string" && head.title.trim())
|
|
@@ -474,7 +474,7 @@ export function createNativeHost(options) {
|
|
|
474
474
|
console.warn(`[STX Native] unknown-class: ${id}: ${name}`);
|
|
475
475
|
record.reportedClasses = unsupported;
|
|
476
476
|
if (record.type === "Icon" && classes.icon) {
|
|
477
|
-
const icon =
|
|
477
|
+
const icon = resolveNodeIcon(id, record, classes.icon);
|
|
478
478
|
record.props.symbol = icon.symbol;
|
|
479
479
|
record.props.iconify = icon.iconify;
|
|
480
480
|
if (record.materialized)
|
|
@@ -491,6 +491,13 @@ export function createNativeHost(options) {
|
|
|
491
491
|
emit({ op: "updateNode", id, patch: { props: { resizeMode: classes.resizeMode } } });
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
+
function resolveNodeIcon(id, record, name) {
|
|
495
|
+
const icon = resolveIconName(name), unknown = !icon.known && name.trim() ? name : void 0;
|
|
496
|
+
if (unknown && record.reportedIcon !== unknown)
|
|
497
|
+
console.warn(`[STX Native] unknown-icon: ${id}: ${unknown}; no native symbol mapping; using ${icon.symbol}. Use an explicit Icon symbol or add a collection mapping.`);
|
|
498
|
+
record.reportedIcon = unknown;
|
|
499
|
+
return icon;
|
|
500
|
+
}
|
|
494
501
|
function collectDescendants(node) {
|
|
495
502
|
const out = [], visit = (current) => {
|
|
496
503
|
const record = records.get(current.__stxId);
|
|
@@ -782,7 +789,7 @@ export function createNativeHost(options) {
|
|
|
782
789
|
else if (NATIVE_STATE_VARIANTS.has(prop))
|
|
783
790
|
applyClasses(node.__stxId, record, !0);
|
|
784
791
|
if (record.type === "Icon" && prop === "name") {
|
|
785
|
-
const icon =
|
|
792
|
+
const icon = resolveNodeIcon(node.__stxId, record, String(value ?? ""));
|
|
786
793
|
this.setAttribute(node, "iconify", icon.iconify ?? null);
|
|
787
794
|
this.setAttribute(node, "symbol", icon.symbol);
|
|
788
795
|
}
|
|
@@ -1062,6 +1069,8 @@ export function createNativeHost(options) {
|
|
|
1062
1069
|
},
|
|
1063
1070
|
setVisible(node, visible) {
|
|
1064
1071
|
const record = recordOf(node), was = record.visible;
|
|
1072
|
+
if (was === visible)
|
|
1073
|
+
return was;
|
|
1065
1074
|
record.visible = visible;
|
|
1066
1075
|
if (!visible)
|
|
1067
1076
|
for (const target of [node, ...collectDescendants(node)]) {
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Us,Ft,il,ag}from"./chunk-k8gxa1jf.js";import{Vs,vi,sg,og,ig}from"./chunk-9v98dzxt.js";import{rl,sl,ol,ng,rg}from"./chunk-b107z777.js";import{Ve,_n,wi}from"./chunk-r2cfezt5.js";import{cg,lg,ug,dg,Ws,Lh}from"./chunk-9bbs9d9q.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-njx1b3cd.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">
|