@stryke/hooks 0.4.47 → 0.4.49
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 +15 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/env/src/runtime-checks.cjs +57 -1
- package/dist/env/src/runtime-checks.mjs +56 -1
- package/dist/env/src/runtime-checks.mjs.map +1 -1
- package/dist/helpers/src/debounce.cjs +62 -1
- package/dist/helpers/src/debounce.mjs +61 -1
- package/dist/helpers/src/debounce.mjs.map +1 -1
- package/dist/helpers/src/throttle.cjs +43 -1
- package/dist/helpers/src/throttle.mjs +42 -1
- package/dist/helpers/src/throttle.mjs.map +1 -1
- package/dist/index.cjs +41 -1
- package/dist/index.mjs +19 -1
- package/dist/type-checks/src/get-object-tag.cjs +15 -1
- package/dist/type-checks/src/get-object-tag.mjs +14 -1
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
- package/dist/type-checks/src/is-equal.cjs +19 -1
- package/dist/type-checks/src/is-equal.mjs +18 -1
- package/dist/type-checks/src/is-equal.mjs.map +1 -1
- package/dist/type-checks/src/is-function.cjs +25 -1
- package/dist/type-checks/src/is-function.mjs +25 -1
- package/dist/type-checks/src/is-function.mjs.map +1 -1
- package/dist/types/src/base.cjs +6 -1
- package/dist/types/src/base.mjs +5 -1
- package/dist/types/src/base.mjs.map +1 -1
- package/dist/use-battery.cjs +60 -1
- package/dist/use-battery.mjs +58 -1
- package/dist/use-battery.mjs.map +1 -1
- package/dist/use-callback-ref.cjs +18 -1
- package/dist/use-callback-ref.mjs +17 -1
- package/dist/use-callback-ref.mjs.map +1 -1
- package/dist/use-callback-stable.cjs +26 -1
- package/dist/use-callback-stable.mjs +26 -1
- package/dist/use-callback-stable.mjs.map +1 -1
- package/dist/use-click-away.cjs +33 -1
- package/dist/use-click-away.mjs +32 -1
- package/dist/use-click-away.mjs.map +1 -1
- package/dist/use-compose-refs.cjs +43 -1
- package/dist/use-compose-refs.mjs +40 -1
- package/dist/use-compose-refs.mjs.map +1 -1
- package/dist/use-copy-to-clipboard.cjs +38 -1
- package/dist/use-copy-to-clipboard.mjs +37 -1
- package/dist/use-copy-to-clipboard.mjs.map +1 -1
- package/dist/use-debounce.cjs +44 -1
- package/dist/use-debounce.mjs +42 -1
- package/dist/use-debounce.mjs.map +1 -1
- package/dist/use-did-finish-ssr.cjs +27 -1
- package/dist/use-did-finish-ssr.mjs +24 -1
- package/dist/use-did-finish-ssr.mjs.map +1 -1
- package/dist/use-escape-keydown.cjs +23 -1
- package/dist/use-escape-keydown.mjs +22 -1
- package/dist/use-escape-keydown.mjs.map +1 -1
- package/dist/use-event.cjs +27 -1
- package/dist/use-event.mjs +26 -1
- package/dist/use-event.mjs.map +1 -1
- package/dist/use-hover.cjs +33 -1
- package/dist/use-hover.mjs +32 -1
- package/dist/use-hover.mjs.map +1 -1
- package/dist/use-idle.cjs +50 -1
- package/dist/use-idle.mjs +49 -1
- package/dist/use-idle.mjs.map +1 -1
- package/dist/use-isomorphic-layout-effect.cjs +14 -1
- package/dist/use-isomorphic-layout-effect.mjs +13 -1
- package/dist/use-isomorphic-layout-effect.mjs.map +1 -1
- package/dist/use-keyboard-visible.cjs +24 -1
- package/dist/use-keyboard-visible.mjs +23 -1
- package/dist/use-keyboard-visible.mjs.map +1 -1
- package/dist/use-memo-stable.cjs +48 -1
- package/dist/use-memo-stable.mjs +47 -1
- package/dist/use-memo-stable.mjs.map +1 -1
- package/dist/use-network-state.cjs +57 -1
- package/dist/use-network-state.mjs +55 -1
- package/dist/use-network-state.mjs.map +1 -1
- package/dist/use-previous.cjs +20 -1
- package/dist/use-previous.mjs +19 -1
- package/dist/use-previous.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - Hooks
|
|
4
4
|
|
|
5
|
+
## [0.4.48](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.48) (01/16/2026)
|
|
6
|
+
|
|
7
|
+
### Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated **type-checks** to **v0.5.19**
|
|
10
|
+
- Updated **helpers** to **v0.9.36**
|
|
11
|
+
- Updated **types** to **v0.10.33**
|
|
12
|
+
- Updated **env** to **v0.20.50**
|
|
13
|
+
|
|
14
|
+
## [0.4.47](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.47) (01/16/2026)
|
|
15
|
+
|
|
16
|
+
### Updated Dependencies
|
|
17
|
+
|
|
18
|
+
- Updated **env** to **v0.20.49**
|
|
19
|
+
|
|
5
20
|
## [0.4.46](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.46) (01/16/2026)
|
|
6
21
|
|
|
7
22
|
### Updated Dependencies
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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"}
|