@stacksjs/stx 0.2.503 → 0.2.504
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-0eptxhzy.js +2 -0
- package/dist/{chunk-4ssg2hn4.js → chunk-0gp4sj0v.js} +1 -1
- package/dist/chunk-0kj3qs23.js +2 -0
- package/dist/{chunk-m9nr12a1.js → chunk-0np4t9ka.js} +120 -120
- package/dist/{chunk-qmcmjdy7.js → chunk-133ggr0t.js} +7 -7
- package/dist/{chunk-8qdvhbv7.js → chunk-17fan751.js} +5 -5
- package/dist/chunk-18pxh9sv.js +2 -0
- package/dist/{chunk-b90y5phw.js → chunk-2242bx8y.js} +65 -65
- package/dist/{chunk-vs0ebfg5.js → chunk-2abv46yw.js} +1 -1
- package/dist/{chunk-7cbtcdqw.js → chunk-2etevws0.js} +2 -2
- package/dist/chunk-2h4bf7m4.js +2 -0
- package/dist/{chunk-z9fz5dby.js → chunk-2j04bc8c.js} +2 -2
- package/dist/chunk-37hm4er5.js +2 -0
- package/dist/{chunk-25m2wqsd.js → chunk-38mtn4ce.js} +3 -3
- package/dist/chunk-3c9t71pc.js +2 -0
- package/dist/{chunk-1mrn5s5z.js → chunk-3kxh9rsp.js} +1 -1
- package/dist/{chunk-vg9dyc4y.js → chunk-3y8ykqpx.js} +1 -1
- package/dist/{chunk-jwjggr91.js → chunk-3ynfz6h8.js} +2 -2
- package/dist/{chunk-0egg3666.js → chunk-49p5j9ab.js} +4 -4
- package/dist/{chunk-rhrv2j36.js → chunk-4hz4g5ym.js} +2 -2
- package/dist/{chunk-ckrpk6ak.js → chunk-5c1qesrs.js} +1 -1
- package/dist/{chunk-b77v56fz.js → chunk-5cyz97t4.js} +7 -7
- package/dist/{chunk-tdetcthb.js → chunk-5kq996qy.js} +1 -1
- package/dist/chunk-5q27xq7w.js +2 -0
- package/dist/{chunk-802qf0vz.js → chunk-5q9rmcp7.js} +1 -1
- package/dist/chunk-5yrn6whx.js +2 -0
- package/dist/chunk-667d6fz8.js +2 -0
- package/dist/{chunk-1erc0vrb.js → chunk-6k4f583z.js} +2 -2
- package/dist/{chunk-40jd0b4h.js → chunk-78yx6xxn.js} +1 -1
- package/dist/{chunk-2pph3dh0.js → chunk-798epzq5.js} +1 -1
- package/dist/chunk-7dmrxhq7.js +2 -0
- package/dist/{chunk-yvt8zszz.js → chunk-81byredt.js} +1 -1
- package/dist/{chunk-qhnpc3ac.js → chunk-88xqy2b9.js} +22 -22
- package/dist/{chunk-cp7hph6f.js → chunk-8xpyzcq2.js} +1 -1
- package/dist/chunk-9836wtag.js +2 -0
- package/dist/chunk-9kt6g57t.js +2 -0
- package/dist/{chunk-81t6zr3m.js → chunk-a5c75hxe.js} +2 -2
- package/dist/{chunk-93sr9q8g.js → chunk-a771dfsg.js} +1 -1
- package/dist/{chunk-h0sd5cda.js → chunk-amd52bnv.js} +5 -5
- package/dist/{chunk-szry3s17.js → chunk-azza6dcr.js} +3 -3
- package/dist/chunk-b3nz1qmj.js +2 -0
- package/dist/chunk-bcgfg3x0.js +2 -0
- package/dist/{chunk-gvkfydq5.js → chunk-bt51kf9z.js} +1 -1
- package/dist/{chunk-2kyfaa0p.js → chunk-c322rrge.js} +2 -2
- package/dist/chunk-cctb8fnj.js +2 -0
- package/dist/chunk-cpj9b887.js +2 -0
- package/dist/{chunk-bv7bsdfe.js → chunk-czmw5xsd.js} +2 -2
- package/dist/chunk-d161ndyz.js +2 -0
- package/dist/chunk-d5x1t498.js +2 -0
- package/dist/{chunk-b5mcvm6y.js → chunk-dn9fxpwt.js} +6 -6
- package/dist/chunk-dne8n6h3.js +3 -0
- package/dist/{chunk-tvag2s5a.js → chunk-eacd5755.js} +1 -1
- package/dist/{chunk-8fb1mqw1.js → chunk-ej46bkaw.js} +1 -1
- package/dist/chunk-f6n6nrdq.js +2 -0
- package/dist/{chunk-4mrgy3ve.js → chunk-fd6abk20.js} +4 -4
- package/dist/{chunk-1v86h5vn.js → chunk-fesb4h31.js} +2 -2
- package/dist/chunk-fgvdq014.js +2 -0
- package/dist/{chunk-1hpttjgq.js → chunk-fh5rp6wb.js} +1 -1
- package/dist/{chunk-vp827ah7.js → chunk-g7wgpys2.js} +4 -4
- package/dist/{chunk-33snwgdy.js → chunk-gxs2p0y7.js} +3 -3
- package/dist/{chunk-z6nm6rf1.js → chunk-h6z4s5p3.js} +1 -1
- package/dist/chunk-hzjk2027.js +2 -0
- package/dist/{chunk-z9tvn738.js → chunk-jcmgj8kk.js} +1 -1
- package/dist/{chunk-zqxqdns1.js → chunk-jt842kx3.js} +1 -1
- package/dist/chunk-jtwx2xte.js +2 -0
- package/dist/chunk-k0zadypg.js +2 -0
- package/dist/{chunk-dve4q9tg.js → chunk-kbhm1wqt.js} +3 -3
- package/dist/{chunk-258qj7pt.js → chunk-km9g9drp.js} +1 -1
- package/dist/chunk-kr5ap3qn.js +2 -0
- package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
- package/dist/chunk-kxt6xb4j.js +2 -0
- package/dist/chunk-kxvtyh05.js +2 -0
- package/dist/chunk-mba6khev.js +2 -0
- package/dist/{chunk-vtn0gmen.js → chunk-mfcdbqvd.js} +8 -8
- package/dist/{chunk-298s08st.js → chunk-n34kagea.js} +2 -2
- package/dist/{chunk-c8psbk2e.js → chunk-p4gbvge6.js} +1 -1
- package/dist/chunk-pykeaf4h.js +2 -0
- package/dist/chunk-qcj12mtw.js +2 -0
- package/dist/chunk-qky9zfvx.js +2 -0
- package/dist/{chunk-4c1afy15.js → chunk-qv57r0fa.js} +1 -1
- package/dist/chunk-rnnead1w.js +2 -0
- package/dist/chunk-rrvfgmqb.js +2 -0
- package/dist/chunk-s4c8vf27.js +2 -0
- package/dist/chunk-srhgfsz3.js +2 -0
- package/dist/{chunk-stvqwzen.js → chunk-szkqmwjg.js} +2 -2
- package/dist/chunk-t1x0x5sw.js +2 -0
- package/dist/{chunk-hqvdm4h9.js → chunk-t77pz252.js} +1 -1
- package/dist/chunk-t7djn7zd.js +2 -0
- package/dist/{chunk-tse7jzmz.js → chunk-tf239jvd.js} +1 -1
- package/dist/{chunk-gzt3ghgq.js → chunk-tkagcknf.js} +2 -2
- package/dist/chunk-txd6fq1x.js +2 -0
- package/dist/{chunk-f0prq6yw.js → chunk-vc1m5fr9.js} +1 -1
- package/dist/{chunk-jbvg29t0.js → chunk-vftdacyb.js} +1 -1
- package/dist/{chunk-hktvv0hd.js → chunk-vtxzaj1h.js} +2 -2
- package/dist/chunk-w78v0xek.js +45 -0
- package/dist/chunk-wrghqec5.js +2 -0
- package/dist/{chunk-xfxrh6vx.js → chunk-wy36z6qp.js} +1 -1
- package/dist/{chunk-d19vgjjt.js → chunk-x81vcxzs.js} +2 -2
- package/dist/{chunk-15w4adyd.js → chunk-x96ardq0.js} +1 -1
- package/dist/{chunk-rmavqxd8.js → chunk-xd4zvm4x.js} +2 -2
- package/dist/{chunk-x8mp9yvn.js → chunk-xemsypk7.js} +4 -4
- package/dist/{chunk-v7vkqg8f.js → chunk-xsc9zbaj.js} +2 -2
- package/dist/{chunk-71bbv43t.js → chunk-xx2pk2ay.js} +3 -3
- package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
- package/dist/{chunk-3mynjdqr.js → chunk-ygetbydb.js} +3 -3
- package/dist/chunk-yn2d8x8m.js +3 -0
- package/dist/{chunk-mq7vvaf4.js → chunk-ywv2838m.js} +1 -1
- package/dist/cli.js +44 -44
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/bridge/protocol.d.ts +3 -0
- package/dist/native/cli.d.ts +1 -0
- package/dist/native/cli.js +7 -2
- package/dist/native/compiler/bundle.d.ts +1 -0
- package/dist/native/compiler/bundle.js +27 -7
- package/dist/native/runtime/craft-bridge.js +9 -1
- package/dist/native/runtime/craft.d.ts +2 -0
- package/dist/native/runtime/shared-screen.d.ts +21 -0
- package/dist/native/runtime/shared-screen.js +43 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-0adrp7qd.js +0 -2
- package/dist/chunk-0vdxchfw.js +0 -2
- package/dist/chunk-2gr5zcm3.js +0 -2
- package/dist/chunk-379nn8yc.js +0 -2
- package/dist/chunk-3vqabd10.js +0 -2
- package/dist/chunk-490f2x2r.js +0 -2
- package/dist/chunk-4j2ej7er.js +0 -2
- package/dist/chunk-4rmdngzw.js +0 -2
- package/dist/chunk-52saa2nj.js +0 -2
- package/dist/chunk-69dc3tyz.js +0 -2
- package/dist/chunk-6v3p6cx1.js +0 -2
- package/dist/chunk-78vfptph.js +0 -2
- package/dist/chunk-7e6sxdp6.js +0 -2
- package/dist/chunk-7wxmsv41.js +0 -2
- package/dist/chunk-9mh1qq3g.js +0 -2
- package/dist/chunk-9z70zv10.js +0 -33
- package/dist/chunk-b0bgprzs.js +0 -2
- package/dist/chunk-c7cajwd2.js +0 -2
- package/dist/chunk-cg8hg6cs.js +0 -3
- package/dist/chunk-en0atzsp.js +0 -2
- package/dist/chunk-fxppbahx.js +0 -2
- package/dist/chunk-hhj1txvj.js +0 -2
- package/dist/chunk-j2q2pp0x.js +0 -2
- package/dist/chunk-jbj6xh7f.js +0 -3
- package/dist/chunk-jh385m2w.js +0 -2
- package/dist/chunk-kxg9q64a.js +0 -2
- package/dist/chunk-mdfrm5hv.js +0 -2
- package/dist/chunk-nfffn3s0.js +0 -2
- package/dist/chunk-nw7qvyek.js +0 -2
- package/dist/chunk-ny64ezsj.js +0 -2
- package/dist/chunk-qjba655t.js +0 -2
- package/dist/chunk-qjxxd4a0.js +0 -2
- package/dist/chunk-qsy7phd4.js +0 -2
- package/dist/chunk-rfq1jfhf.js +0 -2
- package/dist/chunk-rr41gk8b.js +0 -2
- package/dist/chunk-snyq0jj6.js +0 -2
- package/dist/chunk-sybzayv3.js +0 -2
- package/dist/chunk-v8m2khkq.js +0 -2
- package/dist/chunk-vbhykx9z.js +0 -2
- package/dist/chunk-xk2mwk61.js +0 -2
- package/dist/chunk-zbzmfqmk.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
|
|
3
|
-
`),n;try{let{bundleClientScript:t}=await import("./chunk-
|
|
3
|
+
`),n;try{let{bundleClientScript:t}=await import("./chunk-cctb8fnj.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-0fad6jf4.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-bcgfg3x0.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-2grygc4b.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
|
|
4
4
|
`)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Io}from"./chunk-
|
|
2
|
+
import{Io}from"./chunk-17fan751.js";import{d}from"./chunk-yn2d8x8m.js";var vd=`
|
|
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: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function
|
|
934
|
+
`.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function wd(){return!1}function xd(e,r={}){let a=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(a,(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 ko(t)})}function Co(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let a=ko(r);if(e.includes("</head>"))return e.replace("</head>",`${a}
|
|
935
935
|
</head>`);if(e.includes("<body"))return e.replace(/(<body[^>]*>)/,`$1
|
|
936
936
|
${a}`);return a+e}var zr={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,r)=>{let a=e.checked?"checked":"",i=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
937
937
|
<input type="checkbox" class="craft-checkbox" ${a} ${i}>
|
|
@@ -947,7 +947,7 @@ ${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
947
947
|
</details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:(e,r)=>{let a=e.variant||"info",i=e.title||"";return`<div class="craft-alert craft-alert-${a}" role="alert">
|
|
948
948
|
${i?`<div class="craft-alert-title">${i}</div>`:""}
|
|
949
949
|
<div class="craft-alert-content">${r}</div>
|
|
950
|
-
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(e,r)=>{let a=e.content||"",i=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${a}" data-position="${i}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:j},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:H},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:V},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:W},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let a=e.value||"",i=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${a}" min="${i}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}}
|
|
950
|
+
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(e,r)=>{let a=e.content||"",i=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${a}" data-position="${i}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:j},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:H},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:V},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:W},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let a=e.value||"",i=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${a}" min="${i}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},Eo=`
|
|
951
951
|
<style id="craft-component-styles">
|
|
952
952
|
/* Craft Component Base Styles */
|
|
953
953
|
.craft-button {
|
|
@@ -1365,7 +1365,7 @@ ${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
</style>
|
|
1368
|
-
`,
|
|
1368
|
+
`,Sd=`
|
|
1369
1369
|
<script id="craft-component-runtime">
|
|
1370
1370
|
(function() {
|
|
1371
1371
|
if (window.__stxCraftComponentRuntime) return;
|
|
@@ -1469,7 +1469,7 @@ ${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1469
1469
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
1470
1470
|
})();
|
|
1471
1471
|
</script>
|
|
1472
|
-
`;function
|
|
1472
|
+
`;function $o(e,r={}){let{classPrefix:a="craft"}=r;if(!e.includes("craft-component-styles"))if(e.includes("</head>"))e=e.replace("</head>",`${`
|
|
1473
1473
|
<style id="craft-component-styles">
|
|
1474
1474
|
/* Craft Component Base Styles */
|
|
1475
1475
|
.craft-button {
|
|
@@ -2934,17 +2934,17 @@ ${a}`);return a+e}var zr={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(),r,a)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>R("sidebar",s,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>R(s,t,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,n)=>R(s,t,n.trim(),r,a)),e}function R(e,r,a,i,s){let t=i.components?.[e]||zr[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${a}</div>`;let n=A(r),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,a);let
|
|
2937
|
+
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,s,t)=>R("sidebar",s,t.trim(),r,a)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>R("sidebar",s,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>R(s,t,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,n)=>R(s,t,n.trim(),r,a)),e}function R(e,r,a,i,s){let t=i.components?.[e]||zr[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${a}</div>`;let n=A(r),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,a);let l=ee(n,t,c);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${l}>`;return`<${t.fallbackTag} ${l}>${a}</${t.fallbackTag}>`}function A(e){let r={},a=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,i;while((i=a.exec(e))!==null){let[s,t,n,c]=i,l=n??c;if(s.startsWith(":"))r[t]=l;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=l;else if(l===void 0)r[t]=!0;else r[t]=l}return r}function j(e,r){let a=I(String(e.id||`craft-sidebar-${K(r||JSON.stringify(e))}`)),i=Q(e.spaces)||Y(r),s=i.length?[]:X(e.sections)||F(r),t=String(e.selectedSpace||i[0]?.id||""),n=i.find((g)=>g.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:a,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"),p=Number(e.width||e.sidebarWidth||286),u=e.native===!1||e.native==="false"?"false":"true",x=l.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C(l.searchPlaceholder)}"></div>`:"",b;if(i.length)b=G(i,t,c);else if(s.length)b=s.map((g)=>D(g,c)).join("");else b=r;return`<aside class="${h(f)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${h(a)}" data-native="${u}" style="--craft-sidebar-width:${p}px">
|
|
2938
2938
|
${x}
|
|
2939
2939
|
${b}
|
|
2940
2940
|
</aside>
|
|
2941
|
-
<script type="application/json" data-craft-sidebar-config="${h(a)}">${Z(
|
|
2941
|
+
<script type="application/json" data-craft-sidebar-config="${h(a)}">${Z(l)}</script>`}function H(e,r){let a=I(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${h(a)}">
|
|
2942
2942
|
${e.label?`<div class="craft-sidebar-space-title">${C(String(e.label))}</div>`:""}
|
|
2943
2943
|
${r}
|
|
2944
2944
|
</section>`}function V(e,r){let a=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
|
${a?`<div class="craft-sidebar-section-title">${C(a)}</div>`:""}
|
|
2946
2946
|
${r}
|
|
2947
|
-
</section>`}function W(e,r){let a={id:String(e.id||I(String(e.label||r||"item"))),label:String(e.label||r||""),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 O(a,String(e.selected||"")==="true")}function F(e){let r=[],a=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,i;while((i=a.exec(e))!==null){let s=A(i[1]||""),t=i[2]||"",n=String(s.id||I(String(s.header||s.title||`section-${r.length+1}`))),c=String(s.header||s.title||n),
|
|
2947
|
+
</section>`}function W(e,r){let a={id:String(e.id||I(String(e.label||r||"item"))),label:String(e.label||r||""),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 O(a,String(e.selected||"")==="true")}function F(e){let r=[],a=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,i;while((i=a.exec(e))!==null){let s=A(i[1]||""),t=i[2]||"",n=String(s.id||I(String(s.header||s.title||`section-${r.length+1}`))),c=String(s.header||s.title||n),l=J(t);r.push({id:n,header:c,title:c,items:l})}return r}function J(e){let r=[],a=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,i;while((i=a.exec(e))!==null){let s=A(i[1]||""),t=String(s.label||(i[2]||"").replace(/<[^>]*>/g,"").trim()),n=String(s.id||I(t||`item-${r.length+1}`));r.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 r}function Y(e){let r=[],a=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,i;while((i=a.exec(e))!==null){let s=A(i[1]||""),t=i[2]||"",n=String(s.label||s.title||`Space ${r.length+1}`);r.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:F(t)})}return r}function Q(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function G(e,r,a){let i=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${h(t.id)}" data-selected="${t.id===r?"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===r?"true":"false"}">
|
|
2948
2948
|
${t.label?`<div class="craft-sidebar-space-title">${C(t.label)}</div>`:""}
|
|
2949
2949
|
${t.sections.map((n)=>D(n,a)).join("")}
|
|
2950
2950
|
</section>`).join("")}</div>
|
|
@@ -2955,16 +2955,16 @@ ${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2955
2955
|
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${h(e.icon)}"${a}></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 r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>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,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.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 r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>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,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.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 kd(e,r){zr[e]=r}function Cd(){return{...zr}}import{existsSync as z,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 re}from"child_process";import{tmpdir as M,homedir as q,platform as ae}from"os";async function _o(e){let r=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 a=e.target||P(),i=e.format||ue(a),s=e.output||o(process.cwd(),"dist","native");if(!z(s))v(s,{recursive:!0});let t=await Io(e.input,{context:e.context,options:{isDev:!1}});if(t=Co(t,{debug:e.verbose}),t=$o(t),!t.includes("craft-component-styles")){if(t.includes("</head>"))t=t.replace("</head>",`${Eo}
|
|
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:a,format:i,error:"Craft binary not found. Please install Craft or specify craftPath."};if(e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${a}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${l}`);let f;switch(a){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:a,format:i,error:`Unsupported target: ${a}`}}return f.duration=Date.now()-r,f}catch(a){return{success:!1,target:e.target||P(),format:e.format||"app",error:a.message,duration:Date.now()-r}}}async function ie(e,r,a,i,s,t,n){let c=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,l=o(i,`${r}.app`),f=o(l,"Contents"),p=o(f,"MacOS"),u=o(f,"Resources");v(p,{recursive:!0}),v(u,{recursive:!0});let x=o(u,"index.html");await Bun.write(x,e);let b="";if(t.sidebar?.enabled&&t.sidebar?.config)b=o(u,"sidebar-config.json"),await Bun.write(b,JSON.stringify(t.sidebar.config));let g=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",m=t.menubarOnly??t.systemTray;if((t.bundleStyle||(await se(n)?"executable":"launcher"))==="executable"){let S=o(p,r);k(n,S),T(S,493);let w={html:"index.html",title:t.window?.title||r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(m)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(u,"craft.json"),`${JSON.stringify(w,null,2)}
|
|
2960
2960
|
`)}else{let S=o(p,"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||r}"`,`--width ${t.window?.width||1200}`,`--height ${t.window?.height||800}`,m?"--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
|
-
`,N=o(p,r);await Bun.write(N,U),T(N,493)}let B=Boolean(t.icon&&await Bun.file(t.icon).exists());if(B)k(t.icon,o(
|
|
2967
|
-
${i}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[n,c,
|
|
2966
|
+
`,N=o(p,r);await Bun.write(N,U),T(N,493)}let B=Boolean(t.icon&&await Bun.file(t.icon).exists());if(B)k(t.icon,o(u,"AppIcon.icns"));let L={CFBundleExecutable:r,CFBundleIdentifier:c,CFBundleName:r,CFBundleDisplayName:r,CFBundleShortVersionString:a,CFBundleVersion:a,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.menubarOnly??Boolean(t.systemTray),...B?{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,`${r}-${a}.dmg`),w=await pe(l,S,r);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 r=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[a,i]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]);await r.exited;let t=`${a}
|
|
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 _(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(([a,i])=>{let s=typeof i==="boolean"?`<${i}/>`:typeof i=
|
|
|
2973
2973
|
`)}
|
|
2974
2974
|
</dict>
|
|
2975
2975
|
</plist>
|
|
2976
|
-
`}async function oe(e,r,a,i,s,t,n){let c=o(i,r);v(c,{recursive:!0});let
|
|
2976
|
+
`}async function oe(e,r,a,i,s,t,n){let c=o(i,r);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||r}" ^
|
|
@@ -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,`${r}.bat`),
|
|
2984
|
+
`;if(await Bun.write(o(c,`${r}.bat`),f),s==="zip"){let p=o(i,`${r}-${a}-windows.zip`),u=await be(c,p);if(!u.success)return{success:!1,target:"windows",format:"zip",error:u.error};return{success:!0,target:"windows",format:"zip",outputPath:p}}return{success:!0,target:"windows",format:"app",outputPath:c}}async function ce(e,r,a,i,s,t,n){let c=o(i,r);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 p=`#!/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
|
+
`,u=o(c,r.toLowerCase());await Bun.write(u,p),T(u,493);let x=`[Desktop Entry]
|
|
2994
2994
|
Type=Application
|
|
2995
2995
|
Name=${r}
|
|
2996
|
-
Exec=${
|
|
2996
|
+
Exec=${u}
|
|
2997
2997
|
Terminal=false
|
|
2998
2998
|
Categories=Utility;
|
|
2999
2999
|
`;if(await Bun.write(o(c,`${r.toLowerCase()}.desktop`),x),s==="deb"){let b=o(i,`${r.toLowerCase()}_${a}_amd64.deb`),g=await ge(c,b,r,a,t);if(!g.success)return{success:!1,target:"linux",format:"deb",error:g.error};return{success:!0,target:"linux",format:"deb",outputPath:b}}if(s==="appimage"){let b=o(i,`${r}-${a}-x86_64.AppImage`),g=await me(c,b,r,t);if(!g.success)return{success:!1,target:"linux",format:"appimage",error:g.error};return{success:!0,target:"linux",format:"appimage",outputPath:b}}return{success:!0,target:"linux",format:"app",outputPath:c}}async function de(e,r,a,i,s,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${r}' to create an iOS project.`}}async function le(e,r,a,i,s,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${r}' 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(q(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),o(q(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",o(q(),".local/bin/craft"),o(process.env.LOCALAPPDATA||"","craft","craft.exe"),o(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let r of e)if(await Bun.file(r).exists())return r;try{let a=re("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
|
|
3000
|
-
`)[0];if(a&&await Bun.file(a).exists())return a}catch{}return null}function P(){switch(ae()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function ue(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 pe(e,r,a){return new Promise((i)=>{let s=E("hdiutil",["create","-volname",a,"-srcfolder",e,"-ov","-format","UDZO",r]);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,r){return new Promise((a)=>{let i=E("zip",["-r",r,"."],{cwd:e});i.on("close",(s)=>{if(s===0)a({success:!0});else a({success:!1,error:`zip exited with code ${s}`})}),i.on("error",(s)=>{a({success:!1,error:s.message})})})}async function ge(e,r,a,i,s){return new Promise((t)=>{try{let n=o(M(),`stx-deb-${Date.now()}`),c=o(n,"DEBIAN"),
|
|
3001
|
-
exec /usr/share/${a.toLowerCase()}/${a.toLowerCase()} "$@"`;
|
|
3000
|
+
`)[0];if(a&&await Bun.file(a).exists())return a}catch{}return null}function P(){switch(ae()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function ue(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 pe(e,r,a){return new Promise((i)=>{let s=E("hdiutil",["create","-volname",a,"-srcfolder",e,"-ov","-format","UDZO",r]);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,r){return new Promise((a)=>{let i=E("zip",["-r",r,"."],{cwd:e});i.on("close",(s)=>{if(s===0)a({success:!0});else a({success:!1,error:`zip exited with code ${s}`})}),i.on("error",(s)=>{a({success:!1,error:s.message})})})}async function ge(e,r,a,i,s){return new Promise((t)=>{try{let n=o(M(),`stx-deb-${Date.now()}`),c=o(n,"DEBIAN"),l=o(n,"usr","bin"),f=o(n,"usr","share","applications"),p=o(n,"usr","share",a.toLowerCase());v(c,{recursive:!0}),v(l,{recursive:!0}),v(f,{recursive:!0}),v(p,{recursive:!0});let u=d("fs").readdirSync(e);for(let m of u)k(o(e,m),o(p,m));let x=`#!/bin/bash
|
|
3001
|
+
exec /usr/share/${a.toLowerCase()}/${a.toLowerCase()} "$@"`;d("fs").writeFileSync(o(l,a.toLowerCase()),x),T(o(l,a.toLowerCase()),493);let b=`Package: ${a.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||a}
|
|
3009
|
-
`;
|
|
3009
|
+
`;d("fs").writeFileSync(o(c,"control"),b);let g=E("dpkg-deb",["--build",n,r]);g.on("close",(m)=>{if(d("fs").rmSync(n,{recursive:!0,force:!0}),m===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${m}`})}),g.on("error",(m)=>{d("fs").rmSync(n,{recursive:!0,force:!0}),t({success:!1,error:m.message})})}catch(n){t({success:!1,error:n.message})}})}async function me(e,r,a,i){return new Promise((s)=>{try{let t=o(M(),`stx-appimage-${Date.now()}`),n=o(t,`${a}.AppDir`),c=o(n,"usr"),l=o(c,"bin"),f=o(c,"share");v(l,{recursive:!0}),v(f,{recursive:!0});let p=o(f,a.toLowerCase());v(p,{recursive:!0});let u=d("fs").readdirSync(e);for(let y of u)k(o(e,y),o(p,y));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/${a.toLowerCase()}/${a.toLowerCase()}" "$@"
|
|
3014
|
-
`;
|
|
3014
|
+
`;d("fs").writeFileSync(o(n,"AppRun"),x),T(o(n,"AppRun"),493);let b=`[Desktop Entry]
|
|
3015
3015
|
Type=Application
|
|
3016
3016
|
Name=${a}
|
|
3017
3017
|
Exec=${a.toLowerCase()}
|
|
3018
3018
|
Terminal=false
|
|
3019
3019
|
Categories=Utility;
|
|
3020
3020
|
Icon=${a.toLowerCase()}
|
|
3021
|
-
`;
|
|
3022
|
-
export{
|
|
3021
|
+
`;d("fs").writeFileSync(o(n,`${a.toLowerCase()}.desktop`),b);let g=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,`${a.toLowerCase()}.png`),g),i.icon&&z(i.icon))k(i.icon,o(n,`${a.toLowerCase()}.png`));let m=E("appimagetool",[n,r],{env:{...process.env,ARCH:"x86_64"}});m.on("close",(y)=>{if(d("fs").rmSync(t,{recursive:!0,force:!0}),y===0)T(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${y}. Install from https://appimage.github.io/appimagetool/`})}),m.on("error",(y)=>{d("fs").rmSync(t,{recursive:!0,force:!0}),s({success:!1,error:`appimagetool not found: ${y.message}`})})}catch(t){s({success:!1,error:t.message})}})}function To(){return[P()]}function Ro(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:_o,getAvailableTargets:To,getAvailableFormats:Ro,detectPlatform:P},Ed=he;
|
|
3022
|
+
export{vd,ko,wd,xd,Co,zr,Eo,Sd,$o,kd,Cd,_o,To,Ro,Ed};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V}from"./chunk-
|
|
2
|
+
import{V}from"./chunk-x81vcxzs.js";function g(e,t){let r={};for(let n of e)r[n]=V(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=V(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 R(e,t){let r={};for(let n of t)r[n]=e[n];return r}function xo(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=V(!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 w(i){return async(d)=>{d?.preventDefault?.();for(let v of r)o[v]=!0;if(await l())await i(R(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:w}}var Ia=xo;class Wt{rules=[];defaultValue="";addRule(e){let t=new Wt;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 Wt;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 Wt;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 Dl=new Wt;function Da(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 Oa(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 Ma(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 Ol(e,t,r){let n=e;return n=Da(n,t,r),n=Oa(n,t,r),n=Ma(n,t,r),n}export{xo,Ia,Wt,Dl,Da,Oa,Ma,Ol};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{De,Kt,sd}from"./chunk-38mtn4ce.js";import{V,Dn,Xt,jr,Br,On,od,id,ad,Gt,Jt,Fr,Mn,cd}from"./chunk-x81vcxzs.js";import"./chunk-xsc9zbaj.js";export{jr as batch,sd as default,Dn as derived,Xt as effect,De as generateSignalsRuntime,Kt as generateSignalsRuntimeDev,Jt as isDerived,Gt as isSignal,On as onDestroy,Br as onMount,Mn as peek,ad as pendingLifecycleCounts,id as runDestroyCallbacks,od as runMountCallbacks,V as state,Fr as untrack,cd as useOptimistic};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zc}from"./chunk-78yx6xxn.js";import"./chunk-0np4t9ka.js";import"./chunk-azza6dcr.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-a5c75hxe.js";import"./chunk-6k4f583z.js";import"./chunk-133ggr0t.js";import"./chunk-5cyz97t4.js";import"./chunk-798epzq5.js";import"./chunk-d4k4nyj0.js";import"./chunk-xsc9zbaj.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{Zc as startInteractive};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_t,C}from"./chunk-
|
|
2
|
+
import{_t,C}from"./chunk-6k4f583z.js";import m from"fs";import e from"path";async function dn(r,o,i){if(r.__stx_runtime_config)return;let n=_t();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-hzjk2027.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Cs(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
6
6
|
`)}
|
|
7
|
-
export{
|
|
7
|
+
export{dn,Cs};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{M,ce}from"./chunk-
|
|
2
|
+
import{M,ce}from"./chunk-0np4t9ka.js";import{de,C,Xe}from"./chunk-6k4f583z.js";import{Qe,G,ke}from"./chunk-xd4zvm4x.js";import{Ae,ne,_,re,fo,Er,go,Ot}from"./chunk-mfcdbqvd.js";import{Kr}from"./chunk-fd6abk20.js";import{Mt}from"./chunk-2etevws0.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ue(t){if(!t)return null;let e=pe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function le(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function It(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=ue(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),le(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:me}=globalThis.Bun;class q{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ne(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var fe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Qc(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=fo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Mt(r.routeRules),f=new q,h=Kr(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Xe(i.html,m);b.set(n.pattern,i),v.set(n.pattern,ke(i.html)),E.set(n.pattern,ce(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Xe(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=me({port:o,async fetch(n){return It(n,await de(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=fe[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Qe(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Ae}}})}}let d=Er(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await Ot(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return go(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-37hm4er5.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=ke(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ce(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=ke(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ce(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),Y)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
3
|
export{It,Qc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{$e,_e,Te}from"./chunk-czmw5xsd.js";import"./chunk-xsc9zbaj.js";import"./chunk-d4k4nyj0.js";import{u}from"./chunk-0np4t9ka.js";import"./chunk-798epzq5.js";import"./chunk-c57j92td.js";import"./chunk-xd4zvm4x.js";import"./chunk-5cyz97t4.js";import"./chunk-133ggr0t.js";import"./chunk-kp4mzspk.js";import"./chunk-6k4f583z.js";import"./chunk-a5c75hxe.js";import"./chunk-e6y6s7q8.js";import{it,gr,at,Vs,Ee,Us,mr,ct,qs,lt}from"./chunk-c322rrge.js";import"./chunk-azza6dcr.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()=>{Us("Config file changed, restarting...");try{await e.onChange()}catch(p){Ee(`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:dt(),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 dt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var pt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,pt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,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:ut(),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 ut(){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-wrghqec5.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-wrghqec5.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 ct(t);_e(t,r);let s=lt(t.config,r);Te(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),
|
|
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 ct(t);_e(t,r);let s=lt(t.config,r);Te(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=qs(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await ct(t);_e(t,m);let f=lt(t.config,m);if(Te(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={}){it();let e=await
|
|
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":mr();break;case"o":try{let{exec:
|
|
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={}){it();let e=await $e({mode:"dev"});if(!e.config.enabled){Ee("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}),at(e.storyFiles.length),gr(s.url),mr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await $e({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":mr();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{Vs("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),it(),at(e.storyFiles.length),gr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
|