@stacksjs/stx 0.2.440 → 0.2.441

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.
@@ -0,0 +1,33 @@
1
+ // @bun
2
+ import{rr,Ps,To}from"./chunk-1yj3p63h.js";import"./chunk-axydabse.js";import{Ln,n}from"./chunk-a9necy79.js";import"./chunk-b9wpgn7b.js";import"./chunk-ptjqacjd.js";import"./chunk-5ahb6arz.js";import"./chunk-721yq8qx.js";import"./chunk-8x47zcfa.js";import"./chunk-pxqs3psa.js";import"./chunk-my3jkpv7.js";import"./chunk-t7x753ga.js";import"./chunk-114zdbnd.js";import{Pe}from"./chunk-5zahqrb4.js";import"./chunk-8wkja2z2.js";import{existsSync as j,mkdirSync as ut,readFileSync as ft}from"fs";import y from"path";import{existsSync as st,mkdirSync as at}from"fs";import v from"path";import{existsSync as nt}from"fs";import C from"path";var he="data-stx-b",M=new Set(Ps),be=new Set(rr);function xe(t){if(t==="ref"||t==="data-stx-ref")return"ref";if(t.startsWith("::"))return null;if(t.startsWith("@bind:")||t.startsWith("x-bind:"))return"attr";if(t.startsWith("@")||t.startsWith(":")){let e=t.slice(1).split(".")[0];if(M.has(e))return e==="if"?"if":e;if(e==="for"||e==="else"||e==="else-if"||e==="elseif")return"for";if(To(e))return"event";if(t.startsWith("@"))return"event";return"attr"}if(t.startsWith("x-")){let e=t.split(".")[0];if(!be.has(e))return"attr";let r=e.slice(2);if(r==="cloak"||r==="data"||r==="bind")return null;if(r==="tooltip"||r==="tooltip-position")return null;return M.has(r)?r==="if"?"if":r:"attr"}return null}function Se(t){let e=[];for(let[r,i]of t){let o=xe(r);if(o)e.push({name:r,value:i,kind:o})}return e}var we=/<([a-z][\w-]*)((?:\s+[^\s"'=<>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*\/?>/gi,L=/([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function H(t){let e=[],r=0;return{html:t.replace(we,(o,s,a)=>{if(!a||!/[:@]|x-/.test(a))return o;let l=[];L.lastIndex=0;for(let f=L.exec(a);f;f=L.exec(a))l.push([f[1],f[2]??f[3]??f[4]??""]);let d=Se(l);if(!d.length)return o;let p={id:r++,bindings:d};if(d.some((f)=>f.kind==="for"))p.template=!0;e.push(p);let c=o.endsWith("/>");return`${o.slice(0,c?-2:-1).trimEnd()} ${he}="${p.id}"${c?"/>":">"}`}),manifest:{entries:e}}}var ye=["accessibilityHint","accessibilityLabel","accessibilityRole","accessibilityState","accessibilityValue","activeOpacity","alwaysBounceHorizontal","alwaysBounceVertical","animationType","autoCapitalize","autoCorrect","autoFocus","blurRadius","contentContainerStyle","defaultSource","defaultValue","ellipsizeMode","fadeDuration","hidesWhenStopped","hitSlop","imageStyle","initialNumToRender","iosBackgroundColor","keyboardDismissMode","keyboardShouldPersistTaps","keyboardType","keyboardVerticalOffset","keyExtractor","maxLength","maximumTrackTintColor","maximumValue","maxToRenderPerBatch","minimumTrackTintColor","minimumValue","numberOfLines","numColumns","onEndReachedThreshold","pagingEnabled","placeholderTextColor","pointerEvents","presentationStyle","pressRetentionOffset","progressBackgroundColor","progressViewOffset","refreshControl","resizeMode","returnKeyType","scrollEnabled","scrollTarget","secureTextEntry","selectedValue","selectionColor","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","statusBarTranslucent","stickyHeaderIndices","testID","thumbColor","thumbTintColor","titleColor","trackColor","underlayColor","windowSize"],Te=new Map(ye.map((t)=>[G(t),t]));function G(t){return t.replace(/[-_]/g,"").toLowerCase()}function D(t){return Te.get(G(t))??t}var ve={view:"View",text:"Text",button:"Button",image:"Image",img:"Image",input:"TextInput",textarea:"TextInput",scroll:"ScrollView",scrollview:"ScrollView",list:"FlatList",flatlist:"FlatList",modal:"Modal",switch:"Switch",slider:"Slider",picker:"Picker",select:"Picker",loading:"ActivityIndicator",spinner:"ActivityIndicator",div:"View",span:"Text",p:"Text",h1:"Text",h2:"Text",h3:"Text",h4:"Text",h5:"Text",h6:"Text",a:"TouchableOpacity",section:"View",article:"View",header:"SafeAreaView",footer:"View",main:"View",nav:"View",aside:"View",form:"View",label:"Text",fieldset:"View",legend:"Text",option:"Text",dialog:"Modal",figure:"View",figcaption:"Text",picture:"View",hr:"View",ul:"View",ol:"View",li:"View",dl:"View",dt:"Text",dd:"Text",table:"View",thead:"View",tbody:"View",tfoot:"View",tr:"View",th:"Text",td:"Text",caption:"Text",strong:"Text",b:"Text",em:"Text",i:"Text",u:"Text",s:"Text",small:"Text",mark:"Text",abbr:"Text",time:"Text",code:"Text",kbd:"Text",samp:"Text",pre:"Text",blockquote:"Text",cite:"Text",q:"Text",sub:"Text",sup:"Text"};function q(t){return ve[t.toLowerCase()]||t}var ke={activity:"waveform.path.ecg","alarm-clock":"alarm","alert-circle":"exclamationmark.circle","alert-triangle":"exclamationmark.triangle",archive:"archivebox","arrow-down":"arrow.down","arrow-left":"arrow.left","arrow-right":"arrow.right","arrow-up":"arrow.up","arrow-up-right":"arrow.up.right","at-sign":"at","audio-lines":"waveform",award:"rosette","badge-check":"checkmark.seal","bar-chart":"chart.bar","bar-chart-2":"chart.bar","bar-chart-3":"chart.bar",battery:"battery.100",bed:"bed.double",bell:"bell","bell-off":"bell.slash",bike:"figure.outdoor.cycle",bluetooth:"antenna.radiowaves.left.and.right",book:"book","book-open":"book",bookmark:"bookmark",brain:"brain",calendar:"calendar","calendar-check":"calendar.badge.checkmark","calendar-clock":"calendar.badge.clock","calendar-days":"calendar","calendar-plus":"calendar.badge.plus","calendar-range":"calendar","calendar-sync":"arrow.triangle.2.circlepath",camera:"camera","chart-bar":"chart.bar","chart-line":"chart.xyaxis.line",check:"checkmark","check-circle":"checkmark.circle","check-circle-2":"checkmark.circle","chevron-down":"chevron.down","chevron-left":"chevron.left","chevron-right":"chevron.right","chevron-up":"chevron.up",circle:"circle","circle-alert":"exclamationmark.circle","circle-check":"checkmark.circle","circle-check-big":"checkmark.circle","circle-help":"questionmark.circle","circle-play":"play.circle","circle-plus":"plus.circle","circle-user":"person.crop.circle","circle-x":"xmark.circle",clapperboard:"film",clipboard:"clipboard","clipboard-list":"list.clipboard",clock:"clock",cloud:"cloud","cloud-off":"icloud.slash",coffee:"cup.and.saucer",copy:"doc.on.doc","credit-card":"creditcard",download:"arrow.down.circle",droplet:"drop",droplets:"drop",dumbbell:"dumbbell",edit:"pencil","external-link":"arrow.up.right.square",eye:"eye","eye-off":"eye.slash",file:"doc","file-text":"doc.text",filter:"line.3.horizontal.decrease",flag:"flag",flame:"flame",footprints:"figure.run",gauge:"gauge",gift:"gift",globe:"globe","graduation-cap":"graduationcap","grip-vertical":"line.3.horizontal",heart:"heart","heart-pulse":"heart.text.square","help-circle":"questionmark.circle",history:"clock.arrow.circlepath",home:"house",house:"house",image:"photo",inbox:"tray",info:"info.circle",layers:"square.3.layers.3d","layout-grid":"square.grid.2x2",library:"books.vertical",link:"link",list:"list.bullet","list-checks":"checklist",loader:"arrow.triangle.2.circlepath","loader-2":"arrow.triangle.2.circlepath","loader-circle":"arrow.triangle.2.circlepath",lock:"lock","log-in":"arrow.right.to.line","log-out":"rectangle.portrait.and.arrow.right",mail:"envelope",map:"map","map-pin":"mappin.and.ellipse",medal:"medal",menu:"line.3.horizontal","message-circle":"bubble.left","message-square":"text.bubble","message-square-quote":"quote.bubble",mic:"mic",minus:"minus",moon:"moon","more-horizontal":"ellipsis","more-vertical":"ellipsis",mountain:"mountain.2",music:"music.note",package:"shippingbox",pause:"pause","pause-circle":"pause.circle",pencil:"pencil","person-standing":"figure.walk",phone:"phone",play:"play.fill",plug:"powerplug",plus:"plus","plus-circle":"plus.circle","refresh-cw":"arrow.clockwise",repeat:"repeat","rotate-ccw":"arrow.counterclockwise",route:"point.topleft.down.to.point.bottomright.curvepath",ruler:"ruler",sailboat:"sailboat",satellite:"antenna.radiowaves.left.and.right",save:"square.and.arrow.down",scale:"scalemass",search:"magnifyingglass",send:"paperplane",settings:"gearshape","settings-2":"slider.horizontal.3",share:"square.and.arrow.up","share-2":"square.and.arrow.up",shield:"shield","shield-check":"checkmark.shield","shopping-bag":"bag","shopping-cart":"cart","skip-back":"backward.end","skip-forward":"forward.end",sliders:"slider.horizontal.3","sliders-horizontal":"slider.horizontal.3",smartphone:"iphone",snowflake:"snowflake",sparkles:"sparkles",square:"square",star:"star",stopwatch:"stopwatch",store:"storefront",sun:"sun.max",sunrise:"sunrise",sunset:"sunset",tag:"tag",target:"scope",thermometer:"thermometer.medium","thumbs-up":"hand.thumbsup",timer:"timer",trash:"trash","trash-2":"trash","trending-down":"chart.line.downtrend.xyaxis","trending-up":"chart.line.uptrend.xyaxis",trophy:"trophy",unlink:"personalhotspot.slash",upload:"arrow.up.circle",user:"person","user-plus":"person.badge.plus","user-round":"person",users:"person.2",video:"video","volume-2":"speaker.wave.2",watch:"applewatch",waves:"figure.pool.swim",weight:"scalemass",wifi:"wifi","wifi-off":"wifi.slash",wind:"wind",x:"xmark","x-circle":"xmark.circle",zap:"bolt"};function U(t,e=!1){let r=String(t??"").trim();if(!r)return{symbol:"circle",known:!1};if(e)return{symbol:r,known:!0};let i=/^i-([a-z0-9]+)-(.+)$/.exec(r)??/^([a-z0-9]+):(.+)$/.exec(r),o=i?i[1]:"lucide",s=i?i[2]:r;if(o==="lucide"){let a=ke[s];if(a)return{symbol:a,iconify:`i-lucide-${s}`,known:!0};if(!i&&r.includes("."))return{symbol:r,known:!0}}return{symbol:"circle",iconify:i?r:`i-lucide-${s}`,known:!1}}var Re={transparent:"transparent",current:"currentColor",black:"#000000",white:"#ffffff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},K={px:1,0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},J={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48,"6xl":60,"7xl":72,"8xl":96,"9xl":128},w={none:0,sm:2,DEFAULT:4,md:6,lg:8,xl:12,"2xl":16,"3xl":24,full:9999};function N(t){let e=t.lastIndexOf("/");if(e>0&&!t.endsWith("]")){let i=N(t.slice(0,e)),o=t.slice(e+1),s=/^\[(.+)\]$/.test(o)?Number.parseFloat(o.slice(1,-1))*(o.includes("%")?1:100):Number.parseFloat(o);if(!i||!Number.isFinite(s))return;return _e(i,s/100)}if(t==="transparent")return"transparent";if(t==="current")return"currentColor";if(t==="black")return"#000000";if(t==="white")return"#ffffff";let r=t.split("-");if(r.length===2){let[i,o]=r,s=Re[i];if(s&&typeof s==="object")return s[o]}if(t.startsWith("[")&&t.endsWith("]")){let i=t.slice(1,-1);return/^(#|rgba?\(|hsla?\(|[a-z]+$)/i.test(i)?i:void 0}return}function _e(t,e){if(t==="transparent")return t;let r=t.startsWith("#")?t.slice(1):"";if(r.length===3)r=r.split("").map((o)=>o+o).join("");if(r.length===8)r=r.slice(0,6);if(r.length!==6)return;let i=Math.round(Math.min(1,Math.max(0,e))*255);return`#${r}${i.toString(16).padStart(2,"0")}`}function O(t,e=16){if(!t.startsWith("[")||!t.endsWith("]"))return;let r=t.slice(1,-1),i=Number.parseFloat(r);if(!Number.isFinite(i))return;if(r.endsWith("rem"))return i*16;if(r.endsWith("em"))return i*e;return i}function m(t){if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1),r=e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e);return Number.isFinite(r)?r:void 0}return K[t]}var Ce={flex:(t,e)=>(e.display="flex",!0),hidden:(t,e)=>(e.display="none",!0),grid:(t,e)=>(e.display="grid",!0),"flex-row":(t,e)=>(e.flexDirection="row",!0),"flex-col":(t,e)=>(e.flexDirection="column",!0),"flex-row-reverse":(t,e)=>(e.flexDirection="row-reverse",!0),"flex-col-reverse":(t,e)=>(e.flexDirection="column-reverse",!0),"flex-wrap":(t,e)=>(e.flexWrap="wrap",!0),"flex-nowrap":(t,e)=>(e.flexWrap="nowrap",!0),"flex-wrap-reverse":(t,e)=>(e.flexWrap="wrap-reverse",!0),"flex-1":(t,e)=>(e.flex=1,e.flexGrow=1,e.flexShrink=1,e.flexBasis=0,!0),"flex-auto":(t,e)=>(e.flexGrow=1,e.flexShrink=1,!0),"flex-initial":(t,e)=>(e.flexGrow=0,e.flexShrink=1,!0),"flex-none":(t,e)=>(e.flexGrow=0,e.flexShrink=0,!0),grow:(t,e)=>(e.flexGrow=1,!0),"grow-0":(t,e)=>(e.flexGrow=0,!0),shrink:(t,e)=>(e.flexShrink=1,!0),"shrink-0":(t,e)=>(e.flexShrink=0,!0),"justify-start":(t,e)=>(e.justifyContent="flex-start",!0),"justify-center":(t,e)=>(e.justifyContent="center",!0),"justify-end":(t,e)=>(e.justifyContent="flex-end",!0),"justify-between":(t,e)=>(e.justifyContent="space-between",!0),"justify-around":(t,e)=>(e.justifyContent="space-around",!0),"justify-evenly":(t,e)=>(e.justifyContent="space-evenly",!0),"items-start":(t,e)=>(e.alignItems="flex-start",!0),"items-center":(t,e)=>(e.alignItems="center",!0),"items-end":(t,e)=>(e.alignItems="flex-end",!0),"items-stretch":(t,e)=>(e.alignItems="stretch",!0),"items-baseline":(t,e)=>(e.alignItems="baseline",!0),"self-auto":(t,e)=>(e.alignSelf="auto",!0),"self-start":(t,e)=>(e.alignSelf="flex-start",!0),"self-center":(t,e)=>(e.alignSelf="center",!0),"self-end":(t,e)=>(e.alignSelf="flex-end",!0),"self-stretch":(t,e)=>(e.alignSelf="stretch",!0),"self-baseline":(t,e)=>(e.alignSelf="baseline",!0),"min-w-0":(t,e)=>(e.minWidth=0,!0),"aspect-square":(t,e)=>(e.aspectRatio=1,!0),"inset-0":(t,e)=>(e.top=0,e.right=0,e.bottom=0,e.left=0,!0),"tracking-tighter":(t,e)=>(e.letterSpacing=-0.8,!0),"tracking-tight":(t,e)=>(e.letterSpacing=-0.4,!0),"tracking-normal":(t,e)=>(e.letterSpacing=0,!0),"tracking-wide":(t,e)=>(e.letterSpacing=0.4,!0),"tracking-wider":(t,e)=>(e.letterSpacing=0.8,!0),"tracking-widest":(t,e)=>(e.letterSpacing=1.6,!0),"tabular-nums":()=>!0,block:()=>!0,"inline-flex":(t,e)=>(e.display="flex",!0),truncate:()=>!0,relative:(t,e)=>(e.position="relative",!0),absolute:(t,e)=>(e.position="absolute",!0),"overflow-visible":(t,e)=>(e.overflow="visible",!0),"overflow-hidden":(t,e)=>(e.overflow="hidden",!0),"overflow-scroll":(t,e)=>(e.overflow="scroll",!0),"font-thin":(t,e)=>(e.fontWeight="100",!0),"font-extralight":(t,e)=>(e.fontWeight="200",!0),"font-light":(t,e)=>(e.fontWeight="300",!0),"font-normal":(t,e)=>(e.fontWeight="400",!0),"font-medium":(t,e)=>(e.fontWeight="500",!0),"font-semibold":(t,e)=>(e.fontWeight="600",!0),"font-bold":(t,e)=>(e.fontWeight="bold",!0),"font-extrabold":(t,e)=>(e.fontWeight="800",!0),"font-black":(t,e)=>(e.fontWeight="900",!0),italic:(t,e)=>(e.fontStyle="italic",!0),"not-italic":(t,e)=>(e.fontStyle="normal",!0),"text-left":(t,e)=>(e.textAlign="left",!0),"text-center":(t,e)=>(e.textAlign="center",!0),"text-right":(t,e)=>(e.textAlign="right",!0),"text-justify":(t,e)=>(e.textAlign="justify",!0),uppercase:(t,e)=>(e.textTransform="uppercase",!0),lowercase:(t,e)=>(e.textTransform="lowercase",!0),capitalize:(t,e)=>(e.textTransform="capitalize",!0),"normal-case":(t,e)=>(e.textTransform="none",!0),underline:(t,e)=>(e.textDecorationLine="underline",!0),"line-through":(t,e)=>(e.textDecorationLine="line-through",!0),"no-underline":(t,e)=>(e.textDecorationLine="none",!0)};function Ne(t,e){if(!t.startsWith("bg-"))return!1;let r=t.slice(3),i=N(r);if(i)return e.backgroundColor=i,!0;return!1}function We(t,e){if(!t.startsWith("text-"))return!1;let r=t.slice(5);if(J[r])return e.fontSize=J[r],!0;if(r.startsWith("[")&&r.endsWith("]")){let o=r.slice(1,-1);if(/^-?[\d.]+(?:px|r?em)?$/.test(o)){let s=o.endsWith("rem")||o.endsWith("em")?Number.parseFloat(o)*16:Number.parseFloat(o);if(Number.isFinite(s))return e.fontSize=s,!0}}let i=N(r);if(i)return e.color=i,!0;return!1}function Be(t,e){if(t.startsWith("p-")){let r=m(t.slice(2));if(r!==void 0)return e.padding=r,!0}if(t.startsWith("px-")){let r=m(t.slice(3));if(r!==void 0)return e.paddingHorizontal=r,!0}if(t.startsWith("py-")){let r=m(t.slice(3));if(r!==void 0)return e.paddingVertical=r,!0}if(t.startsWith("pt-")){let r=m(t.slice(3));if(r!==void 0)return e.paddingTop=r,!0}if(t.startsWith("pr-")){let r=m(t.slice(3));if(r!==void 0)return e.paddingRight=r,!0}if(t.startsWith("pb-")){let r=m(t.slice(3));if(r!==void 0)return e.paddingBottom=r,!0}if(t.startsWith("pl-")){let r=m(t.slice(3));if(r!==void 0)return e.paddingLeft=r,!0}return!1}function Ee(t,e){if(t.startsWith("m-")){let r=m(t.slice(2));if(r!==void 0)return e.margin=r,!0}if(t.startsWith("mx-")){let r=m(t.slice(3));if(r!==void 0)return e.marginHorizontal=r,!0}if(t.startsWith("my-")){let r=m(t.slice(3));if(r!==void 0)return e.marginVertical=r,!0}if(t.startsWith("mt-")){let r=m(t.slice(3));if(r!==void 0)return e.marginTop=r,!0}if(t.startsWith("mr-")){let r=m(t.slice(3));if(r!==void 0)return e.marginRight=r,!0}if(t.startsWith("mb-")){let r=m(t.slice(3));if(r!==void 0)return e.marginBottom=r,!0}if(t.startsWith("ml-")){let r=m(t.slice(3));if(r!==void 0)return e.marginLeft=r,!0}return!1}function Ie(t,e){if(!t.startsWith("w-"))return!1;let r=t.slice(2);if(r==="full")return e.width="100%",!0;if(r==="screen")return e.width="100%",!0;if(r==="auto")return e.width="auto",!0;if(r.includes("/")){let[o,s]=r.split("/"),a=Number.parseInt(o)/Number.parseInt(s)*100;return e.width=`${a}%`,!0}let i=m(r);if(i!==void 0)return e.width=i,!0;return!1}function Xe(t,e){if(!t.startsWith("h-"))return!1;let r=t.slice(2);if(r==="full")return e.height="100%",!0;if(r==="screen")return e.height="100%",!0;if(r==="auto")return e.height="auto",!0;let i=m(r);if(i!==void 0)return e.height=i,!0;return!1}function Le(t,e){if(!t.startsWith("rounded"))return!1;if(t==="rounded")return e.borderRadius=w.DEFAULT,!0;let r=t.slice(8);if(r==="")return!1;let i=/^(?:(t|b|l|r)-)?(\[[^\]]+\])$/.exec(r);if(i){let s=O(i[2]);if(s===void 0)return!1;let a={t:["borderTopLeftRadius","borderTopRightRadius"],b:["borderBottomLeftRadius","borderBottomRightRadius"],l:["borderTopLeftRadius","borderBottomLeftRadius"],r:["borderTopRightRadius","borderBottomRightRadius"]};for(let l of i[1]?a[i[1]]:["borderRadius"])e[l]=s;return!0}if(r.startsWith("t-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopLeftRadius=s,e.borderTopRightRadius=s,!0}if(r.startsWith("b-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderBottomLeftRadius=s,e.borderBottomRightRadius=s,!0}if(r.startsWith("l-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopLeftRadius=s,e.borderBottomLeftRadius=s,!0}if(r.startsWith("r-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopRightRadius=s,e.borderBottomRightRadius=s,!0}let o=w[r];if(o!==void 0)return e.borderRadius=o,!0;return!1}function De(t,e){if(!t.startsWith("border"))return!1;if(t==="border")return e.borderWidth=1,!0;let r=t.match(/^border-(\d+)$/);if(r)return e.borderWidth=Number.parseInt(r[1]),!0;let i=t.match(/^border-(t|r|b|l)-?(\d*)$/);if(i){let[,o,s]=i,a=s?Number.parseInt(s):1;switch(o){case"t":e.borderTopWidth=a;break;case"r":e.borderRightWidth=a;break;case"b":e.borderBottomWidth=a;break;case"l":e.borderLeftWidth=a;break}return!0}return!1}function Oe(t,e){if(!t.startsWith("border-"))return!1;let r=t.slice(7),i=N(r);if(i)return e.borderColor=i,!0;return!1}function ze(t,e){if(!t.startsWith("opacity-"))return!1;let r=Number.parseInt(t.slice(8));if(!Number.isNaN(r))return e.opacity=r/100,!0;return!1}function $e(t,e){if(t.startsWith("tracking-[")){let r=O(t.slice(9),typeof e.fontSize==="number"?e.fontSize:16);if(r===void 0)return!1;return e.letterSpacing=r,!0}if(t.startsWith("leading-")){let r=t.slice(8),i=typeof e.fontSize==="number"?e.fontSize:16,o={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},s=r.startsWith("[")?/^\[[\d.]+\]$/.test(r)?Number.parseFloat(r.slice(1,-1))*i:O(r,i):o[r]!==void 0?o[r]*i:K[r];if(s===void 0||!Number.isFinite(s))return!1;return e.lineHeight=s,!0}return!1}function Ae(t,e){let r=/^grid-cols-(\d+)$/.exec(t);if(!r)return!1;return e.gridColumns=Number(r[1]),!0}function Ve(t,e){if(!t.startsWith("size-"))return!1;let r=t.slice(5),i=r==="full"?"100%":m(r);if(i===void 0)return!1;return e.width=i,e.height=i,!0}function Fe(t,e){let r=/^(-?)(top|right|bottom|left)-(.+)$/.exec(t);if(!r)return!1;let i=r[3]==="full"?"100%":m(r[3]);if(i===void 0)return!1;return e[r[2]]=typeof i==="number"&&r[1]?-i:i,!0}function je(t,e){let r=/^space-(x|y)-(.+)$/.exec(t);if(!r)return!1;let i=m(r[2]);if(i===void 0)return!1;return e.gap=i,!0}function Me(t,e){if(t.startsWith("gap-")){let r=m(t.slice(4));if(r!==void 0)return e.gap=r,!0}if(t.startsWith("gap-x-")){let r=m(t.slice(6));if(r!==void 0)return e.columnGap=r,!0}if(t.startsWith("gap-y-")){let r=m(t.slice(6));if(r!==void 0)return e.rowGap=r,!0}return!1}function z(t){let e=[],r=[];for(let a of t.split(/\s+/).filter(Boolean))if(a.startsWith("dark:"))r.push(a.slice(5));else if(!a.includes(":")||a.startsWith("["))e.push(a);let i=[],s={style:Y(e.join(" "),i),unknown:i};if(r.length)s.dark=Y(r.join(" "),i);for(let a of e){if(a==="truncate")s.numberOfLines=1;let l=/^line-clamp-(\d+)$/.exec(a);if(l)s.numberOfLines=Number(l[1]);if(!s.icon&&/^i-[a-z0-9]+-[a-z0-9-]+$/.test(a))s.icon=a}return s.unknown=i.filter((a)=>!/^line-clamp-\d+$/.test(a)),s}function Y(t,e){let r={},i=t.split(/\s+/).filter(Boolean);for(let o of i){if(/^i-[a-z0-9]+-/.test(o))continue;let s=Ce[o];if(s){s("",r);continue}if(Ne(o,r))continue;if(We(o,r))continue;if(Be(o,r))continue;if(Ee(o,r))continue;if(Ie(o,r))continue;if(Xe(o,r))continue;if(Le(o,r))continue;if(De(o,r))continue;if(Oe(o,r))continue;if(ze(o,r))continue;if(Me(o,r))continue;if($e(o,r))continue;if(Ve(o,r))continue;if(Ae(o,r))continue;if(Fe(o,r))continue;if(je(o,r))continue;if(e?.push(o),typeof process<"u"&&process.env?.NODE_ENV==="development")console.warn(`[STX Native] Unknown Headwind class: ${o}`)}return r}function W(t,e={},r={},i={},o=[]){return{type:t,props:e,style:r,events:i,children:o}}function Z(t,e,r={}){return{version:"1.0.0",root:t,script:e,meta:{source:r.source||"unknown",compiledAt:r.compiledAt||Date.now(),headwindConfig:r.headwindConfig}}}var Q=new Set(["script","style","head","meta","link","title","base","noscript","svg"]),ee=new Set(["template","body","html","main","fragment"]),B=new Set(["svg"]),He={click:"onPress",press:"onPress",longpress:"onLongPress",contextmenu:"onLongPress",input:"onChangeText",change:"onValueChange",focus:"onFocus",focusin:"onFocus",blur:"onBlur",focusout:"onBlur",submit:"onSubmitEditing",scroll:"onScroll",refresh:"onRefresh",close:"onRequestClose"},Ge=new Set(["onBlur","onChangeText","onEndReached","onFocus","onLayout","onLongPress","onPress","onRequestClose","onRefresh","onScroll","onValueChange"]),A=new Set(["display","flex","flexGrow","flexShrink","flexBasis","flexDirection","flexWrap","justifyContent","alignItems","alignSelf","alignContent","position","top","right","bottom","left","zIndex","width","height","minWidth","maxWidth","minHeight","maxHeight","aspectRatio","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderStyle","backgroundColor","backgroundImage","opacity","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","color","fontSize","fontWeight","fontStyle","fontFamily","lineHeight","letterSpacing","textAlign","textDecorationLine","textDecorationColor","textTransform","resizeMode","tintColor","transform","overflow"]),qe=new Set(["flex","flexGrow","flexShrink","zIndex","aspectRatio","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","opacity","shadowOpacity","shadowRadius","elevation","fontSize","lineHeight","letterSpacing"]),Ue=new Set(["top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical"]),te=new Set(["View","ScrollView","SafeAreaView","KeyboardAvoidingView","Text","TextInput","Button","TouchableOpacity","TouchableHighlight","Pressable","Icon","Image","ImageBackground","FlatList","SectionList","Switch","Slider","Picker","DatePicker","Modal","ActivityIndicator","StatusBar","RefreshControl"]),re=new Set(["View","SafeAreaView","ScrollView","KeyboardAvoidingView"]),Je={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ","#39":"'","#x27":"'"};function _(t){return t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,r)=>{let i=Je[r.toLowerCase()];if(i!==void 0)return i;if(r[0]==="#"){let o=r[1]==="x"||r[1]==="X"?Number.parseInt(r.slice(2),16):Number.parseInt(r.slice(1),10);return Number.isFinite(o)?String.fromCodePoint(o):e}return e})}function ne(t){return t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}function ie(t){let e=/^(-?[\d.]+)px$/.exec(t);if(e)return Number.parseFloat(e[1]);let r=/^(-?[\d.]+)r?em$/.exec(t);if(r)return Number.parseFloat(r[1])*16;if(/^-?[\d.]+$/.test(t))return Number.parseFloat(t);return t}function Ye(t,e,r){let i={},o={},s={},a="",l={};for(let[p,c]of e){let u=p.toLowerCase();if(u==="class"||u==="classname"){a=a?`${a} ${c}`:c;continue}if(u==="style"){l={...l,...Ke(t,c,r)};continue}if(u.startsWith(":")||u.startsWith("x-")&&u!=="x-cloak"){s[u.startsWith(":")?u.slice(1):u.slice(2)]=_(c);continue}if(u==="x-cloak")continue;if(u.startsWith("@")||u.startsWith("v-on:")){let b=u.startsWith("@")?u.slice(1):u.slice(5),[g]=b.split("."),x=He[g]??(g.startsWith("on")?g:"");if(!x||!Ge.has(x)){r.push({kind:"unread-event",tag:t,name:p});continue}o[x]=_(c);continue}if(u==="key"){i.key=c;continue}let f=_(c);try{i[D(p)]=JSON.parse(f)}catch{i[D(p)]=f}}let d={...a?z(a).style:{},...l};return{props:i,style:d,events:o,bindings:s,classes:a,inline:l}}function oe(t,e){if(qe.has(t))return!1;if(Ue.has(t))return/^-?[\d.]+%$/.test(e);return!0}function Ke(t,e,r){let i={},o=_(e);try{let s=JSON.parse(o);if(s&&typeof s==="object"&&!Array.isArray(s)){for(let[a,l]of Object.entries(s)){let d=A.has(a)?a:ne(a.trim().toLowerCase());if(!A.has(d)){r.push({kind:"unknown-style",tag:t,name:d});continue}if(l===null||l===void 0)continue;let p=typeof l==="string"?ie(l):l;if(typeof p!=="string"&&typeof p!=="number")continue;if(typeof p==="string"&&!oe(d,p)){r.push({kind:"non-numeric-style",tag:t,name:d});continue}i[d]=p}return i}}catch{}for(let s of o.split(";")){let a=s.indexOf(":");if(a===-1)continue;let l=ne(s.slice(0,a).trim().toLowerCase()),d=s.slice(a+1).trim();if(!l||!d)continue;if(!A.has(l)){r.push({kind:"unknown-style",tag:t,name:l});continue}let p=ie(d);if(typeof p==="string"&&!oe(l,p)){r.push({kind:"non-numeric-style",tag:t,name:l});continue}i[l]=p}return i}function se(t){return t.children.map((e)=>typeof e==="string"?e:se(e)).join("").replace(/\s+/g," ").trim()}function Ze(t,e){let r=t.node,i=r.children.filter((s)=>typeof s!=="string"),o=r.children.filter((s)=>typeof s==="string").join("").trim();if(re.has(r.type)&&i.length===0&&o)return r.type="Text",r.children=[o],r;if(r.type==="Text"&&i.length>0){let s=se(r);return e.push({kind:"flattened-text",tag:t.tag}),r.children=s?[s]:[],r}if(re.has(r.type)&&i.length>0)r.children=i;return r}async function Qe(t,e={}){let r=[],i=[],o=[],s=new Set;function a(c){let u=o[o.length-1];if(!u)i.push(c);else if(!u.dropped)u.node.children.push(c)}function l(c){if(c.node.bindings&&Object.keys(c.node.bindings).length>0){let f=c.node.children,b=f.filter((x)=>typeof x!=="string"),g=b.length===1&&b.length===f.length?b[0]:W("View",{},{},{},f);if(g.bindings={...c.node.bindings,...g.bindings},g.bindingId===void 0&&c.node.bindingId!==void 0)g.bindingId=c.node.bindingId;a(g);return}let u=o[o.length-1];for(let f of c.node.children){if(typeof f==="string"){if(u&&!u.dropped)u.node.children.push(f);continue}if(!u)i.push(f);else if(!u.dropped)u.node.children.push(f)}}function d(c,u){let f=Q.has(c)&&!B.has(c),b=o[o.length-1]?.dropped??!1,{props:g,style:x,events:h,bindings:S,classes:T,inline:ge}=f||b?{props:{},style:{},events:{},bindings:{},classes:"",inline:{}}:Ye(c,u,r),I=g["data-native"],k;if(typeof I==="string"&&te.has(I))k=I,delete g["data-native"];else k=B.has(c)?"View":q(c);if(k===c&&!te.has(k)&&!Q.has(c)&&!ee.has(c)&&!s.has(c))s.add(c),r.push({kind:"unmapped-tag",tag:c});if((f||B.has(c))&&!s.has(`drop:${c}`))s.add(`drop:${c}`),r.push({kind:"dropped-subtree",tag:c});if(k==="Icon"){let me=z(T).icon;g.symbol=U(String(g.symbol||g.name||me||""),Boolean(g.symbol)).symbol}let R=W(k,g,x,h);R._inlineStyle=ge;let X=g["data-stx-b"];if(typeof X==="number"&&Number.isInteger(X))R.bindingId=X;if(delete g["data-stx-b"],T)R._classes=T;if(Object.keys(S).length>0)R.bindings=S;if(typeof g.key==="string")R.key=g.key,delete g.key;return{tag:c,node:R,dropped:f||b||B.has(c),discard:f||b,unwrap:ee.has(c)}}if(await new HTMLRewriter().on("*",{element(c){let u=c.tagName.toLowerCase(),f=d(u,[...c.attributes]),b=!0;try{c.onEndTag(()=>{if(o.pop(),f.discard)return;if(f.unwrap)l(f);else a(Ze(f,r))})}catch{b=!1}if(b)o.push(f);else if(!f.discard)a(f.node)},text(c){let u=o[o.length-1];if(!u||u.dropped)return;let f=_(c.text).replace(/\s+/g," ");if(!f.trim())return;u.node.children.push(f)}}).transform(new Response(t)).text(),i.length===0)throw Error(`No element to translate in the rendered output of ${e.source??"unknown"}`);return{root:i.length===1?i[0]:W("View",{},{},{},i),diagnostics:r}}async function ae(t,e={}){let{root:r,diagnostics:i}=await Qe(t,e),o=e.script??{exports:{},functions:[],code:""};return{document:Z(r,o,{source:e.source??"unknown"}),diagnostics:i}}var ce=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,et=/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([$\w]+)\s*\(/g,tt=/(?:^|\n)\s*(?:export\s+)?(?:const|let|var)\s+([$\w]+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[$\w]+)\s*=>/g,le=/(?:^|\n)\s*(?:export\s+)?const\s+([$\w]+)\s*=\s*(-?[\d.]+|true|false|'[^']*'|"[^"]*")\s*(?=;|\n|$)/g;function V(t){let e=[];ce.lastIndex=0;for(let s of t.matchAll(ce)){let a=s[1]??"";if(/\bserver\b/.test(a))continue;e.push(s[2].trim())}let r=e.filter(Boolean).join(`
3
+
4
+ `),i=[];for(let s of[et,tt]){s.lastIndex=0;for(let a of r.matchAll(s))if(!i.includes(a[1]))i.push(a[1])}let o={};le.lastIndex=0;for(let s of r.matchAll(le)){let a=s[2];try{o[s[1]]=JSON.parse(a.replace(/^'(.*)'$/,'"$1"'))}catch{o[s[1]]=a}}return{exports:o,functions:i,code:r}}var ue=/<script\b[^>]*\bdata-stx-scoped\b[^>]*>([\s\S]*?)<\/script>/gi,rt=/function\s+(__stx_setup_[\w$]+)\s*\(/;function P(t){ue.lastIndex=0;for(let e of t.matchAll(ue)){let r=e[1].trim(),i=rt.exec(r)?.[1];if(i)return{name:i,code:r}}return null}function it(){let t=[C.join(import.meta.dir,"..","primitives"),C.join(import.meta.dir,"native","primitives")];for(let e of t)if(nt(C.join(e,"View.stx")))return e;return t[0]}async function ot(t,e,r={}){let i=r.root??C.dirname(e),o={root:i,componentsDir:r.componentsDir??C.join(i,"components"),buildMode:"serve",cache:!1,_pluginComponentDirs:[it()]},s={...r.context??{},__stx_inject_css:!1},a=await n(t,s,e,o,new Set),{html:l,manifest:d}=H(a),{document:p,diagnostics:c}=await ae(l,{source:e,script:V(t)}),u=P(l);if(V(t).code.trim()){let f=await Ln(t,e,r.context,{forceClientSetup:!0});u=P(f.setupCode??"")??u}return{document:p,manifest:d,setup:u,diagnostics:c,html:l}}async function E(t,e={}){return ot(await Bun.file(t).text(),t,e)}function fe(t){let r=[v.join(import.meta.dir,"..","runtime",`${t}.ts`),v.join(import.meta.dir,"..","runtime",`${t}.js`),v.join(import.meta.dir,"native","runtime",`${t}.js`)].find((i)=>st(i));if(!r)throw Error(`Native runtime module ${t} is missing`);return r}async function ct(t,e,r){let i=await Bun.build({entrypoints:[t],target:"browser",format:"iife",minify:r,plugins:e,define:{"process.env.NODE_ENV":JSON.stringify(r?"production":"development")}});if(!i.success){let o=i.logs.map((s)=>String(s.message??s)).join(`
5
+ `);throw Error(`Could not bundle ${t}:
6
+ ${o}`)}return(await i.outputs[0].text()).trim()}async function F(t){let e=Object.keys(t.screens);if(e.length===0)throw Error("screens must name at least one .stx file");let r=t.routed??!0,i=t.initialScreen??e[0];if(!t.screens[i])throw Error(`Initial screen ${i} is not in screens`);let o=v.resolve(t.root??process.cwd()),s=[];for(let h of e){let S=v.resolve(o,t.screens[h]);if(!S.endsWith(".stx"))throw Error(`Screen ${h} must name a .stx file`);s.push({name:h,file:S,compiled:await E(S,{root:o})})}let a=fe("jsc-globals"),l=fe("shared-screen"),d=r?`var routeName = g.__stxNativeRoute || ${JSON.stringify(i)};
7
+ if (routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));`:"var routeName = 'main';",p=s.map(({name:h,compiled:S},T)=>`${T===0?"if":"else if"} (routeName === ${JSON.stringify(r?h:"main")}) {
8
+ nativeDocument = ${JSON.stringify(S.document)};
9
+ manifest = ${JSON.stringify(S.manifest)};
10
+ }`).join(`
11
+ `),c=s.map(({name:h,compiled:S},T)=>`${T===0?"if":"else if"} (routeName === ${JSON.stringify(r?h:"main")}) {
12
+ ${S.setup?.code??"g.__stx_latestSetup = null;"}
13
+ }`).join(`
14
+ `),u=`
15
+ import { installJSCGlobals } from ${JSON.stringify(a)};
16
+ import { prepareSharedNativeScreen } from ${JSON.stringify(l)};
17
+ var g = globalThis;
18
+ installJSCGlobals(g);
19
+ var bridge = g.__stxNativeBridge;
20
+ if (!bridge) throw new Error('Missing __stxNativeBridge');
21
+ var routeNames = ${JSON.stringify(r?e:["main"])};
22
+ ${d}
23
+ g.__stxNativeRoute = routeName;
24
+ var nativeDocument;
25
+ var manifest;
26
+ ${p}
27
+ var screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
28
+ g.__stx_host = screen.host;
29
+ g.__stxNativeUnmount = function() { screen.unmount(); };
30
+ ${Pe()}
31
+ ${c}
32
+ screen.mount(g.stx, g.__stx_latestSetup || null);
33
+ `,b=await ct("stx:native-shared-screens",[{name:"stx-native-shared-screens",setup(h){h.onResolve({filter:/^stx:native-shared-screens$/},()=>({path:"entry",namespace:"stx-native-shared-screens"})),h.onLoad({filter:/.*/,namespace:"stx-native-shared-screens"},()=>({contents:u,loader:"js"}))}}],t.minify??!1),g=s.flatMap(({compiled:h})=>h.diagnostics).map((h)=>({level:"warning",message:[h.kind,h.tag,h.name].filter(Boolean).join(": ")}));if(!t.outFile)return{code:b,diagnostics:g};let x=v.resolve(o,t.outFile);return at(v.dirname(x),{recursive:!0}),await Bun.write(x,b),{code:b,outFile:x,diagnostics:g}}async function lt(t,e={}){return F({...e,screens:{main:t},routed:!1})}function de(t,e={}){return lt(t,e)}var pe=["native.config.json","stx-native.config.json"];function dt(t=process.cwd(),e){let r=e?y.resolve(t,e):pe.map((l)=>y.join(t,l)).find((l)=>j(l));if(!r)return null;if(!j(r))throw Error(`Native config not found: ${r}`);let i=JSON.parse(ft(r,"utf8")),o=Object.entries(i.screens??{});if(o.length===0)throw Error(`${y.basename(r)} must name at least one screen in "screens"`);let s={};for(let[l,d]of o){if(!/^[A-Z][\w-]*$/i.test(l))throw Error(`Invalid native screen name: ${l}`);if(typeof d!=="string"||!d.endsWith(".stx"))throw Error(`Screen ${l} must name a .stx file`);if(s[l]=y.resolve(y.dirname(r),d),!j(s[l]))throw Error(`Screen ${l} not found: ${s[l]}`)}let a=i.initialScreen||o[0][0];if(!s[a])throw Error(`Initial screen ${a} is not in screens`);return{initialScreen:a,screens:s,file:r}}async function Gt(t,e={}){let r=y.resolve(e.cwd??process.cwd()),i=e.format??"ir";if(i!=="ir"&&i!=="bundle")throw Error(`Unknown compile format: ${i}. Expected ir or bundle.`);let o=t?null:dt(r,e.config);if(!t&&!o)throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${pe[0]}`);let s,a=[];if(i==="bundle"){let d=o?await F({screens:o.screens,initialScreen:o.initialScreen,minify:e.minify,root:r}):await de(y.resolve(r,t),{minify:e.minify});s=d.code,a=d.diagnostics}else{let d=async(c)=>{let u=await E(c);return a.push(...u.diagnostics.map((f)=>({level:"warning",message:[f.kind,f.tag,f.name].filter(Boolean).join(": ")}))),u.document},p=o?{initialScreen:o.initialScreen,screens:Object.fromEntries(await Promise.all(Object.entries(o.screens).map(async([c,u])=>[c,await d(u)])))}:await d(y.resolve(r,t));s=JSON.stringify(p,null,2)}if(!e.output)return{output:s,diagnostics:a};let l=y.resolve(r,e.output);return ut(y.dirname(l),{recursive:!0}),await Bun.write(l,s),{output:s,written:l,diagnostics:a}}export{Gt as runNativeCompile};
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import"./chunk-b9wpgn7b.js";import"./chunk-8x47zcfa.js";import"./chunk-pxqs3psa.js";import"./chunk-1yj3p63h.js";import"./chunk-axydabse.js";import{U}from"./chunk-a9necy79.js";import"./chunk-721yq8qx.js";import"./chunk-my3jkpv7.js";import"./chunk-ptjqacjd.js";import"./chunk-5ahb6arz.js";import"./chunk-114zdbnd.js";import"./chunk-t7x753ga.js";import"./chunk-nvht5259.js";import"./chunk-thx147nq.js";import"./chunk-24e7qjb8.js";import"./chunk-s28eh0jn.js";import"./chunk-b8dbq51z.js";import"./chunk-9w5nse46.js";import"./chunk-7a0ffmer.js";import"./chunk-zfzcedw4.js";import"./chunk-zpnz1k3b.js";import"./chunk-5zahqrb4.js";import"./chunk-spx27cs4.js";import"./chunk-j1q65enz.js";import"./chunk-44zjqsh9.js";import"./chunk-5vwg3h5g.js";import"./chunk-36kkc60p.js";import"./chunk-3hmy75tw.js";import"./chunk-tprtjzzc.js";import"./chunk-mtb5000n.js";import"./chunk-yhxazetv.js";import"./chunk-w2085fwx.js";import"./chunk-4xemkkm8.js";import"./chunk-bjnvymb7.js";import{ft,gt}from"./chunk-771hf74z.js";import"./chunk-xfv7evmd.js";import"./chunk-3akpy7er.js";import"./chunk-p4wvc7wx.js";import"./chunk-4wf68rht.js";import"./chunk-hc9242wm.js";import"./chunk-dtvwes4f.js";import"./chunk-3rbz496d.js";import"./chunk-tnbgy59s.js";import"./chunk-w040f2er.js";import{Fs,zs,Hs,Vs,dr,Us,Ws,qs,pr,fr,yn,bn,wn}from"./chunk-4gmdfym5.js";import"./chunk-5ty8h14h.js";import"./chunk-ccq35xp7.js";import{lo}from"./chunk-8wkja2z2.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import M from"os";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.440";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(p<1024||p>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),i=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:i}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(p){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(p<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(p>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),H=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,p=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(p)}function L(h){if(!h)return;let p;try{p=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof p!=="object"||p===null||Array.isArray(p))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(p))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return p}async function G(h,p){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let r=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(r.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...r),p.verbose)console.log(`Found ${r.length} file(s) matching pattern: ${c}`)}catch(r){return console.error(`Error expanding glob pattern ${c}:`,r),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),p.filter)x.push("--pattern",p.filter);if(p.timeout)x.push("--timeout",p.timeout.toString());if(p.reporter&&p.reporter!=="default")if(p.reporter==="junit"){let c=f.join(M.tmpdir(),`stx-test-report-${Date.now()}.xml`);x.push("--reporter",p.reporter),x.push("--reporter-outfile",c)}else console.warn(`Warning: Reporter '${p.reporter}' is not supported. Using default reporter.`);if(p.coverage)x.push("--coverage");if(p.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:p.ui?"true":"false",STX_TEST_VERBOSE:p.verbose?"true":"false"},o="bun";if(p.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let i=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(r)=>{let d=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
3
+ import"./chunk-b9wpgn7b.js";import"./chunk-8x47zcfa.js";import"./chunk-pxqs3psa.js";import"./chunk-1yj3p63h.js";import"./chunk-axydabse.js";import{U}from"./chunk-a9necy79.js";import"./chunk-721yq8qx.js";import"./chunk-my3jkpv7.js";import"./chunk-ptjqacjd.js";import"./chunk-5ahb6arz.js";import"./chunk-114zdbnd.js";import"./chunk-t7x753ga.js";import"./chunk-nvht5259.js";import"./chunk-thx147nq.js";import"./chunk-24e7qjb8.js";import"./chunk-s28eh0jn.js";import"./chunk-b8dbq51z.js";import"./chunk-9w5nse46.js";import"./chunk-7a0ffmer.js";import"./chunk-zfzcedw4.js";import"./chunk-zpnz1k3b.js";import"./chunk-5zahqrb4.js";import"./chunk-spx27cs4.js";import"./chunk-j1q65enz.js";import"./chunk-44zjqsh9.js";import"./chunk-5vwg3h5g.js";import"./chunk-36kkc60p.js";import"./chunk-3hmy75tw.js";import"./chunk-tprtjzzc.js";import"./chunk-mtb5000n.js";import"./chunk-yhxazetv.js";import"./chunk-w2085fwx.js";import"./chunk-4xemkkm8.js";import"./chunk-bjnvymb7.js";import{ft,gt}from"./chunk-771hf74z.js";import"./chunk-xfv7evmd.js";import"./chunk-3akpy7er.js";import"./chunk-p4wvc7wx.js";import"./chunk-4wf68rht.js";import"./chunk-hc9242wm.js";import"./chunk-dtvwes4f.js";import"./chunk-3rbz496d.js";import"./chunk-tnbgy59s.js";import"./chunk-w040f2er.js";import{Fs,zs,Hs,Vs,dr,Us,Ws,qs,pr,fr,yn,bn,wn}from"./chunk-4gmdfym5.js";import"./chunk-5ty8h14h.js";import"./chunk-ccq35xp7.js";import{lo}from"./chunk-8wkja2z2.js";import{u}from"./chunk-cg8hg6cs.js";import{spawn as R}from"child_process";import S from"fs";import M from"os";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.441";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(p<1024||p>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),i=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:i}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(p){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(p<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(p>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),H=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,p=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(p)}function L(h){if(!h)return;let p;try{p=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof p!=="object"||p===null||Array.isArray(p))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(p))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return p}async function G(h,p){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let r=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(r.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...r),p.verbose)console.log(`Found ${r.length} file(s) matching pattern: ${c}`)}catch(r){return console.error(`Error expanding glob pattern ${c}:`,r),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),p.filter)x.push("--pattern",p.filter);if(p.timeout)x.push("--timeout",p.timeout.toString());if(p.reporter&&p.reporter!=="default")if(p.reporter==="junit"){let c=f.join(M.tmpdir(),`stx-test-report-${Date.now()}.xml`);x.push("--reporter",p.reporter),x.push("--reporter-outfile",c)}else console.warn(`Warning: Reporter '${p.reporter}' is not supported. Using default reporter.`);if(p.coverage)x.push("--coverage");if(p.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:p.ui?"true":"false",STX_TEST_VERBOSE:p.verbose?"true":"false"},o="bun";if(p.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let i=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(r)=>{let d=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
4
4
  Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var J=n.argv.length>=3&&(H(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(J){let h=n.argv[2],p={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=B(n.argv[++x]);if(!e.isValid)F(e);p.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")p.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")p.cache=!1;else if(t==="--native")p.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),r=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of r)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await bn(t,p))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else yn(h,p).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let i=0;i<=e.length;i++)o[i]=[i];for(let i=0;i<=t.length;i++)o[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=t.length;s++)if(e.charAt(i-1)===t.charAt(s-1))o[i][s]=o[i-1][s-1];else o[i][s]=Math.min(o[i-1][s-1]+1,o[i][s-1]+1,o[i-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await Vs(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:i}=await import("./chunk-t61vdbje.js");if(t==="list"){console.log(`
5
5
  \uD83D\uDCDA Fetching available icon collections...
6
6
  `);let s=await o(),c=Object.entries(s).sort((r,l)=>l[1].total-r[1].total);console.log(`Available collections:
@@ -164,7 +164,7 @@ Press Ctrl+C to stop watching...
164
164
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
165
165
  `);let a=await o({input:c,output:f.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?f.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:L(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
166
166
  \uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
167
- \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-nq7z26y6.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-vzek2z1v.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-j9aberz0.js"),{runVisualTests:o,updateSnapshots:i,formatTestResults:s}=await import("./chunk-93e1nf1y.js"),c=await e({mode:"build"});if(t.update){let r=await i(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${r} snapshots`)}else{let r=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(r)),r.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:i}=await import("./chunk-rnth7r2v.js"),s=await i(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(i){console.error(i instanceof Error?i.message:String(i)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-fg8kmyz8.js"),i=f.resolve(t);if(!S.existsSync(i))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
167
+ \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-nq7z26y6.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-vzek2z1v.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-j9aberz0.js"),{runVisualTests:o,updateSnapshots:i,formatTestResults:s}=await import("./chunk-93e1nf1y.js"),c=await e({mode:"build"});if(t.update){let r=await i(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${r} snapshots`)}else{let r=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(r)),r.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:i}=await import("./chunk-zg79w3gk.js"),s=await i(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(i){console.error(i instanceof Error?i.message:String(i)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-fg8kmyz8.js"),i=f.resolve(t);if(!S.existsSync(i))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
168
168
  \uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
169
169
  `);let r=S.readFileSync(i,"utf-8"),l=await o(r,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),m=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",g=f.join(d,`${a}.${m}`);S.writeFileSync(g,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.join(d,`${a}.${m}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=f.join(d,`${a}.${w}.${m}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${g}`),console.log(` Manifest: ${b}`),console.log(`
170
170
  \uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
@@ -1,6 +1,7 @@
1
1
  import { nativePropName } from "../prop-names.js";
2
2
  import { mapToNativeComponent } from "./component-mapping.js";
3
- import { compileHeadwindToStyle } from "./headwind-to-style.js";
3
+ import { resolveIconName } from "./icons.js";
4
+ import { compileClassStyles } from "./headwind-to-style.js";
4
5
  import { createDocument, createNode } from "./ir.js";
5
6
  const DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title", "base", "noscript", "svg"]), UNWRAP = new Set(["template", "body", "html", "main", "fragment"]), BOX_ONLY = new Set(["svg"]), EVENT_NAMES = {
6
7
  click: "onPress",
@@ -175,6 +176,7 @@ const STYLE_KEYS = new Set([
175
176
  "TouchableOpacity",
176
177
  "TouchableHighlight",
177
178
  "Pressable",
179
+ "Icon",
178
180
  "Image",
179
181
  "ImageBackground",
180
182
  "FlatList",
@@ -262,8 +264,8 @@ function readAttributes(tag, attributes, diagnostics) {
262
264
  props[nativePropName(rawName)] = decoded;
263
265
  }
264
266
  }
265
- const style = { ...classes ? compileHeadwindToStyle(classes) : {}, ...inline };
266
- return { props, style, events, bindings, classes };
267
+ const style = { ...classes ? compileClassStyles(classes).style : {}, ...inline };
268
+ return { props, style, events, bindings, classes, inline };
267
269
  }
268
270
  function holdsString(property, value) {
269
271
  if (NUMERIC_STYLE_KEYS.has(property))
@@ -369,7 +371,7 @@ export async function translateHtmlToIR(html, options = {}) {
369
371
  }
370
372
  }
371
373
  function open(tag, attributes) {
372
- const dropped = DROP_SUBTREE.has(tag) && !BOX_ONLY.has(tag), inheritedDrop = stack[stack.length - 1]?.dropped ?? !1, { props, style, events, bindings, classes } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "" } : readAttributes(tag, attributes, diagnostics), declared = props["data-native"];
374
+ const dropped = DROP_SUBTREE.has(tag) && !BOX_ONLY.has(tag), inheritedDrop = stack[stack.length - 1]?.dropped ?? !1, { props, style, events, bindings, classes, inline } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "", inline: {} } : readAttributes(tag, attributes, diagnostics), declared = props["data-native"];
373
375
  let type;
374
376
  if (typeof declared === "string" && NATIVE_TYPES.has(declared)) {
375
377
  type = declared;
@@ -384,7 +386,13 @@ export async function translateHtmlToIR(html, options = {}) {
384
386
  seenUnmapped.add(`drop:${tag}`);
385
387
  diagnostics.push({ kind: "dropped-subtree", tag });
386
388
  }
387
- const node = createNode(type, props, style, events), bindingId = props["data-stx-b"];
389
+ if (type === "Icon") {
390
+ const icon = compileClassStyles(classes).icon;
391
+ props.symbol = resolveIconName(String(props.symbol || props.name || icon || ""), Boolean(props.symbol)).symbol;
392
+ }
393
+ const node = createNode(type, props, style, events);
394
+ node._inlineStyle = inline;
395
+ const bindingId = props["data-stx-b"];
388
396
  if (typeof bindingId === "number" && Number.isInteger(bindingId))
389
397
  node.bindingId = bindingId;
390
398
  delete props["data-stx-b"];
@@ -15,6 +15,7 @@ export declare interface STXNode {
15
15
  directives?: STXDirectives
16
16
  darkStyle?: STXStyle
17
17
  children: (STXNode | string)[]
18
+ _inlineStyle?: STXStyle
18
19
  _classes?: string
19
20
  _source?: {
20
21
  file: string
@@ -190,6 +191,7 @@ export type STXComponentType = | 'View'
190
191
  | 'TouchableHighlight'
191
192
  | 'Pressable'
192
193
  // Media
194
+ | 'Icon'
193
195
  | 'Image'
194
196
  | 'ImageBackground'
195
197
  // Lists
@@ -13,6 +13,7 @@ export declare const ComponentRegistry: {
13
13
  Pressable: 'Pressable';
14
14
  Switch: 'Switch';
15
15
  Slider: 'Slider';
16
+ Icon: 'Icon';
16
17
  Image: 'Image';
17
18
  ImageBackground: 'ImageBackground';
18
19
  FlatList: 'FlatList';
@@ -158,9 +159,12 @@ export declare interface PickerProps extends BaseProps {
158
159
  onValueChange?: (value: string | number, index: number) => void
159
160
  disabled?: boolean
160
161
  }
161
- // ============================================================================
162
- // Media Components
163
- // ============================================================================
162
+ /** Iconify or SF Symbol rendered by the platform's native icon view. */
163
+ export declare interface IconProps extends BaseProps {
164
+ name?: string
165
+ symbol?: string
166
+ color?: string
167
+ }
164
168
  export declare interface ImageProps extends BaseProps {
165
169
  source: ImageSource
166
170
  resizeMode?: 'cover' | 'contain' | 'stretch' | 'center' | 'repeat'
@@ -11,6 +11,7 @@ export const ComponentRegistry = {
11
11
  Pressable: "Pressable",
12
12
  Switch: "Switch",
13
13
  Slider: "Slider",
14
+ Icon: "Icon",
14
15
  Image: "Image",
15
16
  ImageBackground: "ImageBackground",
16
17
  FlatList: "FlatList",
@@ -0,0 +1,7 @@
1
+ {{-- Iconify icons rendered as native symbols, without browser SVG markup. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ const name = $props.name ?? ''
5
+ const symbol = $props.symbol ?? ''
6
+ </script>
7
+ <span data-native="Icon" class="{{ classes }}" name="{{ name }}" symbol="{{ symbol }}" />
@@ -2,11 +2,13 @@ import type { BindingManifest } from '../../binding-manifest';
2
2
  import type { NativeHost, NativeNode } from './native-host';
3
3
  import type { STXDocument } from '../compiler/ir';
4
4
  /** Clone the DOM-shaped metadata while the host clones the native descriptor. */
5
- export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string): NativeBindingNode;
5
+ export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string, onClassChange?: (value: string) => void): NativeBindingNode;
6
6
  /** Build host handles and a manifest-id lookup from already translated IR. */
7
7
  export declare function materializeNativeBindingTree(document: STXDocument, manifest: BindingManifest, host: NativeHost): NativeBindingTree;
8
8
  export declare interface NativeBindingNode extends NativeNode {
9
9
  nodeType: 1
10
+ className: string
11
+ classList: { add: (...tokens: string[]) => void, remove: (...tokens: string[]) => void }
10
12
  tagName: string
11
13
  attributes: Array<{ name: string, value: string }>
12
14
  parentNode: NativeBindingNode | null
@@ -1,13 +1,30 @@
1
1
  function decodeBindingValue(value) {
2
2
  return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#0?39;/g, "'").replace(/&#x27;/gi, "'").replace(/&amp;/g, "&");
3
3
  }
4
- function createBindingNode(id, type, bindings, connected = !0) {
4
+ function createBindingNode(id, type, bindings, connected = !0, classes = "", onClassChange) {
5
5
  const attributes = bindings.map((binding) => ({
6
6
  name: binding.name,
7
7
  value: decodeBindingValue(binding.value)
8
- })), node = {
8
+ }));
9
+ if (classes && !attributes.some((attribute) => attribute.name === "class"))
10
+ attributes.push({ name: "class", value: classes });
11
+ const node = {
9
12
  __stxId: id,
10
13
  nodeType: 1,
14
+ get className() {
15
+ return node.getAttribute("class") ?? "";
16
+ },
17
+ set className(value) {
18
+ node.setAttribute("class", value);
19
+ },
20
+ classList: {
21
+ add(...tokens) {
22
+ node.className = [...new Set([...node.className.split(/\s+/).filter(Boolean), ...tokens])].join(" ");
23
+ },
24
+ remove(...tokens) {
25
+ node.className = node.className.split(/\s+/).filter((token) => token && !tokens.includes(token)).join(" ");
26
+ }
27
+ },
11
28
  tagName: type.toUpperCase(),
12
29
  attributes,
13
30
  parentNode: null,
@@ -30,11 +47,15 @@ function createBindingNode(id, type, bindings, connected = !0) {
30
47
  existing.value = String(value);
31
48
  else
32
49
  attributes.push({ name, value: String(value) });
50
+ if (name === "class")
51
+ onClassChange?.(String(value));
33
52
  },
34
53
  removeAttribute(name) {
35
54
  const index = attributes.findIndex((attribute) => attribute.name === name);
36
55
  if (index !== -1)
37
56
  attributes.splice(index, 1);
57
+ if (name === "class")
58
+ onClassChange?.("");
38
59
  },
39
60
  contains(candidate) {
40
61
  for (let current = candidate;current; current = current.parentNode)
@@ -61,13 +82,13 @@ function createBindingNode(id, type, bindings, connected = !0) {
61
82
  node.isConnected = connected;
62
83
  return node;
63
84
  }
64
- export function cloneNativeBindingNode(source, id) {
85
+ export function cloneNativeBindingNode(source, id, onClassChange) {
65
86
  const bindings = source.attributes.map((attribute) => ({
66
87
  name: attribute.name,
67
88
  value: attribute.value,
68
89
  kind: "attr"
69
90
  }));
70
- return createBindingNode(id, source.tagName, bindings, !1);
91
+ return createBindingNode(id, source.tagName, bindings, !1, source.className, onClassChange);
71
92
  }
72
93
  export function materializeNativeBindingTree(document, manifest, host) {
73
94
  const entries = new Map(manifest.entries.map((entry) => [entry.id, entry])), nodes = new Map;
@@ -77,7 +98,7 @@ export function materializeNativeBindingTree(document, manifest, host) {
77
98
  for (const [name, value] of Object.entries(source.bindings ?? {}))
78
99
  if (!runtimeBindings.some((binding) => binding.name.replace(/^[:@]/, "") === name))
79
100
  runtimeBindings.push({ name: `:${name}`, value, kind: "attr" });
80
- const node = createBindingNode(id, source.type, runtimeBindings);
101
+ const node = createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
81
102
  source.id = id;
82
103
  source.props.__stxId = id;
83
104
  node.parentNode = parent;
@@ -11,10 +11,12 @@ export declare interface NativeNode {
11
11
  __stxAnchor?: string
12
12
  }
13
13
  export declare interface NativeHostOptions {
14
+ colorScheme?: 'light' | 'dark'
14
15
  send: (operations: NativeMutationOperation[]) => void
15
16
  schedule?: (flush: () => void) => void
16
17
  }
17
18
  export declare interface NativeHost {
19
+ setColorScheme: (scheme: 'light' | 'dark') => void
18
20
  setText: (node: NativeNode, value: unknown) => void
19
21
  setAttribute: (node: NativeNode, name: string, value: unknown) => void
20
22
  removeAttribute: (node: NativeNode, name: string) => void
@@ -28,7 +30,7 @@ export declare interface NativeHost {
28
30
  remove: (node: NativeNode) => void
29
31
  descendants: (node: NativeNode) => NativeNode[]
30
32
  scopesIn: (node: NativeNode) => string[]
31
- adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'props' | 'style' | 'events' | 'children'>) => NativeNode
33
+ adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'props' | 'style' | 'events' | 'children' | '_classes' | '_inlineStyle'>) => NativeNode
32
34
  flush: () => void
33
35
  dispatch: (handlerId: string, payload?: unknown) => void
34
36
  pending: () => number
@@ -1,3 +1,5 @@
1
+ import { compileClassStyles } from "../compiler/headwind-to-style.js";
2
+ import { resolveIconName } from "../compiler/icons.js";
1
3
  import { nativePropName } from "../prop-names.js";
2
4
  import { cloneNativeBindingNode } from "./binding-tree.js";
3
5
  export const HOST_METHODS = [
@@ -33,7 +35,7 @@ const NATIVE_EVENT_NAMES = {
33
35
  };
34
36
  export function createNativeHost(options) {
35
37
  const records = new Map, handlers = new Map;
36
- let queue = [], scheduled = !1, counter = 0;
38
+ let queue = [], scheduled = !1, counter = 0, colorScheme = options.colorScheme ?? "light";
37
39
  const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), nextId = (prefix) => `${prefix}${++counter}`;
38
40
  function flush() {
39
41
  scheduled = !1;
@@ -53,7 +55,7 @@ export function createNativeHost(options) {
53
55
  function recordOf(node) {
54
56
  let record = records.get(node.__stxId);
55
57
  if (!record) {
56
- record = { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0, materialized: !0 };
58
+ record = { type: "View", props: {}, style: {}, baseStyle: {}, classes: "", events: {}, children: [], visible: !0, materialized: !0 };
57
59
  records.set(node.__stxId, record);
58
60
  }
59
61
  return record;
@@ -80,6 +82,7 @@ export function createNativeHost(options) {
80
82
  const record = recordOf(node);
81
83
  if (record.materialized || node.__stxAnchor !== void 0)
82
84
  return;
85
+ record.style = resolveStyle(record);
83
86
  record.materialized = !0;
84
87
  emit({
85
88
  op: "createNode",
@@ -99,6 +102,27 @@ export function createNativeHost(options) {
99
102
  emit({ op: "insertChild", parentId: node.__stxId, childId: child.__stxId, index: index++ });
100
103
  }
101
104
  }
105
+ function resolveStyle(record) {
106
+ const classes = compileClassStyles(record.classes);
107
+ return { ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...record.baseStyle };
108
+ }
109
+ function applyClasses(id, record) {
110
+ const style = resolveStyle(record), patch = Object.fromEntries(Object.keys(record.style).filter((key) => !(key in style)).map((key) => [key, null]));
111
+ record.style = style;
112
+ if (record.materialized)
113
+ emit({ op: "updateNode", id, patch: { style: { ...patch, ...style } } });
114
+ const classes = compileClassStyles(record.classes);
115
+ if (record.type === "Icon" && classes.icon) {
116
+ record.props.symbol = resolveIconName(classes.icon).symbol;
117
+ if (record.materialized)
118
+ emit({ op: "updateNode", id, patch: { props: { symbol: record.props.symbol } } });
119
+ }
120
+ if (classes.numberOfLines !== void 0) {
121
+ record.props.numberOfLines = classes.numberOfLines;
122
+ if (record.materialized)
123
+ emit({ op: "updateNode", id, patch: { props: { numberOfLines: classes.numberOfLines } } });
124
+ }
125
+ }
102
126
  function collectDescendants(node) {
103
127
  const out = [], visit = (current) => {
104
128
  const record = records.get(current.__stxId);
@@ -169,16 +193,22 @@ export function createNativeHost(options) {
169
193
  const suffix = /(?:^|\D)(\d+)$/.exec(node.__stxId)?.[1];
170
194
  if (suffix)
171
195
  counter = Math.max(counter, Number(suffix));
172
- records.set(node.__stxId, {
196
+ const classes = descriptor?._classes ?? "", classStyle = compileClassStyles(classes).style, baseStyle = descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
173
197
  type,
174
198
  props: { ...descriptor?.props ?? {} },
175
199
  style: { ...descriptor?.style ?? {} },
200
+ baseStyle,
201
+ classes,
176
202
  events: { ...descriptor?.events ?? {} },
177
203
  text: descriptor?.children?.find((child) => typeof child === "string"),
178
204
  children: [],
179
205
  visible: !0,
180
206
  materialized: !0
181
- });
207
+ };
208
+ record.style = resolveStyle(record);
209
+ if (descriptor)
210
+ descriptor.style = { ...record.style };
211
+ records.set(node.__stxId, record);
182
212
  decoratePosition(node);
183
213
  node.__stxOwner = owner ?? null;
184
214
  if (owner) {
@@ -190,6 +220,13 @@ export function createNativeHost(options) {
190
220
  }
191
221
  return {
192
222
  adopt,
223
+ setColorScheme(scheme) {
224
+ if (scheme === colorScheme)
225
+ return;
226
+ colorScheme = scheme;
227
+ for (const [id, record] of records)
228
+ applyClasses(id, record);
229
+ },
193
230
  pending: () => queue.length,
194
231
  flush,
195
232
  setText(node, value) {
@@ -198,11 +235,23 @@ export function createNativeHost(options) {
198
235
  emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
199
236
  },
200
237
  setAttribute(node, name, value) {
238
+ if (name === "class" || name === "className") {
239
+ const record = recordOf(node);
240
+ record.classes = String(value ?? "");
241
+ applyClasses(node.__stxId, record);
242
+ return;
243
+ }
201
244
  const prop = nativePropName(name);
202
245
  recordOf(node).props[prop] = value;
246
+ if (recordOf(node).type === "Icon" && prop === "name")
247
+ this.setAttribute(node, "symbol", resolveIconName(String(value ?? "")).symbol);
203
248
  emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
204
249
  },
205
250
  removeAttribute(node, name) {
251
+ if (name === "class" || name === "className") {
252
+ this.setAttribute(node, name, "");
253
+ return;
254
+ }
206
255
  const prop = nativePropName(name);
207
256
  delete recordOf(node).props[prop];
208
257
  emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: null } } });
@@ -211,6 +260,7 @@ export function createNativeHost(options) {
211
260
  if (typeof value !== "object" || value === null || Array.isArray(value))
212
261
  return;
213
262
  const style = value;
263
+ Object.assign(recordOf(node).baseStyle, style);
214
264
  Object.assign(recordOf(node).style, style);
215
265
  emit({ op: "updateNode", id: node.__stxId, patch: { style } });
216
266
  },
@@ -235,6 +285,7 @@ export function createNativeHost(options) {
235
285
  setVisible(node, visible) {
236
286
  const record = recordOf(node), was = record.visible;
237
287
  record.visible = visible;
288
+ record.baseStyle.display = visible ? "flex" : "none";
238
289
  emit({ op: "updateNode", id: node.__stxId, patch: { style: { display: visible ? "flex" : "none" } } });
239
290
  return was;
240
291
  },
@@ -244,7 +295,7 @@ export function createNativeHost(options) {
244
295
  return anchor;
245
296
  },
246
297
  clone(node) {
247
- const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id) : { __stxId: id, __stxOwner: node.__stxOwner };
298
+ const source = descriptorOf(node), id = nextId("n"), copy = isBindingNode(node) ? cloneNativeBindingNode(node, id, (value) => this.setAttribute(copy, "class", value)) : { __stxId: id, __stxOwner: node.__stxOwner };
248
299
  decoratePosition(copy);
249
300
  if (node.__stxScope !== void 0)
250
301
  copy.__stxScope = node.__stxScope;
@@ -252,6 +303,8 @@ export function createNativeHost(options) {
252
303
  type: "View",
253
304
  props: {},
254
305
  style: {},
306
+ baseStyle: {},
307
+ classes: "",
255
308
  events: {},
256
309
  children: [],
257
310
  visible: !0,
@@ -261,6 +314,8 @@ export function createNativeHost(options) {
261
314
  type: descriptor.type,
262
315
  props: { ...descriptor.props, __stxId: copy.__stxId },
263
316
  style: { ...descriptor.style },
317
+ baseStyle: { ...descriptor.baseStyle },
318
+ classes: descriptor.classes,
264
319
  events: { ...descriptor.events },
265
320
  text: descriptor.text,
266
321
  children: [],
@@ -8,6 +8,7 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
8
8
  protocol.initialize(bridge);
9
9
  installCraftBridge(protocol, bridge, globalThis, options);
10
10
  const host = createNativeHost({
11
+ colorScheme: bridge.colorScheme === "dark" ? "dark" : "light",
11
12
  send(operations) {
12
13
  const baseRevision = revision;
13
14
  revision++;
@@ -19,7 +20,15 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
19
20
  operations
20
21
  });
21
22
  }
22
- }), tree = materializeNativeBindingTree(document, manifest, host);
23
+ });
24
+ protocol.on("APPEARANCE", (message) => {
25
+ const scheme = message.payload?.colorScheme;
26
+ if (scheme === "light" || scheme === "dark") {
27
+ bridge.colorScheme = scheme;
28
+ host.setColorScheme(scheme);
29
+ }
30
+ });
31
+ const tree = materializeNativeBindingTree(document, manifest, host);
23
32
  let dispose = null;
24
33
  protocol.on("EVENT", (message) => {
25
34
  const handlerId = message.payload?.handlerId ?? message.payload?.handlerName;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.440",
4
+ "version": "0.2.441",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -122,12 +122,12 @@
122
122
  "dependencies": {
123
123
  "@stacksjs/ts-css": "^0.3.2",
124
124
  "@stacksjs/clapp": "^0.2.16",
125
- "@stacksjs/desktop": "0.2.440",
126
- "@stacksjs/sanitizer": "0.2.440",
125
+ "@stacksjs/desktop": "0.2.441",
126
+ "@stacksjs/sanitizer": "0.2.441",
127
127
  "@stacksjs/ts-i18n": "^0.1.11",
128
- "bun-plugin-stx": "0.2.440",
128
+ "bun-plugin-stx": "0.2.441",
129
129
  "bunfig": "^0.15.19",
130
- "stx-router": "0.2.440",
130
+ "stx-router": "0.2.441",
131
131
  "ts-broadcasting": "^0.0.11",
132
132
  "ts-images": "^0.2.22",
133
133
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,33 +0,0 @@
1
- // @bun
2
- import{rr,Ps,To}from"./chunk-1yj3p63h.js";import"./chunk-axydabse.js";import{Ln,n}from"./chunk-a9necy79.js";import"./chunk-b9wpgn7b.js";import"./chunk-ptjqacjd.js";import"./chunk-5ahb6arz.js";import"./chunk-721yq8qx.js";import"./chunk-8x47zcfa.js";import"./chunk-pxqs3psa.js";import"./chunk-my3jkpv7.js";import"./chunk-t7x753ga.js";import"./chunk-114zdbnd.js";import{Pe}from"./chunk-5zahqrb4.js";import"./chunk-8wkja2z2.js";import{existsSync as j,mkdirSync as ot,readFileSync as st}from"fs";import T from"path";import{existsSync as tt,mkdirSync as nt}from"fs";import y from"path";import{existsSync as Ze}from"fs";import C from"path";var de="data-stx-b",F=new Set(Ps),pe=new Set(rr);function ge(t){if(t==="ref"||t==="data-stx-ref")return"ref";if(t.startsWith("::"))return null;if(t.startsWith("@bind:")||t.startsWith("x-bind:"))return"attr";if(t.startsWith("@")||t.startsWith(":")){let e=t.slice(1).split(".")[0];if(F.has(e))return e==="if"?"if":e;if(e==="for"||e==="else"||e==="else-if"||e==="elseif")return"for";if(To(e))return"event";if(t.startsWith("@"))return"event";return"attr"}if(t.startsWith("x-")){let e=t.split(".")[0];if(!pe.has(e))return"attr";let r=e.slice(2);if(r==="cloak"||r==="data"||r==="bind")return null;if(r==="tooltip"||r==="tooltip-position")return null;return F.has(r)?r==="if"?"if":r:"attr"}return null}function me(t){let e=[];for(let[r,i]of t){let o=ge(r);if(o)e.push({name:r,value:i,kind:o})}return e}var he=/<([a-z][\w-]*)((?:\s+[^\s"'=<>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*\/?>/gi,D=/([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function M(t){let e=[],r=0;return{html:t.replace(he,(o,s,c)=>{if(!c||!/[:@]|x-/.test(c))return o;let f=[];D.lastIndex=0;for(let l=D.exec(c);l;l=D.exec(c))f.push([l[1],l[2]??l[3]??l[4]??""]);let d=me(f);if(!d.length)return o;let p={id:r++,bindings:d};if(d.some((l)=>l.kind==="for"))p.template=!0;e.push(p);let a=o.endsWith("/>");return`${o.slice(0,a?-2:-1).trimEnd()} ${de}="${p.id}"${a?"/>":">"}`}),manifest:{entries:e}}}var be=["accessibilityHint","accessibilityLabel","accessibilityRole","accessibilityState","accessibilityValue","activeOpacity","alwaysBounceHorizontal","alwaysBounceVertical","animationType","autoCapitalize","autoCorrect","autoFocus","blurRadius","contentContainerStyle","defaultSource","defaultValue","ellipsizeMode","fadeDuration","hidesWhenStopped","hitSlop","imageStyle","initialNumToRender","iosBackgroundColor","keyboardDismissMode","keyboardShouldPersistTaps","keyboardType","keyboardVerticalOffset","keyExtractor","maxLength","maximumTrackTintColor","maximumValue","maxToRenderPerBatch","minimumTrackTintColor","minimumValue","numberOfLines","numColumns","onEndReachedThreshold","pagingEnabled","placeholderTextColor","pointerEvents","presentationStyle","pressRetentionOffset","progressBackgroundColor","progressViewOffset","refreshControl","resizeMode","returnKeyType","scrollEnabled","scrollTarget","secureTextEntry","selectedValue","selectionColor","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","statusBarTranslucent","stickyHeaderIndices","testID","thumbColor","thumbTintColor","titleColor","trackColor","underlayColor","windowSize"],Se=new Map(be.map((t)=>[H(t),t]));function H(t){return t.replace(/[-_]/g,"").toLowerCase()}function L(t){return Se.get(H(t))??t}var xe={view:"View",text:"Text",button:"Button",image:"Image",img:"Image",input:"TextInput",textarea:"TextInput",scroll:"ScrollView",scrollview:"ScrollView",list:"FlatList",flatlist:"FlatList",modal:"Modal",switch:"Switch",slider:"Slider",picker:"Picker",select:"Picker",loading:"ActivityIndicator",spinner:"ActivityIndicator",div:"View",span:"Text",p:"Text",h1:"Text",h2:"Text",h3:"Text",h4:"Text",h5:"Text",h6:"Text",a:"TouchableOpacity",section:"View",article:"View",header:"SafeAreaView",footer:"View",main:"View",nav:"View",aside:"View",form:"View",label:"Text",fieldset:"View",legend:"Text",option:"Text",dialog:"Modal",figure:"View",figcaption:"Text",picture:"View",hr:"View",ul:"View",ol:"View",li:"View",dl:"View",dt:"Text",dd:"Text",table:"View",thead:"View",tbody:"View",tfoot:"View",tr:"View",th:"Text",td:"Text",caption:"Text",strong:"Text",b:"Text",em:"Text",i:"Text",u:"Text",s:"Text",small:"Text",mark:"Text",abbr:"Text",time:"Text",code:"Text",kbd:"Text",samp:"Text",pre:"Text",blockquote:"Text",cite:"Text",q:"Text",sub:"Text",sup:"Text"};function G(t){return xe[t.toLowerCase()]||t}var we={transparent:"transparent",current:"currentColor",black:"#000000",white:"#ffffff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},J={px:1,0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},U={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48,"6xl":60,"7xl":72,"8xl":96,"9xl":128},w={none:0,sm:2,DEFAULT:4,md:6,lg:8,xl:12,"2xl":16,"3xl":24,full:9999};function W(t){let e=t.lastIndexOf("/");if(e>0&&!t.endsWith("]")){let i=W(t.slice(0,e)),o=t.slice(e+1),s=/^\[(.+)\]$/.test(o)?Number.parseFloat(o.slice(1,-1))*(o.includes("%")?1:100):Number.parseFloat(o);if(!i||!Number.isFinite(s))return;return Te(i,s/100)}if(t==="transparent")return"transparent";if(t==="current")return"currentColor";if(t==="black")return"#000000";if(t==="white")return"#ffffff";let r=t.split("-");if(r.length===2){let[i,o]=r,s=we[i];if(s&&typeof s==="object")return s[o]}if(t.startsWith("[")&&t.endsWith("]")){let i=t.slice(1,-1);return/^(#|rgba?\(|hsla?\(|[a-z]+$)/i.test(i)?i:void 0}return}function Te(t,e){if(t==="transparent")return t;let r=t.startsWith("#")?t.slice(1):"";if(r.length===3)r=r.split("").map((o)=>o+o).join("");if(r.length===8)r=r.slice(0,6);if(r.length!==6)return;let i=Math.round(Math.min(1,Math.max(0,e))*255);return`#${r}${i.toString(16).padStart(2,"0")}`}function O(t,e=16){if(!t.startsWith("[")||!t.endsWith("]"))return;let r=t.slice(1,-1),i=Number.parseFloat(r);if(!Number.isFinite(i))return;if(r.endsWith("rem"))return i*16;if(r.endsWith("em"))return i*e;return i}function g(t){if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1),r=e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e);return Number.isFinite(r)?r:void 0}return J[t]}var ye={flex:(t,e)=>(e.display="flex",!0),hidden:(t,e)=>(e.display="none",!0),grid:(t,e)=>(e.display="grid",!0),"flex-row":(t,e)=>(e.flexDirection="row",!0),"flex-col":(t,e)=>(e.flexDirection="column",!0),"flex-row-reverse":(t,e)=>(e.flexDirection="row-reverse",!0),"flex-col-reverse":(t,e)=>(e.flexDirection="column-reverse",!0),"flex-wrap":(t,e)=>(e.flexWrap="wrap",!0),"flex-nowrap":(t,e)=>(e.flexWrap="nowrap",!0),"flex-wrap-reverse":(t,e)=>(e.flexWrap="wrap-reverse",!0),"flex-1":(t,e)=>(e.flex=1,e.flexGrow=1,e.flexShrink=1,e.flexBasis=0,!0),"flex-auto":(t,e)=>(e.flexGrow=1,e.flexShrink=1,!0),"flex-initial":(t,e)=>(e.flexGrow=0,e.flexShrink=1,!0),"flex-none":(t,e)=>(e.flexGrow=0,e.flexShrink=0,!0),grow:(t,e)=>(e.flexGrow=1,!0),"grow-0":(t,e)=>(e.flexGrow=0,!0),shrink:(t,e)=>(e.flexShrink=1,!0),"shrink-0":(t,e)=>(e.flexShrink=0,!0),"justify-start":(t,e)=>(e.justifyContent="flex-start",!0),"justify-center":(t,e)=>(e.justifyContent="center",!0),"justify-end":(t,e)=>(e.justifyContent="flex-end",!0),"justify-between":(t,e)=>(e.justifyContent="space-between",!0),"justify-around":(t,e)=>(e.justifyContent="space-around",!0),"justify-evenly":(t,e)=>(e.justifyContent="space-evenly",!0),"items-start":(t,e)=>(e.alignItems="flex-start",!0),"items-center":(t,e)=>(e.alignItems="center",!0),"items-end":(t,e)=>(e.alignItems="flex-end",!0),"items-stretch":(t,e)=>(e.alignItems="stretch",!0),"items-baseline":(t,e)=>(e.alignItems="baseline",!0),"self-auto":(t,e)=>(e.alignSelf="auto",!0),"self-start":(t,e)=>(e.alignSelf="flex-start",!0),"self-center":(t,e)=>(e.alignSelf="center",!0),"self-end":(t,e)=>(e.alignSelf="flex-end",!0),"self-stretch":(t,e)=>(e.alignSelf="stretch",!0),"self-baseline":(t,e)=>(e.alignSelf="baseline",!0),"min-w-0":(t,e)=>(e.minWidth=0,!0),"aspect-square":(t,e)=>(e.aspectRatio=1,!0),"inset-0":(t,e)=>(e.top=0,e.right=0,e.bottom=0,e.left=0,!0),"tracking-tighter":(t,e)=>(e.letterSpacing=-0.8,!0),"tracking-tight":(t,e)=>(e.letterSpacing=-0.4,!0),"tracking-normal":(t,e)=>(e.letterSpacing=0,!0),"tracking-wide":(t,e)=>(e.letterSpacing=0.4,!0),"tracking-wider":(t,e)=>(e.letterSpacing=0.8,!0),"tracking-widest":(t,e)=>(e.letterSpacing=1.6,!0),"tabular-nums":()=>!0,block:()=>!0,"inline-flex":(t,e)=>(e.display="flex",!0),truncate:()=>!0,relative:(t,e)=>(e.position="relative",!0),absolute:(t,e)=>(e.position="absolute",!0),"overflow-visible":(t,e)=>(e.overflow="visible",!0),"overflow-hidden":(t,e)=>(e.overflow="hidden",!0),"overflow-scroll":(t,e)=>(e.overflow="scroll",!0),"font-thin":(t,e)=>(e.fontWeight="100",!0),"font-extralight":(t,e)=>(e.fontWeight="200",!0),"font-light":(t,e)=>(e.fontWeight="300",!0),"font-normal":(t,e)=>(e.fontWeight="400",!0),"font-medium":(t,e)=>(e.fontWeight="500",!0),"font-semibold":(t,e)=>(e.fontWeight="600",!0),"font-bold":(t,e)=>(e.fontWeight="bold",!0),"font-extrabold":(t,e)=>(e.fontWeight="800",!0),"font-black":(t,e)=>(e.fontWeight="900",!0),italic:(t,e)=>(e.fontStyle="italic",!0),"not-italic":(t,e)=>(e.fontStyle="normal",!0),"text-left":(t,e)=>(e.textAlign="left",!0),"text-center":(t,e)=>(e.textAlign="center",!0),"text-right":(t,e)=>(e.textAlign="right",!0),"text-justify":(t,e)=>(e.textAlign="justify",!0),uppercase:(t,e)=>(e.textTransform="uppercase",!0),lowercase:(t,e)=>(e.textTransform="lowercase",!0),capitalize:(t,e)=>(e.textTransform="capitalize",!0),"normal-case":(t,e)=>(e.textTransform="none",!0),underline:(t,e)=>(e.textDecorationLine="underline",!0),"line-through":(t,e)=>(e.textDecorationLine="line-through",!0),"no-underline":(t,e)=>(e.textDecorationLine="none",!0)};function ve(t,e){if(!t.startsWith("bg-"))return!1;let r=t.slice(3),i=W(r);if(i)return e.backgroundColor=i,!0;return!1}function Re(t,e){if(!t.startsWith("text-"))return!1;let r=t.slice(5);if(U[r])return e.fontSize=U[r],!0;if(r.startsWith("[")&&r.endsWith("]")){let o=r.slice(1,-1);if(/^-?[\d.]+(?:px|r?em)?$/.test(o)){let s=o.endsWith("rem")||o.endsWith("em")?Number.parseFloat(o)*16:Number.parseFloat(o);if(Number.isFinite(s))return e.fontSize=s,!0}}let i=W(r);if(i)return e.color=i,!0;return!1}function _e(t,e){if(t.startsWith("p-")){let r=g(t.slice(2));if(r!==void 0)return e.padding=r,!0}if(t.startsWith("px-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingHorizontal=r,!0}if(t.startsWith("py-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingVertical=r,!0}if(t.startsWith("pt-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingTop=r,!0}if(t.startsWith("pr-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingRight=r,!0}if(t.startsWith("pb-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingBottom=r,!0}if(t.startsWith("pl-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingLeft=r,!0}return!1}function ke(t,e){if(t.startsWith("m-")){let r=g(t.slice(2));if(r!==void 0)return e.margin=r,!0}if(t.startsWith("mx-")){let r=g(t.slice(3));if(r!==void 0)return e.marginHorizontal=r,!0}if(t.startsWith("my-")){let r=g(t.slice(3));if(r!==void 0)return e.marginVertical=r,!0}if(t.startsWith("mt-")){let r=g(t.slice(3));if(r!==void 0)return e.marginTop=r,!0}if(t.startsWith("mr-")){let r=g(t.slice(3));if(r!==void 0)return e.marginRight=r,!0}if(t.startsWith("mb-")){let r=g(t.slice(3));if(r!==void 0)return e.marginBottom=r,!0}if(t.startsWith("ml-")){let r=g(t.slice(3));if(r!==void 0)return e.marginLeft=r,!0}return!1}function Ce(t,e){if(!t.startsWith("w-"))return!1;let r=t.slice(2);if(r==="full")return e.width="100%",!0;if(r==="screen")return e.width="100%",!0;if(r==="auto")return e.width="auto",!0;if(r.includes("/")){let[o,s]=r.split("/"),c=Number.parseInt(o)/Number.parseInt(s)*100;return e.width=`${c}%`,!0}let i=g(r);if(i!==void 0)return e.width=i,!0;return!1}function We(t,e){if(!t.startsWith("h-"))return!1;let r=t.slice(2);if(r==="full")return e.height="100%",!0;if(r==="screen")return e.height="100%",!0;if(r==="auto")return e.height="auto",!0;let i=g(r);if(i!==void 0)return e.height=i,!0;return!1}function Ne(t,e){if(!t.startsWith("rounded"))return!1;if(t==="rounded")return e.borderRadius=w.DEFAULT,!0;let r=t.slice(8);if(r==="")return!1;let i=/^(?:(t|b|l|r)-)?(\[[^\]]+\])$/.exec(r);if(i){let s=O(i[2]);if(s===void 0)return!1;let c={t:["borderTopLeftRadius","borderTopRightRadius"],b:["borderBottomLeftRadius","borderBottomRightRadius"],l:["borderTopLeftRadius","borderBottomLeftRadius"],r:["borderTopRightRadius","borderBottomRightRadius"]};for(let f of i[1]?c[i[1]]:["borderRadius"])e[f]=s;return!0}if(r.startsWith("t-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopLeftRadius=s,e.borderTopRightRadius=s,!0}if(r.startsWith("b-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderBottomLeftRadius=s,e.borderBottomRightRadius=s,!0}if(r.startsWith("l-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopLeftRadius=s,e.borderBottomLeftRadius=s,!0}if(r.startsWith("r-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopRightRadius=s,e.borderBottomRightRadius=s,!0}let o=w[r];if(o!==void 0)return e.borderRadius=o,!0;return!1}function Be(t,e){if(!t.startsWith("border"))return!1;if(t==="border")return e.borderWidth=1,!0;let r=t.match(/^border-(\d+)$/);if(r)return e.borderWidth=Number.parseInt(r[1]),!0;let i=t.match(/^border-(t|r|b|l)-?(\d*)$/);if(i){let[,o,s]=i,c=s?Number.parseInt(s):1;switch(o){case"t":e.borderTopWidth=c;break;case"r":e.borderRightWidth=c;break;case"b":e.borderBottomWidth=c;break;case"l":e.borderLeftWidth=c;break}return!0}return!1}function Ee(t,e){if(!t.startsWith("border-"))return!1;let r=t.slice(7),i=W(r);if(i)return e.borderColor=i,!0;return!1}function Xe(t,e){if(!t.startsWith("opacity-"))return!1;let r=Number.parseInt(t.slice(8));if(!Number.isNaN(r))return e.opacity=r/100,!0;return!1}function Ie(t,e){if(t.startsWith("tracking-[")){let r=O(t.slice(9),typeof e.fontSize==="number"?e.fontSize:16);if(r===void 0)return!1;return e.letterSpacing=r,!0}if(t.startsWith("leading-")){let r=t.slice(8),i=typeof e.fontSize==="number"?e.fontSize:16,o={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},s=r.startsWith("[")?/^\[[\d.]+\]$/.test(r)?Number.parseFloat(r.slice(1,-1))*i:O(r,i):o[r]!==void 0?o[r]*i:J[r];if(s===void 0||!Number.isFinite(s))return!1;return e.lineHeight=s,!0}return!1}function De(t,e){let r=/^grid-cols-(\d+)$/.exec(t);if(!r)return!1;return e.gridColumns=Number(r[1]),!0}function Le(t,e){if(!t.startsWith("size-"))return!1;let r=t.slice(5),i=r==="full"?"100%":g(r);if(i===void 0)return!1;return e.width=i,e.height=i,!0}function Oe(t,e){let r=/^(-?)(top|right|bottom|left)-(.+)$/.exec(t);if(!r)return!1;let i=r[3]==="full"?"100%":g(r[3]);if(i===void 0)return!1;return e[r[2]]=typeof i==="number"&&r[1]?-i:i,!0}function Ve(t,e){let r=/^space-(x|y)-(.+)$/.exec(t);if(!r)return!1;let i=g(r[2]);if(i===void 0)return!1;return e.gap=i,!0}function $e(t,e){if(t.startsWith("gap-")){let r=g(t.slice(4));if(r!==void 0)return e.gap=r,!0}if(t.startsWith("gap-x-")){let r=g(t.slice(6));if(r!==void 0)return e.columnGap=r,!0}if(t.startsWith("gap-y-")){let r=g(t.slice(6));if(r!==void 0)return e.rowGap=r,!0}return!1}function Y(t,e){let r={},i=t.split(/\s+/).filter(Boolean);for(let o of i){if(/^i-[a-z0-9]+-/.test(o))continue;let s=ye[o];if(s){s("",r);continue}if(ve(o,r))continue;if(Re(o,r))continue;if(_e(o,r))continue;if(ke(o,r))continue;if(Ce(o,r))continue;if(We(o,r))continue;if(Ne(o,r))continue;if(Be(o,r))continue;if(Ee(o,r))continue;if(Xe(o,r))continue;if($e(o,r))continue;if(Ie(o,r))continue;if(Le(o,r))continue;if(De(o,r))continue;if(Oe(o,r))continue;if(Ve(o,r))continue;if(e?.push(o),typeof process<"u"&&process.env?.NODE_ENV==="development")console.warn(`[STX Native] Unknown Headwind class: ${o}`)}return r}function N(t,e={},r={},i={},o=[]){return{type:t,props:e,style:r,events:i,children:o}}function K(t,e,r={}){return{version:"1.0.0",root:t,script:e,meta:{source:r.source||"unknown",compiledAt:r.compiledAt||Date.now(),headwindConfig:r.headwindConfig}}}var q=new Set(["script","style","head","meta","link","title","base","noscript","svg"]),Z=new Set(["template","body","html","main","fragment"]),B=new Set(["svg"]),Ae={click:"onPress",press:"onPress",longpress:"onLongPress",contextmenu:"onLongPress",input:"onChangeText",change:"onValueChange",focus:"onFocus",focusin:"onFocus",blur:"onBlur",focusout:"onBlur",submit:"onSubmitEditing",scroll:"onScroll",refresh:"onRefresh",close:"onRequestClose"},ze=new Set(["onBlur","onChangeText","onEndReached","onFocus","onLayout","onLongPress","onPress","onRequestClose","onRefresh","onScroll","onValueChange"]),V=new Set(["display","flex","flexGrow","flexShrink","flexBasis","flexDirection","flexWrap","justifyContent","alignItems","alignSelf","alignContent","position","top","right","bottom","left","zIndex","width","height","minWidth","maxWidth","minHeight","maxHeight","aspectRatio","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderStyle","backgroundColor","backgroundImage","opacity","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","color","fontSize","fontWeight","fontStyle","fontFamily","lineHeight","letterSpacing","textAlign","textDecorationLine","textDecorationColor","textTransform","resizeMode","tintColor","transform","overflow"]),je=new Set(["flex","flexGrow","flexShrink","zIndex","aspectRatio","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","opacity","shadowOpacity","shadowRadius","elevation","fontSize","lineHeight","letterSpacing"]),Fe=new Set(["top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical"]),Q=new Set(["View","ScrollView","SafeAreaView","KeyboardAvoidingView","Text","TextInput","Button","TouchableOpacity","TouchableHighlight","Pressable","Image","ImageBackground","FlatList","SectionList","Switch","Slider","Picker","DatePicker","Modal","ActivityIndicator","StatusBar","RefreshControl"]),ee=new Set(["View","SafeAreaView","ScrollView","KeyboardAvoidingView"]),Me={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ","#39":"'","#x27":"'"};function k(t){return t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,r)=>{let i=Me[r.toLowerCase()];if(i!==void 0)return i;if(r[0]==="#"){let o=r[1]==="x"||r[1]==="X"?Number.parseInt(r.slice(2),16):Number.parseInt(r.slice(1),10);return Number.isFinite(o)?String.fromCodePoint(o):e}return e})}function te(t){return t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}function ne(t){let e=/^(-?[\d.]+)px$/.exec(t);if(e)return Number.parseFloat(e[1]);let r=/^(-?[\d.]+)r?em$/.exec(t);if(r)return Number.parseFloat(r[1])*16;if(/^-?[\d.]+$/.test(t))return Number.parseFloat(t);return t}function He(t,e,r){let i={},o={},s={},c="",f={};for(let[p,a]of e){let u=p.toLowerCase();if(u==="class"||u==="classname"){c=c?`${c} ${a}`:a;continue}if(u==="style"){f={...f,...Ge(t,a,r)};continue}if(u.startsWith(":")||u.startsWith("x-")&&u!=="x-cloak"){s[u.startsWith(":")?u.slice(1):u.slice(2)]=k(a);continue}if(u==="x-cloak")continue;if(u.startsWith("@")||u.startsWith("v-on:")){let b=u.startsWith("@")?u.slice(1):u.slice(5),[m]=b.split("."),S=Ae[m]??(m.startsWith("on")?m:"");if(!S||!ze.has(S)){r.push({kind:"unread-event",tag:t,name:p});continue}o[S]=k(a);continue}if(u==="key"){i.key=a;continue}let l=k(a);try{i[L(p)]=JSON.parse(l)}catch{i[L(p)]=l}}let d={...c?Y(c):{},...f};return{props:i,style:d,events:o,bindings:s,classes:c}}function re(t,e){if(je.has(t))return!1;if(Fe.has(t))return/^-?[\d.]+%$/.test(e);return!0}function Ge(t,e,r){let i={},o=k(e);try{let s=JSON.parse(o);if(s&&typeof s==="object"&&!Array.isArray(s)){for(let[c,f]of Object.entries(s)){let d=V.has(c)?c:te(c.trim().toLowerCase());if(!V.has(d)){r.push({kind:"unknown-style",tag:t,name:d});continue}if(f===null||f===void 0)continue;let p=typeof f==="string"?ne(f):f;if(typeof p!=="string"&&typeof p!=="number")continue;if(typeof p==="string"&&!re(d,p)){r.push({kind:"non-numeric-style",tag:t,name:d});continue}i[d]=p}return i}}catch{}for(let s of o.split(";")){let c=s.indexOf(":");if(c===-1)continue;let f=te(s.slice(0,c).trim().toLowerCase()),d=s.slice(c+1).trim();if(!f||!d)continue;if(!V.has(f)){r.push({kind:"unknown-style",tag:t,name:f});continue}let p=ne(d);if(typeof p==="string"&&!re(f,p)){r.push({kind:"non-numeric-style",tag:t,name:f});continue}i[f]=p}return i}function ie(t){return t.children.map((e)=>typeof e==="string"?e:ie(e)).join("").replace(/\s+/g," ").trim()}function Ue(t,e){let r=t.node,i=r.children.filter((s)=>typeof s!=="string"),o=r.children.filter((s)=>typeof s==="string").join("").trim();if(ee.has(r.type)&&i.length===0&&o)return r.type="Text",r.children=[o],r;if(r.type==="Text"&&i.length>0){let s=ie(r);return e.push({kind:"flattened-text",tag:t.tag}),r.children=s?[s]:[],r}if(ee.has(r.type)&&i.length>0)r.children=i;return r}async function Je(t,e={}){let r=[],i=[],o=[],s=new Set;function c(a){let u=o[o.length-1];if(!u)i.push(a);else if(!u.dropped)u.node.children.push(a)}function f(a){if(a.node.bindings&&Object.keys(a.node.bindings).length>0){let l=a.node.children,b=l.filter((S)=>typeof S!=="string"),m=b.length===1&&b.length===l.length?b[0]:N("View",{},{},{},l);if(m.bindings={...a.node.bindings,...m.bindings},m.bindingId===void 0&&a.node.bindingId!==void 0)m.bindingId=a.node.bindingId;c(m);return}let u=o[o.length-1];for(let l of a.node.children){if(typeof l==="string"){if(u&&!u.dropped)u.node.children.push(l);continue}if(!u)i.push(l);else if(!u.dropped)u.node.children.push(l)}}function d(a,u){let l=q.has(a)&&!B.has(a),b=o[o.length-1]?.dropped??!1,{props:m,style:S,events:h,bindings:x,classes:v}=l||b?{props:{},style:{},events:{},bindings:{},classes:""}:He(a,u,r),X=m["data-native"],R;if(typeof X==="string"&&Q.has(X))R=X,delete m["data-native"];else R=B.has(a)?"View":G(a);if(R===a&&!Q.has(R)&&!q.has(a)&&!Z.has(a)&&!s.has(a))s.add(a),r.push({kind:"unmapped-tag",tag:a});if((l||B.has(a))&&!s.has(`drop:${a}`))s.add(`drop:${a}`),r.push({kind:"dropped-subtree",tag:a});let _=N(R,m,S,h),I=m["data-stx-b"];if(typeof I==="number"&&Number.isInteger(I))_.bindingId=I;if(delete m["data-stx-b"],v)_._classes=v;if(Object.keys(x).length>0)_.bindings=x;if(typeof m.key==="string")_.key=m.key,delete m.key;return{tag:a,node:_,dropped:l||b||B.has(a),discard:l||b,unwrap:Z.has(a)}}if(await new HTMLRewriter().on("*",{element(a){let u=a.tagName.toLowerCase(),l=d(u,[...a.attributes]),b=!0;try{a.onEndTag(()=>{if(o.pop(),l.discard)return;if(l.unwrap)f(l);else c(Ue(l,r))})}catch{b=!1}if(b)o.push(l);else if(!l.discard)c(l.node)},text(a){let u=o[o.length-1];if(!u||u.dropped)return;let l=k(a.text).replace(/\s+/g," ");if(!l.trim())return;u.node.children.push(l)}}).transform(new Response(t)).text(),i.length===0)throw Error(`No element to translate in the rendered output of ${e.source??"unknown"}`);return{root:i.length===1?i[0]:N("View",{},{},{},i),diagnostics:r}}async function oe(t,e={}){let{root:r,diagnostics:i}=await Je(t,e),o=e.script??{exports:{},functions:[],code:""};return{document:K(r,o,{source:e.source??"unknown"}),diagnostics:i}}var se=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Ye=/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([$\w]+)\s*\(/g,Ke=/(?:^|\n)\s*(?:export\s+)?(?:const|let|var)\s+([$\w]+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[$\w]+)\s*=>/g,ae=/(?:^|\n)\s*(?:export\s+)?const\s+([$\w]+)\s*=\s*(-?[\d.]+|true|false|'[^']*'|"[^"]*")\s*(?=;|\n|$)/g;function A(t){let e=[];se.lastIndex=0;for(let s of t.matchAll(se)){let c=s[1]??"";if(/\bserver\b/.test(c))continue;e.push(s[2].trim())}let r=e.filter(Boolean).join(`
3
-
4
- `),i=[];for(let s of[Ye,Ke]){s.lastIndex=0;for(let c of r.matchAll(s))if(!i.includes(c[1]))i.push(c[1])}let o={};ae.lastIndex=0;for(let s of r.matchAll(ae)){let c=s[2];try{o[s[1]]=JSON.parse(c.replace(/^'(.*)'$/,'"$1"'))}catch{o[s[1]]=c}}return{exports:o,functions:i,code:r}}var ce=/<script\b[^>]*\bdata-stx-scoped\b[^>]*>([\s\S]*?)<\/script>/gi,qe=/function\s+(__stx_setup_[\w$]+)\s*\(/;function P(t){ce.lastIndex=0;for(let e of t.matchAll(ce)){let r=e[1].trim(),i=qe.exec(r)?.[1];if(i)return{name:i,code:r}}return null}function Qe(){let t=[C.join(import.meta.dir,"..","primitives"),C.join(import.meta.dir,"native","primitives")];for(let e of t)if(Ze(C.join(e,"View.stx")))return e;return t[0]}async function et(t,e,r={}){let i=r.root??C.dirname(e),o={root:i,componentsDir:r.componentsDir??C.join(i,"components"),buildMode:"serve",cache:!1,_pluginComponentDirs:[Qe()]},s={...r.context??{},__stx_inject_css:!1},c=await n(t,s,e,o,new Set),{html:f,manifest:d}=M(c),{document:p,diagnostics:a}=await oe(f,{source:e,script:A(t)}),u=P(f);if(A(t).code.trim()){let l=await Ln(t,e,r.context,{forceClientSetup:!0});u=P(l.setupCode??"")??u}return{document:p,manifest:d,setup:u,diagnostics:a,html:f}}async function E(t,e={}){return et(await Bun.file(t).text(),t,e)}function ue(t){let r=[y.join(import.meta.dir,"..","runtime",`${t}.ts`),y.join(import.meta.dir,"..","runtime",`${t}.js`),y.join(import.meta.dir,"native","runtime",`${t}.js`)].find((i)=>tt(i));if(!r)throw Error(`Native runtime module ${t} is missing`);return r}async function rt(t,e,r){let i=await Bun.build({entrypoints:[t],target:"browser",format:"iife",minify:r,plugins:e,define:{"process.env.NODE_ENV":JSON.stringify(r?"production":"development")}});if(!i.success){let o=i.logs.map((s)=>String(s.message??s)).join(`
5
- `);throw Error(`Could not bundle ${t}:
6
- ${o}`)}return(await i.outputs[0].text()).trim()}async function z(t){let e=Object.keys(t.screens);if(e.length===0)throw Error("screens must name at least one .stx file");let r=t.routed??!0,i=t.initialScreen??e[0];if(!t.screens[i])throw Error(`Initial screen ${i} is not in screens`);let o=y.resolve(t.root??process.cwd()),s=[];for(let h of e){let x=y.resolve(o,t.screens[h]);if(!x.endsWith(".stx"))throw Error(`Screen ${h} must name a .stx file`);s.push({name:h,file:x,compiled:await E(x,{root:o})})}let c=ue("jsc-globals"),f=ue("shared-screen"),d=r?`var routeName = g.__stxNativeRoute || ${JSON.stringify(i)};
7
- if (routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));`:"var routeName = 'main';",p=s.map(({name:h,compiled:x},v)=>`${v===0?"if":"else if"} (routeName === ${JSON.stringify(r?h:"main")}) {
8
- nativeDocument = ${JSON.stringify(x.document)};
9
- manifest = ${JSON.stringify(x.manifest)};
10
- }`).join(`
11
- `),a=s.map(({name:h,compiled:x},v)=>`${v===0?"if":"else if"} (routeName === ${JSON.stringify(r?h:"main")}) {
12
- ${x.setup?.code??"g.__stx_latestSetup = null;"}
13
- }`).join(`
14
- `),u=`
15
- import { installJSCGlobals } from ${JSON.stringify(c)};
16
- import { prepareSharedNativeScreen } from ${JSON.stringify(f)};
17
- var g = globalThis;
18
- installJSCGlobals(g);
19
- var bridge = g.__stxNativeBridge;
20
- if (!bridge) throw new Error('Missing __stxNativeBridge');
21
- var routeNames = ${JSON.stringify(r?e:["main"])};
22
- ${d}
23
- g.__stxNativeRoute = routeName;
24
- var nativeDocument;
25
- var manifest;
26
- ${p}
27
- var screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
28
- g.__stx_host = screen.host;
29
- g.__stxNativeUnmount = function() { screen.unmount(); };
30
- ${Pe()}
31
- ${a}
32
- screen.mount(g.stx, g.__stx_latestSetup || null);
33
- `,b=await rt("stx:native-shared-screens",[{name:"stx-native-shared-screens",setup(h){h.onResolve({filter:/^stx:native-shared-screens$/},()=>({path:"entry",namespace:"stx-native-shared-screens"})),h.onLoad({filter:/.*/,namespace:"stx-native-shared-screens"},()=>({contents:u,loader:"js"}))}}],t.minify??!1),m=s.flatMap(({compiled:h})=>h.diagnostics).map((h)=>({level:"warning",message:[h.kind,h.tag,h.name].filter(Boolean).join(": ")}));if(!t.outFile)return{code:b,diagnostics:m};let S=y.resolve(o,t.outFile);return nt(y.dirname(S),{recursive:!0}),await Bun.write(S,b),{code:b,outFile:S,diagnostics:m}}async function it(t,e={}){return z({...e,screens:{main:t},routed:!1})}function fe(t,e={}){return it(t,e)}var le=["native.config.json","stx-native.config.json"];function at(t=process.cwd(),e){let r=e?T.resolve(t,e):le.map((f)=>T.join(t,f)).find((f)=>j(f));if(!r)return null;if(!j(r))throw Error(`Native config not found: ${r}`);let i=JSON.parse(st(r,"utf8")),o=Object.entries(i.screens??{});if(o.length===0)throw Error(`${T.basename(r)} must name at least one screen in "screens"`);let s={};for(let[f,d]of o){if(!/^[A-Z][\w-]*$/i.test(f))throw Error(`Invalid native screen name: ${f}`);if(typeof d!=="string"||!d.endsWith(".stx"))throw Error(`Screen ${f} must name a .stx file`);if(s[f]=T.resolve(T.dirname(r),d),!j(s[f]))throw Error(`Screen ${f} not found: ${s[f]}`)}let c=i.initialScreen||o[0][0];if(!s[c])throw Error(`Initial screen ${c} is not in screens`);return{initialScreen:c,screens:s,file:r}}async function At(t,e={}){let r=T.resolve(e.cwd??process.cwd()),i=e.format??"ir";if(i!=="ir"&&i!=="bundle")throw Error(`Unknown compile format: ${i}. Expected ir or bundle.`);let o=t?null:at(r,e.config);if(!t&&!o)throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${le[0]}`);let s,c=[];if(i==="bundle"){let d=o?await z({screens:o.screens,initialScreen:o.initialScreen,minify:e.minify,root:r}):await fe(T.resolve(r,t),{minify:e.minify});s=d.code,c=d.diagnostics}else{let d=async(a)=>{let u=await E(a);return c.push(...u.diagnostics.map((l)=>({level:"warning",message:[l.kind,l.tag,l.name].filter(Boolean).join(": ")}))),u.document},p=o?{initialScreen:o.initialScreen,screens:Object.fromEntries(await Promise.all(Object.entries(o.screens).map(async([a,u])=>[a,await d(u)])))}:await d(T.resolve(r,t));s=JSON.stringify(p,null,2)}if(!e.output)return{output:s,diagnostics:c};let f=T.resolve(r,e.output);return ot(T.dirname(f),{recursive:!0}),await Bun.write(f,s),{output:s,written:f,diagnostics:c}}export{At as runNativeCompile};