@koine/browser 1.0.105 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/createStorage.d.ts +2 -2
- package/createStorage.js +2 -2
- package/gtagPageview.d.ts +1 -1
- package/node/createStorage.js +1 -1
- package/package.json +10 -11
- package/storage.d.ts +8 -8
- package/storageClient.d.ts +6 -5
package/createStorage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type CreateStorageConfig = Record<string, any>;
|
|
2
2
|
/**
|
|
3
3
|
* Utility to create a storage instance to interact with `localStorage` using
|
|
4
4
|
* encrypted (encoded) key/values.
|
|
@@ -34,7 +34,7 @@ export declare const createStorage: <T extends CreateStorageConfig>(config: Part
|
|
|
34
34
|
/**
|
|
35
35
|
* Check if a storage value is _truthy_ (it uses `localStorage.get()`).
|
|
36
36
|
*/
|
|
37
|
-
has<TKey_2 extends Extract<keyof T, string>>(key: TKey_2):
|
|
37
|
+
has<TKey_2 extends Extract<keyof T, string>>(key: TKey_2): any;
|
|
38
38
|
/**
|
|
39
39
|
* Remove a storage value (it uses `localStorage.remove()`).
|
|
40
40
|
*/
|
package/createStorage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
|
-
import { decode, encode, isBrowser, isNullOrUndefined } from "@koine/utils";
|
|
2
|
+
import { decode, encode, isBrowser, isNullOrUndefined, noop } from "@koine/utils";
|
|
3
3
|
import { on } from "@koine/dom";
|
|
4
4
|
import storage from "./storage";
|
|
5
5
|
/**
|
|
@@ -118,7 +118,7 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
118
118
|
if (process.env["NODE_ENV"] !== "production") {
|
|
119
119
|
console.log("[@koine/utils:createStorage] attempt to use 'watch' outside of browser.");
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return noop;
|
|
122
122
|
}
|
|
123
123
|
var handler = function (event) {
|
|
124
124
|
var key = event.key, oldValue = event.oldValue, newValue = event.newValue;
|
package/gtagPageview.d.ts
CHANGED
package/node/createStorage.js
CHANGED
|
@@ -121,7 +121,7 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
121
121
|
if (process.env["NODE_ENV"] !== "production") {
|
|
122
122
|
console.log("[@koine/utils:createStorage] attempt to use 'watch' outside of browser.");
|
|
123
123
|
}
|
|
124
|
-
return
|
|
124
|
+
return utils_1.noop;
|
|
125
125
|
}
|
|
126
126
|
var handler = function (event) {
|
|
127
127
|
var key = event.key, oldValue = event.oldValue, newValue = event.newValue;
|
package/package.json
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
"name": "@koine/browser",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"main": "./node/index.js",
|
|
5
|
-
"
|
|
6
|
-
"dependencies": {
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"dependencies": {},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"@koine/utils": "1.1.0",
|
|
9
|
+
"ts-debounce": "4.0.0",
|
|
10
|
+
"type-fest": "3.5.3",
|
|
11
|
+
"date-fns-tz": "1.3.7",
|
|
12
|
+
"tslib": "2.5.0"
|
|
12
13
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"module": "./index.js",
|
|
16
|
-
"types": "./index.d.ts"
|
|
14
|
+
"version": "1.1.0",
|
|
15
|
+
"module": "./index.js"
|
|
17
16
|
}
|
package/storage.d.ts
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const storage: {
|
|
5
5
|
l: {
|
|
6
|
-
get: <TValue>(key:
|
|
7
|
-
set: <TValue_1>(key:
|
|
8
|
-
remove: (key:
|
|
9
|
-
has: (key:
|
|
6
|
+
get: <TKey extends string, TValue = any>(key: TKey, transform?: ((value: string) => TValue) | undefined, defaultValue?: TValue | null | undefined) => NonNullable<TValue> | null;
|
|
7
|
+
set: <TKey_1 extends string, TValue_1 = any>(key: TKey_1, value?: TValue_1 | undefined, transform?: (value: any) => string) => void;
|
|
8
|
+
remove: <TKey_2 extends string>(key: TKey_2) => void;
|
|
9
|
+
has: <TKey_3 extends string, TValue_2 = any>(key: TKey_3, defaultValue?: TValue_2 | undefined) => boolean | NonNullable<TValue_2>;
|
|
10
10
|
};
|
|
11
11
|
s: {
|
|
12
|
-
get: <TValue>(key:
|
|
13
|
-
set: <TValue_1>(key:
|
|
14
|
-
remove: (key:
|
|
15
|
-
has: (key:
|
|
12
|
+
get: <TKey extends string, TValue = any>(key: TKey, transform?: ((value: string) => TValue) | undefined, defaultValue?: TValue | null | undefined) => NonNullable<TValue> | null;
|
|
13
|
+
set: <TKey_1 extends string, TValue_1 = any>(key: TKey_1, value?: TValue_1 | undefined, transform?: (value: any) => string) => void;
|
|
14
|
+
remove: <TKey_2 extends string>(key: TKey_2) => void;
|
|
15
|
+
has: <TKey_3 extends string, TValue_2 = any>(key: TKey_3, defaultValue?: TValue_2 | undefined) => boolean | NonNullable<TValue_2>;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
export default storage;
|
package/storageClient.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export type StorageClientConfig = Record<string, any>;
|
|
1
2
|
/**
|
|
2
3
|
* Super minifiable `local/session Storage` client creator with SSR safety
|
|
3
4
|
*/
|
|
4
|
-
export declare const storageClient: (useSessionStorage?: boolean) => {
|
|
5
|
-
get: <TValue>(key:
|
|
6
|
-
set: <TValue_1>(key:
|
|
7
|
-
remove: (key:
|
|
8
|
-
has: (key:
|
|
5
|
+
export declare const storageClient: <TConfig extends StorageClientConfig = StorageClientConfig>(useSessionStorage?: boolean) => {
|
|
6
|
+
get: <TKey extends Extract<keyof TConfig, string>, TValue = TConfig[TKey]>(key: TKey, transform?: ((value: string) => TValue) | undefined, defaultValue?: TValue | null | undefined) => NonNullable<TValue> | null;
|
|
7
|
+
set: <TKey_1 extends Extract<keyof TConfig, string>, TValue_1 = TConfig[TKey_1]>(key: TKey_1, value?: TValue_1 | undefined, transform?: (value: any) => string) => void;
|
|
8
|
+
remove: <TKey_2 extends Extract<keyof TConfig, string>>(key: TKey_2) => void;
|
|
9
|
+
has: <TKey_3 extends Extract<keyof TConfig, string>, TValue_2 = TConfig[TKey_3]>(key: TKey_3, defaultValue?: TValue_2 | undefined) => boolean | NonNullable<TValue_2>;
|
|
9
10
|
};
|
|
10
11
|
export default storageClient;
|