@stacksjs/stx 0.2.642 → 0.2.643
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-hhnbm4y5.js → chunk-074s7tdg.js} +1 -1
- package/dist/{chunk-n95243ry.js → chunk-0axmn0cs.js} +1 -1
- package/dist/{chunk-mck6csxx.js → chunk-0nhhcn8h.js} +1 -1
- package/dist/{chunk-cc1v8q2d.js → chunk-0rdjara0.js} +5 -5
- package/dist/{chunk-5qwrg6m7.js → chunk-1tvmptew.js} +1 -1
- package/dist/{chunk-p6kaqfa9.js → chunk-24a26e7s.js} +1 -1
- package/dist/chunk-24dnzs9m.js +2 -0
- package/dist/{chunk-6sb3tcr6.js → chunk-2txfgc41.js} +1 -1
- package/dist/{chunk-pr1rt0z4.js → chunk-57a0vpr2.js} +1 -1
- package/dist/{chunk-3xdmxpxe.js → chunk-82b64h3r.js} +1 -1
- package/dist/{chunk-8at87jae.js → chunk-8m18taj7.js} +1 -1
- package/dist/{chunk-pjxns9tp.js → chunk-8xcpjbe8.js} +1 -1
- package/dist/{chunk-1at1xzx5.js → chunk-9ndsmpzm.js} +1 -1
- package/dist/{chunk-cc6f6t8f.js → chunk-b094vnjy.js} +1 -1
- package/dist/{chunk-ngkxtkh3.js → chunk-b7hchpv4.js} +2 -2
- package/dist/{chunk-dqjx14em.js → chunk-bdq0vnky.js} +18 -18
- package/dist/{chunk-wv9mc6gx.js → chunk-djqq2hkm.js} +1 -1
- package/dist/chunk-dx25as3s.js +2 -0
- package/dist/{chunk-g0wr83v9.js → chunk-e2e9pkgh.js} +1 -1
- package/dist/{chunk-4whp2tr5.js → chunk-exv12qm3.js} +1 -1
- package/dist/{chunk-8k4d65x2.js → chunk-f20eg3gr.js} +1 -1
- package/dist/{chunk-52wj6yc8.js → chunk-fgxtsa9g.js} +1 -1
- package/dist/{chunk-75tshgmz.js → chunk-g4fvxzct.js} +1 -1
- package/dist/{chunk-dy3hvydn.js → chunk-h5bvw8x2.js} +1 -1
- package/dist/{chunk-2zey344t.js → chunk-hcd40m6a.js} +1 -1
- package/dist/{chunk-efx1zm7a.js → chunk-htez1y6d.js} +1 -1
- package/dist/{chunk-kcvn37qp.js → chunk-j7xbbp8y.js} +1 -1
- package/dist/{chunk-bxvnzafh.js → chunk-jetfkqht.js} +1 -1
- package/dist/{chunk-crtv20vx.js → chunk-k18pqctb.js} +1 -1
- package/dist/{chunk-5x83f835.js → chunk-k6jfs5d2.js} +1 -1
- package/dist/{chunk-j9kachkd.js → chunk-k93mp0gj.js} +1 -1
- package/dist/{chunk-jmhpfxjq.js → chunk-kapa2kk3.js} +1 -1
- package/dist/{chunk-hbwxr5dq.js → chunk-kh31vt86.js} +1 -1
- package/dist/{chunk-0f75mm0s.js → chunk-kmzadv6e.js} +1 -1
- package/dist/{chunk-7pmcsw3x.js → chunk-ks5wfvzq.js} +1 -1
- package/dist/{chunk-kah2drys.js → chunk-m3ahtfwp.js} +1 -1
- package/dist/{chunk-pr08fz3f.js → chunk-njsnfjc4.js} +1 -1
- package/dist/{chunk-7xq8ng55.js → chunk-pgtvypdg.js} +58 -58
- package/dist/{chunk-h3nrzz4k.js → chunk-qzy8hvh7.js} +1 -1
- package/dist/{chunk-p7jbzxps.js → chunk-stam369d.js} +2 -2
- package/dist/{chunk-z84vhs3n.js → chunk-sz4wg3b5.js} +1 -1
- package/dist/{chunk-yvf7ta8h.js → chunk-tn3d1h0v.js} +1 -1
- package/dist/{chunk-t53pmm3n.js → chunk-tr468nx8.js} +2 -2
- package/dist/{chunk-70na8hcs.js → chunk-trqpaxcp.js} +1 -1
- package/dist/chunk-w05z0vwy.js +2 -0
- package/dist/{chunk-w7wb4t0z.js → chunk-xtfv7nsq.js} +1 -1
- package/dist/{chunk-j36hrzac.js → chunk-zhw4bjbz.js} +3 -3
- package/dist/{chunk-vecjfm4z.js → chunk-znt8zs00.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native-signing.d.ts +2 -1
- package/dist/native-signing.js +45 -9
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-fhhen33c.js +0 -2
- package/dist/chunk-hbqqh0cr.js +0 -2
- package/dist/chunk-razh91br.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ce,U}from"./chunk-gmxrckgj.js";import{ni}from"./chunk-
|
|
2
|
+
import{Ce,U}from"./chunk-gmxrckgj.js";import{ni}from"./chunk-stam369d.js";import{d}from"./chunk-yn2d8x8m.js";import{existsSync as F,mkdirSync as x,copyFileSync as S,chmodSync as k,rmSync as pe}from"fs";import{join as s,basename as ue,resolve as V}from"path";import{spawn as N,execSync as be}from"child_process";import{homedir as q,platform as ge}from"os";var Wu=`
|
|
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 Go(e={}){let{debug:
|
|
471
|
+
`;function Go(e={}){let{debug:a=!1,timeout:r=30000}=e;return`
|
|
472
472
|
<script>
|
|
473
473
|
(function() {
|
|
474
474
|
'use strict';
|
|
@@ -937,23 +937,23 @@ else if (data.type === 'event' && data.method) {
|
|
|
937
937
|
}
|
|
938
938
|
})();
|
|
939
939
|
</script>
|
|
940
|
-
`.replace("debug: false,",`debug: ${
|
|
940
|
+
`.replace("debug: false,",`debug: ${a},`).replace("timeout: 30000",`timeout: ${r}`)}function qu(){return!1}function Gu(e,a={}){let r=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(r,(i,n)=>{let t={};if(n)try{t=JSON.parse(n.replace(/'/g,'"'))}catch{try{t=Function(`return ${n}`)()}catch{console.warn(`[stx] Invalid @craft config: ${n}`)}}return Go(t)})}function Ko(e,a={}){if(e.includes("__craftBridgeInitialized"))return e;let r=Go(a);if(e.includes("</head>"))return e.replace("</head>",`${r}
|
|
941
941
|
</head>`);if(e.includes("<body"))return e.replace(/(<body[^>]*>)/,`$1
|
|
942
|
-
${
|
|
943
|
-
<input type="checkbox" class="craft-checkbox" ${
|
|
944
|
-
<span class="craft-checkbox-label">${
|
|
945
|
-
</label>`}},radio:{nativeType:"craft-radio",fallbackTag:"input",fallbackClasses:"craft-radio",nativeProps:["checked","disabled","name","value","label"]},select:{nativeType:"craft-select",fallbackTag:"select",fallbackClasses:"craft-select",nativeProps:["value","disabled","options","placeholder"]},slider:{nativeType:"craft-slider",fallbackTag:"input",fallbackClasses:"craft-slider",nativeProps:["value","min","max","step","disabled"],render:(e,
|
|
942
|
+
${r}`);return r+e}var ls={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(e,a)=>{let r=e.checked?"checked":"",i=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
943
|
+
<input type="checkbox" class="craft-checkbox" ${r} ${i}>
|
|
944
|
+
<span class="craft-checkbox-label">${a||e.label||""}</span>
|
|
945
|
+
</label>`}},radio:{nativeType:"craft-radio",fallbackTag:"input",fallbackClasses:"craft-radio",nativeProps:["checked","disabled","name","value","label"]},select:{nativeType:"craft-select",fallbackTag:"select",fallbackClasses:"craft-select",nativeProps:["value","disabled","options","placeholder"]},slider:{nativeType:"craft-slider",fallbackTag:"input",fallbackClasses:"craft-slider",nativeProps:["value","min","max","step","disabled"],render:(e,a)=>{let r=e.min??0,i=e.max??100,n=e.step??1,t=e.value??50,o=e.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${r}" max="${i}" step="${n}" value="${t}" ${o}>`}},label:{nativeType:"craft-label",fallbackTag:"span",fallbackClasses:"craft-label",nativeProps:["text","for"]},badge:{nativeType:"craft-badge",fallbackTag:"span",fallbackClasses:"craft-badge",nativeProps:["variant","size"]},avatar:{nativeType:"craft-avatar",fallbackTag:"div",fallbackClasses:"craft-avatar",nativeProps:["src","alt","size","fallback"],render:(e,a)=>{let r=e.size||40,i=e.src,n=String(e.alt||""),t=e.fallback||(n?n.charAt(0).toUpperCase():"?");if(i)return`<img class="craft-avatar" src="${i}" alt="${n}" style="width:${r}px;height:${r}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${r}px;height:${r}px;border-radius:50%;display:flex;align-items:center;justify-content:center">${t}</div>`}},progress:{nativeType:"craft-progress",fallbackTag:"div",fallbackClasses:"craft-progress",nativeProps:["value","max","variant"],render:(e,a)=>{let r=Number(e.value)||0,i=Number(e.max)||100;return`<div class="craft-progress"><div class="craft-progress-bar" style="width:${Math.min(100,Math.max(0,r/i*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:(e,a)=>{let r=e.size||24;return`<div class="craft-spinner" style="width:${r}px;height:${r}px"></div>`}},card:{nativeType:"craft-card",fallbackTag:"div",fallbackClasses:"craft-card",nativeProps:["title","subtitle","variant"]},modal:{nativeType:"craft-modal",fallbackTag:"dialog",fallbackClasses:"craft-modal",nativeProps:["open","title","closable","size"],render:(e,a)=>{let r=e.open?"open":"",i=e.title||"";return`<dialog class="craft-modal" ${r}>
|
|
946
946
|
<div class="craft-modal-content">
|
|
947
947
|
${i?`<div class="craft-modal-header"><h2>${i}</h2></div>`:""}
|
|
948
|
-
<div class="craft-modal-body">${
|
|
948
|
+
<div class="craft-modal-body">${a}</div>
|
|
949
949
|
</div>
|
|
950
|
-
</dialog>`}},tabs:{nativeType:"craft-tabs",fallbackTag:"div",fallbackClasses:"craft-tabs",nativeProps:["activeTab","tabs"]},accordion:{nativeType:"craft-accordion",fallbackTag:"details",fallbackClasses:"craft-accordion",nativeProps:["open","title"],render:(e,
|
|
950
|
+
</dialog>`}},tabs:{nativeType:"craft-tabs",fallbackTag:"div",fallbackClasses:"craft-tabs",nativeProps:["activeTab","tabs"]},accordion:{nativeType:"craft-accordion",fallbackTag:"details",fallbackClasses:"craft-accordion",nativeProps:["open","title"],render:(e,a)=>{let r=e.open?"open":"",i=e.title||"Details";return`<details class="craft-accordion" ${r}>
|
|
951
951
|
<summary class="craft-accordion-header">${i}</summary>
|
|
952
|
-
<div class="craft-accordion-content">${
|
|
953
|
-
</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,
|
|
952
|
+
<div class="craft-accordion-content">${a}</div>
|
|
953
|
+
</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,a)=>{let r=e.variant||"info",i=e.title||"";return`<div class="craft-alert craft-alert-${r}" role="alert">
|
|
954
954
|
${i?`<div class="craft-alert-title">${i}</div>`:""}
|
|
955
|
-
<div class="craft-alert-content">${
|
|
956
|
-
</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,
|
|
955
|
+
<div class="craft-alert-content">${a}</div>
|
|
956
|
+
</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,a)=>{let r=e.content||"",i=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${r}" data-position="${i}">${a}</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:Q},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:G},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:X},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:K},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,a)=>`<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,a)=>{let r=e.value||"",i=e.min||"",n=e.max||"";return`<input type="date" class="craft-date-picker" value="${r}" min="${i}" max="${n}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,a)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},Xo=`
|
|
957
957
|
<style id="craft-component-styles">
|
|
958
958
|
/* Craft Component Base Styles */
|
|
959
959
|
.craft-button {
|
|
@@ -1475,7 +1475,7 @@ ${a}`);return a+e}var ls={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1475
1475
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
1476
1476
|
})();
|
|
1477
1477
|
</script>
|
|
1478
|
-
`;function Jo(e,
|
|
1478
|
+
`;function Jo(e,a={}){let{classPrefix:r="craft"}=a;if(!e.includes("craft-component-styles"))if(e.includes("</head>"))e=e.replace("</head>",`${`
|
|
1479
1479
|
<style id="craft-component-styles">
|
|
1480
1480
|
/* Craft Component Base Styles */
|
|
1481
1481
|
.craft-button {
|
|
@@ -2940,97 +2940,97 @@ ${a}`);return a+e}var ls={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2940
2940
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
2941
2941
|
})();
|
|
2942
2942
|
</script>
|
|
2943
|
-
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,
|
|
2944
|
-
${y}
|
|
2943
|
+
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,n,t)=>E("sidebar",n,t.trim(),a,r)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,n)=>E("sidebar",n,"",a,r)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,n,t)=>E(n,t,"",a,r)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,n,t,o)=>E(n,t,o.trim(),a,r)),e}function E(e,a,r,i,n){let t=i.components?.[e]||ls[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${n}-unknown" data-component="${e}">${r}</div>`;let o=O(a),c=[t.fallbackClasses||`${n}-${e}`];if(o.class)c.push(o.class),delete o.class;if(t.render)return o.__fallbackClasses=c.join(" "),t.render(o,r);let l=se(o,t,c);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${l}>`;return`<${t.fallbackTag} ${l}>${r}</${t.fallbackTag}>`}function O(e){let a={},r=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,i;while((i=r.exec(e))!==null){let[n,t,o,c]=i,l=o??c;if(n.startsWith(":"))a[t]=l;else if(n.startsWith("@"))a[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=l;else if(l===void 0)a[t]=!0;else a[t]=l}return a}function Q(e,a){let r=P(String(e.id||`craft-sidebar-${ie(a||JSON.stringify(e))}`)),i=te(e.spaces)||ee(a),n=i.length?[]:ae(e.sections)||z(a),t=String(e.selectedSpace||i[0]?.id||""),o=i.find((w)=>w.id===t)||i[0],c=String(e.selectedItem||e.selected||(i.length?o?.sections[0]?.items[0]?.id:n[0]?.items[0]?.id)||""),l={id:r,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:c,sections:n,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",g=l.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C(l.searchPlaceholder)}"></div>`:"",b;if(i.length)b=re(i,t,c);else if(n.length)b=n.map((w)=>M(w,c)).join("");else b=a;return`<aside class="${v(f)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${v(r)}" data-native="${u}" style="--craft-sidebar-width:${p}px">
|
|
2945
2944
|
${g}
|
|
2945
|
+
${b}
|
|
2946
2946
|
</aside>
|
|
2947
|
-
<script type="application/json" data-craft-sidebar-config="${
|
|
2947
|
+
<script type="application/json" data-craft-sidebar-config="${v(r)}">${ne(l)}</script>`}function G(e,a){let r=P(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${v(r)}">
|
|
2948
2948
|
${e.label?`<div class="craft-sidebar-space-title">${C(String(e.label))}</div>`:""}
|
|
2949
|
-
${
|
|
2950
|
-
</section>`}function
|
|
2951
|
-
${
|
|
2952
|
-
${
|
|
2953
|
-
</section>`}function
|
|
2949
|
+
${a}
|
|
2950
|
+
</section>`}function X(e,a){let r=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${v(String(e.id||"section"))}">
|
|
2951
|
+
${r?`<div class="craft-sidebar-section-title">${C(r)}</div>`:""}
|
|
2952
|
+
${a}
|
|
2953
|
+
</section>`}function K(e,a){let r={id:String(e.id||P(String(e.label||a||"item"))),label:String(e.label||a||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return L(r,String(e.selected||"")==="true")}function z(e){let a=[],r=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,i;while((i=r.exec(e))!==null){let n=O(i[1]||""),t=i[2]||"",o=String(n.id||P(String(n.header||n.title||`section-${a.length+1}`))),c=String(n.header||n.title||o),l=Z(t);a.push({id:o,header:c,title:c,items:l})}return a}function Z(e){let a=[],r=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,i;while((i=r.exec(e))!==null){let n=O(i[1]||""),t=String(n.label||(i[2]||"").replace(/<[^>]*>/g,"").trim()),o=String(n.id||P(t||`item-${a.length+1}`));a.push({id:o,label:t,icon:n.icon?String(n.icon):void 0,badge:n.badge?String(n.badge):void 0,tintColor:n.tintColor?String(n.tintColor):void 0})}return a}function ee(e){let a=[],r=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,i;while((i=r.exec(e))!==null){let n=O(i[1]||""),t=i[2]||"",o=String(n.label||n.title||`Space ${a.length+1}`);a.push({id:String(n.id||P(o)),label:o,icon:n.icon?String(n.icon):void 0,tint:n.tint?String(n.tint):void 0,sections:z(t)})}return a}function te(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let a=JSON.parse(e);return Array.isArray(a)?a:void 0}catch{return}}function re(e,a,r){let i=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${v(t.id)}" data-selected="${t.id===a?"true":"false"}" title="${v(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${v(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="${v(t.id)}" data-selected="${t.id===a?"true":"false"}">
|
|
2954
2954
|
${t.label?`<div class="craft-sidebar-space-title">${C(t.label)}</div>`:""}
|
|
2955
|
-
${t.sections.map((
|
|
2955
|
+
${t.sections.map((o)=>M(o,r)).join("")}
|
|
2956
2956
|
</section>`).join("")}</div>
|
|
2957
|
-
<div class="craft-sidebar-space-switcher">${i}</div>`}function
|
|
2958
|
-
<div class="craft-sidebar-section-title">${C(
|
|
2959
|
-
${e.items.map((i)=>
|
|
2960
|
-
</section>`}function
|
|
2961
|
-
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${
|
|
2957
|
+
<div class="craft-sidebar-space-switcher">${i}</div>`}function ae(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let a=JSON.parse(e);return Array.isArray(a)?a:void 0}catch{return}}function M(e,a){let r=e.header||e.title||e.id;return`<section class="craft-sidebar-section" data-section-id="${v(e.id)}">
|
|
2958
|
+
<div class="craft-sidebar-section-title">${C(r)}</div>
|
|
2959
|
+
${e.items.map((i)=>L(i,i.id===a)).join("")}
|
|
2960
|
+
</section>`}function L(e,a){let r=e.tintColor?` style="--craft-sidebar-icon-color:${v(e.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${v(e.id)}" data-selected="${a?"true":"false"}">
|
|
2961
|
+
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${v(e.icon)}"${r}></span>`:""}
|
|
2962
2962
|
<span class="craft-sidebar-item-label">${C(e.label)}</span>
|
|
2963
2963
|
${e.badge?`<span class="craft-sidebar-item-badge">${C(e.badge)}</span>`:""}
|
|
2964
|
-
</button>`}function
|
|
2965
|
-
</head>`)}let
|
|
2966
|
-
import handler from ${JSON.stringify(
|
|
2964
|
+
</button>`}function P(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function ie(e){let a=5381;for(let r=0;r<e.length;r++)a=a*33^e.charCodeAt(r);return(a>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function v(e){return C(e).replace(/`/g,"`")}function ne(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function se(e,a,r){let i=[];i.push(`class="${r.join(" ")}"`),i.push(`data-craft="${a.nativeType}"`);for(let[n,t]of Object.entries(e))if(t===!0)i.push(n);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,""");i.push(`${n}="${o}"`)}return i.join(" ")}function Xu(e,a){ls[e]=a}function Ju(){return{...ls}}import{copyFileSync as oe,mkdtempSync as ce,rmSync as de,writeFileSync as le}from"fs";import{tmpdir as fe}from"os";import{join as A}from"path";async function j(e,a=[],r={}){if(process.platform!=="darwin")return;let i=r.entitlements,n;try{if(r.provisioningProfile){if(!r.identity||r.identity==="-")throw Error("A provisioning profile requires a signing identity.");let l=Bun.spawnSync(["/usr/bin/security","cms","-D","-i",r.provisioningProfile]);if(l.exitCode!==0)throw Error("Could not decode the macOS provisioning profile.");let f=Bun.spawnSync(["/usr/bin/plutil","-extract","Entitlements","json","-o","-","-"],{stdin:l.stdout});if(f.exitCode!==0)throw Error("The macOS profile has no entitlement dictionary.");let p=JSON.parse(f.stdout.toString()),u={};if(r.entitlements){let g=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",r.entitlements]);if(g.exitCode!==0)throw Error("Could not read the app entitlements plist.");u=JSON.parse(g.stdout.toString())}for(let g of["com.apple.application-identifier","com.apple.developer.team-identifier"])if(p[g])u[g]=p[g];if(n=ce(A(fe(),"stx-entitlements-")),i=A(n,"entitlements.plist"),le(i,JSON.stringify(u)),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",i]).exitCode!==0)throw Error("Could not generate the provisioned app entitlements.");oe(r.provisioningProfile,A(e,"Contents","embedded.provisionprofile"))}for(let l of[...a,e]){let f=r.hardenedRuntime?["--options","runtime"]:[];if(l===e&&i)f.push("--entitlements",i);let p=r.identity&&r.identity!=="-"?"--timestamp":"--timestamp=none",u=Bun.spawn(["/usr/bin/codesign","--force","--sign",r.identity||"-",p,...f,l],{stdout:"pipe",stderr:"pipe"}),[g,b]=await Promise.all([new Response(u.stderr).text(),u.exited]);if(b!==0)throw Error(`Could not sign native bundle ${l}: ${g.trim()}`)}let t=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[o,c]=await Promise.all([new Response(t.stderr).text(),t.exited]);if(c!==0)throw Error(`Invalid native bundle signature: ${o.trim()}`)}finally{if(n)de(n,{recursive:!0,force:!0})}}async function Yo(e){let a=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||R(),format:e.format||"app",error:`Input file not found: ${e.input}`};let r=e.target||R(),i=e.format||$e(r);if(e.backend&&r!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!F(V(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let n=e.output||s(process.cwd(),"dist","native");if(!F(n))x(n,{recursive:!0});let t=await ni(e.input,{context:e.context,options:{isDev:!1}});if(t=Ko(t,{debug:e.verbose}),t=Jo(t),!t.includes("craft-component-styles")){if(t.includes("</head>"))t=t.replace("</head>",`${Xo}
|
|
2965
|
+
</head>`)}let o=e.name||ue(e.input,".stx"),c=e.version||"1.0.0",l=e.craftPath||await ke();if(!l)return{success:!1,target:r,format:i,error:"Craft binary not found. Please install Craft or specify craftPath."};if(e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${r}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${n}`),console.log(` Craft: ${l}`);let f;switch(r){case"macos":f=await me(t,o,c,n,i,e,l);break;case"windows":f=await ve(t,o,c,n,i,e,l);break;case"linux":f=await xe(t,o,c,n,i,e,l);break;case"ios":f=await ye(t,o,c,n,e,l);break;case"android":f=await Se(t,o,c,n,e,l);break;default:f={success:!1,target:r,format:i,error:`Unsupported target: ${r}`}}return f.duration=Date.now()-a,f}catch(r){return{success:!1,target:e.target||R(),format:e.format||"app",error:r.message,duration:Date.now()-a}}}async function me(e,a,r,i,n,t,o){let c=t.bundleId||`com.stx.${a.toLowerCase().replace(/[^a-z0-9]/g,"")}`,l=s(i,`${a}.app`),f=s(l,"Contents"),p=s(f,"MacOS"),u=s(f,"Resources");pe(l,{recursive:!0,force:!0}),x(p,{recursive:!0}),x(u,{recursive:!0});let g=s(u,"index.html");await Bun.write(g,e);let b="";if(t.sidebar?.enabled&&t.sidebar?.config)b=s(u,"sidebar-config.json"),await Bun.write(b,JSON.stringify(t.sidebar.config));let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",T=t.menubarOnly??t.systemTray,m=t.bundleStyle||(await he(o)?"executable":"launcher");if(t.backend){S(o,s(p,"craft-runtime")),k(s(p,"craft-runtime"),493);let y=Ce("native-backend");try{let h=s(y,"launcher.ts"),_=s(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(h,`import { runNativeBackend } from ${JSON.stringify(_)}
|
|
2966
|
+
import handler from ${JSON.stringify(V(t.backend.entry))}
|
|
2967
2967
|
await runNativeBackend({ html: ${JSON.stringify(e)}, fetch: handler,
|
|
2968
|
-
title: ${JSON.stringify(t.window?.title||
|
|
2968
|
+
title: ${JSON.stringify(t.window?.title||a)},
|
|
2969
2969
|
width: ${t.window?.width||1200}, height: ${t.window?.height||800},
|
|
2970
2970
|
maxRequestBodySize: ${t.backend.maxRequestBodySize??33554432},
|
|
2971
2971
|
devTools: ${Boolean(t.devTools)} })
|
|
2972
|
-
`);let
|
|
2973
|
-
${
|
|
2974
|
-
`)}else{let
|
|
2972
|
+
`);let I=Bun.spawn([process.execPath,"build",h,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",s(p,a)],{stdout:"pipe",stderr:"pipe"}),[B,J,Y]=await Promise.all([new Response(I.stdout).text(),new Response(I.stderr).text(),I.exited]);if(Y!==0)throw Error(`Native backend compilation failed: ${B}
|
|
2973
|
+
${J}`)}finally{U(y)}}else if(m==="executable"){let y=s(p,a);S(o,y),k(y,493);let h={html:"index.html",title:t.window?.title||a,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(t.trayPopover)h.trayPopover=!0;else if(T)h.menubarOnly=!0;else if(t.systemTray)h.systemTray=!0;if(t.window?.frameless)h.frameless=!0;if(t.window?.transparent)h.transparent=!0;if(t.window?.alwaysOnTop)h.alwaysOnTop=!0;if(t.window?.resizable===!1)h.resizable=!1;await Bun.write(s(u,"craft.json"),`${JSON.stringify(h,null,2)}
|
|
2974
|
+
`)}else{let y=s(p,"craft");S(o,y),k(y,493);let h=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",I=`#!/bin/bash
|
|
2975
2975
|
set -euo pipefail
|
|
2976
2976
|
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
2977
2977
|
RESOURCES="$DIR/../Resources"
|
|
2978
2978
|
exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
2979
|
-
${[`--title "${t.window?.title||
|
|
2980
|
-
`,B=
|
|
2981
|
-
${i}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[
|
|
2979
|
+
${[`--title "${t.window?.title||a}"`,`--width ${t.window?.width||1200}`,`--height ${t.window?.height||800}`,t.trayPopover?"--tray-popover":T?"--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":"",h].filter(Boolean).join(" \\\n ")}
|
|
2980
|
+
`,B=s(p,a);await Bun.write(B,I),k(B,493)}let D=Boolean(t.icon&&await Bun.file(t.icon).exists());if(D)S(t.icon,s(u,"AppIcon.icns"));let W={CFBundleExecutable:a,CFBundleIdentifier:c,CFBundleName:a,CFBundleDisplayName:a,CFBundleShortVersionString:r,CFBundleVersion:r,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.trayPopover||(t.menubarOnly??Boolean(t.systemTray)),...D?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(s(f,"Info.plist"),we(W)),await j(l,t.backend?[s(p,"craft-runtime")]:m==="launcher"?[s(p,"craft")]:[],t.macosSigning),n==="dmg"){let y=s(i,`${a}-${r}.dmg`),h=await Te(l,y,a);if(!h.success)return{success:!1,target:"macos",format:"dmg",error:h.error};return{success:!0,target:"macos",format:"dmg",outputPath:y}}return{success:!0,target:"macos",format:"app",outputPath:l}}async function he(e){try{let a=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[r,i]=await Promise.all([new Response(a.stdout).text(),new Response(a.stderr).text()]);await a.exited;let t=`${r}
|
|
2981
|
+
${i}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[o,c,l]=t.slice(1).map(Number);if(o>0||c>0)return!0;return l>=57}catch{return!1}}function H(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function we(e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2982
2982
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
2983
2983
|
<plist version="1.0">
|
|
2984
2984
|
<dict>
|
|
2985
|
-
${Object.entries(e).map(([
|
|
2986
|
-
${
|
|
2985
|
+
${Object.entries(e).map(([r,i])=>{let n=typeof i==="boolean"?`<${i}/>`:typeof i==="number"?`<integer>${i}</integer>`:`<string>${H(String(i))}</string>`;return` <key>${H(r)}</key>
|
|
2986
|
+
${n}`}).join(`
|
|
2987
2987
|
`)}
|
|
2988
2988
|
</dict>
|
|
2989
2989
|
</plist>
|
|
2990
|
-
`}async function
|
|
2990
|
+
`}async function ve(e,a,r,i,n,t,o){let c=s(i,a);x(c,{recursive:!0});let l=s(c,"index.html");await Bun.write(l,e),S(o,s(c,"craft.exe"));let f=`@echo off
|
|
2991
2991
|
set DIR=%~dp0
|
|
2992
2992
|
"%DIR%craft.exe" --html-file "%DIR%index.html" ^
|
|
2993
|
-
--title "${t.window?.title||
|
|
2993
|
+
--title "${t.window?.title||a}" ^
|
|
2994
2994
|
--width ${t.window?.width||1200} ^
|
|
2995
2995
|
--height ${t.window?.height||800} ^
|
|
2996
2996
|
${t.systemTray?"--system-tray":""} ^
|
|
2997
2997
|
${t.devTools?"":"--no-devtools"}
|
|
2998
|
-
`;if(await Bun.write(
|
|
2998
|
+
`;if(await Bun.write(s(c,`${a}.bat`),f),n==="zip"){let p=s(i,`${a}-${r}-windows.zip`),u=await Pe(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 xe(e,a,r,i,n,t,o){let c=s(i,a);x(c,{recursive:!0});let l=s(c,"index.html");await Bun.write(l,e);let f=s(c,"craft");S(o,f),k(f,493);let p=`#!/bin/bash
|
|
2999
2999
|
set -euo pipefail
|
|
3000
3000
|
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
3001
3001
|
exec "$DIR/craft" --html-file "$DIR/index.html" \\
|
|
3002
|
-
--title "${t.window?.title||
|
|
3002
|
+
--title "${t.window?.title||a}" \\
|
|
3003
3003
|
--width ${t.window?.width||1200} \\
|
|
3004
3004
|
--height ${t.window?.height||800} \\
|
|
3005
3005
|
${t.systemTray?"--system-tray":""} \\
|
|
3006
3006
|
${t.devTools?"":"--no-devtools"}
|
|
3007
|
-
`,u=
|
|
3007
|
+
`,u=s(c,a.toLowerCase());await Bun.write(u,p),k(u,493);let g=`[Desktop Entry]
|
|
3008
3008
|
Type=Application
|
|
3009
|
-
Name=${
|
|
3009
|
+
Name=${a}
|
|
3010
3010
|
Exec=${u}
|
|
3011
3011
|
Terminal=false
|
|
3012
3012
|
Categories=Utility;
|
|
3013
|
-
`;if(await Bun.write(
|
|
3014
|
-
`)[0];if(
|
|
3015
|
-
exec /usr/share/${
|
|
3013
|
+
`;if(await Bun.write(s(c,`${a.toLowerCase()}.desktop`),g),n==="deb"){let b=s(i,`${a.toLowerCase()}_${r}_amd64.deb`),w=await Ie(c,b,a,r,t);if(!w.success)return{success:!1,target:"linux",format:"deb",error:w.error};return{success:!0,target:"linux",format:"deb",outputPath:b}}if(n==="appimage"){let b=s(i,`${a}-${r}-x86_64.AppImage`),w=await Re(c,b,a,t);if(!w.success)return{success:!1,target:"linux",format:"appimage",error:w.error};return{success:!0,target:"linux",format:"appimage",outputPath:b}}return{success:!0,target:"linux",format:"app",outputPath:c}}async function ye(e,a,r,i,n,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${a}' to create an iOS project.`}}async function Se(e,a,r,i,n,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${a}' to create an Android project.`}}async function ke(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let e=[s(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),s(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),s(q(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),s(q(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",s(q(),".local/bin/craft"),s(process.env.LOCALAPPDATA||"","craft","craft.exe"),s(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let a of e)if(await Bun.file(a).exists())return a;try{let r=be("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
|
|
3014
|
+
`)[0];if(r&&await Bun.file(r).exists())return r}catch{}return null}function R(){switch(ge()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function $e(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 Te(e,a,r){return new Promise((i)=>{let n=N("hdiutil",["create","-volname",r,"-srcfolder",e,"-ov","-format","UDZO",a]);n.on("close",(t)=>{if(t===0)i({success:!0});else i({success:!1,error:`hdiutil exited with code ${t}`})}),n.on("error",(t)=>{i({success:!1,error:t.message})})})}async function Pe(e,a){return new Promise((r)=>{let i=N("zip",["-r",a,"."],{cwd:e});i.on("close",(n)=>{if(n===0)r({success:!0});else r({success:!1,error:`zip exited with code ${n}`})}),i.on("error",(n)=>{r({success:!1,error:n.message})})})}async function Ie(e,a,r,i,n){return new Promise((t)=>{let o=Ce("deb");try{let c=s(o,"pkg"),l=s(c,"DEBIAN"),f=s(c,"usr","bin"),p=s(c,"usr","share","applications"),u=s(c,"usr","share",r.toLowerCase());x(l,{recursive:!0}),x(f,{recursive:!0}),x(p,{recursive:!0}),x(u,{recursive:!0});let g=d("fs").readdirSync(e);for(let m of g)S(s(e,m),s(u,m));let b=`#!/bin/bash
|
|
3015
|
+
exec /usr/share/${r.toLowerCase()}/${r.toLowerCase()} "$@"`;d("fs").writeFileSync(s(f,r.toLowerCase()),b),k(s(f,r.toLowerCase()),493);let w=`Package: ${r.toLowerCase()}
|
|
3016
3016
|
Version: ${i}
|
|
3017
3017
|
Section: utils
|
|
3018
3018
|
Priority: optional
|
|
3019
3019
|
Architecture: amd64
|
|
3020
3020
|
Depends: libgtk-3-0, libwebkit2gtk-4.0-37
|
|
3021
|
-
Maintainer: ${
|
|
3022
|
-
Description: ${
|
|
3023
|
-
`;d("fs").writeFileSync(
|
|
3021
|
+
Maintainer: ${n.author||"Unknown"}
|
|
3022
|
+
Description: ${n.description||r}
|
|
3023
|
+
`;d("fs").writeFileSync(s(l,"control"),w);let T=N("dpkg-deb",["--build",c,a]);T.on("close",(m)=>{if(U(o),m===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${m}`})}),T.on("error",(m)=>{U(o),t({success:!1,error:m.message})})}catch(c){U(o),t({success:!1,error:c.message})}})}async function Re(e,a,r,i){return new Promise((n)=>{let t=Ce("appimage");try{let o=s(t,`${r}.AppDir`),c=s(o,"usr"),l=s(c,"bin"),f=s(c,"share");x(l,{recursive:!0}),x(f,{recursive:!0});let p=s(f,r.toLowerCase());x(p,{recursive:!0});let u=d("fs").readdirSync(e);for(let m of u)S(s(e,m),s(p,m));let g=`#!/bin/bash
|
|
3024
3024
|
SELF=$(readlink -f "$0")
|
|
3025
3025
|
HERE=\${SELF%/*}
|
|
3026
3026
|
export PATH="\${HERE}/usr/bin:\${PATH}"
|
|
3027
|
-
exec "\${HERE}/usr/share/${
|
|
3028
|
-
`;d("fs").writeFileSync(o
|
|
3027
|
+
exec "\${HERE}/usr/share/${r.toLowerCase()}/${r.toLowerCase()}" "$@"
|
|
3028
|
+
`;d("fs").writeFileSync(s(o,"AppRun"),g),k(s(o,"AppRun"),493);let b=`[Desktop Entry]
|
|
3029
3029
|
Type=Application
|
|
3030
|
-
Name=${
|
|
3031
|
-
Exec=${
|
|
3030
|
+
Name=${r}
|
|
3031
|
+
Exec=${r.toLowerCase()}
|
|
3032
3032
|
Terminal=false
|
|
3033
3033
|
Categories=Utility;
|
|
3034
|
-
Icon=${
|
|
3035
|
-
`;d("fs").writeFileSync(o
|
|
3034
|
+
Icon=${r.toLowerCase()}
|
|
3035
|
+
`;d("fs").writeFileSync(s(o,`${r.toLowerCase()}.desktop`),b);let w=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(s(o,`${r.toLowerCase()}.png`),w),i.icon&&F(i.icon))S(i.icon,s(o,`${r.toLowerCase()}.png`));let T=N("appimagetool",[o,a],{env:{...process.env,ARCH:"x86_64"}});T.on("close",(m)=>{if(U(t),m===0)k(a,493),n({success:!0});else n({success:!1,error:`appimagetool exited with code ${m}. Install from https://appimage.github.io/appimagetool/`})}),T.on("error",(m)=>{U(t),n({success:!1,error:`appimagetool not found: ${m.message}`})})}catch(o){U(t),n({success:!1,error:o.message})}})}function Zo(){return[R()]}function Qo(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 Be={buildNative:Yo,getAvailableTargets:Zo,getAvailableFormats:Qo,detectPlatform:R},Yu=Be;
|
|
3036
3036
|
export{Wu,Go,qu,Gu,Ko,ls,Xo,Ku,Jo,Xu,Ju,Yo,Zo,Qo,Yu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{u,Ds,Oi,Ni,Qc,el,tl,nl,rl,Vs,sl,rt,B,st,ol,hr,il,ji,Us,ot,r,yr,Bi,g,ie,kd}from"./chunk-
|
|
2
|
+
import{u,Ds,Oi,Ni,Qc,el,tl,nl,rl,Vs,sl,rt,B,st,ol,hr,il,ji,Us,ot,r,yr,Bi,g,ie,kd}from"./chunk-bdq0vnky.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-57a0vpr2.js";import"./chunk-a0ygyftk.js";import"./chunk-6vmvra0f.js";import"./chunk-qmh6f1bt.js";import"./chunk-m92q2jyt.js";import"./chunk-ahyq08mp.js";import"./chunk-g1ae3haw.js";import"./chunk-gsp3627d.js";import"./chunk-pvfx0dgz.js";export{ie as clearComponentCache,Us as componentClientSignalNames,Ds as convertToCommonJS,g as createDetailedErrorMessage,rl as extractDirectiveNames,Oi as extractScriptFromTemplate,u as extractVariables,r as fileExists,kd as getComponentCacheStats,el as getPositionInfo,B as getSharedTranspiler,Bi as getSourceLineInfo,nl as hasDirectives,Ni as hasVariables,il as isHydrateTrigger,sl as isJavaScriptScript,ot as renderComponentWithSlot,yr as resolveTemplatePath,ol as scopeOnRootElement,Vs as scopeSequenceKey,rt as shouldTranspileTypeScript,ji as slotContentHasExpressions,st as transpileTypeScript,hr as userComponentFileExists,tl as validateDirective,Qc as validateTemplate};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ir,Ge,_e,Ee,xi,dr,oe,Q,Tn,u,$n,n,A}from"./chunk-
|
|
2
|
+
import{ir,Ge,_e,Ee,xi,dr,oe,Q,Tn,u,$n,n,A}from"./chunk-bdq0vnky.js";function b(o){return o.endsWith(".md")||o.endsWith(".markdown")}function C(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let s=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,s);function m(r,p){let g;while((g=r.exec(o))!==null){let t=g.index,i=t+g[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((r,p)=>r.start-p.start);let a="",c=0;for(let r of e){if(r.start<c)continue;a+=o.slice(c,r.start),a+=`@raw${o.slice(r.start,r.end)}@endraw`,c=r.end}return a+=o.slice(c),a}async function R(o,e={}){let{data:s,content:m}=ir(o),c=await(e.renderer??((r)=>Ge(r)))(m);return{html:C(c),frontmatter:s??{}}}import{dirname as k,resolve as _}from"path";function v(o){let e=o,s=oe(o);if(s)e=s.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],r=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),g;while((g=m.exec(o))!==null){let i=g[1],l=g[2],d=g[0],f=i.includes("server");if(p(l))r.push(d);else if(f)c.push(l);else a.push(d)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=i.exec(t))!==null){let f=l.index+l[0].length,w=t.indexOf("</script>",f);if(w===-1)continue;d.push({start:l.index,end:w+9}),i.lastIndex=w+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:r}}function M(o,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -14,5 +14,5 @@ ${c.join(`
|
|
|
14
14
|
`)}`}else{if(s.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=_e(p),d=await Promise.all(c.map(async(y)=>{let h=y.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!h)return y;return await Ee(h[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})})),w=[await $n(d,{...r,buildMode:"compile"}),...d].filter(Boolean).join(`
|
|
15
15
|
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${w}
|
|
16
16
|
$1`);else t+=`
|
|
17
|
-
${w}`}t=await Q(t)}if(s.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,s.title)}if(s.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
17
|
+
${w}`}t=await Q(t)}if(s.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,s.title)}if(s.injectCSS)try{let{injectCss:i}=await import("./chunk-kmzadv6e.js");t=await i(t)}catch{}return t}
|
|
18
18
|
export{ni};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Z,n}from"./chunk-
|
|
2
|
+
import{Z,n}from"./chunk-bdq0vnky.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${r.description}`),console.log(` Usage: ${e.cyan}${r.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -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-f20eg3gr.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-y51ndrdb.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-htez1y6d.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-wj4rf7sb.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{je,Be,Fe}from"./chunk-6mnwvn9v.js";import"./chunk-g1ae3haw.js";import"./chunk-ahyq08mp.js";import{u}from"./chunk-
|
|
2
|
+
import{je,Be,Fe}from"./chunk-6mnwvn9v.js";import"./chunk-g1ae3haw.js";import"./chunk-ahyq08mp.js";import{u}from"./chunk-bdq0vnky.js";import"./chunk-m92q2jyt.js";import"./chunk-y255yybn.js";import"./chunk-gsp3627d.js";import"./chunk-qmh6f1bt.js";import"./chunk-6vmvra0f.js";import"./chunk-1m5cjrpw.js";import"./chunk-a0ygyftk.js";import"./chunk-57a0vpr2.js";import"./chunk-pvfx0dgz.js";import{vt,Lr,wt,go,Le,mo,jr,xt,yo,St}from"./chunk-1t0m4pwg.js";import"./chunk-r00nn2qs.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()=>{mo("Config file changed, restarting...");try{await e.onChange()}catch(p){Le(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:dt(),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 dt(){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 lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),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:ut(),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,mt),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 ut(){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 lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),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:ut(),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,mt),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 ut(){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-k18pqctb.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 gt(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 gt(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 ft(t,a.source,c);return b(t,e.path,{props:c})}async function ft(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-k18pqctb.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
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 xt(t);Be(t,r);let s=St(t.config,r);Fe(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 yt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return ht(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=yo(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await xt(t);Be(t,m);let f=St(t.config,m);if(Fe(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 yt(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 ht(t,e,r){let s=bt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function bt(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"}">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{kl}from"./chunk-
|
|
2
|
+
import{kl}from"./chunk-sz4wg3b5.js";import"./chunk-bdq0vnky.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-57a0vpr2.js";import"./chunk-a0ygyftk.js";import"./chunk-6vmvra0f.js";import"./chunk-qmh6f1bt.js";import"./chunk-m92q2jyt.js";import"./chunk-ahyq08mp.js";import"./chunk-g1ae3haw.js";import"./chunk-gsp3627d.js";import"./chunk-pvfx0dgz.js";export{kl as startInteractive};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ha,ya}from"./chunk-0rdjara0.js";import"./chunk-sz4wg3b5.js";import"./chunk-h5bvw8x2.js";import"./chunk-j00v4m56.js";import"./chunk-9939fjh4.js";import"./chunk-j7xbbp8y.js";import"./chunk-6avpd901.js";import"./chunk-k93mp0gj.js";import{Po}from"./chunk-b7hchpv4.js";import"./chunk-fztvkacg.js";import"./chunk-639ngkgb.js";import"./chunk-074s7tdg.js";import"./chunk-45xhjrha.js";import"./chunk-s775b8ra.js";import"./chunk-8m18taj7.js";import"./chunk-5e063mgs.js";import"./chunk-48yja477.js";import"./chunk-aztp8r80.js";import"./chunk-drrczm0b.js";import"./chunk-fwdptew6.js";import"./chunk-5wyp57g3.js";import"./chunk-b4j5bpec.js";import"./chunk-b094vnjy.js";import"./chunk-wjq1wqn6.js";import"./chunk-60azcvwr.js";import"./chunk-88p10v0w.js";import"./chunk-c858mepd.js";import"./chunk-qy11cp1v.js";import"./chunk-0nhhcn8h.js";import"./chunk-dcwhp21g.js";import"./chunk-e2e9pkgh.js";import"./chunk-stam369d.js";import"./chunk-gmxrckgj.js";import"./chunk-gqz26wza.js";import"./chunk-jetfkqht.js";import"./chunk-ks5wfvzq.js";import"./chunk-bsts9pr5.js";import{Ee,xn,Sn,Q,u,n,br,A,o,be}from"./chunk-bdq0vnky.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-57a0vpr2.js";import"./chunk-a0ygyftk.js";import"./chunk-6vmvra0f.js";import"./chunk-qmh6f1bt.js";import"./chunk-m92q2jyt.js";import"./chunk-ahyq08mp.js";import"./chunk-g1ae3haw.js";import"./chunk-gsp3627d.js";import"./chunk-pvfx0dgz.js";export{br as buildWebComponents,Sn as cacheTemplate,xn as checkCache,Po as classifyAllScripts,ha as createMiddleware,ya as createRoute,A as defaultConfig,u as extractVariables,Q as injectRouterScript,o as loadStxConfig,Ee as processClientScript,n as processDirectives,be as readMarkdownFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ul}from"./chunk-
|
|
2
|
+
import{Ul}from"./chunk-074s7tdg.js";import"./chunk-bdq0vnky.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-57a0vpr2.js";import"./chunk-a0ygyftk.js";import"./chunk-6vmvra0f.js";import"./chunk-qmh6f1bt.js";import"./chunk-m92q2jyt.js";import"./chunk-ahyq08mp.js";import"./chunk-g1ae3haw.js";import"./chunk-gsp3627d.js";import"./chunk-pvfx0dgz.js";export{Ul as buildApp};
|