@stryke/hooks 0.4.35 → 0.4.37
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/CHANGELOG.md +18 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/env/src/runtime-checks.cjs +1 -0
- package/dist/env/src/runtime-checks.mjs +2 -0
- package/dist/env/src/runtime-checks.mjs.map +1 -0
- package/dist/helpers/src/debounce.cjs +1 -0
- package/dist/helpers/src/debounce.d.cts +7 -0
- package/dist/helpers/src/debounce.d.cts.map +1 -0
- package/dist/helpers/src/debounce.d.mts +7 -0
- package/dist/helpers/src/debounce.d.mts.map +1 -0
- package/dist/helpers/src/debounce.mjs +2 -0
- package/dist/helpers/src/debounce.mjs.map +1 -0
- package/dist/helpers/src/throttle.cjs +1 -0
- package/dist/helpers/src/throttle.mjs +2 -0
- package/dist/helpers/src/throttle.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +17 -17
- package/dist/index.d.mts +17 -17
- package/dist/index.mjs +1 -1
- package/dist/type-checks/src/get-object-tag.cjs +1 -0
- package/dist/type-checks/src/get-object-tag.mjs +2 -0
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
- package/dist/type-checks/src/is-equal.cjs +1 -0
- package/dist/type-checks/src/is-equal.mjs +2 -0
- package/dist/type-checks/src/is-equal.mjs.map +1 -0
- package/dist/type-checks/src/is-function.cjs +1 -0
- package/dist/type-checks/src/is-function.mjs +2 -0
- package/dist/type-checks/src/is-function.mjs.map +1 -0
- package/dist/types/src/base.cjs +1 -0
- package/dist/types/src/base.d.cts +35 -0
- package/dist/types/src/base.d.cts.map +1 -0
- package/dist/types/src/base.d.mts +35 -0
- package/dist/types/src/base.d.mts.map +1 -0
- package/dist/types/src/base.mjs +2 -0
- package/dist/types/src/base.mjs.map +1 -0
- package/dist/{navigator-DUOlrD-4.d.mts → types/src/navigator.d.cts} +2 -2
- package/dist/types/src/navigator.d.cts.map +1 -0
- package/dist/{navigator-CY6InfsZ.d.cts → types/src/navigator.d.mts} +2 -2
- package/dist/types/src/navigator.d.mts.map +1 -0
- package/dist/use-battery.cjs +1 -1
- package/dist/use-battery.d.cts +11 -2
- package/dist/use-battery.d.cts.map +1 -0
- package/dist/use-battery.d.mts +11 -2
- package/dist/use-battery.d.mts.map +1 -0
- package/dist/use-battery.mjs +2 -1
- package/dist/use-battery.mjs.map +1 -0
- package/dist/use-callback-ref.cjs +1 -1
- package/dist/use-callback-ref.d.cts +9 -2
- package/dist/use-callback-ref.d.cts.map +1 -0
- package/dist/use-callback-ref.d.mts +9 -2
- package/dist/use-callback-ref.d.mts.map +1 -0
- package/dist/use-callback-ref.mjs +2 -1
- package/dist/use-callback-ref.mjs.map +1 -0
- package/dist/use-callback-stable.cjs +1 -1
- package/dist/use-callback-stable.d.cts +25 -2
- package/dist/use-callback-stable.d.cts.map +1 -0
- package/dist/use-callback-stable.d.mts +25 -2
- package/dist/use-callback-stable.d.mts.map +1 -0
- package/dist/use-callback-stable.mjs +2 -1
- package/dist/use-callback-stable.mjs.map +1 -0
- package/dist/use-click-away.cjs +1 -1
- package/dist/use-click-away.d.cts +14 -2
- package/dist/use-click-away.d.cts.map +1 -0
- package/dist/use-click-away.d.mts +14 -2
- package/dist/use-click-away.d.mts.map +1 -0
- package/dist/use-click-away.mjs +2 -1
- package/dist/use-click-away.mjs.map +1 -0
- package/dist/use-compose-refs.cjs +1 -1
- package/dist/use-compose-refs.d.cts +31 -2
- package/dist/use-compose-refs.d.cts.map +1 -0
- package/dist/use-compose-refs.d.mts +31 -2
- package/dist/use-compose-refs.d.mts.map +1 -0
- package/dist/use-compose-refs.mjs +2 -1
- package/dist/use-compose-refs.mjs.map +1 -0
- package/dist/use-copy-to-clipboard.cjs +1 -1
- package/dist/use-copy-to-clipboard.d.cts +10 -2
- package/dist/use-copy-to-clipboard.d.cts.map +1 -0
- package/dist/use-copy-to-clipboard.d.mts +10 -2
- package/dist/use-copy-to-clipboard.d.mts.map +1 -0
- package/dist/use-copy-to-clipboard.mjs +2 -1
- package/dist/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/use-debounce.cjs +1 -1
- package/dist/use-debounce.d.cts +14 -2
- package/dist/use-debounce.d.cts.map +1 -0
- package/dist/use-debounce.d.mts +14 -2
- package/dist/use-debounce.d.mts.map +1 -0
- package/dist/use-debounce.mjs +2 -1
- package/dist/use-debounce.mjs.map +1 -0
- package/dist/use-did-finish-ssr.cjs +1 -1
- package/dist/use-did-finish-ssr.d.cts +10 -2
- package/dist/use-did-finish-ssr.d.cts.map +1 -0
- package/dist/use-did-finish-ssr.d.mts +10 -2
- package/dist/use-did-finish-ssr.d.mts.map +1 -0
- package/dist/use-did-finish-ssr.mjs +2 -1
- package/dist/use-did-finish-ssr.mjs.map +1 -0
- package/dist/use-escape-keydown.cjs +1 -1
- package/dist/use-escape-keydown.d.cts +8 -2
- package/dist/use-escape-keydown.d.cts.map +1 -0
- package/dist/use-escape-keydown.d.mts +8 -2
- package/dist/use-escape-keydown.d.mts.map +1 -0
- package/dist/use-escape-keydown.mjs +2 -1
- package/dist/use-escape-keydown.mjs.map +1 -0
- package/dist/use-event.cjs +1 -1
- package/dist/use-event.d.cts +12 -2
- package/dist/use-event.d.cts.map +1 -0
- package/dist/use-event.d.mts +12 -2
- package/dist/use-event.d.mts.map +1 -0
- package/dist/use-event.mjs +2 -1
- package/dist/use-event.mjs.map +1 -0
- package/dist/use-hover.cjs +1 -1
- package/dist/use-hover.d.cts +10 -2
- package/dist/use-hover.d.cts.map +1 -0
- package/dist/use-hover.d.mts +10 -2
- package/dist/use-hover.d.mts.map +1 -0
- package/dist/use-hover.mjs +2 -1
- package/dist/use-hover.mjs.map +1 -0
- package/dist/use-idle.cjs +1 -1
- package/dist/use-idle.d.cts +11 -2
- package/dist/use-idle.d.cts.map +1 -0
- package/dist/use-idle.d.mts +11 -2
- package/dist/use-idle.d.mts.map +1 -0
- package/dist/use-idle.mjs +2 -1
- package/dist/use-idle.mjs.map +1 -0
- package/dist/use-isomorphic-layout-effect.cjs +1 -1
- package/dist/use-isomorphic-layout-effect.d.cts +13 -2
- package/dist/use-isomorphic-layout-effect.d.cts.map +1 -0
- package/dist/use-isomorphic-layout-effect.d.mts +13 -2
- package/dist/use-isomorphic-layout-effect.d.mts.map +1 -0
- package/dist/use-isomorphic-layout-effect.mjs +2 -1
- package/dist/use-isomorphic-layout-effect.mjs.map +1 -0
- package/dist/use-keyboard-visible.cjs +1 -1
- package/dist/use-keyboard-visible.d.cts +5 -2
- package/dist/use-keyboard-visible.d.cts.map +1 -0
- package/dist/use-keyboard-visible.d.mts +5 -2
- package/dist/use-keyboard-visible.d.mts.map +1 -0
- package/dist/use-keyboard-visible.mjs +2 -1
- package/dist/use-keyboard-visible.mjs.map +1 -0
- package/dist/use-memo-stable.cjs +1 -1
- package/dist/use-memo-stable.d.cts +19 -2
- package/dist/use-memo-stable.d.cts.map +1 -0
- package/dist/use-memo-stable.d.mts +19 -2
- package/dist/use-memo-stable.d.mts.map +1 -0
- package/dist/use-memo-stable.mjs +2 -1
- package/dist/use-memo-stable.mjs.map +1 -0
- package/dist/use-network-state.cjs +1 -1
- package/dist/use-network-state.d.cts +20 -2
- package/dist/use-network-state.d.cts.map +1 -0
- package/dist/use-network-state.d.mts +20 -2
- package/dist/use-network-state.d.mts.map +1 -0
- package/dist/use-network-state.mjs +2 -1
- package/dist/use-network-state.mjs.map +1 -0
- package/dist/use-previous.cjs +1 -1
- package/dist/use-previous.d.cts +5 -2
- package/dist/use-previous.d.cts.map +1 -0
- package/dist/use-previous.d.mts +5 -2
- package/dist/use-previous.d.mts.map +1 -0
- package/dist/use-previous.mjs +2 -1
- package/dist/use-previous.mjs.map +1 -0
- package/package.json +7 -7
- package/dist/is-function-BhD7GXOO.cjs +0 -1
- package/dist/is-function-md4Ym3I0.mjs +0 -2
- package/dist/is-function-md4Ym3I0.mjs.map +0 -1
- package/dist/navigator-CY6InfsZ.d.cts.map +0 -1
- package/dist/navigator-DUOlrD-4.d.mts.map +0 -1
- package/dist/use-battery-BkRIfbJz.d.mts +0 -11
- package/dist/use-battery-BkRIfbJz.d.mts.map +0 -1
- package/dist/use-battery-DZZDx003.cjs +0 -1
- package/dist/use-battery-DaA7I4_x.mjs +0 -2
- package/dist/use-battery-DaA7I4_x.mjs.map +0 -1
- package/dist/use-battery-DpuF7GMz.d.cts +0 -11
- package/dist/use-battery-DpuF7GMz.d.cts.map +0 -1
- package/dist/use-callback-ref-B-95d49K.d.mts +0 -9
- package/dist/use-callback-ref-B-95d49K.d.mts.map +0 -1
- package/dist/use-callback-ref-CloM-Kqk.cjs +0 -1
- package/dist/use-callback-ref-ctiFnQn4.d.cts +0 -9
- package/dist/use-callback-ref-ctiFnQn4.d.cts.map +0 -1
- package/dist/use-callback-ref-otlhGzUu.mjs +0 -2
- package/dist/use-callback-ref-otlhGzUu.mjs.map +0 -1
- package/dist/use-callback-stable-C3QZzhdC.mjs +0 -2
- package/dist/use-callback-stable-C3QZzhdC.mjs.map +0 -1
- package/dist/use-callback-stable-C5X8ySnU.d.mts +0 -55
- package/dist/use-callback-stable-C5X8ySnU.d.mts.map +0 -1
- package/dist/use-callback-stable-CvXmYtWT.cjs +0 -1
- package/dist/use-callback-stable-D_wCU4yv.d.cts +0 -55
- package/dist/use-callback-stable-D_wCU4yv.d.cts.map +0 -1
- package/dist/use-click-away-Bpl7sh5j.cjs +0 -1
- package/dist/use-click-away-D-DKaD9B.mjs +0 -2
- package/dist/use-click-away-D-DKaD9B.mjs.map +0 -1
- package/dist/use-click-away-DG8ULjSN.d.cts +0 -14
- package/dist/use-click-away-DG8ULjSN.d.cts.map +0 -1
- package/dist/use-click-away-kc61inYs.d.mts +0 -14
- package/dist/use-click-away-kc61inYs.d.mts.map +0 -1
- package/dist/use-compose-refs-BUwJN8zY.cjs +0 -1
- package/dist/use-compose-refs-BysZtFy1.mjs +0 -2
- package/dist/use-compose-refs-BysZtFy1.mjs.map +0 -1
- package/dist/use-compose-refs-D1nHM35F.d.cts +0 -31
- package/dist/use-compose-refs-D1nHM35F.d.cts.map +0 -1
- package/dist/use-compose-refs-Dy3epP6l.d.mts +0 -31
- package/dist/use-compose-refs-Dy3epP6l.d.mts.map +0 -1
- package/dist/use-copy-to-clipboard-Cls03hBs.mjs +0 -2
- package/dist/use-copy-to-clipboard-Cls03hBs.mjs.map +0 -1
- package/dist/use-copy-to-clipboard-D3QmuRQ2.d.mts +0 -10
- package/dist/use-copy-to-clipboard-D3QmuRQ2.d.mts.map +0 -1
- package/dist/use-copy-to-clipboard-DFTtZkv7.cjs +0 -1
- package/dist/use-copy-to-clipboard-DzccpceW.d.cts +0 -10
- package/dist/use-copy-to-clipboard-DzccpceW.d.cts.map +0 -1
- package/dist/use-debounce-B07BBb1-.d.mts +0 -17
- package/dist/use-debounce-B07BBb1-.d.mts.map +0 -1
- package/dist/use-debounce-Bh6vyN-1.d.cts +0 -17
- package/dist/use-debounce-Bh6vyN-1.d.cts.map +0 -1
- package/dist/use-debounce-Cto2Ny5z.mjs +0 -2
- package/dist/use-debounce-Cto2Ny5z.mjs.map +0 -1
- package/dist/use-debounce-DWeScEkQ.cjs +0 -1
- package/dist/use-did-finish-ssr-B6M_wlP4.mjs +0 -2
- package/dist/use-did-finish-ssr-B6M_wlP4.mjs.map +0 -1
- package/dist/use-did-finish-ssr-BbXffDj5.cjs +0 -1
- package/dist/use-did-finish-ssr-CBz5xeHc.d.mts +0 -10
- package/dist/use-did-finish-ssr-CBz5xeHc.d.mts.map +0 -1
- package/dist/use-did-finish-ssr-D3CpAwOz.d.cts +0 -10
- package/dist/use-did-finish-ssr-D3CpAwOz.d.cts.map +0 -1
- package/dist/use-escape-keydown-BsJYLp1N.d.cts +0 -8
- package/dist/use-escape-keydown-BsJYLp1N.d.cts.map +0 -1
- package/dist/use-escape-keydown-CFy25Wk6.mjs +0 -2
- package/dist/use-escape-keydown-CFy25Wk6.mjs.map +0 -1
- package/dist/use-escape-keydown-DgPvPpzz.d.mts +0 -8
- package/dist/use-escape-keydown-DgPvPpzz.d.mts.map +0 -1
- package/dist/use-escape-keydown-ITaT9SqI.cjs +0 -1
- package/dist/use-event-CBTGhPhg.mjs +0 -2
- package/dist/use-event-CBTGhPhg.mjs.map +0 -1
- package/dist/use-event-DG39UVbo.cjs +0 -1
- package/dist/use-event-DHFCg8sl.d.cts +0 -12
- package/dist/use-event-DHFCg8sl.d.cts.map +0 -1
- package/dist/use-event-DQyUWk4T.d.mts +0 -12
- package/dist/use-event-DQyUWk4T.d.mts.map +0 -1
- package/dist/use-hover-CPJ3UcMM.d.mts +0 -10
- package/dist/use-hover-CPJ3UcMM.d.mts.map +0 -1
- package/dist/use-hover-DCP1g7QG.mjs +0 -2
- package/dist/use-hover-DCP1g7QG.mjs.map +0 -1
- package/dist/use-hover-DeFTY9RX.d.cts +0 -10
- package/dist/use-hover-DeFTY9RX.d.cts.map +0 -1
- package/dist/use-hover-SNRrnUoI.cjs +0 -1
- package/dist/use-idle-Car_0ThE.d.cts +0 -11
- package/dist/use-idle-Car_0ThE.d.cts.map +0 -1
- package/dist/use-idle-CrCoMyLz.cjs +0 -1
- package/dist/use-idle-DrgoS1jh.mjs +0 -2
- package/dist/use-idle-DrgoS1jh.mjs.map +0 -1
- package/dist/use-idle-DwhHMDDp.d.mts +0 -11
- package/dist/use-idle-DwhHMDDp.d.mts.map +0 -1
- package/dist/use-isomorphic-layout-effect-Br2hUBEM.cjs +0 -1
- package/dist/use-isomorphic-layout-effect-CwRlvm9E.d.cts +0 -13
- package/dist/use-isomorphic-layout-effect-CwRlvm9E.d.cts.map +0 -1
- package/dist/use-isomorphic-layout-effect-D7uazny2.mjs +0 -2
- package/dist/use-isomorphic-layout-effect-D7uazny2.mjs.map +0 -1
- package/dist/use-isomorphic-layout-effect-IWX2e-IS.d.mts +0 -13
- package/dist/use-isomorphic-layout-effect-IWX2e-IS.d.mts.map +0 -1
- package/dist/use-keyboard-visible-83MQ2ogF.mjs +0 -2
- package/dist/use-keyboard-visible-83MQ2ogF.mjs.map +0 -1
- package/dist/use-keyboard-visible-BHYBoMGb.cjs +0 -1
- package/dist/use-keyboard-visible-BPIMSGQ1.d.cts +0 -5
- package/dist/use-keyboard-visible-BPIMSGQ1.d.cts.map +0 -1
- package/dist/use-keyboard-visible-iH9veUTt.d.mts +0 -5
- package/dist/use-keyboard-visible-iH9veUTt.d.mts.map +0 -1
- package/dist/use-memo-stable-Aqx3eZTS.d.mts +0 -19
- package/dist/use-memo-stable-Aqx3eZTS.d.mts.map +0 -1
- package/dist/use-memo-stable-DKI3Fj07.mjs +0 -2
- package/dist/use-memo-stable-DKI3Fj07.mjs.map +0 -1
- package/dist/use-memo-stable-DKW_L41q.cjs +0 -1
- package/dist/use-memo-stable-i9UN2iWi.d.cts +0 -19
- package/dist/use-memo-stable-i9UN2iWi.d.cts.map +0 -1
- package/dist/use-network-state-Bce55hBv.cjs +0 -1
- package/dist/use-network-state-CtGu_gfo.mjs +0 -2
- package/dist/use-network-state-CtGu_gfo.mjs.map +0 -1
- package/dist/use-network-state-DPhNT5_N.d.mts +0 -20
- package/dist/use-network-state-DPhNT5_N.d.mts.map +0 -1
- package/dist/use-network-state-DQegmILl.d.cts +0 -20
- package/dist/use-network-state-DQegmILl.d.cts.map +0 -1
- package/dist/use-previous-BNZSuZUn.cjs +0 -1
- package/dist/use-previous-BvOs-yn-.d.cts +0 -5
- package/dist/use-previous-BvOs-yn-.d.cts.map +0 -1
- package/dist/use-previous-ChmuSO8b.d.mts +0 -5
- package/dist/use-previous-ChmuSO8b.d.mts.map +0 -1
- package/dist/use-previous-vtWmTmEN.mjs +0 -2
- package/dist/use-previous-vtWmTmEN.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - Hooks
|
|
4
4
|
|
|
5
|
+
## [0.4.36](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.36) (12/17/2025)
|
|
6
|
+
|
|
7
|
+
### Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated **type-checks** to **v0.5.10**
|
|
10
|
+
- Updated **helpers** to **v0.9.27**
|
|
11
|
+
- Updated **types** to **v0.10.24**
|
|
12
|
+
- Updated **env** to **v0.20.38**
|
|
13
|
+
|
|
14
|
+
## [0.4.35](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.35) (12/08/2025)
|
|
15
|
+
|
|
16
|
+
### Updated Dependencies
|
|
17
|
+
|
|
18
|
+
- Updated **type-checks** to **v0.5.9**
|
|
19
|
+
- Updated **helpers** to **v0.9.26**
|
|
20
|
+
- Updated **types** to **v0.10.23**
|
|
21
|
+
- Updated **env** to **v0.20.37**
|
|
22
|
+
|
|
5
23
|
## [0.4.34](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.34) (12/08/2025)
|
|
6
24
|
|
|
7
25
|
### Updated Dependencies
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=process?.release?.name===`node`,t=!!Bun||!!process?.versions?.bun,n=!!Deno,r=!!fastly,i=!!Netlify,a=!!EdgeRuntime,o=navigator?.userAgent===`Cloudflare-Workers`,s=e||t||n||r||i||a||o,c=[[i,`netlify`],[a,`edge-light`],[o,`workerd`],[r,`fastly`],[n,`deno`],[t,`bun`],[e,`node`]];function l(){let e=c.find(e=>e[0]);if(e)return{name:e[1]}}const u=l(),d=u?.name||``;exports.isRuntimeServer=s;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=process?.release?.name===`node`,t=!!Bun||!!process?.versions?.bun,n=!!Deno,r=!!fastly,i=!!Netlify,a=!!EdgeRuntime,o=navigator?.userAgent===`Cloudflare-Workers`,s=e||t||n||r||i||a||o,c=[[i,`netlify`],[a,`edge-light`],[o,`workerd`],[r,`fastly`],[n,`deno`],[t,`bun`],[e,`node`]];function l(){let e=c.find(e=>e[0]);if(e)return{name:e[1]}}l()?.name;export{s as isRuntimeServer};
|
|
2
|
+
//# sourceMappingURL=runtime-checks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-checks.mjs","names":["runtimeChecks: [boolean, RuntimeName][]","runtime: RuntimeName"],"sources":["../../../../env/src/runtime-checks.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n// https://runtime-keys.proposal.wintercg.org/\nexport type RuntimeName =\n | \"workerd\"\n | \"deno\"\n | \"netlify\"\n | \"node\"\n | \"bun\"\n | \"edge-light\"\n | \"fastly\"\n | \"\";\n\nexport interface RuntimeInfo {\n name: RuntimeName;\n}\n\n/**\n * Indicates if running in Node.js or a Node.js compatible runtime.\n *\n * **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.\n *\n * Use `runtime === \"node\"` if you need strict check for Node.js runtime.\n */\nexport const isNode = process?.release?.name === \"node\";\n\n/**\n * Indicates if running in Bun runtime.\n */\nexport const isBun = Boolean(Bun) || Boolean(process?.versions?.bun);\n\n/**\n * Indicates if running in Deno runtime.\n */\nexport const isDeno = Boolean(Deno);\n\n/**\n * Indicates if running in Fastly runtime.\n */\nexport const isFastly = Boolean(fastly);\n\n/**\n * Indicates if running in Netlify runtime.\n */\nexport const isNetlify = Boolean(Netlify);\n\n/**\n *\n * Indicates if running in EdgeLight (Vercel Edge) runtime.\n */\nexport const isEdgeLight = Boolean(EdgeRuntime);\n// https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent\n\n/**\n * Indicates if running in Cloudflare Workers runtime.\n */\nexport const isWorkerd = navigator?.userAgent === \"Cloudflare-Workers\";\n\n/**\n * Indicates if the code is running on the server-side\n */\nexport const isRuntimeServer =\n isNode ||\n isBun ||\n isDeno ||\n isFastly ||\n isNetlify ||\n isEdgeLight ||\n isWorkerd;\n\n/**\n * Indicates if the code is running in the browser (and not on the server).\n */\nexport const isRuntimeClient = !isRuntimeServer;\n\nconst runtimeChecks: [boolean, RuntimeName][] = [\n [isNetlify, \"netlify\"],\n [isEdgeLight, \"edge-light\"],\n [isWorkerd, \"workerd\"],\n [isFastly, \"fastly\"],\n [isDeno, \"deno\"],\n [isBun, \"bun\"],\n [isNode, \"node\"]\n];\n\nfunction detectRuntime(): RuntimeInfo | undefined {\n const detectedRuntime = runtimeChecks.find(check => check[0]);\n\n if (detectedRuntime) {\n const name = detectedRuntime[1];\n\n return { name };\n }\n\n return undefined;\n}\n\nexport const runtimeInfo = detectRuntime();\n\nexport const runtime: RuntimeName = runtimeInfo?.name || \"\";\n"],"mappings":"AAwCA,MAAa,EAAS,SAAS,SAAS,OAAS,OAKpC,EAAQ,EAAQ,KAAQ,EAAQ,SAAS,UAAU,IAKnD,EAAS,EAAQ,KAKjB,EAAW,EAAQ,OAKnB,EAAY,EAAQ,QAMpB,EAAc,EAAQ,YAMtB,EAAY,WAAW,YAAc,qBAKrC,EACX,GACA,GACA,GACA,GACA,GACA,GACA,EAOIA,EAA0C,CAC9C,CAAC,EAAW,UAAU,CACtB,CAAC,EAAa,aAAa,CAC3B,CAAC,EAAW,UAAU,CACtB,CAAC,EAAU,SAAS,CACpB,CAAC,EAAQ,OAAO,CAChB,CAAC,EAAO,MAAM,CACd,CAAC,EAAQ,OAAO,CACjB,CAED,SAAS,GAAyC,CAChD,IAAM,EAAkB,EAAc,KAAK,GAAS,EAAM,GAAG,CAE7D,GAAI,EAGF,MAAO,CAAE,KAFI,EAAgB,GAEd,CAMQ,GAAe,EAEO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,{signal:n}={}){let r=null,i=((...i)=>{r!==null&&clearTimeout(r),!n?.aborted&&(r=setTimeout(()=>{e(...i),r=null},t))});return i.cancel=()=>{r!==null&&(clearTimeout(r),r=null)},n?.addEventListener(`abort`,()=>{i.cancel()},{once:!0}),i}exports.debounce=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.cts","names":[],"sources":["../../../../helpers/src/debounce.ts"],"sourcesContent":[],"mappings":";UAiBiB,eAAA;EAAA,MAAA,CAAA,EACN,WADqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.mts","names":[],"sources":["../../../../helpers/src/debounce.ts"],"sourcesContent":[],"mappings":";UAiBiB,eAAA;EAAA,MAAA,CAAA,EACN,WADqB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t,{signal:n}={}){let r=null,i=((...i)=>{r!==null&&clearTimeout(r),!n?.aborted&&(r=setTimeout(()=>{e(...i),r=null},t))});return i.cancel=()=>{r!==null&&(clearTimeout(r),r=null)},n?.addEventListener(`abort`,()=>{i.cancel()},{once:!0}),i}export{e as debounce};
|
|
2
|
+
//# sourceMappingURL=debounce.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.mjs","names":["timeoutId: ReturnType<typeof setTimeout> | null"],"sources":["../../../../helpers/src/debounce.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\nexport interface DebounceOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @example\n * ```typescript\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n * ```\n *\n * @param func - The function to debounce.\n * @param debounceMs - The number of milliseconds to delay.\n * @param options - The options object.\n * @returns A new debounced function with a `cancel` method.\n */\nexport function debounce<F extends (...args: any[]) => void>(\n func: F,\n debounceMs: number,\n { signal }: DebounceOptions = {}\n): F & { cancel: () => void } {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const debounced = ((...args: Parameters<F>) => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (signal?.aborted) {\n return;\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, debounceMs);\n }) as F & { cancel: () => void };\n\n const onAbort = () => {\n debounced.cancel();\n };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n return debounced;\n}\n"],"mappings":"AAwDA,SAAgB,EACd,EACA,EACA,CAAE,UAA4B,EAAE,CACJ,CAC5B,IAAIA,EAAkD,KAEhD,IAAc,GAAG,IAAwB,CACzC,IAAc,MAChB,aAAa,EAAU,CAGrB,IAAQ,UAIZ,EAAY,eAAiB,CAC3B,EAAK,GAAG,EAAK,CACb,EAAY,MACX,EAAW,IAgBhB,MATA,GAAU,WAAe,CACnB,IAAc,OAChB,aAAa,EAAU,CACvB,EAAY,OAIhB,GAAQ,iBAAiB,YAXH,CACpB,EAAU,QAAQ,EAUuB,CAAE,KAAM,GAAM,CAAC,CAEnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t){let n;return((...r)=>{let i=Date.now();(n==null||i-n>=t)&&(n=i,e(...r))})}exports.throttle=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.mjs","names":["lastCallTime: number | null"],"sources":["../../../../helpers/src/throttle.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://stormsoftware.com/projects/stryke/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/stryke/license\n\n ------------------------------------------------------------------- */\n\n/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @example\n * ```typescript\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n * ```\n *\n * @param func - The function to throttle.\n * @param throttleMs - The number of milliseconds to throttle executions to.\n * @returns A new throttled function that accepts the same parameters as the original function.\n */\nexport function throttle<F extends (...args: any[]) => void>(\n func: F,\n throttleMs: number\n): F {\n let lastCallTime: number | null;\n\n const throttledFunction = ((...args: Parameters<F>) => {\n const now = Date.now();\n\n if (lastCallTime == null || now - lastCallTime >= throttleMs) {\n lastCallTime = now;\n func(...args);\n }\n }) as F;\n\n return throttledFunction;\n}\n"],"mappings":"AA4CA,SAAgB,EACd,EACA,EACG,CACH,IAAIA,EAWJ,QAT4B,GAAG,IAAwB,CACrD,IAAM,EAAM,KAAK,KAAK,EAElB,GAAgB,MAAQ,EAAM,GAAgB,KAChD,EAAe,EACf,EAAK,GAAG,EAAK"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./use-battery
|
|
1
|
+
const e=require(`./use-battery.cjs`),t=require(`./use-callback-ref.cjs`),n=require(`./use-memo-stable.cjs`),r=require(`./use-callback-stable.cjs`),i=require(`./use-click-away.cjs`),a=require(`./use-compose-refs.cjs`),o=require(`./use-copy-to-clipboard.cjs`),s=require(`./use-debounce.cjs`),c=require(`./use-did-finish-ssr.cjs`),l=require(`./use-escape-keydown.cjs`),u=require(`./use-isomorphic-layout-effect.cjs`),d=require(`./use-event.cjs`),f=require(`./use-hover.cjs`),p=require(`./use-idle.cjs`),m=require(`./use-keyboard-visible.cjs`),h=require(`./use-network-state.cjs`),g=require(`./use-previous.cjs`);exports.composeRefs=a.composeRefs,exports.setRef=a.setRef,exports.useBattery=e.useBattery,exports.useCallbackRef=t.useCallbackRef,exports.useCallbackStable=r.useCallbackStable,exports.useClickAway=i.useClickAway,exports.useClientValue=c.useClientValue,exports.useComposedRefs=a.useComposedRefs,exports.useCopyToClipboard=o.useCopyToClipboard,exports.useDebounce=s.useDebounce,exports.useDebounceValue=s.useDebounceValue,exports.useDidFinishSSR=c.useDidFinishSSR,exports.useDidFinishSSRSync=c.useDidFinishSSRSync,exports.useEscapeKeydown=l.useEscapeKeydown,exports.useEvent=d.useEvent,exports.useHover=f.useHover,exports.useIdle=p.useIdle,exports.useIsomorphicLayoutEffect=u.useIsomorphicLayoutEffect,exports.useKeyboardVisible=m.useKeyboardVisible,exports.useMemoStable=n.useMemoStable,exports.useNetworkState=h.useNetworkState,exports.useNetworkStateSubscribe=h.useNetworkStateSubscribe,exports.usePrevious=g.usePrevious;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
1
|
+
import { useBattery } from "./use-battery.cjs";
|
|
2
|
+
import { useCallbackRef } from "./use-callback-ref.cjs";
|
|
3
|
+
import { useCallbackStable } from "./use-callback-stable.cjs";
|
|
4
|
+
import { useClickAway } from "./use-click-away.cjs";
|
|
5
|
+
import { composeRefs, setRef, useComposedRefs } from "./use-compose-refs.cjs";
|
|
6
|
+
import { useCopyToClipboard } from "./use-copy-to-clipboard.cjs";
|
|
7
|
+
import { useDebounce, useDebounceValue } from "./use-debounce.cjs";
|
|
8
|
+
import { useClientValue, useDidFinishSSR, useDidFinishSSRSync } from "./use-did-finish-ssr.cjs";
|
|
9
|
+
import { useEscapeKeydown } from "./use-escape-keydown.cjs";
|
|
10
|
+
import { useEvent } from "./use-event.cjs";
|
|
11
|
+
import { useHover } from "./use-hover.cjs";
|
|
12
|
+
import { useIdle } from "./use-idle.cjs";
|
|
13
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.cjs";
|
|
14
|
+
import { useKeyboardVisible } from "./use-keyboard-visible.cjs";
|
|
15
|
+
import { useMemoStable } from "./use-memo-stable.cjs";
|
|
16
|
+
import { useNetworkState, useNetworkStateSubscribe } from "./use-network-state.cjs";
|
|
17
|
+
import { usePrevious } from "./use-previous.cjs";
|
|
18
18
|
export { composeRefs, setRef, useBattery, useCallbackRef, useCallbackStable, useClickAway, useClientValue, useComposedRefs, useCopyToClipboard, useDebounce, useDebounceValue, useDidFinishSSR, useDidFinishSSRSync, useEscapeKeydown, useEvent, useHover, useIdle, useIsomorphicLayoutEffect, useKeyboardVisible, useMemoStable, useNetworkState, useNetworkStateSubscribe, usePrevious };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
1
|
+
import { useBattery } from "./use-battery.mjs";
|
|
2
|
+
import { useCallbackRef } from "./use-callback-ref.mjs";
|
|
3
|
+
import { useCallbackStable } from "./use-callback-stable.mjs";
|
|
4
|
+
import { useClickAway } from "./use-click-away.mjs";
|
|
5
|
+
import { composeRefs, setRef, useComposedRefs } from "./use-compose-refs.mjs";
|
|
6
|
+
import { useCopyToClipboard } from "./use-copy-to-clipboard.mjs";
|
|
7
|
+
import { useDebounce, useDebounceValue } from "./use-debounce.mjs";
|
|
8
|
+
import { useClientValue, useDidFinishSSR, useDidFinishSSRSync } from "./use-did-finish-ssr.mjs";
|
|
9
|
+
import { useEscapeKeydown } from "./use-escape-keydown.mjs";
|
|
10
|
+
import { useEvent } from "./use-event.mjs";
|
|
11
|
+
import { useHover } from "./use-hover.mjs";
|
|
12
|
+
import { useIdle } from "./use-idle.mjs";
|
|
13
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.mjs";
|
|
14
|
+
import { useKeyboardVisible } from "./use-keyboard-visible.mjs";
|
|
15
|
+
import { useMemoStable } from "./use-memo-stable.mjs";
|
|
16
|
+
import { useNetworkState, useNetworkStateSubscribe } from "./use-network-state.mjs";
|
|
17
|
+
import { usePrevious } from "./use-previous.mjs";
|
|
18
18
|
export { composeRefs, setRef, useBattery, useCallbackRef, useCallbackStable, useClickAway, useClientValue, useComposedRefs, useCopyToClipboard, useDebounce, useDebounceValue, useDidFinishSSR, useDidFinishSSRSync, useEscapeKeydown, useEvent, useHover, useIdle, useIsomorphicLayoutEffect, useKeyboardVisible, useMemoStable, useNetworkState, useNetworkStateSubscribe, usePrevious };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useBattery as e}from"./use-battery.mjs";import{useCallbackRef as t}from"./use-callback-ref.mjs";import{useMemoStable as n}from"./use-memo-stable.mjs";import{useCallbackStable as r}from"./use-callback-stable.mjs";import{useClickAway as i}from"./use-click-away.mjs";import{composeRefs as a,setRef as o,useComposedRefs as s}from"./use-compose-refs.mjs";import{useCopyToClipboard as c}from"./use-copy-to-clipboard.mjs";import{useDebounce as l,useDebounceValue as u}from"./use-debounce.mjs";import{useClientValue as d,useDidFinishSSR as f,useDidFinishSSRSync as p}from"./use-did-finish-ssr.mjs";import{useEscapeKeydown as m}from"./use-escape-keydown.mjs";import{useIsomorphicLayoutEffect as h}from"./use-isomorphic-layout-effect.mjs";import{useEvent as g}from"./use-event.mjs";import{useHover as _}from"./use-hover.mjs";import{useIdle as v}from"./use-idle.mjs";import{useKeyboardVisible as y}from"./use-keyboard-visible.mjs";import{useNetworkState as b,useNetworkStateSubscribe as x}from"./use-network-state.mjs";import{usePrevious as S}from"./use-previous.mjs";export{a as composeRefs,o as setRef,e as useBattery,t as useCallbackRef,r as useCallbackStable,i as useClickAway,d as useClientValue,s as useComposedRefs,c as useCopyToClipboard,l as useDebounce,u as useDebounceValue,f as useDidFinishSSR,p as useDidFinishSSRSync,m as useEscapeKeydown,g as useEvent,_ as useHover,v as useIdle,h as useIsomorphicLayoutEffect,y as useKeyboardVisible,n as useMemoStable,b as useNetworkState,x as useNetworkStateSubscribe,S as usePrevious};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);exports.getObjectTag=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-object-tag.mjs","names":[],"sources":["../../../../type-checks/src/get-object-tag.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n"],"mappings":"AAwBA,MAAa,EAAgB,GACvB,GAAS,KACJ,IAAU,IAAA,GAAY,qBAAuB,gBAE/C,OAAO,UAAU,SAAS,KAAK,EAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(t,n)=>{if(Object.is(t,n))return!0;if(t instanceof Date&&n instanceof Date)return t.getTime()===n.getTime();if(t instanceof RegExp&&n instanceof RegExp)return t.toString()===n.toString();if(typeof t!=`object`||!t||typeof n!=`object`||!n)return!1;let r=Reflect.ownKeys(t),i=Reflect.ownKeys(n);if(r.length!==i.length)return!1;for(let i of r)if(!Reflect.has(n,i)||!e(t[i],n[i]))return!1;return!0};exports.isEqual=e;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(t,n)=>{if(Object.is(t,n))return!0;if(t instanceof Date&&n instanceof Date)return t.getTime()===n.getTime();if(t instanceof RegExp&&n instanceof RegExp)return t.toString()===n.toString();if(typeof t!=`object`||!t||typeof n!=`object`||!n)return!1;let r=Reflect.ownKeys(t),i=Reflect.ownKeys(n);if(r.length!==i.length)return!1;for(let i of r)if(!Reflect.has(n,i)||!e(t[i],n[i]))return!1;return!0};export{e as isEqual};
|
|
2
|
+
//# sourceMappingURL=is-equal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-equal.mjs","names":[],"sources":["../../../../type-checks/src/is-equal.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isEqual = <TType>(x: TType, y: TType): boolean => {\n if (Object.is(x, y)) return true;\n if (x instanceof Date && y instanceof Date) {\n return x.getTime() === y.getTime();\n }\n if (x instanceof RegExp && y instanceof RegExp) {\n return x.toString() === y.toString();\n }\n if (\n typeof x !== \"object\" ||\n x === null ||\n typeof y !== \"object\" ||\n y === null\n ) {\n return false;\n }\n const keysX = Reflect.ownKeys(x as unknown as object) as (keyof typeof x)[];\n const keysY = Reflect.ownKeys(y as unknown as object);\n if (keysX.length !== keysY.length) return false;\n for (const element_ of keysX) {\n if (!Reflect.has(y as unknown as object, element_)) return false;\n if (!isEqual(x[element_], y[element_])) return false;\n }\n return true;\n};\n"],"mappings":"AAkBA,MAAa,GAAkB,EAAU,IAAsB,CAC7D,GAAI,OAAO,GAAG,EAAG,EAAE,CAAE,MAAO,GAC5B,GAAI,aAAa,MAAQ,aAAa,KACpC,OAAO,EAAE,SAAS,GAAK,EAAE,SAAS,CAEpC,GAAI,aAAa,QAAU,aAAa,OACtC,OAAO,EAAE,UAAU,GAAK,EAAE,UAAU,CAEtC,GACE,OAAO,GAAM,WACb,GACA,OAAO,GAAM,WACb,EAEA,MAAO,GAET,IAAM,EAAQ,QAAQ,QAAQ,EAAuB,CAC/C,EAAQ,QAAQ,QAAQ,EAAuB,CACrD,GAAI,EAAM,SAAW,EAAM,OAAQ,MAAO,GAC1C,IAAK,IAAM,KAAY,EAErB,GADI,CAAC,QAAQ,IAAI,EAAwB,EAAS,EAC9C,CAAC,EAAQ,EAAE,GAAW,EAAE,GAAU,CAAE,MAAO,GAEjD,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./get-object-tag.cjs`);function t(t){return e.getObjectTag(t)===`[object Function]`}function n(t){return e.getObjectTag(t)===`[object AsyncFunction]`}const r=e=>{try{return e instanceof Function||typeof e==`function`||!!(e?.constructor&&e?.call&&e?.apply)||t(e)||n(e)}catch{return!1}};exports.isFunction=r;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getObjectTag as e}from"./get-object-tag.mjs";function t(t){return e(t)===`[object Function]`}function n(t){return e(t)===`[object AsyncFunction]`}const r=e=>{try{return e instanceof Function||typeof e==`function`||!!(e?.constructor&&e?.call&&e?.apply)||t(e)||n(e)}catch{return!1}};export{r as isFunction};
|
|
2
|
+
//# sourceMappingURL=is-function.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-function.mjs","names":[],"sources":["../../../../type-checks/src/is-function.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\nexport function isSyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object Function]\";\n}\n\nexport function isAsyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object AsyncFunction]\";\n}\n\n/**\n * Check if the provided value's type is `Function`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Function`\n */\nexport const isFunction = (value: unknown): value is AnyFunction => {\n try {\n return (\n value instanceof Function ||\n typeof value === \"function\" ||\n Boolean(\n value?.constructor && (value as any)?.call && (value as any)?.apply\n ) ||\n isSyncFunction(value) ||\n isAsyncFunction(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":"oDAqBA,SAAgB,EAAe,EAAmC,CAChE,OAAO,EAAa,EAAM,GAAK,oBAGjC,SAAgB,EAAgB,EAAmC,CACjE,OAAO,EAAa,EAAM,GAAK,yBASjC,MAAa,EAAc,GAAyC,CAClE,GAAI,CACF,OACE,aAAiB,UACjB,OAAO,GAAU,YACjB,GACE,GAAO,aAAgB,GAAe,MAAS,GAAe,QAEhE,EAAe,EAAM,EACrB,EAAgB,EAAM,MAElB,CACN,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=``;exports.EMPTY_STRING=``;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region ../types/src/base.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A [[List]]
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* type list0 = [1, 2, 3]
|
|
9
|
+
* type list1 = number[]
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param A - its type
|
|
13
|
+
* @returns [[List]]
|
|
14
|
+
*/
|
|
15
|
+
type List<A = any> = ReadonlyArray<A>;
|
|
16
|
+
/**
|
|
17
|
+
* Alias to create a [[Function]]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { FunctionLike } from '@stryke/types'
|
|
22
|
+
*
|
|
23
|
+
* type test0 = FunctionLike<[string, number], boolean>
|
|
24
|
+
* /// (args_0: string, args_1: number) => boolean
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param P - parameters
|
|
28
|
+
* @param R - return type
|
|
29
|
+
* @returns [[Function]]
|
|
30
|
+
*/
|
|
31
|
+
type FunctionLike<P extends List = any, R$1 = any> = (...args: P) => R$1;
|
|
32
|
+
type AnyFunction = FunctionLike<any, any>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { AnyFunction };
|
|
35
|
+
//# sourceMappingURL=base.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.cts","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAmEY,gBAAgB,cAAc;;;;;;;;;;;;;;;;KAiB9B,uBAAuB,mCAAiC,MAAM;KAE9D,WAAA,GAAc"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region ../types/src/base.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A [[List]]
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* type list0 = [1, 2, 3]
|
|
9
|
+
* type list1 = number[]
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param A - its type
|
|
13
|
+
* @returns [[List]]
|
|
14
|
+
*/
|
|
15
|
+
type List<A = any> = ReadonlyArray<A>;
|
|
16
|
+
/**
|
|
17
|
+
* Alias to create a [[Function]]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { FunctionLike } from '@stryke/types'
|
|
22
|
+
*
|
|
23
|
+
* type test0 = FunctionLike<[string, number], boolean>
|
|
24
|
+
* /// (args_0: string, args_1: number) => boolean
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param P - parameters
|
|
28
|
+
* @param R - return type
|
|
29
|
+
* @returns [[Function]]
|
|
30
|
+
*/
|
|
31
|
+
type FunctionLike<P extends List = any, R$1 = any> = (...args: P) => R$1;
|
|
32
|
+
type AnyFunction = FunctionLike<any, any>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { AnyFunction };
|
|
35
|
+
//# sourceMappingURL=base.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.mts","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAmEY,gBAAgB,cAAc;;;;;;;;;;;;;;;;KAiB9B,uBAAuB,mCAAiC,MAAM;KAE9D,WAAA,GAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.mjs","names":[],"sources":["../../../../types/src/base.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { TypedArray } from \"./array\";\n\nexport type SerializablePrimitive =\n | null\n | undefined\n | string\n | number\n | boolean\n | bigint;\nexport type Primitive = SerializablePrimitive | symbol;\n\n/**\n * Matches any primitive, `void`, `Date`, or `RegExp` value.\n */\nexport type BuiltIns = Primitive | void | Date | RegExp;\n\n/**\n * Matches any non-primitive object\n */\n// eslint-disable-next-line ts/no-unsafe-function-type\nexport type AtomicObject = Function | Promise<any> | Date | RegExp;\n\n/** Determines if the passed value is of a specific type */\nexport type TypeTester = (value: any) => boolean;\n\n/**\n * The interface for a type mapping (key =\\> function) to use for {@link getType}.\n * export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.\n * The map should be ordered by testing preference, with more specific tests first.\n * If a test returns true, it is selected, and the key is returned as the type.\n */\nexport type TypeMap = Record<string, TypeTester>;\n\ndeclare const emptyObjectSymbol: unique symbol;\n\nexport type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\n/**\n * A [[List]]\n *\n * @example\n * ```ts\n * type list0 = [1, 2, 3]\n * type list1 = number[]\n * ```\n *\n * @param A - its type\n * @returns [[List]]\n */\nexport type List<A = any> = ReadonlyArray<A>;\n\n/**\n * Alias to create a [[Function]]\n *\n * @example\n * ```ts\n * import { FunctionLike } from '@stryke/types'\n *\n * type test0 = FunctionLike<[string, number], boolean>\n * /// (args_0: string, args_1: number) => boolean\n * ```\n *\n * @param P - parameters\n * @param R - return type\n * @returns [[Function]]\n */\nexport type FunctionLike<P extends List = any, R = any> = (...args: P) => R;\n\nexport type AnyFunction = FunctionLike<any, any>;\nexport type Nullish = undefined | null;\nexport type Nullishable<T> = T | Nullish;\nexport type NonNullishObject = object; // not null/undefined which are Object\nexport type NativeClass = abstract new (...args: any) => any;\nexport type AnyNumber = number | number;\nexport type AnyString = string | string;\nexport type AnyBoolean = boolean | boolean;\nexport type AnyArray = any[];\nexport type PlainObject = Record<any, object>; // https://stackoverflow.com/a/75052315/130638\nexport type AnyMap = Map<any, any>;\nexport type AnyWeakMap = WeakMap<WeakKey, any>;\nexport type EmptyArray = [];\nexport interface EmptyObject {\n [emptyObjectSymbol]?: never;\n}\n\nexport type Any =\n | boolean\n | number\n | bigint\n | string\n | null\n | undefined\n | void\n | symbol\n | object\n | PlainObject\n | AnyArray\n | AnyMap\n | AnyWeakMap;\n\n/**\n * The valid types of the index for an `Indexable` type object\n */\nexport type IndexType = string | number | symbol;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type TypedIndexable<T> = Record<IndexType, T>;\n\n/**\n * The declaration of a ***dictionary-type*** object\n *\n * @see {@link TypedIndexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type Indexable = TypedIndexable<any>;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link TypedIndexable}\n */\nexport type Dictionary<T> = Record<string, T>;\n\nexport const EMPTY_STRING = \"\";\nexport const NEWLINE_STRING = \"\\r\\n\";\nexport const EMPTY_OBJECT = {};\n\nexport type AnyCase<T extends IndexType> = string extends T\n ? string\n : T extends `${infer F1}${infer F2}${infer R}`\n ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`\n : T extends `${infer F}${infer R}`\n ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`\n : typeof EMPTY_STRING;\n\nexport type Newable<T> = new (..._args: never[]) => T;\n\nexport interface Abstract<T> {\n prototype: T;\n}\n\nexport interface Clonable<T> {\n clone: () => T;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type ReducerFunction<TState, TAction> = (\n state: TState,\n action: TAction\n) => TState;\n\n// NOTE: for the file size optimization\nexport const TYPE_ARGUMENTS = \"Arguments\";\nexport const TYPE_ARRAY = \"Array\";\nexport const TYPE_OBJECT = \"Object\";\nexport const TYPE_MAP = \"Map\";\nexport const TYPE_SET = \"Set\";\n\nexport type Collection =\n | IArguments\n | unknown[]\n | Map<unknown, unknown>\n | Record<string | number | symbol, unknown>\n | Set<unknown>;\n\nexport type NonUndefined<T> = T extends undefined ? never : T;\n\nexport type BrowserNativeObject = Date | File;\n\nexport type DeepPartial<T> = T extends BrowserNativeObject | NestedValue\n ? T\n : {\n [K in keyof T]?: DeepPartial<T[K]>;\n };\n\nexport type Rollback = Record<\n string,\n (initialValue: any, currentValue: any) => any\n>;\n\n/**\n * Extract all required keys from the given type.\n *\n * @remarks\n * This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...\n */\nexport type RequiredKeysOf<BaseType extends object> = Exclude<\n {\n [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>\n ? Key\n : never;\n }[keyof BaseType],\n undefined\n>;\n\n/**\n * Returns a boolean for whether the two given types are equal.\n *\n * @remarks\n * Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.\n *\n * @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650\n * @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796\n */\nexport type IsEqual<A, B> =\n (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2\n ? true\n : false;\n\nexport type Filter<KeyType, ExcludeType> =\n IsEqual<KeyType, ExcludeType> extends true\n ? never\n : KeyType extends ExcludeType\n ? never\n : KeyType;\n\ninterface ExceptOptions {\n /**\n Disallow assigning non-specified properties.\n\n Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.\n\n @defaultValue false\n */\n requireExactProps?: boolean;\n}\n\n/**\n * Create a type from an object type without certain keys.\n *\n * @remarks\n * We recommend setting the `requireExactProps` option to `true`.\n *\n * This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.\n *\n * This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).\n */\nexport type Except<\n ObjectType,\n KeysType extends keyof ObjectType,\n Options extends ExceptOptions = { requireExactProps: false }\n> = {\n [KeyType in keyof ObjectType as Filter<\n KeyType,\n KeysType\n >]: ObjectType[KeyType];\n} & (Options[\"requireExactProps\"] extends true\n ? Partial<Record<KeysType, never>>\n : Record<string, never>);\n\n/**\n * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n *\n * @remarks\n * Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.\n *\n * If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.\n *\n * @see https://github.com/microsoft/TypeScript/issues/15300\n */\nexport type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};\n\n/**\n * Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.\n *\n * @remarks\n * Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.\n */\nexport type SetRequired<\n BaseType,\n Keys extends keyof BaseType\n> = BaseType extends unknown // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). // union into a [distributive conditional // `extends unknown` is always going to be the case and is used to convert any\n ? Simplify<\n // Pick just the keys that are optional from the base type.\n Except<BaseType, Keys> &\n // Pick the keys that should be required from the base type and make them required.\n Required<Pick<BaseType, Keys>>\n >\n : never;\n\nexport const $NestedValue: unique symbol = Symbol(\"NestedValue\");\n\nexport type NestedValue<TValue extends object = object> = {\n [$NestedValue]: never;\n} & TValue;\n\nexport interface RefObject<T> {\n current: T;\n}\n\nexport interface Identity<T = string> {\n id: T;\n}\n\nexport interface Versioned {\n version: number;\n}\n\nexport interface Sequenced {\n /**\n * The sequence number (version, or event counter, etc.) of the record\n */\n sequence: number;\n}\n\nexport interface Typed {\n /**\n * The type of the record\n */\n __type: string;\n}\n\nexport interface ClassTypeCheckable<T> extends Typed {\n /**\n * Run type check on the given value\n * @param value - The value to check\n * @returns True if the value is of the type of the class\n */\n isTypeOf: (value: unknown) => value is T;\n}\n\n/**\n * Matches non-recursive types.\n */\nexport type NonRecursiveType =\n | BuiltIns\n // eslint-disable-next-line ts/no-unsafe-function-type\n | Function\n | (new (...arguments_: any[]) => unknown);\n\nexport type IsPrimitive<T> = [T] extends [Primitive] ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type IsNull<T> = [T] extends [null] ? true : false;\nexport type IsUndefined<T> = T extends undefined ? true : false;\nexport type IsUnknown<T> = unknown extends T // `T` can be `unknown` or `any`\n ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be\n ? true\n : false\n : false;\nexport type IsNullish<T> = IsNull<T> & IsUndefined<T>;\nexport type IsFunction<T> = T extends AnyFunction ? true : false;\n\n/**\n * Declare locally scoped properties on `globalThis`.\n *\n * When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.\n *\n * Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.\n *\n * @example\n * ```\n * import type { GlobalThis } from '@stryke/types';\n *\n * type ExtraGlobals = GlobalThis & {\n * readonly GLOBAL_TOKEN: string;\n * };\n *\n * (globalThis as ExtraGlobals).GLOBAL_TOKEN;\n * ```\n */\nexport type GlobalThis = typeof globalThis;\n\n/**\n * Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport interface Class<T, Arguments extends unknown[] = any[]> {\n prototype: Pick<T, keyof T>;\n new (...arguments_: Arguments): T;\n}\n\n/**\n * Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport type Constructor<T, Arguments extends unknown[] = any[]> = new (\n ...arguments_: Arguments\n) => T;\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).\n *\n * @privateRemarks\n * We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)\n */\n\nexport interface AbstractClass<\n T,\n Arguments extends unknown[] = any[]\n> extends AbstractConstructor<T, Arguments> {\n prototype: Pick<T, keyof T>;\n}\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.\n */\nexport type AbstractConstructor<\n T,\n Arguments extends unknown[] = any[]\n> = abstract new (...arguments_: Arguments) => T;\n\n/**\n * Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.\n *\n * If `<Fill>` is not provided, it will default to `unknown`.\n *\n * @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f\n */\nexport type BuildTuple<\n L extends number,\n Fill = unknown,\n T extends readonly unknown[] = []\n> = T[\"length\"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;\n\n/**\n * Test if the given function has multiple call signatures.\n *\n * Needed to handle the case of a single call signature with properties.\n *\n * Multiple call signatures cannot currently be supported due to a TypeScript limitation.\n * @see https://github.com/microsoft/TypeScript/issues/29732\n */\nexport type HasMultipleCallSignatures<\n T extends (...arguments_: any[]) => unknown\n> = T extends {\n (...arguments_: infer A): unknown;\n (...arguments_: infer B): unknown;\n}\n ? B extends A\n ? A extends B\n ? false\n : true\n : true\n : false;\n\ntype StructuredCloneablePrimitive =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | boolean\n | number\n | string;\n\ntype StructuredCloneableData =\n | ArrayBuffer\n | DataView\n | Date\n | Error\n | RegExp\n | TypedArray\n | Blob\n | File;\n\n// DOM exclusive types\n// | AudioData\n// | CropTarget\n// | CryptoKey\n// | DOMException\n// | DOMMatrix\n// | DOMMatrixReadOnly\n// | DOMPoint\n// | DOMPointReadOnly\n// | DOMQuad\n// | DOMRect\n// | DOMRectReadOnly\n// | FileList\n// | FileSystemDirectoryHandle\n// | FileSystemFileHandle\n// | FileSystemHandle\n// | GPUCompilationInfo\n// | GPUCompilationMessage\n// | ImageBitmap\n// | ImageData\n// | RTCCertificate\n// | VideoFrame\n\ntype StructuredCloneableCollection =\n | readonly StructuredCloneable[]\n | {\n readonly [key: string]: StructuredCloneable;\n readonly [key: number]: StructuredCloneable;\n }\n | ReadonlyMap<StructuredCloneable, StructuredCloneable>\n | ReadonlySet<StructuredCloneable>;\n\n/**\n * Matches a value that can be losslessly cloned using `structuredClone`.\n *\n * Note:\n * - Custom error types will be cloned as the base `Error` type\n * - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n *\n * @example\n * ```\n * import type { StructuredCloneable } from '@stryke/types';\n *\n * class CustomClass {}\n *\n * // @ts-expect-error\n * const error: StructuredCloneable = {\n * custom: new CustomClass(),\n * };\n *\n * structuredClone(error);\n * //=> {custom: {}}\n *\n * const good: StructuredCloneable = {\n * number: 3,\n * date: new Date(),\n * map: new Map<string, number>(),\n * }\n *\n * good.map.set('key', 1);\n *\n * structuredClone(good);\n * //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}\n * ```\n */\nexport type StructuredCloneable =\n | StructuredCloneablePrimitive\n | StructuredCloneableData\n | StructuredCloneableCollection;\n"],"mappings":"AAsJA,MAAa,EAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.d.cts","names":[],"sources":["../../../../types/src/navigator.ts"],"sourcesContent":[],"mappings":";AAoBiB,UAAA,cAAA,CAAc;EAWd,SAAA,EAAA,OAAY;;;;;;;;;UAAZ,YAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.d.mts","names":[],"sources":["../../../../types/src/navigator.ts"],"sourcesContent":[],"mappings":";AAoBiB,UAAA,cAAA,CAAc;EAWd,SAAA,EAAA,OAAY;;;;;;;;;UAAZ,YAAA"}
|
package/dist/use-battery.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./type-checks/src/is-function.cjs`);let n=require(`react`);n=e.__toESM(n);const r={supported:!0,loading:!0,level:null,charging:null,chargingTime:null,dischargingTime:null};function i(){let[e,i]=n.default.useState(r),a=navigator.getBattery;return(0,n.useEffect)(()=>{if(!t.isFunction(a)){i(e=>({...e,supported:!1,loading:!1}));return}let e=null,n=()=>{i({...r,supported:!0,loading:!1,...e})};return a().then(t=>{e=t,n(),t?.addEventListener(`levelchange`,n),t?.addEventListener(`chargingchange`,n),t?.addEventListener(`chargingtimechange`,n),t?.addEventListener(`dischargingtimechange`,n)}),()=>{e&&(e.removeEventListener(`levelchange`,n),e.removeEventListener(`chargingchange`,n),e.removeEventListener(`chargingtimechange`,n),e.removeEventListener(`dischargingtimechange`,n))}},[a]),e}exports.useBattery=i;
|
package/dist/use-battery.d.cts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BatteryManager } from "./types/src/navigator.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/use-battery.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Listens for updates to the mobile/desktop battery status
|
|
7
|
+
*/
|
|
8
|
+
declare function useBattery(): Omit<BatteryManager, "addEventListener" | "removeEventListener">;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { useBattery };
|
|
11
|
+
//# sourceMappingURL=use-battery.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-battery.d.cts","names":[],"sources":["../src/use-battery.ts"],"sourcesContent":[],"mappings":";;;;;;AAkCA;iBAAgB,UAAA,CAAA,GAAU,KAAA"}
|
package/dist/use-battery.d.mts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BatteryManager } from "./types/src/navigator.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/use-battery.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Listens for updates to the mobile/desktop battery status
|
|
7
|
+
*/
|
|
8
|
+
declare function useBattery(): Omit<BatteryManager, "addEventListener" | "removeEventListener">;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { useBattery };
|
|
11
|
+
//# sourceMappingURL=use-battery.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-battery.d.mts","names":[],"sources":["../src/use-battery.ts"],"sourcesContent":[],"mappings":";;;;;;AAkCA;iBAAgB,UAAA,CAAA,GAAU,KAAA"}
|
package/dist/use-battery.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isFunction as e}from"./type-checks/src/is-function.mjs";import t,{useEffect as n}from"react";const r={supported:!0,loading:!0,level:null,charging:null,chargingTime:null,dischargingTime:null};function i(){let[i,a]=t.useState(r),o=navigator.getBattery;return n(()=>{if(!e(o)){a(e=>({...e,supported:!1,loading:!1}));return}let t=null,n=()=>{a({...r,supported:!0,loading:!1,...t})};return o().then(e=>{t=e,n(),e?.addEventListener(`levelchange`,n),e?.addEventListener(`chargingchange`,n),e?.addEventListener(`chargingtimechange`,n),e?.addEventListener(`dischargingtimechange`,n)}),()=>{t&&(t.removeEventListener(`levelchange`,n),t.removeEventListener(`chargingchange`,n),t.removeEventListener(`chargingtimechange`,n),t.removeEventListener(`dischargingtimechange`,n))}},[o]),i}export{i as useBattery};
|
|
2
|
+
//# sourceMappingURL=use-battery.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-battery.mjs","names":[],"sources":["../src/use-battery.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport type { BatteryManager } from \"@stryke/types/navigator\";\nimport React, { useEffect } from \"react\";\n\nconst defaultBatteryManagerState = {\n supported: true,\n loading: true,\n level: null,\n charging: null,\n chargingTime: null,\n dischargingTime: null\n};\n\n/**\n * Listens for updates to the mobile/desktop battery status\n */\nexport function useBattery() {\n const [state, setState] = React.useState<\n Omit<BatteryManager, \"addEventListener\" | \"removeEventListener\">\n >(defaultBatteryManagerState);\n\n const key = \"getBattery\" as keyof typeof navigator;\n const getBattery = navigator[key] as () => Promise<BatteryManager>;\n\n useEffect(() => {\n if (!isFunction(getBattery)) {\n setState(s => ({\n ...s,\n supported: false,\n loading: false\n }));\n return;\n }\n\n let battery = null as BatteryManager | null;\n\n const handleChange = () => {\n setState({\n ...defaultBatteryManagerState,\n supported: true,\n loading: false,\n ...battery\n });\n };\n\n void getBattery().then(b => {\n battery = b;\n handleChange();\n\n b?.addEventListener(\"levelchange\", handleChange);\n b?.addEventListener(\"chargingchange\", handleChange);\n b?.addEventListener(\"chargingtimechange\", handleChange);\n b?.addEventListener(\"dischargingtimechange\", handleChange);\n });\n\n return () => {\n if (battery) {\n battery.removeEventListener(\"levelchange\", handleChange);\n battery.removeEventListener(\"chargingchange\", handleChange);\n battery.removeEventListener(\"chargingtimechange\", handleChange);\n battery.removeEventListener(\"dischargingtimechange\", handleChange);\n }\n };\n }, [getBattery]);\n\n return state;\n}\n"],"mappings":"oGAsBA,MAAM,EAA6B,CACjC,UAAW,GACX,QAAS,GACT,MAAO,KACP,SAAU,KACV,aAAc,KACd,gBAAiB,KAClB,CAKD,SAAgB,GAAa,CAC3B,GAAM,CAAC,EAAO,GAAY,EAAM,SAE9B,EAA2B,CAGvB,EAAa,UADP,WA4CZ,OAzCA,MAAgB,CACd,GAAI,CAAC,EAAW,EAAW,CAAE,CAC3B,EAAS,IAAM,CACb,GAAG,EACH,UAAW,GACX,QAAS,GACV,EAAE,CACH,OAGF,IAAI,EAAU,KAER,MAAqB,CACzB,EAAS,CACP,GAAG,EACH,UAAW,GACX,QAAS,GACT,GAAG,EACJ,CAAC,EAaJ,OAVK,GAAY,CAAC,KAAK,GAAK,CAC1B,EAAU,EACV,GAAc,CAEd,GAAG,iBAAiB,cAAe,EAAa,CAChD,GAAG,iBAAiB,iBAAkB,EAAa,CACnD,GAAG,iBAAiB,qBAAsB,EAAa,CACvD,GAAG,iBAAiB,wBAAyB,EAAa,EAC1D,KAEW,CACP,IACF,EAAQ,oBAAoB,cAAe,EAAa,CACxD,EAAQ,oBAAoB,iBAAkB,EAAa,CAC3D,EAAQ,oBAAoB,qBAAsB,EAAa,CAC/D,EAAQ,oBAAoB,wBAAyB,EAAa,IAGrE,CAAC,EAAW,CAAC,CAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./
|
|
1
|
+
const e=require(`./_virtual/rolldown_runtime.cjs`);let t=require(`react`);function n(e){let n=(0,t.useRef)(e);return(0,t.useEffect)(()=>{n.current=e}),(0,t.useMemo)(()=>((...e)=>n.current?.(...e)),[])}exports.useCallbackRef=n;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/use-callback-ref.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
4
|
+
* prop or avoid re-executing effects when passed as a dependency
|
|
5
|
+
*/
|
|
6
|
+
declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { useCallbackRef };
|
|
9
|
+
//# sourceMappingURL=use-callback-ref.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-callback-ref.d.cts","names":[],"sources":["../src/use-callback-ref.ts"],"sourcesContent":[],"mappings":";;AAwBA;;;iBAAgB,4DACJ,gBACT"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/use-callback-ref.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
4
|
+
* prop or avoid re-executing effects when passed as a dependency
|
|
5
|
+
*/
|
|
6
|
+
declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { useCallbackRef };
|
|
9
|
+
//# sourceMappingURL=use-callback-ref.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-callback-ref.d.mts","names":[],"sources":["../src/use-callback-ref.ts"],"sourcesContent":[],"mappings":";;AAwBA;;;iBAAgB,4DACJ,gBACT"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{t as
|
|
1
|
+
import{useEffect as e,useMemo as t,useRef as n}from"react";function r(r){let i=n(r);return e(()=>{i.current=r}),t(()=>((...e)=>i.current?.(...e)),[])}export{r as useCallbackRef};
|
|
2
|
+
//# sourceMappingURL=use-callback-ref.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-callback-ref.mjs","names":[],"sources":["../src/use-callback-ref.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { useEffect, useMemo, useRef } from \"react\";\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nexport function useCallbackRef<T extends (...args: any[]) => any>(\n callback: T | undefined\n): T {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n"],"mappings":"2DAwBA,SAAgB,EACd,EACG,CACH,IAAM,EAAc,EAAO,EAAS,CAOpC,OALA,MAAgB,CACd,EAAY,QAAU,GACtB,CAGK,QAAgB,GAAG,IAAS,EAAY,UAAU,GAAG,EAAK,EAAQ,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./use-memo-stable
|
|
1
|
+
const e=require(`./use-memo-stable.cjs`);function t(t,n){return e.useMemoStable(()=>t,n)}exports.useCallbackStable=t;
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AnyFunction } from "./types/src/base.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/use-callback-stable.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Forked from use-memo-one by Alex Reardon
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `useMemo` and `useCallback` cache the most recent result. However, this cache can be destroyed by React when it wants to.
|
|
10
|
+
*
|
|
11
|
+
* `useMemoStable` and `useCallbackStable` are concurrent mode safe alternatives to `useMemo` and `useCallback` that do provide semantic guarantee. What this means is that you will always get the same reference for a memoized value so long as there is no input change.
|
|
12
|
+
*
|
|
13
|
+
* Using `useMemoStable` and `useCallbackStable` will consume more memory than useMemo and `useCallback` in order to provide a stable cache. React can release the cache of `useMemo` and `useCallback`, but `useMemoStable` will not release the cache until it is garbage collected.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* You may rely on useMemo as a performance optimization, not as a semantic guarantee. In the future, React may choose to “forget” some previously memoized values and recalculate them on next render, e.g. to free memory for offscreen components. Write your code so that it still works without `useMemo` — and then add it to optimize performance.
|
|
17
|
+
*
|
|
18
|
+
* @param callback - The callback function to memoize
|
|
19
|
+
* @param inputs - The inputs to watch for changes
|
|
20
|
+
* @returns The memoized callback function
|
|
21
|
+
*/
|
|
22
|
+
declare function useCallbackStable<TCallback extends AnyFunction = AnyFunction>(callback: TCallback, inputs?: any[]): TCallback;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { useCallbackStable };
|
|
25
|
+
//# sourceMappingURL=use-callback-stable.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-callback-stable.d.cts","names":[],"sources":["../src/use-callback-stable.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;;;;;;;;;;iBAAgB,oCAAoC,cAAc,uBACtD,4BAET"}
|