@bquery/bquery 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -23
- package/dist/a11y/announce.d.ts +43 -0
- package/dist/a11y/announce.d.ts.map +1 -0
- package/dist/a11y/audit.d.ts +42 -0
- package/dist/a11y/audit.d.ts.map +1 -0
- package/dist/a11y/index.d.ts +53 -0
- package/dist/a11y/index.d.ts.map +1 -0
- package/dist/a11y/media-preferences.d.ts +77 -0
- package/dist/a11y/media-preferences.d.ts.map +1 -0
- package/dist/a11y/roving-tab-index.d.ts +38 -0
- package/dist/a11y/roving-tab-index.d.ts.map +1 -0
- package/dist/a11y/skip-link.d.ts +37 -0
- package/dist/a11y/skip-link.d.ts.map +1 -0
- package/dist/a11y/trap-focus.d.ts +49 -0
- package/dist/a11y/trap-focus.d.ts.map +1 -0
- package/dist/a11y/types.d.ts +152 -0
- package/dist/a11y/types.d.ts.map +1 -0
- package/dist/a11y-C5QOVvRn.js +421 -0
- package/dist/a11y-C5QOVvRn.js.map +1 -0
- package/dist/a11y.es.mjs +14 -0
- package/dist/component/component.d.ts +13 -5
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/html.d.ts +40 -3
- package/dist/component/html.d.ts.map +1 -1
- package/dist/component/index.d.ts +3 -2
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/library.d.ts.map +1 -1
- package/dist/component/scope.d.ts +138 -0
- package/dist/component/scope.d.ts.map +1 -0
- package/dist/component/types.d.ts +184 -17
- package/dist/component/types.d.ts.map +1 -1
- package/dist/component-CuuTijA6.js +684 -0
- package/dist/component-CuuTijA6.js.map +1 -0
- package/dist/component.es.mjs +10 -6
- package/dist/{config-DRmZZno3.js → config-BW35FKuA.js} +4 -4
- package/dist/config-BW35FKuA.js.map +1 -0
- package/dist/constraints-3lV9yyBw.js +100 -0
- package/dist/constraints-3lV9yyBw.js.map +1 -0
- package/dist/core/collection.d.ts +48 -0
- package/dist/core/collection.d.ts.map +1 -1
- package/dist/core/element.d.ts +92 -0
- package/dist/core/element.d.ts.map +1 -1
- package/dist/core/env.d.ts +18 -0
- package/dist/core/env.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/shared.d.ts +8 -0
- package/dist/core/shared.d.ts.map +1 -1
- package/dist/core/utils/index.d.ts +52 -41
- package/dist/core/utils/index.d.ts.map +1 -1
- package/dist/core-Cjl7GUu8.js +717 -0
- package/dist/core-Cjl7GUu8.js.map +1 -0
- package/dist/{core-DPdbItcq.js → core-DnlyjbF2.js} +1 -1
- package/dist/{core-DPdbItcq.js.map → core-DnlyjbF2.js.map} +1 -1
- package/dist/core.es.mjs +45 -44
- package/dist/custom-directives-7wAShnnd.js +9 -0
- package/dist/custom-directives-7wAShnnd.js.map +1 -0
- package/dist/devtools/devtools.d.ts +212 -0
- package/dist/devtools/devtools.d.ts.map +1 -0
- package/dist/devtools/index.d.ts +20 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/types.d.ts +69 -0
- package/dist/devtools/types.d.ts.map +1 -0
- package/dist/devtools-D2fQLhDN.js +122 -0
- package/dist/devtools-D2fQLhDN.js.map +1 -0
- package/dist/devtools.es.mjs +19 -0
- package/dist/dnd/draggable.d.ts +51 -0
- package/dist/dnd/draggable.d.ts.map +1 -0
- package/dist/dnd/droppable.d.ts +38 -0
- package/dist/dnd/droppable.d.ts.map +1 -0
- package/dist/dnd/index.d.ts +47 -0
- package/dist/dnd/index.d.ts.map +1 -0
- package/dist/dnd/sortable.d.ts +43 -0
- package/dist/dnd/sortable.d.ts.map +1 -0
- package/dist/dnd/types.d.ts +250 -0
- package/dist/dnd/types.d.ts.map +1 -0
- package/dist/dnd-B8EgyzaI.js +244 -0
- package/dist/dnd-B8EgyzaI.js.map +1 -0
- package/dist/dnd.es.mjs +6 -0
- package/dist/env-NeVmr4Gf.js +19 -0
- package/dist/env-NeVmr4Gf.js.map +1 -0
- package/dist/forms/create-form.d.ts +49 -0
- package/dist/forms/create-form.d.ts.map +1 -0
- package/dist/forms/index.d.ts +39 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/types.d.ts +139 -0
- package/dist/forms/types.d.ts.map +1 -0
- package/dist/forms/validators.d.ts +179 -0
- package/dist/forms/validators.d.ts.map +1 -0
- package/dist/forms-C3yovgH9.js +141 -0
- package/dist/forms-C3yovgH9.js.map +1 -0
- package/dist/forms.es.mjs +14 -0
- package/dist/full.d.ts +37 -9
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +186 -91
- package/dist/full.iife.js +47 -31
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +47 -31
- package/dist/full.umd.js.map +1 -1
- package/dist/i18n/formatting.d.ts +40 -0
- package/dist/i18n/formatting.d.ts.map +1 -0
- package/dist/i18n/i18n.d.ts +48 -0
- package/dist/i18n/i18n.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +57 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/translate.d.ts +83 -0
- package/dist/i18n/translate.d.ts.map +1 -0
- package/dist/i18n/types.d.ts +156 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n-BnnhTFOS.js +89 -0
- package/dist/i18n-BnnhTFOS.js.map +1 -0
- package/dist/i18n.es.mjs +6 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.mjs +233 -138
- package/dist/media/battery.d.ts +35 -0
- package/dist/media/battery.d.ts.map +1 -0
- package/dist/media/breakpoints.d.ts +51 -0
- package/dist/media/breakpoints.d.ts.map +1 -0
- package/dist/media/clipboard.d.ts +30 -0
- package/dist/media/clipboard.d.ts.map +1 -0
- package/dist/media/device-sensors.d.ts +54 -0
- package/dist/media/device-sensors.d.ts.map +1 -0
- package/dist/media/geolocation.d.ts +38 -0
- package/dist/media/geolocation.d.ts.map +1 -0
- package/dist/media/index.d.ts +42 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/media-query.d.ts +36 -0
- package/dist/media/media-query.d.ts.map +1 -0
- package/dist/media/network.d.ts +35 -0
- package/dist/media/network.d.ts.map +1 -0
- package/dist/media/types.d.ts +173 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/viewport.d.ts +32 -0
- package/dist/media/viewport.d.ts.map +1 -0
- package/dist/media-Di2Ta22s.js +340 -0
- package/dist/media-Di2Ta22s.js.map +1 -0
- package/dist/media.es.mjs +12 -0
- package/dist/motion/index.d.ts +7 -3
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/morph.d.ts +27 -0
- package/dist/motion/morph.d.ts.map +1 -0
- package/dist/motion/parallax.d.ts +30 -0
- package/dist/motion/parallax.d.ts.map +1 -0
- package/dist/motion/reduced-motion.d.ts +36 -3
- package/dist/motion/reduced-motion.d.ts.map +1 -1
- package/dist/motion/types.d.ts +58 -0
- package/dist/motion/types.d.ts.map +1 -1
- package/dist/motion/typewriter.d.ts +31 -0
- package/dist/motion/typewriter.d.ts.map +1 -0
- package/dist/motion-qPj_TYGv.js +530 -0
- package/dist/motion-qPj_TYGv.js.map +1 -0
- package/dist/motion.es.mjs +27 -23
- package/dist/mount-SM07RUa6.js +403 -0
- package/dist/mount-SM07RUa6.js.map +1 -0
- package/dist/{object-qGpWr6-J.js → object-BCk-1c8T.js} +5 -4
- package/dist/{object-qGpWr6-J.js.map → object-BCk-1c8T.js.map} +1 -1
- package/dist/{platform-B7JhGBc7.js → platform-CPbCprb6.js} +3 -3
- package/dist/platform-CPbCprb6.js.map +1 -0
- package/dist/platform.es.mjs +2 -2
- package/dist/plugin/index.d.ts +22 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/registry.d.ts +108 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +110 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin-cPoOHFLY.js +64 -0
- package/dist/plugin-cPoOHFLY.js.map +1 -0
- package/dist/plugin.es.mjs +9 -0
- package/dist/reactive/computed.d.ts +7 -0
- package/dist/reactive/computed.d.ts.map +1 -1
- package/dist/reactive-Cfv0RK6x.js +233 -0
- package/dist/reactive-Cfv0RK6x.js.map +1 -0
- package/dist/reactive.es.mjs +18 -17
- package/dist/registry-CWf368tT.js +26 -0
- package/dist/registry-CWf368tT.js.map +1 -0
- package/dist/router/bq-link.d.ts +112 -0
- package/dist/router/bq-link.d.ts.map +1 -0
- package/dist/router/constraints.d.ts +9 -0
- package/dist/router/constraints.d.ts.map +1 -0
- package/dist/router/index.d.ts +14 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/match.d.ts +0 -1
- package/dist/router/match.d.ts.map +1 -1
- package/dist/router/path-pattern.d.ts +14 -0
- package/dist/router/path-pattern.d.ts.map +1 -0
- package/dist/router/query.d.ts.map +1 -1
- package/dist/router/router.d.ts +3 -1
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/types.d.ts +48 -4
- package/dist/router/types.d.ts.map +1 -1
- package/dist/router/use-route.d.ts +50 -0
- package/dist/router/use-route.d.ts.map +1 -0
- package/dist/router/utils.d.ts +3 -0
- package/dist/router/utils.d.ts.map +1 -1
- package/dist/router-BrthaP_z.js +473 -0
- package/dist/router-BrthaP_z.js.map +1 -0
- package/dist/router.es.mjs +13 -10
- package/dist/{sanitize-jyJ2ryE2.js → sanitize-B1V4JswB.js} +95 -83
- package/dist/sanitize-B1V4JswB.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/sanitize.d.ts +4 -1
- package/dist/security/sanitize.d.ts.map +1 -1
- package/dist/security/trusted-html.d.ts +53 -0
- package/dist/security/trusted-html.d.ts.map +1 -0
- package/dist/security.es.mjs +10 -9
- package/dist/ssr/hydrate.d.ts +65 -0
- package/dist/ssr/hydrate.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +59 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/render.d.ts +62 -0
- package/dist/ssr/render.d.ts.map +1 -0
- package/dist/ssr/serialize.d.ts +118 -0
- package/dist/ssr/serialize.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +70 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/ssr-B2qd_WBB.js +248 -0
- package/dist/ssr-B2qd_WBB.js.map +1 -0
- package/dist/ssr.es.mjs +9 -0
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/define-store.d.ts +1 -1
- package/dist/store/define-store.d.ts.map +1 -1
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/mapping.d.ts +1 -1
- package/dist/store/mapping.d.ts.map +1 -1
- package/dist/store/persisted.d.ts +38 -4
- package/dist/store/persisted.d.ts.map +1 -1
- package/dist/store/types.d.ts +140 -3
- package/dist/store/types.d.ts.map +1 -1
- package/dist/store/utils.d.ts +2 -2
- package/dist/store/utils.d.ts.map +1 -1
- package/dist/store/watch.d.ts +1 -1
- package/dist/store/watch.d.ts.map +1 -1
- package/dist/store-DWpyH6p5.js +338 -0
- package/dist/store-DWpyH6p5.js.map +1 -0
- package/dist/store.es.mjs +11 -10
- package/dist/storybook/index.d.ts +37 -0
- package/dist/storybook/index.d.ts.map +1 -0
- package/dist/storybook.es.mjs +151 -0
- package/dist/storybook.es.mjs.map +1 -0
- package/dist/testing/index.d.ts +23 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/testing.d.ts +156 -0
- package/dist/testing/testing.d.ts.map +1 -0
- package/dist/testing/types.d.ts +134 -0
- package/dist/testing/types.d.ts.map +1 -0
- package/dist/testing-CsqjNUyy.js +224 -0
- package/dist/testing-CsqjNUyy.js.map +1 -0
- package/dist/testing.es.mjs +9 -0
- package/dist/type-guards-Do9DWgNp.js +44 -0
- package/dist/type-guards-Do9DWgNp.js.map +1 -0
- package/dist/untrack-DJVQQ2WM.js +33 -0
- package/dist/untrack-DJVQQ2WM.js.map +1 -0
- package/dist/view/custom-directives.d.ts +20 -0
- package/dist/view/custom-directives.d.ts.map +1 -0
- package/dist/view/evaluate.d.ts.map +1 -1
- package/dist/view/process.d.ts.map +1 -1
- package/dist/view.es.mjs +11 -10
- package/package.json +52 -11
- package/src/a11y/announce.ts +131 -0
- package/src/a11y/audit.ts +314 -0
- package/src/a11y/index.ts +68 -0
- package/src/a11y/media-preferences.ts +255 -0
- package/src/a11y/roving-tab-index.ts +164 -0
- package/src/a11y/skip-link.ts +255 -0
- package/src/a11y/trap-focus.ts +184 -0
- package/src/a11y/types.ts +183 -0
- package/src/component/component.ts +345 -65
- package/src/component/html.ts +153 -53
- package/src/component/index.ts +12 -2
- package/src/component/library.ts +66 -28
- package/src/component/scope.ts +212 -0
- package/src/component/types.ts +238 -19
- package/src/core/collection.ts +707 -628
- package/src/core/element.ts +981 -774
- package/src/core/env.ts +60 -0
- package/src/core/index.ts +49 -48
- package/src/core/shared.ts +62 -13
- package/src/core/utils/index.ts +148 -83
- package/src/devtools/devtools.ts +410 -0
- package/src/devtools/index.ts +48 -0
- package/src/devtools/types.ts +104 -0
- package/src/dnd/draggable.ts +296 -0
- package/src/dnd/droppable.ts +228 -0
- package/src/dnd/index.ts +62 -0
- package/src/dnd/sortable.ts +307 -0
- package/src/dnd/types.ts +293 -0
- package/src/forms/create-form.ts +278 -0
- package/src/forms/index.ts +65 -0
- package/src/forms/types.ts +154 -0
- package/src/forms/validators.ts +265 -0
- package/src/full.ts +260 -3
- package/src/i18n/formatting.ts +67 -0
- package/src/i18n/i18n.ts +200 -0
- package/src/i18n/index.ts +67 -0
- package/src/i18n/translate.ts +182 -0
- package/src/i18n/types.ts +171 -0
- package/src/index.ts +108 -36
- package/src/media/battery.ts +116 -0
- package/src/media/breakpoints.ts +131 -0
- package/src/media/clipboard.ts +80 -0
- package/src/media/device-sensors.ts +158 -0
- package/src/media/geolocation.ts +119 -0
- package/src/media/index.ts +76 -0
- package/src/media/media-query.ts +92 -0
- package/src/media/network.ts +115 -0
- package/src/media/types.ts +177 -0
- package/src/media/viewport.ts +84 -0
- package/src/motion/index.ts +57 -48
- package/src/motion/morph.ts +151 -0
- package/src/motion/parallax.ts +120 -0
- package/src/motion/reduced-motion.ts +66 -17
- package/src/motion/transition.ts +97 -97
- package/src/motion/types.ts +63 -0
- package/src/motion/typewriter.ts +164 -0
- package/src/platform/announcer.ts +208 -208
- package/src/platform/config.ts +163 -163
- package/src/platform/cookies.ts +165 -165
- package/src/platform/index.ts +39 -39
- package/src/platform/meta.ts +168 -168
- package/src/plugin/index.ts +37 -0
- package/src/plugin/registry.ts +269 -0
- package/src/plugin/types.ts +137 -0
- package/src/reactive/async-data.ts +486 -486
- package/src/reactive/computed.ts +130 -92
- package/src/reactive/index.ts +37 -37
- package/src/reactive/signal.ts +29 -29
- package/src/router/bq-link.ts +279 -0
- package/src/router/constraints.ts +201 -0
- package/src/router/index.ts +49 -41
- package/src/router/match.ts +312 -106
- package/src/router/path-pattern.ts +52 -0
- package/src/router/query.ts +38 -35
- package/src/router/router.ts +402 -211
- package/src/router/types.ts +139 -93
- package/src/router/use-route.ts +68 -0
- package/src/router/utils.ts +157 -116
- package/src/security/constants.ts +211 -211
- package/src/security/index.ts +12 -10
- package/src/security/sanitize.ts +6 -2
- package/src/security/trusted-html.ts +71 -0
- package/src/ssr/hydrate.ts +82 -0
- package/src/ssr/index.ts +70 -0
- package/src/ssr/render.ts +508 -0
- package/src/ssr/serialize.ts +296 -0
- package/src/ssr/types.ts +81 -0
- package/src/store/create-store.ts +467 -329
- package/src/store/define-store.ts +2 -1
- package/src/store/index.ts +27 -22
- package/src/store/mapping.ts +2 -1
- package/src/store/persisted.ts +249 -61
- package/src/store/types.ts +247 -94
- package/src/store/utils.ts +135 -141
- package/src/store/watch.ts +2 -1
- package/src/storybook/index.ts +480 -0
- package/src/testing/index.ts +42 -0
- package/src/testing/testing.ts +593 -0
- package/src/testing/types.ts +170 -0
- package/src/view/custom-directives.ts +30 -0
- package/src/view/evaluate.ts +292 -290
- package/src/view/process.ts +108 -92
- package/dist/component-CY5MVoYN.js +0 -531
- package/dist/component-CY5MVoYN.js.map +0 -1
- package/dist/config-DRmZZno3.js.map +0 -1
- package/dist/core-CK2Mfpf4.js +0 -648
- package/dist/core-CK2Mfpf4.js.map +0 -1
- package/dist/motion-C5DRdPnO.js +0 -415
- package/dist/motion-C5DRdPnO.js.map +0 -1
- package/dist/platform-B7JhGBc7.js.map +0 -1
- package/dist/reactive-BDya-ia8.js +0 -253
- package/dist/reactive-BDya-ia8.js.map +0 -1
- package/dist/router-CijiICxt.js +0 -188
- package/dist/router-CijiICxt.js.map +0 -1
- package/dist/sanitize-jyJ2ryE2.js.map +0 -1
- package/dist/store-CPK9E62U.js +0 -262
- package/dist/store-CPK9E62U.js.map +0 -1
- package/dist/view-Cdi0g-qo.js +0 -396
- package/dist/view-Cdi0g-qo.js.map +0 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { n as p } from "./core-DnlyjbF2.js";
|
|
2
|
+
import { u as R } from "./reactive-Cfv0RK6x.js";
|
|
3
|
+
import { t as q } from "./constraints-3lV9yyBw.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, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
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 L(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 T(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
|
+
T as o,
|
|
220
|
+
z as r,
|
|
221
|
+
L as t
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
//# sourceMappingURL=testing-CsqjNUyy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing-CsqjNUyy.js","names":[],"sources":["../src/testing/testing.ts"],"sourcesContent":["/**\r\n * Testing utilities for bQuery.js.\r\n *\r\n * Provides helpers for mounting components, controlling signals, mocking\r\n * the router, dispatching events, and asserting async conditions — all\r\n * designed for use with `bun:test` and happy-dom.\r\n *\r\n * @module bquery/testing\r\n */\r\n\r\nimport { batch, Signal, signal } from '../reactive/index';\r\nimport { getNormalizedRouteConstraint } from '../router/constraints';\r\nimport type {\r\n FireEventOptions,\r\n MockRouteDefinition,\r\n MockRouter,\r\n MockRouterOptions,\r\n MockSignal,\r\n RenderComponentOptions,\r\n RenderResult,\r\n TestRoute,\r\n WaitForOptions,\r\n} from './types';\r\n\r\n// ============================================================================\r\n// renderComponent\r\n// ============================================================================\r\n\r\nconst isWordChar = (char: string | undefined): boolean =>\r\n char !== undefined &&\r\n ((char >= 'a' && char <= 'z') ||\r\n (char >= 'A' && char <= 'Z') ||\r\n (char >= '0' && char <= '9') ||\r\n char === '_');\r\n\r\nconst readRouteConstraint = (\r\n pattern: string,\r\n startIndex: number\r\n): { constraint: string; endIndex: number } | null => {\r\n let depth = 1;\r\n let constraint = '';\r\n let i = startIndex + 1;\r\n\r\n while (i < pattern.length) {\r\n const char = pattern[i];\r\n\r\n if (char === '\\\\' && i + 1 < pattern.length) {\r\n constraint += char + pattern[i + 1];\r\n i += 2;\r\n continue;\r\n }\r\n\r\n if (char === '(') {\r\n depth++;\r\n } else if (char === ')') {\r\n depth--;\r\n if (depth === 0) {\r\n return { constraint, endIndex: i + 1 };\r\n }\r\n }\r\n\r\n constraint += char;\r\n i++;\r\n }\r\n\r\n return null;\r\n};\r\n\r\nconst routeConstraintRegexCache = new Map<string, RegExp>();\r\n\r\nconst getRouteConstraintRegex = (constraint: string): RegExp => {\r\n const normalized = getNormalizedRouteConstraint(constraint);\r\n const cached = routeConstraintRegexCache.get(normalized);\r\n if (cached) {\r\n return cached;\r\n }\r\n\r\n const compiled = new RegExp(`^(?:${normalized})$`);\r\n routeConstraintRegexCache.set(normalized, compiled);\r\n return compiled;\r\n};\r\n\r\n/**\r\n * Mounts a custom element by tag name for testing and returns a handle\r\n * to interact with it.\r\n *\r\n * The element is created, configured with the given props and slots,\r\n * and appended to the container (defaults to `document.body`). Call\r\n * `unmount()` to remove the element and trigger its `disconnectedCallback`.\r\n *\r\n * @param tagName - The custom element tag name (must already be registered)\r\n * @param options - Props, slots, and container configuration\r\n * @returns A {@link RenderResult} with the element and an unmount function\r\n * @throws {Error} If the tag name is not a valid custom element name\r\n *\r\n * @example\r\n * ```ts\r\n * import { renderComponent } from '@bquery/bquery/testing';\r\n *\r\n * const { el, unmount } = renderComponent('my-counter', {\r\n * props: { start: '5' },\r\n * });\r\n * expect(el.shadowRoot?.textContent).toContain('5');\r\n * unmount();\r\n * ```\r\n */\r\nexport function renderComponent(\r\n tagName: string,\r\n options: RenderComponentOptions = {}\r\n): RenderResult {\r\n if (!tagName || !tagName.includes('-')) {\r\n throw new Error(\r\n `bQuery testing: \"${tagName}\" is not a valid custom element tag name (must contain a hyphen)`\r\n );\r\n }\r\n\r\n const { props, slots, container = document.body } = options;\r\n\r\n const el = document.createElement(tagName);\r\n\r\n // Set attributes (props) before connecting\r\n if (props) {\r\n for (const [key, value] of Object.entries(props)) {\r\n if (value === null || value === undefined) continue;\r\n el.setAttribute(key, String(value));\r\n }\r\n }\r\n\r\n // Inject slot content before connecting so the component can discover it\r\n if (slots) {\r\n if (typeof slots === 'string') {\r\n el.innerHTML = slots;\r\n } else {\r\n const parts: string[] = [];\r\n for (const [slotName, html] of Object.entries(slots)) {\r\n if (slotName === 'default') {\r\n parts.push(html);\r\n } else {\r\n const safeSlotName = slotName\r\n .replace(/&/g, '&')\r\n .replace(/\"/g, '"')\r\n .replace(/</g, '<')\r\n .replace(/>/g, '>');\r\n parts.push(`<div slot=\"${safeSlotName}\">${html}</div>`);\r\n }\r\n }\r\n el.innerHTML = parts.join('');\r\n }\r\n }\r\n\r\n // Connect — triggers connectedCallback\r\n container.appendChild(el);\r\n\r\n const unmount = (): void => {\r\n if (el.parentNode) {\r\n el.parentNode.removeChild(el);\r\n }\r\n };\r\n\r\n return { el, unmount };\r\n}\r\n\r\n// ============================================================================\r\n// flushEffects\r\n// ============================================================================\r\n\r\n/**\r\n * Synchronously flushes any pending reactive effects.\r\n *\r\n * In bQuery's reactive system, effects outside of a batch are executed\r\n * synchronously. This helper exists primarily for clarity and for\r\n * flushing effects that may have been deferred inside a batch.\r\n *\r\n * Internally it performs a no-op batch to trigger the flush of any\r\n * pending observers that were queued during a prior `batch()` call.\r\n *\r\n * @example\r\n * ```ts\r\n * import { signal, batch } from '@bquery/bquery/reactive';\r\n * import { flushEffects } from '@bquery/bquery/testing';\r\n *\r\n * const count = signal(0);\r\n * let observed = 0;\r\n * effect(() => { observed = count.value; });\r\n *\r\n * batch(() => { count.value = 42; });\r\n * flushEffects();\r\n * expect(observed).toBe(42);\r\n * ```\r\n */\r\nexport function flushEffects(): void {\r\n // A no-op batch triggers endBatch which flushes any pending observers.\r\n // Since bQuery's effects are synchronous outside of batches, this is\r\n // mainly useful after manual batch calls or micro-task boundaries.\r\n batch(() => {\r\n /* intentionally empty — triggers pending observer flush */\r\n });\r\n}\r\n\r\n// ============================================================================\r\n// mockSignal\r\n// ============================================================================\r\n\r\n/**\r\n * Creates a controllable signal for tests with `set()` and `reset()` helpers.\r\n *\r\n * This is a thin wrapper around `signal()` that records the initial value\r\n * and adds explicit `set()` / `reset()` methods for clearer test intent.\r\n *\r\n * @template T - The type of the signal value\r\n * @param initialValue - The initial value\r\n * @returns A {@link MockSignal} instance\r\n *\r\n * @example\r\n * ```ts\r\n * import { mockSignal } from '@bquery/bquery/testing';\r\n *\r\n * const count = mockSignal(0);\r\n * count.set(5);\r\n * expect(count.value).toBe(5);\r\n * count.reset();\r\n * expect(count.value).toBe(0);\r\n * ```\r\n */\r\nexport function mockSignal<T>(initialValue: T): MockSignal<T> {\r\n const s = signal(initialValue) as Signal<T> & {\r\n set: (value: T) => void;\r\n reset: () => void;\r\n initialValue: T;\r\n };\r\n\r\n Object.defineProperty(s, 'initialValue', {\r\n value: initialValue,\r\n writable: false,\r\n enumerable: true,\r\n });\r\n\r\n s.set = function (value: T): void {\r\n s.value = value;\r\n };\r\n\r\n s.reset = function (): void {\r\n s.value = initialValue;\r\n };\r\n\r\n return s as MockSignal<T>;\r\n}\r\n\r\n// ============================================================================\r\n// mockRouter\r\n// ============================================================================\r\n\r\n/**\r\n * Parses a path string into the route's `path`, `query`, and `hash` parts.\r\n * @internal\r\n */\r\nfunction parsePath(\r\n fullPath: string,\r\n base: string\r\n): { path: string; query: Record<string, string | string[]>; hash: string } {\r\n let working = fullPath;\r\n\r\n // Strip base prefix\r\n if (base && working.startsWith(base)) {\r\n working = working.slice(base.length) || '/';\r\n }\r\n\r\n // Extract hash\r\n let hash = '';\r\n const hashIdx = working.indexOf('#');\r\n if (hashIdx >= 0) {\r\n hash = working.slice(hashIdx + 1);\r\n working = working.slice(0, hashIdx);\r\n }\r\n\r\n // Extract query string\r\n const query: Record<string, string | string[]> = {};\r\n const qIdx = working.indexOf('?');\r\n if (qIdx >= 0) {\r\n const qs = working.slice(qIdx + 1);\r\n working = working.slice(0, qIdx);\r\n for (const pair of qs.split('&')) {\r\n const eqIdx = pair.indexOf('=');\r\n const key = eqIdx >= 0 ? decodeURIComponent(pair.slice(0, eqIdx)) : decodeURIComponent(pair);\r\n const val = eqIdx >= 0 ? decodeURIComponent(pair.slice(eqIdx + 1)) : '';\r\n const existing = query[key];\r\n if (existing !== undefined) {\r\n if (Array.isArray(existing)) {\r\n existing.push(val);\r\n } else {\r\n query[key] = [existing, val];\r\n }\r\n } else {\r\n query[key] = val;\r\n }\r\n }\r\n }\r\n\r\n return { path: working || '/', query, hash };\r\n}\r\n\r\n/**\r\n * Matches a path against a route definition, extracting params.\r\n * @internal\r\n */\r\nfunction matchRoute(\r\n path: string,\r\n routes: MockRouteDefinition[]\r\n): { matched: MockRouteDefinition | null; params: Record<string, string> } {\r\n for (const route of routes) {\r\n const params = matchRoutePattern(route.path, path);\r\n if (params) {\r\n return { matched: route, params };\r\n }\r\n }\r\n return { matched: null, params: {} };\r\n}\r\n\r\n/**\r\n * Builds param matches from a route path pattern without compiling the full path into a regex.\r\n * @internal\r\n */\r\nfunction matchRoutePattern(pattern: string, path: string): Record<string, string> | null {\r\n if (pattern === '*') {\r\n return {};\r\n }\r\n\r\n // Memoization keeps wildcard/param backtracking linear for repeated subproblems\r\n // within a single pattern/path match attempt.\r\n const memo = new Map<string, Record<string, string> | null>();\r\n\r\n const findSegmentBoundary = (value: string, startIndex: number): number => {\r\n const slashIndex = value.indexOf('/', startIndex);\r\n return slashIndex === -1 ? value.length : slashIndex;\r\n };\r\n\r\n const matchFrom = (patternIndex: number, pathIndex: number): Record<string, string> | null => {\r\n const memoKey = `${patternIndex}:${pathIndex}`;\r\n if (memo.has(memoKey)) {\r\n return memo.get(memoKey) ?? null;\r\n }\r\n\r\n if (patternIndex === pattern.length) {\r\n const result = pathIndex === path.length ? {} : null;\r\n memo.set(memoKey, result);\r\n return result;\r\n }\r\n\r\n const patternChar = pattern[patternIndex];\r\n\r\n if (patternChar === '*') {\r\n for (let candidateEnd = path.length; candidateEnd >= pathIndex; candidateEnd--) {\r\n const suffixMatch = matchFrom(patternIndex + 1, candidateEnd);\r\n if (suffixMatch) {\r\n memo.set(memoKey, suffixMatch);\r\n return suffixMatch;\r\n }\r\n }\r\n\r\n memo.set(memoKey, null);\r\n return null;\r\n }\r\n\r\n if (patternChar === ':' && isWordChar(pattern[patternIndex + 1])) {\r\n let nameEnd = patternIndex + 2;\r\n while (nameEnd < pattern.length && isWordChar(pattern[nameEnd])) {\r\n nameEnd++;\r\n }\r\n\r\n const name = pattern.slice(patternIndex + 1, nameEnd);\r\n let nextPatternIndex = nameEnd;\r\n let constraint: string | undefined;\r\n let catchAll = false;\r\n\r\n if (pattern[nameEnd] === '(') {\r\n const parsedConstraint = readRouteConstraint(pattern, nameEnd);\r\n if (parsedConstraint) {\r\n constraint = parsedConstraint.constraint;\r\n nextPatternIndex = parsedConstraint.endIndex;\r\n }\r\n }\r\n\r\n if (pattern[nextPatternIndex] === '*') {\r\n catchAll = true;\r\n nextPatternIndex++;\r\n }\r\n\r\n const candidateLimit = catchAll\r\n ? path.length\r\n : constraint\r\n ? path.length\r\n : findSegmentBoundary(path, pathIndex);\r\n\r\n for (let candidateEnd = candidateLimit; candidateEnd > pathIndex; candidateEnd--) {\r\n const candidateValue = path.slice(pathIndex, candidateEnd);\r\n if (constraint) {\r\n const constraintRegex = getRouteConstraintRegex(constraint);\r\n if (!constraintRegex.test(candidateValue)) {\r\n continue;\r\n }\r\n }\r\n\r\n const suffixMatch = matchFrom(nextPatternIndex, candidateEnd);\r\n if (suffixMatch) {\r\n const result = {\r\n [name]: candidateValue,\r\n ...suffixMatch,\r\n };\r\n memo.set(memoKey, result);\r\n return result;\r\n }\r\n }\r\n\r\n memo.set(memoKey, null);\r\n return null;\r\n }\r\n\r\n if (pathIndex >= path.length || patternChar !== path[pathIndex]) {\r\n memo.set(memoKey, null);\r\n return null;\r\n }\r\n\r\n const result = matchFrom(patternIndex + 1, pathIndex + 1);\r\n memo.set(memoKey, result);\r\n return result;\r\n };\r\n\r\n return matchFrom(0, 0);\r\n}\r\n\r\n/**\r\n * Creates a lightweight mock router for testing that does not interact\r\n * with the browser History API.\r\n *\r\n * The mock router provides a reactive `currentRoute` signal that updates\r\n * when `push()` or `replace()` is called, making it ideal for testing\r\n * components or logic that depend on route state.\r\n *\r\n * @param options - Mock router configuration\r\n * @returns A {@link MockRouter} instance\r\n *\r\n * @example\r\n * ```ts\r\n * import { mockRouter } from '@bquery/bquery/testing';\r\n *\r\n * const router = mockRouter({\r\n * routes: [\r\n * { path: '/', component: () => null },\r\n * { path: '/user/:id', component: () => null },\r\n * ],\r\n * initialPath: '/',\r\n * });\r\n *\r\n * router.push('/user/42');\r\n * expect(router.currentRoute.value.params.id).toBe('42');\r\n * router.destroy();\r\n * ```\r\n */\r\nexport function mockRouter(options: MockRouterOptions = {}): MockRouter {\r\n const routes = options.routes ?? [{ path: '*', component: () => null }];\r\n const base = options.base ?? '';\r\n const initialPath = options.initialPath ?? '/';\r\n\r\n const resolveRoute = (fullPath: string): TestRoute => {\r\n const { path, query, hash } = parsePath(fullPath, base);\r\n const { matched, params } = matchRoute(path, routes);\r\n return { path, params, query, matched, hash };\r\n };\r\n\r\n const routeSignal = signal<TestRoute>(resolveRoute(initialPath));\r\n\r\n return {\r\n push(path: string): void {\r\n routeSignal.value = resolveRoute(path);\r\n },\r\n replace(path: string): void {\r\n routeSignal.value = resolveRoute(path);\r\n },\r\n get currentRoute(): Signal<TestRoute> {\r\n return routeSignal;\r\n },\r\n get routes(): MockRouteDefinition[] {\r\n return routes;\r\n },\r\n destroy(): void {\r\n routeSignal.dispose();\r\n },\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// fireEvent\r\n// ============================================================================\r\n\r\n/**\r\n * Dispatches a synthetic event on an element and flushes pending effects.\r\n *\r\n * By default the event bubbles, is cancelable, and is composed (crosses\r\n * shadow DOM boundaries). Pass a `detail` option to create a `CustomEvent`.\r\n *\r\n * @param el - The target element\r\n * @param eventName - The event type (e.g. 'click', 'input', 'my-event')\r\n * @param options - Event configuration\r\n * @returns `true` if the event was not cancelled\r\n *\r\n * @example\r\n * ```ts\r\n * import { fireEvent } from '@bquery/bquery/testing';\r\n *\r\n * const button = document.createElement('button');\r\n * let clicked = false;\r\n * button.addEventListener('click', () => { clicked = true; });\r\n * fireEvent(button, 'click');\r\n * expect(clicked).toBe(true);\r\n * ```\r\n */\r\nexport function fireEvent(el: Element, eventName: string, options: FireEventOptions = {}): boolean {\r\n if (!el) {\r\n throw new Error('bQuery testing: fireEvent requires a valid element');\r\n }\r\n if (!eventName) {\r\n throw new Error('bQuery testing: fireEvent requires an event name');\r\n }\r\n\r\n const { bubbles = true, cancelable = true, composed = true, detail } = options;\r\n\r\n let event: Event;\r\n if (detail !== undefined) {\r\n event = new CustomEvent(eventName, { bubbles, cancelable, composed, detail });\r\n } else {\r\n event = new Event(eventName, { bubbles, cancelable, composed });\r\n }\r\n\r\n const result = el.dispatchEvent(event);\r\n\r\n // Flush any effects triggered by event handlers\r\n flushEffects();\r\n\r\n return result;\r\n}\r\n\r\n// ============================================================================\r\n// waitFor\r\n// ============================================================================\r\n\r\n/**\r\n * Waits for a predicate to return `true`, polling at a configurable interval.\r\n *\r\n * Useful for asserting conditions that depend on asynchronous operations,\r\n * timers, or deferred reactive updates.\r\n *\r\n * @param predicate - A function that returns `true` when the condition is met\r\n * @param options - Timeout and interval configuration\r\n * @returns A promise that resolves when the predicate returns `true`\r\n * @throws {Error} If the predicate does not return `true` within the timeout\r\n *\r\n * @example\r\n * ```ts\r\n * import { waitFor } from '@bquery/bquery/testing';\r\n *\r\n * await waitFor(() => document.querySelector('.loaded') !== null, {\r\n * timeout: 2000,\r\n * });\r\n * ```\r\n */\r\nexport async function waitFor(\r\n predicate: () => boolean | Promise<boolean>,\r\n options: WaitForOptions = {}\r\n): Promise<void> {\r\n if (typeof predicate !== 'function') {\r\n throw new Error('bQuery testing: waitFor requires a predicate function');\r\n }\r\n\r\n const { timeout = 1000, interval = 10 } = options;\r\n const start = Date.now();\r\n\r\n while (true) {\r\n try {\r\n const result = await predicate();\r\n if (result) return;\r\n } catch {\r\n // Predicate threw — treat as not-yet-met and keep polling\r\n }\r\n\r\n if (Date.now() - start >= timeout) {\r\n throw new Error(\r\n `bQuery testing: waitFor timed out after ${timeout}ms — predicate never returned true`\r\n );\r\n }\r\n\r\n await new Promise((resolve) => setTimeout(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IAAI,YAAY,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,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-Do9DWgNp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards-Do9DWgNp.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,33 @@
|
|
|
1
|
+
import { a as e, c as h, d as t, l as c, s as u, u as i } from "./core-DnlyjbF2.js";
|
|
2
|
+
var d = 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 r = Array.from(this.subscribers);
|
|
8
|
+
for (const a of r) c(a);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
get value() {
|
|
12
|
+
if (this.disposed)
|
|
13
|
+
return this.hasCachedValue || (this.cachedValue = t(() => this.compute()), this.hasCachedValue = !0), this.cachedValue;
|
|
14
|
+
const s = u();
|
|
15
|
+
return s && (this.subscribers.add(s), h(s, this)), this.dirty && (this.dirty = !1, e(this.markDirty), this.cachedValue = i(this.markDirty, this.compute), this.hasCachedValue = !0), this.cachedValue;
|
|
16
|
+
}
|
|
17
|
+
peek() {
|
|
18
|
+
return this.disposed ? (this.hasCachedValue || (this.cachedValue = t(() => this.compute()), this.hasCachedValue = !0), this.cachedValue) : (this.dirty && (this.dirty = !1, e(this.markDirty), this.cachedValue = i(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, e(this.markDirty), this.subscribers.clear();
|
|
25
|
+
}
|
|
26
|
+
}, o = (s) => new d(s), n = (s) => t(s);
|
|
27
|
+
export {
|
|
28
|
+
d as n,
|
|
29
|
+
o as r,
|
|
30
|
+
n as t
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=untrack-DJVQQ2WM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"untrack-DJVQQ2WM.js","names":[],"sources":["../src/reactive/computed.ts","../src/reactive/untrack.ts"],"sourcesContent":["/**\r\n * Computed reactive values.\r\n */\r\n\r\nimport {\r\n clearDependencies,\r\n getCurrentObserver,\r\n registerDependency,\r\n scheduleObserver,\r\n track,\r\n withoutCurrentObserver,\r\n type ReactiveSource,\r\n} from './internals';\r\n\r\n/**\r\n * A computed value that derives from other reactive sources.\r\n *\r\n * Computed values are lazily evaluated and cached. They only\r\n * recompute when their dependencies change.\r\n *\r\n * @template T - The type of the computed value\r\n */\r\nexport class Computed<T> implements ReactiveSource {\r\n private cachedValue!: T;\r\n private hasCachedValue = false;\r\n private dirty = true;\r\n private disposed = false;\r\n private subscribers = new Set<() => void>();\r\n private readonly markDirty = () => {\r\n if (this.disposed) {\r\n return;\r\n }\r\n this.dirty = true;\r\n // Create snapshot to avoid issues with subscribers modifying the set during iteration\r\n const subscribersSnapshot = Array.from(this.subscribers);\r\n for (const subscriber of subscribersSnapshot) {\r\n scheduleObserver(subscriber);\r\n }\r\n };\r\n\r\n /**\r\n * Creates a new computed value.\r\n * @param compute - Function that computes the value\r\n */\r\n constructor(private readonly compute: () => T) {}\r\n\r\n /**\r\n * Gets the computed value, recomputing if dependencies changed.\r\n * During untrack calls, getCurrentObserver returns undefined, preventing dependency tracking.\r\n */\r\n get value(): T {\r\n if (this.disposed) {\r\n if (!this.hasCachedValue) {\r\n this.cachedValue = withoutCurrentObserver(() => this.compute());\r\n this.hasCachedValue = true;\r\n }\r\n return this.cachedValue;\r\n }\r\n\r\n const current = getCurrentObserver();\r\n if (current) {\r\n this.subscribers.add(current);\r\n registerDependency(current, this);\r\n }\r\n if (this.dirty) {\r\n this.dirty = false;\r\n // Clear old dependencies before recomputing\r\n clearDependencies(this.markDirty);\r\n this.cachedValue = track(this.markDirty, this.compute);\r\n this.hasCachedValue = true;\r\n }\r\n return this.cachedValue;\r\n }\r\n\r\n /**\r\n * Reads the current computed value without tracking.\r\n * Useful when you need the value but don't want to create a dependency.\r\n *\r\n * @returns The current cached value (recomputes if dirty)\r\n */\r\n peek(): T {\r\n if (this.disposed) {\r\n if (!this.hasCachedValue) {\r\n this.cachedValue = withoutCurrentObserver(() => this.compute());\r\n this.hasCachedValue = true;\r\n }\r\n return this.cachedValue;\r\n }\r\n\r\n if (this.dirty) {\r\n this.dirty = false;\r\n // Clear old dependencies before recomputing\r\n clearDependencies(this.markDirty);\r\n this.cachedValue = track(this.markDirty, this.compute);\r\n this.hasCachedValue = true;\r\n }\r\n return this.cachedValue;\r\n }\r\n\r\n /**\r\n * Removes an observer from this computed's subscriber set.\r\n * @internal\r\n */\r\n unsubscribe(observer: () => void): void {\r\n this.subscribers.delete(observer);\r\n }\r\n\r\n /**\r\n * Disposes the computed value by unsubscribing its internal observer\r\n * from all upstream dependencies and clearing subscribers.\r\n */\r\n dispose(): void {\r\n this.disposed = true;\r\n if (this.dirty) {\r\n this.hasCachedValue = false;\r\n }\r\n this.dirty = false;\r\n clearDependencies(this.markDirty);\r\n this.subscribers.clear();\r\n }\r\n}\r\n\r\n/**\r\n * Creates a new computed value.\r\n *\r\n * @template T - The type of the computed value\r\n * @param fn - Function that computes the value from reactive sources\r\n * @returns A new Computed instance\r\n */\r\nexport const computed = <T>(fn: () => T): Computed<T> => new Computed(fn);\r\n","/**\n * Dependency tracking control helpers.\n */\n\nimport { withoutCurrentObserver } from './internals';\n\n/**\n * Executes a function without tracking any signal dependencies.\n * Useful when reading a signal value without creating a reactive dependency.\n *\n * This implementation temporarily hides the current observer rather than\n * disabling tracking globally. This ensures that nested reactive internals\n * (e.g., computed recomputation triggered during untrack) can still properly\n * track their own dependencies.\n *\n * @template T - The return type of the function\n * @param fn - The function to execute without tracking\n * @returns The result of the function\n *\n * @example\n * ```ts\n * const count = signal(0);\n * effect(() => {\n * // This read creates a dependency\n * console.log(count.value);\n * // This read does not create a dependency\n * const snapshot = untrack(() => count.value);\n * });\n * ```\n */\nexport const untrack = <T>(fn: () => T): T => withoutCurrentObserver(fn);\n"],"mappings":";AAsBA,IAAa,IAAb,MAAmD;AAAA,EAsBjD,YAAY,GAAmC;AAAlB,SAAA,UAAA,yBApBJ,iBACT,oBACG,uBACG,oBAAI,IAAA,0BACS;AACjC,UAAI,KAAK,SACP;AAEF,WAAK,QAAQ;AAEb,YAAM,IAAsB,MAAM,KAAK,KAAK,WAAA;AAC5C,iBAAW,KAAc,EACvB,CAAA,EAAiB,CAAA;AAAA;;EAcrB,IAAI,QAAW;AACb,QAAI,KAAK;AACP,aAAK,KAAK,mBACR,KAAK,cAAc,EAAA,MAA6B,KAAK,QAAA,CAAS,GAC9D,KAAK,iBAAiB,KAEjB,KAAK;AAGd,UAAM,IAAU,EAAA;AAChB,WAAI,MACF,KAAK,YAAY,IAAI,CAAA,GACrB,EAAmB,GAAS,IAAA,IAE1B,KAAK,UACP,KAAK,QAAQ,IAEb,EAAkB,KAAK,SAAA,GACvB,KAAK,cAAc,EAAM,KAAK,WAAW,KAAK,OAAA,GAC9C,KAAK,iBAAiB,KAEjB,KAAK;AAAA;EASd,OAAU;AACR,WAAI,KAAK,YACF,KAAK,mBACR,KAAK,cAAc,EAAA,MAA6B,KAAK,QAAA,CAAS,GAC9D,KAAK,iBAAiB,KAEjB,KAAK,gBAGV,KAAK,UACP,KAAK,QAAQ,IAEb,EAAkB,KAAK,SAAA,GACvB,KAAK,cAAc,EAAM,KAAK,WAAW,KAAK,OAAA,GAC9C,KAAK,iBAAiB,KAEjB,KAAK;AAAA;EAOd,YAAY,GAA4B;AACtC,SAAK,YAAY,OAAO,CAAA;AAAA;EAO1B,UAAgB;AACd,SAAK,WAAW,IACZ,KAAK,UACP,KAAK,iBAAiB,KAExB,KAAK,QAAQ,IACb,EAAkB,KAAK,SAAA,GACvB,KAAK,YAAY,MAAA;AAAA;GAWR,IAAA,CAAe,MAA6B,IAAI,EAAS,CAAA,GCnGzD,IAAA,CAAc,MAAmB,EAAuB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DirectiveHandler } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Function signature used to resolve custom directives without coupling the
|
|
4
|
+
* view pipeline directly to the plugin module.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export type CustomDirectiveResolver = (name: string) => DirectiveHandler | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Registers the resolver used by the view pipeline for custom directives.
|
|
10
|
+
*
|
|
11
|
+
* Pass `null` to unregister the current resolver and reset to the default behavior.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare const registerCustomDirectiveResolver: (resolver: CustomDirectiveResolver | null) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a custom directive handler when one is registered.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare const getCustomDirective: (name: string) => DirectiveHandler | undefined;
|
|
20
|
+
//# sourceMappingURL=custom-directives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-directives.d.ts","sourceRoot":"","sources":["../../src/view/custom-directives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAAG,SAAS,CAAC;AAIrF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,GAC1C,UAAU,uBAAuB,GAAG,IAAI,KACvC,IAEF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,gBAAgB,GAAG,SAEpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/view/evaluate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/view/evaluate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4D9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,QAAO,IAGvC,CAAC;AA8BF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,SAAS,cAAc,KAAG,CAoBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,SAAS,cAAc,KAAG,CAiBtF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAsH/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/view/process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/view/process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,EAAE,EAAE,gBAAgB,CAAC;IACrB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,GAAG,EAAE,gBAAgB,CAAC;IACtB,GAAG,EAAE,gBAAgB,CAAC;IACtB,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,gBAAgB,CAAC;IAC7C,EAAE,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,gBAAgB,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,IAAI,OAAO,EACX,SAAS,cAAc,EACvB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,EACrB,UAAU,iBAAiB,KAC1B,IAuDF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,IAAI,OAAO,EACX,SAAS,cAAc,EACvB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,EACrB,UAAU,iBAAiB,KAC1B,IAWF,CAAC"}
|
package/dist/view.es.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as a, r as o } from "./core-DnlyjbF2.js";
|
|
2
|
+
import { u as e } from "./reactive-Cfv0RK6x.js";
|
|
3
|
+
import { r as s } from "./untrack-DJVQQ2WM.js";
|
|
4
|
+
import { n as c, r as f, t as i } from "./mount-SM07RUa6.js";
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
e as batch,
|
|
7
|
+
f as clearExpressionCache,
|
|
8
|
+
s as computed,
|
|
9
|
+
i as createTemplate,
|
|
10
|
+
o as effect,
|
|
11
|
+
c as mount,
|
|
12
|
+
a as signal
|
|
12
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bquery/bquery",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "The jQuery for the Modern Web Platform - Zero build, TypeScript-first library with reactivity, components, and motion",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/full.umd.js",
|
|
@@ -54,6 +54,46 @@
|
|
|
54
54
|
"./view": {
|
|
55
55
|
"import": "./dist/view.es.mjs",
|
|
56
56
|
"types": "./dist/view/index.d.ts"
|
|
57
|
+
},
|
|
58
|
+
"./storybook": {
|
|
59
|
+
"import": "./dist/storybook.es.mjs",
|
|
60
|
+
"types": "./dist/storybook/index.d.ts"
|
|
61
|
+
},
|
|
62
|
+
"./forms": {
|
|
63
|
+
"import": "./dist/forms.es.mjs",
|
|
64
|
+
"types": "./dist/forms/index.d.ts"
|
|
65
|
+
},
|
|
66
|
+
"./i18n": {
|
|
67
|
+
"import": "./dist/i18n.es.mjs",
|
|
68
|
+
"types": "./dist/i18n/index.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./a11y": {
|
|
71
|
+
"import": "./dist/a11y.es.mjs",
|
|
72
|
+
"types": "./dist/a11y/index.d.ts"
|
|
73
|
+
},
|
|
74
|
+
"./dnd": {
|
|
75
|
+
"import": "./dist/dnd.es.mjs",
|
|
76
|
+
"types": "./dist/dnd/index.d.ts"
|
|
77
|
+
},
|
|
78
|
+
"./media": {
|
|
79
|
+
"import": "./dist/media.es.mjs",
|
|
80
|
+
"types": "./dist/media/index.d.ts"
|
|
81
|
+
},
|
|
82
|
+
"./plugin": {
|
|
83
|
+
"import": "./dist/plugin.es.mjs",
|
|
84
|
+
"types": "./dist/plugin/index.d.ts"
|
|
85
|
+
},
|
|
86
|
+
"./devtools": {
|
|
87
|
+
"import": "./dist/devtools.es.mjs",
|
|
88
|
+
"types": "./dist/devtools/index.d.ts"
|
|
89
|
+
},
|
|
90
|
+
"./testing": {
|
|
91
|
+
"import": "./dist/testing.es.mjs",
|
|
92
|
+
"types": "./dist/testing/index.d.ts"
|
|
93
|
+
},
|
|
94
|
+
"./ssr": {
|
|
95
|
+
"import": "./dist/ssr.es.mjs",
|
|
96
|
+
"types": "./dist/ssr/index.d.ts"
|
|
57
97
|
}
|
|
58
98
|
},
|
|
59
99
|
"files": [
|
|
@@ -74,6 +114,7 @@
|
|
|
74
114
|
"build:umd": "vite build --config vite.umd.config.ts",
|
|
75
115
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
76
116
|
"test": "bun test",
|
|
117
|
+
"test:types": "tsc -p tsconfig.component-test.json --noEmit",
|
|
77
118
|
"test:watch": "bun test --watch",
|
|
78
119
|
"lint": "eslint . --fix",
|
|
79
120
|
"lint:types": "tsc --noEmit",
|
|
@@ -116,21 +157,21 @@
|
|
|
116
157
|
"node": ">=18.0.0"
|
|
117
158
|
},
|
|
118
159
|
"devDependencies": {
|
|
119
|
-
"@storybook/addon-docs": "^10.
|
|
120
|
-
"@storybook/web-components-vite": "^10.
|
|
121
|
-
"@typescript-eslint/eslint-plugin": "^8.57.
|
|
122
|
-
"@typescript-eslint/parser": "^8.57.
|
|
123
|
-
"bun-types": "^1.3.
|
|
124
|
-
"eslint": "^10.0
|
|
160
|
+
"@storybook/addon-docs": "^10.3.3",
|
|
161
|
+
"@storybook/web-components-vite": "^10.3.3",
|
|
162
|
+
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
163
|
+
"@typescript-eslint/parser": "^8.57.2",
|
|
164
|
+
"bun-types": "^1.3.11",
|
|
165
|
+
"eslint": "^10.1.0",
|
|
125
166
|
"eslint-config-prettier": "^10.1.8",
|
|
126
167
|
"globals": "^17.4.0",
|
|
127
|
-
"happy-dom": "^20.8.
|
|
168
|
+
"happy-dom": "^20.8.9",
|
|
128
169
|
"prettier": "^3.8.1",
|
|
129
170
|
"rimraf": "^6.1.3",
|
|
130
|
-
"storybook": "^10.
|
|
131
|
-
"typedoc": "^0.28.
|
|
171
|
+
"storybook": "^10.3.3",
|
|
172
|
+
"typedoc": "^0.28.18",
|
|
132
173
|
"typescript": "^5.9.3",
|
|
133
|
-
"vite": "^8.0.
|
|
174
|
+
"vite": "^8.0.3",
|
|
134
175
|
"vitepress": "^1.6.4"
|
|
135
176
|
}
|
|
136
177
|
}
|