@archie/devtools 0.0.4 → 0.0.6

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.
@@ -0,0 +1,7 @@
1
+ import {
2
+ injectInspector
3
+ } from "../../chunk-NYVHR4QL.mjs";
4
+ import "../../chunk-6MYORGLK.mjs";
5
+ export {
6
+ injectInspector
7
+ };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/client/route-listener/routeListener.ts
21
+ var routeListener_exports = {};
22
+ __export(routeListener_exports, {
23
+ setupArchieRouteListener: () => setupArchieRouteListener
24
+ });
25
+ module.exports = __toCommonJS(routeListener_exports);
26
+ function extractAllRoutes(routes, parentPath = "") {
27
+ const result = [];
28
+ for (const route of routes) {
29
+ const path = route.path ? (parentPath + "/" + route.path).replace(/\/+/g, "/") : parentPath || "/";
30
+ if (route.path !== void 0 || route.index) {
31
+ result.push({
32
+ id: route.id,
33
+ path: route.index ? parentPath || "/" : path,
34
+ hasChildren: !!(route.children && route.children.length > 0)
35
+ });
36
+ }
37
+ if (route.children) {
38
+ result.push(...extractAllRoutes(route.children, path));
39
+ }
40
+ }
41
+ return result;
42
+ }
43
+ function broadcastRouteState(target, state, allRoutes) {
44
+ try {
45
+ const message = {
46
+ type: "ARCHIE_ROUTE_UPDATE",
47
+ payload: {
48
+ path: state.location.pathname,
49
+ search: state.location.search,
50
+ hash: state.location.hash,
51
+ matches: state.matches.map((m) => ({
52
+ id: m.route.id,
53
+ pathname: m.pathname,
54
+ params: m.params
55
+ })),
56
+ allRoutes,
57
+ timestamp: Date.now()
58
+ }
59
+ };
60
+ target.postMessage(message, "*");
61
+ } catch {
62
+ }
63
+ }
64
+ function setupArchieRouteListener(router) {
65
+ const target = window.parent !== window ? window.parent : window.opener;
66
+ if (!target) {
67
+ return () => {
68
+ };
69
+ }
70
+ broadcastRouteState(target, router.state, extractAllRoutes(router.routes));
71
+ const unsubscribe = router.subscribe((state) => {
72
+ const currentRoutes = extractAllRoutes(router.routes);
73
+ broadcastRouteState(target, state, currentRoutes);
74
+ });
75
+ const handleMessage = (event) => {
76
+ if (event.data?.type === "ARCHIE_QUERY_ROUTES") {
77
+ const currentRoutes = extractAllRoutes(router.routes);
78
+ broadcastRouteState(target, router.state, currentRoutes);
79
+ }
80
+ };
81
+ window.addEventListener("message", handleMessage);
82
+ return () => {
83
+ unsubscribe();
84
+ window.removeEventListener("message", handleMessage);
85
+ };
86
+ }
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ setupArchieRouteListener
90
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ setupArchieRouteListener
3
+ } from "../../chunk-EQV632XF.mjs";
4
+ export {
5
+ setupArchieRouteListener
6
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Official Archie host origins: domains from which the inspector iframe is included.
3
+ * Use these as allowedOrigins / targetOrigin when the app runs inside Archie (dev, staging, prod).
4
+ * @see https://app.dev.archie-platform.com
5
+ * @see https://app.staging.archie-platform.com
6
+ * @see https://app.archie.com
7
+ */
8
+ declare const ARCHIE_HOST_ORIGINS: readonly ["https://app.dev.archie-platform.com", "https://app.staging.archie-platform.com", "https://app.archie.com"];
9
+ /**
10
+ * Common local origins for development. Add these when testing the inspector
11
+ * with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
12
+ */
13
+ declare const LOCAL_DEV_ORIGINS: readonly ["http://localhost:3000", "http://localhost:3001"];
14
+ type ArchieHostOrigin = (typeof ARCHIE_HOST_ORIGINS)[number];
15
+ /**
16
+ * Returns a list of origins allowed to communicate with the inspector.
17
+ * Use in the host's message listener (allowlist for event.origin) or in
18
+ * injectInspector({ allowedOrigins }) when you want to restrict to Archie + optional local.
19
+ *
20
+ * @param includeLocal - If true, appends LOCAL_DEV_ORIGINS for local testing
21
+ */
22
+ declare function getAllowedOrigins(includeLocal?: boolean): string[];
23
+
24
+ export { ARCHIE_HOST_ORIGINS, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, getAllowedOrigins };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Official Archie host origins: domains from which the inspector iframe is included.
3
+ * Use these as allowedOrigins / targetOrigin when the app runs inside Archie (dev, staging, prod).
4
+ * @see https://app.dev.archie-platform.com
5
+ * @see https://app.staging.archie-platform.com
6
+ * @see https://app.archie.com
7
+ */
8
+ declare const ARCHIE_HOST_ORIGINS: readonly ["https://app.dev.archie-platform.com", "https://app.staging.archie-platform.com", "https://app.archie.com"];
9
+ /**
10
+ * Common local origins for development. Add these when testing the inspector
11
+ * with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
12
+ */
13
+ declare const LOCAL_DEV_ORIGINS: readonly ["http://localhost:3000", "http://localhost:3001"];
14
+ type ArchieHostOrigin = (typeof ARCHIE_HOST_ORIGINS)[number];
15
+ /**
16
+ * Returns a list of origins allowed to communicate with the inspector.
17
+ * Use in the host's message listener (allowlist for event.origin) or in
18
+ * injectInspector({ allowedOrigins }) when you want to restrict to Archie + optional local.
19
+ *
20
+ * @param includeLocal - If true, appends LOCAL_DEV_ORIGINS for local testing
21
+ */
22
+ declare function getAllowedOrigins(includeLocal?: boolean): string[];
23
+
24
+ export { ARCHIE_HOST_ORIGINS, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, getAllowedOrigins };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/constants/archieOrigins.ts
21
+ var archieOrigins_exports = {};
22
+ __export(archieOrigins_exports, {
23
+ ARCHIE_HOST_ORIGINS: () => ARCHIE_HOST_ORIGINS,
24
+ LOCAL_DEV_ORIGINS: () => LOCAL_DEV_ORIGINS,
25
+ getAllowedOrigins: () => getAllowedOrigins
26
+ });
27
+ module.exports = __toCommonJS(archieOrigins_exports);
28
+ var ARCHIE_HOST_ORIGINS = [
29
+ "https://app.dev.archie-platform.com",
30
+ "https://app.staging.archie-platform.com",
31
+ "https://app.archie.com"
32
+ ];
33
+ var LOCAL_DEV_ORIGINS = [
34
+ "http://localhost:3000",
35
+ "http://localhost:3001"
36
+ ];
37
+ function getAllowedOrigins(includeLocal = false) {
38
+ const list = [...ARCHIE_HOST_ORIGINS];
39
+ if (includeLocal) list.push(...LOCAL_DEV_ORIGINS);
40
+ return list;
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ ARCHIE_HOST_ORIGINS,
45
+ LOCAL_DEV_ORIGINS,
46
+ getAllowedOrigins
47
+ });
@@ -0,0 +1,10 @@
1
+ import {
2
+ ARCHIE_HOST_ORIGINS,
3
+ LOCAL_DEV_ORIGINS,
4
+ getAllowedOrigins
5
+ } from "../chunk-6MYORGLK.mjs";
6
+ export {
7
+ ARCHIE_HOST_ORIGINS,
8
+ LOCAL_DEV_ORIGINS,
9
+ getAllowedOrigins
10
+ };