@ecopages/radiant 0.3.0-alpha.4 → 0.3.0-alpha.5

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 (450) hide show
  1. package/README.md +66 -56
  2. package/dist/LICENSE +21 -0
  3. package/dist/client/hydrator.d.ts +1 -1
  4. package/dist/client/hydrator.js +2 -2
  5. package/dist/client/hydrator.js.map +5 -3
  6. package/dist/client/install-hydrator.js +2 -2
  7. package/dist/client/install-hydrator.js.map +5 -3
  8. package/dist/context/context-consumer-bootstrap.d.ts +7 -6
  9. package/dist/context/context-consumer-bootstrap.js +2 -2
  10. package/dist/context/context-consumer-bootstrap.js.map +8 -3
  11. package/dist/context/context-consumer-runtime.d.ts +21 -8
  12. package/dist/context/context-consumer-runtime.js +2 -2
  13. package/dist/context/context-consumer-runtime.js.map +6 -3
  14. package/dist/context/context-host.d.ts +25 -0
  15. package/dist/context/context-host.js +3 -0
  16. package/dist/context/context-host.js.map +10 -0
  17. package/dist/context/context-provider.d.ts +10 -6
  18. package/dist/context/context-provider.js +2 -2
  19. package/dist/context/context-provider.js.map +9 -3
  20. package/dist/context/context-ssr-bridge.js +2 -2
  21. package/dist/context/context-ssr-bridge.js.map +4 -3
  22. package/dist/context/create-context.js +2 -2
  23. package/dist/context/create-context.js.map +4 -3
  24. package/dist/context/decorators/consume-context.d.ts +5 -2
  25. package/dist/context/decorators/consume-context.js +2 -2
  26. package/dist/context/decorators/consume-context.js.map +13 -3
  27. package/dist/context/decorators/context-selection-delivery.d.ts +1 -1
  28. package/dist/context/decorators/context-selection-delivery.js +2 -2
  29. package/dist/context/decorators/context-selection-delivery.js.map +5 -3
  30. package/dist/context/decorators/context-selector.d.ts +6 -6
  31. package/dist/context/decorators/context-selector.js +2 -2
  32. package/dist/context/decorators/context-selector.js.map +15 -3
  33. package/dist/context/decorators/legacy/consume-context.d.ts +2 -2
  34. package/dist/context/decorators/legacy/consume-context.js +2 -2
  35. package/dist/context/decorators/legacy/consume-context.js.map +10 -3
  36. package/dist/context/decorators/legacy/context-selector-field.d.ts +2 -2
  37. package/dist/context/decorators/legacy/context-selector-field.js +2 -2
  38. package/dist/context/decorators/legacy/context-selector-field.js.map +11 -3
  39. package/dist/context/decorators/legacy/context-selector.d.ts +2 -2
  40. package/dist/context/decorators/legacy/context-selector.js +2 -2
  41. package/dist/context/decorators/legacy/context-selector.js.map +11 -3
  42. package/dist/context/decorators/legacy/provide-context.d.ts +2 -2
  43. package/dist/context/decorators/legacy/provide-context.js +2 -2
  44. package/dist/context/decorators/legacy/provide-context.js.map +11 -3
  45. package/dist/context/decorators/on-context-update.d.ts +5 -5
  46. package/dist/context/decorators/on-context-update.js +2 -2
  47. package/dist/context/decorators/on-context-update.js.map +14 -3
  48. package/dist/context/decorators/provide-context.d.ts +5 -2
  49. package/dist/context/decorators/provide-context.js +2 -2
  50. package/dist/context/decorators/provide-context.js.map +14 -3
  51. package/dist/context/decorators/standard/consume-context.d.ts +2 -2
  52. package/dist/context/decorators/standard/consume-context.js +2 -2
  53. package/dist/context/decorators/standard/consume-context.js.map +9 -3
  54. package/dist/context/decorators/standard/context-selector-field.d.ts +2 -2
  55. package/dist/context/decorators/standard/context-selector-field.js +2 -2
  56. package/dist/context/decorators/standard/context-selector-field.js.map +10 -3
  57. package/dist/context/decorators/standard/context-selector.d.ts +2 -3
  58. package/dist/context/decorators/standard/context-selector.js +2 -2
  59. package/dist/context/decorators/standard/context-selector.js.map +10 -3
  60. package/dist/context/decorators/standard/provide-context.d.ts +2 -2
  61. package/dist/context/decorators/standard/provide-context.js +2 -2
  62. package/dist/context/decorators/standard/provide-context.js.map +10 -3
  63. package/dist/context/events.d.ts +18 -11
  64. package/dist/context/events.js +2 -2
  65. package/dist/context/events.js.map +4 -3
  66. package/dist/context/hydration-script.js +2 -2
  67. package/dist/context/hydration-script.js.map +6 -3
  68. package/dist/controller-registry.d.ts +28 -0
  69. package/dist/controller-registry.js +3 -0
  70. package/dist/controller-registry.js.map +11 -0
  71. package/dist/core/controller-metadata.d.ts +3 -0
  72. package/dist/core/controller-metadata.js +3 -0
  73. package/dist/core/controller-metadata.js.map +10 -0
  74. package/dist/core/custom-element-metadata.d.ts +11 -0
  75. package/dist/core/custom-element-metadata.js +2 -2
  76. package/dist/core/custom-element-metadata.js.map +4 -3
  77. package/dist/core/hydration-codec.d.ts +8 -1
  78. package/dist/core/hydration-codec.js +2 -2
  79. package/dist/core/hydration-codec.js.map +5 -3
  80. package/dist/core/radiant-component-ssr-registry.d.ts +13 -13
  81. package/dist/core/radiant-component-ssr-registry.js +2 -2
  82. package/dist/core/radiant-component-ssr-registry.js.map +4 -3
  83. package/dist/core/radiant-component-ssr.d.ts +3 -3
  84. package/dist/core/radiant-component-ssr.js +2 -2
  85. package/dist/core/radiant-component-ssr.js.map +8 -3
  86. package/dist/core/radiant-controller.d.ts +127 -0
  87. package/dist/core/radiant-controller.js +3 -0
  88. package/dist/core/radiant-controller.js.map +13 -0
  89. package/dist/core/radiant-element.d.ts +43 -41
  90. package/dist/core/radiant-element.js +2 -2
  91. package/dist/core/radiant-element.js.map +13 -3
  92. package/dist/core/radiant-hydrator-state.d.ts +1 -1
  93. package/dist/core/radiant-hydrator-state.js +2 -2
  94. package/dist/core/radiant-hydrator-state.js.map +4 -3
  95. package/dist/core/reactive-host.d.ts +137 -0
  96. package/dist/core/reactive-host.js +3 -0
  97. package/dist/core/reactive-host.js.map +10 -0
  98. package/dist/core/reactive-jsx-value.js +2 -2
  99. package/dist/core/reactive-jsx-value.js.map +4 -3
  100. package/dist/core/reactive-prop-metadata.js +2 -2
  101. package/dist/core/reactive-prop-metadata.js.map +4 -3
  102. package/dist/core/slot-projection-runtime.js +2 -2
  103. package/dist/core/slot-projection-runtime.js.map +6 -3
  104. package/dist/core/ssr-preparation.js +2 -2
  105. package/dist/core/ssr-preparation.js.map +4 -3
  106. package/dist/decorators/attr.d.ts +6 -0
  107. package/dist/decorators/attr.js +3 -0
  108. package/dist/decorators/attr.js.map +16 -0
  109. package/dist/decorators/bound.d.ts +4 -2
  110. package/dist/decorators/bound.js +2 -2
  111. package/dist/decorators/bound.js.map +7 -3
  112. package/dist/decorators/bridge.d.ts +11 -7
  113. package/dist/decorators/bridge.js +2 -2
  114. package/dist/decorators/bridge.js.map +4 -3
  115. package/dist/decorators/controller.d.ts +2 -0
  116. package/dist/decorators/controller.js +3 -0
  117. package/dist/decorators/controller.js.map +12 -0
  118. package/dist/decorators/custom-element.d.ts +4 -2
  119. package/dist/decorators/custom-element.js +2 -2
  120. package/dist/decorators/custom-element.js.map +7 -3
  121. package/dist/decorators/debounce.d.ts +5 -2
  122. package/dist/decorators/debounce.js +2 -2
  123. package/dist/decorators/debounce.js.map +8 -3
  124. package/dist/decorators/event.d.ts +5 -2
  125. package/dist/decorators/event.js +2 -2
  126. package/dist/decorators/event.js.map +10 -3
  127. package/dist/decorators/legacy/attr.d.ts +2 -0
  128. package/dist/decorators/legacy/attr.js +3 -0
  129. package/dist/decorators/legacy/attr.js.map +13 -0
  130. package/dist/decorators/legacy/bound.js +2 -2
  131. package/dist/decorators/legacy/bound.js.map +4 -3
  132. package/dist/decorators/legacy/custom-element.js +2 -2
  133. package/dist/decorators/legacy/custom-element.js.map +5 -3
  134. package/dist/decorators/legacy/debounce.js +2 -2
  135. package/dist/decorators/legacy/debounce.js.map +5 -3
  136. package/dist/decorators/legacy/event.js +2 -2
  137. package/dist/decorators/legacy/event.js.map +7 -3
  138. package/dist/decorators/legacy/instance-initializers.d.ts +3 -4
  139. package/dist/decorators/legacy/instance-initializers.js +2 -2
  140. package/dist/decorators/legacy/instance-initializers.js.map +4 -3
  141. package/dist/decorators/legacy/on-event.d.ts +2 -2
  142. package/dist/decorators/legacy/on-event.js +2 -2
  143. package/dist/decorators/legacy/on-event.js.map +6 -3
  144. package/dist/decorators/legacy/on-updated.d.ts +7 -2
  145. package/dist/decorators/legacy/on-updated.js +2 -2
  146. package/dist/decorators/legacy/on-updated.js.map +5 -3
  147. package/dist/decorators/legacy/query-slot.js +2 -2
  148. package/dist/decorators/legacy/query-slot.js.map +7 -3
  149. package/dist/decorators/legacy/query.d.ts +7 -2
  150. package/dist/decorators/legacy/query.js +2 -2
  151. package/dist/decorators/legacy/query.js.map +6 -3
  152. package/dist/decorators/legacy/reactive-field.d.ts +2 -2
  153. package/dist/decorators/legacy/reactive-field.js +2 -2
  154. package/dist/decorators/legacy/reactive-field.js.map +5 -3
  155. package/dist/decorators/legacy/reactive-prop.d.ts +10 -16
  156. package/dist/decorators/legacy/reactive-prop.js +2 -2
  157. package/dist/decorators/legacy/reactive-prop.js.map +7 -3
  158. package/dist/decorators/legacy/signal.d.ts +4 -3
  159. package/dist/decorators/legacy/signal.js +2 -2
  160. package/dist/decorators/legacy/signal.js.map +9 -3
  161. package/dist/decorators/on-event.d.ts +6 -3
  162. package/dist/decorators/on-event.js +2 -2
  163. package/dist/decorators/on-event.js.map +9 -3
  164. package/dist/decorators/on-updated.d.ts +12 -2
  165. package/dist/decorators/on-updated.js +2 -2
  166. package/dist/decorators/on-updated.js.map +8 -3
  167. package/dist/decorators/prop.d.ts +19 -7
  168. package/dist/decorators/prop.js +2 -2
  169. package/dist/decorators/prop.js.map +10 -3
  170. package/dist/decorators/query-slot.d.ts +11 -3
  171. package/dist/decorators/query-slot.js +2 -2
  172. package/dist/decorators/query-slot.js.map +10 -3
  173. package/dist/decorators/query.d.ts +9 -2
  174. package/dist/decorators/query.js +2 -2
  175. package/dist/decorators/query.js.map +9 -3
  176. package/dist/decorators/shared/reactive-attr.d.ts +25 -0
  177. package/dist/decorators/shared/reactive-attr.js +3 -0
  178. package/dist/decorators/shared/reactive-attr.js.map +11 -0
  179. package/dist/decorators/signal.d.ts +10 -4
  180. package/dist/decorators/signal.js +2 -2
  181. package/dist/decorators/signal.js.map +11 -3
  182. package/dist/decorators/standard/attr.d.ts +2 -0
  183. package/dist/decorators/standard/attr.js +3 -0
  184. package/dist/decorators/standard/attr.js.map +12 -0
  185. package/dist/decorators/standard/bound.js +2 -2
  186. package/dist/decorators/standard/bound.js.map +4 -3
  187. package/dist/decorators/standard/custom-element.js +2 -2
  188. package/dist/decorators/standard/custom-element.js.map +5 -3
  189. package/dist/decorators/standard/debounce.js +2 -2
  190. package/dist/decorators/standard/debounce.js.map +5 -3
  191. package/dist/decorators/standard/event.js +2 -2
  192. package/dist/decorators/standard/event.js.map +6 -3
  193. package/dist/decorators/standard/on-event.d.ts +2 -1
  194. package/dist/decorators/standard/on-event.js +2 -2
  195. package/dist/decorators/standard/on-event.js.map +5 -3
  196. package/dist/decorators/standard/on-updated.d.ts +5 -1
  197. package/dist/decorators/standard/on-updated.js +2 -2
  198. package/dist/decorators/standard/on-updated.js.map +4 -3
  199. package/dist/decorators/standard/query-slot.d.ts +1 -1
  200. package/dist/decorators/standard/query-slot.js +2 -2
  201. package/dist/decorators/standard/query-slot.js.map +5 -3
  202. package/dist/decorators/standard/query.d.ts +2 -1
  203. package/dist/decorators/standard/query.js +2 -2
  204. package/dist/decorators/standard/query.js.map +5 -3
  205. package/dist/decorators/standard/reactive-field.d.ts +2 -2
  206. package/dist/decorators/standard/reactive-field.js +2 -2
  207. package/dist/decorators/standard/reactive-field.js.map +4 -3
  208. package/dist/decorators/standard/reactive-prop.d.ts +13 -2
  209. package/dist/decorators/standard/reactive-prop.js +2 -2
  210. package/dist/decorators/standard/reactive-prop.js.map +6 -3
  211. package/dist/decorators/standard/signal.d.ts +4 -3
  212. package/dist/decorators/standard/signal.js +2 -2
  213. package/dist/decorators/standard/signal.js.map +8 -3
  214. package/dist/decorators/state.d.ts +6 -5
  215. package/dist/decorators/state.js +2 -2
  216. package/dist/decorators/state.js.map +8 -3
  217. package/dist/helpers/create-event-listener.d.ts +11 -2
  218. package/dist/helpers/create-event-listener.js +2 -2
  219. package/dist/helpers/create-event-listener.js.map +4 -3
  220. package/dist/helpers/create-event.js +2 -2
  221. package/dist/helpers/create-event.js.map +5 -3
  222. package/dist/helpers/create-query-slot.js +2 -2
  223. package/dist/helpers/create-query-slot.js.map +4 -3
  224. package/dist/helpers/create-query.d.ts +14 -3
  225. package/dist/helpers/create-query.js +2 -2
  226. package/dist/helpers/create-query.js.map +4 -3
  227. package/dist/helpers/debounce.js +2 -2
  228. package/dist/helpers/debounce.js.map +4 -3
  229. package/dist/helpers/index.js +2 -2
  230. package/dist/helpers/index.js.map +9 -3
  231. package/dist/index.d.ts +11 -12
  232. package/dist/index.js +2 -2
  233. package/dist/index.js.map +87 -3
  234. package/dist/server/context-ssr.js +2 -2
  235. package/dist/server/context-ssr.js.map +5 -3
  236. package/dist/server/html-parser.js +2 -2
  237. package/dist/server/html-parser.js.map +4 -3
  238. package/dist/server/install-light-dom-shim.js +2 -2
  239. package/dist/server/install-light-dom-shim.js.map +5 -3
  240. package/dist/server/light-dom-shim.js +2 -2
  241. package/dist/server/light-dom-shim.js.map +5 -3
  242. package/dist/server/project-root.js +2 -2
  243. package/dist/server/project-root.js.map +2 -2
  244. package/dist/server/radiant-component-ssr-runtime.d.ts +2 -2
  245. package/dist/server/radiant-component-ssr-runtime.js +2 -2
  246. package/dist/server/radiant-component-ssr-runtime.js.map +11 -3
  247. package/dist/server/render-component.d.ts +3 -13
  248. package/dist/server/render-component.js +2 -2
  249. package/dist/server/render-component.js.map +14 -4
  250. package/dist/server/render-controller.d.ts +57 -0
  251. package/dist/server/render-controller.js +3 -0
  252. package/dist/server/render-controller.js.map +23 -0
  253. package/dist/server/slot-projection-html.js +2 -2
  254. package/dist/server/slot-projection-html.js.map +7 -3
  255. package/dist/signals/host-resource.js +2 -2
  256. package/dist/signals/host-resource.js.map +2 -2
  257. package/dist/signals/host-signal.d.ts +4 -2
  258. package/dist/signals/host-signal.js +2 -2
  259. package/dist/signals/host-signal.js.map +7 -3
  260. package/dist/signals/hydration-script.js +2 -2
  261. package/dist/signals/hydration-script.js.map +6 -3
  262. package/dist/tools/escape-script-json.js +2 -2
  263. package/dist/tools/escape-script-json.js.map +4 -3
  264. package/dist/tools/event-emitter.js +2 -2
  265. package/dist/tools/event-emitter.js.map +4 -3
  266. package/dist/tools/index.js +2 -2
  267. package/dist/tools/index.js.map +7 -3
  268. package/dist/tools/render-jsx-template.js +2 -2
  269. package/dist/tools/render-jsx-template.js.map +4 -3
  270. package/dist/tools/stringify-typed.js +2 -2
  271. package/dist/tools/stringify-typed.js.map +4 -3
  272. package/dist/types.js +2 -2
  273. package/dist/types.js.map +2 -2
  274. package/dist/utils/attribute-utils.js +2 -2
  275. package/dist/utils/attribute-utils.js.map +4 -3
  276. package/dist/utils/index.js +2 -2
  277. package/dist/utils/index.js.map +4 -3
  278. package/package.json +22 -5
  279. package/size-budget.json +11 -2
  280. package/dist/chunk-0bswvy25.js +0 -4
  281. package/dist/chunk-0bswvy25.js.map +0 -10
  282. package/dist/chunk-0btkzzyc.js +0 -4
  283. package/dist/chunk-0btkzzyc.js.map +0 -10
  284. package/dist/chunk-0g0j9re6.js +0 -4
  285. package/dist/chunk-0g0j9re6.js.map +0 -10
  286. package/dist/chunk-1x26p09c.js +0 -4
  287. package/dist/chunk-1x26p09c.js.map +0 -10
  288. package/dist/chunk-21a7jask.js +0 -4
  289. package/dist/chunk-21a7jask.js.map +0 -10
  290. package/dist/chunk-21acj2eq.js +0 -4
  291. package/dist/chunk-21acj2eq.js.map +0 -10
  292. package/dist/chunk-25zjh0kg.js +0 -4
  293. package/dist/chunk-25zjh0kg.js.map +0 -10
  294. package/dist/chunk-30x4hggg.js +0 -4
  295. package/dist/chunk-30x4hggg.js.map +0 -10
  296. package/dist/chunk-3ynk7e1e.js +0 -4
  297. package/dist/chunk-3ynk7e1e.js.map +0 -10
  298. package/dist/chunk-5b1en9vz.js +0 -4
  299. package/dist/chunk-5b1en9vz.js.map +0 -10
  300. package/dist/chunk-5bkat72n.js +0 -4
  301. package/dist/chunk-5bkat72n.js.map +0 -10
  302. package/dist/chunk-5qeaq3tj.js +0 -4
  303. package/dist/chunk-5qeaq3tj.js.map +0 -10
  304. package/dist/chunk-66e6s792.js +0 -4
  305. package/dist/chunk-66e6s792.js.map +0 -10
  306. package/dist/chunk-79jg8q67.js +0 -4
  307. package/dist/chunk-79jg8q67.js.map +0 -10
  308. package/dist/chunk-8d5ddvvf.js +0 -4
  309. package/dist/chunk-8d5ddvvf.js.map +0 -10
  310. package/dist/chunk-8e9fgtbn.js +0 -4
  311. package/dist/chunk-8e9fgtbn.js.map +0 -10
  312. package/dist/chunk-9mqtp3js.js +0 -4
  313. package/dist/chunk-9mqtp3js.js.map +0 -10
  314. package/dist/chunk-9rj2rwes.js +0 -4
  315. package/dist/chunk-9rj2rwes.js.map +0 -10
  316. package/dist/chunk-atms6yrh.js +0 -4
  317. package/dist/chunk-atms6yrh.js.map +0 -10
  318. package/dist/chunk-bk2nbmcd.js +0 -4
  319. package/dist/chunk-bk2nbmcd.js.map +0 -10
  320. package/dist/chunk-bk6qkvfp.js +0 -4
  321. package/dist/chunk-bk6qkvfp.js.map +0 -10
  322. package/dist/chunk-c0qyz98c.js +0 -4
  323. package/dist/chunk-c0qyz98c.js.map +0 -10
  324. package/dist/chunk-c52qhh0j.js +0 -4
  325. package/dist/chunk-c52qhh0j.js.map +0 -10
  326. package/dist/chunk-cnyxrh9r.js +0 -4
  327. package/dist/chunk-cnyxrh9r.js.map +0 -10
  328. package/dist/chunk-cvz9mrxa.js +0 -4
  329. package/dist/chunk-cvz9mrxa.js.map +0 -10
  330. package/dist/chunk-dabagjk6.js +0 -4
  331. package/dist/chunk-dabagjk6.js.map +0 -10
  332. package/dist/chunk-e0r6ca2g.js +0 -4
  333. package/dist/chunk-e0r6ca2g.js.map +0 -10
  334. package/dist/chunk-e5jd9h6t.js +0 -4
  335. package/dist/chunk-e5jd9h6t.js.map +0 -10
  336. package/dist/chunk-eevw1j2q.js +0 -4
  337. package/dist/chunk-eevw1j2q.js.map +0 -10
  338. package/dist/chunk-ek664x1c.js +0 -4
  339. package/dist/chunk-ek664x1c.js.map +0 -10
  340. package/dist/chunk-eyw14d6y.js +0 -4
  341. package/dist/chunk-eyw14d6y.js.map +0 -10
  342. package/dist/chunk-fs4j94bk.js +0 -4
  343. package/dist/chunk-fs4j94bk.js.map +0 -10
  344. package/dist/chunk-g2z3mm6b.js +0 -4
  345. package/dist/chunk-g2z3mm6b.js.map +0 -10
  346. package/dist/chunk-g5n3m11h.js +0 -4
  347. package/dist/chunk-g5n3m11h.js.map +0 -10
  348. package/dist/chunk-gdkte2vd.js +0 -4
  349. package/dist/chunk-gdkte2vd.js.map +0 -10
  350. package/dist/chunk-gg74gdpv.js +0 -4
  351. package/dist/chunk-gg74gdpv.js.map +0 -10
  352. package/dist/chunk-gpv1n74a.js +0 -4
  353. package/dist/chunk-gpv1n74a.js.map +0 -10
  354. package/dist/chunk-h9k7crjc.js +0 -4
  355. package/dist/chunk-h9k7crjc.js.map +0 -10
  356. package/dist/chunk-hpzgnxgq.js +0 -4
  357. package/dist/chunk-hpzgnxgq.js.map +0 -10
  358. package/dist/chunk-hrjc8b1y.js +0 -4
  359. package/dist/chunk-hrjc8b1y.js.map +0 -10
  360. package/dist/chunk-hvy4zvcc.js +0 -4
  361. package/dist/chunk-hvy4zvcc.js.map +0 -10
  362. package/dist/chunk-hztr86b4.js +0 -4
  363. package/dist/chunk-hztr86b4.js.map +0 -10
  364. package/dist/chunk-j3v7rca5.js +0 -4
  365. package/dist/chunk-j3v7rca5.js.map +0 -10
  366. package/dist/chunk-j864sv4w.js +0 -4
  367. package/dist/chunk-j864sv4w.js.map +0 -10
  368. package/dist/chunk-jkb2y7c8.js +0 -4
  369. package/dist/chunk-jkb2y7c8.js.map +0 -10
  370. package/dist/chunk-kakpjgzf.js +0 -4
  371. package/dist/chunk-kakpjgzf.js.map +0 -10
  372. package/dist/chunk-kmebacvv.js +0 -4
  373. package/dist/chunk-kmebacvv.js.map +0 -10
  374. package/dist/chunk-knqsm6v3.js +0 -4
  375. package/dist/chunk-knqsm6v3.js.map +0 -10
  376. package/dist/chunk-mp2vtrkg.js +0 -4
  377. package/dist/chunk-mp2vtrkg.js.map +0 -10
  378. package/dist/chunk-mpsj3cjs.js +0 -4
  379. package/dist/chunk-mpsj3cjs.js.map +0 -10
  380. package/dist/chunk-n4p2542b.js +0 -4
  381. package/dist/chunk-n4p2542b.js.map +0 -10
  382. package/dist/chunk-nctznxyz.js +0 -4
  383. package/dist/chunk-nctznxyz.js.map +0 -10
  384. package/dist/chunk-ndw3hc3v.js +0 -4
  385. package/dist/chunk-ndw3hc3v.js.map +0 -10
  386. package/dist/chunk-nnnb6pac.js +0 -4
  387. package/dist/chunk-nnnb6pac.js.map +0 -10
  388. package/dist/chunk-nssj2x13.js +0 -4
  389. package/dist/chunk-nssj2x13.js.map +0 -10
  390. package/dist/chunk-nvr37vma.js +0 -4
  391. package/dist/chunk-nvr37vma.js.map +0 -10
  392. package/dist/chunk-p8k4g99a.js +0 -4
  393. package/dist/chunk-p8k4g99a.js.map +0 -10
  394. package/dist/chunk-pkszgjqf.js +0 -4
  395. package/dist/chunk-pkszgjqf.js.map +0 -10
  396. package/dist/chunk-q9z6tnzw.js +0 -4
  397. package/dist/chunk-q9z6tnzw.js.map +0 -10
  398. package/dist/chunk-qdz5sncz.js +0 -4
  399. package/dist/chunk-qdz5sncz.js.map +0 -10
  400. package/dist/chunk-qe0eww1n.js +0 -4
  401. package/dist/chunk-qe0eww1n.js.map +0 -10
  402. package/dist/chunk-r33zvvda.js +0 -4
  403. package/dist/chunk-r33zvvda.js.map +0 -10
  404. package/dist/chunk-rkh1vkb9.js +0 -4
  405. package/dist/chunk-rkh1vkb9.js.map +0 -10
  406. package/dist/chunk-rrg759ht.js +0 -4
  407. package/dist/chunk-rrg759ht.js.map +0 -10
  408. package/dist/chunk-s09s5ayx.js +0 -4
  409. package/dist/chunk-s09s5ayx.js.map +0 -10
  410. package/dist/chunk-sf4a2gy5.js +0 -4
  411. package/dist/chunk-sf4a2gy5.js.map +0 -10
  412. package/dist/chunk-ssnnxzrj.js +0 -4
  413. package/dist/chunk-ssnnxzrj.js.map +0 -10
  414. package/dist/chunk-t8xtvgyg.js +0 -4
  415. package/dist/chunk-t8xtvgyg.js.map +0 -10
  416. package/dist/chunk-v3ta7hnv.js +0 -4
  417. package/dist/chunk-v3ta7hnv.js.map +0 -10
  418. package/dist/chunk-v92hp9g0.js +0 -4
  419. package/dist/chunk-v92hp9g0.js.map +0 -10
  420. package/dist/chunk-vgtggzb6.js +0 -4
  421. package/dist/chunk-vgtggzb6.js.map +0 -9
  422. package/dist/chunk-vk48hgm4.js +0 -4
  423. package/dist/chunk-vk48hgm4.js.map +0 -10
  424. package/dist/chunk-w8s5fnsq.js +0 -4
  425. package/dist/chunk-w8s5fnsq.js.map +0 -10
  426. package/dist/chunk-wd23rn4q.js +0 -4
  427. package/dist/chunk-wd23rn4q.js.map +0 -10
  428. package/dist/chunk-wds4href.js +0 -4
  429. package/dist/chunk-wds4href.js.map +0 -10
  430. package/dist/chunk-wvd1ffe4.js +0 -4
  431. package/dist/chunk-wvd1ffe4.js.map +0 -10
  432. package/dist/chunk-wwbjz9k4.js +0 -4
  433. package/dist/chunk-wwbjz9k4.js.map +0 -10
  434. package/dist/chunk-x2k0ngpz.js +0 -4
  435. package/dist/chunk-x2k0ngpz.js.map +0 -10
  436. package/dist/chunk-x457d0ap.js +0 -4
  437. package/dist/chunk-x457d0ap.js.map +0 -10
  438. package/dist/chunk-xbhtzkre.js +0 -4
  439. package/dist/chunk-xbhtzkre.js.map +0 -10
  440. package/dist/chunk-y139ycfm.js +0 -4
  441. package/dist/chunk-y139ycfm.js.map +0 -10
  442. package/dist/chunk-z9kxfckm.js +0 -4
  443. package/dist/chunk-z9kxfckm.js.map +0 -10
  444. package/dist/chunk-zx5txex8.js +0 -4
  445. package/dist/chunk-zx5txex8.js.map +0 -10
  446. package/dist/chunk-zygdebw8.js +0 -4
  447. package/dist/chunk-zygdebw8.js.map +0 -10
  448. package/dist/core/radiant-component.d.ts +0 -113
  449. package/dist/core/radiant-component.js +0 -3
  450. package/dist/core/radiant-component.js.map +0 -9
