@stryke/hooks 0.4.47 → 0.4.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  3. package/dist/env/src/runtime-checks.cjs +57 -1
  4. package/dist/env/src/runtime-checks.mjs +56 -1
  5. package/dist/env/src/runtime-checks.mjs.map +1 -1
  6. package/dist/helpers/src/debounce.cjs +62 -1
  7. package/dist/helpers/src/debounce.mjs +61 -1
  8. package/dist/helpers/src/debounce.mjs.map +1 -1
  9. package/dist/helpers/src/throttle.cjs +43 -1
  10. package/dist/helpers/src/throttle.mjs +42 -1
  11. package/dist/helpers/src/throttle.mjs.map +1 -1
  12. package/dist/index.cjs +41 -1
  13. package/dist/index.mjs +19 -1
  14. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  15. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  16. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  17. package/dist/type-checks/src/is-equal.cjs +19 -1
  18. package/dist/type-checks/src/is-equal.mjs +18 -1
  19. package/dist/type-checks/src/is-equal.mjs.map +1 -1
  20. package/dist/type-checks/src/is-function.cjs +25 -1
  21. package/dist/type-checks/src/is-function.mjs +25 -1
  22. package/dist/type-checks/src/is-function.mjs.map +1 -1
  23. package/dist/types/src/base.cjs +6 -1
  24. package/dist/types/src/base.mjs +5 -1
  25. package/dist/types/src/base.mjs.map +1 -1
  26. package/dist/use-battery.cjs +60 -1
  27. package/dist/use-battery.mjs +58 -1
  28. package/dist/use-battery.mjs.map +1 -1
  29. package/dist/use-callback-ref.cjs +18 -1
  30. package/dist/use-callback-ref.mjs +17 -1
  31. package/dist/use-callback-ref.mjs.map +1 -1
  32. package/dist/use-callback-stable.cjs +26 -1
  33. package/dist/use-callback-stable.mjs +26 -1
  34. package/dist/use-callback-stable.mjs.map +1 -1
  35. package/dist/use-click-away.cjs +33 -1
  36. package/dist/use-click-away.mjs +32 -1
  37. package/dist/use-click-away.mjs.map +1 -1
  38. package/dist/use-compose-refs.cjs +43 -1
  39. package/dist/use-compose-refs.mjs +40 -1
  40. package/dist/use-compose-refs.mjs.map +1 -1
  41. package/dist/use-copy-to-clipboard.cjs +38 -1
  42. package/dist/use-copy-to-clipboard.mjs +37 -1
  43. package/dist/use-copy-to-clipboard.mjs.map +1 -1
  44. package/dist/use-debounce.cjs +44 -1
  45. package/dist/use-debounce.mjs +42 -1
  46. package/dist/use-debounce.mjs.map +1 -1
  47. package/dist/use-did-finish-ssr.cjs +27 -1
  48. package/dist/use-did-finish-ssr.mjs +24 -1
  49. package/dist/use-did-finish-ssr.mjs.map +1 -1
  50. package/dist/use-escape-keydown.cjs +23 -1
  51. package/dist/use-escape-keydown.mjs +22 -1
  52. package/dist/use-escape-keydown.mjs.map +1 -1
  53. package/dist/use-event.cjs +27 -1
  54. package/dist/use-event.mjs +26 -1
  55. package/dist/use-event.mjs.map +1 -1
  56. package/dist/use-hover.cjs +33 -1
  57. package/dist/use-hover.mjs +32 -1
  58. package/dist/use-hover.mjs.map +1 -1
  59. package/dist/use-idle.cjs +50 -1
  60. package/dist/use-idle.mjs +49 -1
  61. package/dist/use-idle.mjs.map +1 -1
  62. package/dist/use-isomorphic-layout-effect.cjs +14 -1
  63. package/dist/use-isomorphic-layout-effect.mjs +13 -1
  64. package/dist/use-isomorphic-layout-effect.mjs.map +1 -1
  65. package/dist/use-keyboard-visible.cjs +24 -1
  66. package/dist/use-keyboard-visible.mjs +23 -1
  67. package/dist/use-keyboard-visible.mjs.map +1 -1
  68. package/dist/use-memo-stable.cjs +48 -1
  69. package/dist/use-memo-stable.mjs +47 -1
  70. package/dist/use-memo-stable.mjs.map +1 -1
  71. package/dist/use-network-state.cjs +57 -1
  72. package/dist/use-network-state.mjs +55 -1
  73. package/dist/use-network-state.mjs.map +1 -1
  74. package/dist/use-previous.cjs +20 -1
  75. package/dist/use-previous.mjs +19 -1
  76. package/dist/use-previous.mjs.map +1 -1
  77. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  # Changelog for Stryke - Hooks
