@putkoff/abstract-utilities 0.1.163 → 0.1.165
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/dist/cjs/index.js +95 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +90 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/functions/auth_utils/imports.d.ts +1 -0
- package/dist/functions/auth_utils/src/token_utils.d.ts +3 -3
- package/dist/functions/fetch_utils/imports.d.ts +2 -0
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/safe_utils/imports.d.ts +1 -0
- package/dist/functions/safe_utils/index.d.ts +1 -0
- package/dist/functions/safe_utils/src/index.d.ts +2 -0
- package/dist/functions/safe_utils/src/safe_utils.d.ts +12 -0
- package/dist/functions/safe_utils/src/safe_window.d.ts +17 -0
- package/package.json +9 -9
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `window` if running in a browser, otherwise `undefined`.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getSafeLocalStorage(): Storage | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Call a Storage method by name, silencing any errors or missing storage.
|
|
7
|
+
*
|
|
8
|
+
* @param method One of the keys of the Storage interface: "getItem", "setItem", etc.
|
|
9
|
+
* @param args The arguments you’d normally pass to that method.
|
|
10
|
+
* @returns The method’s return value, or undefined if storage/method isn’t available.
|
|
11
|
+
*/
|
|
12
|
+
export declare function callStorage<K extends keyof Storage>(method: K, ...args: Parameters<Storage[K]>): ReturnType<Storage[K]> | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the global window object if it exists, otherwise undefined.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getSafeWindow(): Window | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Safely call a method on window by name.
|
|
7
|
+
*
|
|
8
|
+
* @param method The Window method to call (e.g. "alert", "open", etc.).
|
|
9
|
+
* @param args Arguments to pass to that method.
|
|
10
|
+
* @returns The method’s return value, or undefined if
|
|
11
|
+
* window/method isn’t available or throws.
|
|
12
|
+
*/
|
|
13
|
+
export declare function callWindowMethod<K extends keyof Window, F extends Window[K] = Window[K], Args extends any[] = F extends (...a: infer P) => any ? P : never, R = F extends (...a: any) => infer U ? U : void>(method: K, ...args: Args): R | undefined;
|
|
14
|
+
/** overloads for 1‐ and 2‐level deep props */
|
|
15
|
+
export declare function getWindowProp<K1 extends keyof Window>(prop1: K1): Window[K1] | undefined;
|
|
16
|
+
export declare function getWindowProp<K1 extends keyof Window, K2 extends keyof NonNullable<Window[K1]>>(prop1: K1, prop2: K2): NonNullable<Window[K1]>[K2] | undefined;
|
|
17
|
+
export declare function getWindowHost(): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putkoff/abstract-utilities",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.165",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A reusable React Login component with JWT authentication",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -30,21 +30,21 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
33
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
33
34
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
34
35
|
"@rollup/plugin-typescript": "^11.1.5",
|
|
35
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
36
|
-
"rollup": "^4.12.0",
|
|
37
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
38
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
39
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
40
|
-
"postcss": "^8.5.6",
|
|
41
36
|
"@testing-library/jest-dom": "^6.4.2",
|
|
42
37
|
"@testing-library/react": "^14.2.1",
|
|
43
38
|
"@types/jest": "^29.5.12",
|
|
44
39
|
"@types/node": "^24.0.13",
|
|
45
|
-
"@types/react": "^18.
|
|
46
|
-
"@types/react-dom": "^18.
|
|
40
|
+
"@types/react": "^18.3.23",
|
|
41
|
+
"@types/react-dom": "^18.3.7",
|
|
47
42
|
"jest": "^29.7.0",
|
|
43
|
+
"postcss": "^8.5.6",
|
|
44
|
+
"rollup": "^4.12.0",
|
|
45
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
46
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
47
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
48
48
|
"ts-jest": "^29.1.2",
|
|
49
49
|
"ts-node": "^10.9.2",
|
|
50
50
|
"tslib": "^2.8.1",
|