@koine/browser 2.0.0-beta.13 → 2.0.0-beta.131

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 (151) hide show
  1. package/README.md +1 -1
  2. package/createStorage.cjs.d.ts +2 -0
  3. package/createStorage.cjs.default.js +1 -0
  4. package/createStorage.cjs.js +50 -0
  5. package/createStorage.cjs.mjs +2 -0
  6. package/createStorage.d.ts +7 -54
  7. package/createStorage.esm.d.ts +2 -0
  8. package/createStorage.esm.js +45 -0
  9. package/getZonedDate.cjs.d.ts +2 -0
  10. package/getZonedDate.cjs.default.js +1 -0
  11. package/{getZonedDate.mjs → getZonedDate.cjs.js} +13 -18
  12. package/getZonedDate.cjs.mjs +2 -0
  13. package/getZonedDate.d.ts +1 -15
  14. package/getZonedDate.esm.d.ts +2 -0
  15. package/getZonedDate.esm.js +21 -0
  16. package/gtag.cjs.d.ts +2 -0
  17. package/gtag.cjs.default.js +1 -0
  18. package/gtag.cjs.js +22 -0
  19. package/gtag.cjs.mjs +2 -0
  20. package/gtag.d.ts +2 -0
  21. package/gtag.esm.d.ts +2 -0
  22. package/gtag.esm.js +17 -0
  23. package/gtagPageview.cjs.d.ts +2 -0
  24. package/gtagPageview.cjs.default.js +1 -0
  25. package/gtagPageview.cjs.js +12 -0
  26. package/gtagPageview.cjs.mjs +2 -0
  27. package/gtagPageview.d.ts +1 -4
  28. package/gtagPageview.esm.d.ts +2 -0
  29. package/gtagPageview.esm.js +7 -0
  30. package/index.cjs.d.ts +1 -0
  31. package/index.cjs.default.js +1 -0
  32. package/index.cjs.js +41 -0
  33. package/index.cjs.mjs +2 -0
  34. package/index.d.ts +4 -1
  35. package/index.esm.d.ts +1 -0
  36. package/index.esm.js +18 -0
  37. package/isIE.cjs.d.ts +2 -0
  38. package/isIE.cjs.default.js +1 -0
  39. package/isIE.cjs.js +14 -0
  40. package/isIE.cjs.mjs +2 -0
  41. package/isIE.d.ts +1 -6
  42. package/isIE.esm.d.ts +2 -0
  43. package/isIE.esm.js +9 -0
  44. package/isMobile.cjs.d.ts +2 -0
  45. package/isMobile.cjs.default.js +1 -0
  46. package/isMobile.cjs.js +16 -0
  47. package/isMobile.cjs.mjs +2 -0
  48. package/isMobile.d.ts +1 -6
  49. package/isMobile.esm.d.ts +2 -0
  50. package/isMobile.esm.js +11 -0
  51. package/listenUrlSearch.cjs.d.ts +2 -0
  52. package/listenUrlSearch.cjs.default.js +1 -0
  53. package/listenUrlSearch.cjs.js +32 -0
  54. package/listenUrlSearch.cjs.mjs +2 -0
  55. package/listenUrlSearch.d.ts +3 -0
  56. package/listenUrlSearch.esm.d.ts +2 -0
  57. package/listenUrlSearch.esm.js +27 -0
  58. package/listenUrlSearchParams.cjs.d.ts +2 -0
  59. package/listenUrlSearchParams.cjs.default.js +1 -0
  60. package/listenUrlSearchParams.cjs.js +14 -0
  61. package/listenUrlSearchParams.cjs.mjs +2 -0
  62. package/listenUrlSearchParams.d.ts +2 -0
  63. package/listenUrlSearchParams.esm.d.ts +2 -0
  64. package/listenUrlSearchParams.esm.js +9 -0
  65. package/navigateToHash.cjs.d.ts +2 -0
  66. package/navigateToHash.cjs.default.js +1 -0
  67. package/navigateToHash.cjs.js +15 -0
  68. package/navigateToHash.cjs.mjs +2 -0
  69. package/navigateToHash.d.ts +1 -7
  70. package/navigateToHash.esm.d.ts +2 -0
  71. package/navigateToHash.esm.js +10 -0
  72. package/navigateToHashParams.cjs.d.ts +2 -0
  73. package/navigateToHashParams.cjs.default.js +1 -0
  74. package/navigateToHashParams.cjs.js +15 -0
  75. package/navigateToHashParams.cjs.mjs +2 -0
  76. package/navigateToHashParams.d.ts +2 -8
  77. package/navigateToHashParams.esm.d.ts +2 -0
  78. package/navigateToHashParams.esm.js +10 -0
  79. package/navigateToMergedHashParams.cjs.d.ts +2 -0
  80. package/navigateToMergedHashParams.cjs.default.js +1 -0
  81. package/navigateToMergedHashParams.cjs.js +15 -0
  82. package/navigateToMergedHashParams.cjs.mjs +2 -0
  83. package/navigateToMergedHashParams.d.ts +2 -7
  84. package/navigateToMergedHashParams.esm.d.ts +2 -0
  85. package/navigateToMergedHashParams.esm.js +10 -0
  86. package/navigateToMergedParams.cjs.d.ts +2 -0
  87. package/navigateToMergedParams.cjs.default.js +1 -0
  88. package/navigateToMergedParams.cjs.js +16 -0
  89. package/navigateToMergedParams.cjs.mjs +2 -0
  90. package/navigateToMergedParams.d.ts +2 -8
  91. package/navigateToMergedParams.esm.d.ts +2 -0
  92. package/navigateToMergedParams.esm.js +11 -0
  93. package/navigateToParams.cjs.d.ts +2 -0
  94. package/navigateToParams.cjs.default.js +1 -0
  95. package/navigateToParams.cjs.js +17 -0
  96. package/navigateToParams.cjs.mjs +2 -0
  97. package/navigateToParams.d.ts +2 -9
  98. package/navigateToParams.esm.d.ts +2 -0
  99. package/navigateToParams.esm.js +12 -0
  100. package/navigateToUrl.cjs.d.ts +2 -0
  101. package/navigateToUrl.cjs.default.js +1 -0
  102. package/navigateToUrl.cjs.js +12 -0
  103. package/navigateToUrl.cjs.mjs +2 -0
  104. package/navigateToUrl.d.ts +1 -6
  105. package/navigateToUrl.esm.d.ts +2 -0
  106. package/navigateToUrl.esm.js +7 -0
  107. package/navigateWithoutUrlParam.cjs.d.ts +2 -0
  108. package/navigateWithoutUrlParam.cjs.default.js +1 -0
  109. package/navigateWithoutUrlParam.cjs.js +16 -0
  110. package/navigateWithoutUrlParam.cjs.mjs +2 -0
  111. package/navigateWithoutUrlParam.d.ts +1 -7
  112. package/navigateWithoutUrlParam.esm.d.ts +2 -0
  113. package/navigateWithoutUrlParam.esm.js +11 -0
  114. package/package.json +129 -8
  115. package/redirectTo.cjs.d.ts +2 -0
  116. package/redirectTo.cjs.default.js +1 -0
  117. package/redirectTo.cjs.js +15 -0
  118. package/redirectTo.cjs.mjs +2 -0
  119. package/redirectTo.d.ts +2 -8
  120. package/redirectTo.esm.d.ts +2 -0
  121. package/redirectTo.esm.js +10 -0
  122. package/storage.cjs.d.ts +2 -0
  123. package/storage.cjs.default.js +1 -0
  124. package/storage.cjs.js +14 -0
  125. package/storage.cjs.mjs +2 -0
  126. package/storage.d.ts +7 -12
  127. package/storage.esm.d.ts +2 -0
  128. package/storage.esm.js +9 -0
  129. package/storageClient.cjs.d.ts +2 -0
  130. package/storageClient.cjs.default.js +1 -0
  131. package/storageClient.cjs.js +21 -0
  132. package/storageClient.cjs.mjs +2 -0
  133. package/storageClient.d.ts +5 -13
  134. package/storageClient.esm.d.ts +2 -0
  135. package/storageClient.esm.js +16 -0
  136. package/createStorage.mjs +0 -133
  137. package/gtagPageview.mjs +0 -23
  138. package/index.mjs +0 -15
  139. package/isIE.mjs +0 -16
  140. package/isMobile.mjs +0 -14
  141. package/navigateToHash.mjs +0 -11
  142. package/navigateToHashParams.mjs +0 -19
  143. package/navigateToMergedHashParams.mjs +0 -11
  144. package/navigateToMergedParams.mjs +0 -12
  145. package/navigateToParams.mjs +0 -17
  146. package/navigateToUrl.mjs +0 -10
  147. package/navigateWithoutUrlParam.mjs +0 -18
  148. package/redirectTo.mjs +0 -14
  149. package/storage.mjs +0 -10
  150. package/storageClient.mjs +0 -97
  151. package/typings.d.ts +0 -12
