@koine/browser 2.0.0-beta.4 → 2.0.0-beta.41
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.d.ts +1 -44
- package/getZonedDate.d.ts +1 -16
- package/gtagPageview.d.ts +1 -5
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +58 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +2 -0
- package/index.esm.js +38 -0
- package/isIE.d.ts +1 -7
- package/isMobile.d.ts +1 -7
- package/listenUrlSearch.d.ts +3 -0
- package/listenUrlSearchParams.d.ts +1 -0
- package/navigateToHash.d.ts +1 -8
- package/navigateToHashParams.d.ts +2 -9
- package/navigateToMergedHashParams.d.ts +2 -8
- package/navigateToMergedParams.d.ts +2 -9
- package/navigateToParams.d.ts +2 -10
- package/navigateToUrl.d.ts +1 -7
- package/navigateWithoutUrlParam.d.ts +1 -8
- package/package.json +15 -12
- package/redirectTo.d.ts +2 -9
- package/storage.d.ts +1 -5
- package/storageClient.d.ts +1 -5
- package/createStorage.js +0 -146
- package/createStorage.mjs +0 -130
- package/getZonedDate.js +0 -37
- package/getZonedDate.mjs +0 -31
- 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/createStorage.mjs
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import decode from "@koine/utils/decode";
|
|
2
|
-
import encode from "@koine/utils/encode";
|
|
3
|
-
import isBrowser from "@koine/utils/isBrowser";
|
|
4
|
-
import isNullOrUndefined from "@koine/utils/isNullOrUndefined";
|
|
5
|
-
import noop from "@koine/utils/noop";
|
|
6
|
-
import on from "@koine/dom/on";
|
|
7
|
-
import storage from "./storage";
|
|
8
|
-
/**
|
|
9
|
-
* Utility to create a storage instance to interact with `localStorage` using
|
|
10
|
-
* encrypted (encoded) key/values.
|
|
11
|
-
*/ export const createStorage = (config, useSessionStorage)=>{
|
|
12
|
-
const client = useSessionStorage ? storage.s : storage.l;
|
|
13
|
-
const keys = Object.keys(config).reduce((map, key)=>({
|
|
14
|
-
...map,
|
|
15
|
-
[key]: encode(key)
|
|
16
|
-
}), {});
|
|
17
|
-
return {
|
|
18
|
-
/**
|
|
19
|
-
* Get all storage value (it uses `localStorage.get()`).
|
|
20
|
-
*
|
|
21
|
-
* Unparseable values with `JSON.parse()` return their value as it is.
|
|
22
|
-
* On ssr or if the given `key` argument is not found `defaultValue` is
|
|
23
|
-
* returned, otherwise `null`.
|
|
24
|
-
*/ get (key, defaultValue) {
|
|
25
|
-
return client.get(keys[key], decode, defaultValue);
|
|
26
|
-
},
|
|
27
|
-
/**
|
|
28
|
-
* Get all storage values (it uses `localStorage.get()`).
|
|
29
|
-
*
|
|
30
|
-
* `undefined` and `null` values are not returned.
|
|
31
|
-
*/ getAll (defaultValues) {
|
|
32
|
-
if (!isBrowser) {
|
|
33
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
34
|
-
console.log(`[@koine/utils:createStorage] attempt to use 'getAll' outside of browser.`);
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
const all = {};
|
|
39
|
-
for(const key in keys){
|
|
40
|
-
const value = this.get(key);
|
|
41
|
-
const defaultValue = defaultValues?.[key];
|
|
42
|
-
if (!isNullOrUndefined(value)) {
|
|
43
|
-
all[key] = value;
|
|
44
|
-
} else if (defaultValue) {
|
|
45
|
-
all[key] = defaultValue;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return all;
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* Set a storage value (it uses `localStorage.set()`).
|
|
52
|
-
*
|
|
53
|
-
* Non-string values are stringified with `JSON.stringify()`
|
|
54
|
-
*/ set (key, value) {
|
|
55
|
-
client.set(keys[key], value, encode);
|
|
56
|
-
},
|
|
57
|
-
/**
|
|
58
|
-
* Set all given storage values (it uses `localStorage.set()`).
|
|
59
|
-
*
|
|
60
|
-
* Non-string values are stringified with `JSON.stringify()`, `undefined`
|
|
61
|
-
* and `null` values are removed from the storage
|
|
62
|
-
*/ setMany (newValues) {
|
|
63
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
64
|
-
if (!isBrowser) {
|
|
65
|
-
console.log(`[@koine/utils:createStorage] attempt to use 'setMany' outside of browser.`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (isBrowser) {
|
|
69
|
-
for(const key in newValues){
|
|
70
|
-
const value = newValues[key];
|
|
71
|
-
if (!isNullOrUndefined(value)) {
|
|
72
|
-
this.set(key, value);
|
|
73
|
-
} else {
|
|
74
|
-
this.remove(key);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
/**
|
|
80
|
-
* Check if a storage value is _truthy_ (it uses `localStorage.get()`).
|
|
81
|
-
*/ has (key) {
|
|
82
|
-
return client.has(keys[key]);
|
|
83
|
-
},
|
|
84
|
-
/**
|
|
85
|
-
* Remove a storage value (it uses `localStorage.remove()`).
|
|
86
|
-
*/ remove (key) {
|
|
87
|
-
client.remove(keys[key]);
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Clear all storage values (it uses `localStorage.remove()`).
|
|
91
|
-
*/ clear () {
|
|
92
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
93
|
-
if (!isBrowser) {
|
|
94
|
-
console.log(`[@koine/utils:createStorage] attempt to use 'clear' outside of browser.`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (isBrowser) {
|
|
98
|
-
for(const key in keys){
|
|
99
|
-
client.remove(keys[key]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
/**
|
|
104
|
-
* Watch a storage value changes, this needs to be executed only in browser
|
|
105
|
-
* context (it uses `window.addEventListener("storage")`).
|
|
106
|
-
*
|
|
107
|
-
* Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
|
|
108
|
-
*/ watch: (keyToWatch, onRemoved, onAdded)=>{
|
|
109
|
-
if (!isBrowser) {
|
|
110
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
111
|
-
console.log(`[@koine/utils:createStorage] attempt to use 'watch' outside of browser.`);
|
|
112
|
-
}
|
|
113
|
-
return noop;
|
|
114
|
-
}
|
|
115
|
-
const handler = (event)=>{
|
|
116
|
-
const { key, oldValue, newValue } = event;
|
|
117
|
-
if (key === keys[keyToWatch]) {
|
|
118
|
-
if (oldValue && !newValue) {
|
|
119
|
-
onRemoved?.();
|
|
120
|
-
} else if (!oldValue && newValue) {
|
|
121
|
-
onAdded?.();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const listener = on(window, "storage", handler);
|
|
126
|
-
return listener;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
export default createStorage;
|
package/getZonedDate.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
getZonedDate: function() {
|
|
13
|
-
return getZonedDate;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _utcToZonedTime = /*#__PURE__*/ _interop_require_default._(require("date-fns-tz/utcToZonedTime"));
|
|
21
|
-
const _isBrowser = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/isBrowser"));
|
|
22
|
-
function getZonedDate(dateString = "", timeZone) {
|
|
23
|
-
if (!dateString.endsWith("Z")) dateString += "Z";
|
|
24
|
-
if (!timeZone && _isBrowser.default) {
|
|
25
|
-
try {
|
|
26
|
-
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
27
|
-
} catch (e) {
|
|
28
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
29
|
-
console.warn("[@koine/utils:getZonedDate] failed reading timeZone, error", e);
|
|
30
|
-
}
|
|
31
|
-
// no need to do anything here, it just means `Intl` failed, probably
|
|
32
|
-
// because the browser does not support it
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return timeZone ? (0, _utcToZonedTime.default)(new Date(dateString), timeZone) : new Date(dateString);
|
|
36
|
-
}
|
|
37
|
-
const _default = getZonedDate;
|
package/getZonedDate.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import utcToZonedTime from "date-fns-tz/utcToZonedTime";
|
|
2
|
-
import isBrowser from "@koine/utils/isBrowser";
|
|
3
|
-
/**
|
|
4
|
-
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
5
|
-
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
6
|
-
* API. It gracefully falls back returning a _non-timezone-based_ `Date`.
|
|
7
|
-
*
|
|
8
|
-
* @category date
|
|
9
|
-
*
|
|
10
|
-
* @resources
|
|
11
|
-
* - to get the timeZone client side see [this article](https://attacomsian.com/blog/javascript-current-timezone)
|
|
12
|
-
* - 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)
|
|
13
|
-
*
|
|
14
|
-
* @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
|
-
* @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
|
-
*/ export function getZonedDate(dateString = "", timeZone) {
|
|
17
|
-
if (!dateString.endsWith("Z")) dateString += "Z";
|
|
18
|
-
if (!timeZone && isBrowser) {
|
|
19
|
-
try {
|
|
20
|
-
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
21
|
-
} catch (e) {
|
|
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;
|
package/gtagPageview.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
gtagPageview: function() {
|
|
13
|
-
return gtagPageview;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default // export type GtmEventArgs = [
|
|
17
|
-
// eventCategory?: string,
|
|
18
|
-
// eventAction?: string,
|
|
19
|
-
// eventLabel?: string,
|
|
20
|
-
// eventValue?: string
|
|
21
|
-
// ];
|
|
22
|
-
// export const event = (...args: GtmEventArgs) => {
|
|
23
|
-
// if (!isUndefined(window) && !isUndefined(window.gtag)) {
|
|
24
|
-
// window.gtag("send", "event", ...args);
|
|
25
|
-
// }
|
|
26
|
-
// };
|
|
27
|
-
;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
31
|
-
const _isUndefined = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/isUndefined"));
|
|
32
|
-
const gtagPageview = (...args)=>{
|
|
33
|
-
if (!(0, _isUndefined.default)(window) && !(0, _isUndefined.default)(window.gtag)) {
|
|
34
|
-
window.gtag("event", "page_view", {
|
|
35
|
-
page_path: args[0] || location.pathname,
|
|
36
|
-
page_title: args[1] || document.title,
|
|
37
|
-
page_location: args[2] || location.href
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const _default = gtagPageview;
|
package/gtagPageview.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import isUndefined from "@koine/utils/isUndefined";
|
|
2
|
-
/**
|
|
3
|
-
* @category analytics-google
|
|
4
|
-
*/ export const gtagPageview = (...args)=>{
|
|
5
|
-
if (!isUndefined(window) && !isUndefined(window.gtag)) {
|
|
6
|
-
window.gtag("event", "page_view", {
|
|
7
|
-
page_path: args[0] || location.pathname,
|
|
8
|
-
page_title: args[1] || document.title,
|
|
9
|
-
page_location: args[2] || location.href
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export default gtagPageview; // export type GtmEventArgs = [
|
|
14
|
-
// eventCategory?: string,
|
|
15
|
-
// eventAction?: string,
|
|
16
|
-
// eventLabel?: string,
|
|
17
|
-
// eventValue?: string
|
|
18
|
-
// ];
|
|
19
|
-
// export const event = (...args: GtmEventArgs) => {
|
|
20
|
-
// if (!isUndefined(window) && !isUndefined(window.gtag)) {
|
|
21
|
-
// window.gtag("send", "event", ...args);
|
|
22
|
-
// }
|
|
23
|
-
// };
|
package/index.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
createStorage: function() {
|
|
13
|
-
return _createStorage.createStorage;
|
|
14
|
-
},
|
|
15
|
-
getZonedDate: function() {
|
|
16
|
-
return _getZonedDate.getZonedDate;
|
|
17
|
-
},
|
|
18
|
-
gtagPageview: function() {
|
|
19
|
-
return _gtagPageview.gtagPageview;
|
|
20
|
-
},
|
|
21
|
-
isIE: function() {
|
|
22
|
-
return _isIE.isIE;
|
|
23
|
-
},
|
|
24
|
-
isMobile: function() {
|
|
25
|
-
return _isMobile.isMobile;
|
|
26
|
-
},
|
|
27
|
-
navigateToHash: function() {
|
|
28
|
-
return _navigateToHash.navigateToHash;
|
|
29
|
-
},
|
|
30
|
-
navigateToHashParams: function() {
|
|
31
|
-
return _navigateToHashParams.navigateToHashParams;
|
|
32
|
-
},
|
|
33
|
-
navigateToMergedHashParams: function() {
|
|
34
|
-
return _navigateToMergedHashParams.navigateToMergedHashParams;
|
|
35
|
-
},
|
|
36
|
-
navigateToMergedParams: function() {
|
|
37
|
-
return _navigateToMergedParams.navigateToMergedParams;
|
|
38
|
-
},
|
|
39
|
-
navigateToParams: function() {
|
|
40
|
-
return _navigateToParams.navigateToParams;
|
|
41
|
-
},
|
|
42
|
-
navigateToUrl: function() {
|
|
43
|
-
return _navigateToUrl.navigateToUrl;
|
|
44
|
-
},
|
|
45
|
-
navigateWithoutUrlParam: function() {
|
|
46
|
-
return _navigateWithoutUrlParam.navigateWithoutUrlParam;
|
|
47
|
-
},
|
|
48
|
-
redirectTo: function() {
|
|
49
|
-
return _redirectTo.redirectTo;
|
|
50
|
-
},
|
|
51
|
-
storage: function() {
|
|
52
|
-
return _storage.storage;
|
|
53
|
-
},
|
|
54
|
-
storageClient: function() {
|
|
55
|
-
return _storageClient.storageClient;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
const _createStorage = require("./createStorage");
|
|
59
|
-
const _getZonedDate = require("./getZonedDate");
|
|
60
|
-
const _gtagPageview = require("./gtagPageview");
|
|
61
|
-
const _isIE = require("./isIE");
|
|
62
|
-
const _isMobile = require("./isMobile");
|
|
63
|
-
const _navigateToHash = require("./navigateToHash");
|
|
64
|
-
const _navigateToHashParams = require("./navigateToHashParams");
|
|
65
|
-
const _navigateToMergedHashParams = require("./navigateToMergedHashParams");
|
|
66
|
-
const _navigateToMergedParams = require("./navigateToMergedParams");
|
|
67
|
-
const _navigateToParams = require("./navigateToParams");
|
|
68
|
-
const _navigateToUrl = require("./navigateToUrl");
|
|
69
|
-
const _navigateWithoutUrlParam = require("./navigateWithoutUrlParam");
|
|
70
|
-
const _redirectTo = require("./redirectTo");
|
|
71
|
-
const _storage = require("./storage");
|
|
72
|
-
const _storageClient = require("./storageClient");
|
package/index.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { createStorage } from "./createStorage";
|
|
2
|
-
export { getZonedDate } from "./getZonedDate";
|
|
3
|
-
export { gtagPageview } from "./gtagPageview";
|
|
4
|
-
export { isIE } from "./isIE";
|
|
5
|
-
export { isMobile } from "./isMobile";
|
|
6
|
-
export { navigateToHash } from "./navigateToHash";
|
|
7
|
-
export { navigateToHashParams } from "./navigateToHashParams";
|
|
8
|
-
export { navigateToMergedHashParams } from "./navigateToMergedHashParams";
|
|
9
|
-
export { navigateToMergedParams } from "./navigateToMergedParams";
|
|
10
|
-
export { navigateToParams } from "./navigateToParams";
|
|
11
|
-
export { navigateToUrl } from "./navigateToUrl";
|
|
12
|
-
export { navigateWithoutUrlParam } from "./navigateWithoutUrlParam";
|
|
13
|
-
export { redirectTo } from "./redirectTo";
|
|
14
|
-
export { storage } from "./storage";
|
|
15
|
-
export { storageClient } from "./storageClient";
|
package/isIE.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
isIE: function() {
|
|
13
|
-
return isIE;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _isServer = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/isServer"));
|
|
21
|
-
function isIE(ssrValue = true) {
|
|
22
|
-
if (_isServer.default) {
|
|
23
|
-
return ssrValue;
|
|
24
|
-
}
|
|
25
|
-
const ua = window.navigator.userAgent;
|
|
26
|
-
if (ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const _default = isIE;
|
package/isIE.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import isServer from "@koine/utils/isServer";
|
|
2
|
-
/**
|
|
3
|
-
* @category detect
|
|
4
|
-
* @category is
|
|
5
|
-
* @see https://stackoverflow.com/a/21712356/12285349
|
|
6
|
-
*/ export function isIE(ssrValue = true) {
|
|
7
|
-
if (isServer) {
|
|
8
|
-
return ssrValue;
|
|
9
|
-
}
|
|
10
|
-
const ua = window.navigator.userAgent;
|
|
11
|
-
if (ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
export default isIE;
|
package/isMobile.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
isMobile: function() {
|
|
13
|
-
return isMobile;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _isServer = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/isServer"));
|
|
21
|
-
function isMobile(ssrValue = true) {
|
|
22
|
-
if (_isServer.default) {
|
|
23
|
-
return ssrValue;
|
|
24
|
-
}
|
|
25
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
|
|
26
|
-
// return /(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)
|
|
27
|
-
// || /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)
|
|
28
|
-
}
|
|
29
|
-
const _default = isMobile;
|
package/isMobile.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import isServer from "@koine/utils/isServer";
|
|
2
|
-
/**
|
|
3
|
-
* @category detect
|
|
4
|
-
* @category is
|
|
5
|
-
* @see https://stackoverflow.com/a/3540295
|
|
6
|
-
*/ export function isMobile(ssrValue = true) {
|
|
7
|
-
if (isServer) {
|
|
8
|
-
return ssrValue;
|
|
9
|
-
}
|
|
10
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
|
|
11
|
-
// return /(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
|
-
}
|
|
14
|
-
export default isMobile;
|
package/navigateToHash.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
navigateToHash: function() {
|
|
13
|
-
return navigateToHash;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _navigateToUrl = /*#__PURE__*/ _interop_require_default._(require("./navigateToUrl"));
|
|
21
|
-
function navigateToHash(hash = "") {
|
|
22
|
-
const { pathname, search } = location;
|
|
23
|
-
(0, _navigateToUrl.default)(pathname + (search ? "?" + search : "") + (hash ? "#" + hash : ""), true);
|
|
24
|
-
}
|
|
25
|
-
const _default = navigateToHash;
|
package/navigateToHash.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import navigateToUrl from "./navigateToUrl";
|
|
2
|
-
/**
|
|
3
|
-
* It updates the browser's location hash by replacing the history state.
|
|
4
|
-
* The non-silent standard way would simply be `location.hash = "#new-hash"`
|
|
5
|
-
*
|
|
6
|
-
* @category location
|
|
7
|
-
*/ export function navigateToHash(hash = "") {
|
|
8
|
-
const { pathname, search } = location;
|
|
9
|
-
navigateToUrl(pathname + (search ? "?" + search : "") + (hash ? "#" + hash : ""), true);
|
|
10
|
-
}
|
|
11
|
-
export default navigateToHash;
|
package/navigateToHashParams.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
navigateToHashParams: function() {
|
|
13
|
-
return navigateToHashParams;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _buildUrlQueryString = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/buildUrlQueryString"));
|
|
21
|
-
const _getUrlHashPathname = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/getUrlHashPathname"));
|
|
22
|
-
function navigateToHashParams(params = {}, hash = "") {
|
|
23
|
-
const useLocation = !hash;
|
|
24
|
-
hash = hash || location.hash;
|
|
25
|
-
const hashQueryLess = (0, _getUrlHashPathname.default)(hash);
|
|
26
|
-
const queryString = typeof params === "string" ? params : (0, _buildUrlQueryString.default)(params);
|
|
27
|
-
const newHash = "#/" + hashQueryLess + queryString;
|
|
28
|
-
if (useLocation) {
|
|
29
|
-
location.hash = newHash;
|
|
30
|
-
}
|
|
31
|
-
return newHash;
|
|
32
|
-
}
|
|
33
|
-
const _default = navigateToHashParams;
|
package/navigateToHashParams.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import buildUrlQueryString from "@koine/utils/buildUrlQueryString";
|
|
2
|
-
import getUrlHashPathname from "@koine/utils/getUrlHashPathname";
|
|
3
|
-
/**
|
|
4
|
-
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
5
|
-
* if a second argument `hash` is not provded
|
|
6
|
-
*
|
|
7
|
-
* @category location
|
|
8
|
-
*/ export function navigateToHashParams(params = {}, hash = "") {
|
|
9
|
-
const useLocation = !hash;
|
|
10
|
-
hash = hash || location.hash;
|
|
11
|
-
const hashQueryLess = getUrlHashPathname(hash);
|
|
12
|
-
const queryString = typeof params === "string" ? params : buildUrlQueryString(params);
|
|
13
|
-
const newHash = "#/" + hashQueryLess + queryString;
|
|
14
|
-
if (useLocation) {
|
|
15
|
-
location.hash = newHash;
|
|
16
|
-
}
|
|
17
|
-
return newHash;
|
|
18
|
-
}
|
|
19
|
-
export default navigateToHashParams;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
navigateToMergedHashParams: function() {
|
|
13
|
-
return navigateToMergedHashParams;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _getUrlHashParams = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/getUrlHashParams"));
|
|
21
|
-
const _mergeUrlQueryParams = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/mergeUrlQueryParams"));
|
|
22
|
-
const _navigateToHashParams = require("./navigateToHashParams");
|
|
23
|
-
function navigateToMergedHashParams(params = {}, hash = "") {
|
|
24
|
-
return (0, _navigateToHashParams.navigateToHashParams)((0, _mergeUrlQueryParams.default)((0, _getUrlHashParams.default)(hash), params), hash);
|
|
25
|
-
}
|
|
26
|
-
const _default = navigateToMergedHashParams;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import getUrlHashParams from "@koine/utils/getUrlHashParams";
|
|
2
|
-
import mergeUrlQueryParams from "@koine/utils/mergeUrlQueryParams";
|
|
3
|
-
import { navigateToHashParams } from "./navigateToHashParams";
|
|
4
|
-
/**
|
|
5
|
-
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
6
|
-
*
|
|
7
|
-
* @category location
|
|
8
|
-
*/ export function navigateToMergedHashParams(params = {}, hash = "") {
|
|
9
|
-
return navigateToHashParams(mergeUrlQueryParams(getUrlHashParams(hash), params), hash);
|
|
10
|
-
}
|
|
11
|
-
export default navigateToMergedHashParams;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
navigateToMergedParams: function() {
|
|
13
|
-
return navigateToMergedParams;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _getUrlQueryParams = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/getUrlQueryParams"));
|
|
21
|
-
const _mergeUrlQueryParams = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/mergeUrlQueryParams"));
|
|
22
|
-
const _navigateToParams = require("./navigateToParams");
|
|
23
|
-
function navigateToMergedParams(params = {}, replace) {
|
|
24
|
-
return (0, _navigateToParams.navigateToParams)((0, _mergeUrlQueryParams.default)((0, _getUrlQueryParams.default)(), params), replace);
|
|
25
|
-
}
|
|
26
|
-
const _default = navigateToMergedParams;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import getUrlQueryParams from "@koine/utils/getUrlQueryParams";
|
|
2
|
-
import mergeUrlQueryParams from "@koine/utils/mergeUrlQueryParams";
|
|
3
|
-
import { navigateToParams } from "./navigateToParams";
|
|
4
|
-
/**
|
|
5
|
-
* Merge current URL query parameters with the given ones, it uses `history`.
|
|
6
|
-
*
|
|
7
|
-
* @category location
|
|
8
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
9
|
-
*/ export function navigateToMergedParams(params = {}, replace) {
|
|
10
|
-
return navigateToParams(mergeUrlQueryParams(getUrlQueryParams(), params), replace);
|
|
11
|
-
}
|
|
12
|
-
export default navigateToMergedParams;
|
package/navigateToParams.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
navigateToParams: function() {
|
|
13
|
-
return navigateToParams;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _buildUrlQueryString = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/buildUrlQueryString"));
|
|
21
|
-
const _isBrowser = /*#__PURE__*/ _interop_require_default._(require("@koine/utils/isBrowser"));
|
|
22
|
-
const _navigateToUrl = /*#__PURE__*/ _interop_require_default._(require("./navigateToUrl"));
|
|
23
|
-
function navigateToParams(params = {}, replace) {
|
|
24
|
-
const queryString = typeof params === "string" ? params : (0, _buildUrlQueryString.default)(params);
|
|
25
|
-
if (_isBrowser.default) {
|
|
26
|
-
(0, _navigateToUrl.default)(location.pathname + queryString, replace);
|
|
27
|
-
}
|
|
28
|
-
return queryString;
|
|
29
|
-
}
|
|
30
|
-
const _default = navigateToParams;
|