@stacksjs/stx 0.2.888 → 0.2.890

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.
Files changed (260) hide show
  1. package/dist/{chunk-c0g30cjs.js → chunk-05x1rd86.js} +2 -2
  2. package/dist/{chunk-6qq3wy3m.js → chunk-062qfv99.js} +2 -2
  3. package/dist/{chunk-s29hp1qw.js → chunk-0jdz31q1.js} +3 -3
  4. package/dist/{chunk-1kc0jyhj.js → chunk-0jkj8thz.js} +1 -1
  5. package/dist/chunk-0k437z3q.js +2 -0
  6. package/dist/chunk-0q0nbq50.js +2 -0
  7. package/dist/{chunk-5ysv0499.js → chunk-0wp23n1d.js} +1 -1
  8. package/dist/{chunk-9f31gs4m.js → chunk-115bb91s.js} +2 -2
  9. package/dist/chunk-12cjs6vs.js +2 -0
  10. package/dist/chunk-1a7a8cjs.js +2 -0
  11. package/dist/{chunk-wpa3r3b9.js → chunk-1bft48gk.js} +2 -2
  12. package/dist/{chunk-9tecekzq.js → chunk-1jtsr42q.js} +18 -18
  13. package/dist/{chunk-vazk5qbh.js → chunk-1knk403z.js} +2 -2
  14. package/dist/chunk-1p4q6t48.js +2 -0
  15. package/dist/chunk-1ph2yhfn.js +3 -0
  16. package/dist/{chunk-c1b0fy70.js → chunk-1t15z230.js} +5 -5
  17. package/dist/{chunk-2assyczz.js → chunk-1w0bqqh5.js} +2 -2
  18. package/dist/chunk-1z6pqvmf.js +2 -0
  19. package/dist/chunk-2nqmw4dv.js +2 -0
  20. package/dist/{chunk-e9tjxnhn.js → chunk-2xnbdqy4.js} +5 -5
  21. package/dist/chunk-35j7gaj5.js +2 -0
  22. package/dist/chunk-3b3mkgpj.js +3 -0
  23. package/dist/{chunk-7mcs59pr.js → chunk-3bsz7zj3.js} +2 -2
  24. package/dist/{chunk-w624s5jf.js → chunk-3qk8vf9m.js} +3 -3
  25. package/dist/chunk-3yvmaphj.js +2 -0
  26. package/dist/{chunk-mk6thhwf.js → chunk-40k0r6z9.js} +2 -2
  27. package/dist/{chunk-6t04tqvh.js → chunk-41z7f41b.js} +2 -2
  28. package/dist/chunk-44teqn0b.js +2 -0
  29. package/dist/{chunk-372xh1g1.js → chunk-49xwf7dk.js} +6 -6
  30. package/dist/chunk-4akw3bym.js +2 -0
  31. package/dist/chunk-4d85str1.js +2 -0
  32. package/dist/{chunk-whsdyf4t.js → chunk-4eescf3s.js} +7 -7
  33. package/dist/chunk-4xbtxeak.js +2 -0
  34. package/dist/chunk-53kcqdjj.js +2 -0
  35. package/dist/{chunk-1xpq83mc.js → chunk-67j2m620.js} +4 -4
  36. package/dist/chunk-690518hw.js +2 -0
  37. package/dist/chunk-6s3jwysv.js +2 -0
  38. package/dist/{chunk-znnvq1jp.js → chunk-6svc4kb8.js} +65 -65
  39. package/dist/chunk-732gb689.js +2 -0
  40. package/dist/{chunk-ah6nc29h.js → chunk-80ky40mm.js} +2 -2
  41. package/dist/chunk-80xzjxah.js +2 -0
  42. package/dist/chunk-850tye3c.js +2 -0
  43. package/dist/{chunk-b8528fra.js → chunk-8ccgty8s.js} +4 -4
  44. package/dist/{chunk-btsgt6w3.js → chunk-8f8qgjjr.js} +2 -2
  45. package/dist/{chunk-ry6w43p6.js → chunk-8hwfdwgn.js} +6 -6
  46. package/dist/chunk-9344rq4r.js +38 -0
  47. package/dist/chunk-94j4p584.js +2 -0
  48. package/dist/{chunk-y76znqmh.js → chunk-97snfzsy.js} +54 -54
  49. package/dist/chunk-9a9cec4x.js +2 -0
  50. package/dist/chunk-9afkttvz.js +2 -0
  51. package/dist/{chunk-0hj5apb9.js → chunk-9rjgq8k4.js} +1 -1
  52. package/dist/chunk-a0aqs5a8.js +3 -0
  53. package/dist/{chunk-9qrgdekg.js → chunk-a3zrwky3.js} +16 -16
  54. package/dist/{chunk-care745q.js → chunk-a7bqrjm5.js} +2 -2
  55. package/dist/{chunk-pm4kn9h2.js → chunk-adsqckg4.js} +10 -10
  56. package/dist/chunk-ah8az9vv.js +2 -0
  57. package/dist/{chunk-605g9qhp.js → chunk-aj5tsksz.js} +9 -9
  58. package/dist/chunk-amb7e0fp.js +2 -0
  59. package/dist/chunk-arr79m90.js +2 -0
  60. package/dist/{chunk-55kwxxm5.js → chunk-b0hj8eg2.js} +2 -2
  61. package/dist/{chunk-r57jz09p.js → chunk-bgfs3mbg.js} +5 -5
  62. package/dist/chunk-bm0mzk3b.js +2 -0
  63. package/dist/{chunk-ymqm898x.js → chunk-bvqgq18r.js} +2 -2
  64. package/dist/{chunk-wbxmn5gk.js → chunk-bw2m1e7g.js} +5 -5
  65. package/dist/{chunk-wm287dz2.js → chunk-c25q87ys.js} +3 -3
  66. package/dist/{chunk-98mj0es1.js → chunk-ch9028z3.js} +1 -1
  67. package/dist/{chunk-sbwvvjkc.js → chunk-cmg9x1ka.js} +3 -3
  68. package/dist/{chunk-11fxbd71.js → chunk-cphc60zw.js} +2 -2
  69. package/dist/{chunk-dj9ztcth.js → chunk-dvjv4c3a.js} +1 -1
  70. package/dist/{chunk-v8e2c2r1.js → chunk-e16ef18k.js} +2 -2
  71. package/dist/chunk-e28czxw3.js +2 -0
  72. package/dist/chunk-e8szp5wa.js +2 -0
  73. package/dist/chunk-eq86wzhr.js +1314 -0
  74. package/dist/chunk-essd43ad.js +2 -0
  75. package/dist/chunk-f60k8j9m.js +2 -0
  76. package/dist/chunk-fsk3rk2x.js +2 -0
  77. package/dist/{chunk-fce8wj3t.js → chunk-g3vce7ka.js} +2 -2
  78. package/dist/{chunk-em6fqvjy.js → chunk-g5nfqzfh.js} +2 -2
  79. package/dist/chunk-gfea8a9y.js +2 -0
  80. package/dist/chunk-hda7t8g6.js +2 -0
  81. package/dist/chunk-hk241gt2.js +2 -0
  82. package/dist/{chunk-c3ca056p.js → chunk-htx5yezj.js} +2 -2
  83. package/dist/{chunk-b0jekg4c.js → chunk-hxws025y.js} +3 -3
  84. package/dist/chunk-hyyh7qxw.js +25 -0
  85. package/dist/chunk-j6fs31va.js +2 -0
  86. package/dist/chunk-j9kejcrx.js +2 -0
  87. package/dist/chunk-j9vfv53x.js +20 -0
  88. package/dist/chunk-jhbz5w30.js +2 -0
  89. package/dist/chunk-jvnsz2x9.js +2 -0
  90. package/dist/chunk-k4x680e3.js +2 -0
  91. package/dist/chunk-k8bk685s.js +2 -0
  92. package/dist/chunk-kexqmwx8.js +2 -0
  93. package/dist/chunk-kfdmm240.js +2 -0
  94. package/dist/{chunk-fepezvdq.js → chunk-kg7vby72.js} +8 -8
  95. package/dist/{chunk-wf8pdjq5.js → chunk-khm56bfm.js} +1 -1
  96. package/dist/{chunk-303vzq80.js → chunk-kk2p2tgv.js} +3 -3
  97. package/dist/chunk-kpjq135z.js +2 -0
  98. package/dist/chunk-kqsm7gf1.js +2 -0
  99. package/dist/{chunk-j51wss7s.js → chunk-kr2400c3.js} +4 -4
  100. package/dist/{chunk-r8xper92.js → chunk-ksmn19qw.js} +2 -2
  101. package/dist/{chunk-7hm1tpw0.js → chunk-mhrnjaka.js} +6 -6
  102. package/dist/chunk-mtfymhy1.js +2 -0
  103. package/dist/{chunk-52mhrbps.js → chunk-n6q1d66k.js} +1 -1
  104. package/dist/chunk-neg6ckjg.js +12 -0
  105. package/dist/{chunk-wscry63p.js → chunk-nhv81gp2.js} +2 -2
  106. package/dist/{chunk-c73c0wf9.js → chunk-nq60tjkz.js} +2 -2
  107. package/dist/{chunk-v47xc2fr.js → chunk-nzpb263k.js} +9 -9
  108. package/dist/{chunk-p33npqjt.js → chunk-p0bjbtdx.js} +33 -33
  109. package/dist/{chunk-gdtj5rfa.js → chunk-p3hbsrk9.js} +6 -6
  110. package/dist/chunk-p82fzxdg.js +2 -0
  111. package/dist/{chunk-0d7ypcjb.js → chunk-pjj54ddk.js} +3 -3
  112. package/dist/{chunk-qsnpqa8q.js → chunk-pnmafbv5.js} +1 -1
  113. package/dist/{chunk-vgsasnwm.js → chunk-pvm48tse.js} +3 -3
  114. package/dist/{chunk-zek9t5za.js → chunk-pwpge9bj.js} +2 -2
  115. package/dist/{chunk-6zq3eh7d.js → chunk-q0y8gv18.js} +2 -2
  116. package/dist/{chunk-7s3j8pqq.js → chunk-qnf7w4xw.js} +3 -3
  117. package/dist/chunk-qsv84cwm.js +2 -0
  118. package/dist/{chunk-xavx271y.js → chunk-r5ecgcx2.js} +5 -5
  119. package/dist/chunk-r7m60q1m.js +2 -0
  120. package/dist/chunk-r98pye4h.js +2 -0
  121. package/dist/{chunk-zf29ahhd.js → chunk-rb2zbdqd.js} +4 -4
  122. package/dist/{chunk-vjfp8n6p.js → chunk-rd663v1m.js} +3 -3
  123. package/dist/{chunk-4nnmrp7w.js → chunk-rf0smj4c.js} +2 -2
  124. package/dist/{chunk-0dq9svfb.js → chunk-sh7a0g09.js} +3 -3
  125. package/dist/chunk-snkbn5y8.js +2 -0
  126. package/dist/chunk-sztr4d5g.js +2 -0
  127. package/dist/{chunk-4c9p434g.js → chunk-t0ttxayz.js} +2 -2
  128. package/dist/{chunk-5ymf5c8m.js → chunk-t3zmfh8w.js} +7 -7
  129. package/dist/chunk-t4gcsbna.js +2 -0
  130. package/dist/chunk-tbh7r1wh.js +2 -0
  131. package/dist/chunk-tspqdt8e.js +2 -0
  132. package/dist/{chunk-6fsnnj5v.js → chunk-v1mwwben.js} +6 -6
  133. package/dist/chunk-v3jyb8k6.js +2 -0
  134. package/dist/chunk-v6gkjg5f.js +3 -0
  135. package/dist/chunk-v90nz5xm.js +54 -0
  136. package/dist/{chunk-7nhgpjjw.js → chunk-vf4ejngv.js} +6 -6
  137. package/dist/chunk-vfcbz0an.js +3 -0
  138. package/dist/{chunk-hxhmhw23.js → chunk-vk2jy6mn.js} +3 -3
  139. package/dist/{chunk-e1qcfesw.js → chunk-vkfw9k1n.js} +8 -8
  140. package/dist/{chunk-mm1eg2pg.js → chunk-vxbvrbqs.js} +10 -10
  141. package/dist/chunk-wedwczed.js +2 -0
  142. package/dist/chunk-wg6fmren.js +4 -0
  143. package/dist/{chunk-s7wp7a2x.js → chunk-whcrca58.js} +31 -31
  144. package/dist/chunk-wmvvrsn0.js +2 -0
  145. package/dist/chunk-wnrh62by.js +2 -0
  146. package/dist/{chunk-q3bkxg2n.js → chunk-wy6vjz1e.js} +21 -21
  147. package/dist/{chunk-mbm3ma63.js → chunk-x5bn2svk.js} +2 -2
  148. package/dist/chunk-x6565mhk.js +2 -0
  149. package/dist/{chunk-brzjass3.js → chunk-xc5esqcb.js} +2 -2
  150. package/dist/{chunk-e2ws79vt.js → chunk-xeyq6d0t.js} +8 -8
  151. package/dist/{chunk-xw291tn7.js → chunk-xmg6bmh6.js} +27 -22
  152. package/dist/{chunk-3fbgpv1d.js → chunk-xvncq3m5.js} +2 -2
  153. package/dist/chunk-xwgdcc7w.js +2 -0
  154. package/dist/chunk-xwrjre34.js +2 -0
  155. package/dist/{chunk-1wkp3pks.js → chunk-xy8smv5e.js} +2 -2
  156. package/dist/{chunk-y8p59h6c.js → chunk-y1d3j2j7.js} +4 -4
  157. package/dist/{chunk-zje94z0k.js → chunk-yesh4dfe.js} +61 -61
  158. package/dist/chunk-ymc1wgb3.js +2 -0
  159. package/dist/{chunk-xy4j8t7w.js → chunk-ytjn0gq2.js} +2 -2
  160. package/dist/chunk-z4tdnfxd.js +2 -0
  161. package/dist/{chunk-w1q86c89.js → chunk-zf68afyh.js} +3 -3
  162. package/dist/{chunk-6c1vm6bs.js → chunk-zkwkhesc.js} +2 -2
  163. package/dist/{chunk-2rmqmajd.js → chunk-zpqjsnz9.js} +3 -3
  164. package/dist/{chunk-vgr7gd8k.js → chunk-zwqkbk2m.js} +2 -2
  165. package/dist/chunk-zxjdfgdx.js +3 -0
  166. package/dist/cli.js +29 -29
  167. package/dist/component-contract.d.ts +1 -0
  168. package/dist/component-contract.js +6 -4
  169. package/dist/component-library.d.ts +2 -1
  170. package/dist/component-library.js +218 -348
  171. package/dist/composition-api.d.ts +7 -1
  172. package/dist/craft-entry.js +2 -2
  173. package/dist/craft.js +2 -2
  174. package/dist/directive-arguments.js +39 -6
  175. package/dist/emits-declaration.d.ts +9 -0
  176. package/dist/emits-declaration.js +64 -0
  177. package/dist/parser/tokenizer.d.ts +2 -1
  178. package/dist/parser/tokenizer.js +7 -5
  179. package/dist/props-declaration.d.ts +66 -0
  180. package/dist/props-declaration.js +379 -0
  181. package/dist/pwa.js +3 -3
  182. package/dist/ssg.js +28 -28
  183. package/dist/utils.js +20 -109
  184. package/package.json +5 -5
  185. package/dist/chunk-000mwmfq.js +0 -1203
  186. package/dist/chunk-043d0en0.js +0 -2
  187. package/dist/chunk-0w66z6eq.js +0 -2
  188. package/dist/chunk-13wd9gf0.js +0 -3
  189. package/dist/chunk-1znqedae.js +0 -2
  190. package/dist/chunk-2drzzjcm.js +0 -2
  191. package/dist/chunk-3c7nt5qp.js +0 -2
  192. package/dist/chunk-3ed2erm6.js +0 -12
  193. package/dist/chunk-3zyzhcd9.js +0 -2
  194. package/dist/chunk-44rb9fk0.js +0 -2
  195. package/dist/chunk-472j3bhp.js +0 -2
  196. package/dist/chunk-4acce1m8.js +0 -2
  197. package/dist/chunk-4kasmp98.js +0 -2
  198. package/dist/chunk-53kkjn23.js +0 -2
  199. package/dist/chunk-5gwvy612.js +0 -2
  200. package/dist/chunk-61vbqrde.js +0 -2
  201. package/dist/chunk-6fpzwryt.js +0 -2
  202. package/dist/chunk-7195598h.js +0 -2
  203. package/dist/chunk-7zvf79vb.js +0 -2
  204. package/dist/chunk-88a735jw.js +0 -2
  205. package/dist/chunk-8v7yjq3b.js +0 -2
  206. package/dist/chunk-94mpe1ny.js +0 -3
  207. package/dist/chunk-97kgrevs.js +0 -4
  208. package/dist/chunk-a8c9j9cj.js +0 -2
  209. package/dist/chunk-acw851e8.js +0 -2
  210. package/dist/chunk-andfvr3g.js +0 -2
  211. package/dist/chunk-aqxh80vh.js +0 -2
  212. package/dist/chunk-ay5zkfdg.js +0 -2
  213. package/dist/chunk-b4gptdtc.js +0 -2
  214. package/dist/chunk-baaw9w7y.js +0 -2
  215. package/dist/chunk-bw2p9h2g.js +0 -2
  216. package/dist/chunk-ce0vv7kz.js +0 -2
  217. package/dist/chunk-d1yj29g2.js +0 -2
  218. package/dist/chunk-dbhmbef1.js +0 -20
  219. package/dist/chunk-dfsykk1r.js +0 -2
  220. package/dist/chunk-e9p596bp.js +0 -2
  221. package/dist/chunk-edysherg.js +0 -25
  222. package/dist/chunk-ftecsa8e.js +0 -2
  223. package/dist/chunk-ge2h5v46.js +0 -2
  224. package/dist/chunk-gqvnz8a7.js +0 -2
  225. package/dist/chunk-j41gp8p3.js +0 -2
  226. package/dist/chunk-jxvccj30.js +0 -2
  227. package/dist/chunk-k5bbre7d.js +0 -2
  228. package/dist/chunk-kd47vgs8.js +0 -2
  229. package/dist/chunk-keqjafdz.js +0 -2
  230. package/dist/chunk-kvxdyg7e.js +0 -3
  231. package/dist/chunk-kz3mejc4.js +0 -2
  232. package/dist/chunk-ngkh0t5b.js +0 -2
  233. package/dist/chunk-nx9895m6.js +0 -2
  234. package/dist/chunk-nxgtt1t1.js +0 -2
  235. package/dist/chunk-nyw2ztar.js +0 -2
  236. package/dist/chunk-p5q27adr.js +0 -2
  237. package/dist/chunk-p6hcrg3r.js +0 -3
  238. package/dist/chunk-pa2vt2ej.js +0 -2
  239. package/dist/chunk-pczb7xav.js +0 -2
  240. package/dist/chunk-ps37r6hj.js +0 -2
  241. package/dist/chunk-pvbhk17r.js +0 -2
  242. package/dist/chunk-q252qvsy.js +0 -2
  243. package/dist/chunk-q5b0vpmm.js +0 -2
  244. package/dist/chunk-qg1kw5yf.js +0 -2
  245. package/dist/chunk-qjy5yq25.js +0 -54
  246. package/dist/chunk-r561zt9v.js +0 -38
  247. package/dist/chunk-sbr85vda.js +0 -2
  248. package/dist/chunk-tkab24xr.js +0 -2
  249. package/dist/chunk-vn59yrjh.js +0 -2
  250. package/dist/chunk-w50yggy3.js +0 -3
  251. package/dist/chunk-w5zzwe2f.js +0 -2
  252. package/dist/chunk-wa9q1gyv.js +0 -2
  253. package/dist/chunk-wbmx0rge.js +0 -2
  254. package/dist/chunk-wpgxhrd7.js +0 -2
  255. package/dist/chunk-x3azrbpr.js +0 -2
  256. package/dist/chunk-x50hk1hq.js +0 -2
  257. package/dist/chunk-xbkbvfcg.js +0 -2
  258. package/dist/chunk-z55rpt3s.js +0 -3
  259. package/dist/chunk-zwde52kw.js +0 -2
  260. package/dist/chunk-zxff7kq9.js +0 -2
