@koine/browser 1.1.10 → 1.1.11
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.js +28 -24
- package/{node/createStorage.js → createStorage.mjs} +24 -28
- package/getZonedDate.js +11 -6
- package/{node/getZonedDate.js → getZonedDate.mjs} +6 -11
- package/gtagPageview.js +9 -4
- package/{node/gtagPageview.js → gtagPageview.mjs} +4 -9
- package/index.js +18 -15
- package/index.mjs +15 -0
- package/isIE.js +9 -4
- package/{node/isIE.js → isIE.mjs} +4 -9
- package/isMobile.js +9 -4
- package/{node/isMobile.js → isMobile.mjs} +4 -9
- package/navigateToHash.js +9 -4
- package/navigateToHash.mjs +13 -0
- package/navigateToHashParams.js +11 -6
- package/navigateToHashParams.mjs +22 -0
- package/navigateToMergedHashParams.js +11 -6
- package/navigateToMergedHashParams.mjs +14 -0
- package/navigateToMergedParams.js +11 -6
- package/navigateToMergedParams.mjs +14 -0
- package/navigateToParams.js +13 -8
- package/navigateToParams.mjs +19 -0
- package/navigateToUrl.js +6 -2
- package/{node/navigateToUrl.js → navigateToUrl.mjs} +2 -6
- package/navigateWithoutUrlParam.js +11 -6
- package/navigateWithoutUrlParam.mjs +19 -0
- package/package.json +3 -3
- package/redirectTo.js +11 -6
- package/redirectTo.mjs +15 -0
- package/storage.js +9 -5
- package/storage.mjs +9 -0
- package/storageClient.js +19 -14
- package/{node/storageClient.js → storageClient.mjs} +14 -19
- package/node/index.js +0 -18
- package/node/navigateToHash.js +0 -18
- package/node/navigateToHashParams.js +0 -27
- package/node/navigateToMergedHashParams.js +0 -19
- package/node/navigateToMergedParams.js +0 -19
- package/node/navigateToParams.js +0 -24
- package/node/navigateWithoutUrlParam.js +0 -24
- package/node/redirectTo.js +0 -20
- package/node/storage.js +0 -13
package/createStorage.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStorage = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var decode_1 = tslib_1.__importDefault(require("@koine/utils/decode"));
|
|
6
|
+
var encode_1 = tslib_1.__importDefault(require("@koine/utils/encode"));
|
|
7
|
+
var isBrowser_1 = tslib_1.__importDefault(require("@koine/utils/isBrowser"));
|
|
8
|
+
var isNullOrUndefined_1 = tslib_1.__importDefault(require("@koine/utils/isNullOrUndefined"));
|
|
9
|
+
var noop_1 = tslib_1.__importDefault(require("@koine/utils/noop"));
|
|
10
|
+
var on_1 = tslib_1.__importDefault(require("@koine/dom/on"));
|
|
11
|
+
var storage_1 = tslib_1.__importDefault(require("./storage"));
|
|
9
12
|
/**
|
|
10
13
|
* Utility to create a storage instance to interact with `localStorage` using
|
|
11
14
|
* encrypted (encoded) key/values.
|
|
12
15
|
*/
|
|
13
|
-
|
|
14
|
-
var client = useSessionStorage ?
|
|
16
|
+
var createStorage = function (config, useSessionStorage) {
|
|
17
|
+
var client = useSessionStorage ? storage_1.default.s : storage_1.default.l;
|
|
15
18
|
var keys = Object.keys(config).reduce(function (map, key) {
|
|
16
19
|
var _a;
|
|
17
|
-
return (__assign(__assign({}, map), (_a = {}, _a[key] =
|
|
20
|
+
return (tslib_1.__assign(tslib_1.__assign({}, map), (_a = {}, _a[key] = (0, encode_1.default)(key), _a)));
|
|
18
21
|
}, {});
|
|
19
22
|
return {
|
|
20
23
|
/**
|
|
@@ -25,7 +28,7 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
25
28
|
* returned, otherwise `null`.
|
|
26
29
|
*/
|
|
27
30
|
get: function (key, defaultValue) {
|
|
28
|
-
return client.get(keys[key],
|
|
31
|
+
return client.get(keys[key], decode_1.default, defaultValue);
|
|
29
32
|
},
|
|
30
33
|
/**
|
|
31
34
|
* Get all storage values (it uses `localStorage.get()`).
|
|
@@ -33,7 +36,7 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
33
36
|
* `undefined` and `null` values are not returned.
|
|
34
37
|
*/
|
|
35
38
|
getAll: function (defaultValues) {
|
|
36
|
-
if (!
|
|
39
|
+
if (!isBrowser_1.default) {
|
|
37
40
|
if (process.env["NODE_ENV"] !== "production") {
|
|
38
41
|
console.log("[@koine/utils:createStorage] attempt to use 'getAll' outside of browser.");
|
|
39
42
|
}
|
|
@@ -43,7 +46,7 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
43
46
|
for (var key in keys) {
|
|
44
47
|
var value = this.get(key);
|
|
45
48
|
var defaultValue = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues[key];
|
|
46
|
-
if (!
|
|
49
|
+
if (!(0, isNullOrUndefined_1.default)(value)) {
|
|
47
50
|
all[key] = value;
|
|
48
51
|
}
|
|
49
52
|
else if (defaultValue) {
|
|
@@ -58,7 +61,7 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
58
61
|
* Non-string values are stringified with `JSON.stringify()`
|
|
59
62
|
*/
|
|
60
63
|
set: function (key, value) {
|
|
61
|
-
client.set(keys[key], value,
|
|
64
|
+
client.set(keys[key], value, encode_1.default);
|
|
62
65
|
},
|
|
63
66
|
/**
|
|
64
67
|
* Set all given storage values (it uses `localStorage.set()`).
|
|
@@ -68,14 +71,14 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
68
71
|
*/
|
|
69
72
|
setMany: function (newValues) {
|
|
70
73
|
if (process.env["NODE_ENV"] !== "production") {
|
|
71
|
-
if (!
|
|
74
|
+
if (!isBrowser_1.default) {
|
|
72
75
|
console.log("[@koine/utils:createStorage] attempt to use 'setMany' outside of browser.");
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
if (
|
|
78
|
+
if (isBrowser_1.default) {
|
|
76
79
|
for (var key in newValues) {
|
|
77
80
|
var value = newValues[key];
|
|
78
|
-
if (!
|
|
81
|
+
if (!(0, isNullOrUndefined_1.default)(value)) {
|
|
79
82
|
this.set(key, value);
|
|
80
83
|
}
|
|
81
84
|
else {
|
|
@@ -101,11 +104,11 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
101
104
|
*/
|
|
102
105
|
clear: function () {
|
|
103
106
|
if (process.env["NODE_ENV"] !== "production") {
|
|
104
|
-
if (!
|
|
107
|
+
if (!isBrowser_1.default) {
|
|
105
108
|
console.log("[@koine/utils:createStorage] attempt to use 'clear' outside of browser.");
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
|
-
if (
|
|
111
|
+
if (isBrowser_1.default) {
|
|
109
112
|
for (var key in keys) {
|
|
110
113
|
client.remove(keys[key]);
|
|
111
114
|
}
|
|
@@ -118,11 +121,11 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
118
121
|
* Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
|
|
119
122
|
*/
|
|
120
123
|
watch: function (keyToWatch, onRemoved, onAdded) {
|
|
121
|
-
if (!
|
|
124
|
+
if (!isBrowser_1.default) {
|
|
122
125
|
if (process.env["NODE_ENV"] !== "production") {
|
|
123
126
|
console.log("[@koine/utils:createStorage] attempt to use 'watch' outside of browser.");
|
|
124
127
|
}
|
|
125
|
-
return
|
|
128
|
+
return noop_1.default;
|
|
126
129
|
}
|
|
127
130
|
var handler = function (event) {
|
|
128
131
|
var key = event.key, oldValue = event.oldValue, newValue = event.newValue;
|
|
@@ -135,9 +138,10 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
};
|
|
138
|
-
var listener =
|
|
141
|
+
var listener = (0, on_1.default)(window, "storage", handler);
|
|
139
142
|
return listener;
|
|
140
143
|
},
|
|
141
144
|
};
|
|
142
145
|
};
|
|
143
|
-
|
|
146
|
+
exports.createStorage = createStorage;
|
|
147
|
+
exports.default = exports.createStorage;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var noop_1 = tslib_1.__importDefault(require("@koine/utils/noop"));
|
|
10
|
-
var on_1 = tslib_1.__importDefault(require("@koine/dom/on"));
|
|
11
|
-
var storage_1 = tslib_1.__importDefault(require("./storage"));
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import decode from "@koine/utils/decode";
|
|
3
|
+
import encode from "@koine/utils/encode";
|
|
4
|
+
import isBrowser from "@koine/utils/isBrowser";
|
|
5
|
+
import isNullOrUndefined from "@koine/utils/isNullOrUndefined";
|
|
6
|
+
import noop from "@koine/utils/noop";
|
|
7
|
+
import on from "@koine/dom/on";
|
|
8
|
+
import storage from "./storage";
|
|
12
9
|
/**
|
|
13
10
|
* Utility to create a storage instance to interact with `localStorage` using
|
|
14
11
|
* encrypted (encoded) key/values.
|
|
15
12
|
*/
|
|
16
|
-
var createStorage = function (config, useSessionStorage) {
|
|
17
|
-
var client = useSessionStorage ?
|
|
13
|
+
export var createStorage = function (config, useSessionStorage) {
|
|
14
|
+
var client = useSessionStorage ? storage.s : storage.l;
|
|
18
15
|
var keys = Object.keys(config).reduce(function (map, key) {
|
|
19
16
|
var _a;
|
|
20
|
-
return (
|
|
17
|
+
return (__assign(__assign({}, map), (_a = {}, _a[key] = encode(key), _a)));
|
|
21
18
|
}, {});
|
|
22
19
|
return {
|
|
23
20
|
/**
|
|
@@ -28,7 +25,7 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
28
25
|
* returned, otherwise `null`.
|
|
29
26
|
*/
|
|
30
27
|
get: function (key, defaultValue) {
|
|
31
|
-
return client.get(keys[key],
|
|
28
|
+
return client.get(keys[key], decode, defaultValue);
|
|
32
29
|
},
|
|
33
30
|
/**
|
|
34
31
|
* Get all storage values (it uses `localStorage.get()`).
|
|
@@ -36,7 +33,7 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
36
33
|
* `undefined` and `null` values are not returned.
|
|
37
34
|
*/
|
|
38
35
|
getAll: function (defaultValues) {
|
|
39
|
-
if (!
|
|
36
|
+
if (!isBrowser) {
|
|
40
37
|
if (process.env["NODE_ENV"] !== "production") {
|
|
41
38
|
console.log("[@koine/utils:createStorage] attempt to use 'getAll' outside of browser.");
|
|
42
39
|
}
|
|
@@ -46,7 +43,7 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
46
43
|
for (var key in keys) {
|
|
47
44
|
var value = this.get(key);
|
|
48
45
|
var defaultValue = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues[key];
|
|
49
|
-
if (!(
|
|
46
|
+
if (!isNullOrUndefined(value)) {
|
|
50
47
|
all[key] = value;
|
|
51
48
|
}
|
|
52
49
|
else if (defaultValue) {
|
|
@@ -61,7 +58,7 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
61
58
|
* Non-string values are stringified with `JSON.stringify()`
|
|
62
59
|
*/
|
|
63
60
|
set: function (key, value) {
|
|
64
|
-
client.set(keys[key], value,
|
|
61
|
+
client.set(keys[key], value, encode);
|
|
65
62
|
},
|
|
66
63
|
/**
|
|
67
64
|
* Set all given storage values (it uses `localStorage.set()`).
|
|
@@ -71,14 +68,14 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
71
68
|
*/
|
|
72
69
|
setMany: function (newValues) {
|
|
73
70
|
if (process.env["NODE_ENV"] !== "production") {
|
|
74
|
-
if (!
|
|
71
|
+
if (!isBrowser) {
|
|
75
72
|
console.log("[@koine/utils:createStorage] attempt to use 'setMany' outside of browser.");
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
if (
|
|
75
|
+
if (isBrowser) {
|
|
79
76
|
for (var key in newValues) {
|
|
80
77
|
var value = newValues[key];
|
|
81
|
-
if (!(
|
|
78
|
+
if (!isNullOrUndefined(value)) {
|
|
82
79
|
this.set(key, value);
|
|
83
80
|
}
|
|
84
81
|
else {
|
|
@@ -104,11 +101,11 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
104
101
|
*/
|
|
105
102
|
clear: function () {
|
|
106
103
|
if (process.env["NODE_ENV"] !== "production") {
|
|
107
|
-
if (!
|
|
104
|
+
if (!isBrowser) {
|
|
108
105
|
console.log("[@koine/utils:createStorage] attempt to use 'clear' outside of browser.");
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
if (
|
|
108
|
+
if (isBrowser) {
|
|
112
109
|
for (var key in keys) {
|
|
113
110
|
client.remove(keys[key]);
|
|
114
111
|
}
|
|
@@ -121,11 +118,11 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
121
118
|
* Inspiration from [Multi Tab Logout in React — Redux](https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa)
|
|
122
119
|
*/
|
|
123
120
|
watch: function (keyToWatch, onRemoved, onAdded) {
|
|
124
|
-
if (!
|
|
121
|
+
if (!isBrowser) {
|
|
125
122
|
if (process.env["NODE_ENV"] !== "production") {
|
|
126
123
|
console.log("[@koine/utils:createStorage] attempt to use 'watch' outside of browser.");
|
|
127
124
|
}
|
|
128
|
-
return
|
|
125
|
+
return noop;
|
|
129
126
|
}
|
|
130
127
|
var handler = function (event) {
|
|
131
128
|
var key = event.key, oldValue = event.oldValue, newValue = event.newValue;
|
|
@@ -138,10 +135,9 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
137
|
};
|
|
141
|
-
var listener = (
|
|
138
|
+
var listener = on(window, "storage", handler);
|
|
142
139
|
return listener;
|
|
143
140
|
},
|
|
144
141
|
};
|
|
145
142
|
};
|
|
146
|
-
|
|
147
|
-
exports.default = exports.createStorage;
|
|
143
|
+
export default createStorage;
|
package/getZonedDate.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getZonedDate = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var utcToZonedTime_1 = tslib_1.__importDefault(require("date-fns-tz/utcToZonedTime"));
|
|
6
|
+
var isBrowser_1 = tslib_1.__importDefault(require("@koine/utils/isBrowser"));
|
|
3
7
|
/**
|
|
4
8
|
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
5
9
|
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
@@ -14,11 +18,11 @@ import isBrowser from "@koine/utils/isBrowser";
|
|
|
14
18
|
* @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
19
|
* @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
20
|
*/
|
|
17
|
-
|
|
21
|
+
function getZonedDate(dateString, timeZone) {
|
|
18
22
|
if (dateString === void 0) { dateString = ""; }
|
|
19
23
|
if (!dateString.endsWith("Z"))
|
|
20
24
|
dateString += "Z";
|
|
21
|
-
if (!timeZone &&
|
|
25
|
+
if (!timeZone && isBrowser_1.default) {
|
|
22
26
|
try {
|
|
23
27
|
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
24
28
|
}
|
|
@@ -31,7 +35,8 @@ export function getZonedDate(dateString, timeZone) {
|
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
return timeZone
|
|
34
|
-
?
|
|
38
|
+
? (0, utcToZonedTime_1.default)(new Date(dateString), timeZone)
|
|
35
39
|
: new Date(dateString);
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
exports.getZonedDate = getZonedDate;
|
|
42
|
+
exports.default = getZonedDate;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getZonedDate = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var utcToZonedTime_1 = tslib_1.__importDefault(require("date-fns-tz/utcToZonedTime"));
|
|
6
|
-
var isBrowser_1 = tslib_1.__importDefault(require("@koine/utils/isBrowser"));
|
|
1
|
+
import utcToZonedTime from "date-fns-tz/utcToZonedTime";
|
|
2
|
+
import isBrowser from "@koine/utils/isBrowser";
|
|
7
3
|
/**
|
|
8
4
|
* It returns a `Date` object from a date `string` adjusted on the user timeZone,
|
|
9
5
|
* if a timeZone is not provided we try getting it from the `Intl` browwser native
|
|
@@ -18,11 +14,11 @@ var isBrowser_1 = tslib_1.__importDefault(require("@koine/utils/isBrowser"));
|
|
|
18
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.
|
|
19
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.
|
|
20
16
|
*/
|
|
21
|
-
function getZonedDate(dateString, timeZone) {
|
|
17
|
+
export function getZonedDate(dateString, timeZone) {
|
|
22
18
|
if (dateString === void 0) { dateString = ""; }
|
|
23
19
|
if (!dateString.endsWith("Z"))
|
|
24
20
|
dateString += "Z";
|
|
25
|
-
if (!timeZone &&
|
|
21
|
+
if (!timeZone && isBrowser) {
|
|
26
22
|
try {
|
|
27
23
|
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
28
24
|
}
|
|
@@ -35,8 +31,7 @@ function getZonedDate(dateString, timeZone) {
|
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
return timeZone
|
|
38
|
-
? (
|
|
34
|
+
? utcToZonedTime(new Date(dateString), timeZone)
|
|
39
35
|
: new Date(dateString);
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
exports.default = getZonedDate;
|
|
37
|
+
export default getZonedDate;
|
package/gtagPageview.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gtagPageview = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var isUndefined_1 = tslib_1.__importDefault(require("@koine/utils/isUndefined"));
|
|
2
6
|
/**
|
|
3
7
|
* @category analytics-google
|
|
4
8
|
*/
|
|
5
|
-
|
|
9
|
+
var gtagPageview = function () {
|
|
6
10
|
var args = [];
|
|
7
11
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
12
|
args[_i] = arguments[_i];
|
|
9
13
|
}
|
|
10
|
-
if (!
|
|
14
|
+
if (!(0, isUndefined_1.default)(window) && !(0, isUndefined_1.default)(window.gtag)) {
|
|
11
15
|
window.gtag("event", "page_view", {
|
|
12
16
|
page_path: args[0] || location.pathname,
|
|
13
17
|
page_title: args[1] || document.title,
|
|
@@ -16,7 +20,8 @@ export var gtagPageview = function () {
|
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
};
|
|
19
|
-
|
|
23
|
+
exports.gtagPageview = gtagPageview;
|
|
24
|
+
exports.default = exports.gtagPageview;
|
|
20
25
|
// export type GtmEventArgs = [
|
|
21
26
|
// eventCategory?: string,
|
|
22
27
|
// eventAction?: string,
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gtagPageview = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isUndefined_1 = tslib_1.__importDefault(require("@koine/utils/isUndefined"));
|
|
1
|
+
import isUndefined from "@koine/utils/isUndefined";
|
|
6
2
|
/**
|
|
7
3
|
* @category analytics-google
|
|
8
4
|
*/
|
|
9
|
-
var gtagPageview = function () {
|
|
5
|
+
export var gtagPageview = function () {
|
|
10
6
|
var args = [];
|
|
11
7
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
12
8
|
args[_i] = arguments[_i];
|
|
13
9
|
}
|
|
14
|
-
if (!(
|
|
10
|
+
if (!isUndefined(window) && !isUndefined(window.gtag)) {
|
|
15
11
|
window.gtag("event", "page_view", {
|
|
16
12
|
page_path: args[0] || location.pathname,
|
|
17
13
|
page_title: args[1] || document.title,
|
|
@@ -20,8 +16,7 @@ var gtagPageview = function () {
|
|
|
20
16
|
});
|
|
21
17
|
}
|
|
22
18
|
};
|
|
23
|
-
|
|
24
|
-
exports.default = exports.gtagPageview;
|
|
19
|
+
export default gtagPageview;
|
|
25
20
|
// export type GtmEventArgs = [
|
|
26
21
|
// eventCategory?: string,
|
|
27
22
|
// eventAction?: string,
|
package/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./createStorage"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./getZonedDate"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./gtagPageview"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./isIE"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./isMobile"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./navigateToHash"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./navigateToHashParams"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./navigateToMergedHashParams"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./navigateToMergedParams"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./navigateToParams"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./navigateToUrl"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./navigateWithoutUrlParam"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./redirectTo"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./storage"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./storageClient"), exports);
|
package/index.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./createStorage";
|
|
2
|
+
export * from "./getZonedDate";
|
|
3
|
+
export * from "./gtagPageview";
|
|
4
|
+
export * from "./isIE";
|
|
5
|
+
export * from "./isMobile";
|
|
6
|
+
export * from "./navigateToHash";
|
|
7
|
+
export * from "./navigateToHashParams";
|
|
8
|
+
export * from "./navigateToMergedHashParams";
|
|
9
|
+
export * from "./navigateToMergedParams";
|
|
10
|
+
export * from "./navigateToParams";
|
|
11
|
+
export * from "./navigateToUrl";
|
|
12
|
+
export * from "./navigateWithoutUrlParam";
|
|
13
|
+
export * from "./redirectTo";
|
|
14
|
+
export * from "./storage";
|
|
15
|
+
export * from "./storageClient";
|
package/isIE.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIE = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
2
6
|
/**
|
|
3
7
|
* @category detect
|
|
4
8
|
* @category is
|
|
5
9
|
* @see https://stackoverflow.com/a/21712356/12285349
|
|
6
10
|
*/
|
|
7
|
-
|
|
11
|
+
function isIE(ssrValue) {
|
|
8
12
|
if (ssrValue === void 0) { ssrValue = true; }
|
|
9
|
-
if (
|
|
13
|
+
if (isServer_1.default) {
|
|
10
14
|
return ssrValue;
|
|
11
15
|
}
|
|
12
16
|
var ua = window.navigator.userAgent;
|
|
@@ -15,4 +19,5 @@ export function isIE(ssrValue) {
|
|
|
15
19
|
}
|
|
16
20
|
return false;
|
|
17
21
|
}
|
|
18
|
-
|
|
22
|
+
exports.isIE = isIE;
|
|
23
|
+
exports.default = isIE;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIE = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
1
|
+
import isServer from "@koine/utils/isServer";
|
|
6
2
|
/**
|
|
7
3
|
* @category detect
|
|
8
4
|
* @category is
|
|
9
5
|
* @see https://stackoverflow.com/a/21712356/12285349
|
|
10
6
|
*/
|
|
11
|
-
function isIE(ssrValue) {
|
|
7
|
+
export function isIE(ssrValue) {
|
|
12
8
|
if (ssrValue === void 0) { ssrValue = true; }
|
|
13
|
-
if (
|
|
9
|
+
if (isServer) {
|
|
14
10
|
return ssrValue;
|
|
15
11
|
}
|
|
16
12
|
var ua = window.navigator.userAgent;
|
|
@@ -19,5 +15,4 @@ function isIE(ssrValue) {
|
|
|
19
15
|
}
|
|
20
16
|
return false;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
|
-
exports.default = isIE;
|
|
18
|
+
export default isIE;
|
package/isMobile.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMobile = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
2
6
|
/**
|
|
3
7
|
* @category detect
|
|
4
8
|
* @category is
|
|
5
9
|
* @see https://stackoverflow.com/a/3540295
|
|
6
10
|
*/
|
|
7
|
-
|
|
11
|
+
function isMobile(ssrValue) {
|
|
8
12
|
if (ssrValue === void 0) { ssrValue = true; }
|
|
9
|
-
if (
|
|
13
|
+
if (isServer_1.default) {
|
|
10
14
|
return ssrValue;
|
|
11
15
|
}
|
|
12
16
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
|
|
13
17
|
// 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)
|
|
14
18
|
// || /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)
|
|
15
19
|
}
|
|
16
|
-
|
|
20
|
+
exports.isMobile = isMobile;
|
|
21
|
+
exports.default = isMobile;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMobile = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isServer_1 = tslib_1.__importDefault(require("@koine/utils/isServer"));
|
|
1
|
+
import isServer from "@koine/utils/isServer";
|
|
6
2
|
/**
|
|
7
3
|
* @category detect
|
|
8
4
|
* @category is
|
|
9
5
|
* @see https://stackoverflow.com/a/3540295
|
|
10
6
|
*/
|
|
11
|
-
function isMobile(ssrValue) {
|
|
7
|
+
export function isMobile(ssrValue) {
|
|
12
8
|
if (ssrValue === void 0) { ssrValue = true; }
|
|
13
|
-
if (
|
|
9
|
+
if (isServer) {
|
|
14
10
|
return ssrValue;
|
|
15
11
|
}
|
|
16
12
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
|
|
17
13
|
// 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)
|
|
18
14
|
// || /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)
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
exports.default = isMobile;
|
|
16
|
+
export default isMobile;
|
package/navigateToHash.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateToHash = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var navigateToUrl_1 = tslib_1.__importDefault(require("./navigateToUrl"));
|
|
2
6
|
/**
|
|
3
7
|
* It updates the browser's location hash by replacing the history state.
|
|
4
8
|
* The non-silent standard way would simply be `location.hash = "#new-hash"`
|
|
5
9
|
*
|
|
6
10
|
* @category location
|
|
7
11
|
*/
|
|
8
|
-
|
|
12
|
+
function navigateToHash(hash) {
|
|
9
13
|
if (hash === void 0) { hash = ""; }
|
|
10
14
|
var pathname = location.pathname, search = location.search;
|
|
11
|
-
|
|
15
|
+
(0, navigateToUrl_1.default)(pathname + (search ? "?" + search : "") + (hash ? "#" + hash : ""), true);
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
exports.navigateToHash = navigateToHash;
|
|
18
|
+
exports.default = navigateToHash;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
*/
|
|
8
|
+
export function navigateToHash(hash) {
|
|
9
|
+
if (hash === void 0) { hash = ""; }
|
|
10
|
+
var pathname = location.pathname, search = location.search;
|
|
11
|
+
navigateToUrl(pathname + (search ? "?" + search : "") + (hash ? "#" + hash : ""), true);
|
|
12
|
+
}
|
|
13
|
+
export default navigateToHash;
|
package/navigateToHashParams.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateToHashParams = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var buildUrlQueryString_1 = tslib_1.__importDefault(require("@koine/utils/buildUrlQueryString"));
|
|
6
|
+
var getUrlHashPathname_1 = tslib_1.__importDefault(require("@koine/utils/getUrlHashPathname"));
|
|
3
7
|
/**
|
|
4
8
|
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
5
9
|
* if a second argument `hash` is not provded
|
|
6
10
|
*
|
|
7
11
|
* @category location
|
|
8
12
|
*/
|
|
9
|
-
|
|
13
|
+
function navigateToHashParams(params, hash) {
|
|
10
14
|
if (params === void 0) { params = {}; }
|
|
11
15
|
if (hash === void 0) { hash = ""; }
|
|
12
16
|
var useLocation = !hash;
|
|
13
17
|
hash = hash || location.hash;
|
|
14
|
-
var hashQueryLess =
|
|
15
|
-
var queryString = typeof params === "string" ? params :
|
|
18
|
+
var hashQueryLess = (0, getUrlHashPathname_1.default)(hash);
|
|
19
|
+
var queryString = typeof params === "string" ? params : (0, buildUrlQueryString_1.default)(params);
|
|
16
20
|
var newHash = "#/" + hashQueryLess + queryString;
|
|
17
21
|
if (useLocation) {
|
|
18
22
|
location.hash = newHash;
|
|
19
23
|
}
|
|
20
24
|
return newHash;
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
exports.navigateToHashParams = navigateToHashParams;
|
|
27
|
+
exports.default = navigateToHashParams;
|