package/navigateToUrl.mjs DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * It updates the browser's location URL with global `history` object
3
- *
4
- * @category location
5
- */ export function navigateToUrl(url = "", replace) {
6
- if (url) {
7
- history[replace ? "replaceState" : "pushState"](history.state, "", url);
8
- }
9
- }
10
- export default navigateToUrl;
@@ -1,18 +0,0 @@
1
- import getUrlQueryParams from "@koine/utils/getUrlQueryParams";
2
- import navigateToParams from "./navigateToParams";
3
- /**
4
- * Remove URL query parameter, it uses `history`
5
- *
6
- * @category location
7
- * @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
8
- */ export function navigateWithoutUrlParam(paramName, replace) {
9
- const params = {};
10
- const currentParams = getUrlQueryParams();
11
- for(const key in currentParams){
12
- if (key !== paramName) {
13
- params[key] = currentParams[key];
14
- }
15
- }
16
- return navigateToParams(params, replace);
17
- }
18
- export default navigateWithoutUrlParam;
package/redirectTo.mjs DELETED
@@ -1,14 +0,0 @@
1
- import buildUrlQueryString from "@koine/utils/buildUrlQueryString";
2
- import isBrowser from "@koine/utils/isBrowser";
3
- /**
4
- * Redirect to url with params {optionally}, removes eventual trailing question
5
- * marks from the given URL, it uses `location`
6
- *
7
- * @category location
8
- */ export function redirectTo(url, params) {
9
- if (isBrowser) {
10
- const queryString = buildUrlQueryString(params);
11
- location.href = url.replace(/\?+$/g, "") + queryString;
12
- }
13
- }
14
- export default redirectTo;
package/storage.mjs DELETED
@@ -1,10 +0,0 @@
1
- import storageClient from "./storageClient";
2
- /**
3
- * Storage, for `localStorage` and `sessionStorage`
4
- *
5
- * @category storage
6
- */ export const storage = {
7
- l: storageClient(),
8
- s: storageClient(true)
9
- };
10
- export default storage;
package/storageClient.mjs DELETED
@@ -1,97 +0,0 @@
1
- import isBrowser from "@koine/utils/isBrowser";
2
- import isString from "@koine/utils/isString";
3
- const methodsMap = {
4
- g: "getItem",
5
- s: "setItem",
6
- r: "removeItem"
7
- };
8
- /**
9
- * Super minifiable `local/session Storage` client creator with SSR safety
10
- *
11
- * @category storage
12
- */ export const storageClient = (useSessionStorage)=>{
13
- const nativeMethod = (method, key, value)=>isBrowser ? window[useSessionStorage ? "sessionStorage" : "localStorage"][methodsMap[method]](key, value) : ()=>{
14
- if (process.env["NODE_ENV"] !== "production") {
15
- console.warn(`[@koine/utils:storageClient]: ${useSessionStorage ? "sessionStorage" : "localStorage"} does not exists outside of browser.`);
16
- }
17
- };
18
- const get = (key, transform, defaultValue)=>{
19
- let value = defaultValue ?? null;
20
- if (process.env["NODE_ENV"] !== "production") {
21
- if (!isBrowser) {
22
- console.log(`[@koine/utils:storage] called 'get' outside of browser with default value '${JSON.stringify(defaultValue)}'.`);
23
- }
24
- }
25
- if (isBrowser) {
26
- let stored = nativeMethod("g", key);
27
- if (stored) {
28
- stored = transform ? transform(stored) : stored;
29
- try {
30
- const parsed = JSON.parse(stored);
31
- if (parsed) value = parsed;
32
- } catch (_e) {
33
- value = stored;
34
- // if (process.env["NODE_ENV"] !== "production") {
35
- // console.warn(
36
- // `[@koine/utils:storage]: 'get' failed to parse stored value as JSON. Plain '${stored}' value is returned.`
37
- // );
38
- // }
39
- }
40
- }
41
- }
42
- return value;
43
- };
44
- const set = (key, value, transform = (value)=>value)=>{
45
- if (process.env["NODE_ENV"] !== "production") {
46
- if (!isBrowser) {
47
- console.log(`[@koine/utils:storage] called 'set' outside of browser does not work.`);
48
- }
49
- }
50
- if (isBrowser) {
51
- try {
52
- const transformedValue = isString(value) ? transform(value) : transform(JSON.stringify(value));
53
- nativeMethod("s", key, transformedValue);
54
- } catch (_e) {
55
- if (process.env["NODE_ENV"] !== "production") {
56
- console.warn(`[@koine/utils:createStorage]: 'set' error.`, _e);
57
- }
58
- }
59
- }
60
- };
61
- const remove = (key)=>{
62
- if (process.env["NODE_ENV"] !== "production") {
63
- if (!isBrowser) {
64
- console.log(`[@koine/utils:storage] called 'remove' outside of browser does not work.`);
65
- }
66
- }
67
- if (isBrowser) {
68
- try {
69
- nativeMethod("r", key);
70
- } catch (_e) {
71
- if (process.env["NODE_ENV"] !== "production") {
72
- console.warn(`[@koine/utils:createStorage]: 'remove' error.`, _e);
73
- }
74
- }
75
- }
76
- };
77
- const has = (key, defaultValue)=>{
78
- let value = defaultValue ?? false;
79
- if (process.env["NODE_ENV"] !== "production") {
80
- if (!isBrowser) {
81
- console.log(`[@koine/utils:storage] called 'has' outside of browser with default value '${JSON.stringify(defaultValue)}'.`);
82
- }
83
- }
84
- if (isBrowser) {
85
- const stored = nativeMethod("g", key);
86
- value = stored ?? false;
87
- }
88
- return value;
89
- };
90
- return {
91
- get,
92
- set,
93
- remove,
94
- has
95
- };
96
- };
97
- export default storageClient;
package/typings.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * List here the global variables used by third party scripts supported within
3
- * the `koine` ecosystem. For instance Google Analytics globally available
4
- * variables.
5
- */
6
-
7
- // eslint-disable-next-line no-var,@typescript-eslint/no-explicit-any
8
- declare var gtag: (...args: any[]) => any;
9
-
10
- // declare type NullableRecord<T> = {
11
- // [K in keyof T]: T[K] | null;
12
- // };