@@ -74,7 +74,8 @@ export declare function setGlobalProvide<T>(key: string | symbol, value: T): voi
74
74
  * emit('change', 'newValue')
75
75
  * ```
76
76
  */
77
- export declare function defineEmits<T extends Record<string, any[]> = Record<string, any[]>>(events?: string[] | T): EmitFn<Extract<keyof T, string>>;
77
+ export declare function defineEmits<const T extends readonly string[]>(events: T): EmitFn<T[number]>;
78
+ export declare function defineEmits<T extends object = Record<string, any[]>>(events?: T): ComponentEmit<T>;
78
79
  /**
79
80
  * Expose public properties from a component instance.
80
81
  * These properties become accessible via template refs from the parent.
@@ -195,3 +196,8 @@ export declare interface StxComponentInstance {
195
196
  /** Type-safe emit function */
196
197
  // eslint-disable-next-line pickier/no-unused-vars
197
198
  export type EmitFn<T extends string = string> = (event: T, ...args: any[]) => void;
199
+ /** Tuple maps, payload maps and callable overload contracts share one emitter. */
200
+ export type ComponentEmit<T> = T extends (...args: never[]) => unknown ? T : <K extends Extract<keyof T, string>>(
201
+ event: K,
202
+ ...args: T[K] extends readonly unknown[] ? T[K] : [payload: T[K]]
203
+ ) => void;
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import"./chunk-000mwmfq.js";import{Fo,Va,Ua}from"./chunk-sbwvvjkc.js";import"./chunk-s7wp7a2x.js";import"./chunk-s29hp1qw.js";import"./chunk-xw291tn7.js";import"./chunk-11fxbd71.js";import"./chunk-hxhmhw23.js";import"./chunk-kvxdyg7e.js";import"./chunk-6t04tqvh.js";import"./chunk-fce8wj3t.js";import"./chunk-6zq3eh7d.js";import"./chunk-b8528fra.js";import"./chunk-zje94z0k.js";import"./chunk-5ymf5c8m.js";import"./chunk-zf29ahhd.js";import"./chunk-55kwxxm5.js";import"./chunk-pm4kn9h2.js";import"./chunk-znnvq1jp.js";import"./chunk-e1qcfesw.js";import"./chunk-qjy5yq25.js";import"./chunk-mm1eg2pg.js";import"./chunk-edysherg.js";import"./chunk-c0g30cjs.js";import"./chunk-vgsasnwm.js";import{zu,Wa,Gh,Xh,qa,zo,ps,Ka,Ga,Jh,Yh,Xa,Ja,Ya,Za}from"./chunk-p33npqjt.js";import"./chunk-c1b0fy70.js";import"./chunk-13wd9gf0.js";import"./chunk-ah6nc29h.js";import"./chunk-fepezvdq.js";import"./chunk-0hj5apb9.js";import"./chunk-52mhrbps.js";import"./chunk-7s3j8pqq.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-eq86wzhr.js";import{Vo,Ua,Wa}from"./chunk-cmg9x1ka.js";import"./chunk-whcrca58.js";import"./chunk-0jdz31q1.js";import"./chunk-xmg6bmh6.js";import"./chunk-cphc60zw.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-g3vce7ka.js";import"./chunk-q0y8gv18.js";import"./chunk-8ccgty8s.js";import"./chunk-yesh4dfe.js";import"./chunk-t3zmfh8w.js";import"./chunk-rb2zbdqd.js";import"./chunk-b0hj8eg2.js";import"./chunk-adsqckg4.js";import"./chunk-6svc4kb8.js";import"./chunk-vkfw9k1n.js";import"./chunk-v90nz5xm.js";import"./chunk-vxbvrbqs.js";import"./chunk-hyyh7qxw.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Uo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-p0bjbtdx.js";import"./chunk-1t15z230.js";import"./chunk-vfcbz0an.js";import"./chunk-80ky40mm.js";import"./chunk-kg7vby72.js";import"./chunk-9rjgq8k4.js";import"./chunk-n6q1d66k.js";import"./chunk-qnf7w4xw.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{zu as CRAFT_BRIDGE_SCRIPT,zo as CRAFT_COMPONENTS,Ka as CRAFT_COMPONENT_RUNTIME,ps as CRAFT_COMPONENT_STYLES,Fo as NATIVE_COMPONENTS,Xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Va as compileToNative,Ua as createHotReloadServer,Ja as findCraftBinary,Wa as generateCraftBridgeScript,V as generateCraftOptimizations,Za as getAvailableFormats,Ya as getAvailableTargets,Yh as getCraftComponents,G as getSSRCacheStats,qa as injectCraftBridge,Gh as isCraftEnvironment,Y as prerenderForCraft,Ga as processCraftComponents,Xh as processCraftDirective,Jh as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Hu as CRAFT_BRIDGE_SCRIPT,Uo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Vo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ua as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import"./chunk-000mwmfq.js";import{Fo,Va,Ua}from"./chunk-sbwvvjkc.js";import"./chunk-s7wp7a2x.js";import"./chunk-s29hp1qw.js";import"./chunk-xw291tn7.js";import"./chunk-11fxbd71.js";import"./chunk-hxhmhw23.js";import"./chunk-kvxdyg7e.js";import"./chunk-6t04tqvh.js";import"./chunk-fce8wj3t.js";import"./chunk-6zq3eh7d.js";import"./chunk-b8528fra.js";import"./chunk-zje94z0k.js";import"./chunk-5ymf5c8m.js";import"./chunk-zf29ahhd.js";import"./chunk-55kwxxm5.js";import"./chunk-pm4kn9h2.js";import"./chunk-znnvq1jp.js";import"./chunk-e1qcfesw.js";import"./chunk-qjy5yq25.js";import"./chunk-mm1eg2pg.js";import"./chunk-edysherg.js";import"./chunk-c0g30cjs.js";import"./chunk-vgsasnwm.js";import{zu,Wa,Gh,Xh,qa,zo,ps,Ka,Ga,Jh,Yh,Xa,Ja,Ya,Za}from"./chunk-p33npqjt.js";import"./chunk-c1b0fy70.js";import"./chunk-13wd9gf0.js";import"./chunk-ah6nc29h.js";import"./chunk-fepezvdq.js";import"./chunk-0hj5apb9.js";import"./chunk-52mhrbps.js";import"./chunk-7s3j8pqq.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-eq86wzhr.js";import{Vo,Ua,Wa}from"./chunk-cmg9x1ka.js";import"./chunk-whcrca58.js";import"./chunk-0jdz31q1.js";import"./chunk-xmg6bmh6.js";import"./chunk-cphc60zw.js";import"./chunk-vk2jy6mn.js";import"./chunk-3b3mkgpj.js";import"./chunk-41z7f41b.js";import"./chunk-g3vce7ka.js";import"./chunk-q0y8gv18.js";import"./chunk-8ccgty8s.js";import"./chunk-yesh4dfe.js";import"./chunk-t3zmfh8w.js";import"./chunk-rb2zbdqd.js";import"./chunk-b0hj8eg2.js";import"./chunk-adsqckg4.js";import"./chunk-6svc4kb8.js";import"./chunk-vkfw9k1n.js";import"./chunk-v90nz5xm.js";import"./chunk-vxbvrbqs.js";import"./chunk-hyyh7qxw.js";import"./chunk-05x1rd86.js";import"./chunk-pvm48tse.js";import{Hu,qa,Xh,Jh,Ka,Uo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-p0bjbtdx.js";import"./chunk-1t15z230.js";import"./chunk-vfcbz0an.js";import"./chunk-80ky40mm.js";import"./chunk-kg7vby72.js";import"./chunk-9rjgq8k4.js";import"./chunk-n6q1d66k.js";import"./chunk-qnf7w4xw.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{zu as CRAFT_BRIDGE_SCRIPT,zo as CRAFT_COMPONENTS,Ka as CRAFT_COMPONENT_RUNTIME,ps as CRAFT_COMPONENT_STYLES,Fo as NATIVE_COMPONENTS,Xa as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Va as compileToNative,Ua as createHotReloadServer,Ja as findCraftBinary,Wa as generateCraftBridgeScript,V as generateCraftOptimizations,Za as getAvailableFormats,Ya as getAvailableTargets,Yh as getCraftComponents,G as getSSRCacheStats,qa as injectCraftBridge,Gh as isCraftEnvironment,Y as prerenderForCraft,Ga as processCraftComponents,Xh as processCraftDirective,Jh as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Hu as CRAFT_BRIDGE_SCRIPT,Uo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Vo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ua as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
@@ -74,19 +74,52 @@ export function parseStringLiteral(raw) {
74
74
  if (quote !== "'" && quote !== '"' && quote !== "`" || text.length < 2 || text.at(-1) !== quote)