4
4
 
5
+ ## [0.4.47](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.47) (01/16/2026)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **env** to **v0.20.49**
10
+
5
11
  ## [0.4.46](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.46) (01/16/2026)
6
12
 
7
13
  ### Updated Dependencies
@@ -1 +1,29 @@
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;
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1 +1,57 @@
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;
1
+
2
+ //#region ../env/src/runtime-checks.ts
3
+ /**
4
+ * Indicates if running in Node.js or a Node.js compatible runtime.
5
+ *
6
+ * **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.
7
+ *
8
+ * Use `runtime === "node"` if you need strict check for Node.js runtime.
9
+ */
10
+ const isNode = process?.release?.name === "node";
11
+ /**
12
+ * Indicates if running in Bun runtime.
13
+ */
14
+ const isBun = Boolean(Bun) || Boolean(process?.versions?.bun);
15
+ /**
16
+ * Indicates if running in Deno runtime.
17
+ */
18
+ const isDeno = Boolean(Deno);
19
+ /**
20
+ * Indicates if running in Fastly runtime.
21
+ */
22
+ const isFastly = Boolean(fastly);
23
+ /**
24
+ * Indicates if running in Netlify runtime.
25
+ */
26
+ const isNetlify = Boolean(Netlify);
27
+ /**
28
+ *
29
+ * Indicates if running in EdgeLight (Vercel Edge) runtime.
30
+ */
31
+ const isEdgeLight = Boolean(EdgeRuntime);
32
+ /**
33
+ * Indicates if running in Cloudflare Workers runtime.
34
+ */
35
+ const isWorkerd = navigator?.userAgent === "Cloudflare-Workers";
36
+ /**
37
+ * Indicates if the code is running on the server-side
38
+ */
39
+ const isRuntimeServer = isNode || isBun || isDeno || isFastly || isNetlify || isEdgeLight || isWorkerd;
40
+ const runtimeChecks = [
41
+ [isNetlify, "netlify"],
42
+ [isEdgeLight, "edge-light"],
43
+ [isWorkerd, "workerd"],
44
+ [isFastly, "fastly"],
45
+ [isDeno, "deno"],
46
+ [isBun, "bun"],
47
+ [isNode, "node"]
48
+ ];
49
+ function detectRuntime() {
50
+ const detectedRuntime = runtimeChecks.find((check) => check[0]);
51
+ if (detectedRuntime) return { name: detectedRuntime[1] };
52
+ }
53
+ const runtimeInfo = detectRuntime();
54
+ const runtime = runtimeInfo?.name || "";
55
+
56
+ //#endregion
57
+ exports.isRuntimeServer = isRuntimeServer;
@@ -1,2 +1,57 @@
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};
1
+ //#region ../env/src/runtime-checks.ts
2
+ /**
3
+ * Indicates if running in Node.js or a Node.js compatible runtime.
4
+ *
5
+ * **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.
6
+ *
7
+ * Use `runtime === "node"` if you need strict check for Node.js runtime.
8
+ */
9
+ const isNode = process?.release?.name === "node";
10
+ /**
11
+ * Indicates if running in Bun runtime.
12
+ */
13
+ const isBun = Boolean(Bun) || Boolean(process?.versions?.bun);
14
+ /**
15
+ * Indicates if running in Deno runtime.
16
+ */
17
+ const isDeno = Boolean(Deno);
18
+ /**
19
+ * Indicates if running in Fastly runtime.
20
+ */
21
+ const isFastly = Boolean(fastly);
22
+ /**
23
+ * Indicates if running in Netlify runtime.
24
+ */
25
+ const isNetlify = Boolean(Netlify);
26
+ /**
27
+ *
28
+ * Indicates if running in EdgeLight (Vercel Edge) runtime.
29
+ */
30
+ const isEdgeLight = Boolean(EdgeRuntime);
31
+ /**
32
+ * Indicates if running in Cloudflare Workers runtime.
33
+ */
34
+ const isWorkerd = navigator?.userAgent === "Cloudflare-Workers";
35
+ /**
36
+ * Indicates if the code is running on the server-side
37
+ */
38
+ const isRuntimeServer = isNode || isBun || isDeno || isFastly || isNetlify || isEdgeLight || isWorkerd;
39
+ const runtimeChecks = [
40
+ [isNetlify, "netlify"],
41
+ [isEdgeLight, "edge-light"],
42
+ [isWorkerd, "workerd"],
43
+ [isFastly, "fastly"],
44
+ [isDeno, "deno"],
45
+ [isBun, "bun"],
46
+ [isNode, "node"]
47
+ ];
48
+ function detectRuntime() {
49
+ const detectedRuntime = runtimeChecks.find((check) => check[0]);
50
+ if (detectedRuntime) return { name: detectedRuntime[1] };
51
+ }
52
+ const runtimeInfo = detectRuntime();
53
+ const runtime = runtimeInfo?.name || "";
54
+
55
+ //#endregion
56
+ export { isRuntimeServer };
2
57
  //# sourceMappingURL=runtime-checks.mjs.map