@@ -1,6 +1,10 @@
1
- import type { StandardOrLegacyFieldDecoratorArgs } from '../types';
2
1
  import type { QueryConfig, QueryScope } from '../helpers/create-query';
3
2
  export type { QueryConfig, QueryScope };
3
+ type QueryDecoratorHost = (Element | {
4
+ host: Element;
5
+ }) & {
6
+ registerConnectedCallback(callback: () => void): void;
7
+ };
4
8
  /**
5
9
  * A decorator to query by CSS selector or data-ref attribute.
6
10
  * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.
@@ -8,4 +12,7 @@ export type { QueryConfig, QueryScope };
8
12
  * Queries run against the host light DOM by default, but can be directed to the shadow root or both trees.
9
13
  * @param options {@link QueryConfig} The options for the reactive property.
10
14
  */
11
- export declare function query<T extends Element | Element[]>(options: QueryConfig): (protoOrTarget: StandardOrLegacyFieldDecoratorArgs["protoOrTarget"], nameOrContext: StandardOrLegacyFieldDecoratorArgs["nameOrContext"]) => any;
15
+ export declare function query<T extends Element | Element[]>(options: QueryConfig): {
16
+ <Host extends QueryDecoratorHost>(protoOrTarget: undefined, nameOrContext: ClassFieldDecoratorContext<Host, T>): void;
17
+ (protoOrTarget: QueryDecoratorHost, nameOrContext: string): void;
18
+ };
@@ -1,3 +1,3 @@
1
- import{Z as a}from"../chunk-ndw3hc3v.js";import"../chunk-mpsj3cjs.js";import"../chunk-0bswvy25.js";import"../chunk-cnyxrh9r.js";import"../chunk-q9z6tnzw.js";import"../chunk-wwbjz9k4.js";import"../chunk-vgtggzb6.js";export{a as query};
1
+ var s=((d)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(d,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):d)(function(d){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+d+'" is not supported')});var M=Symbol.for("@ecopages/radiant.legacy-instance-initializers");function g(d,e){let n=d[M];if(Array.isArray(n)){n.push(e);return}Object.defineProperty(d,M,{value:[e],configurable:!0})}function T(d){let e=[],t=Object.getPrototypeOf(d);while(t&&t!==Object.prototype)e.push(t),t=Object.getPrototypeOf(t);for(let n=e.length-1;n>=0;n-=1){let r=e[n][M];if(!Array.isArray(r))continue;for(let o of r)o(d)}}function l(d){return typeof d==="function"}function R(d,e,t,n){if(typeof n==="object")return d(void 0,n);return e(t,n)}function L(d,e,t,n,r){if(typeof n==="object"){if(!l(t))throw TypeError("Standard method decorators require a method target");return d(t,n)}if(!r)throw TypeError("Legacy method decorators require a property descriptor");return e(t,n,r)}function P(d){return!(d instanceof Element)}function D(d){return"shadowRoot"in d?d.shadowRoot??null:null}function c(d){return d instanceof Element?d:d.host}function j(d,e="light"){let t=D(d);if(e==="shadow")return t?[t]:[];if(e==="both")return t?[d,t]:[d];return[d]}function u(d,e){if(P(d)&&e.scope&&e.scope!=="light")throw Error("RadiantController queries only support light DOM scope.");let t=c(d),n="selector"in e?e.selector:`[data-ref="${e.ref}"]`,r=null,o=()=>{let x=j(t,e.scope);if(e.all)return x.flatMap((F)=>Array.from(F.querySelectorAll(n)));for(let F of x){let a=F.querySelector(n);if(a)return a}return null};return{get value(){if(e.cache){if(r===null||e.all&&Array.isArray(r)&&!r.length)r=o();return r}return o()}}}function H({cache:d=!0,...e}){return(t,n)=>{g(t,(r)=>{r.registerConnectedCallback(()=>{let o=u(r,{cache:d,...e});Object.defineProperty(r,n,{get(){return o.value},enumerable:!0,configurable:!0})})})}}function f(d){return function(e,t){let n=String(t.name);t.addInitializer(function(){let r=u(this,d);Object.defineProperty(this,n,{get(){return r.value},enumerable:!0,configurable:!0})})}}function W(d){function e(t,n){return R(f(d),H(d),t,n)}return e}export{W as query};
2
2
 
