@koine/browser 1.0.105 → 1.1.1

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.
@@ -1,4 +1,4 @@
1
- export declare type CreateStorageConfig = Record<string, any>;
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): boolean;
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 function () { return void 0; };
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
@@ -1,4 +1,4 @@
1
- export declare type GtmPageviewArgs = [
1
+ export type GtmPageviewArgs = [
2
2
  page_path?: string,
3
3
  page_title?: string,
4
4
  page_location?: string
@@ -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 function () { return void 0; };
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
- "typings": "./index.d.ts",
6
- "dependencies": {
7
- "@koine/utils": "1.0.105",
8
- "ts-debounce": "^4.0.0",
9
- "@koine/dom": "1.0.105",
10
- "date-fns-tz": "^1.3.7",
11
- "tslib": "^2.4.0"
5
+ "types": "./index.d.ts",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "@koine/utils": "1.1.1",
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
- "peerDependencies": {},
14
- "version": "1.0.105",
15
- "module": "./index.js",
16
- "types": "./index.d.ts"
14
+ "version": "1.1.1",
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: string, transform?: ((value: string) => TValue) | undefined, defaultValue?: TValue | null | undefined) => NonNullable<TValue> | null;
7
- set: <TValue_1>(key: string, value?: TValue_1 | undefined, transform?: (value: any) => string) => void;
8
- remove: (key: string) => void;
9
- has: (key: string, defaultValue?: boolean | undefined) => boolean;
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: string, transform?: ((value: string) => TValue) | undefined, defaultValue?: TValue | null | undefined) => NonNullable<TValue> | null;
13
- set: <TValue_1>(key: string, value?: TValue_1 | undefined, transform?: (value: any) => string) => void;
14
- remove: (key: string) => void;
15
- has: (key: string, defaultValue?: boolean | undefined) => boolean;
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;
@@ -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: string, transform?: ((value: string) => TValue) | undefined, defaultValue?: TValue | null | undefined) => NonNullable<TValue> | null;
6
- set: <TValue_1>(key: string, value?: TValue_1 | undefined, transform?: (value: any) => string) => void;
7
- remove: (key: string) => void;
8
- has: (key: string, defaultValue?: boolean) => boolean;
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;