@@ -1 +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"}
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,SAAS,SAAS,SAAS,SAAS;;;;AAKjD,MAAa,QAAQ,QAAQ,IAAI,IAAI,QAAQ,SAAS,UAAU,IAAI;;;;AAKpE,MAAa,SAAS,QAAQ,KAAK;;;;AAKnC,MAAa,WAAW,QAAQ,OAAO;;;;AAKvC,MAAa,YAAY,QAAQ,QAAQ;;;;;AAMzC,MAAa,cAAc,QAAQ,YAAY;;;;AAM/C,MAAa,YAAY,WAAW,cAAc;;;;AAKlD,MAAa,kBACX,UACA,SACA,UACA,YACA,aACA,eACA;AAOF,MAAMA,gBAA0C;CAC9C,CAAC,WAAW,UAAU;CACtB,CAAC,aAAa,aAAa;CAC3B,CAAC,WAAW,UAAU;CACtB,CAAC,UAAU,SAAS;CACpB,CAAC,QAAQ,OAAO;CAChB,CAAC,OAAO,MAAM;CACd,CAAC,QAAQ,OAAO;CACjB;AAED,SAAS,gBAAyC;CAChD,MAAM,kBAAkB,cAAc,MAAK,UAAS,MAAM,GAAG;AAE7D,KAAI,gBAGF,QAAO,EAAE,MAFI,gBAAgB,IAEd;;AAMnB,MAAa,cAAc,eAAe;AAE1C,MAAaC,UAAuB,aAAa,QAAQ"}
@@ -1 +1,62 @@
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;
1
+
2
+ //#region ../helpers/src/debounce.ts
3
+ /**
4
+ * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
5
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
6
+ * method to cancel any pending execution.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const debouncedFunction = debounce(() => {
11
+ * console.log('Function executed');
12
+ * }, 1000);
13
+ *
14
+ * // Will log 'Function executed' after 1 second if not called again in that time
15
+ * debouncedFunction();
16
+ *
17
+ * // Will not log anything as the previous call is canceled
18
+ * debouncedFunction.cancel();
19
+ *
20
+ * // With AbortSignal
21
+ * const controller = new AbortController();
22
+ * const signal = controller.signal;
23
+ * const debouncedWithSignal = debounce(() => {
24
+ * console.log('Function executed');
25
+ * }, 1000, { signal });
26
+ *
27
+ * debouncedWithSignal();
28
+ *
29
+ * // Will cancel the debounced function call
30
+ * controller.abort();
31
+ * ```
32
+ *
33
+ * @param func - The function to debounce.
34
+ * @param debounceMs - The number of milliseconds to delay.
35
+ * @param options - The options object.
36
+ * @returns A new debounced function with a `cancel` method.
37
+ */
38
+ function debounce(func, debounceMs, { signal } = {}) {
39
+ let timeoutId = null;
40
+ const debounced = ((...args) => {
41
+ if (timeoutId !== null) clearTimeout(timeoutId);
42
+ if (signal?.aborted) return;
43
+ timeoutId = setTimeout(() => {
44
+ func(...args);
45
+ timeoutId = null;
46
+ }, debounceMs);
47
+ });
48
+ const onAbort = () => {
49
+ debounced.cancel();
50
+ };
51
+ debounced.cancel = () => {
52
+ if (timeoutId !== null) {
53
+ clearTimeout(timeoutId);
54
+ timeoutId = null;
55
+ }
56
+ };
57
+ signal?.addEventListener("abort", onAbort, { once: true });
58
+ return debounced;
59
+ }
60
+
61
+ //#endregion
62
+ exports.debounce = debounce;
@@ -1,2 +1,62 @@
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};
1
+ //#region ../helpers/src/debounce.ts
2
+ /**
3
+ * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
4
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
5
+ * method to cancel any pending execution.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const debouncedFunction = debounce(() => {
10
+ * console.log('Function executed');
11
+ * }, 1000);
12
+ *
13
+ * // Will log 'Function executed' after 1 second if not called again in that time
14
+ * debouncedFunction();
15
+ *
16
+ * // Will not log anything as the previous call is canceled
17
+ * debouncedFunction.cancel();
18
+ *
19
+ * // With AbortSignal
20
+ * const controller = new AbortController();
21
+ * const signal = controller.signal;
22
+ * const debouncedWithSignal = debounce(() => {
23
+ * console.log('Function executed');
24
+ * }, 1000, { signal });
25
+ *
26
+ * debouncedWithSignal();
27
+ *
28
+ * // Will cancel the debounced function call
29
+ * controller.abort();
30
+ * ```
31
+ *
32
+ * @param func - The function to debounce.
33
+ * @param debounceMs - The number of milliseconds to delay.
34
+ * @param options - The options object.
35
+ * @returns A new debounced function with a `cancel` method.
36
+ */
37
+ function debounce(func, debounceMs, { signal } = {}) {
38
+ let timeoutId = null;
39
+ const debounced = ((...args) => {
40
+ if (timeoutId !== null) clearTimeout(timeoutId);
41
+ if (signal?.aborted) return;
42
+ timeoutId = setTimeout(() => {
43
+ func(...args);
44
+ timeoutId = null;
45
+ }, debounceMs);
46
+ });
47
+ const onAbort = () => {
48
+ debounced.cancel();
49
+ };
50
+ debounced.cancel = () => {
51
+ if (timeoutId !== null) {
52
+ clearTimeout(timeoutId);
53
+ timeoutId = null;
54
+ }
55
+ };
56
+ signal?.addEventListener("abort", onAbort, { once: true });
57
+ return debounced;
58
+ }
59
+
60
+ //#endregion
61
+ export { debounce };
2
62
  //# sourceMappingURL=debounce.mjs.map