3
- //# debugId=FF3EFC9A7E922D8664756E2164756E21
3
+ //# debugId=C27E3F342EDDD85564756E2164756E21
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/decorators/bridge.ts", "../src/helpers/create-query.ts", "../src/decorators/legacy/query.ts", "../src/decorators/standard/query.ts", "../src/decorators/query.ts"],
4
4
  "sourcesContent": [
5
+ "type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = target[LEGACY_INSTANCE_INITIALIZERS];\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(proto, LEGACY_INSTANCE_INITIALIZERS, {\n\t\tvalue: [initializer],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\tconst prototypes: object[] = [];\n\tlet currentPrototype = Object.getPrototypeOf(instance);\n\n\twhile (currentPrototype && currentPrototype !== Object.prototype) {\n\t\tprototypes.push(currentPrototype);\n\t\tcurrentPrototype = Object.getPrototypeOf(currentPrototype);\n\t}\n\n\tfor (let index = prototypes.length - 1; index >= 0; index -= 1) {\n\t\tconst initializers = (prototypes[index] as Record<PropertyKey, unknown>)[LEGACY_INSTANCE_INITIALIZERS] as\n\t\t\t| LegacyInstanceInitializer<T>[]\n\t\t\t| undefined;\n\n\t\tif (!Array.isArray(initializers)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const initializer of initializers) {\n\t\t\tinitializer(instance);\n\t\t}\n\t}\n}\n",
6
+ "import type { Method } from '../types';\n\ntype StandardFieldFn<Host extends object, Value, Result> = (\n\ttarget: undefined,\n\tcontext: ClassFieldDecoratorContext<Host, Value>,\n) => Result;\n\ntype LegacyFieldFn<Proto, Result> = (proto: Proto, name: string) => Result;\n\ntype StandardMethodFn<Host extends object, TMethod extends Method, Result> = (\n\ttarget: TMethod,\n\tcontext: ClassMethodDecoratorContext<Host, TMethod>,\n) => Result;\n\ntype LegacyMethodFn<Proto, Result> = (proto: Proto, name: string, descriptor: PropertyDescriptor) => Result;\n\nfunction isMethod(value: unknown): value is Method {\n\treturn typeof value === 'function';\n}\n\nexport function fieldDecoratorBridge<Host extends object, Value, Result, Proto>(\n\tstandard: StandardFieldFn<Host, Value, Result>,\n\tlegacy: LegacyFieldFn<Proto, void>,\n\tprotoOrTarget: undefined,\n\tnameOrContext: ClassFieldDecoratorContext<Host, Value>,\n): Result;\nexport function fieldDecoratorBridge<Host extends object, Value, Proto, Result>(\n\tstandard: StandardFieldFn<Host, Value, void>,\n\tlegacy: LegacyFieldFn<Proto, Result>,\n\tprotoOrTarget: Proto,\n\tnameOrContext: string,\n): Result;\nexport function fieldDecoratorBridge<Host extends object, Value, StandardResult, Proto, LegacyResult>(\n\tstandard: StandardFieldFn<Host, Value, StandardResult>,\n\tlegacy: LegacyFieldFn<Proto, LegacyResult>,\n\tprotoOrTarget: Proto | undefined,\n\tnameOrContext: string | ClassFieldDecoratorContext<Host, Value>,\n): StandardResult | LegacyResult;\n\nexport function fieldDecoratorBridge(\n\tstandard: StandardFieldFn<object, unknown, unknown>,\n\tlegacy: LegacyFieldFn<unknown, unknown>,\n\tprotoOrTarget: unknown,\n\tnameOrContext: string | ClassFieldDecoratorContext<object, unknown>,\n): unknown {\n\tif (typeof nameOrContext === 'object') {\n\t\treturn standard(undefined, nameOrContext);\n\t}\n\n\treturn legacy(protoOrTarget, nameOrContext);\n}\n\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, Result, Proto>(\n\tstandard: StandardMethodFn<Host, TMethod, Result>,\n\tlegacy: LegacyMethodFn<Proto, void>,\n\tprotoOrTarget: TMethod,\n\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\tdescriptor?: undefined,\n): Result;\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, Proto, Result>(\n\tstandard: StandardMethodFn<Host, TMethod, void>,\n\tlegacy: LegacyMethodFn<Proto, Result>,\n\tprotoOrTarget: Proto,\n\tnameOrContext: string,\n\tdescriptor: PropertyDescriptor,\n): Result;\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, StandardResult, Proto, LegacyResult>(\n\tstandard: StandardMethodFn<Host, TMethod, StandardResult>,\n\tlegacy: LegacyMethodFn<Proto, LegacyResult>,\n\tprotoOrTarget: Proto | TMethod,\n\tnameOrContext: string | ClassMethodDecoratorContext<Host, TMethod>,\n\tdescriptor?: PropertyDescriptor,\n): StandardResult | LegacyResult;\n\nexport function methodDecoratorBridge(\n\tstandard: StandardMethodFn<object, Method, unknown>,\n\tlegacy: LegacyMethodFn<unknown, unknown>,\n\tprotoOrTarget: unknown,\n\tnameOrContext: string | ClassMethodDecoratorContext<object, Method>,\n\tdescriptor?: PropertyDescriptor,\n): unknown {\n\tif (typeof nameOrContext === 'object') {\n\t\tif (!isMethod(protoOrTarget)) {\n\t\t\tthrow new TypeError('Standard method decorators require a method target');\n\t\t}\n\n\t\treturn standard(protoOrTarget, nameOrContext);\n\t}\n\n\tif (!descriptor) {\n\t\tthrow new TypeError('Legacy method decorators require a property descriptor');\n\t}\n\n\treturn legacy(protoOrTarget, nameOrContext, descriptor);\n}\n",
7
+ "type BaseQueryConfig = {\n\tall?: boolean;\n\tcache?: boolean;\n\tscope?: QueryScope;\n};\n\ntype QueryBySelector = { selector: string };\n\ntype QueryByRef = { ref: string };\n\nexport type QueryHostTarget = Element | { host: Element };\n\n/**\n * Selects which DOM tree a query should read from.\n */\nexport type QueryScope = 'light' | 'shadow' | 'both';\n\nexport type QueryConfig = BaseQueryConfig & (QueryBySelector | QueryByRef);\n\ntype QueryRoot = Element | ShadowRoot;\n\ntype QueryResult<T extends Element | Element[]> = {\n\tget value(): T | null;\n};\n\nfunction isControllerQueryTarget(target: QueryHostTarget): target is { host: Element } {\n\treturn !(target instanceof Element);\n}\n\nfunction resolveShadowRoot(host: Element): ShadowRoot | null {\n\treturn 'shadowRoot' in host ? ((host as Element & { shadowRoot?: ShadowRoot | null }).shadowRoot ?? null) : null;\n}\n\n/**\n * Resolves the DOM element that should serve as the query root.\n *\n * `@query(...)` can run on both element hosts and controller instances. This\n * helper normalizes those call sites to the underlying element that actually\n * owns the DOM subtree.\n */\nexport function resolveQueryHost(target: QueryHostTarget): Element {\n\treturn target instanceof Element ? target : target.host;\n}\n\nfunction getQueryRoots(host: Element, scope: QueryScope = 'light'): QueryRoot[] {\n\tconst shadowRoot = resolveShadowRoot(host);\n\n\tif (scope === 'shadow') {\n\t\treturn shadowRoot ? [shadowRoot] : [];\n\t}\n\n\tif (scope === 'both') {\n\t\treturn shadowRoot ? [host, shadowRoot] : [host];\n\t}\n\n\treturn [host];\n}\n\n/**\n * Creates a lazy DOM query accessor bound to an element host or controller.\n * Functional equivalent of the `@query` decorator for vanilla JS usage.\n * @param target The element host or controller to query within.\n * @param options {@link QueryConfig} The query configuration.\n */\nexport function createQuery<T extends Element | Element[] = Element>(\n\ttarget: QueryHostTarget,\n\toptions: QueryConfig,\n): QueryResult<T> {\n\tif (isControllerQueryTarget(target) && options.scope && options.scope !== 'light') {\n\t\tthrow new Error('RadiantController queries only support light DOM scope.');\n\t}\n\n\tconst host = resolveQueryHost(target);\n\tconst selector = 'selector' in options ? options.selector : `[data-ref=\"${options.ref}\"]`;\n\tlet cached: T | null = null;\n\n\tconst executeQuery = (): T | null => {\n\t\tconst roots = getQueryRoots(host, options.scope);\n\n\t\tif (options.all) {\n\t\t\treturn roots.flatMap((root) => Array.from(root.querySelectorAll(selector))) as T;\n\t\t}\n\n\t\tfor (const root of roots) {\n\t\t\tconst match = root.querySelector(selector);\n\t\t\tif (match) {\n\t\t\t\treturn match as T;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t};\n\n\treturn {\n\t\tget value(): T | null {\n\t\t\tif (options.cache) {\n\t\t\t\tif (cached === null || (options.all && Array.isArray(cached) && !cached.length)) {\n\t\t\t\t\tcached = executeQuery();\n\t\t\t\t}\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\treturn executeQuery();\n\t\t},\n\t};\n}\n",
8
+ "import { createQuery } from '../../helpers/create-query';\nimport type { QueryConfig } from '../query';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\ntype QueryDecoratorInstance = (Element | { host: Element }) & {\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\n/**\n * A decorator to query by CSS selector or data-ref attribute.\n * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.\n *\n * @param {QueryConfig} options - The configuration object for the query.\n * @param {boolean} [options.all] - A flag to query for all elements that match the selector. Defaults to `false`.\n * @param {boolean} [options.cache] - A flag to cache the query result. Defaults to `true`.\n * @param {string} [options.selector] - A CSS selector to match elements against. This property is mutually exclusive with `options.ref`.\n * @param {string} [options.ref] - A reference to an element. This property is mutually exclusive with `options.selector`.\n *\n * @returns {Function} A decorator function that, when applied to a class property, will replace it with a getter. The getter will return the result of the query when accessed.\n *\n * @example\n * class MyElement extends HTMLElement {\n * @query({ selector: '.my-class' })\n * myElement;\n * }\n *\n * // Now, `myElement` will return the first element in the light DOM of `MyElement` that matches the selector '.my-class'.\n */\nexport function query<T extends Element | Element[]>({\n\tcache: shouldBeCached = true,\n\t...options\n}: QueryConfig): (proto: QueryDecoratorInstance, propertyName: string | symbol) => void {\n\treturn (proto: QueryDecoratorInstance, propertyKey: string | symbol) => {\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tconst accessor = createQuery<T>(element, {\n\t\t\t\t\tcache: shouldBeCached,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\n\t\t\t\tObject.defineProperty(element, propertyKey, {\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn accessor.value;\n\t\t\t\t\t},\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n",
9
+ "import { createQuery, type QueryHostTarget } from '../../helpers/create-query';\nimport type { QueryConfig } from '../query';\n\nexport function query(options: QueryConfig) {\n\treturn function <T extends QueryHostTarget, V extends Element | Element[]>(\n\t\ttarget: undefined,\n\t\tcontext: ClassFieldDecoratorContext<T, V>,\n\t) {\n\t\tvoid target;\n\t\tconst propertyName = String(context.name);\n\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst accessor = createQuery<V>(this, options);\n\n\t\t\tObject.defineProperty(this, propertyName, {\n\t\t\t\tget() {\n\t\t\t\t\treturn accessor.value;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t});\n\t};\n}\n",
10
+ "import type { QueryConfig, QueryScope } from '../helpers/create-query';\nimport { query as legacyQuery } from './legacy/query';\nimport { query as standardQuery } from './standard/query';\nimport { fieldDecoratorBridge } from './bridge';\n\nexport type { QueryConfig, QueryScope };\n\ntype QueryDecoratorHost = (Element | { host: Element }) & {\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\n/**\n * A decorator to query by CSS selector or data-ref attribute.\n * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.\n * It caches the result only when `cache` is enabled.\n * Queries run against the host light DOM by default, but can be directed to the shadow root or both trees.\n * @param options {@link QueryConfig} The options for the reactive property.\n */\nexport function query<T extends Element | Element[]>(options: QueryConfig) {\n\tfunction decorator<Host extends QueryDecoratorHost>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, T>,\n\t): void;\n\tfunction decorator(protoOrTarget: QueryDecoratorHost, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: QueryDecoratorHost | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<QueryDecoratorHost, T>,\n\t): void {\n\t\treturn fieldDecoratorBridge(standardQuery(options), legacyQuery<T>(options),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,CACxC,MAAO,KACJ,CACJ,CAAC,EAED,OAAO,eAAe,EAAS,EAAa,CAC3C,GAAG,EAAG,CACL,OAAO,EAAS,OAEjB,WAAY,GACZ,aAAc,EACf,CAAC,EACD,EACD,GC7CI,SAAS,CAAK,CAAC,EAAsB,CAC3C,OAAO,QAAmE,CACzE,EACA,EACC,CAED,IAAM,EAAe,OAAO,EAAQ,IAAI,EAExC,EAAQ,eAAe,QAAS,EAAU,CACzC,IAAM,EAAW,EAAe,KAAM,CAAO,EAE7C,OAAO,eAAe,KAAM,EAAc,CACzC,GAAG,EAAG,CACL,OAAO,EAAS,OAEjB,WAAY,GACZ,aAAc,EACf,CAAC,EACD,GCHI,SAAS,CAAoC,CAAC,EAAsB,CAM1E,SAAS,CAAS,CACjB,EACA,EACO,CACP,OAAO,EAAqB,EAAc,CAAO,EAAG,EAAe,CAAO,EAAG,EAAe,CAAa,EAG1G,OAAO",
13
+ "debugId": "C27E3F342EDDD85564756E2164756E21",
8
14
  "names": []
9
15
  }
