@stacksjs/stx 0.2.581 → 0.2.583
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-ayy9mmrw.js → chunk-02qaqamv.js} +6 -6
- package/dist/{chunk-6w2yqtrd.js → chunk-07anexcg.js} +1 -1
- package/dist/{chunk-dvgvvy5b.js → chunk-09zwhsf9.js} +1 -1
- package/dist/{chunk-cb2pyg5t.js → chunk-0dfgefjv.js} +2 -2
- package/dist/chunk-0fx3ppnt.js +2 -0
- package/dist/chunk-0sfexf9t.js +2 -0
- package/dist/chunk-2927nax9.js +2 -0
- package/dist/{chunk-eww6sdzz.js → chunk-2943qhdt.js} +1 -1
- package/dist/{chunk-9jh2ake5.js → chunk-2nehykbm.js} +5 -5
- package/dist/chunk-2rj0ttas.js +2 -0
- package/dist/chunk-3ae39ttg.js +2 -0
- package/dist/{chunk-q2a58n2a.js → chunk-440yjsk5.js} +1 -1
- package/dist/{chunk-kp0hg06s.js → chunk-4pkpr5cg.js} +2 -2
- package/dist/{chunk-g4crr86j.js → chunk-4pmgr32a.js} +3 -3
- package/dist/chunk-521pe0hb.js +18 -0
- package/dist/chunk-58z26y07.js +2 -0
- package/dist/chunk-5r9k9s3m.js +2 -0
- package/dist/{chunk-vx75fb0d.js → chunk-6fc8vw2v.js} +2 -2
- package/dist/{chunk-43h8q2cm.js → chunk-6m3me7yj.js} +6 -6
- package/dist/chunk-76vza4ve.js +2 -0
- package/dist/{chunk-c1r7zq0q.js → chunk-8tq83fq7.js} +71 -71
- package/dist/chunk-8y8bbsh5.js +2 -0
- package/dist/{chunk-620szfcp.js → chunk-96mb3brj.js} +2 -2
- package/dist/chunk-9kzycb15.js +2 -0
- package/dist/{chunk-djft0m5h.js → chunk-ac6v3s3k.js} +1 -1
- package/dist/chunk-agfhb2qd.js +2 -0
- package/dist/chunk-ay6dzpt4.js +2 -0
- package/dist/{chunk-dtcc09x1.js → chunk-b9njk81d.js} +1 -1
- package/dist/chunk-bfbcmfww.js +2 -0
- package/dist/chunk-br01jvra.js +2 -0
- package/dist/{chunk-v8p5p2kp.js → chunk-c12y2bet.js} +1 -1
- package/dist/chunk-c2nwchk0.js +2 -0
- package/dist/{chunk-3qrrv6af.js → chunk-cby4mkjf.js} +1 -1
- package/dist/{chunk-qazn64pm.js → chunk-ck1yca7g.js} +1 -1
- package/dist/chunk-cxqrwvc5.js +2 -0
- package/dist/chunk-czea8zr1.js +2 -0
- package/dist/chunk-d99kfx3k.js +2 -0
- package/dist/{chunk-7hkc96de.js → chunk-dhq80e4r.js} +4 -4
- package/dist/{chunk-cdgwkzms.js → chunk-dm1qh2vq.js} +1 -1
- package/dist/{chunk-5pgbsc3a.js → chunk-dskrwa8f.js} +1 -1
- package/dist/{chunk-zk2xk0wd.js → chunk-dvc15djp.js} +2 -2
- package/dist/chunk-e6ycqvdm.js +2 -0
- package/dist/{chunk-8v19753h.js → chunk-e809x7m0.js} +1 -1
- package/dist/{chunk-ta3wn842.js → chunk-en7xxgtb.js} +2 -2
- package/dist/chunk-fvx6pd66.js +2 -0
- package/dist/{chunk-xpnpg967.js → chunk-g9zeybqh.js} +2 -2
- package/dist/{chunk-zz02hwec.js → chunk-h3z9b6bw.js} +22 -22
- package/dist/{chunk-yk3fbzx5.js → chunk-hp9nxva6.js} +3 -3
- package/dist/chunk-hrbjapvr.js +2 -0
- package/dist/{chunk-pmpb34md.js → chunk-hzqyfdpy.js} +5 -5
- package/dist/chunk-jc4mxq56.js +2 -0
- package/dist/chunk-jdpyxt8j.js +2 -0
- package/dist/{chunk-4rkvwm6v.js → chunk-je1as16r.js} +9 -9
- package/dist/chunk-k0zev8wc.js +2 -0
- package/dist/{chunk-nrfh7gaa.js → chunk-kfwmqacd.js} +1 -1
- package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
- package/dist/{chunk-y8q1n7hx.js → chunk-ky1426s1.js} +6 -6
- package/dist/{chunk-rr8a7d4q.js → chunk-m417sp42.js} +3 -3
- package/dist/{chunk-101ekf6y.js → chunk-mjj24qpb.js} +2 -2
- package/dist/{chunk-ev5f79mg.js → chunk-mt9x626h.js} +3 -3
- package/dist/{chunk-faghmmrs.js → chunk-n4e02qdz.js} +85 -85
- package/dist/{chunk-yy3ser06.js → chunk-nh3svtvj.js} +3 -3
- package/dist/{chunk-yfq2v7x5.js → chunk-nhd9m8h5.js} +6 -6
- package/dist/chunk-nx8rf4qd.js +2 -0
- package/dist/{chunk-t8wpzqs4.js → chunk-pbwk8tzz.js} +1 -1
- package/dist/chunk-pe5bk9ns.js +2 -0
- package/dist/chunk-qb2j34sp.js +2 -0
- package/dist/chunk-qknfceta.js +2 -0
- package/dist/{chunk-0vnngvy1.js → chunk-qn8gdw21.js} +4 -4
- package/dist/chunk-sf98zgw2.js +2 -0
- package/dist/chunk-sgsp4dph.js +2 -0
- package/dist/{chunk-jtbzmbzz.js → chunk-sv08pd66.js} +2 -2
- package/dist/{chunk-30rf7k4n.js → chunk-tfxmzat6.js} +24 -24
- package/dist/chunk-tms7amrb.js +2 -0
- package/dist/chunk-v0zgarvv.js +2 -0
- package/dist/chunk-vczw73ga.js +2 -0
- package/dist/{chunk-be2ba3hj.js → chunk-vkc51n9m.js} +2 -2
- package/dist/{chunk-1v1mew46.js → chunk-vke73gts.js} +1 -1
- package/dist/{chunk-c0s3k64c.js → chunk-w6wtxj54.js} +2 -2
- package/dist/chunk-webrqm20.js +2 -0
- package/dist/chunk-wngqr949.js +2 -0
- package/dist/{chunk-71sdgv7e.js → chunk-wyn5rfzk.js} +105 -35
- package/dist/{chunk-yhpyqsbr.js → chunk-x552npae.js} +2 -2
- package/dist/{chunk-3wy8q3aq.js → chunk-xp7fxc6p.js} +5 -5
- package/dist/{chunk-t4g2fptt.js → chunk-xytkfa48.js} +4 -4
- package/dist/chunk-xyzy84x0.js +2 -0
- package/dist/chunk-y1jffvkj.js +2 -0
- package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
- package/dist/chunk-yas134jv.js +2 -0
- package/dist/{chunk-tszkg6sj.js → chunk-ycj0342k.js} +1 -1
- package/dist/{chunk-mxe21m6q.js → chunk-yd55vynh.js} +1 -1
- package/dist/{chunk-hzfhn2vr.js → chunk-ye66wc53.js} +2 -2
- package/dist/{chunk-k9th7hc4.js → chunk-ym1sb5bg.js} +2 -2
- package/dist/chunk-yn2d8x8m.js +3 -0
- package/dist/chunk-ze86h6vp.js +2 -0
- package/dist/cli.js +44 -44
- package/dist/client/signals-authoring-runtime.js +13 -6
- package/dist/client/signals-binding-utils-runtime.js +14 -1
- package/dist/client/signals-component-api-runtime.js +3 -1
- package/dist/client/signals-event-shorthand-runtime.js +1 -1
- package/dist/client/signals-expression-runtime.js +1 -1
- package/dist/client/signals-host-runtime.js +20 -0
- package/dist/client/signals-manifest-hydration-runtime.js +7 -0
- package/dist/client/signals-model-runtime.js +2 -0
- package/dist/client/signals-mount-runtime.js +5 -1
- package/dist/client/signals-process-element-runtime.js +22 -7
- package/dist/component-model.d.ts +1 -1
- package/dist/component-model.js +6 -3
- package/dist/composition-api.js +3 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/bundle.js +8 -3
- package/dist/native/compiler/html-to-ir.d.ts +3 -1
- package/dist/native/compiler/html-to-ir.js +28 -1
- package/dist/native/runtime/binding-tree.js +12 -0
- package/dist/native/runtime/craft-bridge.js +2 -1
- package/dist/native/runtime/jsc-globals.d.ts +10 -3
- package/dist/native/runtime/jsc-globals.js +23 -4
- package/dist/native/runtime/native-host.d.ts +4 -0
- package/dist/native/runtime/native-host.js +273 -21
- package/dist/native/runtime/shared-screen.js +1 -0
- package/dist/native/testing.js +1 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +7 -7
- package/package.json +5 -5
- package/dist/chunk-0047meje.js +0 -2
- package/dist/chunk-1cat8kdj.js +0 -2
- package/dist/chunk-1dwnp35v.js +0 -2
- package/dist/chunk-2dnr5qfk.js +0 -2
- package/dist/chunk-2v73cjbc.js +0 -2
- package/dist/chunk-3akgppsy.js +0 -2
- package/dist/chunk-4t67wmcg.js +0 -2
- package/dist/chunk-51zn42jy.js +0 -2
- package/dist/chunk-5702x95v.js +0 -2
- package/dist/chunk-60c2bsh9.js +0 -2
- package/dist/chunk-79v4d9qh.js +0 -2
- package/dist/chunk-7pp2vx1g.js +0 -2
- package/dist/chunk-8zm6tkqb.js +0 -2
- package/dist/chunk-a1z36dt5.js +0 -2
- package/dist/chunk-atsf1fe0.js +0 -2
- package/dist/chunk-b8qd6h1q.js +0 -2
- package/dist/chunk-ccxs40xy.js +0 -2
- package/dist/chunk-cg8hg6cs.js +0 -3
- package/dist/chunk-cp442y7a.js +0 -2
- package/dist/chunk-d4en5d3s.js +0 -2
- package/dist/chunk-dh80d57p.js +0 -2
- package/dist/chunk-dyqte1xq.js +0 -2
- package/dist/chunk-e4n4v022.js +0 -2
- package/dist/chunk-g2fw68zm.js +0 -2
- package/dist/chunk-hcgm37dy.js +0 -2
- package/dist/chunk-hd2bn5q7.js +0 -2
- package/dist/chunk-j1nqnmcd.js +0 -18
- package/dist/chunk-k7jqkt93.js +0 -2
- package/dist/chunk-mqy7g74k.js +0 -2
- package/dist/chunk-ne03tfje.js +0 -2
- package/dist/chunk-p2sns0bn.js +0 -2
- package/dist/chunk-s1sycp43.js +0 -2
- package/dist/chunk-sp46w7z9.js +0 -2
- package/dist/chunk-sy1bk1ry.js +0 -2
- package/dist/chunk-tpd5nwa3.js +0 -2
- package/dist/chunk-tpt4bgs5.js +0 -2
- package/dist/chunk-vq0cb1m9.js +0 -2
- package/dist/chunk-y1bppxgw.js +0 -2
- package/dist/chunk-yv5rwthv.js +0 -2
- package/dist/chunk-z1r4tdqy.js +0 -2
- package/dist/chunk-zv288w4e.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Le,q}from"./chunk-117xss52.js";import{zo}from"./chunk-
|
|
2
|
+
import{Le,q}from"./chunk-117xss52.js";import{zo}from"./chunk-521pe0hb.js";import{d}from"./chunk-yn2d8x8m.js";import{existsSync as M,mkdirSync as v,copyFileSync as k,chmodSync as T}from"fs";import{join as o,basename as te}from"path";import{spawn as E,execSync as ae}from"child_process";import{homedir as B,platform as re}from"os";var Au=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -931,7 +931,7 @@ else if (data.type === 'event' && data.method) {
|
|
|
931
931
|
}
|
|
932
932
|
})();
|
|
933
933
|
</script>
|
|
934
|
-
`.replace("debug: false,",`debug: ${a},`).replace("timeout: 30000",`timeout: ${r}`)}function
|
|
934
|
+
`.replace("debug: false,",`debug: ${a},`).replace("timeout: 30000",`timeout: ${r}`)}function Pu(){return!1}function Iu(e,a={}){let r=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(r,(i,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return Io(t)})}function Oo(e,a={}){if(e.includes("__craftBridgeInitialized"))return e;let r=Io(a);if(e.includes("</head>"))return e.replace("</head>",`${r}
|
|
935
935
|
</head>`);if(e.includes("<body"))return e.replace(/(<body[^>]*>)/,`$1
|
|
936
936
|
${r}`);return r+e}var Xr={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(e,a)=>{let r=e.checked?"checked":"",i=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
937
937
|
<input type="checkbox" class="craft-checkbox" ${r} ${i}>
|
|
@@ -1365,7 +1365,7 @@ ${r}`);return r+e}var Xr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
</style>
|
|
1368
|
-
`,
|
|
1368
|
+
`,Ou=`
|
|
1369
1369
|
<script id="craft-component-runtime">
|
|
1370
1370
|
(function() {
|
|
1371
1371
|
if (window.__stxCraftComponentRuntime) return;
|
|
@@ -2934,17 +2934,17 @@ ${r}`);return r+e}var Xr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2934
2934
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
2935
2935
|
})();
|
|
2936
2936
|
</script>
|
|
2937
|
-
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,s,t)=>R("sidebar",s,t.trim(),a,r)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>R("sidebar",s,"",a,r)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>R(s,t,"",a,r)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,n)=>R(s,t,n.trim(),a,r)),e}function R(e,a,r,i,s){let t=i.components?.[e]||Xr[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${r}</div>`;let n=A(a),c=[t.fallbackClasses||`${s}-${e}`];if(n.class)c.push(n.class),delete n.class;if(t.render)return n.__fallbackClasses=c.join(" "),t.render(n,r);let
|
|
2937
|
+
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,s,t)=>R("sidebar",s,t.trim(),a,r)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>R("sidebar",s,"",a,r)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>R(s,t,"",a,r)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,n)=>R(s,t,n.trim(),a,r)),e}function R(e,a,r,i,s){let t=i.components?.[e]||Xr[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${r}</div>`;let n=A(a),c=[t.fallbackClasses||`${s}-${e}`];if(n.class)c.push(n.class),delete n.class;if(t.render)return n.__fallbackClasses=c.join(" "),t.render(n,r);let l=ee(n,t,c);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${l}>`;return`<${t.fallbackTag} ${l}>${r}</${t.fallbackTag}>`}function A(e){let a={},r=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,i;while((i=r.exec(e))!==null){let[s,t,n,c]=i,l=n??c;if(s.startsWith(":"))a[t]=l;else if(s.startsWith("@"))a[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=l;else if(l===void 0)a[t]=!0;else a[t]=l}return a}function j(e,a){let r=I(String(e.id||`craft-sidebar-${K(a||JSON.stringify(e))}`)),i=Q(e.spaces)||Y(a),s=i.length?[]:X(e.sections)||D(a),t=String(e.selectedSpace||i[0]?.id||""),n=i.find((m)=>m.id===t)||i[0],c=String(e.selectedItem||e.selected||(i.length?n?.sections[0]?.items[0]?.id:s[0]?.items[0]?.id)||""),l={id:r,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:c,sections:s,spaces:i,selectedSpace:t||void 0},f=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),b=Number(e.width||e.sidebarWidth||286),p=e.native===!1||e.native==="false"?"false":"true",x=l.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C(l.searchPlaceholder)}"></div>`:"",u;if(i.length)u=G(i,t,c);else if(s.length)u=s.map((m)=>O(m,c)).join("");else u=a;return`<aside class="${h(f)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${h(r)}" data-native="${p}" style="--craft-sidebar-width:${b}px">
|
|
2938
2938
|
${x}
|
|
2939
|
-
${
|
|
2939
|
+
${u}
|
|
2940
2940
|
</aside>
|
|
2941
|
-
<script type="application/json" data-craft-sidebar-config="${h(r)}">${Z(
|
|
2941
|
+
<script type="application/json" data-craft-sidebar-config="${h(r)}">${Z(l)}</script>`}function H(e,a){let r=I(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${h(r)}">
|
|
2942
2942
|
${e.label?`<div class="craft-sidebar-space-title">${C(String(e.label))}</div>`:""}
|
|
2943
2943
|
${a}
|
|
2944
2944
|
</section>`}function V(e,a){let r=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${h(String(e.id||"section"))}">
|
|
2945
2945
|
${r?`<div class="craft-sidebar-section-title">${C(r)}</div>`:""}
|
|
2946
2946
|
${a}
|
|
2947
|
-
</section>`}function W(e,a){let r={id:String(e.id||I(String(e.label||a||"item"))),label:String(e.label||a||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return _(r,String(e.selected||"")==="true")}function D(e){let a=[],r=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,i;while((i=r.exec(e))!==null){let s=A(i[1]||""),t=i[2]||"",n=String(s.id||I(String(s.header||s.title||`section-${a.length+1}`))),c=String(s.header||s.title||n),
|
|
2947
|
+
</section>`}function W(e,a){let r={id:String(e.id||I(String(e.label||a||"item"))),label:String(e.label||a||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return _(r,String(e.selected||"")==="true")}function D(e){let a=[],r=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,i;while((i=r.exec(e))!==null){let s=A(i[1]||""),t=i[2]||"",n=String(s.id||I(String(s.header||s.title||`section-${a.length+1}`))),c=String(s.header||s.title||n),l=J(t);a.push({id:n,header:c,title:c,items:l})}return a}function J(e){let a=[],r=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,i;while((i=r.exec(e))!==null){let s=A(i[1]||""),t=String(s.label||(i[2]||"").replace(/<[^>]*>/g,"").trim()),n=String(s.id||I(t||`item-${a.length+1}`));a.push({id:n,label:t,icon:s.icon?String(s.icon):void 0,badge:s.badge?String(s.badge):void 0,tintColor:s.tintColor?String(s.tintColor):void 0})}return a}function Y(e){let a=[],r=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,i;while((i=r.exec(e))!==null){let s=A(i[1]||""),t=i[2]||"",n=String(s.label||s.title||`Space ${a.length+1}`);a.push({id:String(s.id||I(n)),label:n,icon:s.icon?String(s.icon):void 0,tint:s.tint?String(s.tint):void 0,sections:D(t)})}return a}function Q(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let a=JSON.parse(e);return Array.isArray(a)?a:void 0}catch{return}}function G(e,a,r){let i=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${h(t.id)}" data-selected="${t.id===a?"true":"false"}" title="${h(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${h(t.icon)}"></span>`:C((t.label||t.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${e.map((t)=>`<section class="craft-sidebar-space" data-space-id="${h(t.id)}" data-selected="${t.id===a?"true":"false"}">
|
|
2948
2948
|
${t.label?`<div class="craft-sidebar-space-title">${C(t.label)}</div>`:""}
|
|
2949
2949
|
${t.sections.map((n)=>O(n,r)).join("")}
|
|
2950
2950
|
</section>`).join("")}</div>
|
|
@@ -2955,16 +2955,16 @@ ${r}`);return r+e}var Xr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2955
2955
|
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${h(e.icon)}"${r}></span>`:""}
|
|
2956
2956
|
<span class="craft-sidebar-item-label">${C(e.label)}</span>
|
|
2957
2957
|
${e.badge?`<span class="craft-sidebar-item-badge">${C(e.badge)}</span>`:""}
|
|
2958
|
-
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function K(e){let a=5381;for(let r=0;r<e.length;r++)a=a*33^e.charCodeAt(r);return(a>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(e){return C(e).replace(/`/g,"`")}function Z(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ee(e,a,r){let i=[];i.push(`class="${r.join(" ")}"`),i.push(`data-craft="${a.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let n=String(t).replace(/"/g,""");i.push(`${s}="${n}"`)}return i.join(" ")}function
|
|
2959
|
-
</head>`)}let n=e.name||te(e.input,".stx"),c=e.version||"1.0.0",
|
|
2958
|
+
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function K(e){let a=5381;for(let r=0;r<e.length;r++)a=a*33^e.charCodeAt(r);return(a>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(e){return C(e).replace(/`/g,"`")}function Z(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ee(e,a,r){let i=[];i.push(`class="${r.join(" ")}"`),i.push(`data-craft="${a.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let n=String(t).replace(/"/g,""");i.push(`${s}="${n}"`)}return i.join(" ")}function Du(e,a){Xr[e]=a}function Mu(){return{...Xr}}async function No(e){let a=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||P(),format:e.format||"app",error:`Input file not found: ${e.input}`};let r=e.target||P(),i=e.format||pe(r),s=e.output||o(process.cwd(),"dist","native");if(!M(s))v(s,{recursive:!0});let t=await zo(e.input,{context:e.context,options:{isDev:!1}});if(t=Oo(t,{debug:e.verbose}),t=Mo(t),!t.includes("craft-component-styles")){if(t.includes("</head>"))t=t.replace("</head>",`${Do}
|
|
2959
|
+
</head>`)}let n=e.name||te(e.input,".stx"),c=e.version||"1.0.0",l=e.craftPath||await fe();if(!l)return{success:!1,target:r,format:i,error:"Craft binary not found. Please install Craft or specify craftPath."};if(e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${r}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${l}`);let f;switch(r){case"macos":f=await ie(t,n,c,s,i,e,l);break;case"windows":f=await oe(t,n,c,s,i,e,l);break;case"linux":f=await ce(t,n,c,s,i,e,l);break;case"ios":f=await de(t,n,c,s,e,l);break;case"android":f=await le(t,n,c,s,e,l);break;default:f={success:!1,target:r,format:i,error:`Unsupported target: ${r}`}}return f.duration=Date.now()-a,f}catch(r){return{success:!1,target:e.target||P(),format:e.format||"app",error:r.message,duration:Date.now()-a}}}async function ie(e,a,r,i,s,t,n){let c=t.bundleId||`com.stx.${a.toLowerCase().replace(/[^a-z0-9]/g,"")}`,l=o(i,`${a}.app`),f=o(l,"Contents"),b=o(f,"MacOS"),p=o(f,"Resources");v(b,{recursive:!0}),v(p,{recursive:!0});let x=o(p,"index.html");await Bun.write(x,e);let u="";if(t.sidebar?.enabled&&t.sidebar?.config)u=o(p,"sidebar-config.json"),await Bun.write(u,JSON.stringify(t.sidebar.config));let m=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",y=t.menubarOnly??t.systemTray;if((t.bundleStyle||(await se(n)?"executable":"launcher"))==="executable"){let S=o(b,a);k(n,S),T(S,493);let w={html:"index.html",title:t.window?.title||a,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(y)w.menubarOnly=!0;else if(t.systemTray)w.systemTray=!0;if(t.window?.frameless)w.frameless=!0;if(t.window?.transparent)w.transparent=!0;if(t.window?.alwaysOnTop)w.alwaysOnTop=!0;if(t.window?.resizable===!1)w.resizable=!1;await Bun.write(o(p,"craft.json"),`${JSON.stringify(w,null,2)}
|
|
2960
2960
|
`)}else{let S=o(b,"craft");k(n,S),T(S,493);let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",U=`#!/bin/bash
|
|
2961
2961
|
set -euo pipefail
|
|
2962
2962
|
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
2963
2963
|
RESOURCES="$DIR/../Resources"
|
|
2964
2964
|
exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
2965
2965
|
${[`--title "${t.window?.title||a}"`,`--width ${t.window?.width||1200}`,`--height ${t.window?.height||800}`,y?"--menubar-only":t.systemTray?"--system-tray":"",t.devTools?"":"--no-devtools",t.window?.frameless?"--frameless":"",t.window?.transparent?"--transparent":"",t.window?.alwaysOnTop?"--always-on-top":"",t.window?.resizable===!1?"--no-resize":"",w].filter(Boolean).join(" \\\n ")}
|
|
2966
|
-
`,F=o(b,a);await Bun.write(F,U),T(F,493)}let N=Boolean(t.icon&&await Bun.file(t.icon).exists());if(N)k(t.icon,o(
|
|
2967
|
-
${i}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[n,c,
|
|
2966
|
+
`,F=o(b,a);await Bun.write(F,U),T(F,493)}let N=Boolean(t.icon&&await Bun.file(t.icon).exists());if(N)k(t.icon,o(p,"AppIcon.icns"));let L={CFBundleExecutable:a,CFBundleIdentifier:c,CFBundleName:a,CFBundleDisplayName:a,CFBundleShortVersionString:r,CFBundleVersion:r,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.menubarOnly??Boolean(t.systemTray),...N?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(o(f,"Info.plist"),ne(L)),s==="dmg"){let S=o(i,`${a}-${r}.dmg`),w=await ue(l,S,a);if(!w.success)return{success:!1,target:"macos",format:"dmg",error:w.error};return{success:!0,target:"macos",format:"dmg",outputPath:S}}return{success:!0,target:"macos",format:"app",outputPath:l}}async function se(e){try{let a=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[r,i]=await Promise.all([new Response(a.stdout).text(),new Response(a.stderr).text()]);await a.exited;let t=`${r}
|
|
2967
|
+
${i}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[n,c,l]=t.slice(1).map(Number);if(n>0||c>0)return!0;return l>=57}catch{return!1}}function z(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ne(e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2968
2968
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
2969
2969
|
<plist version="1.0">
|
|
2970
2970
|
<dict>
|
|
@@ -2973,7 +2973,7 @@ ${Object.entries(e).map(([r,i])=>{let s=typeof i==="boolean"?`<${i}/>`:typeof i=
|
|
|
2973
2973
|
`)}
|
|
2974
2974
|
</dict>
|
|
2975
2975
|
</plist>
|
|
2976
|
-
`}async function oe(e,a,r,i,s,t,n){let c=o(i,a);v(c,{recursive:!0});let
|
|
2976
|
+
`}async function oe(e,a,r,i,s,t,n){let c=o(i,a);v(c,{recursive:!0});let l=o(c,"index.html");await Bun.write(l,e),k(n,o(c,"craft.exe"));let f=`@echo off
|
|
2977
2977
|
set DIR=%~dp0
|
|
2978
2978
|
"%DIR%craft.exe" --html-file "%DIR%index.html" ^
|
|
2979
2979
|
--title "${t.window?.title||a}" ^
|
|
@@ -2981,7 +2981,7 @@ set DIR=%~dp0
|
|
|
2981
2981
|
--height ${t.window?.height||800} ^
|
|
2982
2982
|
${t.systemTray?"--system-tray":""} ^
|
|
2983
2983
|
${t.devTools?"":"--no-devtools"}
|
|
2984
|
-
`;if(await Bun.write(o(c,`${a}.bat`),
|
|
2984
|
+
`;if(await Bun.write(o(c,`${a}.bat`),f),s==="zip"){let b=o(i,`${a}-${r}-windows.zip`),p=await be(c,b);if(!p.success)return{success:!1,target:"windows",format:"zip",error:p.error};return{success:!0,target:"windows",format:"zip",outputPath:b}}return{success:!0,target:"windows",format:"app",outputPath:c}}async function ce(e,a,r,i,s,t,n){let c=o(i,a);v(c,{recursive:!0});let l=o(c,"index.html");await Bun.write(l,e);let f=o(c,"craft");k(n,f),T(f,493);let b=`#!/bin/bash
|
|
2985
2985
|
set -euo pipefail
|
|
2986
2986
|
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
2987
2987
|
exec "$DIR/craft" --html-file "$DIR/index.html" \\
|
|
@@ -2990,15 +2990,15 @@ exec "$DIR/craft" --html-file "$DIR/index.html" \\
|
|
|
2990
2990
|
--height ${t.window?.height||800} \\
|
|
2991
2991
|
${t.systemTray?"--system-tray":""} \\
|
|
2992
2992
|
${t.devTools?"":"--no-devtools"}
|
|
2993
|
-
`,
|
|
2993
|
+
`,p=o(c,a.toLowerCase());await Bun.write(p,b),T(p,493);let x=`[Desktop Entry]
|
|
2994
2994
|
Type=Application
|
|
2995
2995
|
Name=${a}
|
|
2996
|
-
Exec=${
|
|
2996
|
+
Exec=${p}
|
|
2997
2997
|
Terminal=false
|
|
2998
2998
|
Categories=Utility;
|
|
2999
|
-
`;if(await Bun.write(o(c,`${a.toLowerCase()}.desktop`),x),s==="deb"){let
|
|
3000
|
-
`)[0];if(r&&await Bun.file(r).exists())return r}catch{}return null}function P(){switch(re()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function pe(e){switch(e){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function ue(e,a,r){return new Promise((i)=>{let s=E("hdiutil",["create","-volname",r,"-srcfolder",e,"-ov","-format","UDZO",a]);s.on("close",(t)=>{if(t===0)i({success:!0});else i({success:!1,error:`hdiutil exited with code ${t}`})}),s.on("error",(t)=>{i({success:!1,error:t.message})})})}async function be(e,a){return new Promise((r)=>{let i=E("zip",["-r",a,"."],{cwd:e});i.on("close",(s)=>{if(s===0)r({success:!0});else r({success:!1,error:`zip exited with code ${s}`})}),i.on("error",(s)=>{r({success:!1,error:s.message})})})}async function ge(e,a,r,i,s){return new Promise((t)=>{let n=Le("deb");try{let c=o(n,"pkg"),
|
|
3001
|
-
exec /usr/share/${r.toLowerCase()}/${r.toLowerCase()} "$@"`;
|
|
2999
|
+
`;if(await Bun.write(o(c,`${a.toLowerCase()}.desktop`),x),s==="deb"){let u=o(i,`${a.toLowerCase()}_${r}_amd64.deb`),m=await ge(c,u,a,r,t);if(!m.success)return{success:!1,target:"linux",format:"deb",error:m.error};return{success:!0,target:"linux",format:"deb",outputPath:u}}if(s==="appimage"){let u=o(i,`${a}-${r}-x86_64.AppImage`),m=await me(c,u,a,t);if(!m.success)return{success:!1,target:"linux",format:"appimage",error:m.error};return{success:!0,target:"linux",format:"appimage",outputPath:u}}return{success:!0,target:"linux",format:"app",outputPath:c}}async function de(e,a,r,i,s,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${a}' to create an iOS project.`}}async function le(e,a,r,i,s,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${a}' to create an Android project.`}}async function fe(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let e=[o(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),o(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),o(B(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),o(B(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",o(B(),".local/bin/craft"),o(process.env.LOCALAPPDATA||"","craft","craft.exe"),o(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let a of e)if(await Bun.file(a).exists())return a;try{let r=ae("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
|
|
3000
|
+
`)[0];if(r&&await Bun.file(r).exists())return r}catch{}return null}function P(){switch(re()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function pe(e){switch(e){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function ue(e,a,r){return new Promise((i)=>{let s=E("hdiutil",["create","-volname",r,"-srcfolder",e,"-ov","-format","UDZO",a]);s.on("close",(t)=>{if(t===0)i({success:!0});else i({success:!1,error:`hdiutil exited with code ${t}`})}),s.on("error",(t)=>{i({success:!1,error:t.message})})})}async function be(e,a){return new Promise((r)=>{let i=E("zip",["-r",a,"."],{cwd:e});i.on("close",(s)=>{if(s===0)r({success:!0});else r({success:!1,error:`zip exited with code ${s}`})}),i.on("error",(s)=>{r({success:!1,error:s.message})})})}async function ge(e,a,r,i,s){return new Promise((t)=>{let n=Le("deb");try{let c=o(n,"pkg"),l=o(c,"DEBIAN"),f=o(c,"usr","bin"),b=o(c,"usr","share","applications"),p=o(c,"usr","share",r.toLowerCase());v(l,{recursive:!0}),v(f,{recursive:!0}),v(b,{recursive:!0}),v(p,{recursive:!0});let x=d("fs").readdirSync(e);for(let g of x)k(o(e,g),o(p,g));let u=`#!/bin/bash
|
|
3001
|
+
exec /usr/share/${r.toLowerCase()}/${r.toLowerCase()} "$@"`;d("fs").writeFileSync(o(f,r.toLowerCase()),u),T(o(f,r.toLowerCase()),493);let m=`Package: ${r.toLowerCase()}
|
|
3002
3002
|
Version: ${i}
|
|
3003
3003
|
Section: utils
|
|
3004
3004
|
Priority: optional
|
|
@@ -3006,17 +3006,17 @@ Architecture: amd64
|
|
|
3006
3006
|
Depends: libgtk-3-0, libwebkit2gtk-4.0-37
|
|
3007
3007
|
Maintainer: ${s.author||"Unknown"}
|
|
3008
3008
|
Description: ${s.description||r}
|
|
3009
|
-
`;
|
|
3009
|
+
`;d("fs").writeFileSync(o(l,"control"),m);let y=E("dpkg-deb",["--build",c,a]);y.on("close",(g)=>{if(q(n),g===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${g}`})}),y.on("error",(g)=>{q(n),t({success:!1,error:g.message})})}catch(c){q(n),t({success:!1,error:c.message})}})}async function me(e,a,r,i){return new Promise((s)=>{let t=Le("appimage");try{let n=o(t,`${r}.AppDir`),c=o(n,"usr"),l=o(c,"bin"),f=o(c,"share");v(l,{recursive:!0}),v(f,{recursive:!0});let b=o(f,r.toLowerCase());v(b,{recursive:!0});let p=d("fs").readdirSync(e);for(let g of p)k(o(e,g),o(b,g));let x=`#!/bin/bash
|
|
3010
3010
|
SELF=$(readlink -f "$0")
|
|
3011
3011
|
HERE=\${SELF%/*}
|
|
3012
3012
|
export PATH="\${HERE}/usr/bin:\${PATH}"
|
|
3013
3013
|
exec "\${HERE}/usr/share/${r.toLowerCase()}/${r.toLowerCase()}" "$@"
|
|
3014
|
-
`;
|
|
3014
|
+
`;d("fs").writeFileSync(o(n,"AppRun"),x),T(o(n,"AppRun"),493);let u=`[Desktop Entry]
|
|
3015
3015
|
Type=Application
|
|
3016
3016
|
Name=${r}
|
|
3017
3017
|
Exec=${r.toLowerCase()}
|
|
3018
3018
|
Terminal=false
|
|
3019
3019
|
Categories=Utility;
|
|
3020
3020
|
Icon=${r.toLowerCase()}
|
|
3021
|
-
`;
|
|
3022
|
-
export{
|
|
3021
|
+
`;d("fs").writeFileSync(o(n,`${r.toLowerCase()}.desktop`),u);let m=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(d("fs").writeFileSync(o(n,`${r.toLowerCase()}.png`),m),i.icon&&M(i.icon))k(i.icon,o(n,`${r.toLowerCase()}.png`));let y=E("appimagetool",[n,a],{env:{...process.env,ARCH:"x86_64"}});y.on("close",(g)=>{if(q(t),g===0)T(a,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${g}. Install from https://appimage.github.io/appimagetool/`})}),y.on("error",(g)=>{q(t),s({success:!1,error:`appimagetool not found: ${g.message}`})})}catch(n){q(t),s({success:!1,error:n.message})}})}function Lo(){return[P()]}function jo(e){switch(e){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var he={buildNative:No,getAvailableTargets:Lo,getAvailableFormats:jo,detectPlatform:P},Nu=he;
|
|
3022
|
+
export{Au,Io,Pu,Iu,Oo,Xr,Do,Ou,Mo,Du,Mu,No,Lo,jo,Nu};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ae,yt,Zr}from"./chunk-jpqkm8tm.js";function
|
|
2
|
+
import{ae,yt,Zr}from"./chunk-jpqkm8tm.js";function Wn(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?ae(a,e):null,h=u?yt(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
|
|
3
3
|
* Service Worker - Auto-generated by stx
|
|
4
4
|
* Cache Version: ${i}
|
|
5
5
|
*
|
|
@@ -825,5 +825,5 @@ self.addEventListener('message', (event) => {
|
|
|
825
825
|
event.waitUntil(registerFormSync(event.data.payload));
|
|
826
826
|
}
|
|
827
827
|
});
|
|
828
|
-
`}function je(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function Xo(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function nc(e,a){if(!e.pwa?.enabled)return"";if(Xo(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-4srg0qbv.js");return t(e,a)}return
|
|
829
|
-
export{
|
|
828
|
+
`}function je(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function Xo(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function nc(e,a){if(!e.pwa?.enabled)return"";if(Xo(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-4srg0qbv.js");return t(e,a)}return Wn(e,a)}
|
|
829
|
+
export{Wn,je,Xo,nc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{No,Lo,jo,Nu}from"./chunk-h3z9b6bw.js";import"./chunk-521pe0hb.js";import"./chunk-117xss52.js";import"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{No as buildNative,Nu as default,jo as getAvailableFormats,Lo as getAvailableTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Re,Ae,Pe}from"./chunk-30acme5g.js";import"./chunk-
|
|
2
|
+
import{Re,Ae,Pe}from"./chunk-30acme5g.js";import"./chunk-dvc15djp.js";import"./chunk-vpdx7qr3.js";import{u}from"./chunk-n4e02qdz.js";import"./chunk-dhq80e4r.js";import"./chunk-ah9xyss2.js";import"./chunk-x552npae.js";import"./chunk-6m3me7yj.js";import"./chunk-02qaqamv.js";import"./chunk-sv08pd66.js";import"./chunk-vkc51n9m.js";import"./chunk-2943qhdt.js";import"./chunk-qdyp2zqf.js";import{lt,kr,ut,Zs,$e,Qs,Cr,dt,to,pt}from"./chunk-mjj24qpb.js";import"./chunk-dm1qh2vq.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Qs("Config file changed, restarting...");try{await e.onChange()}catch(p){$e(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,9 +556,9 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-nx8rf4qd.js"),p={},g=h(n);if(g)try{await u(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await u(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-nx8rf4qd.js"),c={...r},n=h(e);if(n)try{await u(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
|
-
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await
|
|
561
|
+
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await dt(t);Ae(t,r);let s=pt(t.config,r);Pe(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=to(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await dt(t);Ae(t,m);let f=pt(t.config,m);if(Pe(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,g,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
563
563
|
<head>
|
|
564
564
|
<meta charset="UTF-8">
|
|
@@ -1276,5 +1276,5 @@ else {
|
|
|
1276
1276
|
<style>${W()}</style>
|
|
1277
1277
|
${D()}
|
|
1278
1278
|
</body>
|
|
1279
|
-
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){lt();let e=await Re({mode:"dev"});if(!e.config.enabled){$e("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),
|
|
1280
|
-
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":
|
|
1279
|
+
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){lt();let e=await Re({mode:"dev"});if(!e.config.enabled){$e("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),ut(e.storyFiles.length),kr(s.url),Cr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Re({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
|
|
1280
|
+
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":Cr();break;case"o":try{let{exec:p}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${g} ${s.url}`)}catch{Zs("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),lt(),ut(e.storyFiles.length),kr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{cl}from"./chunk-09zwhsf9.js";import"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{cl as startInteractive};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ot}from"./chunk-
|
|
2
|
+
import{Ot}from"./chunk-6m3me7yj.js";import{ni,as,U,ze,ee,Tt,x,Ue,Ve,tr,u}from"./chunk-n4e02qdz.js";import{M}from"./chunk-5db5sxy3.js";var H=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function V(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(H.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var B=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function ho(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=ze(t,s);if(a>s){i=a;continue}let o=U(t,s);if(o>s){let c=t.slice(s,o),f=B.exec(c);if(f){let l=V(f[1],f[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var q=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function z(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function G(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function W(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function O(t,n="main"){let e=G(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=z(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||q.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!W(o,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let S=m[1]==="/";if(!S&&(m[2]||"").trimEnd().endsWith("/"))continue;if(g+=S?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:m.index,tagName:a}}return null}return null}var Oe="private, no-store";function yo(t){return t.replace(/&#(\d+);/g,(n,e)=>j(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>j(Number.parseInt(e,16),n)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function j(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function se(t){return t.headers.get("X-STX-Router")==="true"}function X(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function T(t){return{Vary:X(t,"X-STX-Router")}}import E from"path";var J="stx-page-head:",K=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Y(){let t=M()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-c12y2bet.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function bo(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Or(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=ho(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)o.push(f[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:S,defaultConfig:b,loadStxConfig:w}=await import("./chunk-k0zev8wc.js"),y=await w(),p={__filename:t,__dirname:E.dirname(t)};for(let d of a){let C=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!d.includes("client")&&!d.includes('type="module"'))await S(C[1],p,t)}let R=await m(l,p,t,{...b,...y,...n},new Set),h=R.indexOf(g);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:R.substring(0,h),afterSlot:R.substring(h+g.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function jn(t,n,e){let r,i="",s=n.match(K);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Y(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -18,14 +18,14 @@ ${t.shellScripts.filter((l)=>!l.includes("server")).join(`
|
|
|
18
18
|
${c}
|
|
19
19
|
${o}
|
|
20
20
|
</body>
|
|
21
|
-
</html>`}function ye(t,n={}){let e=t.trim();if(!Ot(e))return t;let r=[],i=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(i){let c=i[1],
|
|
22
|
-
`),"utf8").toString("base64")}-->`)}let s=e.match(/<body\b[^>]*>/i),a=e.lastIndexOf("</body>");if(s&&a!==-1){let c=s.index+s[0].length,
|
|
21
|
+
</html>`}function ye(t,n={}){let e=t.trim();if(!Ot(e))return t;let r=[],i=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(i){let c=i[1],f=/<style\b[^>]*>[\s\S]*?<\/style>/gi,l;while((l=f.exec(c))!==null)r.push(l[0]);let g=c.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);if(g)r.push(g[0]);let m=c.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);if(m)r.push(m[0])}if(n.preserveHead&&i){let c=[],f=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,l;while((l=f.exec(i[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(l[0]))continue;c.push(l[0])}if(c.length>0)r.unshift(`<!--${J}${Buffer.from(c.join(`
|
|
22
|
+
`),"utf8").toString("base64")}-->`)}let s=e.match(/<body\b[^>]*>/i),a=e.lastIndexOf("</body>");if(s&&a!==-1){let c=s.index+s[0].length,f=e.slice(c,a).trim();if(r.length>0)return r.join(`
|
|
23
23
|
`)+`
|
|
24
|
-
`+
|
|
25
|
-
`));return o=o.replace(/<body\b[^>]*>/i,""),o=o.replace(/<\/body\s*>/i,""),o.trim()}var N=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function I(t,n,e,r){if(!N.test(n))return!1;let i=n.slice(0,n.indexOf(">")+1),s=/\sdata-stx-owner="([^"]+)"/i.exec(i)?.[1];if(!s)return!0;let a=`data-stx-scope="${s}"`;for(let o=t.indexOf(a);o!==-1;o=t.indexOf(a,o+a.length))if(o>=e&&o<r)return!1;return!0}function
|
|
24
|
+
`+f;return f}let o=e;if(o=o.replace(/<!DOCTYPE\b[^>]*>/i,""),o=o.replace(/<html\b[^>]*>/i,""),o=o.replace(/<\/html\s*>/i,""),i)o=o.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,r.join(`
|
|
25
|
+
`));return o=o.replace(/<body\b[^>]*>/i,""),o=o.replace(/<\/body\s*>/i,""),o.trim()}var N=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function I(t,n,e,r){if(!N.test(n))return!1;let i=n.slice(0,n.indexOf(">")+1),s=/\sdata-stx-owner="([^"]+)"/i.exec(i)?.[1];if(!s)return!0;let a=`data-stx-scope="${s}"`;for(let o=t.indexOf(a);o!==-1;o=t.indexOf(a,o+a.length))if(o>=e&&o<r)return!1;return!0}function vo(t){return se(t)}function Z(t,n){let e=[],r=new Set;for(let i of ee(t,U)){if(i.start>=n.start&&i.start<n.end)continue;let s=i.token.match(/^<script\b((?:"[^"]*"|'[^']*'|[^'">])*)>/i)?.[1]??"",a=new Map;for(let f of s.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))a.set(f[1].toLowerCase(),f[2]??f[3]??f[4]??"");let o=a.get("src")?.trim(),c=a.get("type")?.trim().toLowerCase();if(!o||a.has("server")||c&&!["module","text/javascript","application/javascript"].includes(c))continue;if(a.has("data-stx-runtime")||a.has("data-stx-router")||/^\/_stx\/(?:runtime|router)(?:\.[a-f0-9]{16})?\.js(?:[?#]|$)/i.test(o))continue;if(I(t,i.token,n.start,n.end)||r.has(i.token))continue;r.add(i.token),e.push(i.token)}return e}function oe(t,n="main"){let e=t.trim(),r=[],i=[],s=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(s){let p=s[1],R=/<style\b[^>]*>[\s\S]*?<\/style>/gi,h;while((h=R.exec(p))!==null)r.push(h[0]);let d=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((h=d.exec(p))!==null){if(N.test(h[0])||h[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(h[0]))continue;i.push(h[0])}}let a=O(e,n);if(!a)return ye(t);let o=Z(e,a),c=new Set(o),{tagName:f,start:l,end:g}=a,m=e.slice(l,g).trim(),S=[],b=e.match(/<body\b[^>]*>/i),w=e.lastIndexOf("</body>");if(b&&b.index!==void 0&&w!==-1){let R=[[b.index+b[0].length,a.openIndex],[g+`</${f}>`.length,w]],h=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[d,C]of R){if(d>=C)continue;let L=e.slice(d,C),A;h.lastIndex=0;while((A=h.exec(L))!==null){if(I(e,A[0],l,g))continue;S.push(A[0])}}}let y=[];if(r.length>0)y.push(r.join(`
|
|
26
26
|
`));if(o.length>0)y.push(o.join(`
|
|
27
|
-
`));if(i.length>0)y.push(i.filter((
|
|
28
|
-
`));if(S.length>0)y.push(S.filter((
|
|
27
|
+
`));if(i.length>0)y.push(i.filter((p)=>!c.has(p)).join(`
|
|
28
|
+
`));if(S.length>0)y.push(S.filter((p)=>!c.has(p)).join(`
|
|
29
29
|
`));return y.push(m),y.join(`
|
|
30
|
-
`)}import k from"fs";import D from"path";function
|
|
31
|
-
export{ho,Oe,yo,se,T,bo,
|
|
30
|
+
`)}import k from"fs";import D from"path";function wo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function xo(t,n){let e=D.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function So(t){let n=D.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function _(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function Q(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Dr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function F(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Dr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await Q(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=tt(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function tt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(_(e,i.value,i))}}return n}function ko(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function Bt(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await et(t,n),a=Ue(r),o=Ve(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-webrqm20.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-nx8rf4qd.js"),{defaultConfig:m}=await import("./chunk-2927nax9.js"),S=r.streamBoundaries||{},b={...m,autoShell:!1},w=Object.keys(l).map((p)=>({id:p,render:async()=>{let R=typeof S[p]==="function"?await S[p]():void 0;return g(l[p],{...r,$boundary:R},t.sourceFile,b,new Set)}})),y=new Set(w.map((p)=>p.id));f=[...(f||[]).filter((p)=>!y.has(p.id)),...w]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:o}}async function et(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!as(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await F(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=tr(e);if(!c)return o;let f=o.indexOf("</head>");return f<0?c+o:o.slice(0,f)+c+o.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!as(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=x(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?Tt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(ni(t.html,s)),context:e,cookies:r.cookies}}
|
|
31
|
+
export{ho,Oe,yo,se,T,bo,Or,jn,ye,vo,oe,wo,xo,So,Dr,ko,Bt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ta,na}from"./chunk-8tq83fq7.js";import"./chunk-09zwhsf9.js";import"./chunk-ac6v3s3k.js";import"./chunk-xp7fxc6p.js";import"./chunk-ym1sb5bg.js";import"./chunk-ky1426s1.js";import"./chunk-5kh5ehfh.js";import"./chunk-07anexcg.js";import{ho}from"./chunk-je1as16r.js";import"./chunk-en7xxgtb.js";import"./chunk-h0a2s340.js";import"./chunk-ycj0342k.js";import"./chunk-6z3e1tyz.js";import"./chunk-sv5nvfmb.js";import"./chunk-0dfgefjv.js";import"./chunk-pbwk8tzz.js";import"./chunk-4pmgr32a.js";import"./chunk-wwj8zbzc.js";import"./chunk-0k5faspy.js";import"./chunk-qccgncp2.js";import"./chunk-kfwmqacd.js";import"./chunk-w3rmepwy.js";import"./chunk-6fc8vw2v.js";import"./chunk-s12bnv32.js";import"./chunk-1r1maqep.js";import"./chunk-mt9x626h.js";import"./chunk-2nehykbm.js";import"./chunk-qn8gdw21.js";import"./chunk-m417sp42.js";import"./chunk-wyn5rfzk.js";import"./chunk-nhd9m8h5.js";import"./chunk-521pe0hb.js";import"./chunk-117xss52.js";import"./chunk-bj29pwm0.js";import"./chunk-4pkpr5cg.js";import"./chunk-nh3svtvj.js";import"./chunk-ktyctev3.js";import{ve,un,dn,J,u,n,sr,A,o,pe}from"./chunk-n4e02qdz.js";import"./chunk-dm1qh2vq.js";import"./chunk-ah9xyss2.js";import"./chunk-sv08pd66.js";import"./chunk-2943qhdt.js";import"./chunk-vkc51n9m.js";import"./chunk-02qaqamv.js";import"./chunk-6m3me7yj.js";import"./chunk-dhq80e4r.js";import"./chunk-vpdx7qr3.js";import"./chunk-dvc15djp.js";import"./chunk-x552npae.js";import"./chunk-qdyp2zqf.js";export{sr as buildWebComponents,dn as cacheTemplate,un as checkCache,ho as classifyAllScripts,ta as createMiddleware,na as createRoute,A as defaultConfig,u as extractVariables,J as injectRouterScript,o as loadStxConfig,ve as processClientScript,n as processDirectives,pe as readMarkdownFile};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{W}from"./chunk-
|
|
2
|
+
import{W}from"./chunk-w6wtxj54.js";function g(e,t){let r={};for(let n of e)r[n]=W(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=W(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Ao(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=W(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var Ua=Ao;class Jt{rules=[];defaultValue="";addRule(e){let t=new Jt;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Jt;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Jt;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var Ul=new Jt;function Va(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>c.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
|
|
3
3
|
`)}catch{return""}})}function Wa(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>c.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
|
|
4
4
|
`)}catch{return""}})}function qa(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function Vl(e,t,r){let n=e;return n=Va(n,t,r),n=Wa(n,t,r),n=qa(n,t,r),n}export{Ao,Ua,Jt,Ul,Va,Wa,qa,Vl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{d}from"./chunk-yn2d8x8m.js";import{mkdir as w,writeFile as h}from"fs/promises";import{join as l}from"path";var f="https://api.iconify.design";async function D(){let e=await fetch(`${f}/collections`);if(!e.ok)throw Error(`Failed to fetch collections: ${e.statusText}`);return await e.json()}async function P(e,t){try{let c=d.resolve("@iconify/json"),r=`${`${c.substring(0,c.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`}/json/${e}.json`,s=Bun.file(r);if(await s.exists()){let a=await s.json();if(t&&t.length>0){let p={};for(let y of t)if(a.icons[y])p[y]=a.icons[y];return{...a,icons:p}}return a}}catch{}let n=t&&t.length>0?`${f}/${e}.json?icons=${t.join(",")}`:`${f}/${e}.json`,i=await fetch(n);if(!i.ok)throw Error(`Failed to fetch icons for ${e}: ${i.statusText}`);return await i.json()}function F(e,t=24,n=24){return{body:e.body,width:e.width||t,height:e.height||n,viewBox:`0 0 ${e.width||t} ${e.height||n}`}}function T(e,t){let n=u(e);return`import type { IconData } from '@stacksjs/iconify-core'
|
|
3
3
|
|
|
4
4
|
export const ${n}: IconData = ${JSON.stringify(t,null,2)}
|
|
5
5
|
|
|
@@ -44,7 +44,7 @@ const svg = \`<svg xmlns="http://www.w3.org/2000/svg" width="\${iconWidth}" heig
|
|
|
44
44
|
|
|
45
45
|
{!! svg !!}
|
|
46
46
|
`}function _(e){let t=new Set;return`// Icon data exports
|
|
47
|
-
${e.map((i)=>{let o=
|
|
47
|
+
${e.map((i)=>{let o=u(i);if(t.has(o)){let r=i.replace(/[^a-zA-Z0-9]/g,"_");if(/^[0-9]/.test(r))r=`_${r}`;o=r;let s=2;while(t.has(o))o=`${r}_${s}`,s++}return t.add(o),`export { default as ${o} } from './${i}.js'`}).join(`
|
|
48
48
|
`)}
|
|
49
49
|
|
|
50
50
|
export * from './types.js'
|
|
@@ -155,7 +155,7 @@ ${t.license?.url?`License: ${t.license.url}`:""}
|
|
|
155
155
|
|
|
156
156
|
- Icons: ${t.author?.name||"Iconify"}${t.author?.url?` (${t.author.url})`:""}
|
|
157
157
|
- Iconify: https://iconify.design/
|
|
158
|
-
`}function M(e,t,n){let i=n.length,c=n.slice(0,5).map(
|
|
158
|
+
`}function M(e,t,n){let i=n.length,c=n.slice(0,5).map(u),o=c.map((s)=>`${s.charAt(0).toUpperCase()}${s.slice(1)}Icon`),r=n.map((s)=>`- \`${u(s)}\``).join(`
|
|
159
159
|
`);return`# ${t.name}
|
|
160
160
|
|
|
161
161
|
> ${t.name} icons for stx from Iconify
|
|
@@ -338,14 +338,14 @@ You can also use the \`size\` property as a shorthand for setting both width and
|
|
|
338
338
|
You can also control icon size via CSS:
|
|
339
339
|
|
|
340
340
|
\`\`\`css
|
|
341
|
-
.${
|
|
341
|
+
.${u(e)}-icon {
|
|
342
342
|
width: 1em;
|
|
343
343
|
height: 1em;
|
|
344
344
|
}
|
|
345
345
|
\`\`\`
|
|
346
346
|
|
|
347
347
|
\`\`\`html
|
|
348
|
-
<${o[0]||"DraftsIcon"} class="${
|
|
348
|
+
<${o[0]||"DraftsIcon"} class="${u(e)}-icon" />
|
|
349
349
|
\`\`\`
|
|
350
350
|
|
|
351
351
|
## Available Icons
|
|
@@ -502,4 +502,4 @@ ${t.license?.url?`See [license details](${t.license.url}) for more information.`
|
|
|
502
502
|
- [Iconify documentation](https://iconify.design/docs/)
|
|
503
503
|
- [stx iconify integration guide](../../docs/iconify.md)
|
|
504
504
|
`}async function G(e,t,n,i){console.log(`
|
|
505
|
-
\uD83D\uDCE6 Generating package for ${e}...`);let o=(await D())[e];if(!o)throw Error(`Collection ${e} not found`);console.log(` Collection: ${o.name}`),console.log(` Total icons: ${o.total}`);let r=await P(e,n),s=Object.keys(r.icons);console.log(` Generating ${s.length} icons...`);let a=l(t,`iconify-${e}`),
|
|
505
|
+
\uD83D\uDCE6 Generating package for ${e}...`);let o=(await D())[e];if(!o)throw Error(`Collection ${e} not found`);console.log(` Collection: ${o.name}`),console.log(` Total icons: ${o.total}`);let r=await P(e,n),s=Object.keys(r.icons);console.log(` Generating ${s.length} icons...`);let a=l(t,`iconify-${e}`),p=l(a,"src");await w(p,{recursive:!0});let y=r.width||24,b=r.height||24;for(let m of s){let g=r.icons[m],I=F(g,y,b),z=T(m,I);await h(l(p,`${m}.ts`),z);let k=A(m,I);await h(l(p,`${m}-icon.stx`),k)}let v=_(s);await h(l(p,"index.ts"),v);let C=E(e);await h(l(p,"types.ts"),C);let S=N(e,o,s.length);await h(l(a,"package.json"),S);let x=U(e);await h(l(a,"build.ts"),x);let j=R(e,o,s.length);if(await h(l(a,"README.md"),j),i){let m=l(i,`iconify-${e}.md`),g=M(e,o,s);await w(i,{recursive:!0}),await h(m,g),console.log(` \u2713 Generated documentation in ${m}`)}console.log(` \u2713 Generated ${s.length} icons in ${a}`)}var B=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","let","static","yield","implements","interface","package","private","protected","public","await","eval","arguments"]);function u(e){let t=e.replace(/-([a-z0-9])/g,(n)=>n[1].toUpperCase());if(t=t.replace(/[^a-zA-Z0-9_$]/g,"_"),/^[0-9]/.test(t))t=`_${t}`;if(B.has(t))t=`${t}_`;return t}function W(e){let t=u(e);return t.charAt(0).toUpperCase()+t.slice(1)}export{D as fetchCollections,G as generatePackage};
|