@@ -1 +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"}
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,SACd,MACA,YACA,EAAE,WAA4B,EAAE,EACJ;CAC5B,IAAIA,YAAkD;CAEtD,MAAM,cAAc,GAAG,SAAwB;AAC7C,MAAI,cAAc,KAChB,cAAa,UAAU;AAGzB,MAAI,QAAQ,QACV;AAGF,cAAY,iBAAiB;AAC3B,QAAK,GAAG,KAAK;AACb,eAAY;KACX,WAAW;;CAGhB,MAAM,gBAAgB;AACpB,YAAU,QAAQ;;AAGpB,WAAU,eAAe;AACvB,MAAI,cAAc,MAAM;AACtB,gBAAa,UAAU;AACvB,eAAY;;;AAIhB,SAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1D,QAAO"}
@@ -1 +1,43 @@
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;
1
+
2
+ //#region ../helpers/src/throttle.ts
3
+ /**
4
+ * Creates a throttled function that only invokes the provided function at most once
5
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
6
+ * within the wait time will not trigger the execution of the original function.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const throttledFunction = throttle(() => {
11
+ * console.log('Function executed');
12
+ * }, 1000);
13
+ *
14
+ * // Will log 'Function executed' immediately
15
+ * throttledFunction();
16
+ *
17
+ * // Will not log anything as it is within the throttle time
18
+ * throttledFunction();
19
+ *
20
+ * // After 1 second
21
+ * setTimeout(() => {
22
+ * throttledFunction(); // Will log 'Function executed'
23
+ * }, 1000);
24
+ * ```
25
+ *
26
+ * @param func - The function to throttle.
27
+ * @param throttleMs - The number of milliseconds to throttle executions to.
28
+ * @returns A new throttled function that accepts the same parameters as the original function.
29
+ */
30
+ function throttle(func, throttleMs) {
31
+ let lastCallTime;
32
+ const throttledFunction = ((...args) => {
33
+ const now = Date.now();
34
+ if (lastCallTime == null || now - lastCallTime >= throttleMs) {
35
+ lastCallTime = now;
36
+ func(...args);
37
+ }
38
+ });
39
+ return throttledFunction;
40
+ }
41
+
42
+ //#endregion
43
+ exports.throttle = throttle;
@@ -1,2 +1,43 @@
1
- function e(e,t){let n;return((...r)=>{let i=Date.now();(n==null||i-n>=t)&&(n=i,e(...r))})}export{e as throttle};
1
+ //#region ../helpers/src/throttle.ts
2
+ /**
3
+ * Creates a throttled function that only invokes the provided function at most once
4
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
5
+ * within the wait time will not trigger the execution of the original function.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const throttledFunction = throttle(() => {
10
+ * console.log('Function executed');
11
+ * }, 1000);
12
+ *
13
+ * // Will log 'Function executed' immediately
14
+ * throttledFunction();
15
+ *
16
+ * // Will not log anything as it is within the throttle time
17
+ * throttledFunction();
18
+ *
19
+ * // After 1 second
20
+ * setTimeout(() => {
21
+ * throttledFunction(); // Will log 'Function executed'
22
+ * }, 1000);
23
+ * ```
24
+ *
25
+ * @param func - The function to throttle.
26
+ * @param throttleMs - The number of milliseconds to throttle executions to.
27
+ * @returns A new throttled function that accepts the same parameters as the original function.
28
+ */
29
+ function throttle(func, throttleMs) {
30
+ let lastCallTime;
31
+ const throttledFunction = ((...args) => {
32
+ const now = Date.now();
33
+ if (lastCallTime == null || now - lastCallTime >= throttleMs) {
34
+ lastCallTime = now;
35
+ func(...args);
36
+ }
37
+ });
38
+ return throttledFunction;
39
+ }
40
+
41
+ //#endregion
42
+ export { throttle };
2
43
  //# sourceMappingURL=throttle.mjs.map