@@ -0,0 +1,25 @@
1
+ import type { ReactiveHostLike } from '../../core/reactive-host';
2
+ import type { ReactiveBindingOption } from '../../core/radiant-element';
3
+ import { type AttributeTypeConstant } from '../../utils/attribute-utils';
4
+ export type AttrConverter<T> = {
5
+ fromAttribute?: (value: string | null) => T;
6
+ toAttribute?: (value: T) => string | null;
7
+ };
8
+ export type AttrOptions<T = string | undefined> = {
9
+ source?: string;
10
+ type?: AttributeTypeConstant;
11
+ bind?: ReactiveBindingOption;
12
+ defaultValue?: T;
13
+ converter?: AttrConverter<T>;
14
+ };
15
+ type ReactiveAttributeHostApi<Bindings extends object = {}> = ReactiveHostLike<Bindings> & {
16
+ registerCleanupCallback(callback: () => void): void;
17
+ registerConnectedCallback(callback: () => void): void;
18
+ };
19
+ export type ReactiveAttributeHostLike<Bindings extends object = {}> = (ReactiveAttributeHostApi<Bindings> & Element) | (ReactiveAttributeHostApi<Bindings> & {
20
+ host: Element;
21
+ }) | (ReactiveAttributeHostApi<Bindings> & {
22
+ element: Element;
23
+ });
24
+ export declare function installReactiveAttribute<TBindings extends object, TValue>(host: ReactiveAttributeHostLike<TBindings>, propertyName: string, options?: AttrOptions<TValue>): void;
25
+ export {};
@@ -0,0 +1,3 @@
1
+ var D=((t)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function O(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function M(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(t))return"array";if(Object.prototype.toString.call(t)==="[object Object]")return"object"}function T(t){switch(t){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function $(t){try{return JSON.parse(t)}catch{throw TypeError("Invalid JSON string")}}var P={array(t){let e=$(t);if(!Array.isArray(e))throw TypeError(`Expected an array but got a value of type "${typeof e}"`);return e},boolean(t){return!(t==="0"||String(t).toLowerCase()==="false")},number(t){return Number(t.replace(/_/g,""))},object(t){let e=JSON.parse(t);if(e===null||typeof e!=="object"||Array.isArray(e))throw TypeError(`expected value of type "object" but instead got value "${t}" of type "${M(e)}"`);return e},string(t){return t}},H={default:L,array:B,object:B};function B(t){return JSON.stringify(t)}function L(t){return`${t}`}function R(t,e){let n=O(e);if(!n)throw TypeError(`[radiant-element] Unknown type "${e}"`);return P[n](t)}function x(t,e){let n=O(e);if(!n)throw TypeError(`[radiant-element] Unknown type "${e}"`);return(H[n]??H.default??L)(t)}function U(t){return typeof t==="boolean"}function j(t){return typeof t==="number"}function z(t){return typeof t==="string"}function F(t){return Array.isArray(t)}function Z(t){return typeof t==="object"&&!Array.isArray(t)&&t!==null}function C(t,e){switch(t){case Boolean:return U(e);case Number:return j(e);case String:return z(e);case Array:return F(e);case Object:return Z(e);default:return!1}}var I=(t,e,n,i)=>{if(e===Boolean){let s=t.getAttribute(n);if(s===null)return i;return s===""?!0:R(s,e)}let r=t.getAttribute(n);return r!==null?R(r,e):i??T(e)};function k(t){if(t instanceof Element)return t;if("host"in t)return t.host;return t.element}function _(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function l(t,e){if(e.converter?.fromAttribute){let n=e.converter.fromAttribute(t);if(t===null&&n===void 0&&"defaultValue"in e)return e.defaultValue;return n}if(e.type){if(t===null)return e.defaultValue??T(e.type);if(e.type===Boolean&&t==="")return!0;return R(t,e.type)}if(t===null)return e.defaultValue;return t}function c(t,e,n){return l(k(t).getAttribute(e),n)}function q(t,e,n,i){let r=i.converter?.toAttribute?i.converter.toAttribute(n):i.type?x(n,i.type):n==null?null:String(n);if(r===null){t.removeAttribute(e);return}t.setAttribute(e,r)}function W(t,e,n={}){if(n.type&&n.defaultValue!==void 0&&!C(n.type,n.defaultValue))throw Error(`defaultValue does not match the expected type for ${n.type.name}`);let i=t,r=n.source??_(e),s=Symbol(`@ecopages/radiant/attr:${e}:observer`),o=Symbol(`@ecopages/radiant/attr:${e}:last-value`),E=n.bind??t.shouldAutoBindReactiveMembers?.()??!1;t.defineReactiveBinding(e,E),t.registerReactiveDependencyReader(e,()=>c(t,r,n)),i[o]=c(t,r,n),Object.defineProperty(t,e,{get(){return t.trackReactiveRead(e),c(this,r,n)},set(b){let A=k(this),g=c(this,r,n);q(A,r,b,n);let d=c(this,r,n);if(Object.is(g,d))return;this[o]=d,t.notifyUpdate(e,g,d)},enumerable:!0,configurable:!0});let u=()=>{i[s]?.disconnect()},m=()=>{let b=c(t,r,n),A=i[o];if(!Object.is(A,b))i[o]=b,t.notifyUpdate(e,A,b);if(typeof MutationObserver>"u")return;let g=k(t);u();let d=new MutationObserver(()=>{let f=c(t,r,n),v=i[o];if(Object.is(v,f))return;i[o]=f,t.notifyUpdate(e,v,f)});d.observe(g,{attributeFilter:[r],attributes:!0}),i[s]=d};m(),t.registerConnectedCallback(m),t.registerCleanupCallback(u)}export{W as installReactiveAttribute};
2
+
3
+ //# debugId=AB2EB88C94EBA54D64756E2164756E21
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils/attribute-utils.ts", "../src/decorators/shared/reactive-attr.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
6
+ "import type { ReactiveHostLike } from '../../core/reactive-host';\nimport type { ReactiveBindingOption } from '../../core/radiant-element';\nimport {\n\tdefaultValueForType,\n\tisValueOfType,\n\treadAttributeValue,\n\ttype AttributeTypeConstant,\n\twriteAttributeValue,\n} from '../../utils/attribute-utils';\n\nexport type AttrConverter<T> = {\n\tfromAttribute?: (value: string | null) => T;\n\ttoAttribute?: (value: T) => string | null;\n};\n\nexport type AttrOptions<T = string | undefined> = {\n\tsource?: string;\n\ttype?: AttributeTypeConstant;\n\tbind?: ReactiveBindingOption;\n\tdefaultValue?: T;\n\tconverter?: AttrConverter<T>;\n};\n\ntype ReactiveAttributeHostApi<Bindings extends object = {}> = ReactiveHostLike<Bindings> & {\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\nexport type ReactiveAttributeHostLike<Bindings extends object = {}> =\n\t| (ReactiveAttributeHostApi<Bindings> & Element)\n\t| (ReactiveAttributeHostApi<Bindings> & { host: Element })\n\t| (ReactiveAttributeHostApi<Bindings> & { element: Element });\n\nfunction resolveAttributeTarget(host: ReactiveAttributeHostLike): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction toAttributeName(propertyName: string): string {\n\treturn propertyName\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n\t\t.replace(/_/g, '-')\n\t\t.toLowerCase();\n}\n\nfunction resolveAttributeValue<T>(rawValue: string | null, options: AttrOptions<T>): T {\n\tif (options.converter?.fromAttribute) {\n\t\tconst convertedValue = options.converter.fromAttribute(rawValue);\n\n\t\tif (rawValue === null && convertedValue === undefined && 'defaultValue' in options) {\n\t\t\treturn options.defaultValue as T;\n\t\t}\n\n\t\treturn convertedValue;\n\t}\n\n\tif (options.type) {\n\t\tif (rawValue === null) {\n\t\t\treturn (options.defaultValue ?? defaultValueForType(options.type)) as T;\n\t\t}\n\n\t\tif (options.type === Boolean && rawValue === '') {\n\t\t\treturn true as T;\n\t\t}\n\n\t\treturn readAttributeValue(rawValue, options.type) as T;\n\t}\n\n\tif (rawValue === null) {\n\t\treturn options.defaultValue as T;\n\t}\n\n\treturn rawValue as T;\n}\n\nfunction readReactiveAttributeValue<T>(\n\thost: ReactiveAttributeHostLike,\n\tattributeName: string,\n\toptions: AttrOptions<T>,\n): T {\n\treturn resolveAttributeValue(resolveAttributeTarget(host).getAttribute(attributeName), options);\n}\n\nfunction writeReactiveAttributeValue<T>(\n\ttarget: Element,\n\tattributeName: string,\n\tvalue: T,\n\toptions: AttrOptions<T>,\n): void {\n\tconst attributeValue = options.converter?.toAttribute\n\t\t? options.converter.toAttribute(value)\n\t\t: options.type\n\t\t\t? writeAttributeValue(value, options.type)\n\t\t\t: value == null\n\t\t\t\t? null\n\t\t\t\t: String(value);\n\n\tif (attributeValue === null) {\n\t\ttarget.removeAttribute(attributeName);\n\t\treturn;\n\t}\n\n\ttarget.setAttribute(attributeName, attributeValue);\n}\n\nexport function installReactiveAttribute<TBindings extends object, TValue>(\n\thost: ReactiveAttributeHostLike<TBindings>,\n\tpropertyName: string,\n\toptions: AttrOptions<TValue> = {},\n): void {\n\tif (options.type && options.defaultValue !== undefined && !isValueOfType(options.type, options.defaultValue)) {\n\t\tthrow new Error(`defaultValue does not match the expected type for ${options.type.name}`);\n\t}\n\n\tconst hostRecord = host as unknown as Record<PropertyKey, unknown>;\n\tconst attributeName = options.source ?? toAttributeName(propertyName);\n\tconst observerKey = Symbol(`@ecopages/radiant/attr:${propertyName}:observer`);\n\tconst lastValueKey = Symbol(`@ecopages/radiant/attr:${propertyName}:last-value`);\n\tconst bind =\n\t\toptions.bind ??\n\t\t(host as unknown as { shouldAutoBindReactiveMembers?: () => boolean }).shouldAutoBindReactiveMembers?.() ??\n\t\tfalse;\n\n\thost.defineReactiveBinding(propertyName, bind);\n\thost.registerReactiveDependencyReader(propertyName, () => readReactiveAttributeValue(host, attributeName, options));\n\thostRecord[lastValueKey] = readReactiveAttributeValue(host, attributeName, options);\n\n\tObject.defineProperty(host, propertyName, {\n\t\tget() {\n\t\t\thost.trackReactiveRead(propertyName);\n\t\t\treturn readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t},\n\t\tset(newValue: TValue) {\n\t\t\tconst target = resolveAttributeTarget(this as ReactiveAttributeHostLike);\n\t\t\tconst oldValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t\twriteReactiveAttributeValue(target, attributeName, newValue, options);\n\t\t\tconst nextValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\n\t\t\tif (Object.is(oldValue, nextValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t(this as Record<PropertyKey, unknown>)[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, oldValue, nextValue);\n\t\t},\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\tconst disconnectObserver = () => {\n\t\tconst observer = hostRecord[observerKey] as MutationObserver | undefined;\n\t\tobserver?.disconnect();\n\t};\n\n\tconst syncAndObserve = () => {\n\t\tconst nextValue = readReactiveAttributeValue(host, attributeName, options);\n\t\tconst previousValue = hostRecord[lastValueKey];\n\n\t\tif (!Object.is(previousValue, nextValue)) {\n\t\t\thostRecord[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, previousValue, nextValue);\n\t\t}\n\n\t\tif (typeof MutationObserver === 'undefined') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = resolveAttributeTarget(host);\n\n\t\tdisconnectObserver();\n\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst currentValue = readReactiveAttributeValue(host, attributeName, options);\n\t\t\tconst lastValue = hostRecord[lastValueKey];\n\n\t\t\tif (Object.is(lastValue, currentValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thostRecord[lastValueKey] = currentValue;\n\t\t\thost.notifyUpdate(propertyName, lastValue, currentValue);\n\t\t});\n\n\t\tobserver.observe(target, {\n\t\t\tattributeFilter: [attributeName],\n\t\t\tattributes: true,\n\t\t});\n\n\t\thostRecord[observerKey] = observer;\n\t};\n\n\tsyncAndObserve();\n\thost.registerConnectedCallback(syncAndObserve);\n\thost.registerCleanupCallback(disconnectObserver);\n}\n"
7
+ ],
8
+ "mappings": "2PAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ,MAAO,aACH,QACJ,MAAO,eACH,OACJ,MAAO,cACH,OACJ,MAAO,cACH,OACJ,MAAO,UAUH,SAAS,CAAyB,CAAC,EAAqC,CAC9E,OAAQ,OAAO,OACT,UACJ,MAAO,cACH,SACJ,MAAO,aACH,SACJ,MAAO,SAGT,GAAI,MAAM,QAAQ,CAAY,EAAG,MAAO,QACxC,GAAI,OAAO,UAAU,SAAS,KAAK,CAAY,IAAM,kBAAmB,MAAO,SASzE,SAAS,CAAmB,CAAC,EAAsC,CACzE,OAAQ,QACF,OACJ,MAAO,QACH,OACJ,MAAO,QACH,QACJ,MAAO,WAEP,OAAO,MASV,SAAS,CAAY,CAAC,EAAkB,CACvC,GAAI,CACH,OAAO,KAAK,MAAM,CAAK,EACtB,KAAM,CACP,MAAU,UAAU,qBAAqB,GAQ3C,IAAM,EAAsC,CAC3C,KAAK,CAAC,EAA0B,CAC/B,IAAM,EAAQ,EAAqB,CAAK,EACxC,GAAI,CAAC,MAAM,QAAQ,CAAK,EACvB,MAAU,UAAU,8CAA8C,OAAO,IAAQ,EAElF,OAAO,GAGR,OAAO,CAAC,EAAwB,CAC/B,MAAO,EAAE,IAAU,K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B,WAAW,GAGhB,EAAiB,IAAM,CAC5B,IAAM,EAAY,EAA2B,EAAM,EAAe,CAAO,EACnE,EAAgB,EAAW,GAEjC,GAAI,CAAC,OAAO,GAAG,EAAe,CAAS,EACtC,EAAW,GAAgB,EAC3B,EAAK,aAAa,EAAc,EAAe,CAAS,EAGzD,GAAI,OAAO,iBAAqB,IAC/B,OAGD,IAAM,EAAS,EAAuB,CAAI,EAE1C,EAAmB,EAEnB,IAAM,EAAW,IAAI,iBAAiB,IAAM,CAC3C,IAAM,EAAe,EAA2B,EAAM,EAAe,CAAO,EACtE,EAAY,EAAW,GAE7B,GAAI,OAAO,GAAG,EAAW,CAAY,EACpC,OAGD,EAAW,GAAgB,EAC3B,EAAK,aAAa,EAAc,EAAW,CAAY,EACvD,EAED,EAAS,QAAQ,EAAQ,CACxB,gBAAiB,CAAC,CAAa,EAC/B,WAAY,EACb,CAAC,EAED,EAAW,GAAe,GAG3B,EAAe,EACf,EAAK,0BAA0B,CAAc,EAC7C,EAAK,wBAAwB,CAAkB",
9
+ "debugId": "AB2EB88C94EBA54D64756E2164756E21",
10
+ "names": []
11
+ }
@@ -1,6 +1,11 @@
1
- import type { StandardOrLegacyFieldDecoratorArgs } from '../types';
1
+ import type { ReactiveHostLike } from '../core/reactive-host';
2
2
  import { type SignalDecoratorOptions } from './legacy/signal';
3
+ import type { WritableSignal } from '@ecopages/signals';
3
4
  export type { SignalDecoratorOptions } from './standard/signal';
5
+ type SignalDecorator<Value = unknown> = {
6
+ <THost extends ReactiveHostLike>(protoOrTarget: undefined, nameOrContext: ClassFieldDecoratorContext<THost, WritableSignal<Value>>): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;
7
+ (protoOrTarget: ReactiveHostLike, nameOrContext: string): void;
8
+ };
4
9
  /**
5
10
  * Declares a host-aware writable signal field.
6
11
  *
@@ -11,7 +16,7 @@ export type { SignalDecoratorOptions } from './standard/signal';
11
16
  *
12
17
  * Connected signals still flow through Radiant's update callback channel so
13
18
  * `@onUpdated(...)` and `this.$.name` bindings continue to work. On
14
- * `RadiantComponent`, any signal or store reads performed during `render()`
19
+ * `RadiantElement`, any signal or store reads performed during `render()`
15
20
  * now participate in rerender invalidation directly, which makes module-level
16
21
  * shared stores a natural fit without prop-bridging them through a second
17
22
  * reactive layer.
@@ -19,5 +24,6 @@ export type { SignalDecoratorOptions } from './standard/signal';
19
24
  * When `hydrate` is provided, SSR host output appends a keyed JSON script so
20
25
  * the client can restore the signal's initial value during hydration.
21
26
  */
22
- export declare function signal(protoOrTarget: StandardOrLegacyFieldDecoratorArgs['protoOrTarget'], nameOrContext: StandardOrLegacyFieldDecoratorArgs['nameOrContext']): any;
23
- export declare function signal(options?: SignalDecoratorOptions): any;
27
+ export declare function signal<THost extends ReactiveHostLike, Value>(protoOrTarget: undefined, nameOrContext: ClassFieldDecoratorContext<THost, WritableSignal<Value>>): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;
28
+ export declare function signal(protoOrTarget: ReactiveHostLike, nameOrContext: string): void;
29
+ export declare function signal<Value = unknown>(options?: SignalDecoratorOptions<Value>): SignalDecorator<Value>;
@@ -1,3 +1,3 @@
1
- import{aa as a}from"../chunk-pkszgjqf.js";import"../chunk-x457d0ap.js";import"../chunk-vk48hgm4.js";import"../chunk-nnnb6pac.js";import"../chunk-dabagjk6.js";import"../chunk-cnyxrh9r.js";import"../chunk-hpzgnxgq.js";import"../chunk-nssj2x13.js";import"../chunk-vgtggzb6.js";export{a as signal};
1
+ var v=((q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(q,{get:(Q,F)=>(typeof require<"u"?require:Q)[F]}):q)(function(q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+q+'" is not supported')});var D=Symbol.for("@ecopages/radiant.legacy-instance-initializers");function Y(q,Q){let $=q[D];if(Array.isArray($)){$.push(Q);return}Object.defineProperty(q,D,{value:[Q],configurable:!0})}function N(q){let Q=[],F=Object.getPrototypeOf(q);while(F&&F!==Object.prototype)Q.push(F),F=Object.getPrototypeOf(F);for(let $=Q.length-1;$>=0;$-=1){let X=Q[$][D];if(!Array.isArray(X))continue;for(let j of X)j(q)}}function f(q){return q.replace(/&/g,"\\u0026").replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var K="data-hydration",z="data-hydration-type",U="data-hydration-key";function _(q){let Q=q.hydrationKey?` ${U}="${A(q.hydrationKey)}"`:"";return`<script type="application/json" ${K} ${z}="${q.type}"${Q}>${q.serializedValue}</script>`}function k(q){return f(q)}function b(q,Q){let F=q.textContent;if(!F)return Q;try{return JSON.parse(F)}catch{if(typeof console<"u")console.warn(`[@ecopages/radiant] Failed to parse hydration payload from <script ${K}>:`,F.slice(0,120));return Q}}function E(q,Q,F){let $=q.children;if(!$||$.length===0){let X=q.childNodes;if(!X||X.length===0)return null;for(let j=0;j<X.length;j+=1){let G=X[j];if(G.nodeType!==1)continue;let Z=G;if(C(Z,Q,F))return Z}return null}for(let X=0;X<$.length;X+=1)if(C($[X],Q,F))return $[X];return null}function C(q,Q,F){if(q.tagName!=="SCRIPT"||!q.hasAttribute(K)||q.getAttribute(z)!==Q)return!1;if(F!==void 0)return q.getAttribute(U)===F;return!q.hasAttribute(U)}function A(q){return q.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function H(q){return _({type:"signal",...q})}function R(q){return k(q)}import{createMarkupNodeLike as x}from"@ecopages/jsx";import{state as I}from"@ecopages/signals";function P(q){return typeof q==="object"&&q!==null&&typeof q.get==="function"&&typeof q.set==="function"&&typeof q.subscribe==="function"&&typeof q.update==="function"}class W{host;hydrate;hydrationKey;property;source;currentValue;hasAppliedHostHydration=!1;sourceUnsubscribe;constructor(q){this.host=q.host,this.hydrate=q.hydrate,this.hydrationKey=q.hydrationKey,this.property=q.property,this.source=q.source??I(this.resolveInitialValue(q.initialValue)),this.currentValue=this.source.get()}get(){return this.source.get()}set(q){this.source.set(q)}subscribe(q){return this.source.subscribe(q)}update(q){this.set(q(this.get()))}connectToSource(){if(this.sourceUnsubscribe)return;let q=this.source.get();if(!Object.is(this.currentValue,q)){let Q=this.currentValue;this.currentValue=q,this.host.notifyUpdate(this.property,Q,q)}this.sourceUnsubscribe=this.source.subscribe((Q)=>{this.handleSourceChange(Q)})}disconnectFromSource(){this.sourceUnsubscribe?.(),this.sourceUnsubscribe=void 0}hydrateFromHost(){if(!this.hydrate||this.hasAppliedHostHydration)return;this.hasAppliedHostHydration=!0;let q=this.source.get(),Q=this.resolveInitialValue(q);if(!Object.is(q,Q))this.source.set(Q),this.currentValue=this.source.get(),this.host.notifyUpdate(this.property,q,this.currentValue)}renderHydrationScript(){let q=this.renderHydrationScriptTag();if(!q)return;return x(q)}renderHydrationScriptTag(){let q=this.serializeHydrationValue();if(!q)return;return H({hydrationKey:this.hydrationKey,serializedValue:q})}findHydrationScriptElement(){if(!(this.host instanceof Element))return null;return E(this.host,"signal",this.hydrationKey)}isObject(q){return typeof q==="object"&&!Array.isArray(q)&&q!==null}resolveInitialValue(q){if(!this.hydrate)return q;let Q=this.findHydrationScriptElement();if(!Q)return q;let F=b(Q,q);if(this.hydrate===Object&&this.isObject(F)&&this.isObject(q))return{...q,...F};return F}serializeHydrationValue(){if(!this.hydrate)return;let q=JSON.stringify(this.get());if(typeof q!=="string")return;return R(q)}handleSourceChange(q){let Q=this.currentValue;if(this.currentValue=q,!Object.is(Q,q))this.host.notifyUpdate(this.property,Q,q)}}function B(q){return new W(q)}function L(q={}){return(Q,F)=>{let $=(X)=>{let j=X[F];if(j instanceof W)return j;let G=typeof q.source==="function"?q.source(X):q.source??(P(j)?j:void 0),Z=q.bind??X.shouldAutoBindReactiveMembers?.()??!1,M=G!==void 0?q.initial:j===void 0?q.initial:j;X.defineReactiveBinding(F,Z);let J=B({host:X,hydrate:q.hydrate,hydrationKey:F,initialValue:M,property:F,source:G});if(X.registerConnectedCallback(()=>{J.hydrateFromHost(),J.connectToSource()}),X.registerCleanupCallback(()=>{J.disconnectFromSource()}),q.hydrate)X.registerHydrationBinding(F,J);return X[F]=J,J};Y(Q,(X)=>{let j=$(X);X.registerConnectedCallback(()=>{if(!(X[F]instanceof W))X[F]=j})})}}function w(q={}){return function(Q,F){let $=String(F.name);return function(X){let j=typeof q.source==="function"?q.source(this):q.source??(P(X)?X:void 0),G=j!==void 0?q.initial:X===void 0?q.initial:X,Z=q.bind??this.shouldAutoBindReactiveMembers?.()??!1;this.defineReactiveBinding($,Z);let M=B({host:this,hydrate:q.hydrate,hydrationKey:$,initialValue:G,property:$,source:j});if(this.registerConnectedCallback(()=>{M.hydrateFromHost(),M.connectToSource()}),this.registerCleanupCallback(()=>{M.disconnectFromSource()}),q.hydrate)this.registerHydrationBinding($,M);return M}}}function t(q,Q){if(typeof Q<"u"){if(typeof Q==="object"){if(q!==void 0)throw TypeError("@signal standard decorators require an undefined target");return w()(void 0,Q)}if(q===void 0)throw TypeError("@signal legacy decorators require a host target");return L()(q,Q)}let F=q??{};function $(X,j){if(typeof j==="object"){if(X!==void 0)throw TypeError("@signal standard decorators require an undefined target");return w(F)(void 0,j)}if(X===void 0)throw TypeError("@signal legacy decorators require a host target");return L(F)(X,j)}return $}export{t as signal};
2
2
 
3
- //# debugId=772B269B2EA6985664756E2164756E21
3
+ //# debugId=FB33BA77921C240664756E2164756E21
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/tools/escape-script-json.ts", "../src/core/hydration-codec.ts", "../src/signals/hydration-script.ts", "../src/signals/host-signal.ts", "../src/decorators/legacy/signal.ts", "../src/decorators/standard/signal.ts", "../src/decorators/signal.ts"],
4
4
  "sourcesContent": [
5
+ "type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = target[LEGACY_INSTANCE_INITIALIZERS];\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(proto, LEGACY_INSTANCE_INITIALIZERS, {\n\t\tvalue: [initializer],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\tconst prototypes: object[] = [];\n\tlet currentPrototype = Object.getPrototypeOf(instance);\n\n\twhile (currentPrototype && currentPrototype !== Object.prototype) {\n\t\tprototypes.push(currentPrototype);\n\t\tcurrentPrototype = Object.getPrototypeOf(currentPrototype);\n\t}\n\n\tfor (let index = prototypes.length - 1; index >= 0; index -= 1) {\n\t\tconst initializers = (prototypes[index] as Record<PropertyKey, unknown>)[LEGACY_INSTANCE_INITIALIZERS] as\n\t\t\t| LegacyInstanceInitializer<T>[]\n\t\t\t| undefined;\n\n\t\tif (!Array.isArray(initializers)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const initializer of initializers) {\n\t\t\tinitializer(instance);\n\t\t}\n\t}\n}\n",
6
+ "/**\n * Escapes serialized JSON so it remains safe when embedded inside an HTML\n * `<script>` tag.\n */\nexport function escapeScriptJson(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '\\\\u0026')\n\t\t.replace(/</g, '\\\\u003c')\n\t\t.replace(/>/g, '\\\\u003e')\n\t\t.replace(/\\u2028/g, '\\\\u2028')\n\t\t.replace(/\\u2029/g, '\\\\u2029');\n}\n",
7
+ "import { escapeScriptJson } from '../tools/escape-script-json';\n\n/** Attribute marker used to identify hydration payloads inside a host. */\nexport const HYDRATION_ATTRIBUTE = 'data-hydration';\n/** Discriminator that scopes a hydration payload to a specific feature. */\nexport const HYDRATION_TYPE_ATTRIBUTE = 'data-hydration-type';\n/** Optional key that scopes a hydration payload to a specific decorated field. */\nexport const HYDRATION_KEY_ATTRIBUTE = 'data-hydration-key';\n\nexport type HydrationPayloadType = 'signal' | 'context';\n\ntype HydrationScriptHost = {\n\tchildren?: ArrayLike<Element> | undefined;\n\tchildNodes?: ArrayLike<{ nodeType: number }> | undefined;\n};\n\n/** Creates a `<script type=\"application/json\">` tag for a hydration payload. */\nexport function createHydrationScriptTag(options: {\n\ttype: HydrationPayloadType;\n\thydrationKey?: string;\n\tserializedValue: string;\n}): string {\n\tconst keyAttribute = options.hydrationKey\n\t\t? ` ${HYDRATION_KEY_ATTRIBUTE}=\"${escapeHtmlAttribute(options.hydrationKey)}\"`\n\t\t: '';\n\n\treturn `<script type=\"application/json\" ${HYDRATION_ATTRIBUTE} ${HYDRATION_TYPE_ATTRIBUTE}=\"${options.type}\"${keyAttribute}>${options.serializedValue}</script>`;\n}\n\n/** Escapes serialized JSON so it remains safe inside an HTML script tag. */\nexport function escapeHydrationJson(value: string): string {\n\treturn escapeScriptJson(value);\n}\n\n/** Parses JSON from a hydration script element, returning the fallback on failure. */\nexport function parseHydrationPayload<T>(element: Element, fallback: T): T {\n\tconst textContent = element.textContent;\n\n\tif (!textContent) {\n\t\treturn fallback;\n\t}\n\n\ttry {\n\t\treturn JSON.parse(textContent) as T;\n\t} catch {\n\t\tif (typeof console !== 'undefined') {\n\t\t\tconsole.warn(\n\t\t\t\t`[@ecopages/radiant] Failed to parse hydration payload from <script ${HYDRATION_ATTRIBUTE}>:`,\n\t\t\t\ttextContent.slice(0, 120),\n\t\t\t);\n\t\t}\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Finds a hydration script element inside a host by type and optional key.\n *\n * When a key is provided, looks for an exact `data-hydration-key` match.\n * Otherwise, returns the first unkeyed script matching the type.\n */\nexport function findHydrationScript(\n\thost: HydrationScriptHost,\n\ttype: HydrationPayloadType,\n\thydrationKey?: string,\n): Element | null {\n\tconst children = host.children;\n\n\tif (!children || children.length === 0) {\n\t\tconst childNodes = (host as Partial<{ childNodes: ArrayLike<{ nodeType: number }> }>).childNodes;\n\n\t\tif (!childNodes || childNodes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfor (let i = 0; i < childNodes.length; i += 1) {\n\t\t\tconst node = childNodes[i]!;\n\n\t\t\tif (node.nodeType !== 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst element = node as unknown as Element;\n\n\t\t\tif (matchesHydrationScript(element, type, hydrationKey)) {\n\t\t\t\treturn element;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfor (let i = 0; i < children.length; i += 1) {\n\t\tif (matchesHydrationScript(children[i]!, type, hydrationKey)) {\n\t\t\treturn children[i]!;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction matchesHydrationScript(element: Element, type: HydrationPayloadType, hydrationKey?: string): boolean {\n\tif (\n\t\telement.tagName !== 'SCRIPT' ||\n\t\t!element.hasAttribute(HYDRATION_ATTRIBUTE) ||\n\t\telement.getAttribute(HYDRATION_TYPE_ATTRIBUTE) !== type\n\t) {\n\t\treturn false;\n\t}\n\n\tif (hydrationKey !== undefined) {\n\t\treturn element.getAttribute(HYDRATION_KEY_ATTRIBUTE) === hydrationKey;\n\t}\n\n\treturn !element.hasAttribute(HYDRATION_KEY_ATTRIBUTE);\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n",
8
+ "import { createHydrationScriptTag, escapeHydrationJson } from '../core/hydration-codec';\n\n/** Creates the raw `<script type=\"application/json\">` tag used to hydrate a signal field. */\nexport function createSignalHydrationScriptTag(options: { hydrationKey?: string; serializedValue: string }): string {\n\treturn createHydrationScriptTag({ type: 'signal', ...options });\n}\n\n/** Escapes serialized JSON so it remains safe inside an HTML script tag. */\nexport function escapeSignalHydrationJson(value: string): string {\n\treturn escapeHydrationJson(value);\n}\n",
9
+ "import { createMarkupNodeLike, type JsxRenderable } from '@ecopages/jsx';\nimport { state, type WritableSignal } from '@ecopages/signals';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\nimport type { AttributeTypeConstant } from '../utils/attribute-utils';\nimport { findHydrationScript, parseHydrationPayload } from '../core/hydration-codec';\nimport { createSignalHydrationScriptTag, escapeSignalHydrationJson } from './hydration-script';\n\ntype HostSignalOwner = {\n\tnotifyUpdate(property: string, oldValue: unknown, value: unknown): void;\n};\n\ntype HostSignalOptions<Value> = {\n\thost: HostSignalOwner;\n\thydrate?: AttributeTypeConstant;\n\thydrationKey?: string;\n\tinitialValue?: Value;\n\tproperty: string;\n\tsource?: WritableSignal<Value>;\n};\n\nexport function isWritableSignalLike<Value>(value: unknown): value is WritableSignal<Value> {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as WritableSignal<Value>).get === 'function' &&\n\t\ttypeof (value as WritableSignal<Value>).set === 'function' &&\n\t\ttypeof (value as WritableSignal<Value>).subscribe === 'function' &&\n\t\ttypeof (value as WritableSignal<Value>).update === 'function'\n\t);\n}\n\n/**\n * Host-owned writable signal that bridges signal updates back into Radiant's\n * update callback channel and optional SSR hydration pipeline.\n */\nexport class HostSignal<Value> implements WritableSignal<Value>, SsrSerializableHydrationBinding {\n\tprivate readonly host: HostSignalOwner;\n\tprivate readonly hydrate?: AttributeTypeConstant;\n\tprivate readonly hydrationKey?: string;\n\tprivate readonly property: string;\n\tprivate readonly source: WritableSignal<Value>;\n\tprivate currentValue: Value;\n\tprivate hasAppliedHostHydration = false;\n\tprivate sourceUnsubscribe?: () => void;\n\n\tconstructor(options: HostSignalOptions<Value>) {\n\t\tthis.host = options.host;\n\t\tthis.hydrate = options.hydrate;\n\t\tthis.hydrationKey = options.hydrationKey;\n\t\tthis.property = options.property;\n\t\tthis.source = options.source ?? state(this.resolveInitialValue(options.initialValue as Value));\n\t\tthis.currentValue = this.source.get();\n\t}\n\n\tpublic get(): Value {\n\t\treturn this.source.get();\n\t}\n\n\tpublic set(nextValue: Value): void {\n\t\tthis.source.set(nextValue);\n\t}\n\n\tpublic subscribe(notify: (value: Value) => void): () => void {\n\t\treturn this.source.subscribe(notify);\n\t}\n\n\tpublic update(updater: (value: Value) => Value): void {\n\t\tthis.set(updater(this.get()));\n\t}\n\n\tpublic connectToSource(): void {\n\t\tif (this.sourceUnsubscribe) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextValue = this.source.get();\n\n\t\tif (!Object.is(this.currentValue, nextValue)) {\n\t\t\tconst previousValue = this.currentValue;\n\t\t\tthis.currentValue = nextValue;\n\t\t\tthis.host.notifyUpdate(this.property, previousValue, nextValue);\n\t\t}\n\n\t\tthis.sourceUnsubscribe = this.source.subscribe((value) => {\n\t\t\tthis.handleSourceChange(value);\n\t\t});\n\t}\n\n\tpublic disconnectFromSource(): void {\n\t\tthis.sourceUnsubscribe?.();\n\t\tthis.sourceUnsubscribe = undefined;\n\t}\n\n\tpublic hydrateFromHost(): void {\n\t\tif (!this.hydrate || this.hasAppliedHostHydration) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hasAppliedHostHydration = true;\n\n\t\tconst previousValue = this.source.get();\n\t\tconst hydratedValue = this.resolveInitialValue(previousValue);\n\n\t\tif (!Object.is(previousValue, hydratedValue)) {\n\t\t\tthis.source.set(hydratedValue);\n\t\t\tthis.currentValue = this.source.get();\n\t\t\tthis.host.notifyUpdate(this.property, previousValue, this.currentValue);\n\t\t}\n\t}\n\n\tpublic renderHydrationScript(): JsxRenderable | undefined {\n\t\tconst outerHTML = this.renderHydrationScriptTag();\n\n\t\tif (!outerHTML) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createMarkupNodeLike(outerHTML);\n\t}\n\n\tpublic renderHydrationScriptTag(): string | undefined {\n\t\tconst serializedValue = this.serializeHydrationValue();\n\n\t\tif (!serializedValue) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createSignalHydrationScriptTag({\n\t\t\thydrationKey: this.hydrationKey,\n\t\t\tserializedValue,\n\t\t});\n\t}\n\n\tprivate findHydrationScriptElement(): Element | null {\n\t\tif (!(this.host instanceof Element)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn findHydrationScript(this.host, 'signal', this.hydrationKey);\n\t}\n\n\tprivate isObject(value: unknown): value is Record<string, unknown> {\n\t\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n\t}\n\n\tprivate resolveInitialValue(initialValue: Value): Value {\n\t\tif (!this.hydrate) {\n\t\t\treturn initialValue;\n\t\t}\n\n\t\tconst hydrationScriptElement = this.findHydrationScriptElement();\n\n\t\tif (!hydrationScriptElement) {\n\t\t\treturn initialValue;\n\t\t}\n\n\t\tconst parsedHydrationValue = parseHydrationPayload(hydrationScriptElement, initialValue);\n\n\t\tif (this.hydrate === Object && this.isObject(parsedHydrationValue) && this.isObject(initialValue)) {\n\t\t\treturn {\n\t\t\t\t...initialValue,\n\t\t\t\t...parsedHydrationValue,\n\t\t\t} as Value;\n\t\t}\n\n\t\treturn parsedHydrationValue;\n\t}\n\n\tprivate serializeHydrationValue(): string | undefined {\n\t\tif (!this.hydrate) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst serializedValue = JSON.stringify(this.get());\n\n\t\tif (typeof serializedValue !== 'string') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn escapeSignalHydrationJson(serializedValue);\n\t}\n\n\tprivate handleSourceChange(nextValue: Value): void {\n\t\tconst previousValue = this.currentValue;\n\t\tthis.currentValue = nextValue;\n\n\t\tif (!Object.is(previousValue, nextValue)) {\n\t\t\tthis.host.notifyUpdate(this.property, previousValue, nextValue);\n\t\t}\n\t}\n}\n\nexport function createHostSignal<Value>(options: HostSignalOptions<Value>): HostSignal<Value> {\n\treturn new HostSignal(options);\n}\n",
10
+ "import type { ReactiveBindingOption } from '../../core/radiant-element';\nimport type { ReactiveHostLike } from '../../core/reactive-host';\nimport { createHostSignal, HostSignal, isWritableSignalLike } from '../../signals/host-signal';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\nimport type { AttributeTypeConstant } from '../../utils/attribute-utils';\nimport type { WritableSignal } from '@ecopages/signals';\n\nexport type SignalDecoratorOptions<Value = unknown> = {\n\tbind?: ReactiveBindingOption;\n\tinitial?: Value;\n\tsource?: WritableSignal<Value> | ((host: ReactiveHostLike) => WritableSignal<Value>);\n\thydrate?: AttributeTypeConstant;\n};\n\nexport function signal<Value = unknown>(options: SignalDecoratorOptions<Value> = {}) {\n\treturn (target: ReactiveHostLike, propertyName: string) => {\n\t\tconst initializeSignal = (element: ReactiveHostLike): HostSignal<unknown> => {\n\t\t\tconst currentValue = element[propertyName as keyof typeof element] as unknown;\n\n\t\t\tif (currentValue instanceof HostSignal) {\n\t\t\t\treturn currentValue;\n\t\t\t}\n\n\t\t\tconst resolvedSource =\n\t\t\t\ttypeof options.source === 'function'\n\t\t\t\t\t? options.source(element)\n\t\t\t\t\t: (options.source ?? (isWritableSignalLike(currentValue) ? currentValue : undefined));\n\n\t\t\tconst bind =\n\t\t\t\toptions.bind ??\n\t\t\t\t(\n\t\t\t\t\telement as unknown as { shouldAutoBindReactiveMembers?: () => boolean }\n\t\t\t\t).shouldAutoBindReactiveMembers?.() ??\n\t\t\t\tfalse;\n\n\t\t\tconst resolvedInitialValue =\n\t\t\t\tresolvedSource !== undefined\n\t\t\t\t\t? options.initial\n\t\t\t\t\t: ((currentValue === undefined ? options.initial : currentValue) as Value);\n\t\t\telement.defineReactiveBinding(propertyName, bind);\n\n\t\t\tconst hostSignal = createHostSignal({\n\t\t\t\thost: element,\n\t\t\t\thydrate: options.hydrate,\n\t\t\t\thydrationKey: propertyName,\n\t\t\t\tinitialValue: resolvedInitialValue,\n\t\t\t\tproperty: propertyName,\n\t\t\t\tsource: resolvedSource,\n\t\t\t});\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\thostSignal.hydrateFromHost();\n\t\t\t\thostSignal.connectToSource();\n\t\t\t});\n\t\t\telement.registerCleanupCallback(() => {\n\t\t\t\thostSignal.disconnectFromSource();\n\t\t\t});\n\n\t\t\tif (options.hydrate) {\n\t\t\t\telement.registerHydrationBinding(propertyName, hostSignal);\n\t\t\t}\n\n\t\t\t(element as unknown as Record<string, unknown>)[propertyName] = hostSignal;\n\t\t\treturn hostSignal as unknown as HostSignal<unknown>;\n\t\t};\n\n\t\tregisterLegacyInstanceInitializer(target, (element) => {\n\t\t\tconst hostSignal = initializeSignal(element);\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tif (!((element as any)[propertyName] instanceof HostSignal)) {\n\t\t\t\t\t(element as unknown as Record<string, unknown>)[propertyName] = hostSignal;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t};\n}\n",
11
+ "import type { WritableSignal } from '@ecopages/signals';\nimport type { ReactiveBindingOption } from '../../core/radiant-element';\nimport type { ReactiveHostLike } from '../../core/reactive-host';\nimport { createHostSignal, isWritableSignalLike } from '../../signals/host-signal';\nimport type { AttributeTypeConstant } from '../../utils/attribute-utils';\n\n/** Options for the `@signal` decorator. */\nexport type SignalDecoratorOptions<Value = unknown> = {\n\t/**\n\t * Exposes a JSX binding companion for the decorated signal.\n\t *\n\t * - `true` creates a `$propertyName` accessor.\n\t * - a string creates a custom accessor with that name.\n\t * - `undefined` defers to the host default.\n\t */\n\tbind?: ReactiveBindingOption;\n\n\t/**\n\t * Optional initial value used when the field does not provide one directly.\n\t *\n\t * This is primarily useful with `declare field: WritableSignal<T>` syntax,\n\t * which keeps the component surface clean while still letting the decorator\n\t * own signal construction.\n\t */\n\tinitial?: Value;\n\n\t/**\n\t * Connects an existing writable signal to the host instead of creating a\n\t * host-owned one.\n\t */\n\tsource?: WritableSignal<Value> | ((host: ReactiveHostLike) => WritableSignal<Value>);\n\n\t/**\n\t * Serializes the current signal value into a keyed hydration script during\n\t * SSR and restores it on the client.\n\t */\n\thydrate?: AttributeTypeConstant;\n};\n\nexport function signal<Value = unknown>(options: SignalDecoratorOptions<Value> = {}) {\n\treturn function <T extends ReactiveHostLike, Value>(_: undefined, context: ClassFieldDecoratorContext<T, unknown>) {\n\t\tconst propertyName = String(context.name);\n\n\t\treturn function (this: T, initialValue: Value | WritableSignal<Value>) {\n\t\t\tconst resolvedSource =\n\t\t\t\ttypeof options.source === 'function'\n\t\t\t\t\t? options.source(this)\n\t\t\t\t\t: (options.source ?? (isWritableSignalLike<Value>(initialValue) ? initialValue : undefined));\n\t\t\tconst resolvedInitialValue =\n\t\t\t\tresolvedSource !== undefined\n\t\t\t\t\t? options.initial\n\t\t\t\t\t: ((initialValue === undefined ? options.initial : initialValue) as Value);\n\t\t\tconst bind =\n\t\t\t\toptions.bind ??\n\t\t\t\t(\n\t\t\t\t\tthis as unknown as { shouldAutoBindReactiveMembers?: () => boolean }\n\t\t\t\t).shouldAutoBindReactiveMembers?.() ??\n\t\t\t\tfalse;\n\n\t\t\tthis.defineReactiveBinding(propertyName, bind);\n\n\t\t\tconst hostSignal = createHostSignal({\n\t\t\t\thost: this,\n\t\t\t\thydrate: options.hydrate,\n\t\t\t\thydrationKey: propertyName,\n\t\t\t\tinitialValue: resolvedInitialValue,\n\t\t\t\tproperty: propertyName,\n\t\t\t\tsource: resolvedSource,\n\t\t\t});\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\thostSignal.hydrateFromHost();\n\t\t\t\thostSignal.connectToSource();\n\t\t\t});\n\t\t\tthis.registerCleanupCallback(() => {\n\t\t\t\thostSignal.disconnectFromSource();\n\t\t\t});\n\n\t\t\tif (options.hydrate) {\n\t\t\t\tthis.registerHydrationBinding(propertyName, hostSignal);\n\t\t\t}\n\n\t\t\treturn hostSignal as unknown as WritableSignal<Value>;\n\t\t};\n\t};\n}\n",
12
+ "import type { LegacyFieldDecoratorArgs } from '../types';\nimport type { ReactiveHostLike } from '../core/reactive-host';\nimport { signal as legacySignal, type SignalDecoratorOptions } from './legacy/signal';\nimport { signal as standardSignal } from './standard/signal';\nimport type { WritableSignal } from '@ecopages/signals';\n\nexport type { SignalDecoratorOptions } from './standard/signal';\n\ntype SignalDecorator<Value = unknown> = {\n\t<THost extends ReactiveHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, WritableSignal<Value>>,\n\t): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;\n\t(protoOrTarget: ReactiveHostLike, nameOrContext: string): void;\n};\n\n/**\n * Declares a host-aware writable signal field.\n *\n * The decorated member becomes a real `WritableSignal` instance that JSX can\n * consume directly in child or attribute positions. By default the decorator\n * creates a host-owned signal, but it can also connect an existing shared\n * signal through the `source` option or a signal-valued field initializer.\n *\n * Connected signals still flow through Radiant's update callback channel so\n * `@onUpdated(...)` and `this.$.name` bindings continue to work. On\n * `RadiantElement`, any signal or store reads performed during `render()`\n * now participate in rerender invalidation directly, which makes module-level\n * shared stores a natural fit without prop-bridging them through a second\n * reactive layer.\n *\n * When `hydrate` is provided, SSR host output appends a keyed JSON script so\n * the client can restore the signal's initial value during hydration.\n */\nexport function signal<THost extends ReactiveHostLike, Value>(\n\tprotoOrTarget: undefined,\n\tnameOrContext: ClassFieldDecoratorContext<THost, WritableSignal<Value>>,\n): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;\nexport function signal(protoOrTarget: ReactiveHostLike, nameOrContext: string): void;\nexport function signal<Value = unknown>(options?: SignalDecoratorOptions<Value>): SignalDecorator<Value>;\nexport function signal<Value = unknown>(\n\tprotoOrOptions?: ReactiveHostLike | SignalDecoratorOptions<Value>,\n\tnameOrContext?: string | ClassFieldDecoratorContext<ReactiveHostLike, WritableSignal<Value>>,\n):\n\t| ((this: ReactiveHostLike, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>)\n\t| SignalDecorator<Value>\n\t| void {\n\tif (typeof nameOrContext !== 'undefined') {\n\t\tif (typeof nameOrContext === 'object') {\n\t\t\tif (protoOrOptions !== undefined) {\n\t\t\t\tthrow new TypeError('@signal standard decorators require an undefined target');\n\t\t\t}\n\n\t\t\treturn standardSignal<Value>()(undefined, nameOrContext);\n\t\t}\n\n\t\tif (protoOrOptions === undefined) {\n\t\t\tthrow new TypeError('@signal legacy decorators require a host target');\n\t\t}\n\n\t\treturn legacySignal<Value>()(protoOrOptions as LegacyFieldDecoratorArgs['protoOrTarget'], nameOrContext);\n\t}\n\n\tconst options = (protoOrOptions ?? {}) as SignalDecoratorOptions<Value>;\n\n\tfunction decorator<THost extends ReactiveHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tcontextOrName: ClassFieldDecoratorContext<THost, WritableSignal<Value>>,\n\t): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;\n\tfunction decorator(protoOrTarget: ReactiveHostLike, contextOrName: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ReactiveHostLike | undefined,\n\t\tcontextOrName: string | ClassFieldDecoratorContext<ReactiveHostLike, WritableSignal<Value>>,\n\t): ((this: ReactiveHostLike, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>) | void {\n\t\tif (typeof contextOrName === 'object') {\n\t\t\tif (protoOrTarget !== undefined) {\n\t\t\t\tthrow new TypeError('@signal standard decorators require an undefined target');\n\t\t\t}\n\n\t\t\treturn standardSignal<Value>(options)(undefined, contextOrName);\n\t\t}\n\n\t\tif (protoOrTarget === undefined) {\n\t\t\tthrow new TypeError('@signal legacy decorators require a host target');\n\t\t}\n\n\t\treturn legacySignal<Value>(options)(protoOrTarget as LegacyFieldDecoratorArgs['protoOrTarget'], contextOrName);\n\t}\n\n\treturn decorator;\n}\n"
5
13
  ],
6
- "mappings": "",
7
- "debugId": "772B269B2EA6985664756E2164756E21",
14
+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OAAY,EAAQ,QAAU,EAC/C,EACL,EAAQ,MAEP,KACC,gCAAgC,GAClC,GAED,KAAK,sBAAsB,EAAc,CAAI,EAE7C,IAAM,EAAa,EAAiB,CACnC,KAAM,KACN,QAAS,EAAQ,QACjB,aAAc,EACd,aAAc,EACd,SAAU,EACV,OAAQ,CACT,CAAC,EAUD,GARA,KAAK,0BAA0B,IAAM,CACpC,EAAW,gBAAgB,EAC3B,EAAW,gBAAgB,EAC3B,EACD,KAAK,wBAAwB,IAAM,CAClC,EAAW,qBAAqB,EAChC,EAEG,EAAQ,QACX,KAAK,yBAAyB,EAAc,CAAU,EAGvD,OAAO,IC1CH,SAAS,CAAuB,CACtC,EACA,EAIO,CACP,GAAI,OAAO,EAAkB,IAAa,CACzC,GAAI,OAAO,IAAkB,SAAU,CACtC,GAAI,IAAmB,OACtB,MAAU,UAAU,yDAAyD,EAG9E,OAAO,EAAsB,EAAE,OAAW,CAAa,EAGxD,GAAI,IAAmB,OACtB,MAAU,UAAU,iDAAiD,EAGtE,OAAO,EAAoB,EAAE,EAA6D,CAAa,EAGxG,IAAM,EAAW,GAAkB,CAAC,EAOpC,SAAS,CAAS,CACjB,EACA,EAC0G,CAC1G,GAAI,OAAO,IAAkB,SAAU,CACtC,GAAI,IAAkB,OACrB,MAAU,UAAU,yDAAyD,EAG9E,OAAO,EAAsB,CAAO,EAAE,OAAW,CAAa,EAG/D,GAAI,IAAkB,OACrB,MAAU,UAAU,iDAAiD,EAGtE,OAAO,EAAoB,CAAO,EAAE,EAA4D,CAAa,EAG9G,OAAO",
15
+ "debugId": "FB33BA77921C240664756E2164756E21",
8
16
  "names": []
9
17
  }
@@ -0,0 +1,2 @@
1
+ import { type AttrOptions, type ReactiveAttributeHostLike } from '../shared/reactive-attr';
2
+ export declare function reactiveAttr<TValue = string | undefined>(options?: AttrOptions<TValue>): <THost extends ReactiveAttributeHostLike>(target: undefined, context: ClassFieldDecoratorContext<THost, TValue>) => (this: THost, value: TValue) => TValue;
@@ -0,0 +1,3 @@
1
+ var I=((t)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function H(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function E(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(t))return"array";if(Object.prototype.toString.call(t)==="[object Object]")return"object"}function T(t){switch(t){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function $(t){try{return JSON.parse(t)}catch{throw TypeError("Invalid JSON string")}}var z={array(t){let e=$(t);if(!Array.isArray(e))throw TypeError(`Expected an array but got a value of type "${typeof e}"`);return e},boolean(t){return!(t==="0"||String(t).toLowerCase()==="false")},number(t){return Number(t.replace(/_/g,""))},object(t){let e=JSON.parse(t);if(e===null||typeof e!=="object"||Array.isArray(e))throw TypeError(`expected value of type "object" but instead got value "${t}" of type "${E(e)}"`);return e},string(t){return t}},m={default:O,array:v,object:v};function v(t){return JSON.stringify(t)}function O(t){return`${t}`}function f(t,e){let n=H(e);if(!n)throw TypeError(`[radiant-element] Unknown type "${e}"`);return z[n](t)}function B(t,e){let n=H(e);if(!n)throw TypeError(`[radiant-element] Unknown type "${e}"`);return(m[n]??m.default??O)(t)}function M(t){return typeof t==="boolean"}function P(t){return typeof t==="number"}function V(t){return typeof t==="string"}function K(t){return Array.isArray(t)}function U(t){return typeof t==="object"&&!Array.isArray(t)&&t!==null}function L(t,e){switch(t){case Boolean:return M(e);case Number:return P(e);case String:return V(e);case Array:return K(e);case Object:return U(e);default:return!1}}var _=(t,e,n,i)=>{if(e===Boolean){let c=t.getAttribute(n);if(c===null)return i;return c===""?!0:f(c,e)}let r=t.getAttribute(n);return r!==null?f(r,e):i??T(e)};function g(t){if(t instanceof Element)return t;if("host"in t)return t.host;return t.element}function F(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function j(t,e){if(e.converter?.fromAttribute){let n=e.converter.fromAttribute(t);if(t===null&&n===void 0&&"defaultValue"in e)return e.defaultValue;return n}if(e.type){if(t===null)return e.defaultValue??T(e.type);if(e.type===Boolean&&t==="")return!0;return f(t,e.type)}if(t===null)return e.defaultValue;return t}function o(t,e,n){return j(g(t).getAttribute(e),n)}function D(t,e,n,i){let r=i.converter?.toAttribute?i.converter.toAttribute(n):i.type?B(n,i.type):n==null?null:String(n);if(r===null){t.removeAttribute(e);return}t.setAttribute(e,r)}function x(t,e,n={}){if(n.type&&n.defaultValue!==void 0&&!L(n.type,n.defaultValue))throw Error(`defaultValue does not match the expected type for ${n.type.name}`);let i=t,r=n.source??F(e),c=Symbol(`@ecopages/radiant/attr:${e}:observer`),s=Symbol(`@ecopages/radiant/attr:${e}:last-value`),C=n.bind??t.shouldAutoBindReactiveMembers?.()??!1;t.defineReactiveBinding(e,C),t.registerReactiveDependencyReader(e,()=>o(t,r,n)),i[s]=o(t,r,n),Object.defineProperty(t,e,{get(){return t.trackReactiveRead(e),o(this,r,n)},set(d){let u=g(this),A=o(this,r,n);D(u,r,d,n);let b=o(this,r,n);if(Object.is(A,b))return;this[s]=b,t.notifyUpdate(e,A,b)},enumerable:!0,configurable:!0});let a=()=>{i[c]?.disconnect()},l=()=>{let d=o(t,r,n),u=i[s];if(!Object.is(u,d))i[s]=d,t.notifyUpdate(e,u,d);if(typeof MutationObserver>"u")return;let A=g(t);a();let b=new MutationObserver(()=>{let R=o(t,r,n),k=i[s];if(Object.is(k,R))return;i[s]=R,t.notifyUpdate(e,k,R)});b.observe(A,{attributeFilter:[r],attributes:!0}),i[c]=b};l(),t.registerConnectedCallback(l),t.registerCleanupCallback(a)}function W(t={}){return function(e,n){let i=String(n.name),r=Symbol(`@ecopages/radiant/attr:${i}:initializer`);return n.addInitializer(function(){let c=this[r],s=t.defaultValue===void 0?c:t.defaultValue;x(this,i,{...t,defaultValue:s})}),function(c){return this[r]=c,c}}}export{W as reactiveAttr};
2
+
3
+ //# debugId=F1AB634CF55A3FFD64756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils/attribute-utils.ts", "../src/decorators/shared/reactive-attr.ts", "../src/decorators/standard/attr.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
6
+ "import type { ReactiveHostLike } from '../../core/reactive-host';\nimport type { ReactiveBindingOption } from '../../core/radiant-element';\nimport {\n\tdefaultValueForType,\n\tisValueOfType,\n\treadAttributeValue,\n\ttype AttributeTypeConstant,\n\twriteAttributeValue,\n} from '../../utils/attribute-utils';\n\nexport type AttrConverter<T> = {\n\tfromAttribute?: (value: string | null) => T;\n\ttoAttribute?: (value: T) => string | null;\n};\n\nexport type AttrOptions<T = string | undefined> = {\n\tsource?: string;\n\ttype?: AttributeTypeConstant;\n\tbind?: ReactiveBindingOption;\n\tdefaultValue?: T;\n\tconverter?: AttrConverter<T>;\n};\n\ntype ReactiveAttributeHostApi<Bindings extends object = {}> = ReactiveHostLike<Bindings> & {\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\nexport type ReactiveAttributeHostLike<Bindings extends object = {}> =\n\t| (ReactiveAttributeHostApi<Bindings> & Element)\n\t| (ReactiveAttributeHostApi<Bindings> & { host: Element })\n\t| (ReactiveAttributeHostApi<Bindings> & { element: Element });\n\nfunction resolveAttributeTarget(host: ReactiveAttributeHostLike): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction toAttributeName(propertyName: string): string {\n\treturn propertyName\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n\t\t.replace(/_/g, '-')\n\t\t.toLowerCase();\n}\n\nfunction resolveAttributeValue<T>(rawValue: string | null, options: AttrOptions<T>): T {\n\tif (options.converter?.fromAttribute) {\n\t\tconst convertedValue = options.converter.fromAttribute(rawValue);\n\n\t\tif (rawValue === null && convertedValue === undefined && 'defaultValue' in options) {\n\t\t\treturn options.defaultValue as T;\n\t\t}\n\n\t\treturn convertedValue;\n\t}\n\n\tif (options.type) {\n\t\tif (rawValue === null) {\n\t\t\treturn (options.defaultValue ?? defaultValueForType(options.type)) as T;\n\t\t}\n\n\t\tif (options.type === Boolean && rawValue === '') {\n\t\t\treturn true as T;\n\t\t}\n\n\t\treturn readAttributeValue(rawValue, options.type) as T;\n\t}\n\n\tif (rawValue === null) {\n\t\treturn options.defaultValue as T;\n\t}\n\n\treturn rawValue as T;\n}\n\nfunction readReactiveAttributeValue<T>(\n\thost: ReactiveAttributeHostLike,\n\tattributeName: string,\n\toptions: AttrOptions<T>,\n): T {\n\treturn resolveAttributeValue(resolveAttributeTarget(host).getAttribute(attributeName), options);\n}\n\nfunction writeReactiveAttributeValue<T>(\n\ttarget: Element,\n\tattributeName: string,\n\tvalue: T,\n\toptions: AttrOptions<T>,\n): void {\n\tconst attributeValue = options.converter?.toAttribute\n\t\t? options.converter.toAttribute(value)\n\t\t: options.type\n\t\t\t? writeAttributeValue(value, options.type)\n\t\t\t: value == null\n\t\t\t\t? null\n\t\t\t\t: String(value);\n\n\tif (attributeValue === null) {\n\t\ttarget.removeAttribute(attributeName);\n\t\treturn;\n\t}\n\n\ttarget.setAttribute(attributeName, attributeValue);\n}\n\nexport function installReactiveAttribute<TBindings extends object, TValue>(\n\thost: ReactiveAttributeHostLike<TBindings>,\n\tpropertyName: string,\n\toptions: AttrOptions<TValue> = {},\n): void {\n\tif (options.type && options.defaultValue !== undefined && !isValueOfType(options.type, options.defaultValue)) {\n\t\tthrow new Error(`defaultValue does not match the expected type for ${options.type.name}`);\n\t}\n\n\tconst hostRecord = host as unknown as Record<PropertyKey, unknown>;\n\tconst attributeName = options.source ?? toAttributeName(propertyName);\n\tconst observerKey = Symbol(`@ecopages/radiant/attr:${propertyName}:observer`);\n\tconst lastValueKey = Symbol(`@ecopages/radiant/attr:${propertyName}:last-value`);\n\tconst bind =\n\t\toptions.bind ??\n\t\t(host as unknown as { shouldAutoBindReactiveMembers?: () => boolean }).shouldAutoBindReactiveMembers?.() ??\n\t\tfalse;\n\n\thost.defineReactiveBinding(propertyName, bind);\n\thost.registerReactiveDependencyReader(propertyName, () => readReactiveAttributeValue(host, attributeName, options));\n\thostRecord[lastValueKey] = readReactiveAttributeValue(host, attributeName, options);\n\n\tObject.defineProperty(host, propertyName, {\n\t\tget() {\n\t\t\thost.trackReactiveRead(propertyName);\n\t\t\treturn readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t},\n\t\tset(newValue: TValue) {\n\t\t\tconst target = resolveAttributeTarget(this as ReactiveAttributeHostLike);\n\t\t\tconst oldValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t\twriteReactiveAttributeValue(target, attributeName, newValue, options);\n\t\t\tconst nextValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\n\t\t\tif (Object.is(oldValue, nextValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t(this as Record<PropertyKey, unknown>)[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, oldValue, nextValue);\n\t\t},\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\tconst disconnectObserver = () => {\n\t\tconst observer = hostRecord[observerKey] as MutationObserver | undefined;\n\t\tobserver?.disconnect();\n\t};\n\n\tconst syncAndObserve = () => {\n\t\tconst nextValue = readReactiveAttributeValue(host, attributeName, options);\n\t\tconst previousValue = hostRecord[lastValueKey];\n\n\t\tif (!Object.is(previousValue, nextValue)) {\n\t\t\thostRecord[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, previousValue, nextValue);\n\t\t}\n\n\t\tif (typeof MutationObserver === 'undefined') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = resolveAttributeTarget(host);\n\n\t\tdisconnectObserver();\n\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst currentValue = readReactiveAttributeValue(host, attributeName, options);\n\t\t\tconst lastValue = hostRecord[lastValueKey];\n\n\t\t\tif (Object.is(lastValue, currentValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thostRecord[lastValueKey] = currentValue;\n\t\t\thost.notifyUpdate(propertyName, lastValue, currentValue);\n\t\t});\n\n\t\tobserver.observe(target, {\n\t\t\tattributeFilter: [attributeName],\n\t\t\tattributes: true,\n\t\t});\n\n\t\thostRecord[observerKey] = observer;\n\t};\n\n\tsyncAndObserve();\n\thost.registerConnectedCallback(syncAndObserve);\n\thost.registerCleanupCallback(disconnectObserver);\n}\n",
7
+ "import { installReactiveAttribute, type AttrOptions, type ReactiveAttributeHostLike } from '../shared/reactive-attr';\n\nexport function reactiveAttr<TValue = string | undefined>(options: AttrOptions<TValue> = {}) {\n\treturn function <THost extends ReactiveAttributeHostLike>(\n\t\ttarget: undefined,\n\t\tcontext: ClassFieldDecoratorContext<THost, TValue>,\n\t) {\n\t\tvoid target;\n\t\tconst propertyName = String(context.name);\n\t\tconst initializerValueKey = Symbol(`@ecopages/radiant/attr:${propertyName}:initializer`);\n\n\t\tcontext.addInitializer(function (this: THost) {\n\t\t\tconst initializerValue = (this as Record<PropertyKey, TValue | undefined>)[initializerValueKey];\n\t\t\tconst defaultValue = (options.defaultValue === undefined ? initializerValue : options.defaultValue) as\n\t\t\t\t| TValue\n\t\t\t\t| undefined;\n\n\t\t\tinstallReactiveAttribute(this, propertyName, {\n\t\t\t\t...options,\n\t\t\t\tdefaultValue,\n\t\t\t});\n\t\t});\n\n\t\treturn function (this: THost, value: TValue) {\n\t\t\t(this as Record<PropertyKey, TValue | undefined>)[initializerValueKey] = value;\n\t\t\treturn value;\n\t\t};\n\t};\n}\n"
8
+ ],
9
+ "mappings": "2PAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ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xB,gBAAiB,CAAC,CAAa,EAC/B,WAAY,EACb,CAAC,EAED,EAAW,GAAe,GAG3B,EAAe,EACf,EAAK,0BAA0B,CAAc,EAC7C,EAAK,wBAAwB,CAAkB,ECtMzC,SAAS,CAAyC,CAAC,EAA+B,CAAC,EAAG,CAC5F,OAAO,QAAkD,CACxD,EACA,EACC,CAED,IAAM,EAAe,OAAO,EAAQ,IAAI,EAClC,EAAsB,OAAO,0BAA0B,eAA0B,EAcvF,OAZA,EAAQ,eAAe,QAAS,EAAc,CAC7C,IAAM,EAAoB,KAAiD,GACrE,EAAgB,EAAQ,eAAiB,OAAY,EAAmB,EAAQ,aAItF,EAAyB,KAAM,EAAc,IACzC,EACH,cACD,CAAC,EACD,EAEM,QAAS,CAAc,EAAe,CAE5C,OADC,KAAiD,GAAuB,EAClE",
10
+ "debugId": "F1AB634CF55A3FFD64756E2164756E21",
11
+ "names": []
12
+ }
@@ -1,3 +1,3 @@
1
- import{ia as a}from"../../chunk-rkh1vkb9.js";import"../../chunk-vgtggzb6.js";export{a as bound};
1
+ var o=((t)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function n(t,e){let i=String(e.name);if(e.private)throw Error(`'bound' cannot decorate private properties like ${i}.`);e.addInitializer(function(){this[i]=this[i].bind(this)})}export{n as bound};
2
2
 
3
- //# debugId=1CF81EC19E4E722764756E2164756E21
3
+ //# debugId=310E0A7CD1B4A56564756E2164756E21
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/decorators/standard/bound.ts"],
4
4
  "sourcesContent": [
5
+ "import type { Method } from '../../types';\n\nexport function bound<T extends Method>(_: T, context: ClassMethodDecoratorContext) {\n\tconst methodName = String(context.name);\n\tif (context.private) {\n\t\tthrow new Error(`'bound' cannot decorate private properties like ${methodName as string}.`);\n\t}\n\tcontext.addInitializer(function (this: any) {\n\t\tthis[methodName] = this[methodName].bind(this);\n\t});\n}\n"
5
6
  ],
6
- "mappings": "",
7
- "debugId": "1CF81EC19E4E722764756E2164756E21",
7
+ "mappings": "2PAEO,SAAS,CAAuB,CAAC,EAAM,EAAsC,CACnF,IAAM,EAAa,OAAO,EAAQ,IAAI,EACtC,GAAI,EAAQ,QACX,MAAU,MAAM,mDAAmD,IAAuB,EAE3F,EAAQ,eAAe,QAAS,EAAY,CAC3C,KAAK,GAAc,KAAK,GAAY,KAAK,IAAI,EAC7C",
8
+ "debugId": "310E0A7CD1B4A56564756E2164756E21",
8
9
  "names": []
9
10
  }
@@ -1,3 +1,3 @@
1
- import{ra as a}from"../../chunk-mp2vtrkg.js";import"../../chunk-hztr86b4.js";import"../../chunk-vgtggzb6.js";export{a as customElement};
1
+ var B=((b)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(b,{get:(j,k)=>(typeof require<"u"?require:j)[k]}):b)(function(b){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+b+'" is not supported')});var q=Symbol.for("@ecopages/radiant.customElementTagName");function y(b,j){b[q]=j}function F(b){return b[q]}function J(b,j){return function(k,z){z.addInitializer(function(){if(y(this,b),typeof customElements<"u"&&!customElements.get(b))customElements.define(b,this,j)})}}export{J as customElement};
2
2
 
3
- //# debugId=444C90C7499A037B64756E2164756E21
3
+ //# debugId=3A73EAEEEA884AE964756E2164756E21
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/core/custom-element-metadata.ts", "../src/decorators/standard/custom-element.ts"],
4
4
  "sourcesContent": [
5
+ "export const CUSTOM_ELEMENT_TAG_NAME = Symbol.for('@ecopages/radiant.customElementTagName');\n\ntype CustomElementConstructorWithMetadata = CustomElementConstructor & {\n\t[CUSTOM_ELEMENT_TAG_NAME]?: string;\n};\n\n/**\n * Sets the custom element tag name for a given constructor.\n * This is used internally to associate a class with its custom element tag, which is necessary for features like hydration and SSR support.\n * @param target The constructor of the custom element.\n * @param tagName The tag name to associate with the custom element.\n */\nexport function setCustomElementTagName(target: CustomElementConstructor, tagName: string): void {\n\t(target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME] = tagName;\n}\n\n/**\n * Retrieves the custom element tag name associated with a given constructor.\n * @param target The constructor of the custom element.\n * @returns The tag name associated with the custom element, or `undefined` if not set.\n */\nexport function getCustomElementTagName(target: CustomElementConstructor): string | undefined {\n\treturn (target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME];\n}\n",
6
+ "import { setCustomElementTagName } from '../../core/custom-element-metadata';\n\nexport function customElement(name: string, options?: ElementDefinitionOptions) {\n\treturn function <T extends CustomElementConstructor>(_: T, context: ClassDecoratorContext<T>) {\n\t\tcontext.addInitializer(function () {\n\t\t\tsetCustomElementTagName(this, name);\n\n\t\t\tif (typeof customElements !== 'undefined' && !customElements.get(name)) {\n\t\t\t\tcustomElements.define(name, this, options);\n\t\t\t}\n\t\t});\n\t};\n}\n"
5
7
  ],
6
- "mappings": "",
7
- "debugId": "444C90C7499A037B64756E2164756E21",
8
+ "mappings": "2PAAO,IAAM,EAA0B,OAAO,IAAI,wCAAwC,EAYnF,SAAS,CAAuB,CAAC,EAAkC,EAAuB,CAC/F,EAAgD,GAA2B,EAQtE,SAAS,CAAuB,CAAC,EAAsD,CAC7F,OAAQ,EAAgD,GCpBlD,SAAS,CAAa,CAAC,EAAc,EAAoC,CAC/E,OAAO,QAA6C,CAAC,EAAM,EAAmC,CAC7F,EAAQ,eAAe,QAAS,EAAG,CAGlC,GAFA,EAAwB,KAAM,CAAI,EAE9B,OAAO,eAAmB,KAAe,CAAC,eAAe,IAAI,CAAI,EACpE,eAAe,OAAO,EAAM,KAAM,CAAO,EAE1C",
9
+ "debugId": "3A73EAEEEA884AE964756E2164756E21",
8
10
  "names": []
9
11
  }
@@ -1,3 +1,3 @@
1
- import{la as a}from"../../chunk-8d5ddvvf.js";import"../../chunk-wd23rn4q.js";import"../../chunk-vgtggzb6.js";export{a as debounce};
1
+ var D=((F)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(F,{get:(x,M)=>(typeof require<"u"?require:x)[M]}):F)(function(F){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+F+'" is not supported')});function z(F,x){let M=null,y=null,j,B=()=>{if(M!==null)clearTimeout(M),M=null},q=()=>{if(y===null)return j;let W=y;return y=null,B(),j=W(),j},T=function(...W){y=()=>F.apply(this,W),B(),M=setTimeout(()=>{q()},x)};return T.cancel=()=>{B(),y=null},T.flush=()=>{if(y===null)return j;return q()},T.pending=()=>y!==null,T}function J(F){return(x)=>{let M=new WeakMap;return function(...y){let j=M.get(this);if(!j)j=z((...B)=>{return x.apply(this,B)},F),M.set(this,j);j(...y)}}}export{J as debounce};
2
2
 
3
- //# debugId=1224EAAB2694FF7064756E2164756E21
3
+ //# debugId=D1A684ED03E4C21164756E2164756E21
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/helpers/debounce.ts", "../src/decorators/standard/debounce.ts"],
4
4
  "sourcesContent": [
5
+ "import type { Method } from '../types';\n\n/**\n * A debounced function with imperative helpers for controlling pending work.\n *\n * @typeParam T The wrapped callback type.\n */\nexport interface DebouncedFunction<T extends Method> {\n\t(...args: Parameters<T>): void;\n\n\t/**\n\t * Cancels the pending callback invocation, if one exists.\n\t */\n\tcancel(): void;\n\n\t/**\n\t * Immediately invokes the latest pending callback invocation.\n\t *\n\t * @returns The callback result when a call is pending, or the last completed\n\t * result when no call is pending.\n\t */\n\tflush(): ReturnType<T> | undefined;\n\n\t/**\n\t * Reports whether the callback currently has a scheduled invocation.\n\t *\n\t * @returns True when a call is pending.\n\t */\n\tpending(): boolean;\n}\n\n/**\n * Creates a debounced wrapper around a function.\n *\n * The returned function delays invocation until the configured timeout has\n * elapsed since the latest call. It also exposes helpers to cancel, flush,\n * and inspect pending work.\n *\n * @typeParam T The wrapped callback type.\n * @param callback The callback to debounce.\n * @param timeout The debounce timeout in milliseconds.\n * @returns A debounced wrapper around the callback.\n */\nexport function debounce<T extends Method>(callback: T, timeout: number): DebouncedFunction<T> {\n\tlet timeoutRef: ReturnType<typeof setTimeout> | null = null;\n\tlet pendingInvocation: (() => ReturnType<T>) | null = null;\n\tlet lastResult: ReturnType<T> | undefined;\n\n\tconst clearPendingCall = () => {\n\t\tif (timeoutRef !== null) {\n\t\t\tclearTimeout(timeoutRef);\n\t\t\ttimeoutRef = null;\n\t\t}\n\t};\n\n\tconst invoke = (): ReturnType<T> | undefined => {\n\t\tif (pendingInvocation === null) {\n\t\t\treturn lastResult;\n\t\t}\n\n\t\tconst invocation = pendingInvocation;\n\t\tpendingInvocation = null;\n\t\tclearPendingCall();\n\t\tlastResult = invocation();\n\n\t\treturn lastResult;\n\t};\n\n\tconst debounced = function (this: ThisParameterType<T>, ...args: Parameters<T>) {\n\t\tpendingInvocation = () => callback.apply(this, args) as ReturnType<T>;\n\t\tclearPendingCall();\n\t\ttimeoutRef = setTimeout(() => {\n\t\t\tinvoke();\n\t\t}, timeout);\n\t} as DebouncedFunction<T>;\n\n\tdebounced.cancel = () => {\n\t\tclearPendingCall();\n\t\tpendingInvocation = null;\n\t};\n\n\tdebounced.flush = () => {\n\t\tif (pendingInvocation === null) {\n\t\t\treturn lastResult;\n\t\t}\n\n\t\treturn invoke();\n\t};\n\n\tdebounced.pending = () => pendingInvocation !== null;\n\n\treturn debounced;\n}\n",
6
+ "import { debounce as debounceFunction } from '../../helpers/debounce';\nimport type { Method } from '../../types';\n\nexport function debounce(timeout: number): Method {\n\treturn <T extends Method>(originalMethod: T): Method => {\n\t\tconst debouncedByInstance = new WeakMap<object, ReturnType<typeof debounceFunction<T>>>();\n\n\t\treturn function (this: object, ...args: Parameters<T>): void {\n\t\t\tlet debounced = debouncedByInstance.get(this);\n\n\t\t\tif (!debounced) {\n\t\t\t\tdebounced = debounceFunction((...innerArgs: Parameters<T>) => {\n\t\t\t\t\treturn originalMethod.apply(this, innerArgs);\n\t\t\t\t}, timeout);\n\t\t\t\tdebouncedByInstance.set(this, debounced);\n\t\t\t}\n\n\t\t\tdebounced(...args);\n\t\t};\n\t};\n}\n"
5
7
  ],
6
- "mappings": "",
7
- "debugId": "1224EAAB2694FF7064756E2164756E21",
8
+ "mappings": "2PA2CO,SAAS,CAA0B,CAAC,EAAa,EAAuC,CAC9F,IAAI,EAAmD,KACnD,EAAkD,KAClD,EAEE,EAAmB,IAAM,CAC9B,GAAI,IAAe,KAClB,aAAa,CAAU,EACvB,EAAa,MAIT,EAAS,IAAiC,CAC/C,GAAI,IAAsB,KACzB,OAAO,EAGR,IAAM,EAAa,EAKnB,OAJA,EAAoB,KACpB,EAAiB,EACjB,EAAa,EAAW,EAEjB,GAGF,EAAY,QAAS,IAAgC,EAAqB,CAC/E,EAAoB,IAAM,EAAS,MAAM,KAAM,CAAI,EACnD,EAAiB,EACjB,EAAa,WAAW,IAAM,CAC7B,EAAO,GACL,CAAO,GAkBX,OAfA,EAAU,OAAS,IAAM,CACxB,EAAiB,EACjB,EAAoB,MAGrB,EAAU,MAAQ,IAAM,CACvB,GAAI,IAAsB,KACzB,OAAO,EAGR,OAAO,EAAO,GAGf,EAAU,QAAU,IAAM,IAAsB,KAEzC,ECxFD,SAAS,CAAQ,CAAC,EAAyB,CACjD,MAAO,CAAmB,IAA8B,CACvD,IAAM,EAAsB,IAAI,QAEhC,OAAO,QAAS,IAAkB,EAA2B,CAC5D,IAAI,EAAY,EAAoB,IAAI,IAAI,EAE5C,GAAI,CAAC,EACJ,EAAY,EAAiB,IAAI,IAA6B,CAC7D,OAAO,EAAe,MAAM,KAAM,CAAS,GACzC,CAAO,EACV,EAAoB,IAAI,KAAM,CAAS,EAGxC,EAAU,GAAG,CAAI",
9
+ "debugId": "D1A684ED03E4C21164756E2164756E21",
8
10
  "names": []
9
11
  }
@@ -1,3 +1,3 @@
1
- import{fa as a}from"../../chunk-w8s5fnsq.js";import"../../chunk-rrg759ht.js";import"../../chunk-wvd1ffe4.js";import"../../chunk-vgtggzb6.js";export{a as event};
1
+ var K=((z)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(z,{get:(A,B)=>(typeof require<"u"?require:A)[B]}):z)(function(z){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+z+'" is not supported')});class G{host;eventConfig;constructor(z,A){this.host=z,this.eventConfig=A}emit(z){let A=new CustomEvent(this.eventConfig.name,{detail:z,bubbles:this.eventConfig.bubbles,cancelable:this.eventConfig.cancelable,composed:this.eventConfig.composed});this.host.dispatchEvent(A)}}function H(z,A){let B=new G(z,A);return z.registerEventEmitter(A.name,B),B}function Q(z){return function(A,B){B.addInitializer(function(){let I=H(this,z);Object.defineProperty(this,B.name,{get(){return I},enumerable:!0,configurable:!0})})}}export{Q as event};
2
2
 
