@stacksjs/stx 0.2.890 → 0.2.891
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-9a9cec4x.js → chunk-08kcxz79.js} +1 -1
- package/dist/{chunk-r7m60q1m.js → chunk-0fyh29m1.js} +1 -1
- package/dist/{chunk-xeyq6d0t.js → chunk-0t31rf3v.js} +1 -1
- package/dist/chunk-0w578pgv.js +3 -0
- package/dist/{chunk-1t15z230.js → chunk-0yxvz6qz.js} +2 -2
- package/dist/chunk-0zynd3x0.js +2 -0
- package/dist/chunk-10c7pg5h.js +2 -0
- package/dist/{chunk-wedwczed.js → chunk-12m3qagv.js} +1 -1
- package/dist/{chunk-8f8qgjjr.js → chunk-12nmmdnp.js} +1 -1
- package/dist/{chunk-6svc4kb8.js → chunk-1vp0h7d6.js} +9 -9
- package/dist/{chunk-zpqjsnz9.js → chunk-29cw0fcr.js} +1 -1
- package/dist/{chunk-xwrjre34.js → chunk-2eq3aret.js} +1 -1
- package/dist/chunk-3ngbdap1.js +2 -0
- package/dist/{chunk-gfea8a9y.js → chunk-3t30a2nx.js} +1 -1
- package/dist/chunk-484x27q5.js +2 -0
- package/dist/{chunk-9344rq4r.js → chunk-4f3456ht.js} +1 -1
- package/dist/{chunk-v1mwwben.js → chunk-4r6hbjx7.js} +2 -2
- package/dist/chunk-4ts8qztg.js +2 -0
- package/dist/{chunk-1bft48gk.js → chunk-5zs5hrgz.js} +2 -2
- package/dist/{chunk-k8bk685s.js → chunk-6aq1pv9a.js} +1 -1
- package/dist/chunk-6kkatcka.js +2 -0
- package/dist/{chunk-a3zrwky3.js → chunk-6kt9wxja.js} +1 -1
- package/dist/{chunk-nzpb263k.js → chunk-70paeznz.js} +5 -5
- package/dist/{chunk-v90nz5xm.js → chunk-7d2j41e3.js} +4 -4
- package/dist/{chunk-49xwf7dk.js → chunk-8ay5r808.js} +2 -2
- package/dist/{chunk-40k0r6z9.js → chunk-8hdp4ark.js} +1 -1
- package/dist/chunk-8res5m9x.js +2 -0
- package/dist/{chunk-zf68afyh.js → chunk-8y39f6z3.js} +3 -3
- package/dist/{chunk-4akw3bym.js → chunk-90qwzwsm.js} +1 -1
- package/dist/{chunk-ch9028z3.js → chunk-9f8fda1j.js} +1 -1
- package/dist/{chunk-eq86wzhr.js → chunk-9w6k311w.js} +35 -27
- package/dist/{chunk-3yvmaphj.js → chunk-9zhpv03v.js} +1 -1
- package/dist/chunk-a5d5qveh.js +2 -0
- package/dist/{chunk-4eescf3s.js → chunk-aasgawa9.js} +4 -4
- package/dist/{chunk-xmg6bmh6.js → chunk-ac3e6nhg.js} +3 -3
- package/dist/{chunk-qnf7w4xw.js → chunk-b0jk94wx.js} +3 -3
- package/dist/{chunk-kr2400c3.js → chunk-b18vpz6p.js} +1 -1
- package/dist/chunk-bsbd6y64.js +2 -0
- package/dist/{chunk-sztr4d5g.js → chunk-cf527twj.js} +1 -1
- package/dist/{chunk-bm0mzk3b.js → chunk-cgrg6xzg.js} +1 -1
- package/dist/{chunk-adsqckg4.js → chunk-dm069acv.js} +4 -4
- package/dist/{chunk-yesh4dfe.js → chunk-e5md1cck.js} +4 -4
- package/dist/{chunk-j9vfv53x.js → chunk-fs7tv867.js} +1 -1
- package/dist/{chunk-1jtsr42q.js → chunk-gcjqxvbb.js} +6 -2
- package/dist/{chunk-35j7gaj5.js → chunk-gk0h2hp7.js} +1 -1
- package/dist/{chunk-b0hj8eg2.js → chunk-gwayvyg5.js} +1 -1
- package/dist/{chunk-kg7vby72.js → chunk-gydvy8a3.js} +5 -5
- package/dist/{chunk-8ccgty8s.js → chunk-gzc16hs8.js} +2 -2
- package/dist/{chunk-xy8smv5e.js → chunk-h7yme97q.js} +2 -2
- package/dist/chunk-h87pjzn7.js +2 -0
- package/dist/{chunk-94j4p584.js → chunk-hq03mwtw.js} +1 -1
- package/dist/chunk-k0mndyb4.js +2 -0
- package/dist/{chunk-nhv81gp2.js → chunk-k89gbytd.js} +2 -2
- package/dist/{chunk-aj5tsksz.js → chunk-kd7k31x3.js} +4 -4
- package/dist/{chunk-t0ttxayz.js → chunk-kfbw96c5.js} +2 -2
- package/dist/chunk-kh3sxa3j.js +2 -0
- package/dist/chunk-kr4z3633.js +2 -0
- package/dist/{chunk-rd663v1m.js → chunk-kvz7ad7p.js} +1 -1
- package/dist/{chunk-wy6vjz1e.js → chunk-kxewj557.js} +19 -19
- package/dist/chunk-mbpz45v9.js +2 -0
- package/dist/{chunk-whcrca58.js → chunk-mxf6cfbg.js} +6 -6
- package/dist/{chunk-9rjgq8k4.js → chunk-n64zbwzr.js} +1 -1
- package/dist/chunk-nd0f11at.js +2 -0
- package/dist/{chunk-p0bjbtdx.js → chunk-nvre22sw.js} +5 -5
- package/dist/chunk-p9cwapm8.js +2 -0
- package/dist/{chunk-12cjs6vs.js → chunk-ph4tgp9g.js} +1 -1
- package/dist/{chunk-0wp23n1d.js → chunk-phx820py.js} +1 -1
- package/dist/{chunk-690518hw.js → chunk-pjpf21y9.js} +1 -1
- package/dist/{chunk-1w0bqqh5.js → chunk-psykt348.js} +1 -1
- package/dist/{chunk-0k437z3q.js → chunk-qn45rk5n.js} +1 -1
- package/dist/{chunk-t3zmfh8w.js → chunk-qrk535j6.js} +4 -4
- package/dist/{chunk-97snfzsy.js → chunk-rc7djca5.js} +19 -19
- package/dist/chunk-sydgagr1.js +2 -0
- package/dist/chunk-vm57848v.js +2 -0
- package/dist/{chunk-4d85str1.js → chunk-vya7cck4.js} +1 -1
- package/dist/{chunk-vkfw9k1n.js → chunk-w8djc4qb.js} +8 -8
- package/dist/chunk-wwb6c5rr.js +2 -0
- package/dist/chunk-x691tnkx.js +2 -0
- package/dist/{chunk-cphc60zw.js → chunk-x9036mfd.js} +2 -2
- package/dist/{chunk-80ky40mm.js → chunk-xvprhdcb.js} +1 -1
- package/dist/chunk-y7qm1m0e.js +2 -0
- package/dist/{chunk-c25q87ys.js → chunk-ye6ev3qp.js} +1 -1
- package/dist/{chunk-g3vce7ka.js → chunk-ypyezjr0.js} +1 -1
- package/dist/{chunk-vxbvrbqs.js → chunk-yv797v6e.js} +2 -2
- package/dist/{chunk-cmg9x1ka.js → chunk-z012vpdz.js} +3 -3
- package/dist/{chunk-hyyh7qxw.js → chunk-z6ndrx2p.js} +1 -1
- package/dist/{chunk-2nqmw4dv.js → chunk-z8sv926e.js} +1 -1
- package/dist/{chunk-2xnbdqy4.js → chunk-z92e297r.js} +2 -2
- package/dist/chunk-zd21ntcm.js +2 -0
- package/dist/cli.js +14 -14
- package/dist/client/signals-timer-runtime.js +4 -0
- package/dist/component-library.js +11 -3
- package/dist/component-renderer.js +23 -10
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/prop-names.js +7 -2
- package/dist/native/runtime/craft-bridge.js +29 -2
- package/dist/native/runtime/craft.d.ts +32 -0
- package/dist/native/runtime/native-host.js +27 -11
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +10 -10
- package/package.json +5 -5
- package/stx.d.ts +2 -1
- package/dist/chunk-0q0nbq50.js +0 -2
- package/dist/chunk-44teqn0b.js +0 -2
- package/dist/chunk-4xbtxeak.js +0 -2
- package/dist/chunk-6s3jwysv.js +0 -2
- package/dist/chunk-850tye3c.js +0 -2
- package/dist/chunk-amb7e0fp.js +0 -2
- package/dist/chunk-e8szp5wa.js +0 -2
- package/dist/chunk-hda7t8g6.js +0 -2
- package/dist/chunk-j6fs31va.js +0 -2
- package/dist/chunk-jvnsz2x9.js +0 -2
- package/dist/chunk-kexqmwx8.js +0 -2
- package/dist/chunk-kpjq135z.js +0 -2
- package/dist/chunk-kqsm7gf1.js +0 -2
- package/dist/chunk-mtfymhy1.js +0 -2
- package/dist/chunk-p82fzxdg.js +0 -2
- package/dist/chunk-qsv84cwm.js +0 -2
- package/dist/chunk-r98pye4h.js +0 -2
- package/dist/chunk-t4gcsbna.js +0 -2
- package/dist/chunk-tbh7r1wh.js +0 -2
- package/dist/chunk-vfcbz0an.js +0 -3
- package/dist/chunk-wmvvrsn0.js +0 -2
- package/dist/chunk-wnrh62by.js +0 -2
- package/dist/chunk-ymc1wgb3.js +0 -2
|
@@ -277,6 +277,10 @@ else if (timer === null) {
|
|
|
277
277
|
function useClickOutside(target, handler) {
|
|
278
278
|
function resolveTarget() {
|
|
279
279
|
if (typeof target === 'string') return document.querySelector(target);
|
|
280
|
+
// A getter (\`() => box.current\`), as the module composable's MaybeRef reads one.
|
|
281
|
+
// It used to be taken for the element itself, and every pointerdown threw
|
|
282
|
+
// "el.contains is not a function" without ever running the handler.
|
|
283
|
+
if (typeof target === 'function') return target();
|
|
280
284
|
if (target && typeof target === 'object') {
|
|
281
285
|
if ('current' in target) return target.current;
|
|
282
286
|
if ('value' in target) return target.value;
|
|
@@ -801,7 +801,10 @@ ${signals ? ` _beginScope() {
|
|
|
801
801
|
}
|
|
802
802
|
|
|
803
803
|
_callScopeMethod(name, args) {
|
|
804
|
-
|
|
804
|
+
// Template calls already have this render's current prop closures. Refresh
|
|
805
|
+
// pending props only for an outside call, otherwise a public helper in the
|
|
806
|
+
// template would recursively render while the queued update is pending.
|
|
807
|
+
if (!this._scopeRenderDepth && (!this._scopeMethods || this._updatePending)) this.render(RENDER_HELPERS);
|
|
805
808
|
return this._scopeMethods[name].apply(this, args);
|
|
806
809
|
}
|
|
807
810
|
|
|
@@ -1025,8 +1028,13 @@ ${inner}
|
|
|
1025
1028
|
}
|
|
1026
1029
|
renderMethod = `
|
|
1027
1030
|
render(__helpers) {
|
|
1028
|
-
|
|
1029
|
-
|
|
1031
|
+
this._scopeRenderDepth = (this._scopeRenderDepth || 0) + 1;
|
|
1032
|
+
try {
|
|
1033
|
+
const { escape: __escape, raw: __raw, values: __values, entries: __entries } = __helpers;
|
|
1034
|
+
${indent(indent(compiled.trim()))}
|
|
1035
|
+
} finally {
|
|
1036
|
+
this._scopeRenderDepth--;
|
|
1037
|
+
}
|
|
1030
1038
|
}
|
|
1031
1039
|
`;
|
|
1032
1040
|
}
|
|
@@ -623,6 +623,15 @@ function forwardHostAttrs(html, props, declaredProps = new Set, consumedProps =
|
|
|
623
623
|
const root = findRenderedComponentHostRoot(html, nativeTarget);
|
|
624
624
|
if (!root)
|
|
625
625
|
return html;
|
|
626
|
+
const outer = nativeTarget ? findRenderedComponentRoot(html) : null;
|
|
627
|
+
if (outer) {
|
|
628
|
+
const alternates = findOwnedNativeHostRoots(html, outer).filter((other) => other.insertPos > root.insertPos);
|
|
629
|
+
for (let index = alternates.length - 1;index >= 0; index--)
|
|
630
|
+
html = forwardHostAttrsTo(html, alternates[index], props, declaredProps, consumedProps, nativeTarget);
|
|
631
|
+
}
|
|
632
|
+
return forwardHostAttrsTo(html, root, props, declaredProps, consumedProps, nativeTarget);
|
|
633
|
+
}
|
|
634
|
+
function forwardHostAttrsTo(html, root, props, declaredProps, consumedProps, nativeTarget) {
|
|
626
635
|
let openingTag = html.slice(root.insertPos, root.tagEnd);
|
|
627
636
|
const callerClass = props.serverDynamic.class ?? props.static.class;
|
|
628
637
|
if (nativeTarget && typeof callerClass === "string" && callerClass && !consumedProps.has("class")) {
|
|
@@ -703,15 +712,19 @@ function findRenderedComponentHostRoot(html, nativeTarget = !1) {
|
|
|
703
712
|
return root && nativeTarget ? findOwnedNativeHostRoot(html, root) ?? root : root;
|
|
704
713
|
}
|
|
705
714
|
function findOwnedNativeHostRoot(html, root) {
|
|
715
|
+
return findOwnedNativeHostRoots(html, root)[0] ?? null;
|
|
716
|
+
}
|
|
717
|
+
function findOwnedNativeHostRoots(html, root) {
|
|
718
|
+
const found = [];
|
|
706
719
|
if (!html.includes("data-stx-native-host-root"))
|
|
707
|
-
return
|
|
720
|
+
return found;
|
|
708
721
|
const voidTags = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
709
722
|
let cursor = html.lastIndexOf("<", root.insertPos), depth = 0, foreignDepth;
|
|
710
723
|
while (cursor >= 0 && cursor < html.length) {
|
|
711
724
|
if (html.startsWith("<!--", cursor)) {
|
|
712
725
|
const end = html.indexOf("-->", cursor + 4);
|
|
713
726
|
if (end < 0)
|
|
714
|
-
return
|
|
727
|
+
return found;
|
|
715
728
|
cursor = html.indexOf("<", end + 3);
|
|
716
729
|
continue;
|
|
717
730
|
}
|
|
@@ -726,28 +739,28 @@ function findOwnedNativeHostRoot(html, root) {
|
|
|
726
739
|
if (foreignDepth !== void 0 && depth < foreignDepth)
|
|
727
740
|
foreignDepth = void 0;
|
|
728
741
|
if (depth <= 0)
|
|
729
|
-
return
|
|
742
|
+
return found;
|
|
730
743
|
} else if (name === "script" || name === "style") {
|
|
731
744
|
const close = new RegExp(`</${name}\\s*>`, "gi");
|
|
732
745
|
close.lastIndex = tagEnd + 1;
|
|
733
746
|
if (!close.exec(html))
|
|
734
|
-
return
|
|
747
|
+
return found;
|
|
735
748
|
cursor = html.indexOf("<", close.lastIndex);
|
|
736
749
|
continue;
|
|
737
750
|
} else {
|
|
738
|
-
const attributes = parseAllAttributes(html.slice(insertPos, tagEnd)), foreign = depth > 0 && (Object.hasOwn(attributes, "data-stx-component-wrapper") || Object.hasOwn(attributes, "data-stx-native-host-owner"));
|
|
739
|
-
if (
|
|
740
|
-
|
|
751
|
+
const attributes = parseAllAttributes(html.slice(insertPos, tagEnd)), foreign = depth > 0 && (Object.hasOwn(attributes, "data-stx-component-wrapper") || Object.hasOwn(attributes, "data-stx-native-host-owner")), marked = foreignDepth === void 0 && !foreign && Object.hasOwn(attributes, "data-stx-native-host-root");
|
|
752
|
+
if (marked)
|
|
753
|
+
found.push({ insertPos, tagEnd });
|
|
741
754
|
if (!voidTags.has(name) && html[tagEnd - 1] !== "/") {
|
|
742
755
|
depth++;
|
|
743
|
-
if (foreignDepth === void 0 && foreign)
|
|
756
|
+
if (foreignDepth === void 0 && (foreign || marked))
|
|
744
757
|
foreignDepth = depth;
|
|
745
758
|
} else if (depth === 0)
|
|
746
|
-
return
|
|
759
|
+
return found;
|
|
747
760
|
}
|
|
748
761
|
cursor = html.indexOf("<", tagEnd + 1);
|
|
749
762
|
}
|
|
750
|
-
return
|
|
763
|
+
return found;
|
|
751
764
|
}
|
|
752
765
|
function findFirstRenderedElement(html, start) {
|
|
753
766
|
let cursor = start;
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-9w6k311w.js";import{Uo,Va,Wa}from"./chunk-z012vpdz.js";import"./chunk-mxf6cfbg.js";import"./chunk-0jdz31q1.js";import"./chunk-ac3e6nhg.js";import"./chunk-x9036mfd.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-ypyezjr0.js";import"./chunk-q0y8gv18.js";import"./chunk-gzc16hs8.js";import"./chunk-e5md1cck.js";import"./chunk-qrk535j6.js";import"./chunk-rb2zbdqd.js";import"./chunk-gwayvyg5.js";import"./chunk-dm069acv.js";import"./chunk-1vp0h7d6.js";import"./chunk-w8djc4qb.js";import"./chunk-7d2j41e3.js";import"./chunk-yv797v6e.js";import"./chunk-z6ndrx2p.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Vo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-nvre22sw.js";import"./chunk-0yxvz6qz.js";import"./chunk-0w578pgv.js";import"./chunk-xvprhdcb.js";import"./chunk-gydvy8a3.js";import"./chunk-n64zbwzr.js";import"./chunk-n6q1d66k.js";import"./chunk-b0jk94wx.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{Hu as CRAFT_BRIDGE_SCRIPT,
|
|
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{Hu as CRAFT_BRIDGE_SCRIPT,Vo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Uo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Va as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-9w6k311w.js";import{Uo,Va,Wa}from"./chunk-z012vpdz.js";import"./chunk-mxf6cfbg.js";import"./chunk-0jdz31q1.js";import"./chunk-ac3e6nhg.js";import"./chunk-x9036mfd.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-ypyezjr0.js";import"./chunk-q0y8gv18.js";import"./chunk-gzc16hs8.js";import"./chunk-e5md1cck.js";import"./chunk-qrk535j6.js";import"./chunk-rb2zbdqd.js";import"./chunk-gwayvyg5.js";import"./chunk-dm069acv.js";import"./chunk-1vp0h7d6.js";import"./chunk-w8djc4qb.js";import"./chunk-7d2j41e3.js";import"./chunk-yv797v6e.js";import"./chunk-z6ndrx2p.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Vo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-nvre22sw.js";import"./chunk-0yxvz6qz.js";import"./chunk-0w578pgv.js";import"./chunk-xvprhdcb.js";import"./chunk-gydvy8a3.js";import"./chunk-n64zbwzr.js";import"./chunk-n6q1d66k.js";import"./chunk-b0jk94wx.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{Hu as CRAFT_BRIDGE_SCRIPT,
|
|
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{Hu as CRAFT_BRIDGE_SCRIPT,Vo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Uo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Va as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
|
|
@@ -102,13 +102,17 @@ const NATIVE_PROP_NAMES = [
|
|
|
102
102
|
"ghostText",
|
|
103
103
|
"rowHeight",
|
|
104
104
|
"labelFontSize",
|
|
105
|
+
"labelFontWeight",
|
|
106
|
+
"selectionInset",
|
|
107
|
+
"contentInset",
|
|
105
108
|
"pictureInPicture",
|
|
106
109
|
"transitionID",
|
|
107
110
|
"dragData",
|
|
108
111
|
"dragURL",
|
|
109
112
|
"dropTypes",
|
|
110
113
|
"dropInside",
|
|
111
|
-
"selectTextOnFocus"
|
|
114
|
+
"selectTextOnFocus",
|
|
115
|
+
"iconOnly"
|
|
112
116
|
];
|
|
113
117
|
export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
114
118
|
"alwaysBounceHorizontal",
|
|
@@ -149,7 +153,8 @@ export const NATIVE_BOOLEAN_PROPS = new Set([
|
|
|
149
153
|
"showsCompass",
|
|
150
154
|
"showsScale",
|
|
151
155
|
"pictureInPicture",
|
|
152
|
-
"grabberVisible"
|
|
156
|
+
"grabberVisible",
|
|
157
|
+
"iconOnly"
|
|
153
158
|
]);
|
|
154
159
|
const nativePropNames = new Map(NATIVE_PROP_NAMES.map((name) => [normaliseKey(name), name]));
|
|
155
160
|
function normaliseKey(name) {
|
|
@@ -8,6 +8,7 @@ const permissionFallbacks = new WeakSet;
|
|
|
8
8
|
function capabilityFlags(capabilities) {
|
|
9
9
|
return {
|
|
10
10
|
desktop: capabilities.has("desktop"),
|
|
11
|
+
updater: capabilities.has("updater"),
|
|
11
12
|
haptics: capabilities.has("haptics"),
|
|
12
13
|
rawMotionSensors: capabilities.has("rawMotionSensors"),
|
|
13
14
|
barometer: capabilities.has("barometer"),
|
|
@@ -413,6 +414,32 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
413
414
|
setDefaultBrowser: () => request("Desktop", "setDefaultBrowser", [])
|
|
414
415
|
};
|
|
415
416
|
}
|
|
417
|
+
if (capabilities.has("updater") || capabilities.has("desktop")) {
|
|
418
|
+
const isStatus = (value) => !!value && typeof value === "object" && typeof value.state === "string", unavailable = () => ({
|
|
419
|
+
currentVersion: craft.app.version,
|
|
420
|
+
state: "unavailable",
|
|
421
|
+
selfUpdating: !1,
|
|
422
|
+
reason: "This version of the app cannot update itself."
|
|
423
|
+
}), failed = (error) => {
|
|
424
|
+
const code = String(error?.code ?? "");
|
|
425
|
+
if (["CAPABILITY_DISABLED", "UNSUPPORTED", "UNSUPPORTED_METHOD", "UNSUPPORTED_MODULE"].includes(code))
|
|
426
|
+
return unavailable();
|
|
427
|
+
const message = typeof error?.message === "string" ? error.message : String(error);
|
|
428
|
+
return { currentVersion: craft.app.version, state: "error", selfUpdating: !1, error: message };
|
|
429
|
+
}, answer = (method) => request("Updater", method, []).then((value) => isStatus(value) ? value : unavailable(), failed);
|
|
430
|
+
craft.updater = {
|
|
431
|
+
status: () => answer("status"),
|
|
432
|
+
check: () => answer("check"),
|
|
433
|
+
install: () => answer("install"),
|
|
434
|
+
relaunch: () => request("Updater", "relaunch", []).then(() => {
|
|
435
|
+
return;
|
|
436
|
+
}),
|
|
437
|
+
onChange: (callback) => protocol.on("CRAFT_EVENT", ({ payload }) => {
|
|
438
|
+
if (payload?.event === "craftUpdaterChange" && isStatus(payload.detail))
|
|
439
|
+
callback(payload.detail);
|
|
440
|
+
})
|
|
441
|
+
};
|
|
442
|
+
}
|
|
416
443
|
if (capabilities.has("web")) {
|
|
417
444
|
const call = (method, args) => request("Web", method, args), web = {
|
|
418
445
|
create: (options = {}) => call("create", [options]),
|
|
@@ -1100,7 +1127,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
1100
1127
|
return Promise.reject(TypeError("fetch in a native screen sends string bodies only"));
|
|
1101
1128
|
if (body != null && (method === "GET" || method === "HEAD"))
|
|
1102
1129
|
return Promise.reject(TypeError("A GET or HEAD request cannot have a body"));
|
|
1103
|
-
const signal = init.signal || source.signal;
|
|
1130
|
+
const signal = init.signal || source.signal, omitCredentials = (init.credentials || source.credentials) === "omit";
|
|
1104
1131
|
if (signal?.aborted)
|
|
1105
1132
|
return Promise.reject(abortError(signal.reason));
|
|
1106
1133
|
if (typeof init.onUploadProgress === "function" && !capabilities.has("uploadProgress"))
|
|
@@ -1113,7 +1140,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
1113
1140
|
if (!signal?.aborted)
|
|
1114
1141
|
init.onUploadProgress(value);
|
|
1115
1142
|
});
|
|
1116
|
-
return protocol.request("API_REQUEST", { version: 1, module: "Network", method: "fetch", args: [{ url, method, headers, body: body == null ? null : body, ...form ? { form } : {}, ...uploadProgressId ? { uploadProgressId } : {} }], ...form ? { untimed: !0 } : {} }, form ? null : void 0, signal).then((data) => {
|
|
1143
|
+
return protocol.request("API_REQUEST", { version: 1, module: "Network", method: "fetch", args: [{ url, method, headers, body: body == null ? null : body, ...omitCredentials ? { credentials: "omit" } : {}, ...form ? { form } : {}, ...uploadProgressId ? { uploadProgressId } : {} }], ...form ? { untimed: !0 } : {} }, form ? null : void 0, signal).then((data) => {
|
|
1117
1144
|
const responseBody = data?.body == null ? "" : String(data.body);
|
|
1118
1145
|
let bodyUsed = !1;
|
|
1119
1146
|
return response(data, { get bodyUsed() {
|
|
@@ -256,6 +256,7 @@ export declare interface NativeCraft {
|
|
|
256
256
|
barometer?: NativeBarometer
|
|
257
257
|
liveActivity?: NativeLiveActivities
|
|
258
258
|
desktop?: NativeDesktop
|
|
259
|
+
updater?: NativeUpdater
|
|
259
260
|
web?: NativeWeb
|
|
260
261
|
platform: string
|
|
261
262
|
capabilityProtocolVersion: number
|
|
@@ -416,6 +417,35 @@ export declare interface NativeCraft {
|
|
|
416
417
|
app: { url: string, version: string, build: string }
|
|
417
418
|
background?: { complete: (ok?: boolean, id?: string) => Promise<boolean> }
|
|
418
419
|
}
|
|
420
|
+
/** What `craft.updater` reports: in every answer and in every change. */
|
|
421
|
+
export declare interface NativeUpdateStatus {
|
|
422
|
+
currentVersion: string
|
|
423
|
+
state: NativeUpdateState
|
|
424
|
+
selfUpdating: boolean
|
|
425
|
+
reason?: string
|
|
426
|
+
version?: string
|
|
427
|
+
notes?: string
|
|
428
|
+
publishedAt?: string
|
|
429
|
+
progress?: number
|
|
430
|
+
error?: string
|
|
431
|
+
lastCheckedAt?: string
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* In-app updates (`craft.updater`), answered by the host's `Updater` module.
|
|
435
|
+
*
|
|
436
|
+
* Present on Craft's AppKit host. A host that has the surface but cannot
|
|
437
|
+
* update (no `updates` in its config, a Mac App Store build, a host older than
|
|
438
|
+
* the module) answers every call with `state: 'unavailable'` and
|
|
439
|
+
* `selfUpdating: false`, so a screen draws from the status and never from
|
|
440
|
+
* whether a call threw.
|
|
441
|
+
*/
|
|
442
|
+
export declare interface NativeUpdater {
|
|
443
|
+
status: () => Promise<NativeUpdateStatus>
|
|
444
|
+
check: () => Promise<NativeUpdateStatus>
|
|
445
|
+
install: () => Promise<NativeUpdateStatus>
|
|
446
|
+
relaunch: () => Promise<void>
|
|
447
|
+
onChange: (callback: (status: NativeUpdateStatus) => void) => () => void
|
|
448
|
+
}
|
|
419
449
|
export declare interface NativeDesktop {
|
|
420
450
|
openWindow: (options: { name: string, route: string, title?: string, titlebarStyle?: 'standard' | 'transparent', width?: number, height?: number, minWidth?: number, minHeight?: number, floating?: boolean, params?: Record<string, unknown> }) => Promise<{ name: string }>
|
|
421
451
|
closeWindow: () => Promise<void>
|
|
@@ -567,6 +597,8 @@ export type NativePedometerEvent = | { state: 'sample', kind: 'interval', startD
|
|
|
567
597
|
| { state: 'sample', kind: 'step', count: 1, timestampMs: number }
|
|
568
598
|
| { state: 'stopped', reason: 'requested' | 'background' | 'disposed' | 'sensorError' | 'permissionDenied' }
|
|
569
599
|
export type NativePasskeyCredential = NativePasskeyRegistration | NativePasskeyAssertion;
|
|
600
|
+
/** Where an in-app update stands. */
|
|
601
|
+
export type NativeUpdateState = 'unavailable' | 'idle' | 'checking' | 'current' | 'available' | 'downloading' | 'installing' | 'installed' | 'error';
|
|
570
602
|
export type NativeWebEvent = | ({ type: 'state' } & NativeWebTabState)
|
|
571
603
|
| { type: 'navigationStart' | 'navigationFinish', tab: string, url: string }
|
|
572
604
|
| { type: 'navigationError', tab: string, url: string, code: number, domain: string, message: string }
|
|
@@ -623,26 +623,28 @@ export function createNativeHost(options) {
|
|
|
623
623
|
return !1;
|
|
624
624
|
return !0;
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function forwardedHostRoots(node, name) {
|
|
627
|
+
const found = [];
|
|
627
628
|
if (!isBindingNode(node))
|
|
628
|
-
return;
|
|
629
|
+
return found;
|
|
629
630
|
const forward = node.getAttribute("data-stx-native-forward");
|
|
630
631
|
if (!forward || !words(forward).includes(name))
|
|
631
|
-
return;
|
|
632
|
+
return found;
|
|
632
633
|
const find = (candidate) => {
|
|
633
634
|
if (candidate !== node && isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-owner"))
|
|
634
635
|
return;
|
|
635
|
-
if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root"))
|
|
636
|
-
|
|
636
|
+
if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root")) {
|
|
637
|
+
found.push(candidate);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
637
640
|
for (const child of recordOf(candidate).children) {
|
|
638
641
|
if (isBindingNode(child) && child.hasAttribute("data-stx-component-wrapper"))
|
|
639
642
|
continue;
|
|
640
|
-
|
|
641
|
-
if (match)
|
|
642
|
-
return match;
|
|
643
|
+
find(child);
|
|
643
644
|
}
|
|
644
645
|
};
|
|
645
|
-
|
|
646
|
+
find(node);
|
|
647
|
+
return found;
|
|
646
648
|
}
|
|
647
649
|
function callerBindingOnWrapper(node, name) {
|
|
648
650
|
if (!isBindingNode(node) || !node.hasAttribute("data-stx-component-wrapper"))
|
|
@@ -1128,7 +1130,14 @@ export function createNativeHost(options) {
|
|
|
1128
1130
|
}
|
|
1129
1131
|
},
|
|
1130
1132
|
setAttribute(node, name, value) {
|
|
1131
|
-
const forwarded =
|
|
1133
|
+
const [forwarded, ...alternates] = forwardedHostRoots(node, name);
|
|
1134
|
+
for (const alternate of alternates) {
|
|
1135
|
+
if (alternate === node)
|
|
1136
|
+
continue;
|
|
1137
|
+
reflectAttribute(alternate, name, value);
|
|
1138
|
+
if (!applyForwardedStyle(alternate, name, value))
|
|
1139
|
+
this.setAttribute(alternate, name, value);
|
|
1140
|
+
}
|
|
1132
1141
|
reflectAttribute(node, name, value);
|
|
1133
1142
|
if (forwarded) {
|
|
1134
1143
|
if (forwarded !== node)
|
|
@@ -1197,7 +1206,14 @@ export function createNativeHost(options) {
|
|
|
1197
1206
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: patch } });
|
|
1198
1207
|
},
|
|
1199
1208
|
removeAttribute(node, name) {
|
|
1200
|
-
const forwarded =
|
|
1209
|
+
const [forwarded, ...alternates] = forwardedHostRoots(node, name);
|
|
1210
|
+
for (const alternate of alternates) {
|
|
1211
|
+
if (alternate === node)
|
|
1212
|
+
continue;
|
|
1213
|
+
reflectAttribute(alternate, name, void 0, !0);
|
|
1214
|
+
if (!applyForwardedStyle(alternate, name, void 0))
|
|
1215
|
+
this.removeAttribute(alternate, name);
|
|
1216
|
+
}
|
|
1201
1217
|
reflectAttribute(node, name, void 0, !0);
|
|
1202
1218
|
if (forwarded) {
|
|
1203
1219
|
reflectAttribute(forwarded, name, void 0, !0);
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{xo,tn,Yl,rm}from"./chunk-67j2m620.js";import{vo,ra,em,tm,nm}from"./chunk-p3hbsrk9.js";import{Gl,Xl,Jl,Zg,Qg}from"./chunk-rf0smj4c.js";import{nt,Hn,sa}from"./chunk-sh7a0g09.js";import{sm,om,im,am,So,Wy}from"./chunk-ksmn19qw.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-
|
|
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-x691tnkx.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">
|