@stacksjs/stx 0.2.566 → 0.2.570
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-0mw3d5fc.js +2 -0
- package/dist/{chunk-fpa1nq88.js → chunk-0pzbg1bt.js} +2 -2
- package/dist/chunk-0zq4btre.js +3 -0
- package/dist/chunk-1sh80b1c.js +2 -0
- package/dist/chunk-1xyhdpbn.js +2 -0
- package/dist/chunk-20nrvpps.js +2 -0
- package/dist/chunk-2j7tr8wj.js +2 -0
- package/dist/chunk-2mxhp1yy.js +2 -0
- package/dist/{chunk-gjx5256r.js → chunk-2t3bhp2j.js} +5 -5
- package/dist/chunk-32yj7sbw.js +2 -0
- package/dist/{chunk-c765y72x.js → chunk-35kmebz9.js} +4 -4
- package/dist/{chunk-203rr1c8.js → chunk-3m01ym55.js} +2 -2
- package/dist/chunk-3ss3vfad.js +2 -0
- package/dist/{chunk-kch9a9v1.js → chunk-3tzkqf6e.js} +2 -2
- package/dist/{chunk-4zb2ga7p.js → chunk-3wcwtqx1.js} +2 -2
- package/dist/chunk-4zp2zzch.js +2 -0
- package/dist/chunk-503w9dn3.js +2 -0
- package/dist/{chunk-18270qgd.js → chunk-5hxsdkvp.js} +2 -2
- package/dist/{chunk-ma2yh8zc.js → chunk-6m406xsn.js} +4 -4
- package/dist/chunk-6yja1c8e.js +2 -0
- package/dist/{chunk-mb59b499.js → chunk-724zsgbk.js} +5 -5
- package/dist/chunk-74va4kza.js +2 -0
- package/dist/chunk-74w81h3v.js +2 -0
- package/dist/chunk-85j8cxfd.js +2 -0
- package/dist/chunk-8bwp2m95.js +2 -0
- package/dist/{chunk-z2n1rtj5.js → chunk-8rj08x1d.js} +1 -1
- package/dist/{chunk-90qywh24.js → chunk-8yn9wxzt.js} +4 -4
- package/dist/{chunk-2ernwctg.js → chunk-8zmahjqg.js} +6 -6
- package/dist/chunk-98xp5rfe.js +2 -0
- package/dist/chunk-9ah35e2w.js +2 -0
- package/dist/chunk-9d1bs55s.js +2 -0
- package/dist/{chunk-7wyyjdks.js → chunk-9d6dr0dr.js} +2 -2
- package/dist/{chunk-dmf1jmge.js → chunk-9k6r7f3c.js} +4 -4
- package/dist/chunk-9rts16ta.js +2 -0
- package/dist/{chunk-m6m19hwd.js → chunk-9zf49tqg.js} +4 -4
- package/dist/{chunk-d1mqedk0.js → chunk-a2mztbta.js} +3 -3
- package/dist/{chunk-k2dgwy05.js → chunk-a849hqna.js} +2 -2
- package/dist/chunk-ajezxt0s.js +2 -0
- package/dist/chunk-bf572npc.js +2 -0
- package/dist/{chunk-g1epk002.js → chunk-brkq2s62.js} +3 -3
- package/dist/{chunk-7m0r2qs2.js → chunk-c1ys37c9.js} +2 -2
- package/dist/{chunk-tc01jkfc.js → chunk-chythmea.js} +1 -1
- package/dist/chunk-cqeccn7x.js +2 -0
- package/dist/{chunk-g8tx0yf8.js → chunk-d8jdr1k4.js} +4 -4
- package/dist/{chunk-8txqk9nq.js → chunk-dajh1369.js} +2 -2
- package/dist/{chunk-tsmbstj6.js → chunk-dgr561sc.js} +4 -4
- package/dist/{chunk-39tkfkp7.js → chunk-dkyqkkpj.js} +3 -3
- package/dist/chunk-dsdxa5x1.js +2 -0
- package/dist/{chunk-ghnkphy4.js → chunk-ebg20d8s.js} +2 -2
- package/dist/chunk-ectcp21m.js +2 -0
- package/dist/chunk-ewcnyvcd.js +2 -0
- package/dist/chunk-ez7r18ef.js +2 -0
- package/dist/{chunk-wy4hfmjs.js → chunk-fas9k7sw.js} +5 -5
- package/dist/chunk-ffgsaf9e.js +2 -0
- package/dist/chunk-fnnhekdc.js +2 -0
- package/dist/chunk-g8b74qvn.js +2 -0
- package/dist/chunk-ge87hcgb.js +2 -0
- package/dist/chunk-gra2v7xz.js +2 -0
- package/dist/{chunk-8afnq4qx.js → chunk-gwabvrc3.js} +3 -3
- package/dist/{chunk-6sf4v894.js → chunk-he2et28k.js} +4 -4
- package/dist/{chunk-n6va14bt.js → chunk-hvzznc50.js} +2 -2
- package/dist/{chunk-m8qgr307.js → chunk-j3vwyzvb.js} +3 -3
- package/dist/{chunk-s1xxkzc9.js → chunk-je0jxvmj.js} +4 -4
- package/dist/chunk-jg9fydw8.js +2 -0
- package/dist/{chunk-wsdn5fxe.js → chunk-jvm6agq7.js} +3 -3
- package/dist/{chunk-z06npyzn.js → chunk-k0shfsfx.js} +3 -3
- package/dist/{chunk-f46a7pvn.js → chunk-kaaxb9c5.js} +2 -2
- package/dist/{chunk-jbmhdyzz.js → chunk-knpzph55.js} +2 -2
- package/dist/{chunk-xw8kzm6b.js → chunk-kz131809.js} +148 -148
- package/dist/{chunk-8nr1kras.js → chunk-mbj9dbrh.js} +6 -6
- package/dist/chunk-mg8yjzkr.js +2 -0
- package/dist/chunk-mjkw1esn.js +2 -0
- package/dist/{chunk-7ze47qgv.js → chunk-mw2dravv.js} +5 -5
- package/dist/chunk-n0ra4mv3.js +2 -0
- package/dist/{chunk-pzasxhwz.js → chunk-ncq5n15k.js} +1 -1
- package/dist/{chunk-325p135t.js → chunk-nebtks7j.js} +9 -9
- package/dist/{chunk-01s01ten.js → chunk-nmy7mcbd.js} +4 -4
- package/dist/chunk-nspfk500.js +2 -0
- package/dist/chunk-nwyp2xaf.js +2 -0
- package/dist/{chunk-125rc958.js → chunk-nz0krznq.js} +2 -2
- package/dist/chunk-pdk87hhe.js +2 -0
- package/dist/{chunk-55hfvmvv.js → chunk-q8nw82pz.js} +9 -9
- package/dist/{chunk-wm11csdm.js → chunk-qh0es7mk.js} +2 -2
- package/dist/{chunk-9tcvkbb5.js → chunk-qw4fjtt1.js} +2 -2
- package/dist/{chunk-5grx48s2.js → chunk-r17t24jr.js} +2 -2
- package/dist/{chunk-tfeenp4h.js → chunk-r8h9b3f8.js} +94 -77
- package/dist/chunk-re030f77.js +2 -0
- package/dist/{chunk-68b64sj4.js → chunk-rh606w0q.js} +1 -1
- package/dist/chunk-rn80ctkd.js +2 -0
- package/dist/{chunk-3hkv4e7t.js → chunk-rrce2fyv.js} +1 -1
- package/dist/{chunk-saf7kypg.js → chunk-rtc17gy5.js} +2 -2
- package/dist/chunk-s7dzs6yg.js +2 -0
- package/dist/chunk-t1tqn3xx.js +2 -0
- package/dist/{chunk-ss78553t.js → chunk-tc5zk2ka.js} +1 -1
- package/dist/{chunk-rgage0vm.js → chunk-tdv9np5t.js} +2 -2
- package/dist/{chunk-mm1vvk49.js → chunk-tgwdk0gt.js} +4 -4
- package/dist/chunk-tma2vac1.js +2 -0
- package/dist/chunk-v0chatw1.js +2 -0
- package/dist/{chunk-8cpqy9ea.js → chunk-v9gy8rda.js} +41 -41
- package/dist/chunk-v9mkambt.js +2 -0
- package/dist/chunk-vwjqbn5y.js +2 -0
- package/dist/{chunk-ev3qnr9q.js → chunk-w8vg3te3.js} +4 -4
- package/dist/{chunk-1hrj0t0j.js → chunk-wemq37qe.js} +10 -10
- package/dist/{chunk-9ya4tdpz.js → chunk-wjazf68a.js} +2 -2
- package/dist/chunk-wrvksj26.js +2 -0
- package/dist/{chunk-nm0y4qjg.js → chunk-wvjpvs89.js} +3 -3
- package/dist/{chunk-6vnnx536.js → chunk-xjr67xvb.js} +2 -2
- package/dist/chunk-xkxwg6d4.js +2 -0
- package/dist/chunk-xspkz804.js +2 -0
- package/dist/chunk-xwqyw7zt.js +2 -0
- package/dist/chunk-y3kp87w1.js +2 -0
- package/dist/{chunk-wwn9dh6p.js → chunk-y3mmeywt.js} +2 -2
- package/dist/chunk-ya39wk58.js +2 -0
- package/dist/chunk-ygbdfzqn.js +2 -0
- package/dist/chunk-ypswj8sv.js +2 -0
- package/dist/chunk-yqzhev40.js +2 -0
- package/dist/{chunk-mt8sew7a.js → chunk-ywah1c30.js} +10 -10
- package/dist/chunk-z1tnn2pm.js +2 -0
- package/dist/{chunk-n1xcmhjw.js → chunk-z3smaz4z.js} +3 -3
- package/dist/{chunk-jra9r8fq.js → chunk-zckbg2vb.js} +1 -1
- package/dist/cli.js +18 -18
- package/dist/client/signals-helpers-runtime.d.ts +1 -1
- package/dist/client/signals-helpers-runtime.js +1 -8
- package/dist/client/signals-notify-runtime.d.ts +2 -0
- package/dist/client/signals-notify-runtime.js +26 -0
- package/dist/client/signals-process-element-runtime.js +8 -4
- package/dist/client/signals-reactive-core-bootstrap-runtime.js +2 -0
- package/dist/client/signals-state-runtime.d.ts +1 -1
- package/dist/client/signals-state-runtime.js +12 -18
- package/dist/composables/use-mouse.js +6 -4
- package/dist/config.d.ts +16 -0
- package/dist/config.js +12 -3
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/runtime/craft-bridge.js +25 -2
- package/dist/native/runtime/craft.d.ts +3 -1
- package/dist/pwa.js +3 -3
- package/dist/reactive-tracking.d.ts +17 -0
- package/dist/reactive-tracking.js +23 -0
- package/dist/reactivity.js +3 -11
- package/dist/signals-api.js +13 -11
- package/dist/signals-notify-runtime.d.ts +2 -0
- package/dist/ssg.js +3 -3
- package/package.json +5 -5
- package/src/composables/use-mouse.ts +6 -4
- package/dist/chunk-04qvjcsr.js +0 -2
- package/dist/chunk-2xbrrc5a.js +0 -2
- package/dist/chunk-2yypassp.js +0 -2
- package/dist/chunk-375skn32.js +0 -2
- package/dist/chunk-3wyxe996.js +0 -2
- package/dist/chunk-4mmdpb46.js +0 -2
- package/dist/chunk-4q5d5r7s.js +0 -2
- package/dist/chunk-5ytg0wbc.js +0 -2
- package/dist/chunk-6qyters0.js +0 -2
- package/dist/chunk-6yn90mq9.js +0 -2
- package/dist/chunk-7d2vyre0.js +0 -2
- package/dist/chunk-7pewegtw.js +0 -2
- package/dist/chunk-7w0qa3n0.js +0 -2
- package/dist/chunk-8d788kvt.js +0 -2
- package/dist/chunk-bdhtq3vs.js +0 -2
- package/dist/chunk-brnapchc.js +0 -2
- package/dist/chunk-c78327kx.js +0 -2
- package/dist/chunk-d19w3e4x.js +0 -2
- package/dist/chunk-da649d3k.js +0 -2
- package/dist/chunk-da9avgd9.js +0 -2
- package/dist/chunk-e3njkecx.js +0 -2
- package/dist/chunk-efzc1nw8.js +0 -2
- package/dist/chunk-fm4w1r9e.js +0 -2
- package/dist/chunk-gan95hj0.js +0 -2
- package/dist/chunk-hg7amzgz.js +0 -2
- package/dist/chunk-hmk7z0z6.js +0 -2
- package/dist/chunk-hn105xy3.js +0 -2
- package/dist/chunk-jq079mrx.js +0 -2
- package/dist/chunk-jr149mmp.js +0 -2
- package/dist/chunk-kwxy0e3r.js +0 -2
- package/dist/chunk-kza3nxr0.js +0 -2
- package/dist/chunk-m9cmc6np.js +0 -2
- package/dist/chunk-m9r4x7e6.js +0 -2
- package/dist/chunk-mahv855w.js +0 -2
- package/dist/chunk-mbwdn96z.js +0 -2
- package/dist/chunk-mdxg95mq.js +0 -2
- package/dist/chunk-mqje968d.js +0 -2
- package/dist/chunk-n2g9mj2h.js +0 -2
- package/dist/chunk-n2nha538.js +0 -2
- package/dist/chunk-nebw444s.js +0 -2
- package/dist/chunk-nmt7kw0e.js +0 -2
- package/dist/chunk-pq8mz4ma.js +0 -2
- package/dist/chunk-pxes1ft6.js +0 -2
- package/dist/chunk-qajc13zq.js +0 -2
- package/dist/chunk-qtnqmw1n.js +0 -2
- package/dist/chunk-r3zdgeah.js +0 -2
- package/dist/chunk-r5htacg5.js +0 -2
- package/dist/chunk-rf2rwddd.js +0 -2
- package/dist/chunk-s833fbvf.js +0 -2
- package/dist/chunk-sgvszh9s.js +0 -2
- package/dist/chunk-t5r3s1wj.js +0 -2
- package/dist/chunk-tjprg6kq.js +0 -2
- package/dist/chunk-v0dzrwg8.js +0 -2
- package/dist/chunk-vtz9empe.js +0 -2
- package/dist/chunk-wa6nzq5b.js +0 -2
- package/dist/chunk-ymdy7b8z.js +0 -3
- package/dist/chunk-ytdzgctp.js +0 -2
package/dist/config.js
CHANGED
|
@@ -457,6 +457,15 @@ function applyStateDir(loaded) {
|
|
|
457
457
|
let _config = null;
|
|
458
458
|
const _cwdConfigCache = new Map, _layerSnapshots = new Map;
|
|
459
459
|
let _configPromise = null;
|
|
460
|
+
export async function discoverConfig(options, load = loadConfigWithResult) {
|
|
461
|
+
try {
|
|
462
|
+
return await load(options);
|
|
463
|
+
} catch (error) {
|
|
464
|
+
if (error instanceof Error && error.name === "ConfigNotFoundError")
|
|
465
|
+
return { config: options.defaultConfig };
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
460
469
|
export async function loadStxConfig(cwd) {
|
|
461
470
|
const effectiveCwd = cwd ? path.resolve(cwd) : process.cwd(), snapshot = _layerSnapshots.get(effectiveCwd);
|
|
462
471
|
if (snapshot && snapshot.signature !== layerSignature(snapshot.graph)) {
|
|
@@ -497,13 +506,13 @@ export async function loadStxConfig(cwd) {
|
|
|
497
506
|
const rootConfigExtensions = [".ts", ".js", ".mjs", ".cjs", ".json"], hasRootConfig = rootConfigExtensions.some((ext) => fs.existsSync(path.join(effectiveCwd, `stx.config${ext}`))), hasUiConfig = rootConfigExtensions.some((ext) => fs.existsSync(path.join(effectiveCwd, "config", `ui${ext}`)));
|
|
498
507
|
let loaded;
|
|
499
508
|
if (hasRootConfig && hasUiConfig) {
|
|
500
|
-
const uiResult = await
|
|
509
|
+
const uiResult = await discoverConfig({
|
|
501
510
|
name: "ui",
|
|
502
511
|
cwd: path.join(effectiveCwd, "config"),
|
|
503
512
|
defaultConfig,
|
|
504
513
|
verbose: !1
|
|
505
514
|
});
|
|
506
|
-
loaded = (await
|
|
515
|
+
loaded = (await discoverConfig({
|
|
507
516
|
name: "stx",
|
|
508
517
|
alias: "ui",
|
|
509
518
|
cwd: effectiveCwd,
|
|
@@ -511,7 +520,7 @@ export async function loadStxConfig(cwd) {
|
|
|
511
520
|
verbose: !1
|
|
512
521
|
})).config;
|
|
513
522
|
} else
|
|
514
|
-
loaded = (await
|
|
523
|
+
loaded = (await discoverConfig({
|
|
515
524
|
name: "stx",
|
|
516
525
|
alias: "ui",
|
|
517
526
|
cwd: effectiveCwd,
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qr,
|
|
2
|
+
import{qr,Do,Mo}from"./chunk-jvm6agq7.js";import"./chunk-j3vwyzvb.js";import"./chunk-3wcwtqx1.js";import"./chunk-w8vg3te3.js";import"./chunk-c1ys37c9.js";import"./chunk-d4ybwtqt.js";import"./chunk-kz131809.js";import"./chunk-wemq37qe.js";import"./chunk-ywah1c30.js";import"./chunk-ebg20d8s.js";import"./chunk-dajh1369.js";import"./chunk-tdv9np5t.js";import"./chunk-9k6r7f3c.js";import"./chunk-rtc17gy5.js";import{_d,To,Ed,Td,$o,Wr,Ro,$d,Ao,Rd,Ad,Po,Io,Oo}from"./chunk-q8nw82pz.js";import"./chunk-35kmebz9.js";import"./chunk-gwabvrc3.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{_d as CRAFT_BRIDGE_SCRIPT,Wr as CRAFT_COMPONENTS,$d as CRAFT_COMPONENT_RUNTIME,Ro as CRAFT_COMPONENT_STYLES,qr as NATIVE_COMPONENTS,Po as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Do as compileToNative,Mo as createHotReloadServer,To as generateCraftBridgeScript,V as generateCraftOptimizations,Oo as getAvailableFormats,Io as getAvailableTargets,Ad as getCraftComponents,G as getSSRCacheStats,$o as injectCraftBridge,Ed as isCraftEnvironment,Y as prerenderForCraft,Ao as processCraftComponents,Td as processCraftDirective,Rd as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qr,
|
|
2
|
+
import{qr,Do,Mo}from"./chunk-jvm6agq7.js";import"./chunk-j3vwyzvb.js";import"./chunk-3wcwtqx1.js";import"./chunk-w8vg3te3.js";import"./chunk-c1ys37c9.js";import"./chunk-d4ybwtqt.js";import"./chunk-kz131809.js";import"./chunk-wemq37qe.js";import"./chunk-ywah1c30.js";import"./chunk-ebg20d8s.js";import"./chunk-dajh1369.js";import"./chunk-tdv9np5t.js";import"./chunk-9k6r7f3c.js";import"./chunk-rtc17gy5.js";import{_d,To,Ed,Td,$o,Wr,Ro,$d,Ao,Rd,Ad,Po,Io,Oo}from"./chunk-q8nw82pz.js";import"./chunk-35kmebz9.js";import"./chunk-gwabvrc3.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{_d as CRAFT_BRIDGE_SCRIPT,Wr as CRAFT_COMPONENTS,$d as CRAFT_COMPONENT_RUNTIME,Ro as CRAFT_COMPONENT_STYLES,qr as NATIVE_COMPONENTS,Po as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Do as compileToNative,Mo as createHotReloadServer,To as generateCraftBridgeScript,V as generateCraftOptimizations,Oo as getAvailableFormats,Io as getAvailableTargets,Ad as getCraftComponents,G as getSSRCacheStats,$o as injectCraftBridge,Ed as isCraftEnvironment,Y as prerenderForCraft,Ao as processCraftComponents,Td as processCraftDirective,Rd as registerCraftComponent,Q as renderSSR};
|
|
@@ -14,14 +14,18 @@ function capabilityFlags(capabilities) {
|
|
|
14
14
|
pushNotifications: capabilities.has("push"),
|
|
15
15
|
secureStorage: capabilities.has("secureStorage"),
|
|
16
16
|
storage: capabilities.has("storage"),
|
|
17
|
+
crypto: capabilities.has("crypto"),
|
|
17
18
|
storageCompareAndSet: capabilities.has("storageCompareAndSet"),
|
|
19
|
+
storageSetIfAbsent: capabilities.has("storageSetIfAbsent"),
|
|
18
20
|
localDatabase: capabilities.has("database"),
|
|
19
21
|
lifecycle: capabilities.has("lifecycle"),
|
|
20
22
|
geolocation: capabilities.has("geolocation"),
|
|
21
23
|
locationRecordingOwnership: capabilities.has("locationRecordingOwnership"),
|
|
24
|
+
locationRecordingIntentIdentity: capabilities.has("locationRecordingIntentIdentity"),
|
|
22
25
|
music: capabilities.has("music"),
|
|
23
26
|
heartRate: capabilities.has("heartRate"),
|
|
24
27
|
heartRateRecordingOwnership: capabilities.has("heartRateRecordingOwnership"),
|
|
28
|
+
heartRateRecordingIntentIdentity: capabilities.has("heartRateRecordingIntentIdentity"),
|
|
25
29
|
bluetooth: capabilities.has("bluetooth"),
|
|
26
30
|
scheduledWorkouts: capabilities.has("scheduledWorkouts"),
|
|
27
31
|
liveActivities: capabilities.has("liveActivities"),
|
|
@@ -71,7 +75,21 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
71
75
|
return Promise.reject(Object.assign(Error("This app build cannot enforce recording ownership"), { code: "RECORDING_OWNERSHIP_UNSUPPORTED" }));
|
|
72
76
|
}
|
|
73
77
|
return request(module, method, options === void 0 ? [] : [options]);
|
|
78
|
+
}, recordingStart = async (module, options = {}) => {
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(options, "recordingId")) {
|
|
80
|
+
if (typeof options.recordingId !== "string" || !options.recordingId.trim())
|
|
81
|
+
throw Object.assign(Error("recordingId must be a nonempty recording ID"), { code: "INVALID_ARGUMENT" });
|
|
82
|
+
const prefix = module === "Location" ? "location" : "heartRate";
|
|
83
|
+
if (!capabilities.has(`${prefix}RecordingIntentIdentity`) || !capabilities.has(`${prefix}RecordingOwnership`))
|
|
84
|
+
throw Object.assign(Error("This app build cannot start the persisted recording intent"), { code: "RECORDING_INTENT_IDENTITY_UNSUPPORTED" });
|
|
85
|
+
}
|
|
86
|
+
const result = await ask(module, "startRecording", [options]);
|
|
87
|
+
if (options.recordingId !== void 0 && result?.id !== options.recordingId)
|
|
88
|
+
throw Object.assign(Error("The native recording does not match the persisted intent"), { code: "RECORDING_CONFLICT" });
|
|
89
|
+
return result;
|
|
74
90
|
};
|
|
91
|
+
if (capabilities.has("crypto"))
|
|
92
|
+
craft.crypto = { randomUUID: () => request("Crypto", "randomUUID", []) };
|
|
75
93
|
let appState = nativeBridge.initialAppState || "active", initialDeepLinkClaimed = !1;
|
|
76
94
|
const appStateHandlers = new Set, deepLinkHandlers = new Set, navButtonHandlers = new Set, navButtonPresses = {
|
|
77
95
|
leftButtons: new Map,
|
|
@@ -126,6 +144,11 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
126
144
|
remove: (key) => request("Storage", "remove", [key]),
|
|
127
145
|
clear: () => request("Storage", "clear", []),
|
|
128
146
|
keys: () => request("Storage", "keys", []),
|
|
147
|
+
setIfAbsent: (key, value) => {
|
|
148
|
+
if (!capabilities.has("storageSetIfAbsent"))
|
|
149
|
+
return Promise.reject(Object.assign(Error("This host cannot atomically register an intent"), { code: "STORAGE_SET_IF_ABSENT_UNSUPPORTED" }));
|
|
150
|
+
return request("Storage", "setIfAbsent", [key, value]);
|
|
151
|
+
},
|
|
129
152
|
compareAndSet: (key, expectedValue, nextValue) => {
|
|
130
153
|
if (!capabilities.has("storageCompareAndSet"))
|
|
131
154
|
return Promise.reject(Object.assign(Error("This host cannot atomically checkpoint existing storage"), { code: "STORAGE_COMPARE_AND_SET_UNSUPPORTED" }));
|
|
@@ -316,7 +339,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
316
339
|
return;
|
|
317
340
|
unwatched();
|
|
318
341
|
},
|
|
319
|
-
startRecording: (options = {}) =>
|
|
342
|
+
startRecording: (options = {}) => recordingStart("Location", options),
|
|
320
343
|
pauseRecording: (options) => recordingRequest("Location", "pauseRecording", options),
|
|
321
344
|
resumeRecording: (options) => recordingRequest("Location", "resumeRecording", options),
|
|
322
345
|
stopRecording: (options) => recordingRequest("Location", "stopRecording", options),
|
|
@@ -370,7 +393,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
370
393
|
connect: (id) => ask("HeartRate", "connect", [{ id: typeof id === "string" ? id : id?.id }]),
|
|
371
394
|
reconnect: () => strap("reconnect"),
|
|
372
395
|
disconnect: (options = {}) => strap("disconnect", { forget: !!options.forget }),
|
|
373
|
-
startRecording: () =>
|
|
396
|
+
startRecording: (options = {}) => recordingStart("HeartRate", options),
|
|
374
397
|
pauseRecording: (options) => recordingRequest("HeartRate", "pauseRecording", options),
|
|
375
398
|
resumeRecording: (options) => recordingRequest("HeartRate", "resumeRecording", options),
|
|
376
399
|
stopRecording: (options) => recordingRequest("HeartRate", "stopRecording", options),
|
|
@@ -100,6 +100,7 @@ export declare interface NativeStorage {
|
|
|
100
100
|
clear: () => Promise<unknown>
|
|
101
101
|
keys: () => Promise<string[]>
|
|
102
102
|
compareAndSet: (key: string, expectedValue: unknown, nextValue: unknown) => Promise<boolean>
|
|
103
|
+
setIfAbsent: (key: string, value: unknown) => Promise<boolean>
|
|
103
104
|
getSync: <T = unknown>(key: string) => T | null
|
|
104
105
|
setSync: (key: string, value: unknown) => void
|
|
105
106
|
}
|
|
@@ -129,6 +130,7 @@ export declare interface NativeCraft {
|
|
|
129
130
|
capabilityProtocolVersion: number
|
|
130
131
|
route: NativeRoute
|
|
131
132
|
capabilities: Record<string, boolean>
|
|
133
|
+
crypto?: { randomUUID: () => Promise<string> }
|
|
132
134
|
navigation: NativeNavigation
|
|
133
135
|
storage: NativeStorage
|
|
134
136
|
secureStorage: NativeSecureStorage
|
|
@@ -204,7 +206,7 @@ export declare interface NativeCraft {
|
|
|
204
206
|
getCurrentPosition: (options?: { enableHighAccuracy?: boolean, timeout?: number, maximumAge?: number }) => Promise<NativeLocation>
|
|
205
207
|
watchPosition: (callback: (location: NativeLocation) => unknown, options?: Record<string, unknown>) => number
|
|
206
208
|
clearWatch: (id?: number) => void
|
|
207
|
-
startRecording: (options?: Record<string, unknown>) => Promise<NativeLocationRecordingState>
|
|
209
|
+
startRecording: (options?: Record<string, unknown> & { recordingId?: string }) => Promise<NativeLocationRecordingState>
|
|
208
210
|
pauseRecording: (options?: { expectedId: string }) => Promise<NativeLocationRecordingState>
|
|
209
211
|
resumeRecording: (options?: { expectedId: string }) => Promise<NativeLocationRecordingState>
|
|
210
212
|
stopRecording: (options?: { expectedId: string }) => Promise<NativeLocationRecordingState & { locations: NativeLocation[] }>
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fn,Le,
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{Fn,Le,Vo,Za}from"./chunk-wjazf68a.js";import{Bn,Gr,Xa,Ja,Ya}from"./chunk-d8jdr1k4.js";import{zo,Ho,Uo,Ga,Ka}from"./chunk-9d6dr0dr.js";import{ae,yt,Kr}from"./chunk-8cs45k3f.js";import{el,tl,nl,rl,yr,Su}from"./chunk-qw4fjtt1.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-yqzhev40.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
|
|
|
233
233
|
}, 5000);
|
|
234
234
|
</script>
|
|
235
235
|
</body>
|
|
236
|
-
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Fn(n,t);if(a){let s=Le(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function se(n,t){return Gr(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Fn(n,t);if(a){let s=Le(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function se(n,t){return Gr(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Ho as auditBuildOutput,zo as auditConfig,re as buildPwaAssets,Uo as calculateAuditResult,Ka as formatAuditResult,Kr as formatSize,j as generateManifest,_ as generateManifestJson,Ja as generateManifestLink,F as generateOfflinePage,ae as generatePrecacheManifest,yt as generatePrecacheManifestJs,M as generatePwaIcons,Bn as generatePwaTags,Fn as generateServiceWorker,Za as generateServiceWorkerAuto,Xa as generateSwRegistrationScript,Ya as generateThemeColorMeta,N as getExpectedIconPaths,Le as getServiceWorkerFileName,Gr as injectPwaTags,oe as isPwaEnabled,I as isSharpAvailable,Vo as isWorkboxEnabled,q as mergeManifestConfig,se as processPwaHtml,yr as pwaDirectives,el as pwaInstallDirective,nl as pwaOfflineDirective,rl as pwaPushDirective,tl as pwaUpdateDirective,Su as registerPwaDirectives,Ga as runPwaAudit,D as validateManifest};
|
|
@@ -64,6 +64,23 @@ export declare function isBatching(): boolean;
|
|
|
64
64
|
* still runs its subscribers once.
|
|
65
65
|
*/
|
|
66
66
|
export declare function enqueueEffect(effect: () => void): void;
|
|
67
|
+
/**
|
|
68
|
+
* Register `subscriber` (a derived value's mark-dirty function) as one that
|
|
69
|
+
* forwards a change rather than reacting to it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function markAsForwarder(subscriber: () => void, collect: (into: Set<() => void>) => void): void;
|
|
72
|
+
/** Gather the effects a change reaches, walking through derived values. */
|
|
73
|
+
export declare function collectSubscribers(subscribers: Iterable<() => void>, into: Set<() => void>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Tell everything that read a value that it changed.
|
|
76
|
+
*
|
|
77
|
+
* Two phases: first every derived value on the way is marked stale and the
|
|
78
|
+
* effects it reaches are gathered, then each effect runs once. Running them
|
|
79
|
+
* as they were found ran an effect that reads a signal both directly and
|
|
80
|
+
* through a `derived` twice for one change, the first time against the
|
|
81
|
+
* derived's old value (a page loaded its data twice).
|
|
82
|
+
*/
|
|
83
|
+
export declare function notifySubscribers(subscribers: Iterable<() => void>): void;
|
|
67
84
|
/**
|
|
68
85
|
* Collect updates rather than applying them, and run each affected effect once
|
|
69
86
|
* when the outermost batch ends.
|
|
@@ -24,6 +24,29 @@ export function isBatching() {
|
|
|
24
24
|
export function enqueueEffect(effect) {
|
|
25
25
|
pendingEffects.add(effect);
|
|
26
26
|
}
|
|
27
|
+
const collectors = new WeakMap;
|
|
28
|
+
export function markAsForwarder(subscriber, collect) {
|
|
29
|
+
collectors.set(subscriber, collect);
|
|
30
|
+
}
|
|
31
|
+
export function collectSubscribers(subscribers, into) {
|
|
32
|
+
for (const subscriber of subscribers) {
|
|
33
|
+
const collect = collectors.get(subscriber);
|
|
34
|
+
if (collect)
|
|
35
|
+
collect(into);
|
|
36
|
+
else
|
|
37
|
+
into.add(subscriber);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function notifySubscribers(subscribers) {
|
|
41
|
+
if (batchDepth > 0) {
|
|
42
|
+
collectSubscribers(subscribers, pendingEffects);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const reached = new Set;
|
|
46
|
+
collectSubscribers(subscribers, reached);
|
|
47
|
+
for (const effect of reached)
|
|
48
|
+
effect();
|
|
49
|
+
}
|
|
27
50
|
export function runBatched(fn) {
|
|
28
51
|
batchDepth++;
|
|
29
52
|
try {
|
package/dist/reactivity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getActiveSubscriber, notifySubscribers, restoreActiveSubscriber, setActiveSubscriber } from "./reactive-tracking.js";
|
|
2
2
|
let currentInstance = null;
|
|
3
3
|
function structuralEqual(a, b, seen = new WeakSet) {
|
|
4
4
|
if (Object.is(a, b))
|
|
@@ -98,11 +98,7 @@ export function ref(initialValue) {
|
|
|
98
98
|
value = newValue;
|
|
99
99
|
for (const callback of subscribers)
|
|
100
100
|
callback(newValue, oldValue);
|
|
101
|
-
|
|
102
|
-
if (isBatching())
|
|
103
|
-
enqueueEffect(effect);
|
|
104
|
-
else
|
|
105
|
-
effect();
|
|
101
|
+
notifySubscribers(effectSubscribers);
|
|
106
102
|
}
|
|
107
103
|
},
|
|
108
104
|
subscribe(callback) {
|
|
@@ -125,11 +121,7 @@ export function reactive(target) {
|
|
|
125
121
|
const subs = subscribers.get(key);
|
|
126
122
|
if (!subs)
|
|
127
123
|
return;
|
|
128
|
-
|
|
129
|
-
if (isBatching())
|
|
130
|
-
enqueueEffect(callback);
|
|
131
|
-
else
|
|
132
|
-
callback();
|
|
124
|
+
notifySubscribers([...subs]);
|
|
133
125
|
}, subscribe = (key, callback) => {
|
|
134
126
|
if (!subscribers.has(key))
|
|
135
127
|
subscribers.set(key, new Set);
|
package/dist/signals-api.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
collectSubscribers,
|
|
3
3
|
getActiveSubscriber,
|
|
4
|
-
|
|
4
|
+
markAsForwarder,
|
|
5
|
+
notifySubscribers,
|
|
5
6
|
restoreActiveSubscriber,
|
|
6
7
|
runBatched,
|
|
7
8
|
setActiveSubscriber,
|
|
@@ -27,10 +28,7 @@ export function state(initialValue) {
|
|
|
27
28
|
console.error("[stx] subscriber error:", error);
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
-
effects.forEach((effect) => enqueueEffect(effect));
|
|
32
|
-
else
|
|
33
|
-
effects.forEach((effect) => effect());
|
|
31
|
+
notifySubscribers(effects);
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
34
|
signal.update = (fn) => {
|
|
@@ -53,12 +51,16 @@ export function derived(compute) {
|
|
|
53
51
|
const effects = new Set, markDirty = () => {
|
|
54
52
|
if (!isDirty) {
|
|
55
53
|
isDirty = !0;
|
|
56
|
-
|
|
57
|
-
effects.forEach((effect) => enqueueEffect(effect));
|
|
58
|
-
else
|
|
59
|
-
effects.forEach((effect) => effect());
|
|
54
|
+
notifySubscribers(effects);
|
|
60
55
|
}
|
|
61
|
-
}
|
|
56
|
+
};
|
|
57
|
+
markAsForwarder(markDirty, (into) => {
|
|
58
|
+
if (!isDirty) {
|
|
59
|
+
isDirty = !0;
|
|
60
|
+
collectSubscribers(effects, into);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const signal = () => {
|
|
62
64
|
const subscriber = getActiveSubscriber();
|
|
63
65
|
if (subscriber)
|
|
64
66
|
effects.add(subscriber);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Change notification shared by state, derived and reactive objects in the client runtime. */
|
|
2
|
+
export declare const SIGNALS_NOTIFY_RUNTIME = " // ==========================================================================\n // Notify\n // ==========================================================================\n\n // Gather the effects a change reaches, walking through derived values.\n function collectSubscribers(subscribers, into) {\n subscribers.forEach(function(sub) {\n if (sub._stxCollect) sub._stxCollect(into);\n else into.add(sub);\n });\n }\n\n // Two phases: mark every derived value on the way stale and gather the\n // effects reached, then run each once. Running them as found ran an effect\n // that reads a signal both directly and through a derived twice for one\n // change, the first time against the derived's old value.\n function notifySubscribers(subscribers) {\n if (isBatching) {\n collectSubscribers(subscribers, pendingEffects);\n return;\n }\n const reached = new Set();\n collectSubscribers(subscribers, reached);\n reached.forEach(function(e) { e(); });\n }\n";
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-ffxwsa94.js";import"./chunk-
|
|
2
|
+
import"./chunk-ffxwsa94.js";import"./chunk-j3vwyzvb.js";import"./chunk-3wcwtqx1.js";import{rt,st,ot,it,at,ct}from"./chunk-w8vg3te3.js";import"./chunk-c1ys37c9.js";import"./chunk-d4ybwtqt.js";import{f,He,N,X,n,o}from"./chunk-kz131809.js";import"./chunk-wemq37qe.js";import{or}from"./chunk-ywah1c30.js";import"./chunk-ebg20d8s.js";import"./chunk-dajh1369.js";import"./chunk-tdv9np5t.js";import"./chunk-9k6r7f3c.js";import"./chunk-nmy7mcbd.js";import{ce,bt,wt}from"./chunk-tgwdk0gt.js";import{jo,Bo,Fo}from"./chunk-k0shfsfx.js";import{ht,en,tn}from"./chunk-15g5sc0p.js";import"./chunk-gwabvrc3.js";import{a}from"./chunk-3m01ym55.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ft(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
3
|
`)}class mt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class yt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
@@ -41,7 +41,7 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now();wt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();wt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-503w9dn3.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-4zp2zzch.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new mt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-503w9dn3.js");await u('<div class="bg-black"></div>')}catch{}rt();let xt=s?.routeMiddleware?.dir||"middleware";await ot(process.cwd(),xt);let H=st();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=s?.routeMiddleware?.global||[];Fo(s?.layoutsDir,a(process.cwd()));let V=N(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let _=[];for(let u of V){let m=await Ot(u);for(let v of m)_.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=_.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],K=[];for(let u=0;u<_.length;u+=e.concurrency)K.push(_.slice(u,u+e.concurrency));for(let u of K)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...vt,...$t];if(tt.length>0){let C=it(d,L,F||{}),O=at(C,null,void 0,{isServer:!0}),E=await ct(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,U=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,U),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(U),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${et[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,nt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)nt=!0,l.cachedCount++}if(!k){let C=await St(v,L,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
|
|
|
73
73
|
<a href="/">Go home</a>
|
|
74
74
|
</div>
|
|
75
75
|
</body>
|
|
76
|
-
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},L=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),L)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=or({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let G=
|
|
76
|
+
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},L=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),L)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=or({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let G=jo(e.outputDir);if(G.assets>0)console.log(`Externalized ${G.assets} asset(s) from ${G.pages} page(s) (${(G.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=Bo(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await J(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=tn();if(Z)await J(Z,g.join(e.outputDir,en)),console.log(`Copied assets from ${ht}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
|
|
77
77
|
Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
78
78
|
Build complete!
|
|
79
79
|
Total: ${l.totalPages} pages
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.570",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -124,12 +124,12 @@
|
|
|
124
124
|
"dependencies": {
|
|
125
125
|
"@stacksjs/ts-css": "^0.3.11",
|
|
126
126
|
"@stacksjs/clapp": "^0.2.16",
|
|
127
|
-
"@stacksjs/desktop": "0.2.
|
|
128
|
-
"@stacksjs/sanitizer": "0.2.
|
|
127
|
+
"@stacksjs/desktop": "0.2.570",
|
|
128
|
+
"@stacksjs/sanitizer": "0.2.570",
|
|
129
129
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
130
|
-
"bun-plugin-stx": "0.2.
|
|
130
|
+
"bun-plugin-stx": "0.2.570",
|
|
131
131
|
"bunfig": "^0.15.19",
|
|
132
|
-
"stx-router": "0.2.
|
|
132
|
+
"stx-router": "0.2.570",
|
|
133
133
|
"ts-broadcasting": "^0.0.11",
|
|
134
134
|
"ts-images": "^0.2.22",
|
|
135
135
|
"ts-syntax-highlighter": "^0.2.1"
|
|
@@ -111,8 +111,9 @@ export function useMouse(options: MouseOptions = {}): MouseRef {
|
|
|
111
111
|
|
|
112
112
|
const handleMouseMove = (e: MouseEvent) => handleMove(e)
|
|
113
113
|
const handleTouchMove = (e: TouchEvent) => {
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const touch = e.touches[0]
|
|
115
|
+
if (touch) {
|
|
116
|
+
handleMove(touch, true)
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -281,8 +282,9 @@ export function useMouseInElement(
|
|
|
281
282
|
|
|
282
283
|
const handleMouseMove = (e: MouseEvent) => handleMove(e)
|
|
283
284
|
const handleTouchMove = (e: TouchEvent) => {
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
const touch = e.touches[0]
|
|
286
|
+
if (touch) {
|
|
287
|
+
handleMove(touch, true)
|
|
286
288
|
}
|
|
287
289
|
}
|
|
288
290
|
|
package/dist/chunk-04qvjcsr.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{gd,Eo,Ua,md,hd,yd,bd,wd,Va,Wa,vd,xd,Sd,kd}from"./chunk-mb59b499.js";import"./chunk-xw8kzm6b.js";import"./chunk-8afnq4qx.js";import"./chunk-4zb2ga7p.js";import"./chunk-dmf1jmge.js";import"./chunk-8txqk9nq.js";import"./chunk-ghnkphy4.js";import"./chunk-mt8sew7a.js";import"./chunk-1hrj0t0j.js";import"./chunk-m8qgr307.js";import"./chunk-d4ybwtqt.js";import"./chunk-7m0r2qs2.js";import"./chunk-ev3qnr9q.js";import"./chunk-rgage0vm.js";export{Ua as SUSPENSE_RESOLVER_RUNTIME,Eo as buildSuspenseResolveScript,wd as createStreamRenderer,yd as extractStreamBoundaries,kd as generateHydrationRuntime,Wa as islandDirective,xd as processSectionDirectives,hd as processStreamDirectives,vd as registerStreamingDirectives,md as renderStreamingPage,gd as streamTemplate,bd as streamTemplateSimple,Sd as streamToResponse,Va as streamingSuspenseDirective};
|
package/dist/chunk-2xbrrc5a.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Dr,Mr,Nr,xa,Lr,jr,Sa,Br,Fr,xo,ka}from"./chunk-jbmhdyzz.js";export{Dr as VideoProcessorCache,xo as analyzeVideo,xa as clearVideoCache,Fr as generateDASHManifest,Br as generateHLSManifest,Lr as generatePoster,Sa as generateSpriteSheet,jr as generateThumbnails,Mr as getCachedVideoResult,ka as processVideo,Nr as setCachedVideoResult};
|
package/dist/chunk-2yypassp.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ao,Po,Io,Ad}from"./chunk-55hfvmvv.js";import"./chunk-c765y72x.js";import"./chunk-saf7kypg.js";import"./chunk-xw8kzm6b.js";import"./chunk-8afnq4qx.js";import"./chunk-4zb2ga7p.js";import"./chunk-dmf1jmge.js";import"./chunk-8txqk9nq.js";import"./chunk-ghnkphy4.js";import"./chunk-mt8sew7a.js";import"./chunk-1hrj0t0j.js";import"./chunk-m8qgr307.js";import"./chunk-d4ybwtqt.js";import"./chunk-7m0r2qs2.js";import"./chunk-ev3qnr9q.js";import"./chunk-rgage0vm.js";export{Ao as buildNative,Ad as default,Io as getAvailableFormats,Po as getAvailableTargets};
|
package/dist/chunk-375skn32.js
DELETED
package/dist/chunk-3wyxe996.js
DELETED