3
- //# debugId=9A561DDB1B5B4B5064756E2164756E21
3
+ //# debugId=296EAF1229B044B664756E2164756E21
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/tools/event-emitter.ts", "../src/helpers/create-event.ts", "../src/decorators/standard/event.ts"],
4
4
  "sourcesContent": [
5
+ "import type { RadiantElement } from '../core/radiant-element';\n\nexport interface EventEmitterConfig {\n\tname: string;\n\tbubbles?: boolean;\n\tcancelable?: boolean;\n\tcomposed?: boolean;\n}\n\n/**\n * A generic event emitter class that allows emitting custom events.\n *\n * @template T - The type of the event detail.\n */\nexport class EventEmitter<T = unknown> {\n\tprivate host: RadiantElement;\n\tprivate eventConfig: EventEmitterConfig;\n\n\t/**\n\t * Constructs a new instance of the EventEmitter class.\n\t *\n\t * @param host - The host element on which the events will be dispatched.\n\t * @param eventConfig - The configuration for the event.\n\t */\n\tconstructor(host: RadiantElement, eventConfig: EventEmitterConfig) {\n\t\tthis.host = host;\n\t\tthis.eventConfig = eventConfig;\n\t}\n\n\t/**\n\t * Emits a custom event with the specified detail.\n\t *\n\t * @param detail - The detail object to be passed along with the event.\n\t */\n\temit(detail?: T) {\n\t\tconst event = new CustomEvent(this.eventConfig.name, {\n\t\t\tdetail: detail,\n\t\t\tbubbles: this.eventConfig.bubbles,\n\t\t\tcancelable: this.eventConfig.cancelable,\n\t\t\tcomposed: this.eventConfig.composed,\n\t\t});\n\t\tthis.host.dispatchEvent(event);\n\t}\n}\n",
6
+ "import type { RadiantElement } from '../core/radiant-element';\nimport { EventEmitter, type EventEmitterConfig } from '../tools/event-emitter';\n\n/**\n * Creates an EventEmitter bound to a host element and registers it on the host.\n * Functional equivalent of the `@event` decorator for vanilla JS usage.\n * @param host The host element that will dispatch the events.\n * @param config {@link EventEmitterConfig} The event emitter configuration.\n */\nexport function createEvent<T = unknown>(host: RadiantElement, config: EventEmitterConfig): EventEmitter<T> {\n\tconst emitter = new EventEmitter<T>(host, config);\n\thost.registerEventEmitter(config.name, emitter);\n\treturn emitter;\n}\n",
7
+ "import type { RadiantElement } from '../../core/radiant-element';\nimport { createEvent } from '../../helpers/create-event';\nimport type { EventEmitterConfig } from '../../tools/event-emitter';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\treturn function <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst emitter = createEvent(this, eventConfig);\n\n\t\t\tObject.defineProperty(this, context.name, {\n\t\t\t\tget() {\n\t\t\t\t\treturn emitter;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t});\n\t};\n}\n"
5
8
  ],
