@bquery/bquery 1.6.0 → 1.8.1

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 (402) hide show
  1. package/README.md +192 -18
  2. package/dist/a11y/announce.d.ts +43 -0
  3. package/dist/a11y/announce.d.ts.map +1 -0
  4. package/dist/a11y/audit.d.ts +42 -0
  5. package/dist/a11y/audit.d.ts.map +1 -0
  6. package/dist/a11y/index.d.ts +53 -0
  7. package/dist/a11y/index.d.ts.map +1 -0
  8. package/dist/a11y/media-preferences.d.ts +77 -0
  9. package/dist/a11y/media-preferences.d.ts.map +1 -0
  10. package/dist/a11y/roving-tab-index.d.ts +38 -0
  11. package/dist/a11y/roving-tab-index.d.ts.map +1 -0
  12. package/dist/a11y/skip-link.d.ts +37 -0
  13. package/dist/a11y/skip-link.d.ts.map +1 -0
  14. package/dist/a11y/trap-focus.d.ts +49 -0
  15. package/dist/a11y/trap-focus.d.ts.map +1 -0
  16. package/dist/a11y/types.d.ts +152 -0
  17. package/dist/a11y/types.d.ts.map +1 -0
  18. package/dist/a11y-DVBCy09c.js +421 -0
  19. package/dist/a11y-DVBCy09c.js.map +1 -0
  20. package/dist/a11y.es.mjs +14 -0
  21. package/dist/component/component.d.ts.map +1 -1
  22. package/dist/component/html.d.ts.map +1 -1
  23. package/dist/component/index.d.ts +2 -1
  24. package/dist/component/index.d.ts.map +1 -1
  25. package/dist/component/library.d.ts.map +1 -1
  26. package/dist/component/scope.d.ts +138 -0
  27. package/dist/component/scope.d.ts.map +1 -0
  28. package/dist/component/types.d.ts +53 -1
  29. package/dist/component/types.d.ts.map +1 -1
  30. package/dist/component-L3-JfOFz.js +684 -0
  31. package/dist/component-L3-JfOFz.js.map +1 -0
  32. package/dist/component.es.mjs +9 -6
  33. package/dist/{config-DRmZZno3.js → config-DhT9auRm.js} +4 -4
  34. package/dist/{config-DRmZZno3.js.map → config-DhT9auRm.js.map} +1 -1
  35. package/dist/constraints-D5RHQLmP.js +100 -0
  36. package/dist/constraints-D5RHQLmP.js.map +1 -0
  37. package/dist/core/collection.d.ts +134 -0
  38. package/dist/core/collection.d.ts.map +1 -1
  39. package/dist/core/element.d.ts +120 -0
  40. package/dist/core/element.d.ts.map +1 -1
  41. package/dist/core/env.d.ts +18 -0
  42. package/dist/core/env.d.ts.map +1 -0
  43. package/dist/core/index.d.ts +1 -0
  44. package/dist/core/index.d.ts.map +1 -1
  45. package/dist/core/shared.d.ts +14 -0
  46. package/dist/core/shared.d.ts.map +1 -1
  47. package/dist/core/utils/index.d.ts +52 -41
  48. package/dist/core/utils/index.d.ts.map +1 -1
  49. package/dist/core-DdtZHzsS.js +168 -0
  50. package/dist/core-DdtZHzsS.js.map +1 -0
  51. package/dist/{core-CCEabVHl.js → core-EMYSLzaT.js} +293 -194
  52. package/dist/core-EMYSLzaT.js.map +1 -0
  53. package/dist/core.es.mjs +48 -46
  54. package/dist/custom-directives-Dr4C5lVV.js +9 -0
  55. package/dist/custom-directives-Dr4C5lVV.js.map +1 -0
  56. package/dist/devtools/devtools.d.ts +212 -0
  57. package/dist/devtools/devtools.d.ts.map +1 -0
  58. package/dist/devtools/index.d.ts +20 -0
  59. package/dist/devtools/index.d.ts.map +1 -0
  60. package/dist/devtools/types.d.ts +69 -0
  61. package/dist/devtools/types.d.ts.map +1 -0
  62. package/dist/devtools-BhB2iDPT.js +122 -0
  63. package/dist/devtools-BhB2iDPT.js.map +1 -0
  64. package/dist/devtools.es.mjs +19 -0
  65. package/dist/dnd/draggable.d.ts +51 -0
  66. package/dist/dnd/draggable.d.ts.map +1 -0
  67. package/dist/dnd/droppable.d.ts +38 -0
  68. package/dist/dnd/droppable.d.ts.map +1 -0
  69. package/dist/dnd/index.d.ts +47 -0
  70. package/dist/dnd/index.d.ts.map +1 -0
  71. package/dist/dnd/sortable.d.ts +43 -0
  72. package/dist/dnd/sortable.d.ts.map +1 -0
  73. package/dist/dnd/types.d.ts +250 -0
  74. package/dist/dnd/types.d.ts.map +1 -0
  75. package/dist/dnd-NwZBYh4l.js +244 -0
  76. package/dist/dnd-NwZBYh4l.js.map +1 -0
  77. package/dist/dnd.es.mjs +6 -0
  78. package/dist/env-CTdvLaH2.js +19 -0
  79. package/dist/env-CTdvLaH2.js.map +1 -0
  80. package/dist/forms/create-form.d.ts +49 -0
  81. package/dist/forms/create-form.d.ts.map +1 -0
  82. package/dist/forms/index.d.ts +40 -0
  83. package/dist/forms/index.d.ts.map +1 -0
  84. package/dist/forms/types.d.ts +185 -0
  85. package/dist/forms/types.d.ts.map +1 -0
  86. package/dist/forms/use-field.d.ts +34 -0
  87. package/dist/forms/use-field.d.ts.map +1 -0
  88. package/dist/forms/validators.d.ts +204 -0
  89. package/dist/forms/validators.d.ts.map +1 -0
  90. package/dist/forms-UcRHsYxC.js +227 -0
  91. package/dist/forms-UcRHsYxC.js.map +1 -0
  92. package/dist/forms.es.mjs +16 -0
  93. package/dist/full.d.ts +30 -11
  94. package/dist/full.d.ts.map +1 -1
  95. package/dist/full.es.mjs +209 -93
  96. package/dist/full.iife.js +47 -31
  97. package/dist/full.iife.js.map +1 -1
  98. package/dist/full.umd.js +47 -31
  99. package/dist/full.umd.js.map +1 -1
  100. package/dist/function-Cybd57JV.js +33 -0
  101. package/dist/function-Cybd57JV.js.map +1 -0
  102. package/dist/i18n/formatting.d.ts +40 -0
  103. package/dist/i18n/formatting.d.ts.map +1 -0
  104. package/dist/i18n/i18n.d.ts +48 -0
  105. package/dist/i18n/i18n.d.ts.map +1 -0
  106. package/dist/i18n/index.d.ts +57 -0
  107. package/dist/i18n/index.d.ts.map +1 -0
  108. package/dist/i18n/translate.d.ts +83 -0
  109. package/dist/i18n/translate.d.ts.map +1 -0
  110. package/dist/i18n/types.d.ts +156 -0
  111. package/dist/i18n/types.d.ts.map +1 -0
  112. package/dist/i18n-kuF6Ekj6.js +89 -0
  113. package/dist/i18n-kuF6Ekj6.js.map +1 -0
  114. package/dist/i18n.es.mjs +6 -0
  115. package/dist/index.d.ts +11 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.es.mjs +257 -143
  118. package/dist/media/battery.d.ts +35 -0
  119. package/dist/media/battery.d.ts.map +1 -0
  120. package/dist/media/breakpoints.d.ts +51 -0
  121. package/dist/media/breakpoints.d.ts.map +1 -0
  122. package/dist/media/clipboard.d.ts +30 -0
  123. package/dist/media/clipboard.d.ts.map +1 -0
  124. package/dist/media/device-sensors.d.ts +54 -0
  125. package/dist/media/device-sensors.d.ts.map +1 -0
  126. package/dist/media/geolocation.d.ts +38 -0
  127. package/dist/media/geolocation.d.ts.map +1 -0
  128. package/dist/media/index.d.ts +42 -0
  129. package/dist/media/index.d.ts.map +1 -0
  130. package/dist/media/media-query.d.ts +36 -0
  131. package/dist/media/media-query.d.ts.map +1 -0
  132. package/dist/media/network.d.ts +35 -0
  133. package/dist/media/network.d.ts.map +1 -0
  134. package/dist/media/types.d.ts +173 -0
  135. package/dist/media/types.d.ts.map +1 -0
  136. package/dist/media/viewport.d.ts +32 -0
  137. package/dist/media/viewport.d.ts.map +1 -0
  138. package/dist/media-i-fB5WxI.js +340 -0
  139. package/dist/media-i-fB5WxI.js.map +1 -0
  140. package/dist/media.es.mjs +12 -0
  141. package/dist/motion/index.d.ts +7 -3
  142. package/dist/motion/index.d.ts.map +1 -1
  143. package/dist/motion/morph.d.ts +27 -0
  144. package/dist/motion/morph.d.ts.map +1 -0
  145. package/dist/motion/parallax.d.ts +30 -0
  146. package/dist/motion/parallax.d.ts.map +1 -0
  147. package/dist/motion/reduced-motion.d.ts +36 -3
  148. package/dist/motion/reduced-motion.d.ts.map +1 -1
  149. package/dist/motion/types.d.ts +58 -0
  150. package/dist/motion/types.d.ts.map +1 -1
  151. package/dist/motion/typewriter.d.ts +31 -0
  152. package/dist/motion/typewriter.d.ts.map +1 -0
  153. package/dist/motion-BJsAuULb.js +530 -0
  154. package/dist/motion-BJsAuULb.js.map +1 -0
  155. package/dist/motion.es.mjs +27 -23
  156. package/dist/{view-C70lA3vf.js → mount-B4Y8bk8Z.js} +166 -160
  157. package/dist/mount-B4Y8bk8Z.js.map +1 -0
  158. package/dist/{object-qGpWr6-J.js → object-BCk-1c8T.js} +5 -4
  159. package/dist/{object-qGpWr6-J.js.map → object-BCk-1c8T.js.map} +1 -1
  160. package/dist/{platform-Dr9b6fsq.js → platform-Dw2gE3zI.js} +21 -22
  161. package/dist/{platform-Dr9b6fsq.js.map → platform-Dw2gE3zI.js.map} +1 -1
  162. package/dist/platform.es.mjs +2 -2
  163. package/dist/plugin/index.d.ts +22 -0
  164. package/dist/plugin/index.d.ts.map +1 -0
  165. package/dist/plugin/registry.d.ts +108 -0
  166. package/dist/plugin/registry.d.ts.map +1 -0
  167. package/dist/plugin/types.d.ts +110 -0
  168. package/dist/plugin/types.d.ts.map +1 -0
  169. package/dist/plugin-C2WuC8SF.js +66 -0
  170. package/dist/plugin-C2WuC8SF.js.map +1 -0
  171. package/dist/plugin.es.mjs +9 -0
  172. package/dist/reactive/async-data.d.ts +28 -3
  173. package/dist/reactive/async-data.d.ts.map +1 -1
  174. package/dist/reactive/computed.d.ts +10 -0
  175. package/dist/reactive/computed.d.ts.map +1 -1
  176. package/dist/reactive/effect.d.ts +3 -0
  177. package/dist/reactive/effect.d.ts.map +1 -1
  178. package/dist/reactive/http.d.ts +194 -0
  179. package/dist/reactive/http.d.ts.map +1 -0
  180. package/dist/reactive/index.d.ts +2 -2
  181. package/dist/reactive/index.d.ts.map +1 -1
  182. package/dist/reactive/pagination.d.ts +126 -0
  183. package/dist/reactive/pagination.d.ts.map +1 -0
  184. package/dist/reactive/polling.d.ts +55 -0
  185. package/dist/reactive/polling.d.ts.map +1 -0
  186. package/dist/reactive/readonly.d.ts +20 -1
  187. package/dist/reactive/readonly.d.ts.map +1 -1
  188. package/dist/reactive/rest.d.ts +293 -0
  189. package/dist/reactive/rest.d.ts.map +1 -0
  190. package/dist/reactive/scope.d.ts +140 -0
  191. package/dist/reactive/scope.d.ts.map +1 -0
  192. package/dist/reactive/signal.d.ts +16 -2
  193. package/dist/reactive/signal.d.ts.map +1 -1
  194. package/dist/reactive/to-value.d.ts +57 -0
  195. package/dist/reactive/to-value.d.ts.map +1 -0
  196. package/dist/reactive/websocket.d.ts +285 -0
  197. package/dist/reactive/websocket.d.ts.map +1 -0
  198. package/dist/reactive-DwkhUJfP.js +1148 -0
  199. package/dist/reactive-DwkhUJfP.js.map +1 -0
  200. package/dist/reactive.es.mjs +38 -20
  201. package/dist/registry-B08iilIh.js +26 -0
  202. package/dist/registry-B08iilIh.js.map +1 -0
  203. package/dist/router/bq-link.d.ts +112 -0
  204. package/dist/router/bq-link.d.ts.map +1 -0
  205. package/dist/router/constraints.d.ts +9 -0
  206. package/dist/router/constraints.d.ts.map +1 -0
  207. package/dist/router/index.d.ts +15 -7
  208. package/dist/router/index.d.ts.map +1 -1
  209. package/dist/router/match.d.ts +0 -1
  210. package/dist/router/match.d.ts.map +1 -1
  211. package/dist/router/path-pattern.d.ts +14 -0
  212. package/dist/router/path-pattern.d.ts.map +1 -0
  213. package/dist/router/query.d.ts.map +1 -1
  214. package/dist/router/router.d.ts +3 -1
  215. package/dist/router/router.d.ts.map +1 -1
  216. package/dist/router/state.d.ts +25 -2
  217. package/dist/router/state.d.ts.map +1 -1
  218. package/dist/router/types.d.ts +48 -4
  219. package/dist/router/types.d.ts.map +1 -1
  220. package/dist/router/use-route.d.ts +50 -0
  221. package/dist/router/use-route.d.ts.map +1 -0
  222. package/dist/router/utils.d.ts +3 -0
  223. package/dist/router/utils.d.ts.map +1 -1
  224. package/dist/router-CQikC9Ed.js +492 -0
  225. package/dist/router-CQikC9Ed.js.map +1 -0
  226. package/dist/router.es.mjs +14 -10
  227. package/dist/{sanitize-Bs2dkMby.js → sanitize-B1V4JswB.js} +2 -1
  228. package/dist/{sanitize-Bs2dkMby.js.map → sanitize-B1V4JswB.js.map} +1 -1
  229. package/dist/security/index.d.ts +2 -2
  230. package/dist/security/index.d.ts.map +1 -1
  231. package/dist/security.es.mjs +1 -1
  232. package/dist/ssr/hydrate.d.ts +65 -0
  233. package/dist/ssr/hydrate.d.ts.map +1 -0
  234. package/dist/ssr/index.d.ts +59 -0
  235. package/dist/ssr/index.d.ts.map +1 -0
  236. package/dist/ssr/render.d.ts +62 -0
  237. package/dist/ssr/render.d.ts.map +1 -0
  238. package/dist/ssr/serialize.d.ts +118 -0
  239. package/dist/ssr/serialize.d.ts.map +1 -0
  240. package/dist/ssr/types.d.ts +70 -0
  241. package/dist/ssr/types.d.ts.map +1 -0
  242. package/dist/ssr-_dAcGdzu.js +248 -0
  243. package/dist/ssr-_dAcGdzu.js.map +1 -0
  244. package/dist/ssr.es.mjs +9 -0
  245. package/dist/store/create-store.d.ts.map +1 -1
  246. package/dist/store/index.d.ts +1 -1
  247. package/dist/store/index.d.ts.map +1 -1
  248. package/dist/store/persisted.d.ts +38 -4
  249. package/dist/store/persisted.d.ts.map +1 -1
  250. package/dist/store/types.d.ts +138 -1
  251. package/dist/store/types.d.ts.map +1 -1
  252. package/dist/store/utils.d.ts +2 -2
  253. package/dist/store/utils.d.ts.map +1 -1
  254. package/dist/store-Cb3gPRve.js +338 -0
  255. package/dist/store-Cb3gPRve.js.map +1 -0
  256. package/dist/store.es.mjs +11 -10
  257. package/dist/storybook/index.d.ts.map +1 -1
  258. package/dist/storybook.es.mjs +1 -1
  259. package/dist/storybook.es.mjs.map +1 -1
  260. package/dist/testing/index.d.ts +23 -0
  261. package/dist/testing/index.d.ts.map +1 -0
  262. package/dist/testing/testing.d.ts +156 -0
  263. package/dist/testing/testing.d.ts.map +1 -0
  264. package/dist/testing/types.d.ts +134 -0
  265. package/dist/testing/types.d.ts.map +1 -0
  266. package/dist/testing-C5Sjfsna.js +224 -0
  267. package/dist/testing-C5Sjfsna.js.map +1 -0
  268. package/dist/testing.es.mjs +9 -0
  269. package/dist/type-guards-BMX2c0LP.js +44 -0
  270. package/dist/type-guards-BMX2c0LP.js.map +1 -0
  271. package/dist/untrack-D0fnO5k2.js +36 -0
  272. package/dist/untrack-D0fnO5k2.js.map +1 -0
  273. package/dist/view/custom-directives.d.ts +20 -0
  274. package/dist/view/custom-directives.d.ts.map +1 -0
  275. package/dist/view/evaluate.d.ts.map +1 -1
  276. package/dist/view/process.d.ts.map +1 -1
  277. package/dist/view.es.mjs +9 -9
  278. package/package.json +47 -11
  279. package/src/a11y/announce.ts +131 -0
  280. package/src/a11y/audit.ts +314 -0
  281. package/src/a11y/index.ts +68 -0
  282. package/src/a11y/media-preferences.ts +255 -0
  283. package/src/a11y/roving-tab-index.ts +164 -0
  284. package/src/a11y/skip-link.ts +255 -0
  285. package/src/a11y/trap-focus.ts +184 -0
  286. package/src/a11y/types.ts +183 -0
  287. package/src/component/component.ts +599 -524
  288. package/src/component/html.ts +153 -153
  289. package/src/component/index.ts +52 -50
  290. package/src/component/library.ts +540 -518
  291. package/src/component/scope.ts +212 -0
  292. package/src/component/types.ts +310 -256
  293. package/src/core/collection.ts +249 -1
  294. package/src/core/element.ts +252 -11
  295. package/src/core/env.ts +60 -0
  296. package/src/core/index.ts +1 -0
  297. package/src/core/shared.ts +64 -0
  298. package/src/core/utils/index.ts +66 -1
  299. package/src/devtools/devtools.ts +410 -0
  300. package/src/devtools/index.ts +48 -0
  301. package/src/devtools/types.ts +104 -0
  302. package/src/dnd/draggable.ts +296 -0
  303. package/src/dnd/droppable.ts +228 -0
  304. package/src/dnd/index.ts +62 -0
  305. package/src/dnd/sortable.ts +307 -0
  306. package/src/dnd/types.ts +293 -0
  307. package/src/forms/create-form.ts +320 -0
  308. package/src/forms/index.ts +70 -0
  309. package/src/forms/types.ts +203 -0
  310. package/src/forms/use-field.ts +231 -0
  311. package/src/forms/validators.ts +294 -0
  312. package/src/full.ts +554 -229
  313. package/src/i18n/formatting.ts +67 -0
  314. package/src/i18n/i18n.ts +200 -0
  315. package/src/i18n/index.ts +67 -0
  316. package/src/i18n/translate.ts +182 -0
  317. package/src/i18n/types.ts +171 -0
  318. package/src/index.ts +72 -0
  319. package/src/media/battery.ts +116 -0
  320. package/src/media/breakpoints.ts +129 -0
  321. package/src/media/clipboard.ts +80 -0
  322. package/src/media/device-sensors.ts +158 -0
  323. package/src/media/geolocation.ts +119 -0
  324. package/src/media/index.ts +76 -0
  325. package/src/media/media-query.ts +92 -0
  326. package/src/media/network.ts +115 -0
  327. package/src/media/types.ts +177 -0
  328. package/src/media/viewport.ts +84 -0
  329. package/src/motion/index.ts +11 -2
  330. package/src/motion/morph.ts +151 -0
  331. package/src/motion/parallax.ts +120 -0
  332. package/src/motion/reduced-motion.ts +52 -3
  333. package/src/motion/types.ts +63 -0
  334. package/src/motion/typewriter.ts +164 -0
  335. package/src/plugin/index.ts +37 -0
  336. package/src/plugin/registry.ts +284 -0
  337. package/src/plugin/types.ts +137 -0
  338. package/src/reactive/async-data.ts +250 -29
  339. package/src/reactive/computed.ts +53 -1
  340. package/src/reactive/effect.ts +29 -6
  341. package/src/reactive/http.ts +790 -0
  342. package/src/reactive/index.ts +60 -0
  343. package/src/reactive/pagination.ts +317 -0
  344. package/src/reactive/polling.ts +179 -0
  345. package/src/reactive/readonly.ts +52 -8
  346. package/src/reactive/rest.ts +859 -0
  347. package/src/reactive/scope.ts +276 -0
  348. package/src/reactive/signal.ts +61 -1
  349. package/src/reactive/to-value.ts +71 -0
  350. package/src/reactive/websocket.ts +849 -0
  351. package/src/router/bq-link.ts +279 -0
  352. package/src/router/constraints.ts +204 -0
  353. package/src/router/index.ts +15 -7
  354. package/src/router/match.ts +255 -49
  355. package/src/router/path-pattern.ts +52 -0
  356. package/src/router/query.ts +3 -0
  357. package/src/router/router.ts +258 -48
  358. package/src/router/state.ts +51 -3
  359. package/src/router/types.ts +50 -4
  360. package/src/router/use-route.ts +68 -0
  361. package/src/router/utils.ts +44 -3
  362. package/src/security/index.ts +12 -17
  363. package/src/security/sanitize.ts +70 -70
  364. package/src/security/trusted-html.ts +71 -71
  365. package/src/ssr/hydrate.ts +84 -0
  366. package/src/ssr/index.ts +70 -0
  367. package/src/ssr/render.ts +508 -0
  368. package/src/ssr/serialize.ts +296 -0
  369. package/src/ssr/types.ts +81 -0
  370. package/src/store/create-store.ts +146 -8
  371. package/src/store/define-store.ts +49 -49
  372. package/src/store/index.ts +5 -0
  373. package/src/store/mapping.ts +74 -74
  374. package/src/store/persisted.ts +245 -62
  375. package/src/store/types.ts +247 -92
  376. package/src/store/utils.ts +4 -10
  377. package/src/store/watch.ts +53 -53
  378. package/src/storybook/index.ts +480 -479
  379. package/src/testing/index.ts +42 -0
  380. package/src/testing/testing.ts +593 -0
  381. package/src/testing/types.ts +170 -0
  382. package/src/view/custom-directives.ts +28 -0
  383. package/src/view/evaluate.ts +2 -0
  384. package/src/view/process.ts +19 -3
  385. package/dist/component-BEQgt5hl.js +0 -600
  386. package/dist/component-BEQgt5hl.js.map +0 -1
  387. package/dist/core-BGQJVw0-.js +0 -35
  388. package/dist/core-BGQJVw0-.js.map +0 -1
  389. package/dist/core-CCEabVHl.js.map +0 -1
  390. package/dist/effect-AFRW_Plg.js +0 -84
  391. package/dist/effect-AFRW_Plg.js.map +0 -1
  392. package/dist/motion-D9TcHxOF.js +0 -415
  393. package/dist/motion-D9TcHxOF.js.map +0 -1
  394. package/dist/reactive-DSkct0dO.js +0 -254
  395. package/dist/reactive-DSkct0dO.js.map +0 -1
  396. package/dist/router-CbDhl8rS.js +0 -188
  397. package/dist/router-CbDhl8rS.js.map +0 -1
  398. package/dist/store-BwDvI45q.js +0 -263
  399. package/dist/store-BwDvI45q.js.map +0 -1
  400. package/dist/untrack-B0rVscTc.js +0 -7
  401. package/dist/untrack-B0rVscTc.js.map +0 -1
  402. package/dist/view-C70lA3vf.js.map +0 -1
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Testing utilities for bQuery.js.
3
+ *
4
+ * Provides helpers for mounting components, controlling signals, mocking
5
+ * the router, dispatching events, and asserting async conditions — all
6
+ * designed for use with `bun:test` and happy-dom.
7
+ *
8
+ * @module bquery/testing
9
+ */
10
+ import type { FireEventOptions, MockRouter, MockRouterOptions, MockSignal, RenderComponentOptions, RenderResult, WaitForOptions } from './types';
11
+ /**
12
+ * Mounts a custom element by tag name for testing and returns a handle
13
+ * to interact with it.
14
+ *
15
+ * The element is created, configured with the given props and slots,
16
+ * and appended to the container (defaults to `document.body`). Call
17
+ * `unmount()` to remove the element and trigger its `disconnectedCallback`.
18
+ *
19
+ * @param tagName - The custom element tag name (must already be registered)
20
+ * @param options - Props, slots, and container configuration
21
+ * @returns A {@link RenderResult} with the element and an unmount function
22
+ * @throws {Error} If the tag name is not a valid custom element name
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { renderComponent } from '@bquery/bquery/testing';
27
+ *
28
+ * const { el, unmount } = renderComponent('my-counter', {
29
+ * props: { start: '5' },
30
+ * });
31
+ * expect(el.shadowRoot?.textContent).toContain('5');
32
+ * unmount();
33
+ * ```
34
+ */
35
+ export declare function renderComponent(tagName: string, options?: RenderComponentOptions): RenderResult;
36
+ /**
37
+ * Synchronously flushes any pending reactive effects.
38
+ *
39
+ * In bQuery's reactive system, effects outside of a batch are executed
40
+ * synchronously. This helper exists primarily for clarity and for
41
+ * flushing effects that may have been deferred inside a batch.
42
+ *
43
+ * Internally it performs a no-op batch to trigger the flush of any
44
+ * pending observers that were queued during a prior `batch()` call.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { signal, batch } from '@bquery/bquery/reactive';
49
+ * import { flushEffects } from '@bquery/bquery/testing';
50
+ *
51
+ * const count = signal(0);
52
+ * let observed = 0;
53
+ * effect(() => { observed = count.value; });
54
+ *
55
+ * batch(() => { count.value = 42; });
56
+ * flushEffects();
57
+ * expect(observed).toBe(42);
58
+ * ```
59
+ */
60
+ export declare function flushEffects(): void;
61
+ /**
62
+ * Creates a controllable signal for tests with `set()` and `reset()` helpers.
63
+ *
64
+ * This is a thin wrapper around `signal()` that records the initial value
65
+ * and adds explicit `set()` / `reset()` methods for clearer test intent.
66
+ *
67
+ * @template T - The type of the signal value
68
+ * @param initialValue - The initial value
69
+ * @returns A {@link MockSignal} instance
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { mockSignal } from '@bquery/bquery/testing';
74
+ *
75
+ * const count = mockSignal(0);
76
+ * count.set(5);
77
+ * expect(count.value).toBe(5);
78
+ * count.reset();
79
+ * expect(count.value).toBe(0);
80
+ * ```
81
+ */
82
+ export declare function mockSignal<T>(initialValue: T): MockSignal<T>;
83
+ /**
84
+ * Creates a lightweight mock router for testing that does not interact
85
+ * with the browser History API.
86
+ *
87
+ * The mock router provides a reactive `currentRoute` signal that updates
88
+ * when `push()` or `replace()` is called, making it ideal for testing
89
+ * components or logic that depend on route state.
90
+ *
91
+ * @param options - Mock router configuration
92
+ * @returns A {@link MockRouter} instance
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { mockRouter } from '@bquery/bquery/testing';
97
+ *
98
+ * const router = mockRouter({
99
+ * routes: [
100
+ * { path: '/', component: () => null },
101
+ * { path: '/user/:id', component: () => null },
102
+ * ],
103
+ * initialPath: '/',
104
+ * });
105
+ *
106
+ * router.push('/user/42');
107
+ * expect(router.currentRoute.value.params.id).toBe('42');
108
+ * router.destroy();
109
+ * ```
110
+ */
111
+ export declare function mockRouter(options?: MockRouterOptions): MockRouter;
112
+ /**
113
+ * Dispatches a synthetic event on an element and flushes pending effects.
114
+ *
115
+ * By default the event bubbles, is cancelable, and is composed (crosses
116
+ * shadow DOM boundaries). Pass a `detail` option to create a `CustomEvent`.
117
+ *
118
+ * @param el - The target element
119
+ * @param eventName - The event type (e.g. 'click', 'input', 'my-event')
120
+ * @param options - Event configuration
121
+ * @returns `true` if the event was not cancelled
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * import { fireEvent } from '@bquery/bquery/testing';
126
+ *
127
+ * const button = document.createElement('button');
128
+ * let clicked = false;
129
+ * button.addEventListener('click', () => { clicked = true; });
130
+ * fireEvent(button, 'click');
131
+ * expect(clicked).toBe(true);
132
+ * ```
133
+ */
134
+ export declare function fireEvent(el: Element, eventName: string, options?: FireEventOptions): boolean;
135
+ /**
136
+ * Waits for a predicate to return `true`, polling at a configurable interval.
137
+ *
138
+ * Useful for asserting conditions that depend on asynchronous operations,
139
+ * timers, or deferred reactive updates.
140
+ *
141
+ * @param predicate - A function that returns `true` when the condition is met
142
+ * @param options - Timeout and interval configuration
143
+ * @returns A promise that resolves when the predicate returns `true`
144
+ * @throws {Error} If the predicate does not return `true` within the timeout
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * import { waitFor } from '@bquery/bquery/testing';
149
+ *
150
+ * await waitFor(() => document.querySelector('.loaded') !== null, {
151
+ * timeout: 2000,
152
+ * });
153
+ * ```
154
+ */
155
+ export declare function waitFor(predicate: () => boolean | Promise<boolean>, options?: WaitForOptions): Promise<void>;
156
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/testing/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,gBAAgB,EAEhB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,sBAAsB,EACtB,YAAY,EAEZ,cAAc,EACf,MAAM,SAAS,CAAC;AA4DjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,sBAA2B,GACnC,YAAY,CAmDd;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAOnC;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAsB5D;AAwLD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CA8BtE;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAuBjG;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC3C,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAwBf"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Types for the bQuery testing utilities module.
3
+ * @module bquery/testing
4
+ */
5
+ import type { Signal } from '../reactive/index';
6
+ /**
7
+ * Minimal route shape accepted by the testing mock router.
8
+ */
9
+ export interface MockRouteDefinition {
10
+ path: string;
11
+ [key: string]: unknown;
12
+ }
13
+ /**
14
+ * Options for mounting a bQuery component in tests.
15
+ */
16
+ export interface RenderComponentOptions {
17
+ /**
18
+ * Attributes (props) to set on the custom element.
19
+ * Keys are attribute names; values are stringified automatically.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * renderComponent('my-counter', { props: { start: 5 } });
24
+ * ```
25
+ */
26
+ props?: Record<string, unknown>;
27
+ /**
28
+ * Named or default slot content to inject inside the host element
29
+ * **before** it is connected to the DOM.
30
+ *
31
+ * - A plain string sets the default (unnamed) slot.
32
+ * - An object maps slot names to HTML strings.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * renderComponent('my-card', {
37
+ * slots: { default: '<p>Body</p>', header: '<h2>Title</h2>' },
38
+ * });
39
+ * ```
40
+ */
41
+ slots?: string | Record<string, string>;
42
+ /**
43
+ * Parent element to attach to. Defaults to `document.body`.
44
+ */
45
+ container?: HTMLElement;
46
+ }
47
+ /**
48
+ * Return value of {@link renderComponent}.
49
+ */
50
+ export interface RenderResult {
51
+ /** The mounted custom element instance. */
52
+ el: HTMLElement;
53
+ /** Remove the element and run cleanup. */
54
+ unmount: () => void;
55
+ }
56
+ /**
57
+ * A controllable signal for use in tests.
58
+ *
59
+ * Extends the regular Signal with explicit `set()` and `reset()` helpers
60
+ * that make test intent clearer.
61
+ */
62
+ export interface MockSignal<T> extends Signal<T> {
63
+ /**
64
+ * Explicitly set the signal value (alias for `.value = v`).
65
+ */
66
+ set(value: T): void;
67
+ /**
68
+ * Reset the signal back to its initial value.
69
+ */
70
+ reset(): void;
71
+ /**
72
+ * The initial value this mock was created with.
73
+ */
74
+ readonly initialValue: T;
75
+ }
76
+ /**
77
+ * Options for creating a mock router.
78
+ */
79
+ export interface MockRouterOptions {
80
+ /** Route definitions. Defaults to a single catch-all route. */
81
+ routes?: MockRouteDefinition[];
82
+ /** Initial path. Defaults to '/'. */
83
+ initialPath?: string;
84
+ /** Base path. Defaults to ''. */
85
+ base?: string;
86
+ }
87
+ /**
88
+ * A lightweight mock router for tests that doesn't touch the History API.
89
+ */
90
+ export interface MockRouter {
91
+ /** Navigate to a path (synchronous, no guards). */
92
+ push(path: string): void;
93
+ /** Replace the current path. */
94
+ replace(path: string): void;
95
+ /** The current route (reactive signal). */
96
+ readonly currentRoute: Signal<TestRoute>;
97
+ /** Registered routes. */
98
+ readonly routes: MockRouteDefinition[];
99
+ /** Destroy and clean up. */
100
+ destroy(): void;
101
+ }
102
+ /**
103
+ * Minimal route shape for the mock router.
104
+ */
105
+ export interface TestRoute {
106
+ path: string;
107
+ params: Record<string, string>;
108
+ query: Record<string, string | string[]>;
109
+ matched: MockRouteDefinition | null;
110
+ hash: string;
111
+ }
112
+ /**
113
+ * Options for dispatching a synthetic event.
114
+ */
115
+ export interface FireEventOptions {
116
+ /** Whether the event bubbles. Defaults to `true`. */
117
+ bubbles?: boolean;
118
+ /** Whether the event is cancelable. Defaults to `true`. */
119
+ cancelable?: boolean;
120
+ /** Whether the event crosses shadow DOM boundaries. Defaults to `true`. */
121
+ composed?: boolean;
122
+ /** Extra detail data for CustomEvent. */
123
+ detail?: unknown;
124
+ }
125
+ /**
126
+ * Options for the async `waitFor` helper.
127
+ */
128
+ export interface WaitForOptions {
129
+ /** Maximum time (ms) to wait before timing out. Defaults to 1000. */
130
+ timeout?: number;
131
+ /** Polling interval (ms). Defaults to 10. */
132
+ interval?: number;
133
+ }
134
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAMD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExC;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,EAAE,EAAE,WAAW,CAAC;IAChB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IAC9C;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAEpB;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;CAC1B;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC/B,qCAAqC;IACrC,WAAW,CAAC,EA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RHQLmP.js";
4
+ var b = (e) => e !== void 0 && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "_"), $ = (e, o) => {
5
+ let t = 1, i = "", r = o + 1;
6
+ for (; r < e.length; ) {
7
+ const n = e[r];
8
+ if (n === "\\" && r + 1 < e.length) {
9
+ i += n + e[r + 1], r += 2;
10
+ continue;
11
+ }
12
+ if (n === "(") t++;
13
+ else if (n === ")" && (t--, t === 0))
14
+ return {
15
+ constraint: i,
16
+ endIndex: r + 1
17
+ };
18
+ i += n, r++;
19
+ }
20
+ return null;
21
+ }, E = /* @__PURE__ */ new Map(), O = (e) => {
22
+ const o = q(e), t = E.get(o);
23
+ if (t) return t;
24
+ const i = new RegExp(`^(?:${o})$`);
25
+ return E.set(o, i), i;
26
+ };
27
+ function x(e, o = {}) {
28
+ if (!e || !e.includes("-")) throw new Error(`bQuery testing: "${e}" is not a valid custom element tag name (must contain a hyphen)`);
29
+ const { props: t, slots: i, container: r = document.body } = o, n = document.createElement(e);
30
+ if (t) for (const [s, l] of Object.entries(t))
31
+ l != null && n.setAttribute(s, String(l));
32
+ if (i) if (typeof i == "string") n.innerHTML = i;
33
+ else {
34
+ const s = [];
35
+ for (const [l, a] of Object.entries(i)) if (l === "default") s.push(a);
36
+ else {
37
+ const c = l.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
38
+ s.push(`<div slot="${c}">${a}</div>`);
39
+ }
40
+ n.innerHTML = s.join("");
41
+ }
42
+ return r.appendChild(n), {
43
+ el: n,
44
+ unmount: () => {
45
+ n.parentNode && n.parentNode.removeChild(n);
46
+ }
47
+ };
48
+ }
49
+ function P() {
50
+ R(() => {
51
+ });
52
+ }
53
+ function F(e) {
54
+ const o = p(e);
55
+ return Object.defineProperty(o, "initialValue", {
56
+ value: e,
57
+ writable: !1,
58
+ enumerable: !0
59
+ }), o.set = function(t) {
60
+ o.value = t;
61
+ }, o.reset = function() {
62
+ o.value = e;
63
+ }, o;
64
+ }
65
+ function M(e, o) {
66
+ let t = e;
67
+ o && t.startsWith(o) && (t = t.slice(o.length) || "/");
68
+ let i = "";
69
+ const r = t.indexOf("#");
70
+ r >= 0 && (i = t.slice(r + 1), t = t.slice(0, r));
71
+ const n = {}, u = t.indexOf("?");
72
+ if (u >= 0) {
73
+ const s = t.slice(u + 1);
74
+ t = t.slice(0, u);
75
+ for (const l of s.split("&")) {
76
+ const a = l.indexOf("="), c = a >= 0 ? decodeURIComponent(l.slice(0, a)) : decodeURIComponent(l), f = a >= 0 ? decodeURIComponent(l.slice(a + 1)) : "", d = n[c];
77
+ d !== void 0 ? Array.isArray(d) ? d.push(f) : n[c] = [d, f] : n[c] = f;
78
+ }
79
+ }
80
+ return {
81
+ path: t || "/",
82
+ query: n,
83
+ hash: i
84
+ };
85
+ }
86
+ function k(e, o) {
87
+ for (const t of o) {
88
+ const i = A(t.path, e);
89
+ if (i) return {
90
+ matched: t,
91
+ params: i
92
+ };
93
+ }
94
+ return {
95
+ matched: null,
96
+ params: {}
97
+ };
98
+ }
99
+ function A(e, o) {
100
+ if (e === "*") return {};
101
+ const t = /* @__PURE__ */ new Map(), i = (n, u) => {
102
+ const s = n.indexOf("/", u);
103
+ return s === -1 ? n.length : s;
104
+ }, r = (n, u) => {
105
+ const s = `${n}:${u}`;
106
+ if (t.has(s)) return t.get(s) ?? null;
107
+ if (n === e.length) {
108
+ const c = u === o.length ? {} : null;
109
+ return t.set(s, c), c;
110
+ }
111
+ const l = e[n];
112
+ if (l === "*") {
113
+ for (let c = o.length; c >= u; c--) {
114
+ const f = r(n + 1, c);
115
+ if (f)
116
+ return t.set(s, f), f;
117
+ }
118
+ return t.set(s, null), null;
119
+ }
120
+ if (l === ":" && b(e[n + 1])) {
121
+ let c = n + 2;
122
+ for (; c < e.length && b(e[c]); ) c++;
123
+ const f = e.slice(n + 1, c);
124
+ let d = c, h, g = !1;
125
+ if (e[c] === "(") {
126
+ const m = $(e, c);
127
+ m && (h = m.constraint, d = m.endIndex);
128
+ }
129
+ e[d] === "*" && (g = !0, d++);
130
+ const C = g || h ? o.length : i(o, u);
131
+ for (let m = C; m > u; m--) {
132
+ const v = o.slice(u, m);
133
+ if (h && !O(h).test(v))
134
+ continue;
135
+ const w = r(d, m);
136
+ if (w) {
137
+ const y = {
138
+ [f]: v,
139
+ ...w
140
+ };
141
+ return t.set(s, y), y;
142
+ }
143
+ }
144
+ return t.set(s, null), null;
145
+ }
146
+ if (u >= o.length || l !== o[u])
147
+ return t.set(s, null), null;
148
+ const a = r(n + 1, u + 1);
149
+ return t.set(s, a), a;
150
+ };
151
+ return r(0, 0);
152
+ }
153
+ function z(e = {}) {
154
+ const o = e.routes ?? [{
155
+ path: "*",
156
+ component: () => null
157
+ }], t = e.base ?? "", i = e.initialPath ?? "/", r = (u) => {
158
+ const { path: s, query: l, hash: a } = M(u, t), { matched: c, params: f } = k(s, o);
159
+ return {
160
+ path: s,
161
+ params: f,
162
+ query: l,
163
+ matched: c,
164
+ hash: a
165
+ };
166
+ }, n = p(r(i));
167
+ return {
168
+ push(u) {
169
+ n.value = r(u);
170
+ },
171
+ replace(u) {
172
+ n.value = r(u);
173
+ },
174
+ get currentRoute() {
175
+ return n;
176
+ },
177
+ get routes() {
178
+ return o;
179
+ },
180
+ destroy() {
181
+ n.dispose();
182
+ }
183
+ };
184
+ }
185
+ function D(e, o, t = {}) {
186
+ if (!e) throw new Error("bQuery testing: fireEvent requires a valid element");
187
+ if (!o) throw new Error("bQuery testing: fireEvent requires an event name");
188
+ const { bubbles: i = !0, cancelable: r = !0, composed: n = !0, detail: u } = t;
189
+ let s;
190
+ u !== void 0 ? s = new CustomEvent(o, {
191
+ bubbles: i,
192
+ cancelable: r,
193
+ composed: n,
194
+ detail: u
195
+ }) : s = new Event(o, {
196
+ bubbles: i,
197
+ cancelable: r,
198
+ composed: n
199
+ });
200
+ const l = e.dispatchEvent(s);
201
+ return P(), l;
202
+ }
203
+ async function L(e, o = {}) {
204
+ if (typeof e != "function") throw new Error("bQuery testing: waitFor requires a predicate function");
205
+ const { timeout: t = 1e3, interval: i = 10 } = o, r = Date.now();
206
+ for (; ; ) {
207
+ try {
208
+ if (await e()) return;
209
+ } catch {
210
+ }
211
+ if (Date.now() - r >= t) throw new Error(`bQuery testing: waitFor timed out after ${t}ms — predicate never returned true`);
212
+ await new Promise((n) => setTimeout(n, i));
213
+ }
214
+ }
215
+ export {
216
+ x as a,
217
+ F as i,
218
+ P as n,
219
+ L as o,
220
+ z as r,
221
+ D as t
222
+ };
223
+
224
+ //# sourceMappingURL=testing-C5Sjfsna.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing-C5Sjfsna.js","names":[],"sources":["../src/testing/testing.ts"],"sourcesContent":["/**\n * Testing utilities for bQuery.js.\n *\n * Provides helpers for mounting components, controlling signals, mocking\n * the router, dispatching events, and asserting async conditions — all\n * designed for use with `bun:test` and happy-dom.\n *\n * @module bquery/testing\n */\n\nimport { batch, Signal, signal } from '../reactive/index';\nimport { getNormalizedRouteConstraint } from '../router/constraints';\nimport type {\n FireEventOptions,\n MockRouteDefinition,\n MockRouter,\n MockRouterOptions,\n MockSignal,\n RenderComponentOptions,\n RenderResult,\n TestRoute,\n WaitForOptions,\n} from './types';\n\n// ============================================================================\n// renderComponent\n// ============================================================================\n\nconst isWordChar = (char: string | undefined): boolean =>\n char !== undefined &&\n ((char >= 'a' && char <= 'z') ||\n (char >= 'A' && char <= 'Z') ||\n (char >= '0' && char <= '9') ||\n char === '_');\n\nconst readRouteConstraint = (\n pattern: string,\n startIndex: number\n): { constraint: string; endIndex: number } | null => {\n let depth = 1;\n let constraint = '';\n let i = startIndex + 1;\n\n while (i < pattern.length) {\n const char = pattern[i];\n\n if (char === '\\\\' && i + 1 < pattern.length) {\n constraint += char + pattern[i + 1];\n i += 2;\n continue;\n }\n\n if (char === '(') {\n depth++;\n } else if (char === ')') {\n depth--;\n if (depth === 0) {\n return { constraint, endIndex: i + 1 };\n }\n }\n\n constraint += char;\n i++;\n }\n\n return null;\n};\n\nconst routeConstraintRegexCache = new Map<string, RegExp>();\n\nconst getRouteConstraintRegex = (constraint: string): RegExp => {\n const normalized = getNormalizedRouteConstraint(constraint);\n const cached = routeConstraintRegexCache.get(normalized);\n if (cached) {\n return cached;\n }\n\n const compiled = new RegExp(`^(?:${normalized})$`);\n routeConstraintRegexCache.set(normalized, compiled);\n return compiled;\n};\n\n/**\n * Mounts a custom element by tag name for testing and returns a handle\n * to interact with it.\n *\n * The element is created, configured with the given props and slots,\n * and appended to the container (defaults to `document.body`). Call\n * `unmount()` to remove the element and trigger its `disconnectedCallback`.\n *\n * @param tagName - The custom element tag name (must already be registered)\n * @param options - Props, slots, and container configuration\n * @returns A {@link RenderResult} with the element and an unmount function\n * @throws {Error} If the tag name is not a valid custom element name\n *\n * @example\n * ```ts\n * import { renderComponent } from '@bquery/bquery/testing';\n *\n * const { el, unmount } = renderComponent('my-counter', {\n * props: { start: '5' },\n * });\n * expect(el.shadowRoot?.textContent).toContain('5');\n * unmount();\n * ```\n */\nexport function renderComponent(\n tagName: string,\n options: RenderComponentOptions = {}\n): RenderResult {\n if (!tagName || !tagName.includes('-')) {\n throw new Error(\n `bQuery testing: \"${tagName}\" is not a valid custom element tag name (must contain a hyphen)`\n );\n }\n\n const { props, slots, container = document.body } = options;\n\n const el = document.createElement(tagName);\n\n // Set attributes (props) before connecting\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n if (value === null || value === undefined) continue;\n el.setAttribute(key, String(value));\n }\n }\n\n // Inject slot content before connecting so the component can discover it\n if (slots) {\n if (typeof slots === 'string') {\n el.innerHTML = slots;\n } else {\n const parts: string[] = [];\n for (const [slotName, html] of Object.entries(slots)) {\n if (slotName === 'default') {\n parts.push(html);\n } else {\n const safeSlotName = slotName\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n parts.push(`<div slot=\"${safeSlotName}\">${html}</div>`);\n }\n }\n el.innerHTML = parts.join('');\n }\n }\n\n // Connect — triggers connectedCallback\n container.appendChild(el);\n\n const unmount = (): void => {\n if (el.parentNode) {\n el.parentNode.removeChild(el);\n }\n };\n\n return { el, unmount };\n}\n\n// ============================================================================\n// flushEffects\n// ============================================================================\n\n/**\n * Synchronously flushes any pending reactive effects.\n *\n * In bQuery's reactive system, effects outside of a batch are executed\n * synchronously. This helper exists primarily for clarity and for\n * flushing effects that may have been deferred inside a batch.\n *\n * Internally it performs a no-op batch to trigger the flush of any\n * pending observers that were queued during a prior `batch()` call.\n *\n * @example\n * ```ts\n * import { signal, batch } from '@bquery/bquery/reactive';\n * import { flushEffects } from '@bquery/bquery/testing';\n *\n * const count = signal(0);\n * let observed = 0;\n * effect(() => { observed = count.value; });\n *\n * batch(() => { count.value = 42; });\n * flushEffects();\n * expect(observed).toBe(42);\n * ```\n */\nexport function flushEffects(): void {\n // A no-op batch triggers endBatch which flushes any pending observers.\n // Since bQuery's effects are synchronous outside of batches, this is\n // mainly useful after manual batch calls or micro-task boundaries.\n batch(() => {\n /* intentionally empty — triggers pending observer flush */\n });\n}\n\n// ============================================================================\n// mockSignal\n// ============================================================================\n\n/**\n * Creates a controllable signal for tests with `set()` and `reset()` helpers.\n *\n * This is a thin wrapper around `signal()` that records the initial value\n * and adds explicit `set()` / `reset()` methods for clearer test intent.\n *\n * @template T - The type of the signal value\n * @param initialValue - The initial value\n * @returns A {@link MockSignal} instance\n *\n * @example\n * ```ts\n * import { mockSignal } from '@bquery/bquery/testing';\n *\n * const count = mockSignal(0);\n * count.set(5);\n * expect(count.value).toBe(5);\n * count.reset();\n * expect(count.value).toBe(0);\n * ```\n */\nexport function mockSignal<T>(initialValue: T): MockSignal<T> {\n const s = signal(initialValue) as Signal<T> & {\n set: (value: T) => void;\n reset: () => void;\n initialValue: T;\n };\n\n Object.defineProperty(s, 'initialValue', {\n value: initialValue,\n writable: false,\n enumerable: true,\n });\n\n s.set = function (value: T): void {\n s.value = value;\n };\n\n s.reset = function (): void {\n s.value = initialValue;\n };\n\n return s as MockSignal<T>;\n}\n\n// ============================================================================\n// mockRouter\n// ============================================================================\n\n/**\n * Parses a path string into the route's `path`, `query`, and `hash` parts.\n * @internal\n */\nfunction parsePath(\n fullPath: string,\n base: string\n): { path: string; query: Record<string, string | string[]>; hash: string } {\n let working = fullPath;\n\n // Strip base prefix\n if (base && working.startsWith(base)) {\n working = working.slice(base.length) || '/';\n }\n\n // Extract hash\n let hash = '';\n const hashIdx = working.indexOf('#');\n if (hashIdx >= 0) {\n hash = working.slice(hashIdx + 1);\n working = working.slice(0, hashIdx);\n }\n\n // Extract query string\n const query: Record<string, string | string[]> = {};\n const qIdx = working.indexOf('?');\n if (qIdx >= 0) {\n const qs = working.slice(qIdx + 1);\n working = working.slice(0, qIdx);\n for (const pair of qs.split('&')) {\n const eqIdx = pair.indexOf('=');\n const key = eqIdx >= 0 ? decodeURIComponent(pair.slice(0, eqIdx)) : decodeURIComponent(pair);\n const val = eqIdx >= 0 ? decodeURIComponent(pair.slice(eqIdx + 1)) : '';\n const existing = query[key];\n if (existing !== undefined) {\n if (Array.isArray(existing)) {\n existing.push(val);\n } else {\n query[key] = [existing, val];\n }\n } else {\n query[key] = val;\n }\n }\n }\n\n return { path: working || '/', query, hash };\n}\n\n/**\n * Matches a path against a route definition, extracting params.\n * @internal\n */\nfunction matchRoute(\n path: string,\n routes: MockRouteDefinition[]\n): { matched: MockRouteDefinition | null; params: Record<string, string> } {\n for (const route of routes) {\n const params = matchRoutePattern(route.path, path);\n if (params) {\n return { matched: route, params };\n }\n }\n return { matched: null, params: {} };\n}\n\n/**\n * Builds param matches from a route path pattern without compiling the full path into a regex.\n * @internal\n */\nfunction matchRoutePattern(pattern: string, path: string): Record<string, string> | null {\n if (pattern === '*') {\n return {};\n }\n\n // Memoization keeps wildcard/param backtracking linear for repeated subproblems\n // within a single pattern/path match attempt.\n const memo = new Map<string, Record<string, string> | null>();\n\n const findSegmentBoundary = (value: string, startIndex: number): number => {\n const slashIndex = value.indexOf('/', startIndex);\n return slashIndex === -1 ? value.length : slashIndex;\n };\n\n const matchFrom = (patternIndex: number, pathIndex: number): Record<string, string> | null => {\n const memoKey = `${patternIndex}:${pathIndex}`;\n if (memo.has(memoKey)) {\n return memo.get(memoKey) ?? null;\n }\n\n if (patternIndex === pattern.length) {\n const result = pathIndex === path.length ? {} : null;\n memo.set(memoKey, result);\n return result;\n }\n\n const patternChar = pattern[patternIndex];\n\n if (patternChar === '*') {\n for (let candidateEnd = path.length; candidateEnd >= pathIndex; candidateEnd--) {\n const suffixMatch = matchFrom(patternIndex + 1, candidateEnd);\n if (suffixMatch) {\n memo.set(memoKey, suffixMatch);\n return suffixMatch;\n }\n }\n\n memo.set(memoKey, null);\n return null;\n }\n\n if (patternChar === ':' && isWordChar(pattern[patternIndex + 1])) {\n let nameEnd = patternIndex + 2;\n while (nameEnd < pattern.length && isWordChar(pattern[nameEnd])) {\n nameEnd++;\n }\n\n const name = pattern.slice(patternIndex + 1, nameEnd);\n let nextPatternIndex = nameEnd;\n let constraint: string | undefined;\n let catchAll = false;\n\n if (pattern[nameEnd] === '(') {\n const parsedConstraint = readRouteConstraint(pattern, nameEnd);\n if (parsedConstraint) {\n constraint = parsedConstraint.constraint;\n nextPatternIndex = parsedConstraint.endIndex;\n }\n }\n\n if (pattern[nextPatternIndex] === '*') {\n catchAll = true;\n nextPatternIndex++;\n }\n\n const candidateLimit = catchAll\n ? path.length\n : constraint\n ? path.length\n : findSegmentBoundary(path, pathIndex);\n\n for (let candidateEnd = candidateLimit; candidateEnd > pathIndex; candidateEnd--) {\n const candidateValue = path.slice(pathIndex, candidateEnd);\n if (constraint) {\n const constraintRegex = getRouteConstraintRegex(constraint);\n if (!constraintRegex.test(candidateValue)) {\n continue;\n }\n }\n\n const suffixMatch = matchFrom(nextPatternIndex, candidateEnd);\n if (suffixMatch) {\n const result = {\n [name]: candidateValue,\n ...suffixMatch,\n };\n memo.set(memoKey, result);\n return result;\n }\n }\n\n memo.set(memoKey, null);\n return null;\n }\n\n if (pathIndex >= path.length || patternChar !== path[pathIndex]) {\n memo.set(memoKey, null);\n return null;\n }\n\n const result = matchFrom(patternIndex + 1, pathIndex + 1);\n memo.set(memoKey, result);\n return result;\n };\n\n return matchFrom(0, 0);\n}\n\n/**\n * Creates a lightweight mock router for testing that does not interact\n * with the browser History API.\n *\n * The mock router provides a reactive `currentRoute` signal that updates\n * when `push()` or `replace()` is called, making it ideal for testing\n * components or logic that depend on route state.\n *\n * @param options - Mock router configuration\n * @returns A {@link MockRouter} instance\n *\n * @example\n * ```ts\n * import { mockRouter } from '@bquery/bquery/testing';\n *\n * const router = mockRouter({\n * routes: [\n * { path: '/', component: () => null },\n * { path: '/user/:id', component: () => null },\n * ],\n * initialPath: '/',\n * });\n *\n * router.push('/user/42');\n * expect(router.currentRoute.value.params.id).toBe('42');\n * router.destroy();\n * ```\n */\nexport function mockRouter(options: MockRouterOptions = {}): MockRouter {\n const routes = options.routes ?? [{ path: '*', component: () => null }];\n const base = options.base ?? '';\n const initialPath = options.initialPath ?? '/';\n\n const resolveRoute = (fullPath: string): TestRoute => {\n const { path, query, hash } = parsePath(fullPath, base);\n const { matched, params } = matchRoute(path, routes);\n return { path, params, query, matched, hash };\n };\n\n const routeSignal = signal<TestRoute>(resolveRoute(initialPath));\n\n return {\n push(path: string): void {\n routeSignal.value = resolveRoute(path);\n },\n replace(path: string): void {\n routeSignal.value = resolveRoute(path);\n },\n get currentRoute(): Signal<TestRoute> {\n return routeSignal;\n },\n get routes(): MockRouteDefinition[] {\n return routes;\n },\n destroy(): void {\n routeSignal.dispose();\n },\n };\n}\n\n// ============================================================================\n// fireEvent\n// ============================================================================\n\n/**\n * Dispatches a synthetic event on an element and flushes pending effects.\n *\n * By default the event bubbles, is cancelable, and is composed (crosses\n * shadow DOM boundaries). Pass a `detail` option to create a `CustomEvent`.\n *\n * @param el - The target element\n * @param eventName - The event type (e.g. 'click', 'input', 'my-event')\n * @param options - Event configuration\n * @returns `true` if the event was not cancelled\n *\n * @example\n * ```ts\n * import { fireEvent } from '@bquery/bquery/testing';\n *\n * const button = document.createElement('button');\n * let clicked = false;\n * button.addEventListener('click', () => { clicked = true; });\n * fireEvent(button, 'click');\n * expect(clicked).toBe(true);\n * ```\n */\nexport function fireEvent(el: Element, eventName: string, options: FireEventOptions = {}): boolean {\n if (!el) {\n throw new Error('bQuery testing: fireEvent requires a valid element');\n }\n if (!eventName) {\n throw new Error('bQuery testing: fireEvent requires an event name');\n }\n\n const { bubbles = true, cancelable = true, composed = true, detail } = options;\n\n let event: Event;\n if (detail !== undefined) {\n event = new CustomEvent(eventName, { bubbles, cancelable, composed, detail });\n } else {\n event = new Event(eventName, { bubbles, cancelable, composed });\n }\n\n const result = el.dispatchEvent(event);\n\n // Flush any effects triggered by event handlers\n flushEffects();\n\n return result;\n}\n\n// ============================================================================\n// waitFor\n// ============================================================================\n\n/**\n * Waits for a predicate to return `true`, polling at a configurable interval.\n *\n * Useful for asserting conditions that depend on asynchronous operations,\n * timers, or deferred reactive updates.\n *\n * @param predicate - A function that returns `true` when the condition is met\n * @param options - Timeout and interval configuration\n * @returns A promise that resolves when the predicate returns `true`\n * @throws {Error} If the predicate does not return `true` within the timeout\n *\n * @example\n * ```ts\n * import { waitFor } from '@bquery/bquery/testing';\n *\n * await waitFor(() => document.querySelector('.loaded') !== null, {\n * timeout: 2000,\n * });\n * ```\n */\nexport async function waitFor(\n predicate: () => boolean | Promise<boolean>,\n options: WaitForOptions = {}\n): Promise<void> {\n if (typeof predicate !== 'function') {\n throw new Error('bQuery testing: waitFor requires a predicate function');\n }\n\n const { timeout = 1000, interval = 10 } = options;\n const start = Date.now();\n\n while (true) {\n try {\n const result = await predicate();\n if (result) return;\n } catch {\n // Predicate threw — treat as not-yet-met and keep polling\n }\n\n if (Date.now() - start >= timeout) {\n throw new Error(\n `bQuery testing: waitFor timed out after ${timeout}ms — predicate never returned true`\n );\n }\n\n await new Promise((resolve) => setTimeout(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AAY,GAAW;AAAA,IAAE,SAAA;AAAA,IAAS,YAAA;AAAA,IAAY,UAAA;AAAA,IAAU,QAAA;AAAA,GAAQ,IAE5E,IAAQ,IAAI,MAAM,GAAW;AAAA,IAAE,SAAA;AAAA,IAAS,YAAA;AAAA,IAAY,UAAA;AAAA,GAAU;AAGhE,QAAM,IAAS,EAAG,cAAc,CAAA;AAGhC,SAAA,EAAA,GAEO;;AA2BT,eAAsB,EACpB,GACA,IAA0B,CAAA,GACX;AACf,MAAI,OAAO,KAAc,WACvB,OAAM,IAAI,MAAM,uDAAA;AAGlB,QAAM,EAAE,SAAA,IAAU,KAAM,UAAA,IAAW,GAAA,IAAO,GACpC,IAAQ,KAAK,IAAA;AAEnB,aAAa;AACX,QAAI;AAEF,UADe,MAAM,EAAA,EACT;AAAA,YACN;AAAA,IAAA;AAIR,QAAI,KAAK,IAAA,IAAQ,KAAS,EACxB,OAAM,IAAI,MACR,2CAA2C,CAAA,oCAAQ;AAIvD,UAAM,IAAI,QAAA,CAAS,MAAY,WAAW,GAAS,CAAA,CAAS;AAAA"}
@@ -0,0 +1,9 @@
1
+ import { a, i as r, n as e, o as s, r as t, t as n } from "./testing-C5Sjfsna.js";
2
+ export {
3
+ n as fireEvent,
4
+ e as flushEffects,
5
+ t as mockRouter,
6
+ r as mockSignal,
7
+ a as renderComponent,
8
+ s as waitFor
9
+ };
@@ -0,0 +1,44 @@
1
+ function t(n) {
2
+ return typeof Element < "u" && n instanceof Element;
3
+ }
4
+ function e(n) {
5
+ return !!(n && typeof n == "object" && "elements" in n);
6
+ }
7
+ function o(n) {
8
+ return typeof n == "function";
9
+ }
10
+ function i(n) {
11
+ return typeof n == "string";
12
+ }
13
+ function r(n) {
14
+ return typeof n == "number" && !Number.isNaN(n);
15
+ }
16
+ function s(n) {
17
+ return typeof n == "boolean";
18
+ }
19
+ function f(n) {
20
+ return Array.isArray(n);
21
+ }
22
+ function c(n) {
23
+ return n instanceof Date;
24
+ }
25
+ function u(n) {
26
+ return !!(n && (n instanceof Promise || typeof n == "object" && "then" in n && typeof n.then == "function"));
27
+ }
28
+ function a(n) {
29
+ return typeof n == "object" && n !== null;
30
+ }
31
+ export {
32
+ t as a,
33
+ a as c,
34
+ c as i,
35
+ u as l,
36
+ s as n,
37
+ o,
38
+ e as r,
39
+ r as s,
40
+ f as t,
41
+ i as u
42
+ };
43
+
44
+ //# sourceMappingURL=type-guards-BMX2c0LP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-guards-BMX2c0LP.js","names":[],"sources":["../src/core/utils/type-guards.ts"],"sourcesContent":["/**\n * Type guard helpers.\n *\n * @module bquery/core/utils/type-guards\n */\n\n/**\n * Checks if a value is a DOM Element.\n *\n * @param value - The value to check\n * @returns True if the value is an Element\n */\nexport function isElement(value: unknown): value is Element {\n return typeof Element !== 'undefined' && value instanceof Element;\n}\n\n/**\n * Checks if a value is a BQueryCollection-like object.\n *\n * @param value - The value to check\n * @returns True if the value has an elements array property\n */\nexport function isCollection(value: unknown): value is { elements: Element[] } {\n return Boolean(value && typeof value === 'object' && 'elements' in (value as object));\n}\n\n/**\n * Checks if a value is a function.\n *\n * @param value - The value to check\n * @returns True if the value is a function\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a string.\n *\n * @param value - The value to check\n * @returns True if the value is a string\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number (excluding NaN).\n *\n * @param value - The value to check\n * @returns True if the value is a valid number\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value);\n}\n\n/**\n * Checks if a value is a boolean.\n *\n * @param value - The value to check\n * @returns True if the value is a boolean\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is an array.\n *\n * @template T - The type of array elements\n * @param value - The value to check\n * @returns True if the value is an array\n */\nexport function isArray<T = unknown>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Checks if a value is a Date instance.\n *\n * @param value - The value to check\n * @returns True if the value is a Date\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n\n/**\n * Checks if a value is a Promise-like object.\n *\n * @param value - The value to check\n * @returns True if the value is a Promise-like object\n */\nexport function isPromise<T = unknown>(value: unknown): value is Promise<T> {\n return Boolean(\n value &&\n (value instanceof Promise ||\n (typeof value === 'object' &&\n 'then' in (value as object) &&\n typeof (value as { then?: unknown }).then === 'function'))\n );\n}\n\n/**\n * Checks if a value is a non-null object.\n *\n * @param value - The value to check\n * @returns True if the value is an object\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n"],"mappings":"AAYA,SAAgB,EAAU,GAAkC;AAC1D,SAAO,OAAO,UAAY,OAAe,aAAiB;;AAS5D,SAAgB,EAAa,GAAkD;AAC7E,SAAO,GAAQ,KAAS,OAAO,KAAU,YAAY,cAAe;;AAStE,SAAgB,EAAW,GAA0D;AACnF,SAAO,OAAO,KAAU;;AAS1B,SAAgB,EAAS,GAAiC;AACxD,SAAO,OAAO,KAAU;;AAS1B,SAAgB,EAAS,GAAiC;AACxD,SAAO,OAAO,KAAU,YAAY,CAAC,OAAO,MAAM,CAAA;;AASpD,SAAgB,EAAU,GAAkC;AAC1D,SAAO,OAAO,KAAU;;AAU1B,SAAgB,EAAqB,GAA8B;AACjE,SAAO,MAAM,QAAQ,CAAA;;AASvB,SAAgB,EAAO,GAA+B;AACpD,SAAO,aAAiB;;AAS1B,SAAgB,EAAuB,GAAqC;AAC1E,SAAO,GACL,MACC,aAAiB,WACf,OAAO,KAAU,YAChB,UAAW,KACX,OAAQ,EAA6B,QAAS;;AAUtD,SAAgB,EAAS,GAAkD;AACzE,SAAO,OAAO,KAAU,YAAY,MAAU"}
@@ -0,0 +1,36 @@
1
+ import { a as h, f as c, g as r, h as a, m as u, p as d, s as o, u as i } from "./core-DdtZHzsS.js";
2
+ var l = class {
3
+ constructor(s) {
4
+ this.compute = s, this.hasCachedValue = !1, this.dirty = !0, this.disposed = !1, this.subscribers = /* @__PURE__ */ new Set(), this.markDirty = () => {
5
+ if (this.disposed) return;
6
+ this.dirty = !0;
7
+ const e = Array.from(this.subscribers);
8
+ for (const t of e) u(t);
9
+ };
10
+ }
11
+ get value() {
12
+ if (this.disposed)
13
+ return this.hasCachedValue || (this.cachedValue = r(() => this.compute()), this.hasCachedValue = !0), this.cachedValue;
14
+ const s = c();
15
+ return s && (this.subscribers.add(s), d(s, this)), this.dirty && (this.dirty = !1, i(this.markDirty), this.cachedValue = a(this.markDirty, this.compute), this.hasCachedValue = !0), this.cachedValue;
16
+ }
17
+ peek() {
18
+ return this.disposed ? (this.hasCachedValue || (this.cachedValue = r(() => this.compute()), this.hasCachedValue = !0), this.cachedValue) : (this.dirty && (this.dirty = !1, i(this.markDirty), this.cachedValue = a(this.markDirty, this.compute), this.hasCachedValue = !0), this.cachedValue);
19
+ }
20
+ unsubscribe(s) {
21
+ this.subscribers.delete(s);
22
+ }
23
+ dispose() {
24
+ this.disposed = !0, this.dirty && (this.hasCachedValue = !1), this.dirty = !1, i(this.markDirty), this.subscribers.clear();
25
+ }
26
+ }, n = (s) => {
27
+ const e = new l(s), t = h();
28
+ return o(t) && t._addDisposer(() => e.dispose()), e;
29
+ }, f = (s) => r(s);
30
+ export {
31
+ l as n,
32
+ n as r,
33
+ f as t
34
+ };
35
+
36
+ //# sourceMappingURL=untrack-D0fnO5k2.js.map