@@ -1 +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"}
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,SACd,MACA,YACG;CACH,IAAIA;CAEJ,MAAM,sBAAsB,GAAG,SAAwB;EACrD,MAAM,MAAM,KAAK,KAAK;AAEtB,MAAI,gBAAgB,QAAQ,MAAM,gBAAgB,YAAY;AAC5D,kBAAe;AACf,QAAK,GAAG,KAAK;;;AAIjB,QAAO"}
package/dist/index.cjs CHANGED
@@ -1 +1,41 @@
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;
1
+ const require_use_battery = require('./use-battery.cjs');
2
+ const require_use_callback_ref = require('./use-callback-ref.cjs');
3
+ const require_use_memo_stable = require('./use-memo-stable.cjs');
4
+ const require_use_callback_stable = require('./use-callback-stable.cjs');
5
+ const require_use_click_away = require('./use-click-away.cjs');
6
+ const require_use_compose_refs = require('./use-compose-refs.cjs');
7
+ const require_use_copy_to_clipboard = require('./use-copy-to-clipboard.cjs');
8
+ const require_use_debounce = require('./use-debounce.cjs');
9
+ const require_use_did_finish_ssr = require('./use-did-finish-ssr.cjs');
10
+ const require_use_escape_keydown = require('./use-escape-keydown.cjs');
11
+ const require_use_isomorphic_layout_effect = require('./use-isomorphic-layout-effect.cjs');
12
+ const require_use_event = require('./use-event.cjs');
13
+ const require_use_hover = require('./use-hover.cjs');
14
+ const require_use_idle = require('./use-idle.cjs');
15
+ const require_use_keyboard_visible = require('./use-keyboard-visible.cjs');
16
+ const require_use_network_state = require('./use-network-state.cjs');
17
+ const require_use_previous = require('./use-previous.cjs');
18
+
19
+ exports.composeRefs = require_use_compose_refs.composeRefs;
20
+ exports.setRef = require_use_compose_refs.setRef;
21
+ exports.useBattery = require_use_battery.useBattery;
22
+ exports.useCallbackRef = require_use_callback_ref.useCallbackRef;
23
+ exports.useCallbackStable = require_use_callback_stable.useCallbackStable;
24
+ exports.useClickAway = require_use_click_away.useClickAway;
25
+ exports.useClientValue = require_use_did_finish_ssr.useClientValue;
26
+ exports.useComposedRefs = require_use_compose_refs.useComposedRefs;
27
+ exports.useCopyToClipboard = require_use_copy_to_clipboard.useCopyToClipboard;
28
+ exports.useDebounce = require_use_debounce.useDebounce;
29
+ exports.useDebounceValue = require_use_debounce.useDebounceValue;
30
+ exports.useDidFinishSSR = require_use_did_finish_ssr.useDidFinishSSR;
31
+ exports.useDidFinishSSRSync = require_use_did_finish_ssr.useDidFinishSSRSync;
32
+ exports.useEscapeKeydown = require_use_escape_keydown.useEscapeKeydown;
33
+ exports.useEvent = require_use_event.useEvent;
34
+ exports.useHover = require_use_hover.useHover;
35
+ exports.useIdle = require_use_idle.useIdle;
36
+ exports.useIsomorphicLayoutEffect = require_use_isomorphic_layout_effect.useIsomorphicLayoutEffect;
37
+ exports.useKeyboardVisible = require_use_keyboard_visible.useKeyboardVisible;
38
+ exports.useMemoStable = require_use_memo_stable.useMemoStable;
39
+ exports.useNetworkState = require_use_network_state.useNetworkState;
40
+ exports.useNetworkStateSubscribe = require_use_network_state.useNetworkStateSubscribe;
41
+ exports.usePrevious = require_use_previous.usePrevious;
package/dist/index.mjs CHANGED
@@ -1 +1,19 @@
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};
1
+ import { useBattery } from "./use-battery.mjs";
2
+ import { useCallbackRef } from "./use-callback-ref.mjs";
3
+ import { useMemoStable } from "./use-memo-stable.mjs";
4
+ import { useCallbackStable } from "./use-callback-stable.mjs";
5
+ import { useClickAway } from "./use-click-away.mjs";
6
+ import { composeRefs, setRef, useComposedRefs } from "./use-compose-refs.mjs";
7
+ import { useCopyToClipboard } from "./use-copy-to-clipboard.mjs";
8
+ import { useDebounce, useDebounceValue } from "./use-debounce.mjs";
9
+ import { useClientValue, useDidFinishSSR, useDidFinishSSRSync } from "./use-did-finish-ssr.mjs";
10
+ import { useEscapeKeydown } from "./use-escape-keydown.mjs";
11
+ import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.mjs";
12
+ import { useEvent } from "./use-event.mjs";
13
+ import { useHover } from "./use-hover.mjs";
14
+ import { useIdle } from "./use-idle.mjs";
15
+ import { useKeyboardVisible } from "./use-keyboard-visible.mjs";
16
+ import { useNetworkState, useNetworkStateSubscribe } from "./use-network-state.mjs";
17
+ import { usePrevious } from "./use-previous.mjs";
18
+
19
+ export { composeRefs, setRef, useBattery, useCallbackRef, useCallbackStable, useClickAway, useClientValue, useComposedRefs, useCopyToClipboard, useDebounce, useDebounceValue, useDidFinishSSR, useDidFinishSSRSync, useEscapeKeydown, useEvent, useHover, useIdle, useIsomorphicLayoutEffect, useKeyboardVisible, useMemoStable, useNetworkState, useNetworkStateSubscribe, usePrevious };
@@ -1 +1,15 @@
1
- const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);exports.getObjectTag=e;
1
+
2
+ //#region ../type-checks/src/get-object-tag.ts
3
+ /**
4
+ * Gets the `toStringTag` of `obj`.
5
+ *
6
+ * @param value - The obj to query.
7
+ * @returns Returns the `toStringTag`.
8
+ */
9
+ const getObjectTag = (value) => {
10
+ if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
11
+ return Object.prototype.toString.call(value);
12
+ };
13
+
14
+ //#endregion
15
+ exports.getObjectTag = getObjectTag;
@@ -1,2 +1,15 @@
1
- const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);export{e as getObjectTag};
1
+ //#region ../type-checks/src/get-object-tag.ts
2
+ /**
3
+ * Gets the `toStringTag` of `obj`.
4
+ *
5
+ * @param value - The obj to query.
6
+ * @returns Returns the `toStringTag`.
7
+ */
8
+ const getObjectTag = (value) => {
9
+ if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
10
+ return Object.prototype.toString.call(value);
11
+ };
12
+
13
+ //#endregion
14
+ export { getObjectTag };
2
15
  //# sourceMappingURL=get-object-tag.mjs.map