6
- "mappings": "",
7
- "debugId": "9A561DDB1B5B4B5064756E2164756E21",
9
+ "mappings": "2PAcO,MAAM,CAA0B,CAC9B,KACA,YAQR,WAAW,CAAC,EAAsB,EAAiC,CAClE,KAAK,KAAO,EACZ,KAAK,YAAc,EAQpB,IAAI,CAAC,EAAY,CAChB,IAAM,EAAQ,IAAI,YAAY,KAAK,YAAY,KAAM,CACpD,OAAQ,EACR,QAAS,KAAK,YAAY,QAC1B,WAAY,KAAK,YAAY,WAC7B,SAAU,KAAK,YAAY,QAC5B,CAAC,EACD,KAAK,KAAK,cAAc,CAAK,EAE/B,CClCO,SAAS,CAAwB,CAAC,EAAsB,EAA6C,CAC3G,IAAM,EAAU,IAAI,EAAgB,EAAM,CAAM,EAEhD,OADA,EAAK,qBAAqB,EAAO,KAAM,CAAO,EACvC,ECFD,SAAS,CAAK,CAAC,EAAiC,CACtD,OAAO,QAAsC,CAAC,EAAc,EAA2C,CACtG,EAAQ,eAAe,QAAS,EAAU,CACzC,IAAM,EAAU,EAAY,KAAM,CAAW,EAE7C,OAAO,eAAe,KAAM,EAAQ,KAAM,CACzC,GAAG,EAAG,CACL,OAAO,GAER,WAAY,GACZ,aAAc,EACf,CAAC,EACD",
10
+ "debugId": "296EAF1229B044B664756E2164756E21",
8
11
  "names": []
