@stacksjs/stx 0.2.744 → 0.2.746
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/builtins/icon.d.ts +35 -1
- package/dist/builtins/icon.js +39 -8
- package/dist/{chunk-mene2hv8.js → chunk-0nhb2nwp.js} +1 -1
- package/dist/{chunk-pgmkefnc.js → chunk-149yxrcj.js} +3 -3
- package/dist/{chunk-q4d49yg7.js → chunk-19ayktjy.js} +1 -1
- package/dist/{chunk-49x0spek.js → chunk-1v4w7ppq.js} +1 -1
- package/dist/{chunk-chss7tcr.js → chunk-1wke0qfq.js} +2 -2
- package/dist/{chunk-7q630cz3.js → chunk-1xen7nkk.js} +1 -1
- package/dist/{chunk-swf1qs3z.js → chunk-2g9eaq6p.js} +1 -1
- package/dist/{chunk-g0tfh66t.js → chunk-4rr35v4y.js} +4 -4
- package/dist/{chunk-806jkdzv.js → chunk-57tpkrm5.js} +1 -1
- package/dist/{chunk-ptrme33w.js → chunk-5nqhfdj6.js} +1 -1
- package/dist/{chunk-hatn4c85.js → chunk-5spasxv7.js} +1 -1
- package/dist/chunk-6662t3bx.js +2 -0
- package/dist/{chunk-mzchr2vt.js → chunk-6mnebk49.js} +1 -1
- package/dist/chunk-79ch0r9x.js +2 -0
- package/dist/chunk-7vy02dt0.js +2 -0
- package/dist/{chunk-q53eg32x.js → chunk-7w7f14jq.js} +1 -1
- package/dist/{chunk-rm8nt1gr.js → chunk-8f14cgm8.js} +1 -1
- package/dist/{chunk-kq90gp4a.js → chunk-8fcne6ar.js} +1 -1
- package/dist/{chunk-g89gmt74.js → chunk-8zapr6yt.js} +1 -1
- package/dist/chunk-91pa4mt8.js +2 -0
- package/dist/{chunk-809kkqny.js → chunk-9p99v0vr.js} +2 -2
- package/dist/{chunk-n05sgshg.js → chunk-a46h84sz.js} +1 -1
- package/dist/{chunk-1rpntw1k.js → chunk-a6p51fpw.js} +1 -1
- package/dist/{chunk-qav71tr8.js → chunk-a7py2qd2.js} +6 -6
- package/dist/{chunk-ktxa9vx8.js → chunk-bgt7bwm0.js} +1 -1
- package/dist/{chunk-220pc67r.js → chunk-bj0z4gve.js} +1 -1
- package/dist/{chunk-0v9deafv.js → chunk-c8v5c5mz.js} +1 -1
- package/dist/{chunk-9r8ff53d.js → chunk-dxgvah9p.js} +3 -3
- package/dist/{chunk-eys9qtvt.js → chunk-dxsdr77m.js} +1 -1
- package/dist/{chunk-h6cxq0hn.js → chunk-dz2hn14j.js} +1 -1
- package/dist/{chunk-b1ft4znp.js → chunk-e7ke3rpn.js} +1 -1
- package/dist/{chunk-mwwnt27k.js → chunk-ed67z92f.js} +1 -1
- package/dist/chunk-eqbg3aj0.js +2 -0
- package/dist/{chunk-qxw5hr6e.js → chunk-evphmzyh.js} +1 -1
- package/dist/{chunk-wc23g6b4.js → chunk-evsbb3rc.js} +1 -1
- package/dist/{chunk-3zzgcvfc.js → chunk-f4y3h74q.js} +8 -8
- package/dist/{chunk-3ff1zbgf.js → chunk-f6gqf6v3.js} +2 -2
- package/dist/{chunk-e6527scq.js → chunk-fb6af3vk.js} +1 -1
- package/dist/chunk-gmp889v9.js +3 -0
- package/dist/chunk-h3gk6j59.js +2 -0
- package/dist/{chunk-493wjn21.js → chunk-hfryhf26.js} +1 -1
- package/dist/chunk-hqfd6mmq.js +2 -0
- package/dist/chunk-hrd0qhj0.js +2 -0
- package/dist/chunk-j5dzthxj.js +2 -0
- package/dist/{chunk-v3hxq6k0.js → chunk-kkmayabs.js} +5 -5
- package/dist/chunk-m2b0nwgp.js +2 -0
- package/dist/{chunk-pc8cb5q8.js → chunk-m7jq3907.js} +1 -1
- package/dist/{chunk-s52ny7da.js → chunk-mhn18833.js} +1 -1
- package/dist/{chunk-bq974x5d.js → chunk-n8txdhez.js} +1 -1
- package/dist/chunk-q1wk9j3s.js +2 -0
- package/dist/{chunk-qr0hy556.js → chunk-qx04cejf.js} +1 -1
- package/dist/{chunk-9d4anhh8.js → chunk-rfa9rz3g.js} +6 -6
- package/dist/{chunk-7fnkqpkh.js → chunk-s8gc1h8e.js} +1 -1
- package/dist/chunk-t0myqe0n.js +2 -0
- package/dist/{chunk-54t61ech.js → chunk-t7nw25st.js} +2 -2
- package/dist/chunk-vtjtz685.js +2 -0
- package/dist/{chunk-6m6p1pvr.js → chunk-wds7pewp.js} +1 -1
- package/dist/{chunk-shf75rrg.js → chunk-wpwh529h.js} +26 -26
- package/dist/{chunk-kjva91by.js → chunk-wwd61ewe.js} +1 -1
- package/dist/{chunk-jb39s79f.js → chunk-xc907jck.js} +1 -1
- package/dist/chunk-xgfetnnc.js +2 -0
- package/dist/{chunk-vc5kdzvy.js → chunk-xzsvx81w.js} +4 -4
- package/dist/{chunk-4j0brfek.js → chunk-y8ws4501.js} +1 -1
- package/dist/{chunk-mzryggpk.js → chunk-ygs7ersb.js} +1 -1
- package/dist/chunk-yjdp76hr.js +2 -0
- package/dist/{chunk-87n3hr89.js → chunk-ykjx8zf0.js} +1 -1
- package/dist/{chunk-0rfgcsv1.js → chunk-yvbqhm47.js} +1 -1
- package/dist/chunk-z7g92wak.js +2 -0
- package/dist/{chunk-h26wgsbx.js → chunk-zswnmzsd.js} +2 -2
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/safe-evaluator.js +13 -2
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-0pv0vtx4.js +0 -2
- package/dist/chunk-1j5sjqh6.js +0 -2
- package/dist/chunk-2f8ttc6h.js +0 -2
- package/dist/chunk-3sw3ekqc.js +0 -2
- package/dist/chunk-3sz24efq.js +0 -2
- package/dist/chunk-8dydc6f0.js +0 -2
- package/dist/chunk-c58rqhyz.js +0 -2
- package/dist/chunk-h3dr2826.js +0 -2
- package/dist/chunk-k5j1q8we.js +0 -2
- package/dist/chunk-m1n3jxkd.js +0 -2
- package/dist/chunk-nee03ys0.js +0 -3
- package/dist/chunk-q53kc812.js +0 -2
- package/dist/chunk-qzfxasdd.js +0 -2
- package/dist/chunk-stmtvwry.js +0 -2
- package/dist/chunk-wh8rhad0.js +0 -2
- package/dist/chunk-xkpa06r2.js +0 -2
- package/dist/chunk-xsmj68pc.js +0 -2
package/dist/builtins/icon.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ export declare function resolveCollectionPath(prefix: string): string | null;
|
|
|
22
22
|
* miss is the right trade-off for correct SSR output.
|
|
23
23
|
*/
|
|
24
24
|
declare function loadCollectionSync(prefix: string): IconCollection | null;
|
|
25
|
+
/**
|
|
26
|
+
* Find an icon by the name a template wrote, following aliases.
|
|
27
|
+
*
|
|
28
|
+
* The size comes from the icon when it states one and from the collection's
|
|
29
|
+
* default otherwise, which is the order Iconify itself resolves in.
|
|
30
|
+
*/
|
|
31
|
+
export declare function lookupIcon(collection: IconCollection, name: string): ResolvedIcon | null;
|
|
25
32
|
/**
|
|
26
33
|
* Resolve a prop value from any binding category.
|
|
27
34
|
*/
|
|
@@ -40,4 +47,31 @@ export declare function preloadIconCollection(prefix?: string, options?: { specu
|
|
|
40
47
|
// Cache loaded icon collections to avoid re-reading JSON files
|
|
41
48
|
declare const collectionCache: Map<string, IconCollection>;
|
|
42
49
|
export declare const IconBuiltin: BuiltinComponentDef;
|
|
43
|
-
declare
|
|
50
|
+
declare interface IconEntry { body: string, width?: number, height?: number }
|
|
51
|
+
/**
|
|
52
|
+
* An Iconify alias: a second name for an icon, optionally flipped or rotated.
|
|
53
|
+
* Collections rename icons this way rather than deleting the old name, so an
|
|
54
|
+
* alias is a perfectly ordinary thing for a template to ask for.
|
|
55
|
+
*/
|
|
56
|
+
declare interface IconAlias { parent: string, hFlip?: boolean, vFlip?: boolean, rotate?: number }
|
|
57
|
+
/**
|
|
58
|
+
* A collection as its `icons.json` is actually shaped.
|
|
59
|
+
*
|
|
60
|
+
* Only `icons` used to be kept, which threw away the other two things the file
|
|
61
|
+
* says. `aliases` is how a collection records a rename — lucide has 220 of
|
|
62
|
+
* them, `trash-2` among them — and dropping it meant those names resolved to
|
|
63
|
+
* nothing: an HTML comment where the glyph should be, so the button was still
|
|
64
|
+
* there and still clickable and simply invisible. The top-level `width` and
|
|
65
|
+
* `height` are the collection's own default size, which most icons rely on
|
|
66
|
+
* rather than repeating per icon; assuming 24 instead draws, say, Framework7's
|
|
67
|
+
* 56-unit artwork into a 24-unit viewBox, cropping every one of its icons to
|
|
68
|
+
* roughly its top-left corner.
|
|
69
|
+
*/
|
|
70
|
+
declare interface IconCollection {
|
|
71
|
+
icons: Record<string, IconEntry>
|
|
72
|
+
aliases?: Record<string, IconAlias>
|
|
73
|
+
width?: number
|
|
74
|
+
height?: number
|
|
75
|
+
}
|
|
76
|
+
/** An icon ready to draw: body, and the viewBox it is drawn in. */
|
|
77
|
+
declare interface ResolvedIcon { body: string, width: number, height: number }
|
package/dist/builtins/icon.js
CHANGED
|
@@ -36,8 +36,8 @@ function loadCollectionSync(prefix) {
|
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
38
|
const data = JSON.parse(readFileSync(jsonPath, "utf8"));
|
|
39
|
-
collectionCache.set(prefix, data
|
|
40
|
-
return data
|
|
39
|
+
collectionCache.set(prefix, data);
|
|
40
|
+
return data;
|
|
41
41
|
} catch {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
@@ -53,12 +53,43 @@ async function loadCollection(prefix, speculative = !1) {
|
|
|
53
53
|
}
|
|
54
54
|
try {
|
|
55
55
|
const data = await Bun.file(jsonPath).json();
|
|
56
|
-
collectionCache.set(prefix, data
|
|
57
|
-
return data
|
|
56
|
+
collectionCache.set(prefix, data);
|
|
57
|
+
return data;
|
|
58
58
|
} catch {
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
function applyTransform(body, flip, width, height) {
|
|
63
|
+
const parts = [];
|
|
64
|
+
if (flip.rotate)
|
|
65
|
+
parts.push(`rotate(${flip.rotate * 90} ${width / 2} ${height / 2})`);
|
|
66
|
+
if (flip.hFlip)
|
|
67
|
+
parts.push(`translate(${width} 0) scale(-1 1)`);
|
|
68
|
+
if (flip.vFlip)
|
|
69
|
+
parts.push(`translate(0 ${height}) scale(1 -1)`);
|
|
70
|
+
return parts.length ? `<g transform="${parts.join(" ")}">${body}</g>` : body;
|
|
71
|
+
}
|
|
72
|
+
export function lookupIcon(collection, name) {
|
|
73
|
+
let current = name, entry = collection.icons[current];
|
|
74
|
+
const flip = { hFlip: !1, vFlip: !1, rotate: 0 };
|
|
75
|
+
for (let hop = 0;!entry && hop < 8; hop++) {
|
|
76
|
+
const alias = collection.aliases?.[current];
|
|
77
|
+
if (!alias)
|
|
78
|
+
return null;
|
|
79
|
+
if (alias.hFlip)
|
|
80
|
+
flip.hFlip = !flip.hFlip;
|
|
81
|
+
if (alias.vFlip)
|
|
82
|
+
flip.vFlip = !flip.vFlip;
|
|
83
|
+
if (alias.rotate)
|
|
84
|
+
flip.rotate = ((flip.rotate + alias.rotate) % 4 + 4) % 4;
|
|
85
|
+
current = alias.parent;
|
|
86
|
+
entry = collection.icons[current];
|
|
87
|
+
}
|
|
88
|
+
if (!entry)
|
|
89
|
+
return null;
|
|
90
|
+
const width = entry.width ?? collection.width ?? 24, height = entry.height ?? collection.height ?? 24;
|
|
91
|
+
return { body: applyTransform(entry.body, flip, width, height), width, height };
|
|
92
|
+
}
|
|
62
93
|
function resolveProp(props, key) {
|
|
63
94
|
if (props.serverDynamic[key] !== void 0)
|
|
64
95
|
return String(props.serverDynamic[key]);
|
|
@@ -81,13 +112,13 @@ export const IconBuiltin = {
|
|
|
81
112
|
collection = parts[0];
|
|
82
113
|
iconName = parts[1];
|
|
83
114
|
}
|
|
84
|
-
const size = escapeAttr(resolveProp(props, "size") || "24"), color = escapeAttr(resolveProp(props, "color") || "currentColor"), className = escapeAttr(resolveProp(props, "class") || ""), style = escapeAttr(resolveProp(props, "style") || ""),
|
|
85
|
-
if (!
|
|
115
|
+
const size = escapeAttr(resolveProp(props, "size") || "24"), color = escapeAttr(resolveProp(props, "color") || "currentColor"), className = escapeAttr(resolveProp(props, "class") || ""), style = escapeAttr(resolveProp(props, "style") || ""), data = collectionCache.get(collection) ?? loadCollectionSync(collection);
|
|
116
|
+
if (!data)
|
|
86
117
|
return `<!-- Icon: collection "${collection}" not loaded -->`;
|
|
87
|
-
const iconData =
|
|
118
|
+
const iconData = lookupIcon(data, iconName);
|
|
88
119
|
if (!iconData)
|
|
89
120
|
return `<!-- Icon: "${iconName}" not found in ${collection} -->`;
|
|
90
|
-
const
|
|
121
|
+
const viewBox = `0 0 ${iconData.width} ${iconData.height}`;
|
|
91
122
|
let body = iconData.body;
|
|
92
123
|
if (color !== "currentColor")
|
|
93
124
|
body = body.replace(/currentColor/g, color);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,h,p}from"./chunk-
|
|
2
|
+
import{m,h,p}from"./chunk-rfa9rz3g.js";import{j}from"./chunk-t7nw25st.js";import{i}from"./chunk-a7py2qd2.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Jg(e,t={},o={}){let n={...j,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(d.name,i(d.content,y,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|