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