9
12
  }
@@ -1,3 +1,4 @@
1
+ import { type EventListenerHost } from '../../helpers/create-event-listener';
1
2
  import type { OnEventConfig } from '../on-event';
2
3
  import type { Method } from '../../types';
3
4
  /**
@@ -14,4 +15,4 @@ import type { Method } from '../../types';
14
15
  * @param eventConfig.type The type of the event to listen for.
15
16
  * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.
16
17
  */
17
- export declare function onEvent(eventConfig: OnEventConfig): <T extends Method>(originalMethod: T, context: ClassMethodDecoratorContext) => void;
18
+ export declare function onEvent(eventConfig: OnEventConfig): <Host extends EventListenerHost, T extends Method>(originalMethod: T, context: ClassMethodDecoratorContext<Host, T>) => void;
@@ -1,3 +1,3 @@
1
- import{ua as a}from"../../chunk-v3ta7hnv.js";import"../../chunk-hrjc8b1y.js";import"../../chunk-vgtggzb6.js";export{a as onEvent};
1
+ var x=((z)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(z,{get:(j,B)=>(typeof require<"u"?require:j)[B]}):z)(function(z){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+z+'" is not supported')});var V=Symbol("radiant.shadowRootListenerHooks"),_=Symbol("radiant.patchedAttachShadow");function q(z){if(z instanceof Element)return z;if("host"in z)return z.host;return z.element}function J(z){return!(z instanceof Element)}function $(z,j,B,N){let G=(I)=>{if(I.target instanceof Element&&I.target.matches(B))N(I)};return z.addEventListener(j.type,G,j.options),()=>{z.removeEventListener(j.type,G,j.options)}}function O(z,j){let B=q(z);if(!B[V])B[V]=new Set;if(B[V].add(j),B[_])return;let N=B.attachShadow;B.attachShadow=function(I){let P=N.call(this,I);for(let Q of B[V]??[])Q();return P},B[_]=!0}function F(z,j,B){if(J(z)&&"scope"in j&&j.scope&&j.scope!=="light")throw Error("RadiantController event listeners only support light DOM scope.");let N=q(z),G=B.bind(z),I=null,P=null,Q=null,U=null,X=!1,Y=()=>{I?.(),P?.(),Q?.(),U?.(),I=null,P=null,Q=null,U=null},W=()=>{if(X)return;if("window"in j&&!I)window.addEventListener(j.type,G,j.options),I=()=>{window.removeEventListener(j.type,G,j.options)};if("document"in j&&!P)document.addEventListener(j.type,G,j.options),P=()=>{document.removeEventListener(j.type,G,j.options)};if("selector"in j||"ref"in j){let Z="selector"in j?j.selector:`[data-ref='${CSS.escape(j.ref)}']`;if(j.scope!=="shadow"&&!Q)Q=$(N,j,Z,G);if(j.scope!=="light"&&N.shadowRoot&&!U)U=$(N.shadowRoot,j,Z,G)}};if("selector"in j||"ref"in j){if(j.scope!=="light")O(z,()=>{if(z.isConnected)W()})}if(z.registerConnectedCallback(W),z.registerCleanupCallback(Y),z.isConnected)W();return()=>{X=!0,Y()}}function y(z){return function(j,B){B.addInitializer(function(){F(this,z,j.bind(this))})}}export{y as onEvent};
2
2
 
