@koine/browser 2.0.0-beta.16 → 2.0.0-beta.18
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.d.ts +0 -0
- package/createStorage.js +0 -0
- package/getZonedDate.d.ts +0 -0
- package/getZonedDate.js +0 -0
- package/gtagPageview.d.ts +0 -0
- package/gtagPageview.js +0 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/isIE.d.ts +0 -0
- package/isIE.js +0 -0
- package/isMobile.d.ts +0 -0
- package/isMobile.js +0 -0
- package/listenUrlSearch.d.ts +3 -0
- package/listenUrlSearch.js +54 -0
- package/listenUrlSearchParams.d.ts +2 -0
- package/listenUrlSearchParams.js +12 -0
- package/navigateToHash.d.ts +0 -0
- package/navigateToHash.js +0 -0
- package/navigateToHashParams.d.ts +0 -0
- package/navigateToHashParams.js +0 -0
- package/navigateToMergedHashParams.d.ts +0 -0
- package/navigateToMergedHashParams.js +0 -0
- package/navigateToMergedParams.d.ts +0 -0
- package/navigateToMergedParams.js +0 -0
- package/navigateToParams.d.ts +0 -0
- package/navigateToParams.js +0 -0
- package/navigateToUrl.d.ts +0 -0
- package/navigateToUrl.js +0 -0
- package/navigateWithoutUrlParam.d.ts +0 -0
- package/navigateWithoutUrlParam.js +0 -0
- package/package.json +9 -3
- package/redirectTo.d.ts +0 -0
- package/redirectTo.js +0 -0
- package/storage.d.ts +0 -0
- package/storage.js +0 -0
- package/storageClient.d.ts +0 -0
- package/storageClient.js +0 -0
package/createStorage.d.ts
CHANGED
|
File without changes
|
package/createStorage.js
CHANGED
|
File without changes
|
package/getZonedDate.d.ts
CHANGED
|
File without changes
|
package/getZonedDate.js
CHANGED
|
File without changes
|
package/gtagPageview.d.ts
CHANGED
|
File without changes
|
package/gtagPageview.js
CHANGED
|
File without changes
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export { getZonedDate } from "./getZonedDate.js";
|
|
|
3
3
|
export { gtagPageview, type GtmPageviewArgs } from "./gtagPageview.js";
|
|
4
4
|
export { isIE } from "./isIE.js";
|
|
5
5
|
export { isMobile } from "./isMobile.js";
|
|
6
|
+
export { listenUrlSearch } from "./listenUrlSearch.js";
|
|
7
|
+
export { listenUrlSearchParams } from "./listenUrlSearchParams.js";
|
|
6
8
|
export { navigateToHash } from "./navigateToHash.js";
|
|
7
9
|
export { navigateToHashParams } from "./navigateToHashParams.js";
|
|
8
10
|
export { navigateToMergedHashParams } from "./navigateToMergedHashParams.js";
|
package/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export { getZonedDate } from "./getZonedDate.js";
|
|
|
3
3
|
export { gtagPageview } from "./gtagPageview.js";
|
|
4
4
|
export { isIE } from "./isIE.js";
|
|
5
5
|
export { isMobile } from "./isMobile.js";
|
|
6
|
+
export { listenUrlSearch } from "./listenUrlSearch.js";
|
|
7
|
+
export { listenUrlSearchParams } from "./listenUrlSearchParams.js";
|
|
6
8
|
export { navigateToHash } from "./navigateToHash.js";
|
|
7
9
|
export { navigateToHashParams } from "./navigateToHashParams.js";
|
|
8
10
|
export { navigateToMergedHashParams } from "./navigateToMergedHashParams.js";
|
package/isIE.d.ts
CHANGED
|
File without changes
|
package/isIE.js
CHANGED
|
File without changes
|
package/isMobile.d.ts
CHANGED
|
File without changes
|
package/isMobile.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __values } from "tslib";
|
|
2
|
+
import { on } from "@koine/dom";
|
|
3
|
+
function extendHistoryMethod(fn, runHandlers, before) {
|
|
4
|
+
return function interceptor() {
|
|
5
|
+
var args = [];
|
|
6
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
+
args[_i] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
if (before) {
|
|
10
|
+
runHandlers();
|
|
11
|
+
return fn.apply(this, args);
|
|
12
|
+
}
|
|
13
|
+
var result = fn.apply(this, args);
|
|
14
|
+
runHandlers();
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var prevSearch = location.search;
|
|
19
|
+
function runHandlers() {
|
|
20
|
+
var e_1, _a;
|
|
21
|
+
var newSearch = location.search;
|
|
22
|
+
if (newSearch !== prevSearch) {
|
|
23
|
+
var listeners = history.__.h.values();
|
|
24
|
+
try {
|
|
25
|
+
for (var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()) {
|
|
26
|
+
var listener = listeners_1_1.value;
|
|
27
|
+
listener(prevSearch, newSearch);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (listeners_1_1 && !listeners_1_1.done && (_a = listeners_1.return)) _a.call(listeners_1);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e_1) throw e_1.error; }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
prevSearch = newSearch;
|
|
39
|
+
}
|
|
40
|
+
export function listenUrlSearch(handler) {
|
|
41
|
+
if (!history.__) {
|
|
42
|
+
history.pushState = extendHistoryMethod(history.pushState, runHandlers);
|
|
43
|
+
history.replaceState = extendHistoryMethod(history.replaceState, runHandlers);
|
|
44
|
+
on(window, "popstate", runHandlers);
|
|
45
|
+
history.__ = { h: new Set() };
|
|
46
|
+
}
|
|
47
|
+
if (!history.__.h.has(handler)) {
|
|
48
|
+
history.__.h.add(handler);
|
|
49
|
+
}
|
|
50
|
+
return function () {
|
|
51
|
+
history.__.h.delete(handler);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export default listenUrlSearch;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import listenUrlSearch from "./listenUrlSearch.js";
|
|
2
|
+
export var listenUrlSearchParams = function (paramName, handler) {
|
|
3
|
+
return listenUrlSearch(function (prevSearch, newSearch) {
|
|
4
|
+
var prevParams = new URLSearchParams(prevSearch);
|
|
5
|
+
var newParams = new URLSearchParams(newSearch);
|
|
6
|
+
var newValue = newParams.get(paramName);
|
|
7
|
+
if (prevParams.get(paramName) !== newValue) {
|
|
8
|
+
handler(newValue);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export default listenUrlSearchParams;
|
package/navigateToHash.d.ts
CHANGED
|
File without changes
|
package/navigateToHash.js
CHANGED
|
File without changes
|
|
File without changes
|
package/navigateToHashParams.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/navigateToParams.d.ts
CHANGED
|
File without changes
|
package/navigateToParams.js
CHANGED
|
File without changes
|
package/navigateToUrl.d.ts
CHANGED
|
File without changes
|
package/navigateToUrl.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "@koine/browser",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/dom": "2.0.0-beta.
|
|
6
|
-
"@koine/utils": "2.0.0-beta.
|
|
5
|
+
"@koine/dom": "2.0.0-beta.18",
|
|
6
|
+
"@koine/utils": "2.0.0-beta.18"
|
|
7
7
|
},
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"type": "module",
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
"./isMobile": {
|
|
28
28
|
"import": "./isMobile.js"
|
|
29
29
|
},
|
|
30
|
+
"./listenUrlSearch": {
|
|
31
|
+
"import": "./listenUrlSearch.js"
|
|
32
|
+
},
|
|
33
|
+
"./listenUrlSearchParams": {
|
|
34
|
+
"import": "./listenUrlSearchParams.js"
|
|
35
|
+
},
|
|
30
36
|
"./navigateToHash": {
|
|
31
37
|
"import": "./navigateToHash.js"
|
|
32
38
|
},
|
|
@@ -59,5 +65,5 @@
|
|
|
59
65
|
}
|
|
60
66
|
},
|
|
61
67
|
"peerDependencies": {},
|
|
62
|
-
"version": "2.0.0-beta.
|
|
68
|
+
"version": "2.0.0-beta.18"
|
|
63
69
|
}
|
package/redirectTo.d.ts
CHANGED
|
File without changes
|
package/redirectTo.js
CHANGED
|
File without changes
|
package/storage.d.ts
CHANGED
|
File without changes
|
package/storage.js
CHANGED
|
File without changes
|
package/storageClient.d.ts
CHANGED
|
File without changes
|
package/storageClient.js
CHANGED
|
File without changes
|