@koine/browser 2.0.0-beta.9 → 2.0.0-beta.90
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/README.md +1 -1
- package/createStorage.cjs.d.ts +2 -0
- package/createStorage.cjs.default.js +1 -0
- package/createStorage.cjs.js +51 -0
- package/createStorage.cjs.mjs +2 -0
- package/createStorage.d.ts +3 -45
- package/createStorage.esm.js +46 -0
- package/getZonedDate.cjs.d.ts +2 -0
- package/getZonedDate.cjs.default.js +1 -0
- package/{getZonedDate.mjs → getZonedDate.cjs.js} +15 -19
- package/getZonedDate.cjs.mjs +2 -0
- package/getZonedDate.d.ts +1 -15
- package/getZonedDate.esm.js +22 -0
- package/gtag.cjs.d.ts +2 -0
- package/gtag.cjs.default.js +1 -0
- package/gtag.cjs.js +22 -0
- package/gtag.cjs.mjs +2 -0
- package/gtag.d.ts +2 -0
- package/gtag.esm.js +17 -0
- package/gtagPageview.cjs.d.ts +2 -0
- package/gtagPageview.cjs.default.js +1 -0
- package/gtagPageview.cjs.js +13 -0
- package/gtagPageview.cjs.mjs +2 -0
- package/gtagPageview.d.ts +1 -4
- package/gtagPageview.esm.js +8 -0
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +45 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +4 -1
- package/index.esm.js +20 -0
- package/isIE.cjs.d.ts +2 -0
- package/isIE.cjs.default.js +1 -0
- package/isIE.cjs.js +14 -0
- package/isIE.cjs.mjs +2 -0
- package/isIE.d.ts +1 -6
- package/isIE.esm.js +9 -0
- package/isMobile.cjs.d.ts +2 -0
- package/isMobile.cjs.default.js +1 -0
- package/isMobile.cjs.js +16 -0
- package/isMobile.cjs.mjs +2 -0
- package/isMobile.d.ts +1 -6
- package/isMobile.esm.js +11 -0
- package/listenUrlSearch.cjs.d.ts +2 -0
- package/listenUrlSearch.cjs.default.js +1 -0
- package/listenUrlSearch.cjs.js +32 -0
- package/listenUrlSearch.cjs.mjs +2 -0
- package/listenUrlSearch.d.ts +3 -0
- package/listenUrlSearch.esm.js +27 -0
- package/listenUrlSearchParams.cjs.d.ts +2 -0
- package/listenUrlSearchParams.cjs.default.js +1 -0
- package/listenUrlSearchParams.cjs.js +16 -0
- package/listenUrlSearchParams.cjs.mjs +2 -0
- package/listenUrlSearchParams.d.ts +2 -0
- package/listenUrlSearchParams.esm.js +11 -0
- package/navigateToHash.cjs.d.ts +2 -0
- package/navigateToHash.cjs.default.js +1 -0
- package/navigateToHash.cjs.js +15 -0
- package/navigateToHash.cjs.mjs +2 -0
- package/navigateToHash.d.ts +1 -7
- package/navigateToHash.esm.js +10 -0
- package/navigateToHashParams.cjs.d.ts +2 -0
- package/navigateToHashParams.cjs.default.js +1 -0
- package/navigateToHashParams.cjs.js +15 -0
- package/navigateToHashParams.cjs.mjs +2 -0
- package/navigateToHashParams.d.ts +2 -8
- package/navigateToHashParams.esm.js +10 -0
- package/navigateToMergedHashParams.cjs.d.ts +2 -0
- package/navigateToMergedHashParams.cjs.default.js +1 -0
- package/navigateToMergedHashParams.cjs.js +15 -0
- package/navigateToMergedHashParams.cjs.mjs +2 -0
- package/navigateToMergedHashParams.d.ts +2 -7
- package/navigateToMergedHashParams.esm.js +10 -0
- package/navigateToMergedParams.cjs.d.ts +2 -0
- package/navigateToMergedParams.cjs.default.js +1 -0
- package/navigateToMergedParams.cjs.js +17 -0
- package/navigateToMergedParams.cjs.mjs +2 -0
- package/navigateToMergedParams.d.ts +2 -8
- package/navigateToMergedParams.esm.js +12 -0
- package/navigateToParams.cjs.d.ts +2 -0
- package/navigateToParams.cjs.default.js +1 -0
- package/navigateToParams.cjs.js +17 -0
- package/navigateToParams.cjs.mjs +2 -0
- package/navigateToParams.d.ts +2 -9
- package/navigateToParams.esm.js +12 -0
- package/navigateToUrl.cjs.d.ts +2 -0
- package/navigateToUrl.cjs.default.js +1 -0
- package/navigateToUrl.cjs.js +12 -0
- package/navigateToUrl.cjs.mjs +2 -0
- package/navigateToUrl.d.ts +1 -6
- package/navigateToUrl.esm.js +7 -0
- package/navigateWithoutUrlParam.cjs.d.ts +2 -0
- package/navigateWithoutUrlParam.cjs.default.js +1 -0
- package/navigateWithoutUrlParam.cjs.js +17 -0
- package/navigateWithoutUrlParam.cjs.mjs +2 -0
- package/navigateWithoutUrlParam.d.ts +1 -7
- package/navigateWithoutUrlParam.esm.js +12 -0
- package/package.json +108 -10
- package/redirectTo.cjs.d.ts +2 -0
- package/redirectTo.cjs.default.js +1 -0
- package/redirectTo.cjs.js +15 -0
- package/redirectTo.cjs.mjs +2 -0
- package/redirectTo.d.ts +2 -8
- package/redirectTo.esm.js +10 -0
- package/storage.cjs.d.ts +2 -0
- package/storage.cjs.default.js +1 -0
- package/storage.cjs.js +15 -0
- package/storage.cjs.mjs +2 -0
- package/storage.d.ts +1 -4
- package/storage.esm.js +10 -0
- package/storageClient.cjs.d.ts +2 -0
- package/storageClient.cjs.default.js +1 -0
- package/storageClient.cjs.js +21 -0
- package/storageClient.cjs.mjs +2 -0
- package/storageClient.d.ts +2 -5
- package/storageClient.esm.js +16 -0
- package/createStorage.js +0 -146
- package/createStorage.mjs +0 -130
- package/getZonedDate.js +0 -37
- package/gtagPageview.js +0 -41
- package/gtagPageview.mjs +0 -23
- package/index.js +0 -72
- package/index.mjs +0 -15
- package/isIE.js +0 -31
- package/isIE.mjs +0 -16
- package/isMobile.js +0 -29
- package/isMobile.mjs +0 -14
- package/navigateToHash.js +0 -25
- package/navigateToHash.mjs +0 -11
- package/navigateToHashParams.js +0 -33
- package/navigateToHashParams.mjs +0 -19
- package/navigateToMergedHashParams.js +0 -26
- package/navigateToMergedHashParams.mjs +0 -11
- package/navigateToMergedParams.js +0 -26
- package/navigateToMergedParams.mjs +0 -12
- package/navigateToParams.js +0 -30
- package/navigateToParams.mjs +0 -17
- package/navigateToUrl.js +0 -28
- package/navigateToUrl.mjs +0 -10
- package/navigateWithoutUrlParam.js +0 -32
- package/navigateWithoutUrlParam.mjs +0 -18
- package/redirectTo.js +0 -28
- package/redirectTo.mjs +0 -14
- package/storage.js +0 -25
- package/storage.mjs +0 -8
- package/storageClient.js +0 -112
- package/storageClient.mjs +0 -95
- package/typings.d.ts +0 -12
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# @koine/
|
|
1
|
+
# @koine/i18n
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./createStorage.cjs.js').default;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
var dom = require('@koine/dom');
|
|
7
|
+
var storage = require('./storage.cjs.js');
|
|
8
|
+
require('./storageClient.cjs.js');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @category storage
|
|
12
|
+
*//**
|
|
13
|
+
* Utility to create a storage instance to interact with `localStorage` using
|
|
14
|
+
* encrypted (encoded) key/values.
|
|
15
|
+
*
|
|
16
|
+
* @category storage
|
|
17
|
+
*/let createStorage=(a,n)=>{let c=n?storage.storage.s:storage.storage.l,m=Object.keys(a).reduce((e,o)=>({...e,[o]:utils.encode(o)}),{});return {/**
|
|
18
|
+
* Get all storage value (it uses `localStorage.get()`).
|
|
19
|
+
*
|
|
20
|
+
* Unparseable values with `JSON.parse()` return their value as it is.
|
|
21
|
+
* On ssr or if the given `key` argument is not found `defaultValue` is
|
|
22
|
+
* returned, otherwise `null`.
|
|
23
|
+
*/get:(t,o)=>c.get(m[t],utils.decode,o),/**
|
|
24
|
+
* Get all storage values (it uses `localStorage.get()`).
|
|
25
|
+
*
|
|
26
|
+
* `undefined` and `null` values are not returned.
|
|
27
|
+
*/getAll(e){if(!utils.isBrowser)return "development"===process.env.NODE_ENV&&console.log("[@koine/utils:createStorage] attempt to use 'getAll' outside of browser."),{};let t={};for(let o in m){let s=this.get(o),l=e?.[o];utils.isNullOrUndefined(s)?l&&// NOTE: without the assertion typedoc does not compile
|
|
28
|
+
(t[o]=l):t[o]=s;}return t},/**
|
|
29
|
+
* Set a storage value (it uses `localStorage.set()`).
|
|
30
|
+
*
|
|
31
|
+
* Non-string values are stringified with `JSON.stringify()`
|
|
32
|
+
*/set(e,o){c.set(m[e],o,utils.encode);},/**
|
|
33
|
+
* Set all given storage values (it uses `localStorage.set()`).
|
|
34
|
+
*
|
|
35
|
+
* Non-string values are stringified with `JSON.stringify()`, `undefined`
|
|
36
|
+
* and `null` values are removed from the storage
|
|
37
|
+
*/setMany(e){if("development"!==process.env.NODE_ENV||utils.isBrowser||console.log("[@koine/utils:createStorage] attempt to use 'setMany' outside of browser."),utils.isBrowser)for(let t in e){let o=e[t];utils.isNullOrUndefined(o)?this.remove(t):this.set(t,o);}},/**
|
|
38
|
+
* Check if a storage value is _truthy_ (it uses `localStorage.get()`).
|
|
39
|
+
*/has:e=>c.has(m[e]),/**
|
|
40
|
+
* Remove a storage value (it uses `localStorage.remove()`).
|
|
41
|
+
*/remove(e){c.remove(m[e]);},/**
|
|
42
|
+
* Clear all storage values (it uses `localStorage.remove()`).
|
|
43
|
+
*/clear(){if("development"!==process.env.NODE_ENV||utils.isBrowser||console.log("[@koine/utils:createStorage] attempt to use 'clear' outside of browser."),utils.isBrowser)for(let e in m)c.remove(m[e]);},/**
|
|
44
|
+
* Watch a storage value changes, this needs to be executed only in browser
|
|
45
|
+
* context (it uses `window.addEventListener("storage")`).
|
|
46
|
+
*
|
|
47
|
+
* Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
|
|
48
|
+
*/watch:(e,t,r)=>utils.isBrowser?dom.on(window,"storage",o=>{let{key:s,oldValue:l,newValue:i}=o;s===m[e]&&(l&&!i?t?.():!l&&i&&r?.());}):("development"===process.env.NODE_ENV&&console.log("[@koine/utils:createStorage] attempt to use 'watch' outside of browser."),utils.noop)}};
|
|
49
|
+
|
|
50
|
+
exports.createStorage = createStorage;
|
|
51
|
+
exports["default"] = createStorage;
|
package/createStorage.d.ts
CHANGED
|
@@ -1,54 +1,12 @@
|
|
|
1
1
|
export type CreateStorageConfig = Record<string, any>;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare const createStorage: <T extends CreateStorageConfig>(config: Partial<T>, useSessionStorage?: boolean) => {
|
|
7
|
-
/**
|
|
8
|
-
* Get all storage value (it uses `localStorage.get()`).
|
|
9
|
-
*
|
|
10
|
-
* Unparseable values with `JSON.parse()` return their value as it is.
|
|
11
|
-
* On ssr or if the given `key` argument is not found `defaultValue` is
|
|
12
|
-
* returned, otherwise `null`.
|
|
13
|
-
*/
|
|
14
|
-
get<TKey extends Extract<keyof T, string>>(key: TKey, defaultValue?: T[TKey] | null | undefined): T[TKey] | null;
|
|
15
|
-
/**
|
|
16
|
-
* Get all storage values (it uses `localStorage.get()`).
|
|
17
|
-
*
|
|
18
|
-
* `undefined` and `null` values are not returned.
|
|
19
|
-
*/
|
|
20
|
-
getAll(defaultValues?: Partial<T> | undefined): T;
|
|
21
|
-
/**
|
|
22
|
-
* Set a storage value (it uses `localStorage.set()`).
|
|
23
|
-
*
|
|
24
|
-
* Non-string values are stringified with `JSON.stringify()`
|
|
25
|
-
*/
|
|
2
|
+
export declare let createStorage: <T extends CreateStorageConfig>(config: Partial<T>, useSessionStorage?: boolean) => {
|
|
3
|
+
get<TKey extends Extract<keyof T, string>>(key: TKey, defaultValue?: null | T[TKey]): T[TKey] | null;
|
|
4
|
+
getAll(defaultValues?: Partial<T>): T;
|
|
26
5
|
set<TKey_1 extends Extract<keyof T, string>>(key: TKey_1, value?: T[TKey_1] | undefined): void;
|
|
27
|
-
/**
|
|
28
|
-
* Set all given storage values (it uses `localStorage.set()`).
|
|
29
|
-
*
|
|
30
|
-
* Non-string values are stringified with `JSON.stringify()`, `undefined`
|
|
31
|
-
* and `null` values are removed from the storage
|
|
32
|
-
*/
|
|
33
6
|
setMany(newValues: Partial<T>): void;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a storage value is _truthy_ (it uses `localStorage.get()`).
|
|
36
|
-
*/
|
|
37
7
|
has<TKey_2 extends Extract<keyof T, string>>(key: TKey_2): any;
|
|
38
|
-
/**
|
|
39
|
-
* Remove a storage value (it uses `localStorage.remove()`).
|
|
40
|
-
*/
|
|
41
8
|
remove<TKey_3 extends Extract<keyof T, string>>(key: TKey_3): void;
|
|
42
|
-
/**
|
|
43
|
-
* Clear all storage values (it uses `localStorage.remove()`).
|
|
44
|
-
*/
|
|
45
9
|
clear(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Watch a storage value changes, this needs to be executed only in browser
|
|
48
|
-
* context (it uses `window.addEventListener("storage")`).
|
|
49
|
-
*
|
|
50
|
-
* Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
|
|
51
|
-
*/
|
|
52
10
|
watch: <TKey_4 extends keyof T>(keyToWatch: TKey_4, onRemoved?: () => void, onAdded?: () => void) => () => void | undefined;
|
|
53
11
|
};
|
|
54
12
|
export default createStorage;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { encode, decode, isBrowser, isNullOrUndefined, noop } from '@koine/utils';
|
|
2
|
+
import { on } from '@koine/dom';
|
|
3
|
+
import { storage } from './storage.esm.js';
|
|
4
|
+
import './storageClient.esm.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @category storage
|
|
8
|
+
*//**
|
|
9
|
+
* Utility to create a storage instance to interact with `localStorage` using
|
|
10
|
+
* encrypted (encoded) key/values.
|
|
11
|
+
*
|
|
12
|
+
* @category storage
|
|
13
|
+
*/let createStorage=(a,n)=>{let c=n?storage.s:storage.l,m=Object.keys(a).reduce((e,o)=>({...e,[o]:encode(o)}),{});return {/**
|
|
14
|
+
* Get all storage value (it uses `localStorage.get()`).
|
|
15
|
+
*
|
|
16
|
+
* Unparseable values with `JSON.parse()` return their value as it is.
|
|
17
|
+
* On ssr or if the given `key` argument is not found `defaultValue` is
|
|
18
|
+
* returned, otherwise `null`.
|
|
19
|
+
*/get:(t,o)=>c.get(m[t],decode,o),/**
|
|
20
|
+
* Get all storage values (it uses `localStorage.get()`).
|
|
21
|
+
*
|
|
22
|
+
* `undefined` and `null` values are not returned.
|
|
23
|
+
*/getAll(e){if(!isBrowser)return "development"===process.env.NODE_ENV&&console.log("[@koine/utils:createStorage] attempt to use 'getAll' outside of browser."),{};let t={};for(let o in m){let s=this.get(o),l=e?.[o];isNullOrUndefined(s)?l&&// NOTE: without the assertion typedoc does not compile
|
|
24
|
+
(t[o]=l):t[o]=s;}return t},/**
|
|
25
|
+
* Set a storage value (it uses `localStorage.set()`).
|
|
26
|
+
*
|
|
27
|
+
* Non-string values are stringified with `JSON.stringify()`
|
|
28
|
+
*/set(e,o){c.set(m[e],o,encode);},/**
|
|
29
|
+
* Set all given storage values (it uses `localStorage.set()`).
|
|
30
|
+
*
|
|
31
|
+
* Non-string values are stringified with `JSON.stringify()`, `undefined`
|
|
32
|
+
* and `null` values are removed from the storage
|
|
33
|
+
*/setMany(e){if("development"!==process.env.NODE_ENV||isBrowser||console.log("[@koine/utils:createStorage] attempt to use 'setMany' outside of browser."),isBrowser)for(let t in e){let o=e[t];isNullOrUndefined(o)?this.remove(t):this.set(t,o);}},/**
|
|
34
|
+
* Check if a storage value is _truthy_ (it uses `localStorage.get()`).
|
|
35
|
+
*/has:e=>c.has(m[e]),/**
|
|
36
|
+
* Remove a storage value (it uses `localStorage.remove()`).
|
|
37
|
+
*/remove(e){c.remove(m[e]);},/**
|
|
38
|
+
* Clear all storage values (it uses `localStorage.remove()`).
|
|
39
|
+
*/clear(){if("development"!==process.env.NODE_ENV||isBrowser||console.log("[@koine/utils:createStorage] attempt to use 'clear' outside of browser."),isBrowser)for(let e in m)c.remove(m[e]);},/**
|
|
40
|
+
* Watch a storage value changes, this needs to be executed only in browser
|
|
41
|
+
* context (it uses `window.addEventListener("storage")`).
|
|
42
|
+
*
|
|
43
|
+
* Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
|
|
44
|
+
*/watch:(e,t,r)=>isBrowser?on(window,"storage",o=>{let{key:s,oldValue:l,newValue:i}=o;s===m[e]&&(l&&!i?t?.():!l&&i&&r?.());}):("development"===process.env.NODE_ENV&&console.log("[@koine/utils:createStorage] attempt to use 'watch' outside of browser."),noop)}};
|
|
45
|
+
|
|
46
|
+
export { createStorage, createStorage as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./getZonedDate.cjs.js').default;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
|
|
7
|
+
// import utcToZonedTime from "date-fns-tz/utcToZonedTime";
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
let t=(e,t)=>e;/**
|
|
4
10
|
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
5
11
|
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
6
12
|
* API. It gracefully falls back returning a _non-timezone-based_ `Date`.
|
|
@@ -13,19 +19,9 @@ import isBrowser from "@koine/utils/isBrowser";
|
|
|
13
19
|
*
|
|
14
20
|
* @param dateString A parseable date as string, `Z` is automatically suffixed if not present to correctly get time zone based time from a UTC date.
|
|
15
21
|
* @param timeZone Optionally pass a timeZone (e.g. from user preference or from the server), it falls back trying to read it from the `Intl` browwser native API.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
23
|
-
console.warn("[@koine/utils:getZonedDate] failed reading timeZone, error", e);
|
|
24
|
-
}
|
|
25
|
-
// no need to do anything here, it just means `Intl` failed, probably
|
|
26
|
-
// because the browser does not support it
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return timeZone ? utcToZonedTime(new Date(dateString), timeZone) : new Date(dateString);
|
|
30
|
-
}
|
|
31
|
-
export default getZonedDate;
|
|
22
|
+
*/let getZonedDate=(o="",n)=>{if(o.endsWith("Z")||(o+="Z"),!n&&utils.isBrowser)try{n=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch(e){"development"===process.env.NODE_ENV&&console.warn("[@koine/browser:getZonedDate] failed reading timeZone, error",e);}// no need to do anything here, it just means `Intl` failed, probably
|
|
23
|
+
// because the browser does not support it
|
|
24
|
+
return n?t(new Date(o)):new Date(o)};
|
|
25
|
+
|
|
26
|
+
exports["default"] = getZonedDate;
|
|
27
|
+
exports.getZonedDate = getZonedDate;
|
package/getZonedDate.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
3
|
-
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
4
|
-
* API. It gracefully falls back returning a _non-timezone-based_ `Date`.
|
|
5
|
-
*
|
|
6
|
-
* @category date
|
|
7
|
-
*
|
|
8
|
-
* @resources
|
|
9
|
-
* - to get the timeZone client side see [this article](https://attacomsian.com/blog/javascript-current-timezone)
|
|
10
|
-
* - for converting the date based on the time zone [date-fns docs](https://date-fns.org/v2.27.0/docs/Time-Zones) and [date-fns-tz docs](https://github.com/marnusw/date-fns-tz)
|
|
11
|
-
*
|
|
12
|
-
* @param dateString A parseable date as string, `Z` is automatically suffixed if not present to correctly get time zone based time from a UTC date.
|
|
13
|
-
* @param timeZone Optionally pass a timeZone (e.g. from user preference or from the server), it falls back trying to read it from the `Intl` browwser native API.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getZonedDate(dateString?: string, timeZone?: string): Date;
|
|
1
|
+
export declare let getZonedDate: (dateString?: string, timeZone?: string) => Date;
|
|
16
2
|
export default getZonedDate;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isBrowser } from '@koine/utils';
|
|
2
|
+
|
|
3
|
+
// import utcToZonedTime from "date-fns-tz/utcToZonedTime";
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
let t=(e,t)=>e;/**
|
|
6
|
+
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
7
|
+
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
8
|
+
* API. It gracefully falls back returning a _non-timezone-based_ `Date`.
|
|
9
|
+
*
|
|
10
|
+
* @category date
|
|
11
|
+
*
|
|
12
|
+
* @resources
|
|
13
|
+
* - to get the timeZone client side see [this article](https://attacomsian.com/blog/javascript-current-timezone)
|
|
14
|
+
* - for converting the date based on the time zone [date-fns docs](https://date-fns.org/v2.27.0/docs/Time-Zones) and [date-fns-tz docs](https://github.com/marnusw/date-fns-tz)
|
|
15
|
+
*
|
|
16
|
+
* @param dateString A parseable date as string, `Z` is automatically suffixed if not present to correctly get time zone based time from a UTC date.
|
|
17
|
+
* @param timeZone Optionally pass a timeZone (e.g. from user preference or from the server), it falls back trying to read it from the `Intl` browwser native API.
|
|
18
|
+
*/let getZonedDate=(o="",n)=>{if(o.endsWith("Z")||(o+="Z"),!n&&isBrowser)try{n=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch(e){"development"===process.env.NODE_ENV&&console.warn("[@koine/browser:getZonedDate] failed reading timeZone, error",e);}// no need to do anything here, it just means `Intl` failed, probably
|
|
19
|
+
// because the browser does not support it
|
|
20
|
+
return n?t(new Date(o)):new Date(o)};
|
|
21
|
+
|
|
22
|
+
export { getZonedDate as default, getZonedDate };
|
package/gtag.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./gtag.cjs.js').default;
|
package/gtag.cjs.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @category analytics-google
|
|
9
|
+
*
|
|
10
|
+
* If you like you could add to your globals `.d.ts` types:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* declare interface Window {
|
|
14
|
+
* gtag: <T extends unknown[]>(...args: T) => void;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/let gtag=(...o)=>{// @ts-expect-error nevermind
|
|
18
|
+
utils.isUndefined(window)||utils.isUndefined(window.gtag)?utils.noop():// @ts-expect-error nevermind
|
|
19
|
+
window.gtag(...o);};// export type GtmEventArgs = [
|
|
20
|
+
|
|
21
|
+
exports["default"] = gtag;
|
|
22
|
+
exports.gtag = gtag;
|
package/gtag.cjs.mjs
ADDED
package/gtag.d.ts
ADDED
package/gtag.esm.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isUndefined, noop } from '@koine/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @category analytics-google
|
|
5
|
+
*
|
|
6
|
+
* If you like you could add to your globals `.d.ts` types:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* declare interface Window {
|
|
10
|
+
* gtag: <T extends unknown[]>(...args: T) => void;
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/let gtag=(...o)=>{// @ts-expect-error nevermind
|
|
14
|
+
isUndefined(window)||isUndefined(window.gtag)?noop():// @ts-expect-error nevermind
|
|
15
|
+
window.gtag(...o);};// export type GtmEventArgs = [
|
|
16
|
+
|
|
17
|
+
export { gtag as default, gtag };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./gtagPageview.cjs.js').default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var gtag = require('./gtag.cjs.js');
|
|
6
|
+
require('@koine/utils');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @category analytics-google
|
|
10
|
+
*/let gtagPageview=(...t)=>gtag.gtag("event","page_view",{page_path:t[0]||location.pathname,page_title:t[1]||document.title,page_location:t[2]||location.href});// send_to: '<GA_MEASUREMENT_ID>'
|
|
11
|
+
|
|
12
|
+
exports["default"] = gtagPageview;
|
|
13
|
+
exports.gtagPageview = gtagPageview;
|
package/gtagPageview.d.ts
CHANGED
|
@@ -3,8 +3,5 @@ export type GtmPageviewArgs = [
|
|
|
3
3
|
page_title?: string,
|
|
4
4
|
page_location?: string
|
|
5
5
|
];
|
|
6
|
-
|
|
7
|
-
* @category analytics-google
|
|
8
|
-
*/
|
|
9
|
-
export declare const gtagPageview: (page_path?: string | undefined, page_title?: string | undefined, page_location?: string | undefined) => void;
|
|
6
|
+
export declare let gtagPageview: (page_path?: string | undefined, page_title?: string | undefined, page_location?: string | undefined) => void;
|
|
10
7
|
export default gtagPageview;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { gtag } from './gtag.esm.js';
|
|
2
|
+
import '@koine/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @category analytics-google
|
|
6
|
+
*/let gtagPageview=(...t)=>gtag("event","page_view",{page_path:t[0]||location.pathname,page_title:t[1]||document.title,page_location:t[2]||location.href});// send_to: '<GA_MEASUREMENT_ID>'
|
|
7
|
+
|
|
8
|
+
export { gtagPageview as default, gtagPageview };
|
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./index.cjs.js').default;
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var createStorage = require('./createStorage.cjs.js');
|
|
6
|
+
var getZonedDate = require('./getZonedDate.cjs.js');
|
|
7
|
+
var gtag = require('./gtag.cjs.js');
|
|
8
|
+
var gtagPageview = require('./gtagPageview.cjs.js');
|
|
9
|
+
var isIE = require('./isIE.cjs.js');
|
|
10
|
+
var isMobile = require('./isMobile.cjs.js');
|
|
11
|
+
var listenUrlSearch = require('./listenUrlSearch.cjs.js');
|
|
12
|
+
var listenUrlSearchParams = require('./listenUrlSearchParams.cjs.js');
|
|
13
|
+
var navigateToHash = require('./navigateToHash.cjs.js');
|
|
14
|
+
var navigateToHashParams = require('./navigateToHashParams.cjs.js');
|
|
15
|
+
var navigateToMergedHashParams = require('./navigateToMergedHashParams.cjs.js');
|
|
16
|
+
var navigateToMergedParams = require('./navigateToMergedParams.cjs.js');
|
|
17
|
+
var navigateToParams = require('./navigateToParams.cjs.js');
|
|
18
|
+
var navigateToUrl = require('./navigateToUrl.cjs.js');
|
|
19
|
+
var navigateWithoutUrlParam = require('./navigateWithoutUrlParam.cjs.js');
|
|
20
|
+
var storage = require('./storage.cjs.js');
|
|
21
|
+
var redirectTo = require('./redirectTo.cjs.js');
|
|
22
|
+
var storageClient = require('./storageClient.cjs.js');
|
|
23
|
+
require('@koine/utils');
|
|
24
|
+
require('@koine/dom');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.createStorage = createStorage.createStorage;
|
|
29
|
+
exports.getZonedDate = getZonedDate.getZonedDate;
|
|
30
|
+
exports.gtag = gtag.gtag;
|
|
31
|
+
exports.gtagPageview = gtagPageview.gtagPageview;
|
|
32
|
+
exports.isIE = isIE.isIE;
|
|
33
|
+
exports.isMobile = isMobile.isMobile;
|
|
34
|
+
exports.listenUrlSearch = listenUrlSearch.listenUrlSearch;
|
|
35
|
+
exports.listenUrlSearchParams = listenUrlSearchParams.listenUrlSearchParams;
|
|
36
|
+
exports.navigateToHash = navigateToHash.navigateToHash;
|
|
37
|
+
exports.navigateToHashParams = navigateToHashParams.navigateToHashParams;
|
|
38
|
+
exports.navigateToMergedHashParams = navigateToMergedHashParams.navigateToMergedHashParams;
|
|
39
|
+
exports.navigateToMergedParams = navigateToMergedParams.navigateToMergedParams;
|
|
40
|
+
exports.navigateToParams = navigateToParams.navigateToParams;
|
|
41
|
+
exports.navigateToUrl = navigateToUrl.navigateToUrl;
|
|
42
|
+
exports.navigateWithoutUrlParam = navigateWithoutUrlParam.navigateWithoutUrlParam;
|
|
43
|
+
exports.storage = storage.storage;
|
|
44
|
+
exports.redirectTo = redirectTo.redirectTo;
|
|
45
|
+
exports.storageClient = storageClient.storageClient;
|
package/index.cjs.mjs
ADDED
package/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { createStorage, type CreateStorageConfig } from "./createStorage";
|
|
2
2
|
export { getZonedDate } from "./getZonedDate";
|
|
3
|
+
export { gtag } from "./gtag";
|
|
3
4
|
export { gtagPageview, type GtmPageviewArgs } from "./gtagPageview";
|
|
4
5
|
export { isIE } from "./isIE";
|
|
5
6
|
export { isMobile } from "./isMobile";
|
|
7
|
+
export { listenUrlSearch } from "./listenUrlSearch";
|
|
8
|
+
export { listenUrlSearchParams } from "./listenUrlSearchParams";
|
|
6
9
|
export { navigateToHash } from "./navigateToHash";
|
|
7
10
|
export { navigateToHashParams } from "./navigateToHashParams";
|
|
8
11
|
export { navigateToMergedHashParams } from "./navigateToMergedHashParams";
|
|
@@ -10,6 +13,6 @@ export { navigateToMergedParams } from "./navigateToMergedParams";
|
|
|
10
13
|
export { navigateToParams } from "./navigateToParams";
|
|
11
14
|
export { navigateToUrl } from "./navigateToUrl";
|
|
12
15
|
export { navigateWithoutUrlParam } from "./navigateWithoutUrlParam";
|
|
13
|
-
export { redirectTo } from "./redirectTo";
|
|
14
16
|
export { storage } from "./storage";
|
|
17
|
+
export { redirectTo } from "./redirectTo";
|
|
15
18
|
export { storageClient, type StorageClientConfig } from "./storageClient";
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { createStorage } from './createStorage.esm.js';
|
|
2
|
+
export { getZonedDate } from './getZonedDate.esm.js';
|
|
3
|
+
export { gtag } from './gtag.esm.js';
|
|
4
|
+
export { gtagPageview } from './gtagPageview.esm.js';
|
|
5
|
+
export { isIE } from './isIE.esm.js';
|
|
6
|
+
export { isMobile } from './isMobile.esm.js';
|
|
7
|
+
export { listenUrlSearch } from './listenUrlSearch.esm.js';
|
|
8
|
+
export { listenUrlSearchParams } from './listenUrlSearchParams.esm.js';
|
|
9
|
+
export { navigateToHash } from './navigateToHash.esm.js';
|
|
10
|
+
export { navigateToHashParams } from './navigateToHashParams.esm.js';
|
|
11
|
+
export { navigateToMergedHashParams } from './navigateToMergedHashParams.esm.js';
|
|
12
|
+
export { navigateToMergedParams } from './navigateToMergedParams.esm.js';
|
|
13
|
+
export { navigateToParams } from './navigateToParams.esm.js';
|
|
14
|
+
export { navigateToUrl } from './navigateToUrl.esm.js';
|
|
15
|
+
export { navigateWithoutUrlParam } from './navigateWithoutUrlParam.esm.js';
|
|
16
|
+
export { storage } from './storage.esm.js';
|
|
17
|
+
export { redirectTo } from './redirectTo.esm.js';
|
|
18
|
+
export { storageClient } from './storageClient.esm.js';
|
|
19
|
+
import '@koine/utils';
|
|
20
|
+
import '@koine/dom';
|
package/isIE.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./isIE.cjs.js').default;
|
package/isIE.cjs.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @category detect
|
|
9
|
+
* @category is
|
|
10
|
+
* @see https://stackoverflow.com/a/21712356/12285349
|
|
11
|
+
*/let isIE=(t=!0)=>{if(utils.isServer)return t;let i=window.navigator.userAgent;return !!(i.indexOf("MSIE ")>0||i.indexOf("Trident/")>0)};
|
|
12
|
+
|
|
13
|
+
exports["default"] = isIE;
|
|
14
|
+
exports.isIE = isIE;
|
package/isIE.cjs.mjs
ADDED
package/isIE.d.ts
CHANGED
package/isIE.esm.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isServer } from '@koine/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @category detect
|
|
5
|
+
* @category is
|
|
6
|
+
* @see https://stackoverflow.com/a/21712356/12285349
|
|
7
|
+
*/let isIE=(t=!0)=>{if(isServer)return t;let i=window.navigator.userAgent;return !!(i.indexOf("MSIE ")>0||i.indexOf("Trident/")>0)};
|
|
8
|
+
|
|
9
|
+
export { isIE as default, isIE };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./isMobile.cjs.js').default;
|
package/isMobile.cjs.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @category detect
|
|
9
|
+
* @category is
|
|
10
|
+
* @see https://stackoverflow.com/a/3540295
|
|
11
|
+
*/let isMobile=(e=!0)=>utils.isServer?e:// /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|
|
12
|
+
// || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)
|
|
13
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
|
|
14
|
+
|
|
15
|
+
exports["default"] = isMobile;
|
|
16
|
+
exports.isMobile = isMobile;
|
package/isMobile.cjs.mjs
ADDED
package/isMobile.d.ts
CHANGED
package/isMobile.esm.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isServer } from '@koine/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @category detect
|
|
5
|
+
* @category is
|
|
6
|
+
* @see https://stackoverflow.com/a/3540295
|
|
7
|
+
*/let isMobile=(e=!0)=>isServer?e:// /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|
|
8
|
+
// || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)
|
|
9
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
|
|
10
|
+
|
|
11
|
+
export { isMobile as default, isMobile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./listenUrlSearch.cjs.js').default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@koine/utils');
|
|
6
|
+
var dom = require('@koine/dom');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Flag that tells if `history` methods have been replaced
|
|
10
|
+
*//**
|
|
11
|
+
* @param prevLocationSearch The previous URL search query e.g. `?myparam=mvalue`
|
|
12
|
+
* @param newLocationSearch The previous URL search query e.g. `?myparam=mvalue`
|
|
13
|
+
*/let r=(t,e,r)=>function(...o){if(r)return e(),t.apply(this,o);let i=t.apply(this,o);return e(),i},o=utils.isBrowser?location.search:"",i=()=>{let t=location.search;// console.log(`listenUrlSearch: "${prevSearch}" vs "${newSearch}`);
|
|
14
|
+
if(t!==o)for(let e of history.__.h.values())e(o,t);o=t;};/**
|
|
15
|
+
* Here we extend and mutate the native `window.history` object so that multiple
|
|
16
|
+
* scripts can add url change handlers without interfering each other and using
|
|
17
|
+
* the same single listener.
|
|
18
|
+
*
|
|
19
|
+
* @borrows [SO answer](https://stackoverflow.com/a/42727249/1938970)
|
|
20
|
+
*
|
|
21
|
+
* @category location
|
|
22
|
+
* @category navigation
|
|
23
|
+
* @category events
|
|
24
|
+
*
|
|
25
|
+
* @returns A de-register function to remove the handler
|
|
26
|
+
*/let listenUrlSearch=t=>(history.__||(// replace browser's history global methods
|
|
27
|
+
history.pushState=r(history.pushState,i),history.replaceState=r(history.replaceState,i),// listen native history events
|
|
28
|
+
dom.on(window,"popstate",i),// extend history object
|
|
29
|
+
history.__={h:new Set}),history.__.h.has(t)||history.__.h.add(t),()=>{history.__.h.delete(t);});
|
|
30
|
+
|
|
31
|
+
exports["default"] = listenUrlSearch;
|
|
32
|
+
exports.listenUrlSearch = listenUrlSearch;
|