3
- //# debugId=840EA949D6BDDCC064756E2164756E21
3
+ //# debugId=8F5AD2177CBE9C8164756E2164756E21
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../src/helpers/create-event-listener.ts", "../src/decorators/standard/on-event.ts"],
4
4
  "sourcesContent": [
5
+ "import type { RadiantElementEventListener } from '../core/radiant-element';\n\n/**\n * Selects which DOM tree delegated event listeners should observe.\n */\nexport type OnEventScope = 'light' | 'shadow' | 'both';\n\ntype BaseOnEventConfig = Pick<RadiantElementEventListener, 'type' | 'options'> & {\n\tscope?: OnEventScope;\n};\n\nexport type OnEventConfig = BaseOnEventConfig &\n\t(\n\t\t| {\n\t\t\t\tselector: string;\n\t\t }\n\t\t| {\n\t\t\t\tref: string;\n\t\t }\n\t\t| {\n\t\t\t\twindow: true;\n\t\t }\n\t\t| {\n\t\t\t\tdocument: true;\n\t\t }\n\t);\n\ntype DelegatedEventRoot = Element | ShadowRoot;\n\ntype EventListenerLifecycleHost = {\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterCleanupCallback(callback: () => void): void;\n\tisConnected: boolean;\n};\n\nexport type EventListenerHost =\n\t| (EventListenerLifecycleHost & Element)\n\t| (EventListenerLifecycleHost & { host: Element })\n\t| (EventListenerLifecycleHost & { element: Element });\n\nconst shadowRootListenerHooksKey = Symbol('radiant.shadowRootListenerHooks');\nconst patchedAttachShadowKey = Symbol('radiant.patchedAttachShadow');\n\ntype ShadowRootHookHost = Element & {\n\t[patchedAttachShadowKey]?: true;\n\t[shadowRootListenerHooksKey]?: Set<() => void>;\n};\n\nfunction resolveEventListenerHostElement(host: EventListenerHost): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction isControllerEventHost(host: EventListenerHost): host is EventListenerLifecycleHost & { host: Element } {\n\treturn !(host instanceof Element);\n}\n\nfunction addDelegatedListener(\n\troot: DelegatedEventRoot,\n\tconfig: Pick<OnEventConfig, 'type' | 'options'>,\n\tselector: string,\n\tlistener: EventListener,\n): () => void {\n\tconst delegatedListener = (event: Event) => {\n\t\tif (event.target instanceof Element && event.target.matches(selector)) {\n\t\t\tlistener(event);\n\t\t}\n\t};\n\n\troot.addEventListener(config.type, delegatedListener, config.options);\n\n\treturn () => {\n\t\troot.removeEventListener(config.type, delegatedListener, config.options);\n\t};\n}\n\nfunction registerShadowRootHook(host: EventListenerHost, hook: () => void): void {\n\tconst shadowAwareHost = resolveEventListenerHostElement(host) as ShadowRootHookHost;\n\n\tif (!shadowAwareHost[shadowRootListenerHooksKey]) {\n\t\tshadowAwareHost[shadowRootListenerHooksKey] = new Set();\n\t}\n\n\tshadowAwareHost[shadowRootListenerHooksKey].add(hook);\n\n\tif (shadowAwareHost[patchedAttachShadowKey]) {\n\t\treturn;\n\t}\n\n\tconst originalAttachShadow = shadowAwareHost.attachShadow;\n\n\tshadowAwareHost.attachShadow = function patchedAttachShadow(init: ShadowRootInit): ShadowRoot {\n\t\tconst shadowRoot = originalAttachShadow.call(this, init);\n\t\tfor (const shadowRootHook of shadowAwareHost[shadowRootListenerHooksKey] ?? []) {\n\t\t\tshadowRootHook();\n\t\t}\n\t\treturn shadowRoot;\n\t};\n\n\tshadowAwareHost[patchedAttachShadowKey] = true;\n}\n\n/**\n * Subscribes to a DOM event with delegation, window, or document targeting.\n * Functional equivalent of the `@onEvent` decorator for vanilla JS usage.\n * Returns a cleanup function to remove the listener.\n * @param host The host RadiantElement.\n * @param config The event listener configuration.\n * @param callback The event handler function.\n */\nexport function createEventListener(\n\thost: EventListenerHost,\n\tconfig: OnEventConfig,\n\tcallback: (event: Event) => void,\n): () => void {\n\tif (isControllerEventHost(host) && 'scope' in config && config.scope && config.scope !== 'light') {\n\t\tthrow new Error('RadiantController event listeners only support light DOM scope.');\n\t}\n\n\tconst hostElement = resolveEventListenerHostElement(host);\n\tconst boundCallback = callback.bind(host);\n\tlet windowCleanup: (() => void) | null = null;\n\tlet documentCleanup: (() => void) | null = null;\n\tlet lightCleanup: (() => void) | null = null;\n\tlet shadowCleanup: (() => void) | null = null;\n\tlet disposed = false;\n\n\tconst detachListeners = () => {\n\t\twindowCleanup?.();\n\t\tdocumentCleanup?.();\n\t\tlightCleanup?.();\n\t\tshadowCleanup?.();\n\n\t\twindowCleanup = null;\n\t\tdocumentCleanup = null;\n\t\tlightCleanup = null;\n\t\tshadowCleanup = null;\n\t};\n\n\tconst attachListeners = () => {\n\t\tif (disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ('window' in config && !windowCleanup) {\n\t\t\twindow.addEventListener(config.type, boundCallback, config.options);\n\t\t\twindowCleanup = () => {\n\t\t\t\twindow.removeEventListener(config.type, boundCallback, config.options);\n\t\t\t};\n\t\t}\n\n\t\tif ('document' in config && !documentCleanup) {\n\t\t\tdocument.addEventListener(config.type, boundCallback, config.options);\n\t\t\tdocumentCleanup = () => {\n\t\t\t\tdocument.removeEventListener(config.type, boundCallback, config.options);\n\t\t\t};\n\t\t}\n\n\t\tif ('selector' in config || 'ref' in config) {\n\t\t\tconst selector = 'selector' in config ? config.selector : `[data-ref='${CSS.escape(config.ref)}']`;\n\n\t\t\tif (config.scope !== 'shadow' && !lightCleanup) {\n\t\t\t\tlightCleanup = addDelegatedListener(hostElement, config, selector, boundCallback);\n\t\t\t}\n\n\t\t\tif (config.scope !== 'light' && hostElement.shadowRoot && !shadowCleanup) {\n\t\t\t\tshadowCleanup = addDelegatedListener(hostElement.shadowRoot, config, selector, boundCallback);\n\t\t\t}\n\t\t}\n\t};\n\n\tif ('selector' in config || 'ref' in config) {\n\t\tif (config.scope !== 'light') {\n\t\t\tregisterShadowRootHook(host, () => {\n\t\t\t\tif (host.isConnected) {\n\t\t\t\t\tattachListeners();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\thost.registerConnectedCallback(attachListeners);\n\thost.registerCleanupCallback(detachListeners);\n\n\tif (host.isConnected) {\n\t\tattachListeners();\n\t}\n\n\treturn () => {\n\t\tdisposed = true;\n\t\tdetachListeners();\n\t};\n}\n",
6
+ "import { createEventListener, type EventListenerHost } from '../../helpers/create-event-listener';\nimport type { OnEventConfig } from '../on-event';\nimport type { Method } from '../../types';\n\n/**\n * A decorator to subscribe to an event on the target element.\n * The event listener will be automatically unsubscribed when the element is disconnected.\n *\n * Note: This decorator uses event delegation, which means it relies on event bubbling.\n * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.\n * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.\n *\n * @param eventConfig The event configuration.\n * @param eventConfig.selectors The CSS selector(s) of the target element(s).\n * @param eventConfig.ref The data-ref attribute of the target element.\n * @param eventConfig.type The type of the event to listen for.\n * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.\n */\nexport function onEvent(eventConfig: OnEventConfig) {\n\treturn function <Host extends EventListenerHost, T extends Method>(\n\t\toriginalMethod: T,\n\t\tcontext: ClassMethodDecoratorContext<Host, T>,\n\t): void {\n\t\tcontext.addInitializer(function (this: Host) {\n\t\t\tcreateEventListener(this, eventConfig, originalMethod.bind(this));\n\t\t});\n\t};\n}\n"
5
7
  ],
6
- "mappings": "",
7
- "debugId": "840EA949D6BDDCC064756E2164756E21",
8
+ "mappings": "2PAwCA,IAAM,EAA6B,OAAO,iCAAiC,EACrE,EAAyB,OAAO,6BAA6B,EAOnE,SAAS,CAA+B,CAAC,EAAkC,CAC1E,GAAI,aAAgB,QACnB,OAAO,EAGR,GAAI,SAAU,EACb,OAAO,EAAK,KAGb,OAAO,EAAK,QAGb,SAAS,CAAqB,CAAC,EAAiF,CAC/G,MAAO,EAAE,aAAgB,SAG1B,SAAS,CAAoB,CAC5B,EACA,EACA,EACA,EACa,CACb,IAAM,EAAoB,CAAC,IAAiB,CAC3C,GAAI,EAAM,kBAAkB,SAAW,EAAM,OAAO,QAAQ,CAAQ,EACnE,EAAS,CAAK,GAMhB,OAFA,EAAK,iBAAiB,EAAO,KAAM,EAAmB,EAA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