@stacksjs/stx 0.2.785 → 0.2.787
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-bj1dmqa1.js → chunk-0jp3tt5c.js} +1 -1
- package/dist/{chunk-cfpw4c6b.js → chunk-0r61tkfe.js} +2 -2
- package/dist/chunk-0s25gyy5.js +2 -0
- package/dist/{chunk-m4mpyq3d.js → chunk-14ft0zc7.js} +3 -3
- package/dist/chunk-1brkqd5f.js +2 -0
- package/dist/chunk-1pdaqca9.js +2 -0
- package/dist/{chunk-9tec9eap.js → chunk-1y9ez7nz.js} +2 -2
- package/dist/{chunk-k0aejzg9.js → chunk-2p4yad7w.js} +4 -4
- package/dist/chunk-2scyqqt3.js +2 -0
- package/dist/{chunk-x27rzb5w.js → chunk-2v75eyf8.js} +1 -1
- package/dist/chunk-2vxh8b8g.js +2 -0
- package/dist/chunk-33na85q2.js +2 -0
- package/dist/{chunk-qby3e5nm.js → chunk-3gn1t0pa.js} +29 -29
- package/dist/chunk-3n03m9w0.js +2 -0
- package/dist/chunk-3t4t655h.js +2 -0
- package/dist/{chunk-3ywnsdha.js → chunk-40ambk0h.js} +4 -4
- package/dist/chunk-43ynckvh.js +2 -0
- package/dist/chunk-44bm0pty.js +2 -0
- package/dist/chunk-498286bb.js +2 -0
- package/dist/{chunk-e1gxykm8.js → chunk-4s5q1aea.js} +4 -4
- package/dist/chunk-4v22nj67.js +2 -0
- package/dist/chunk-549zk2p7.js +2 -0
- package/dist/{chunk-ra8f8sm2.js → chunk-59tbk9qj.js} +4 -4
- package/dist/{chunk-w9d18r1t.js → chunk-5a92srn2.js} +1 -1
- package/dist/{chunk-cz8mka1b.js → chunk-5j619xgb.js} +2 -2
- package/dist/chunk-5pgv8jh1.js +2 -0
- package/dist/chunk-699t603m.js +2 -0
- package/dist/chunk-6f6xqzhb.js +2 -0
- package/dist/{chunk-r1jzbqr3.js → chunk-6v4b0xc1.js} +5 -5
- package/dist/{chunk-ya150593.js → chunk-6w935vyf.js} +2 -2
- package/dist/{chunk-bgc2fm73.js → chunk-74rf78w8.js} +2 -2
- package/dist/chunk-76ngpa25.js +2 -0
- package/dist/{chunk-gm9cag4s.js → chunk-7gvaz6ye.js} +3 -3
- package/dist/{chunk-et1vz3wd.js → chunk-7pk3t82j.js} +2 -2
- package/dist/{chunk-rzb6bdby.js → chunk-7wkz9sz5.js} +6 -6
- package/dist/chunk-8pphy0p1.js +2 -0
- package/dist/{chunk-tx628jpx.js → chunk-8w54jyt7.js} +2 -2
- package/dist/{chunk-2z69cw5m.js → chunk-8ycz8ss9.js} +5 -5
- package/dist/{chunk-bq9xf8nq.js → chunk-94gyfwpz.js} +8 -8
- package/dist/{chunk-tk08pr4b.js → chunk-992nsr70.js} +2 -2
- package/dist/chunk-9th217rf.js +2 -0
- package/dist/{chunk-y5f04xtb.js → chunk-9tqa8xvf.js} +2 -2
- package/dist/chunk-9wmjmas8.js +2 -0
- package/dist/{chunk-x8anspa5.js → chunk-agtvdtx4.js} +2 -2
- package/dist/{chunk-yzs2afn7.js → chunk-b4r7d6me.js} +3 -3
- package/dist/chunk-bgybw1k5.js +2 -0
- package/dist/chunk-bm7xr4xh.js +3 -0
- package/dist/{chunk-4wc5pc19.js → chunk-bwcj9z19.js} +2 -2
- package/dist/chunk-cagvn9tf.js +2 -0
- package/dist/chunk-cdsv4yrv.js +2 -0
- package/dist/chunk-cg5ar6y0.js +2 -0
- package/dist/{chunk-hpt354jm.js → chunk-d3pemcp8.js} +5 -5
- package/dist/chunk-d5e47gr4.js +2 -0
- package/dist/chunk-d910ytt2.js +2 -0
- package/dist/chunk-d9p7xaj7.js +2 -0
- package/dist/{chunk-y38swh5t.js → chunk-dhqp3z4w.js} +2 -2
- package/dist/chunk-dtc8expv.js +2 -0
- package/dist/{chunk-kf8hzvb7.js → chunk-e3wmnjz8.js} +3 -3
- package/dist/{chunk-6mj7fx2x.js → chunk-e44zheax.js} +3 -3
- package/dist/chunk-ebbzq4va.js +2 -0
- package/dist/chunk-eeqr09wt.js +2 -0
- package/dist/{chunk-z2m9p8xe.js → chunk-es006emk.js} +2 -2
- package/dist/chunk-fkkdt6sj.js +2 -0
- package/dist/chunk-fxy0cq7h.js +2 -0
- package/dist/chunk-g6smtcc0.js +2 -0
- package/dist/{chunk-9f6qx8b9.js → chunk-gb65t4n1.js} +2 -2
- package/dist/{chunk-2b34ce4g.js → chunk-gj5hjak1.js} +1 -1
- package/dist/{chunk-eapt899m.js → chunk-gv3bfkdm.js} +5 -5
- package/dist/{chunk-ady8cnpb.js → chunk-h0c6jtrj.js} +4 -4
- package/dist/{chunk-zxfptbac.js → chunk-h0jnatd4.js} +2 -2
- package/dist/{chunk-ghfw9cgr.js → chunk-h1cep4w8.js} +3 -3
- package/dist/{chunk-7rtcmxhd.js → chunk-hc8htggj.js} +4 -4
- package/dist/{chunk-3vzee3z9.js → chunk-hf2h0shz.js} +3 -3
- package/dist/{chunk-dt4435zf.js → chunk-hqmgvan6.js} +2 -2
- package/dist/{chunk-5behs1dk.js → chunk-hzmhh3k5.js} +1 -1
- package/dist/chunk-k7w05cjv.js +2 -0
- package/dist/{chunk-20afyff6.js → chunk-kce6pzmj.js} +2 -2
- package/dist/chunk-kk8vqwe4.js +2 -0
- package/dist/chunk-kn38mjpp.js +2 -0
- package/dist/{chunk-7d7aj7rh.js → chunk-kq1zc10a.js} +2 -2
- package/dist/chunk-kvmpc0sg.js +2 -0
- package/dist/chunk-memz2xdn.js +2 -0
- package/dist/{chunk-0q2v7k1m.js → chunk-mqr61kqn.js} +2 -2
- package/dist/chunk-n2cq11e3.js +2 -0
- package/dist/{chunk-ss2mk7zm.js → chunk-n70gbh4y.js} +9 -9
- package/dist/chunk-nf2bzqaw.js +2 -0
- package/dist/{chunk-mhkftysj.js → chunk-npfs1zyn.js} +3 -3
- package/dist/{chunk-05xa75nb.js → chunk-nrnkqqmb.js} +5 -5
- package/dist/{chunk-tmd1qwx7.js → chunk-nzj7mkvm.js} +61 -61
- package/dist/{chunk-7w1373q6.js → chunk-p0f5vygc.js} +5 -5
- package/dist/{chunk-9ct3gbyv.js → chunk-pa9zfbh6.js} +6 -6
- package/dist/{chunk-j2qv5ra2.js → chunk-q14d714d.js} +2 -2
- package/dist/chunk-qf86f6c5.js +2 -0
- package/dist/{chunk-tyjzye2d.js → chunk-qp3xd98j.js} +1 -1
- package/dist/chunk-qrnws56v.js +2 -0
- package/dist/{chunk-t3wfrb5x.js → chunk-qsqha895.js} +16 -16
- package/dist/{chunk-he85ksa7.js → chunk-qv85c3qy.js} +1 -1
- package/dist/{chunk-dyn8hwy1.js → chunk-qvc6d3ka.js} +4 -4
- package/dist/chunk-qzb0v08n.js +2 -0
- package/dist/{chunk-yazy1vk7.js → chunk-rkpd5pqc.js} +5 -5
- package/dist/chunk-rnaeezmp.js +2 -0
- package/dist/{chunk-gbx5vw81.js → chunk-rrb9m2q2.js} +5 -5
- package/dist/{chunk-e0ze9x4e.js → chunk-rwbcxzw2.js} +2 -2
- package/dist/chunk-s18ecm80.js +2 -0
- package/dist/chunk-s1wdzttg.js +2 -0
- package/dist/{chunk-mjpv9r5m.js → chunk-t0kh3ev1.js} +10 -10
- package/dist/chunk-t2hscbrh.js +2 -0
- package/dist/chunk-tbnyx5d2.js +2 -0
- package/dist/chunk-th5afzmv.js +2 -0
- package/dist/chunk-tktkj2dc.js +2 -0
- package/dist/{chunk-5mng4x26.js → chunk-tnkxww7b.js} +5 -5
- package/dist/{chunk-td3qp5my.js → chunk-tnn0br4w.js} +3 -3
- package/dist/{chunk-qfcn4btf.js → chunk-v1z6n7wz.js} +1 -1
- package/dist/{chunk-w6gfpxz3.js → chunk-v6z3ak8h.js} +1 -1
- package/dist/{chunk-vct6dec8.js → chunk-v8rfeev5.js} +2 -2
- package/dist/{chunk-yzapw5rk.js → chunk-vgtbds23.js} +13 -13
- package/dist/chunk-vgzfsh1z.js +2 -0
- package/dist/{chunk-416jy1m5.js → chunk-vkn133cs.js} +2 -2
- package/dist/{chunk-kk7seavb.js → chunk-vr6jccpy.js} +3 -3
- package/dist/{chunk-sxwgq49z.js → chunk-vrbcdds3.js} +1 -1
- package/dist/{chunk-wj78td69.js → chunk-w5hhqjwr.js} +1 -1
- package/dist/{chunk-8yjmf3gv.js → chunk-w6emseps.js} +5 -5
- package/dist/{chunk-x8js27hd.js → chunk-w9nwb8r3.js} +6 -6
- package/dist/chunk-wdqgf1hh.js +2 -0
- package/dist/chunk-wqjdzdaj.js +2 -0
- package/dist/chunk-wr3adhd8.js +2 -0
- package/dist/{chunk-rhpn4s5s.js → chunk-wrd3aygb.js} +1 -1
- package/dist/chunk-x8pehmac.js +2 -0
- package/dist/{chunk-9ba2z5fe.js → chunk-ymb0h1b9.js} +4 -4
- package/dist/chunk-zdwnzq78.js +2 -0
- package/dist/chunk-zyf6737j.js +2 -0
- package/dist/cli.js +12 -12
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/expressions.js +2 -2
- package/dist/native/bridge/protocol.d.ts +2 -0
- package/dist/native/runtime/jsc-globals.js +16 -0
- package/dist/native/runtime/native-host.js +41 -6
- package/dist/native/runtime/native-media.d.ts +39 -0
- package/dist/native/runtime/native-media.js +144 -0
- package/dist/native/runtime/shared-screen.js +3 -0
- package/dist/native/testing.js +7 -2
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +3 -3
- package/dist/utils.d.ts +1 -8
- package/dist/utils.js +11 -3
- package/package.json +5 -5
- package/dist/chunk-0vm1ys7q.js +0 -2
- package/dist/chunk-2vnhyter.js +0 -2
- package/dist/chunk-462dyzmx.js +0 -2
- package/dist/chunk-47qestfz.js +0 -2
- package/dist/chunk-4kx7pw6x.js +0 -2
- package/dist/chunk-4te06cpw.js +0 -2
- package/dist/chunk-4wsdx9vy.js +0 -2
- package/dist/chunk-4yr14p2w.js +0 -2
- package/dist/chunk-65s4mjxb.js +0 -2
- package/dist/chunk-713az4kg.js +0 -2
- package/dist/chunk-7y2h7nfd.js +0 -2
- package/dist/chunk-7y6ad89y.js +0 -2
- package/dist/chunk-8ds59ttd.js +0 -2
- package/dist/chunk-8pyyqev1.js +0 -2
- package/dist/chunk-9896204h.js +0 -2
- package/dist/chunk-9fh3h9p3.js +0 -2
- package/dist/chunk-9qwkyt81.js +0 -2
- package/dist/chunk-bancsgvx.js +0 -2
- package/dist/chunk-c91y14ae.js +0 -2
- package/dist/chunk-cpq9b0fx.js +0 -2
- package/dist/chunk-cqv28wmk.js +0 -2
- package/dist/chunk-d1ngw481.js +0 -2
- package/dist/chunk-dcnjpjc1.js +0 -2
- package/dist/chunk-dxp022r0.js +0 -2
- package/dist/chunk-e3y78men.js +0 -2
- package/dist/chunk-evshahyj.js +0 -2
- package/dist/chunk-gbgbhpms.js +0 -2
- package/dist/chunk-gd6hxe85.js +0 -2
- package/dist/chunk-hef2dr38.js +0 -2
- package/dist/chunk-jazkazdy.js +0 -2
- package/dist/chunk-k8srkymx.js +0 -2
- package/dist/chunk-k9dg3nyy.js +0 -2
- package/dist/chunk-m627y6xq.js +0 -2
- package/dist/chunk-m90wyzhd.js +0 -2
- package/dist/chunk-mcevnfnx.js +0 -2
- package/dist/chunk-mxbzqyvp.js +0 -2
- package/dist/chunk-nx20kccb.js +0 -2
- package/dist/chunk-p43hw6ef.js +0 -2
- package/dist/chunk-pxfrshr6.js +0 -2
- package/dist/chunk-q0v6y356.js +0 -2
- package/dist/chunk-q71qqjy7.js +0 -2
- package/dist/chunk-qe9dqhpr.js +0 -2
- package/dist/chunk-s53psb1j.js +0 -2
- package/dist/chunk-t482tgm6.js +0 -2
- package/dist/chunk-t619ap22.js +0 -2
- package/dist/chunk-t61m22mj.js +0 -2
- package/dist/chunk-thajeb3z.js +0 -2
- package/dist/chunk-wm8wz183.js +0 -2
- package/dist/chunk-x0e0pcn0.js +0 -2
- package/dist/chunk-x756yzrc.js +0 -2
- package/dist/chunk-xgvsaj4e.js +0 -2
- package/dist/chunk-xq2tfg4v.js +0 -2
- package/dist/chunk-ycyn0jrr.js +0 -2
- package/dist/chunk-yehbnf0t.js +0 -2
- package/dist/chunk-yrdxvphr.js +0 -2
- package/dist/chunk-z9678kfn.js +0 -2
- package/dist/chunk-zh8w0nb6.js +0 -2
- package/dist/chunk-zj3dz854.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qr}from"./chunk-
|
|
2
|
+
import{Qr}from"./chunk-3gn1t0pa.js";import{S}from"./chunk-nzj7mkvm.js";import{a}from"./chunk-7wkz9sz5.js";import{Ke,re}from"./chunk-c0ejyxfj.js";import{Ka}from"./chunk-hc8htggj.js";import{L}from"./chunk-k3rcpnzm.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as F,mkdirSync as y,copyFileSync as P,chmodSync as I,rmSync as he}from"fs";import{join as c,basename as ve,resolve as G}from"path";import{spawn as z}from"child_process";import{platform as xe}from"os";function E(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=S(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var pu=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -468,7 +468,7 @@ else if (data.type === 'event' && data.method) {
|
|
|
468
468
|
}
|
|
469
469
|
})();
|
|
470
470
|
</script>
|
|
471
|
-
`;function wa(e={}){let{debug:r=!1,timeout:i=30000}=e;return
|
|
471
|
+
`;function wa(e={}){let{debug:r=!1,timeout:i=30000}=e;return pu.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${i}`)}function gh(){return!1}function mh(e,r={}){let i=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(i,(n,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 wa(t)})}function va(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let i=wa(r),n=E(e,"head",`${i}
|
|
472
472
|
`);if(n!==null)return n;let s=L(e);if(s){let t=s.index+s.tag.length;return e.slice(0,t)+`
|
|
473
473
|
${i}`+e.slice(t)}return i+e}var xo={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 i=e.checked?"checked":"",n=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
474
474
|
<input type="checkbox" class="craft-checkbox" ${i} ${n}>
|
|
@@ -1029,7 +1029,7 @@ ${i}`+e.slice(t)}return i+e}var xo={button:{nativeType:"craft-button",fallbackTa
|
|
|
1029
1029
|
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${x(e.icon)}"${i}></span>`:""}
|
|
1030
1030
|
<span class="craft-sidebar-item-label">${T(e.label)}</span>
|
|
1031
1031
|
${e.badge?`<span class="craft-sidebar-item-badge">${T(e.badge)}</span>`:""}
|
|
1032
|
-
</button>`}function B(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function le(e){let r=5381;for(let i=0;i<e.length;i++)r=r*33^e.charCodeAt(i);return(r>>>0).toString(36)}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function x(e){return T(e).replace(/`/g,"`")}function ue(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function fe(e,r,i){let n=[];n.push(`class="${i.join(" ")}"`),n.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)n.push(s);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,""");n.push(`${s}="${o}"`)}return n.join(" ")}function
|
|
1032
|
+
</button>`}function B(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function le(e){let r=5381;for(let i=0;i<e.length;i++)r=r*33^e.charCodeAt(i);return(r>>>0).toString(36)}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function x(e){return T(e).replace(/`/g,"`")}function ue(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function fe(e,r,i){let n=[];n.push(`class="${i.join(" ")}"`),n.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)n.push(s);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,""");n.push(`${s}="${o}"`)}return n.join(" ")}function hh(e,r){xo[e]=r}function yh(){return{...xo}}import{chmodSync as pe,copyFileSync as be,mkdtempSync as V,rmSync as ge,writeFileSync as J}from"fs";import{tmpdir as W}from"os";import{join as O}from"path";function me(e){let r=Bun.spawnSync(["/usr/bin/plutil","-extract","Entitlements","xml1","-o","-","-"],{stdin:e});if(r.exitCode!==0)throw Error(`Could not extract the macOS profile entitlements: ${r.stderr.toString().trim()||r.stdout.toString().trim()}`);let i=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-","-"],{stdin:r.stdout});if(i.exitCode!==0)throw Error(`Could not convert the macOS profile entitlements: ${i.stderr.toString().trim()||i.stdout.toString().trim()}`);let n=JSON.parse(i.stdout.toString());if(!n||typeof n!=="object"||Array.isArray(n))throw Error("The macOS profile entitlements must be a dictionary.");return n}function we(e,r){let i=O(r,"Contents","embedded.provisionprofile");be(e,i),pe(i,420)}async function Q(e,r=[],i={}){if(process.platform!=="darwin")return;let n=i.entitlements,s;try{if(i.provisioningProfile){if(!i.identity||i.identity==="-")throw Error("A provisioning profile requires a signing identity.");let u=Bun.spawnSync(["/usr/bin/security","cms","-D","-i",i.provisioningProfile]);if(u.exitCode!==0)throw Error("Could not decode the macOS provisioning profile.");let l=me(u.stdout),p={};if(i.entitlements){let b=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",i.entitlements]);if(b.exitCode!==0)throw Error("Could not read the app entitlements plist.");p=JSON.parse(b.stdout.toString())}for(let b of["com.apple.application-identifier","com.apple.developer.team-identifier"])if(l[b])p[b]=l[b];if(s=V(O(W(),"stx-entitlements-")),n=O(s,"entitlements.plist"),J(n,JSON.stringify(p)),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",n]).exitCode!==0)throw Error("Could not generate the provisioned app entitlements.");we(i.provisioningProfile,e)}let t;if(r.length){let u=!1;if(n){let l=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",n]);if(l.exitCode!==0)throw Error("Could not read native parent entitlements.");u=JSON.parse(l.stdout.toString())["com.apple.security.app-sandbox"]===!0}if(s??=V(O(W(),"stx-entitlements-")),t=O(s,"helper.entitlements.plist"),J(t,JSON.stringify({"com.apple.security.cs.allow-jit":!0,...u?{"com.apple.security.app-sandbox":!0,"com.apple.security.inherit":!0}:{}})),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",t]).exitCode!==0)throw Error("Could not generate native helper entitlements.")}for(let u of[...r,e]){let l=i.hardenedRuntime?["--options","runtime"]:[];if(u===e&&n)l.push("--entitlements",n);if(u!==e&&t)l.push("--entitlements",t);let p=i.identity&&i.identity!=="-"?"--timestamp":"--timestamp=none",b=Bun.spawn(["/usr/bin/codesign","--force","--sign",i.identity||"-",p,...l,u],{stdout:"pipe",stderr:"pipe"}),[m,v]=await Promise.all([new Response(b.stderr).text(),b.exited]);if(v!==0)throw Error(`Could not sign native bundle ${u}: ${m.trim()}`)}let o=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[d,f]=await Promise.all([new Response(o.stderr).text(),o.exited]);if(f!==0)throw Error(`Invalid native bundle signature: ${d.trim()}`)}finally{if(s)ge(s,{recursive:!0,force:!0})}}async function ka(e){if(e.window?.cornerRadius!==void 0&&(!Number.isFinite(e.window.cornerRadius)||e.window.cornerRadius<0||e.window.cornerRadius>128))throw Error("Native window cornerRadius must be between 0 and 128");let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||D(),format:e.format||"app",error:`Input file not found: ${e.input}`};let i=e.target||D(),n=e.format||Be(i);if(e.backend&&i!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!F(G(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let s=e.output||c(process.cwd(),"dist","native");if(!F(s))y(s,{recursive:!0});let t=await a(process.cwd()),o=await Ka(e.input,{context:e.context,options:{...t,isDev:!1},injectCSS:!0});if(o=va(o,{debug:e.verbose}),o=Sa(o),!o.includes("craft-component-styles")){if(o.includes("</head>"))o=o.replace("</head>",`${Zr}
|
|
1033
1033
|
</head>`)}let d=e.name||ve(e.input,".stx"),f=e.version||"1.0.0",u=e.craftPath||_a(e.runtimeProfile);if(!u)return{success:!1,target:i,format:n,error:"Craft native binary not found on PATH. Run pantry install craft, or specify craftPath for framework development."};if(e.runtimeProfile==="webview"){if(i!=="macos")throw Error("The webview runtime profile is currently available on macOS only.");let p=Bun.spawnSync([u,"--runtime-profile"],{stdout:"pipe",stderr:"pipe",timeout:1e4});if(p.exitCode!==0||p.stdout.toString().trim()!=="webview")throw Error("The requested Craft webview runtime is unavailable. Upgrade Craft with Pantry before building.")}if(u=Qr(e.craftPath,e.runtimeProfile),e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${i}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${u}`);let l;switch(i){case"macos":l=await ye(o,d,f,s,n,e,u);break;case"windows":l=await $e(o,d,f,s,n,e,u);break;case"linux":l=await Te(o,d,f,s,n,e,u);break;case"ios":l=await Pe(o,d,f,s,e,u);break;case"android":l=await Ie(o,d,f,s,e,u);break;default:l={success:!1,target:i,format:n,error:`Unsupported target: ${i}`}}return l.duration=Date.now()-r,l}catch(i){return{success:!1,target:e.target||D(),format:e.format||"app",error:i.message,duration:Date.now()-r}}}async function ye(e,r,i,n,s,t,o){let d=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,f=c(n,`${r}.app`),u=c(f,"Contents"),l=c(u,"MacOS"),p=c(u,"Resources");he(f,{recursive:!0,force:!0}),y(l,{recursive:!0}),y(p,{recursive:!0});let b=c(p,"index.html");await Bun.write(b,e);let m="";if(t.sidebar?.enabled&&t.sidebar?.config)m=c(p,"sidebar-config.json"),await Bun.write(m,JSON.stringify(t.sidebar.config));let v=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",k=t.menubarOnly??t.systemTray,h=t.bundleStyle||(await Ce(o)?"executable":"launcher");if(t.backend){if(!await Se(o))throw Error("This Craft runtime does not support bundled backends. Upgrade Craft before building this app.");P(o,c(l,r)),I(c(l,r),493);let C=Ke("native-backend");try{let w=c(C,"launcher.ts"),M=c(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(w,`import { runNativeBackend } from ${JSON.stringify(M)}
|
|
1034
1034
|
import * as backend from ${JSON.stringify(G(t.backend.entry))}
|
|
1035
1035
|
await runNativeBackend({ html: ${JSON.stringify(e)}, fetch: backend.default, shutdown: Reflect.get(backend, "shutdown"),
|
|
@@ -1097,5 +1097,5 @@ Exec=${i.toLowerCase()}
|
|
|
1097
1097
|
Terminal=false
|
|
1098
1098
|
Categories=Utility;
|
|
1099
1099
|
Icon=${i.toLowerCase()}
|
|
1100
|
-
`;g("fs").writeFileSync(c(o,`${i.toLowerCase()}.desktop`),m);let v=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(g("fs").writeFileSync(c(o,`${i.toLowerCase()}.png`),v),n.icon&&F(n.icon))P(n.icon,c(o,`${i.toLowerCase()}.png`));let k=z("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});k.on("close",(h)=>{if(re(t),h===0)I(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${h}. Install from https://appimage.github.io/appimagetool/`})}),k.on("error",(h)=>{re(t),s({success:!1,error:`appimagetool not found: ${h.message}`})})}catch(o){re(t),s({success:!1,error:o.message})}})}function Ca(){return[D()]}function Ea(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 qe={buildNative:ka,getAvailableTargets:Ca,getAvailableFormats:Ea,detectPlatform:D},
|
|
1101
|
-
export{
|
|
1100
|
+
`;g("fs").writeFileSync(c(o,`${i.toLowerCase()}.desktop`),m);let v=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(g("fs").writeFileSync(c(o,`${i.toLowerCase()}.png`),v),n.icon&&F(n.icon))P(n.icon,c(o,`${i.toLowerCase()}.png`));let k=z("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});k.on("close",(h)=>{if(re(t),h===0)I(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${h}. Install from https://appimage.github.io/appimagetool/`})}),k.on("error",(h)=>{re(t),s({success:!1,error:`appimagetool not found: ${h.message}`})})}catch(o){re(t),s({success:!1,error:o.message})}})}function Ca(){return[D()]}function Ea(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 qe={buildNative:ka,getAvailableTargets:Ca,getAvailableFormats:Ea,detectPlatform:D},bh=qe;
|
|
1101
|
+
export{pu,wa,gh,mh,va,xo,Zr,xa,Sa,hh,yh,ka,_a,Ca,Ea,bh};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ve,Hs,pg,Kh,fg,Xh,Dt,p,V,Z,wn,Se,gg,bi,mg,Gh,_,hg,Jh,T,Yh}from"./chunk-nzj7mkvm.js";import"./chunk-wrd3aygb.js";import"./chunk-27rzdq3n.js";import"./chunk-94gyfwpz.js";import"./chunk-2yxva96k.js";import"./chunk-gb65t4n1.js";export{hg as applyFilters,Xh as clearCustomFilters,gg as clientLoopScopes,Hs as defaultFilters,wn as escapeAttributeValue,p as escapeHtml,V as escapeHtmlValue,Z as escapeInterpolatedHtmlValue,T as evaluateExpression,ve as findMustacheEnd,fg as getAllFilters,mg as interpolateScriptAttributes,bi as interpolateScriptExpressions,Gh as interpolateScriptsInTemplate,_ as processExpressions,pg as registerFilter,Kh as registerFilters,Dt as replaceInterpolations,Jh as resetRejectedExpressionWarnings,Yh as unescapeHtml,Se as usesSignalsInScript};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var d=0;function l(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function
|
|
2
|
+
var d=0;function l(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function wm(e,t={},n){let i=/@keepAlive(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@endkeepAlive/gi;return e.replace(i,(a,c,o)=>{let s=l(),r=u(c||"");return p(s,o.trim(),r)})}function u(e){let t={max:10},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,i;while((i=n.exec(e))!==null){let a=i[1],c=i[2]||i[3],o=i[4];switch(a){case"max":t.max=o?parseInt(o,10):10;break;case"include":t.include=c;break;case"exclude":t.exclude=c;break;case"id":t.id=c;break}}return t}function p(e,t,n){let{max:i,include:a,exclude:c}=n,o=n.id||e;return`
|
|
3
3
|
<div class="stx-keep-alive" data-keep-alive-id="${e}" data-custom-id="${o}">
|
|
4
4
|
<div class="stx-keep-alive-content" data-keep-alive-content="${e}">
|
|
5
5
|
${t}
|
|
@@ -286,7 +286,7 @@ else {
|
|
|
286
286
|
});
|
|
287
287
|
})();
|
|
288
288
|
</script>
|
|
289
|
-
`}function
|
|
289
|
+
`}function vm(e={}){return{id:e.id||l(),cache:new Map,max:e.max||10,include:e.include?e.include.split(",").map((n)=>n.trim()):null,exclude:e.exclude?e.exclude.split(",").map((n)=>n.trim()):null}}function xm(e,t){if(t.exclude&&t.exclude.includes(e))return!1;if(t.include&&!t.include.includes(e))return!1;return!0}function Sm(){return`
|
|
290
290
|
/* STX Keep-Alive Styles */
|
|
291
291
|
.stx-keep-alive {
|
|
292
292
|
position: relative;
|
|
@@ -311,7 +311,7 @@ else {
|
|
|
311
311
|
.stx-keep-alive-content > [data-activated] {
|
|
312
312
|
opacity: 1;
|
|
313
313
|
}
|
|
314
|
-
`}function
|
|
314
|
+
`}function km(){return`
|
|
315
315
|
// STX Keep-Alive Runtime
|
|
316
316
|
(function() {
|
|
317
317
|
if (typeof window === 'undefined') return;
|
|
@@ -347,5 +347,5 @@ else {
|
|
|
347
347
|
|
|
348
348
|
console.log('[stx] Keep-alive runtime initialized');
|
|
349
349
|
})();
|
|
350
|
-
`}function
|
|
351
|
-
export{
|
|
350
|
+
`}function _m(e){if(typeof document<"u")document.addEventListener("stx:activated",(t)=>{e(t.detail)})}function Cm(e){if(typeof document<"u")document.addEventListener("stx:deactivated",(t)=>{e(t.detail)})}
|
|
351
|
+
export{wm,vm,xm,Sm,km,_m,Cm};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-
|
|
2
|
+
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import{m}from"./chunk-nzj7mkvm.js";import"./chunk-94gyfwpz.js";import"./chunk-27rzdq3n.js";import"./chunk-wrd3aygb.js";import{Vt,eo,Ut,Hi,ct,Vi,to,Wt,Wi,qt}from"./chunk-7gdwvnwc.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()=>{Vi("Config file changed, restarting...");try{await e.onChange()}catch(p){ct(`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",pt=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:pt,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,7 +556,7 @@ 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:d}=await import("./chunk-
|
|
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-498286bb.js"),p={},g=h(n);if(g)try{await m(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),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,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 m(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-498286bb.js"),c={...r},n=h(e);if(n)try{await m(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
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 Wt(t);ut(t,r);let s=qt(t.config,r);dt(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=Wi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await Wt(t);ut(t,u);let f=qt(t.config,u);if(dt(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"),u=process.platform;l(`${u==="darwin"?"open":u==="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((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],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"}">
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{on,$o,Ro,Ao,xh,Po}from"./chunk-npfs1zyn.js";import"./chunk-605b93pe.js";import"./chunk-q14d714d.js";import"./chunk-27rzdq3n.js";export{Ro as buildServerApi,xh as createServerApi,on as discoverServerApi,$o as generateApiTypes,Po as isServerApiSource,Ao as productionApiDispatcher};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Mi,Di,Li,Og,ji,Bi,Ng,Fi,zi,Sl,Mg}from"./chunk-e3wmnjz8.js";export{Mi as VideoProcessorCache,Sl as analyzeVideo,Og as clearVideoCache,zi as generateDASHManifest,Fi as generateHLSManifest,ji as generatePoster,Ng as generateSpriteSheet,Bi as generateThumbnails,Di as getCachedVideoResult,Mg as processVideo,Li as setCachedVideoResult};
|