75
75
  return null;
76
76
  let value = "";
77
+ const escapes = { b: "\b", f: "\f", n: `
78
+ `, r: "\r", t: "\t", v: "\v", 0: "\x00" };
77
79
  for (let i = 1;i < text.length - 1; i++) {
78
80
  const char = text[i];
79
- if (char === "\\" && i + 1 < text.length - 1) {
80
- const next = text[++i];
81
- value += next === "n" ? `
82
- ` : next === "t" ? "\t" : next;
81
+ if (char === "\\") {
82
+ if (++i >= text.length - 1)
83
+ return null;
84
+ const next = text[i];
85
+ if (/[1-9]/.test(next) || next === "0" && /\d/.test(text[i + 1] ?? ""))
86
+ return null;
87
+ if (next === `
88
+ ` || next === "\u2028" || next === "\u2029")
89
+ continue;
90
+ if (next === "\r") {
91
+ if (text[i + 1] === `
92
+ `)
93
+ i++;
94
+ continue;
95
+ }
96
+ if (next === "x" || next === "u") {
97
+ const point = next === "u" && text[i + 1] === "{", end = point ? text.indexOf("}", i + 2) : i + (next === "x" ? 2 : 4) + 1, digits = text.slice(i + (point ? 2 : 1), end);
98
+ if (end < 0 || end >= text.length || !/^[\da-f]+$/i.test(digits) || !point && digits.length !== (next === "x" ? 2 : 4))
99
+ return null;
100
+ const code = Number.parseInt(digits, 16);
101
+ if (code > 1114111)
102
+ return null;
103
+ value += String.fromCodePoint(code);
104
+ i = point ? end : end - 1;
105
+ continue;
106
+ }
107
+ value += Object.hasOwn(escapes, next) ? escapes[next] : next;
83
108
  continue;
84
109
  }
85
- if (char === quote)
110
+ if (char === quote || quote !== "`" && (char === `
111
+ ` || char === "\r"))
86
112
  return null;
87
113
  if (quote === "`" && char === "$" && text[i + 1] === "{")
88
114
  return null;
89
- value += char;
115
+ if (quote === "`" && char === "\r") {
116
+ if (text[i + 1] === `
117
+ `)
118
+ i++;
119
+ value += `
120
+ `;
121
+ } else
122
+ value += char;
90
123
  }
91
124
  return value;
92
125
  }
