@archie/devtools 0.0.9 → 0.0.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.
@@ -1,47 +0,0 @@
1
- // src/constants/archieOrigins.ts
2
- var ARCHIE_HOST_ORIGINS = [
3
- "https://app.dev.archie-platform.com",
4
- "https://app.staging.archie-platform.com",
5
- "https://app.archie.com"
6
- ];
7
- var ARCHIE_PREVIEW_ORIGIN_SUFFIXES = [
8
- ".staging.archie-platform.com",
9
- ".archie-platform.com",
10
- ".archie.com"
11
- ];
12
- var PREVIEW_DEPLOY_HOST_SUFFIXES = [
13
- ".previews.staging.archie-platform.com",
14
- ".previews.archie-platform.com",
15
- ".previews.archie.com"
16
- ];
17
- var LOCAL_DEV_ORIGINS = [
18
- "http://localhost:3000",
19
- "http://localhost:3001"
20
- ];
21
- function getAllowedOrigins(includeLocal = false) {
22
- const list = [...ARCHIE_HOST_ORIGINS];
23
- if (includeLocal) list.push(...LOCAL_DEV_ORIGINS);
24
- return list;
25
- }
26
- function getAllowedOriginPatterns() {
27
- return [...ARCHIE_PREVIEW_ORIGIN_SUFFIXES];
28
- }
29
- function isPreviewOrigin(origin) {
30
- if (!origin || typeof origin !== "string") return false;
31
- try {
32
- const host = new URL(origin).host;
33
- return PREVIEW_DEPLOY_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix));
34
- } catch {
35
- return false;
36
- }
37
- }
38
-
39
- export {
40
- ARCHIE_HOST_ORIGINS,
41
- ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
42
- PREVIEW_DEPLOY_HOST_SUFFIXES,
43
- LOCAL_DEV_ORIGINS,
44
- getAllowedOrigins,
45
- getAllowedOriginPatterns,
46
- isPreviewOrigin
47
- };
@@ -1,66 +0,0 @@
1
- // src/client/route-listener/routeListener.ts
2
- function extractAllRoutes(routes, parentPath = "") {
3
- const result = [];
4
- for (const route of routes) {
5
- const path = route.path ? (parentPath + "/" + route.path).replace(/\/+/g, "/") : parentPath || "/";
6
- if (route.path !== void 0 || route.index) {
7
- result.push({
8
- id: route.id,
9
- path: route.index ? parentPath || "/" : path,
10
- hasChildren: !!(route.children && route.children.length > 0)
11
- });
12
- }
13
- if (route.children) {
14
- result.push(...extractAllRoutes(route.children, path));
15
- }
16
- }
17
- return result;
18
- }
19
- function broadcastRouteState(target, state, allRoutes) {
20
- try {
21
- const message = {
22
- type: "ARCHIE_ROUTE_UPDATE",
23
- payload: {
24
- path: state.location.pathname,
25
- search: state.location.search,
26
- hash: state.location.hash,
27
- matches: state.matches.map((m) => ({
28
- id: m.route.id,
29
- pathname: m.pathname,
30
- params: m.params
31
- })),
32
- allRoutes,
33
- timestamp: Date.now()
34
- }
35
- };
36
- target.postMessage(message, "*");
37
- } catch {
38
- }
39
- }
40
- function setupArchieRouteListener(router) {
41
- const target = window.parent !== window ? window.parent : window.opener;
42
- if (!target) {
43
- return () => {
44
- };
45
- }
46
- broadcastRouteState(target, router.state, extractAllRoutes(router.routes));
47
- const unsubscribe = router.subscribe((state) => {
48
- const currentRoutes = extractAllRoutes(router.routes);
49
- broadcastRouteState(target, state, currentRoutes);
50
- });
51
- const handleMessage = (event) => {
52
- if (event.data?.type === "ARCHIE_QUERY_ROUTES") {
53
- const currentRoutes = extractAllRoutes(router.routes);
54
- broadcastRouteState(target, router.state, currentRoutes);
55
- }
56
- };
57
- window.addEventListener("message", handleMessage);
58
- return () => {
59
- unsubscribe();
60
- window.removeEventListener("message", handleMessage);
61
- };
62
- }
63
-
64
- export {
65
- setupArchieRouteListener
66
- };
@@ -1,2 +0,0 @@
1
-
2
- export { }
@@ -1,2 +0,0 @@
1
-
2
- export { }