@stacksjs/stx 0.2.639 → 0.2.641
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-nfqk2m0e.js → chunk-06w3s9gq.js} +1 -1
- package/dist/chunk-0bksh0c0.js +2 -0
- package/dist/{chunk-z2s2f36w.js → chunk-1t2emmxe.js} +1 -1
- package/dist/{chunk-5xepx5y1.js → chunk-2f6mvvwk.js} +5 -5
- package/dist/{chunk-q0n4vgy8.js → chunk-32j06rtz.js} +1 -1
- package/dist/{chunk-n8vqhbgp.js → chunk-32yz18fd.js} +1 -1
- package/dist/{chunk-x5h1qspg.js → chunk-3p0qjenv.js} +1 -1
- package/dist/{chunk-4fqkamxa.js → chunk-5a50m90y.js} +1 -1
- package/dist/{chunk-hd080add.js → chunk-6mwwg8t5.js} +1 -1
- package/dist/{chunk-c8wkjjs5.js → chunk-6pmm4a7x.js} +1 -1
- package/dist/{chunk-f920yx9g.js → chunk-6w0e7wfq.js} +1 -1
- package/dist/{chunk-6e5t8e5b.js → chunk-7pha60mn.js} +1 -1
- package/dist/{chunk-tt78ksns.js → chunk-8jqr3mrw.js} +1 -1
- package/dist/{chunk-tjmy7vq3.js → chunk-8z1qpe3d.js} +1 -1
- package/dist/{chunk-5wep11np.js → chunk-94znr894.js} +1 -1
- package/dist/{chunk-2yycvrt9.js → chunk-967tfsby.js} +1 -1
- package/dist/{chunk-7mv2dr59.js → chunk-96etsv47.js} +2 -2
- package/dist/{chunk-gk9629wk.js → chunk-az24jgff.js} +1 -1
- package/dist/{chunk-afvs2d83.js → chunk-b9ja34n4.js} +55 -55
- package/dist/{chunk-bxj5wg5n.js → chunk-c37ys0h4.js} +1 -1
- package/dist/{chunk-xzpq96dc.js → chunk-dc16xt8w.js} +1 -1
- package/dist/{chunk-06y8nsyj.js → chunk-dy8zpcph.js} +1 -1
- package/dist/chunk-efnt9rq0.js +2 -0
- package/dist/{chunk-ptj8qcbc.js → chunk-epgjrwpw.js} +1 -1
- package/dist/{chunk-9xrmv78p.js → chunk-eqgg5pax.js} +1 -1
- package/dist/{chunk-k3sre98y.js → chunk-f31n0ag7.js} +1 -1
- package/dist/{chunk-3qv5dkz3.js → chunk-f82jd4j3.js} +1 -1
- package/dist/{chunk-e1khh3pf.js → chunk-fgrxy18t.js} +1 -1
- package/dist/{chunk-rc0yb6rk.js → chunk-fkpsyk7k.js} +1 -1
- package/dist/{chunk-0dxw5xbk.js → chunk-g9mzgscw.js} +1 -1
- package/dist/{chunk-901x249w.js → chunk-gg2kxtbz.js} +1 -1
- package/dist/{chunk-bhvbtk5v.js → chunk-j2e16j5h.js} +1 -1
- package/dist/{chunk-svgzmrxm.js → chunk-k7anjg46.js} +1 -1
- package/dist/{chunk-2ekfrm68.js → chunk-kc28g7z3.js} +1 -1
- package/dist/{chunk-bwhwkb22.js → chunk-kpa73y6y.js} +1 -1
- package/dist/chunk-ktxfwpvm.js +2 -0
- package/dist/{chunk-gpztrw67.js → chunk-kyc4m05g.js} +1 -1
- package/dist/{chunk-msp7zz1a.js → chunk-mefkgsn2.js} +2 -2
- package/dist/{chunk-me88325a.js → chunk-mxc5gem0.js} +1 -1
- package/dist/{chunk-rfxtatzg.js → chunk-nx6asyhf.js} +1 -1
- package/dist/{chunk-wp2d4cyc.js → chunk-pzwtx9mz.js} +3 -3
- package/dist/{chunk-6rpt4s20.js → chunk-qey0czx3.js} +1 -1
- package/dist/{chunk-gyrmwwgm.js → chunk-sn6qj2jz.js} +18 -18
- package/dist/{chunk-06d1sznf.js → chunk-tr0behn9.js} +1 -1
- package/dist/{chunk-2rffxmdh.js → chunk-vk4pnexw.js} +1 -1
- package/dist/{chunk-4v652fjx.js → chunk-vpqqfy9p.js} +2 -2
- package/dist/{chunk-4fe9hw31.js → chunk-w2wm9ef4.js} +1 -1
- package/dist/{chunk-brfknbwn.js → chunk-yh5f3v74.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-build.js +2 -0
- package/dist/native-signing.d.ts +2 -0
- package/dist/native-signing.js +12 -0
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-b5ctmyf5.js +0 -2
- package/dist/chunk-d5q7sq7c.js +0 -2
- package/dist/chunk-rdgjwpte.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-96etsv47.js";import{d}from"./chunk-yn2d8x8m.js";import{existsSync as q,mkdirSync as v,copyFileSync as S,chmodSync as k,rmSync as ne}from"fs";import{join as n,basename as oe,resolve as H}from"path";import{spawn as A,execSync as ce}from"child_process";import{homedir as O,platform as de}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:r=!1,timeout:a=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: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function qu(){return!1}function Gu(e,r={}){let a=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(a,(i,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return Go(t)})}function Ko(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let a=Go(r);if(e.includes("</head>"))return e.replace("</head>",`${a}
|
|
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
|
+
${a}`);return a+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,r)=>{let a=e.checked?"checked":"",i=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
943
|
+
<input type="checkbox" class="craft-checkbox" ${a} ${i}>
|
|
944
|
+
<span class="craft-checkbox-label">${r||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,r)=>{let a=e.min??0,i=e.max??100,s=e.step??1,t=e.value??50,o=e.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${a}" max="${i}" step="${s}" 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,r)=>{let a=e.size||40,i=e.src,s=String(e.alt||""),t=e.fallback||(s?s.charAt(0).toUpperCase():"?");if(i)return`<img class="craft-avatar" src="${i}" alt="${s}" style="width:${a}px;height:${a}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${a}px;height:${a}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,r)=>{let a=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,a/i*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:(e,r)=>{let a=e.size||24;return`<div class="craft-spinner" style="width:${a}px;height:${a}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,r)=>{let a=e.open?"open":"",i=e.title||"";return`<dialog class="craft-modal" ${a}>
|
|
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">${r}</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,r)=>{let a=e.open?"open":"",i=e.title||"Details";return`<details class="craft-accordion" ${a}>
|
|
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">${r}</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,r)=>{let a=e.variant||"info",i=e.title||"";return`<div class="craft-alert craft-alert-${a}" 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">${r}</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,r)=>{let a=e.content||"",i=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${a}" data-position="${i}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:Y},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:Q},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:G},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:X},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let a=e.value||"",i=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${a}" min="${i}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},Xo=`
|
|
957
957
|
<style id="craft-component-styles">
|
|
958
958
|
/* Craft Component Base Styles */
|
|
959
959
|
.craft-button {
|
|
@@ -1475,7 +1475,7 @@ ${r}`);return r+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,r={}){let{classPrefix:a="craft"}=r;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 @@ ${r}`);return r+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,s,t)=>E("sidebar",s,t.trim(),a
|
|
2943
|
+
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,s,t)=>E("sidebar",s,t.trim(),r,a)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>E("sidebar",s,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>E(s,t,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,o)=>E(s,t,o.trim(),r,a)),e}function E(e,r,a,i,s){let t=i.components?.[e]||ls[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${a}</div>`;let o=N(r),c=[t.fallbackClasses||`${s}-${e}`];if(o.class)c.push(o.class),delete o.class;if(t.render)return o.__fallbackClasses=c.join(" "),t.render(o,a);let l=se(o,t,c);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${l}>`;return`<${t.fallbackTag} ${l}>${a}</${t.fallbackTag}>`}function N(e){let r={},a=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,i;while((i=a.exec(e))!==null){let[s,t,o,c]=i,l=o??c;if(s.startsWith(":"))r[t]=l;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=l;else if(l===void 0)r[t]=!0;else r[t]=l}return r}function Y(e,r){let a=I(String(e.id||`craft-sidebar-${ae(r||JSON.stringify(e))}`)),i=ee(e.spaces)||Z(r),s=i.length?[]:re(e.sections)||_(r),t=String(e.selectedSpace||i[0]?.id||""),o=i.find((h)=>h.id===t)||i[0],c=String(e.selectedItem||e.selected||(i.length?o?.sections[0]?.items[0]?.id:s[0]?.items[0]?.id)||""),l={id:a,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:c,sections:s,spaces:i,selectedSpace:t||void 0},f=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),p=Number(e.width||e.sidebarWidth||286),u=e.native===!1||e.native==="false"?"false":"true",y=l.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C(l.searchPlaceholder)}"></div>`:"",g;if(i.length)g=te(i,t,c);else if(s.length)g=s.map((h)=>z(h,c)).join("");else g=r;return`<aside class="${w(f)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${w(a)}" data-native="${u}" style="--craft-sidebar-width:${p}px">
|
|
2944
2944
|
${y}
|
|
2945
|
-
${
|
|
2945
|
+
${g}
|
|
2946
2946
|
</aside>
|
|
2947
|
-
<script type="application/json" data-craft-sidebar-config="${w(
|
|
2947
|
+
<script type="application/json" data-craft-sidebar-config="${w(a)}">${ie(l)}</script>`}function Q(e,r){let a=I(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${w(a)}">
|
|
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
|
+
${r}
|
|
2950
|
+
</section>`}function G(e,r){let a=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${w(String(e.id||"section"))}">
|
|
2951
|
+
${a?`<div class="craft-sidebar-section-title">${C(a)}</div>`:""}
|
|
2952
|
+
${r}
|
|
2953
|
+
</section>`}function X(e,r){let a={id:String(e.id||I(String(e.label||r||"item"))),label:String(e.label||r||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return M(a,String(e.selected||"")==="true")}function _(e){let r=[],a=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,i;while((i=a.exec(e))!==null){let s=N(i[1]||""),t=i[2]||"",o=String(s.id||I(String(s.header||s.title||`section-${r.length+1}`))),c=String(s.header||s.title||o),l=K(t);r.push({id:o,header:c,title:c,items:l})}return r}function K(e){let r=[],a=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,i;while((i=a.exec(e))!==null){let s=N(i[1]||""),t=String(s.label||(i[2]||"").replace(/<[^>]*>/g,"").trim()),o=String(s.id||I(t||`item-${r.length+1}`));r.push({id:o,label:t,icon:s.icon?String(s.icon):void 0,badge:s.badge?String(s.badge):void 0,tintColor:s.tintColor?String(s.tintColor):void 0})}return r}function Z(e){let r=[],a=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,i;while((i=a.exec(e))!==null){let s=N(i[1]||""),t=i[2]||"",o=String(s.label||s.title||`Space ${r.length+1}`);r.push({id:String(s.id||I(o)),label:o,icon:s.icon?String(s.icon):void 0,tint:s.tint?String(s.tint):void 0,sections:_(t)})}return r}function ee(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function te(e,r,a){let i=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${w(t.id)}" data-selected="${t.id===r?"true":"false"}" title="${w(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${w(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="${w(t.id)}" data-selected="${t.id===r?"true":"false"}">
|
|
2954
2954
|
${t.label?`<div class="craft-sidebar-space-title">${C(t.label)}</div>`:""}
|
|
2955
|
-
${t.sections.map((o)=>z(o,
|
|
2955
|
+
${t.sections.map((o)=>z(o,a)).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)=>M(i,i.id===
|
|
2960
|
-
</section>`}function M(e,
|
|
2961
|
-
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${w(e.icon)}"${
|
|
2957
|
+
<div class="craft-sidebar-space-switcher">${i}</div>`}function re(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function z(e,r){let a=e.header||e.title||e.id;return`<section class="craft-sidebar-section" data-section-id="${w(e.id)}">
|
|
2958
|
+
<div class="craft-sidebar-section-title">${C(a)}</div>
|
|
2959
|
+
${e.items.map((i)=>M(i,i.id===r)).join("")}
|
|
2960
|
+
</section>`}function M(e,r){let a=e.tintColor?` style="--craft-sidebar-icon-color:${w(e.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${w(e.id)}" data-selected="${r?"true":"false"}">
|
|
2961
|
+
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${w(e.icon)}"${a}></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 I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function ae(e){let
|
|
2965
|
-
</head>`)}let o=e.name||
|
|
2966
|
-
import handler from ${JSON.stringify(
|
|
2964
|
+
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function ae(e){let r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function w(e){return C(e).replace(/`/g,"`")}function ie(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function se(e,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,""");i.push(`${s}="${o}"`)}return i.join(" ")}function Xu(e,r){ls[e]=r}function Ju(){return{...ls}}async function L(e,r=[]){if(process.platform!=="darwin")return;for(let t of[...r,e]){let o=Bun.spawn(["/usr/bin/codesign","--force","--sign","-","--timestamp=none",t],{stdout:"pipe",stderr:"pipe"}),[c,l]=await Promise.all([new Response(o.stderr).text(),o.exited]);if(l!==0)throw Error(`Could not sign native bundle ${t}: ${c.trim()}`)}let a=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[i,s]=await Promise.all([new Response(a.stderr).text(),a.exited]);if(s!==0)throw Error(`Invalid native bundle signature: ${i.trim()}`)}async function Yo(e){let r=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 a=e.target||R(),i=e.format||we(a);if(e.backend&&a!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!q(H(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let s=e.output||n(process.cwd(),"dist","native");if(!q(s))v(s,{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||oe(e.input,".stx"),c=e.version||"1.0.0",l=e.craftPath||await he();if(!l)return{success:!1,target:a,format:i,error:"Craft binary not found. Please install Craft or specify craftPath."};if(e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${a}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${l}`);let f;switch(a){case"macos":f=await le(t,o,c,s,i,e,l);break;case"windows":f=await ue(t,o,c,s,i,e,l);break;case"linux":f=await be(t,o,c,s,i,e,l);break;case"ios":f=await ge(t,o,c,s,e,l);break;case"android":f=await me(t,o,c,s,e,l);break;default:f={success:!1,target:a,format:i,error:`Unsupported target: ${a}`}}return f.duration=Date.now()-r,f}catch(a){return{success:!1,target:e.target||R(),format:e.format||"app",error:a.message,duration:Date.now()-r}}}async function le(e,r,a,i,s,t,o){let c=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,l=n(i,`${r}.app`),f=n(l,"Contents"),p=n(f,"MacOS"),u=n(f,"Resources");ne(l,{recursive:!0,force:!0}),v(p,{recursive:!0}),v(u,{recursive:!0});let y=n(u,"index.html");await Bun.write(y,e);let g="";if(t.sidebar?.enabled&&t.sidebar?.config)g=n(u,"sidebar-config.json"),await Bun.write(g,JSON.stringify(t.sidebar.config));let h=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",T=t.menubarOnly??t.systemTray,b=t.bundleStyle||(await fe(o)?"executable":"launcher");if(t.backend){S(o,n(p,"craft-runtime")),k(n(p,"craft-runtime"),493);let x=Ce("native-backend");try{let m=n(x,"launcher.ts"),D=n(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(m,`import { runNativeBackend } from ${JSON.stringify(D)}
|
|
2966
|
+
import handler from ${JSON.stringify(H(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||r)},
|
|
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 P=Bun.spawn([process.execPath,"build",m,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",n(p,
|
|
2973
|
-
${
|
|
2972
|
+
`);let P=Bun.spawn([process.execPath,"build",m,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",n(p,r)],{stdout:"pipe",stderr:"pipe"}),[B,W,J]=await Promise.all([new Response(P.stdout).text(),new Response(P.stderr).text(),P.exited]);if(J!==0)throw Error(`Native backend compilation failed: ${B}
|
|
2973
|
+
${W}`)}finally{U(x)}}else if(b==="executable"){let x=n(p,r);S(o,x),k(x,493);let m={html:"index.html",title:t.window?.title||r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(t.trayPopover)m.trayPopover=!0;else if(T)m.menubarOnly=!0;else if(t.systemTray)m.systemTray=!0;if(t.window?.frameless)m.frameless=!0;if(t.window?.transparent)m.transparent=!0;if(t.window?.alwaysOnTop)m.alwaysOnTop=!0;if(t.window?.resizable===!1)m.resizable=!1;await Bun.write(n(u,"craft.json"),`${JSON.stringify(m,null,2)}
|
|
2974
2974
|
`)}else{let x=n(p,"craft");S(o,x),k(x,493);let m=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",P=`#!/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=n(p,
|
|
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
|
|
2979
|
+
${[`--title "${t.window?.title||r}"`,`--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":"",m].filter(Boolean).join(" \\\n ")}
|
|
2980
|
+
`,B=n(p,r);await Bun.write(B,P),k(B,493)}let F=Boolean(t.icon&&await Bun.file(t.icon).exists());if(F)S(t.icon,n(u,"AppIcon.icns"));let V={CFBundleExecutable:r,CFBundleIdentifier:c,CFBundleName:r,CFBundleDisplayName:r,CFBundleShortVersionString:a,CFBundleVersion:a,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.trayPopover||(t.menubarOnly??Boolean(t.systemTray)),...F?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(n(f,"Info.plist"),pe(V)),await L(l,t.backend?[n(p,"craft-runtime")]:b==="launcher"?[n(p,"craft")]:[]),s==="dmg"){let x=n(i,`${r}-${a}.dmg`),m=await ve(l,x,r);if(!m.success)return{success:!1,target:"macos",format:"dmg",error:m.error};return{success:!0,target:"macos",format:"dmg",outputPath:x}}return{success:!0,target:"macos",format:"app",outputPath:l}}async function fe(e){try{let r=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[a,i]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]);await r.exited;let t=`${a}
|
|
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 j(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function pe(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(([
|
|
2985
|
+
${Object.entries(e).map(([a,i])=>{let s=typeof i==="boolean"?`<${i}/>`:typeof i==="number"?`<integer>${i}</integer>`:`<string>${j(String(i))}</string>`;return` <key>${j(a)}</key>
|
|
2986
2986
|
${s}`}).join(`
|
|
2987
2987
|
`)}
|
|
2988
2988
|
</dict>
|
|
2989
2989
|
</plist>
|
|
2990
|
-
`}async function
|
|
2990
|
+
`}async function ue(e,r,a,i,s,t,o){let c=n(i,r);v(c,{recursive:!0});let l=n(c,"index.html");await Bun.write(l,e),S(o,n(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||r}" ^
|
|
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(n(c,`${
|
|
2998
|
+
`;if(await Bun.write(n(c,`${r}.bat`),f),s==="zip"){let p=n(i,`${r}-${a}-windows.zip`),u=await xe(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 be(e,r,a,i,s,t,o){let c=n(i,r);v(c,{recursive:!0});let l=n(c,"index.html");await Bun.write(l,e);let f=n(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||r}" \\
|
|
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=n(c,
|
|
3007
|
+
`,u=n(c,r.toLowerCase());await Bun.write(u,p),k(u,493);let y=`[Desktop Entry]
|
|
3008
3008
|
Type=Application
|
|
3009
|
-
Name=${
|
|
3009
|
+
Name=${r}
|
|
3010
3010
|
Exec=${u}
|
|
3011
3011
|
Terminal=false
|
|
3012
3012
|
Categories=Utility;
|
|
3013
|
-
`;if(await Bun.write(n(c,`${
|
|
3014
|
-
`)[0];if(
|
|
3015
|
-
exec /usr/share/${
|
|
3013
|
+
`;if(await Bun.write(n(c,`${r.toLowerCase()}.desktop`),y),s==="deb"){let g=n(i,`${r.toLowerCase()}_${a}_amd64.deb`),h=await ye(c,g,r,a,t);if(!h.success)return{success:!1,target:"linux",format:"deb",error:h.error};return{success:!0,target:"linux",format:"deb",outputPath:g}}if(s==="appimage"){let g=n(i,`${r}-${a}-x86_64.AppImage`),h=await Se(c,g,r,t);if(!h.success)return{success:!1,target:"linux",format:"appimage",error:h.error};return{success:!0,target:"linux",format:"appimage",outputPath:g}}return{success:!0,target:"linux",format:"app",outputPath:c}}async function ge(e,r,a,i,s,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${r}' to create an iOS project.`}}async function me(e,r,a,i,s,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${r}' to create an Android project.`}}async function he(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let e=[n(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),n(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),n(O(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),n(O(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",n(O(),".local/bin/craft"),n(process.env.LOCALAPPDATA||"","craft","craft.exe"),n(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let r of e)if(await Bun.file(r).exists())return r;try{let a=ce("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
|
|
3014
|
+
`)[0];if(a&&await Bun.file(a).exists())return a}catch{}return null}function R(){switch(de()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function we(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 ve(e,r,a){return new Promise((i)=>{let s=A("hdiutil",["create","-volname",a,"-srcfolder",e,"-ov","-format","UDZO",r]);s.on("close",(t)=>{if(t===0)i({success:!0});else i({success:!1,error:`hdiutil exited with code ${t}`})}),s.on("error",(t)=>{i({success:!1,error:t.message})})})}async function xe(e,r){return new Promise((a)=>{let i=A("zip",["-r",r,"."],{cwd:e});i.on("close",(s)=>{if(s===0)a({success:!0});else a({success:!1,error:`zip exited with code ${s}`})}),i.on("error",(s)=>{a({success:!1,error:s.message})})})}async function ye(e,r,a,i,s){return new Promise((t)=>{let o=Ce("deb");try{let c=n(o,"pkg"),l=n(c,"DEBIAN"),f=n(c,"usr","bin"),p=n(c,"usr","share","applications"),u=n(c,"usr","share",a.toLowerCase());v(l,{recursive:!0}),v(f,{recursive:!0}),v(p,{recursive:!0}),v(u,{recursive:!0});let y=d("fs").readdirSync(e);for(let b of y)S(n(e,b),n(u,b));let g=`#!/bin/bash
|
|
3015
|
+
exec /usr/share/${a.toLowerCase()}/${a.toLowerCase()} "$@"`;d("fs").writeFileSync(n(f,a.toLowerCase()),g),k(n(f,a.toLowerCase()),493);let h=`Package: ${a.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
3021
|
Maintainer: ${s.author||"Unknown"}
|
|
3022
|
-
Description: ${s.description||
|
|
3023
|
-
`;d("fs").writeFileSync(n(l,"control"),h);let T=A("dpkg-deb",["--build",c,
|
|
3022
|
+
Description: ${s.description||a}
|
|
3023
|
+
`;d("fs").writeFileSync(n(l,"control"),h);let T=A("dpkg-deb",["--build",c,r]);T.on("close",(b)=>{if(U(o),b===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${b}`})}),T.on("error",(b)=>{U(o),t({success:!1,error:b.message})})}catch(c){U(o),t({success:!1,error:c.message})}})}async function Se(e,r,a,i){return new Promise((s)=>{let t=Ce("appimage");try{let o=n(t,`${a}.AppDir`),c=n(o,"usr"),l=n(c,"bin"),f=n(c,"share");v(l,{recursive:!0}),v(f,{recursive:!0});let p=n(f,a.toLowerCase());v(p,{recursive:!0});let u=d("fs").readdirSync(e);for(let b of u)S(n(e,b),n(p,b));let y=`#!/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(n(o,"AppRun"),y),k(n(o,"AppRun"),493);let
|
|
3027
|
+
exec "\${HERE}/usr/share/${a.toLowerCase()}/${a.toLowerCase()}" "$@"
|
|
3028
|
+
`;d("fs").writeFileSync(n(o,"AppRun"),y),k(n(o,"AppRun"),493);let g=`[Desktop Entry]
|
|
3029
3029
|
Type=Application
|
|
3030
|
-
Name=${
|
|
3031
|
-
Exec=${
|
|
3030
|
+
Name=${a}
|
|
3031
|
+
Exec=${a.toLowerCase()}
|
|
3032
3032
|
Terminal=false
|
|
3033
3033
|
Categories=Utility;
|
|
3034
|
-
Icon=${
|
|
3035
|
-
`;d("fs").writeFileSync(n(o,`${
|
|
3034
|
+
Icon=${a.toLowerCase()}
|
|
3035
|
+
`;d("fs").writeFileSync(n(o,`${a.toLowerCase()}.desktop`),g);let h=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(n(o,`${a.toLowerCase()}.png`),h),i.icon&&q(i.icon))S(i.icon,n(o,`${a.toLowerCase()}.png`));let T=A("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});T.on("close",(b)=>{if(U(t),b===0)k(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${b}. Install from https://appimage.github.io/appimagetool/`})}),T.on("error",(b)=>{U(t),s({success:!1,error:`appimagetool not found: ${b.message}`})})}catch(o){U(t),s({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 ke={buildNative:Yo,getAvailableTargets:Zo,getAvailableFormats:Qo,detectPlatform:R},Yu=ke;
|
|
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{Mt,Ms,Di,Yc}from"./chunk-
|
|
2
|
+
import{Mt,Ms,Di,Yc}from"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{Yc as declareBareLoopHead,Mt as parseLoopBinding,Di as processLoops,Ms as reportDeferredLoopWarnings};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ul}from"./chunk-
|
|
2
|
+
import{Ul}from"./chunk-kpa73y6y.js";import"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bn,fe}from"./chunk-bsts9pr5.js";import{M,m,vn,ar,w,Ke,o,P}from"./chunk-gyrmwwgm.js";import{bs}from"./chunk-bhvbtk5v.js";import{s,Pe}from"./chunk-70et0fbw.js";import{a}from"./chunk-8cqx63aw.js";import d from"path";import b from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||bs(t,e,n)}var ot=2;function bc(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):a(t,"bundle-cache")}function nt(t,e){let n=t;for(let i of xt(e))if(i!==d.sep)n=n.split(i).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let i=e;try{i=b.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((u,g)=>g.length-u.length),st.set(e,n)}return n}function yt(t,e){try{let n=b.statSync(t),i=d.resolve(e),u=t.startsWith(`${i}${d.sep}`);return{path:u?d.relative(i,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function bt(t,e){for(let n of t){let i=at(n,e);try{let u=b.statSync(i);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,wt=100;function vc(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function St(t){let e=G.get(t)??0;if(e>0&&e<wt){G.set(t,e+1);return}G.set(t,1);try{let n=(await b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),i=vc();if(n.length<=i)return;let g=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);g.sort((l,S)=>S.at-l.at);for(let l of g.slice(i)){let S=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${S}.js`),{force:!0}),await b.promises.rm(d.join(t,`${S}.deps.json`),{force:!0})}C("pruned bundle cache to",i,"entries")}catch{}}function pe(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function wc(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(wc())console.log("[stx:bundler]",...t)}var Y=[];function di(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function $t(){return Y.slice()}function Rt(){Y.length=0}var Z;function Qu(t){Z=t}function pi(){if(Z)return Z;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function At(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var yn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function xc(t,e){return d.relative(t,e).split(d.sep).join("/")}function Sc(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,u,g)=>{let l=e.get(g);return l&&!g.startsWith(yn)?`${i}${u}${l}${u}`:n})}function kc(t,e){let n=0,i=(g)=>{let l=`__stxMod${n++}`,S=JSON.stringify(g);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${S}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(S)} + " is not registered on this page (#1957)");`),l},u=(g,l)=>{for(let S of g.split(",")){let F=S.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],r=j[2]??p;e.push(`var ${r} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(g,l,S)=>{let F=S.slice(yn.length),j=i(F),p=l.trim(),r=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${r[1]} = ${j}.default;`),p=p.slice(r[0].length).trim();let c=p.match(/^\*\s*as\s+([\w$]+)$/);if(c)e.push(`var ${c[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(g,l)=>(i(l.slice(yn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function gs(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,u]of[...t].sort(([g],[l])=>g<l?-1:g>l?1:0))n.update(`${i}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Pt(){return K.getStore()?.key??""}function Bt(t,e,n,i,u,g=new Map,l,S){let F=(p,r,c)=>{if(X(r,t,l))return null;if(!u||p!==n||!vt.test(r))return null;try{if(!b.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}i.add(r);let x=`${yn}${xc(process.cwd(),r)}`;return g.set(c,x),{path:x,external:!0}},j=(p,r)=>{let c=p===n?e:d.dirname(p),x=d.resolve(c,r);return rt(x)??x};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^\//},(r)=>{let c=rt(r.path);if(c){let x=F(r.importer,c,r.path);if(x)return x;if(c!==n)i.add(c);return{path:c}}return{path:r.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(r)=>{let c=j(r.importer,r.path),x=F(r.importer,c,r.path);if(x)return x;return i.add(c),{path:c}}),p.onResolve({filter:/^[@~]\//},(r)=>{let c=d.resolve(t,r.path.slice(2)),x=[c,`${c}.ts`,`${c}.tsx`,`${c}.js`,`${c}.mjs`,`${c}.jsx`,d.join(c,"index.ts"),d.join(c,"index.tsx"),d.join(c,"index.js"),d.join(c,"index.mjs")];for(let I of x)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(r.importer,I,r.path);if(E)return E;return C(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",I),i.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:c}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let c=`${yn}npm:${r.path}`;return g.set(r.path,c),{path:c,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(X(r.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let c=d.extname(r.path).toLowerCase(),x=c===".json"?"json":c===".tsx"?"tsx":c===".jsx"?"jsx":c===".ts"||c===".mts"||c===".cts"?"ts":"js";if(r.path!==n)i.add(r.path);let I=S?.get(r.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(r.path,"utf8"),loader:x}})}}}var H=new Map,k=m(64),it=Symbol.for("stx.client-bundle-build-queue");function Cc(t){let e=globalThis,i=(e[it]??Promise.resolve()).then(t,t);return e[it]=i.then(()=>{return},()=>{return}),i}async function It(t,e,n={}){let i=n.projectRoot||process.cwd(),u=(await o(i)).serverApi,g=n.minify??!1,l=n.externalizeUserModules??!0,S=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||bc(i),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${ht}\x00${Ke()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${S?S.join(","):"*"}\x00${g?"minified":"readable"}\x00${j?.key??""}\x00${nt(t,i)}\x00${nt(e,i)}`);let r=p.digest("hex").slice(0,12),c=d.join(F,`${r}.js`),x=k.get(c);if(x){if(ar(x.files)&&x.files.every((R)=>!X(R.path,i,u))){C("memo hit:",r);let R=x.files.map((A)=>A.path);return q(e,R),n.collectInputs?.push(...R),x.code}k.delete(c),C("memo invalidated by dep change:",r)}let I=d.join(F,`${r}.deps.json`),E=Bun.file(c);if(await E.exists()){let R=Bun.file(I),A=!1,O=null;if(await R.exists())try{let D=JSON.parse(await R.text());if(D.metadataVersion===ot&&Array.isArray(D.files)&&bt(D.files,i))O=vn(D.files.map((h)=>at(h,i))),A=O.length===D.files.length&&!O.some((h)=>X(h.path,i,u))}catch{A=!1}if(A){if(C("cache hit:",r),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),h=new Date;if(b.promises.utimes(c,h,h).catch(()=>{}),O)k.set(c,{code:D,files:O});return D}C("cache invalidated by dep change:",r)}let z=H.get(r);if(z){let R=await z;if(n.collectInputs)n.collectInputs.push(...(k.get(c)?.files??[]).map((A)=>A.path));return R}let V=Cc(()=>Et(t,e,{projectRoot:i,minify:g,cacheDir:F,hash:r,cachePath:c,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:S,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(r,V);try{return await V}finally{H.delete(r)}}var jt=0;function _c(t){return`${t}-${process.pid}-${++jt}`}async function Et(t,e,n){let{projectRoot:i,minify:u,cacheDir:g,hash:l,cachePath:S,depsPath:F,externalizeUserModules:j}=n,p=a(i,"bundle-tmp"),r=_c(l),c=d.join(p,`${r}.ts`),x=d.join(p,"out",r);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(x,{recursive:!0});let I=d.dirname(e),E=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,R=s(t),{depths:A,balanced:O}=Pe(R),D=(B)=>!O||A[B]===0,h;while((h=z.exec(R))!==null){if(h[1])continue;if(!D(h.index))continue;if(h[2])h[2].split(",").forEach((B)=>{let f=_t(B);if(f)E.add(f)});else if(h[3])E.add(h[3])}while((h=V.exec(R))!==null){if(h[1])continue;if(!D(h.index))continue;E.add(h[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((h=T.exec(R))!==null){if(!D(h.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(h.index+h[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(h[1])E.add(h[1]);if(h[2])E.add(h[2]);for(let f of(h[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let L=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(L)E.add(L)}}for(let B of R.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let lt=E.size>0?`
|
|
2
|
+
import{bn,fe}from"./chunk-bsts9pr5.js";import{M,m,vn,ar,w,Ke,o,P}from"./chunk-sn6qj2jz.js";import{bs}from"./chunk-j2e16j5h.js";import{s,Pe}from"./chunk-70et0fbw.js";import{a}from"./chunk-8cqx63aw.js";import d from"path";import b from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||bs(t,e,n)}var ot=2;function bc(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):a(t,"bundle-cache")}function nt(t,e){let n=t;for(let i of xt(e))if(i!==d.sep)n=n.split(i).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let i=e;try{i=b.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((u,g)=>g.length-u.length),st.set(e,n)}return n}function yt(t,e){try{let n=b.statSync(t),i=d.resolve(e),u=t.startsWith(`${i}${d.sep}`);return{path:u?d.relative(i,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function bt(t,e){for(let n of t){let i=at(n,e);try{let u=b.statSync(i);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,wt=100;function vc(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function St(t){let e=G.get(t)??0;if(e>0&&e<wt){G.set(t,e+1);return}G.set(t,1);try{let n=(await b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),i=vc();if(n.length<=i)return;let g=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);g.sort((l,S)=>S.at-l.at);for(let l of g.slice(i)){let S=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${S}.js`),{force:!0}),await b.promises.rm(d.join(t,`${S}.deps.json`),{force:!0})}C("pruned bundle cache to",i,"entries")}catch{}}function pe(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function wc(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(wc())console.log("[stx:bundler]",...t)}var Y=[];function di(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function $t(){return Y.slice()}function Rt(){Y.length=0}var Z;function Qu(t){Z=t}function pi(){if(Z)return Z;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function At(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var yn="stx-module:",vt=/\.(?:[cm]?[jt]sx?|json)$/i;function xc(t,e){return d.relative(t,e).split(d.sep).join("/")}function Sc(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,u,g)=>{let l=e.get(g);return l&&!g.startsWith(yn)?`${i}${u}${l}${u}`:n})}function kc(t,e){let n=0,i=(g)=>{let l=`__stxMod${n++}`,S=JSON.stringify(g);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${S}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(S)} + " is not registered on this page (#1957)");`),l},u=(g,l)=>{for(let S of g.split(",")){let F=S.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],r=j[2]??p;e.push(`var ${r} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(g,l,S)=>{let F=S.slice(yn.length),j=i(F),p=l.trim(),r=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${r[1]} = ${j}.default;`),p=p.slice(r[0].length).trim();let c=p.match(/^\*\s*as\s+([\w$]+)$/);if(c)e.push(`var ${c[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(g,l)=>(i(l.slice(yn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function gs(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,u]of[...t].sort(([g],[l])=>g<l?-1:g>l?1:0))n.update(`${i}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Pt(){return K.getStore()?.key??""}function Bt(t,e,n,i,u,g=new Map,l,S){let F=(p,r,c)=>{if(X(r,t,l))return null;if(!u||p!==n||!vt.test(r))return null;try{if(!b.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}i.add(r);let x=`${yn}${xc(process.cwd(),r)}`;return g.set(c,x),{path:x,external:!0}},j=(p,r)=>{let c=p===n?e:d.dirname(p),x=d.resolve(c,r);return rt(x)??x};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),p.onResolve({filter:/^\//},(r)=>{let c=rt(r.path);if(c){let x=F(r.importer,c,r.path);if(x)return x;if(c!==n)i.add(c);return{path:c}}return{path:r.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(r)=>{let c=j(r.importer,r.path),x=F(r.importer,c,r.path);if(x)return x;return i.add(c),{path:c}}),p.onResolve({filter:/^[@~]\//},(r)=>{let c=d.resolve(t,r.path.slice(2)),x=[c,`${c}.ts`,`${c}.tsx`,`${c}.js`,`${c}.mjs`,`${c}.jsx`,d.join(c,"index.ts"),d.join(c,"index.tsx"),d.join(c,"index.js"),d.join(c,"index.mjs")];for(let I of x)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(r.importer,I,r.path);if(E)return E;return C(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",I),i.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:c}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let c=`${yn}npm:${r.path}`;return g.set(r.path,c),{path:c,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(X(r.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let c=d.extname(r.path).toLowerCase(),x=c===".json"?"json":c===".tsx"?"tsx":c===".jsx"?"jsx":c===".ts"||c===".mts"||c===".cts"?"ts":"js";if(r.path!==n)i.add(r.path);let I=S?.get(r.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(r.path,"utf8"),loader:x}})}}}var H=new Map,k=m(64),it=Symbol.for("stx.client-bundle-build-queue");function Cc(t){let e=globalThis,i=(e[it]??Promise.resolve()).then(t,t);return e[it]=i.then(()=>{return},()=>{return}),i}async function It(t,e,n={}){let i=n.projectRoot||process.cwd(),u=(await o(i)).serverApi,g=n.minify??!1,l=n.externalizeUserModules??!0,S=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||bc(i),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${ht}\x00${Ke()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${S?S.join(","):"*"}\x00${g?"minified":"readable"}\x00${j?.key??""}\x00${nt(t,i)}\x00${nt(e,i)}`);let r=p.digest("hex").slice(0,12),c=d.join(F,`${r}.js`),x=k.get(c);if(x){if(ar(x.files)&&x.files.every((R)=>!X(R.path,i,u))){C("memo hit:",r);let R=x.files.map((A)=>A.path);return q(e,R),n.collectInputs?.push(...R),x.code}k.delete(c),C("memo invalidated by dep change:",r)}let I=d.join(F,`${r}.deps.json`),E=Bun.file(c);if(await E.exists()){let R=Bun.file(I),A=!1,O=null;if(await R.exists())try{let D=JSON.parse(await R.text());if(D.metadataVersion===ot&&Array.isArray(D.files)&&bt(D.files,i))O=vn(D.files.map((h)=>at(h,i))),A=O.length===D.files.length&&!O.some((h)=>X(h.path,i,u))}catch{A=!1}if(A){if(C("cache hit:",r),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),h=new Date;if(b.promises.utimes(c,h,h).catch(()=>{}),O)k.set(c,{code:D,files:O});return D}C("cache invalidated by dep change:",r)}let z=H.get(r);if(z){let R=await z;if(n.collectInputs)n.collectInputs.push(...(k.get(c)?.files??[]).map((A)=>A.path));return R}let V=Cc(()=>Et(t,e,{projectRoot:i,minify:g,cacheDir:F,hash:r,cachePath:c,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:S,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(r,V);try{return await V}finally{H.delete(r)}}var jt=0;function _c(t){return`${t}-${process.pid}-${++jt}`}async function Et(t,e,n){let{projectRoot:i,minify:u,cacheDir:g,hash:l,cachePath:S,depsPath:F,externalizeUserModules:j}=n,p=a(i,"bundle-tmp"),r=_c(l),c=d.join(p,`${r}.ts`),x=d.join(p,"out",r);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(x,{recursive:!0});let I=d.dirname(e),E=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,R=s(t),{depths:A,balanced:O}=Pe(R),D=(B)=>!O||A[B]===0,h;while((h=z.exec(R))!==null){if(h[1])continue;if(!D(h.index))continue;if(h[2])h[2].split(",").forEach((B)=>{let f=_t(B);if(f)E.add(f)});else if(h[3])E.add(h[3])}while((h=V.exec(R))!==null){if(h[1])continue;if(!D(h.index))continue;E.add(h[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((h=T.exec(R))!==null){if(!D(h.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(h.index+h[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(h[1])E.add(h[1]);if(h[2])E.add(h[2]);for(let f of(h[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let L=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(L)E.add(L)}}for(let B of R.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let lt=E.size>0?`
|
|
3
3
|
export { ${[...E].join(", ")} }`:"";await Bun.write(c,t+lt),C("bundling:",l,"from:",d.basename(e));let tt=new Set,et=new Map;try{let B=await Bun.build({entrypoints:[c],outdir:x,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[Bt(i,I,c,tt,j,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...w()},root:i});if(!B.success){let _=B.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${d.basename(e)}`,U=bn(B.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",_),di(e||"",_,U),n.throwOnFailure||pi()==="error")throw Error(_);return t}let f="";for(let y of B.outputs){f=await y.text();break}let v=[];for(let y of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let _ of y[1].split(",")){let U=_.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(U){v.push([U[2],U[1]]);continue}let N=_.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))v.push([N,N])}if(n.expose){let y=new Set(n.expose);for(let _=v.length-1;_>=0;_--)if(!y.has(v[_][0]))v.splice(_,1)}let L=[];f=kc(Sc(f,et),L);let ut=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${l}`,dt=new Set(M(t,!0).split(",").map((y)=>y.trim())),pt=v.map(([y,_])=>`get ${JSON.stringify(y)}() { return ${_} }${dt.has(y)?`, set ${JSON.stringify(y)}(__stxValue_${_}) { ${_} = __stxValue_${_} }`:""}`).join(", "),ft=v.map(([y])=>`var ${y} = undefined;`).join(`
|
|
4
4
|
`),mt=v.map(([y])=>`${y} = ${J}[${JSON.stringify(y)}];`).join(`
|
|
5
5
|
`);if(f=`${ut.join(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Tu,$u}from"./chunk-32j06rtz.js";import"./chunk-dy8zpcph.js";import"./chunk-j2e16j5h.js";import"./chunk-bsts9pr5.js";import"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{$u as clearStoreCache,Tu as getStoreScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ke,Oc,ad,cd,ld,ud,Nc,Dc,dd,pd,bi,fd,xn,Sn,ur}from"./chunk-
|
|
2
|
+
import{Ke,Oc,ad,cd,ld,ud,Nc,Dc,dd,pd,bi,fd,xn,Sn,ur}from"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{ud as __setSignalsGeneratorsForTest,Ke as cacheEngineFingerprint,Sn as cacheTemplate,xn as checkCache,fd as clearDevCaches,Dc as getCachedRouterScript,Nc as getCachedSignalsRuntime,dd as getServeClientAsset,bi as getServeModuleBundle,ur as hashFilePath,cd as invalidateFileCache,ld as invalidateFileCacheByDir,ad as readFileCached,pd as registerServeModuleBundle,Oc as templateCache};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Yo,Zo,Qo,Yu}from"./chunk-
|
|
2
|
+
import{Yo,Zo,Qo,Yu}from"./chunk-b9ja34n4.js";import"./chunk-96etsv47.js";import"./chunk-gmxrckgj.js";import"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{Yo as buildNative,Yu as default,Qo as getAvailableFormats,Zo as getAvailableTargets};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cl}from"./chunk-
|
|
2
|
+
import{Cl}from"./chunk-3p0qjenv.js";import"./chunk-mefkgsn2.js";import"./chunk-j2e16j5h.js";import"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{Cl as startProductionServer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Oa,ql,Na,Da,Gl,Kl}from"./chunk-
|
|
2
|
+
import{Oa,ql,Na,Da,Gl,Kl}from"./chunk-k7anjg46.js";import"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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 applySlots,Gl as extractSlotContent,ql as parseSlotElement,Oa as parseSlots,Da as processSlots,Na as renderSlot};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Il}from"./chunk-
|
|
2
|
+
import{Il}from"./chunk-gg2kxtbz.js";import"./chunk-mefkgsn2.js";import"./chunk-dcwhp21g.js";import"./chunk-j2e16j5h.js";import"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{Il as buildForProduction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Y,vs,ws,Ec,Dt,fi,xs,gi,td,_e,wn,Ee}from"./chunk-
|
|
2
|
+
import{Y,vs,ws,Ec,Dt,fi,xs,gi,td,_e,wn,Ee}from"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import{Wi,s}from"./chunk-70et0fbw.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{Y as BROWSER_CORE_IMPORTS,Ec as STX_AUTO_IMPORTS,vs as extractAndStripCssImports,_e as extractBridgeData,Wi as findInterpolationEnd,gi as generateAutoImportDestructuring,td as generateBrowserAutoImportDestructuring,wn as generateServerDataBridge,Dt as injectBrowserCoreAutoImports,Ee as processClientScript,xs as referencesName,ws as renderVendorStyleTags,s as stripCommentsAndLiterals,fi as transformAutoImports};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xd,Zc,Ae,Mi,Sd,Ls,js,Bs}from"./chunk-
|
|
2
|
+
import{xd,Zc,Ae,Mi,Sd,Ls,js,Bs}from"./chunk-sn6qj2jz.js";import"./chunk-r00nn2qs.js";import"./chunk-y255yybn.js";import"./chunk-1m5cjrpw.js";import"./chunk-94znr894.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{Sd as clearOnceStore,Mi as onceStore,Ae as partialsCache,Ls as processIncludes,js as processStackPushDirectives,Bs as processStackReplacements,xd as resetUnscopedSignalWarnings,Zc as topLevelElements};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Me}from"./chunk-gsp3627d.js";import{We,un}from"./chunk-dcwhp21g.js";import{mi,hi,f,Ft,he,j,n,A,o}from"./chunk-
|
|
2
|
+
import{Me}from"./chunk-gsp3627d.js";import{We,un}from"./chunk-dcwhp21g.js";import{mi,hi,f,Ft,he,j,n,A,o}from"./chunk-sn6qj2jz.js";import{C}from"./chunk-a0ygyftk.js";import{Ks}from"./chunk-94znr894.js";import{On,Nn,Dn,Ln,xe}from"./chunk-qmh6f1bt.js";import{Ki}from"./chunk-1m5cjrpw.js";import{ke,le,Do,Mo,Jt}from"./chunk-mefkgsn2.js";import{Ot,hs}from"./chunk-j2e16j5h.js";import{Yt}from"./chunk-fqg0espy.js";import{Et,mn,hn}from"./chunk-kxbw0e2f.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(i){return Q("sha256").update(i).digest("hex").slice(0,8)}function U(i=!1){let l=i?un():We(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let i=Me(),l=J(i);return{content:i,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(i={}){let l=new Set;return{context:new Proxy(i,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(i,l,a={}){let r=q.resolve(i),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);mi();let _={};try{_=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>he(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,B={...A,..._,...a,buildMode:"compile",strict:!1},b=await n(e,D,r,B,w),T=ke(b),M=hi();return{route:l,sourceFile:i,html:b,fragment:T,placeholders:M,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:Ft(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(i,l){let a=0,r=0;if(!m.existsSync(i))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),a++,r+=m.statSync(u).size}}}return e(i,l),{copied:a,bytes:r}}async function Il(i={}){let l=Date.now(),a=c.resolve(i.root||process.cwd()),r=c.resolve(a,i.outputDir||".output");console.log("[stx build] Starting production build...");let e=await o(a),S=c.resolve(a,i.componentsDir??e.componentsDir??"components"),_=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",g=xe(e.app?.head,{known:Ln,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=i.routeRules??e.routeRules??{},B=Yt(w),b=i.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)Ot(a,T);if(e.runtimeConfig)C(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let M=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of M)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=j(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],O=R.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${O.length} page routes (${R.length-O.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(i.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let k=[],H=[];for(let s of O){let h=B(s.pattern),E=h.rendering==="prerender";if(E&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:i.debug});if(k.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Dn(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=On(t.html,u);if(g.htmlAttrs)t.html=Nn(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await f(t.html),E){let p=await Jt(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=le(t.html,D);let z=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),G=c.join("server","pages",`${z}.compiled.json`),I=c.join("server","fragments",`${z}.html`);await Bun.write(c.join(r,G),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),H.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:E}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let F=c.resolve(a,d);if(m.existsSync(F)){let{copied:s,bytes:h}=Z(F,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let N=hn(a);if(N){let{copied:s,bytes:h}=Z(N,c.join(r,"public",mn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${Et}/`)}let K={runtime:v.filename,router:x.filename},P=Do(H,K,r);if(P.routeRules=w,P.routerContainer=D,b)P.apiRoutes=await hs(a,r,T);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Ks(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Ki(e._layerGraph),null,2));Mo(P,r);let L=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${L}ms \u2014 ${k.length} pages compiled`),{pageCount:k.length,assets:K,outputDir:r,duration:L}}
|
|
4
4
|
export{Il};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{ee}from"./chunk-gsp3627d.js";import{ve,C}from"./chunk-a0ygyftk.js";import{qi}from"./chunk-1m5cjrpw.js";import{a}from"./chunk-8cqx63aw.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function Ot(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function ms(s,l){let o=a(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:p}=ee(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function hs(s,l,o={}){let i=Ot(s,o);await ms(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...ee(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function ys(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function ed(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Ot(s,o);return await ms(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Ot(s,o);await ms(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...ee(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function ys(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function ed(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Ot(s,o);return await ms(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Ot(s,o);await ms(s,t);let{loadStxConfig:e}=await import("./chunk-5a50m90y.js"),p=C((await e(s)).runtimeConfig);return await ve(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function bs(s,l,o){if(qi(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
|
|
6
6
|
export{Ot,ms,hs,ys,ed,bs};
|