@@ -0,0 +1,9 @@
1
+ import type { ComponentLibraryEvent } from './types.js';
2
+ export declare function parseEmitsDeclaration(code: string): EmitsDeclaration | null;
3
+ export declare interface EmitsDeclaration {
4
+ text: string
5
+ start: number
6
+ end: number
7
+ typeName?: string
8
+ events: Record<string, ComponentLibraryEvent>
9
+ }
@@ -0,0 +1,64 @@
1
+ import { macroCall } from "./component-contract.js";
2
+ import { parseStringLiteral } from "./directive-arguments.js";
3
+ import { Tokenizer } from "./parser/tokenizer.js";
4
+ import { localType, skipBalanced, splitTopLevel } from "./props-declaration.js";
5
+ function eventName(raw) {
6
+ const name = raw.trim();
7
+ return /^[A-Za-z_$][\w$]*$/.test(name) ? name : parseStringLiteral(name) ?? void 0;
8
+ }
9
+ function detailFromTuple(tuple) {
10
+ const members = splitTopLevel(tuple.trim().slice(1, -1), ",", !0);
11
+ if (members.length !== 1)
12
+ return tuple.trim();
13
+ const member = members[0];
14
+ if (member.startsWith("..."))
15
+ return tuple.trim();
16
+ const labelled = /^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(member), optional = labelled ? !!labelled[1] : member.endsWith("?"), type = labelled ? labelled[2] : optional ? member.slice(0, -1).trim() : member;
17
+ return optional ? `(${type}) | undefined | []` : type;
18
+ }
19
+ export function parseEmitsDeclaration(code) {
20
+ const call = macroCall(code, ["defineEmits"], !0);
21
+ if (!call)
22
+ return null;
23
+ const events = Object.create(null), typeName = /^[A-Za-z_$][\w$]*$/.test(call.type.trim()) ? call.type.trim() : void 0, type = typeName ? localType(code, typeName) : call.type.trim();
24
+ if (type?.startsWith("{"))
25
+ for (const member of splitTopLevel(type.slice(1, -1), `;,
26
+ `, !0)) {
27
+ if (member.startsWith("(")) {
28
+ const end = skipBalanced(member, 0, "(", ")");
29
+ if (end < 0)
30
+ continue;
31
+ const parameters = splitTopLevel(member.slice(1, end - 1), ",", !0), first = parameters.shift() || "", colon = first.indexOf(":");
32
+ if (colon < 0)
33
+ continue;
34
+ for (const literal of splitTopLevel(first.slice(colon + 1), "|", !0)) {
35
+ const name = eventName(literal);
36
+ if (name !== void 0)
37
+ events[name] = { detailType: detailFromTuple(`[${parameters.join(", ")}]`) };
38
+ }
39
+ continue;
40
+ }
41
+ const tokens = new Tokenizer(member, "javascript").tokenize().filter((token) => !["WHITESPACE", "COMMENT", "EOF"].includes(token.type)), key = tokens[0], colon = tokens.findIndex((token) => token.value === ":");
42
+ if (!key || colon < 0)
43
+ continue;
44
+ const name = eventName(key.value), value = member.slice(tokens[colon].end).trim();
45
+ if (name !== void 0)
46
+ events[name] = { detailType: value.startsWith("[") ? detailFromTuple(value) : value };
47
+ }
48
+ else {
49
+ const argument = call.args[0]?.trim() || "";
50
+ if (argument.startsWith("["))
51
+ for (const item of splitTopLevel(argument.slice(1, -1), ",", !1)) {
52
+ const name = eventName(item);
53
+ if (name !== void 0)
54
+ events[name] = { detailType: "unknown" };
55
+ }
56
+ else if (argument.startsWith("{"))
57
+ for (const member of splitTopLevel(argument.slice(1, -1), ",", !1)) {
58
+ const key = new Tokenizer(member, "javascript").tokenize().find((token) => !["WHITESPACE", "COMMENT"].includes(token.type)), name = key && eventName(key.value);
59
+ if (name !== void 0)
60
+ events[name] = { detailType: "unknown" };
61
+ }
62
+ }
63
+ return { ...call, text: code.slice(call.start, call.end), typeName, events };
64
+ }
@@ -63,7 +63,8 @@ export declare class Tokenizer {
63
63
  private line;
64
64
  private column;
65
65
  private tokens;
66
- constructor(source: string);
66
+ private context;
67
+ constructor(source: string, context?: 'template' | 'javascript');
67
68
  tokenize(): Token[];
68
69
  private nextToken;
69
70
  private readWhitespace;
@@ -1,10 +1,12 @@
1
1
  export class Tokenizer {
2
+ context;
2
3
  source;
3
4
  pos = 0;
4
5
  line = 1;
5
6
  column = 0;
6
7
  tokens = [];
7
- constructor(source) {
8
+ constructor(source, context = "template") {
9
+ this.context = context;
8
10
  this.source = source;
9
11
  }
10
12
  tokenize() {
@@ -45,7 +47,7 @@ export class Tokenizer {
45
47
  return this.readNumber(start, startLine, startColumn);
46
48
  if (/[a-z_$]/i.test(char))
47
49
  return this.readIdentifier(start, startLine, startColumn);
48
- if (char === "{") {
50
+ if (this.context === "template" && char === "{") {
49
51
  if (this.peek(1) === "{" && this.peek(2) === "{") {
50
52
  this.advance(3);
51
53
  return { type: "RAW_START", value: "{{{", start, end: this.pos, line: startLine, column: startColumn };
@@ -59,7 +61,7 @@ export class Tokenizer {
59
61
  return { type: "RAW_START", value: "{!!", start, end: this.pos, line: startLine, column: startColumn };
60
62
  }
61
63
  }
62
- if (char === "}") {
64
+ if (this.context === "template" && char === "}") {
63
65
  if (this.peek(1) === "}" && this.peek(2) === "}") {
64
66
  this.advance(3);
65
67
  return { type: "RAW_END", value: "}}}", start, end: this.pos, line: startLine, column: startColumn };
@@ -69,7 +71,7 @@ export class Tokenizer {
69
71
  return { type: "EXPRESSION_END", value: "}}", start, end: this.pos, line: startLine, column: startColumn };
70
72
  }
71
73
  }
72
- if (char === "!" && this.peek(1) === "!" && this.peek(2) === "}") {
74
+ if (this.context === "template" && char === "!" && this.peek(1) === "!" && this.peek(2) === "}") {
73
75
  this.advance(3);
74
76
  return { type: "RAW_END", value: "!!}", start, end: this.pos, line: startLine, column: startColumn };
75
77
  }
@@ -249,7 +251,7 @@ export class Tokenizer {
249
251
  }
250
252
  while (this.pos < this.source.length && /[\d_]/.test(this.source[this.pos]))
251
253
  this.advance();
252
- if (this.source[this.pos] === "." && /\d/.test(this.peek(1) || "")) {
254
+ if (this.source[this.pos] === "." && (this.context === "javascript" || /\d/.test(this.peek(1) || ""))) {
253
255
  this.advance();
254
256
  while (this.pos < this.source.length && /[\d_]/.test(this.source[this.pos]))
255
257
  this.advance();
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The index just past a balanced bracket pair starting at `index`, or -1 when
3
+ * it never closes.
4
+ *
5
+ * Quotes and template literals are skipped, so a bracket inside a string
6
+ * default does not unbalance the scan.
7
+ */
8
+ export declare function skipBalanced(source: string, index: number, open: string, close: string): number;
9
+ /**
10
+ * Split a list on separators that are not nested inside brackets or quotes.
11
+ *
12
+ * `angles` decides whether `<` and `>` nest. They must in a type literal, so
13
+ * `Array<string, number>` stays one member, and must NOT in a value, where
14
+ * `>` is a comparison and `=>` an arrow and counting either unbalances
15
+ * everything after it.
16
+ */
17
+ export declare function splitTopLevel(body: string, separators: string, angles: boolean): string[];
18
+ /**
19
+ * Read a `defineProps` declaration, in every form it is written
20
+ * (stacksjs/stx#2009).
21
+ *
22
+ * This used to be one regex that required a destructuring assignment AND an
23
+ * explicit type argument, so four of the five documented spellings produced no
24
+ * properties at all and the component silently had no public surface. The one
25
+ * that did match split its names on `:` only, so
26
+ *
27
+ * const { label = 'Hello' } = defineProps<{ label?: string }>()
28
+ *
29
+ * produced a property literally named `label = 'Hello'`, documented as the
30
+ * attribute `label-hello`, and nothing a page wrote as `label="x"` ever
31
+ * arrived. That is worse than not reading it, because it looks like it worked.
32
+ *
33
+ * Handled here:
34
+ *
35
+ * const { a, b = 1 } = defineProps<{ a?: string, b?: number }>()
36
+ * const { a } = defineProps(['a'])
37
+ * const props = defineProps<{ a?: string }>()
38
+ * const props = defineProps<Props>()
39
+ * const props = withDefaults(defineProps<{ a?: string }>(), { a: 'x' })
40
+ * const props = defineProps({ a: { type: String, default: 'x' } })
41
+ *
42
+ * Names come from the destructuring pattern when there is one, since that is
43
+ * the author naming them, and otherwise from whichever of the type literal,
44
+ * the object form or the array form is present. Types come from the type
45
+ * literal or the object form's `type:`, never inferred from a default: a
46
+ * `title?: string` with no default was being typed as an object, and the
47
+ * attribute `"Revenue"` was then JSON-parsed, failed, and reached the page as
48
+ * `[object Object]`.
49
+ */
50
+ export declare function parsePropsDeclaration(source: string): PropsDeclaration | null;
51
+ export declare function parseDefaults(object: string): Array<[string, string]>;
52
+ /** Literal defaults only: no client functions, imports, identifiers or getters run in SSR. */
53
+ export declare function literalValue(source: string): unknown;
54
+ /** Resolve local macro-support types with the same balanced scanner as props. */
55
+ export declare function localType(code: string, name: string): string | undefined;
56
+ declare interface PropsDeclaration {
57
+ text: string
58
+ propNames: string[]
59
+ propBindings: Record<string, string>
60
+ localBindings: Record<string, string>
61
+ defaults: Record<string, string>
62
+ declared: Record<string, string>
63
+ typeName?: string
64
+ identifier?: string
65
+ }
66
+ export {};