@@ -1 +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"}
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,gBAAgB,UAA2B;AACtD,KAAI,SAAS,KACX,QAAO,UAAU,SAAY,uBAAuB;AAEtD,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM"}
@@ -1 +1,19 @@
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;
1
+
2
+ //#region ../type-checks/src/is-equal.ts
3
+ const isEqual = (x, y) => {
4
+ if (Object.is(x, y)) return true;
5
+ if (x instanceof Date && y instanceof Date) return x.getTime() === y.getTime();
6
+ if (x instanceof RegExp && y instanceof RegExp) return x.toString() === y.toString();
7
+ if (typeof x !== "object" || x === null || typeof y !== "object" || y === null) return false;
8
+ const keysX = Reflect.ownKeys(x);
9
+ const keysY = Reflect.ownKeys(y);
10
+ if (keysX.length !== keysY.length) return false;
11
+ for (const element_ of keysX) {
12
+ if (!Reflect.has(y, element_)) return false;
13
+ if (!isEqual(x[element_], y[element_])) return false;
14
+ }
15
+ return true;
16
+ };
17
+
18
+ //#endregion
19
+ exports.isEqual = isEqual;
@@ -1,2 +1,19 @@
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};
1
+ //#region ../type-checks/src/is-equal.ts
2
+ const isEqual = (x, y) => {
3
+ if (Object.is(x, y)) return true;
4
+ if (x instanceof Date && y instanceof Date) return x.getTime() === y.getTime();
5
+ if (x instanceof RegExp && y instanceof RegExp) return x.toString() === y.toString();
6
+ if (typeof x !== "object" || x === null || typeof y !== "object" || y === null) return false;
7
+ const keysX = Reflect.ownKeys(x);
8
+ const keysY = Reflect.ownKeys(y);
9
+ if (keysX.length !== keysY.length) return false;
10
+ for (const element_ of keysX) {
11
+ if (!Reflect.has(y, element_)) return false;
12
+ if (!isEqual(x[element_], y[element_])) return false;
13
+ }
14
+ return true;
15
+ };
16
+
17
+ //#endregion
18
+ export { isEqual };
2
19
  //# sourceMappingURL=is-equal.mjs.map
@@ -1 +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"}
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,WAAkB,GAAU,MAAsB;AAC7D,KAAI,OAAO,GAAG,GAAG,EAAE,CAAE,QAAO;AAC5B,KAAI,aAAa,QAAQ,aAAa,KACpC,QAAO,EAAE,SAAS,KAAK,EAAE,SAAS;AAEpC,KAAI,aAAa,UAAU,aAAa,OACtC,QAAO,EAAE,UAAU,KAAK,EAAE,UAAU;AAEtC,KACE,OAAO,MAAM,YACb,MAAM,QACN,OAAO,MAAM,YACb,MAAM,KAEN,QAAO;CAET,MAAM,QAAQ,QAAQ,QAAQ,EAAuB;CACrD,MAAM,QAAQ,QAAQ,QAAQ,EAAuB;AACrD,KAAI,MAAM,WAAW,MAAM,OAAQ,QAAO;AAC1C,MAAK,MAAM,YAAY,OAAO;AAC5B,MAAI,CAAC,QAAQ,IAAI,GAAwB,SAAS,CAAE,QAAO;AAC3D,MAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAE,QAAO;;AAEjD,QAAO"}