@archie/devtools 0.0.3 → 0.0.5
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/dist/client.js +14 -4
- package/dist/client.mjs +14 -4
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -29,12 +29,22 @@ function setupArchieRouteListener(router) {
|
|
|
29
29
|
return () => {
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
broadcastRouteState(target, router.state, allRoutes);
|
|
32
|
+
broadcastRouteState(target, router.state, extractAllRoutes(router.routes));
|
|
34
33
|
const unsubscribe = router.subscribe((state) => {
|
|
35
|
-
|
|
34
|
+
const currentRoutes = extractAllRoutes(router.routes);
|
|
35
|
+
broadcastRouteState(target, state, currentRoutes);
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
const handleMessage = (event) => {
|
|
38
|
+
if (event.data?.type === "ARCHIE_QUERY_ROUTES") {
|
|
39
|
+
const currentRoutes = extractAllRoutes(router.routes);
|
|
40
|
+
broadcastRouteState(target, router.state, currentRoutes);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
window.addEventListener("message", handleMessage);
|
|
44
|
+
return () => {
|
|
45
|
+
unsubscribe();
|
|
46
|
+
window.removeEventListener("message", handleMessage);
|
|
47
|
+
};
|
|
38
48
|
}
|
|
39
49
|
function extractAllRoutes(routes, parentPath = "") {
|
|
40
50
|
const result = [];
|
package/dist/client.mjs
CHANGED
|
@@ -5,12 +5,22 @@ function setupArchieRouteListener(router) {
|
|
|
5
5
|
return () => {
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
broadcastRouteState(target, router.state, allRoutes);
|
|
8
|
+
broadcastRouteState(target, router.state, extractAllRoutes(router.routes));
|
|
10
9
|
const unsubscribe = router.subscribe((state) => {
|
|
11
|
-
|
|
10
|
+
const currentRoutes = extractAllRoutes(router.routes);
|
|
11
|
+
broadcastRouteState(target, state, currentRoutes);
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
const handleMessage = (event) => {
|
|
14
|
+
if (event.data?.type === "ARCHIE_QUERY_ROUTES") {
|
|
15
|
+
const currentRoutes = extractAllRoutes(router.routes);
|
|
16
|
+
broadcastRouteState(target, router.state, currentRoutes);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
window.addEventListener("message", handleMessage);
|
|
20
|
+
return () => {
|
|
21
|
+
unsubscribe();
|
|
22
|
+
window.removeEventListener("message", handleMessage);
|
|
23
|
+
};
|
|
14
24
|
}
|
|
15
25
|
function extractAllRoutes(routes, parentPath = "") {
|
|
16
26
|
const result = [];
|
package/package.json
CHANGED