@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,7 +0,0 @@
1
- import {
2
- injectInspector
3
- } from "../../chunk-6HHNPJXA.mjs";
4
- import "../../chunk-D5EA6RR5.mjs";
5
- export {
6
- injectInspector
7
- };
@@ -1,49 +0,0 @@
1
- import { Router } from '@remix-run/router';
2
-
3
- /**
4
- * Route information for the sitemap
5
- */
6
- interface RouteInfo {
7
- id: string | undefined;
8
- path: string;
9
- hasChildren: boolean;
10
- }
11
- /**
12
- * Type definition for the route update message
13
- */
14
- interface ArchieRouteUpdateMessage {
15
- type: 'ARCHIE_ROUTE_UPDATE';
16
- payload: {
17
- path: string;
18
- search: string;
19
- hash: string;
20
- matches: Array<{
21
- id: string | undefined;
22
- pathname: string;
23
- params: Record<string, string | undefined>;
24
- }>;
25
- allRoutes: RouteInfo[];
26
- timestamp: number;
27
- };
28
- }
29
- /**
30
- * Archie Route Listener Setup
31
- *
32
- * Subscribes to the React Router instance to detect route changes
33
- * and broadcast them to the host editor (iframe parent or popup opener).
34
- *
35
- * @param router - The React Router instance (from createBrowserRouter)
36
- * @returns Unsubscribe function to stop listening
37
- *
38
- * @example
39
- * ```typescript
40
- * import { setupArchieRouteListener } from '@archie/devtools/client';
41
- * import { router } from './App';
42
- *
43
- * const unsubscribe = setupArchieRouteListener(router);
44
- * // Later: unsubscribe();
45
- * ```
46
- */
47
- declare function setupArchieRouteListener(router: Router): () => void;
48
-
49
- export { type ArchieRouteUpdateMessage, type RouteInfo, setupArchieRouteListener };
@@ -1,49 +0,0 @@
1
- import { Router } from '@remix-run/router';
2
-
3
- /**
4
- * Route information for the sitemap
5
- */
6
- interface RouteInfo {
7
- id: string | undefined;
8
- path: string;
9
- hasChildren: boolean;
10
- }
11
- /**
12
- * Type definition for the route update message
13
- */
14
- interface ArchieRouteUpdateMessage {
15
- type: 'ARCHIE_ROUTE_UPDATE';
16
- payload: {
17
- path: string;
18
- search: string;
19
- hash: string;
20
- matches: Array<{
21
- id: string | undefined;
22
- pathname: string;
23
- params: Record<string, string | undefined>;
24
- }>;
25
- allRoutes: RouteInfo[];
26
- timestamp: number;
27
- };
28
- }
29
- /**
30
- * Archie Route Listener Setup
31
- *
32
- * Subscribes to the React Router instance to detect route changes
33
- * and broadcast them to the host editor (iframe parent or popup opener).
34
- *
35
- * @param router - The React Router instance (from createBrowserRouter)
36
- * @returns Unsubscribe function to stop listening
37
- *
38
- * @example
39
- * ```typescript
40
- * import { setupArchieRouteListener } from '@archie/devtools/client';
41
- * import { router } from './App';
42
- *
43
- * const unsubscribe = setupArchieRouteListener(router);
44
- * // Later: unsubscribe();
45
- * ```
46
- */
47
- declare function setupArchieRouteListener(router: Router): () => void;
48
-
49
- export { type ArchieRouteUpdateMessage, type RouteInfo, setupArchieRouteListener };
@@ -1,90 +0,0 @@
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
- });
@@ -1,6 +0,0 @@
1
- import {
2
- setupArchieRouteListener
3
- } from "../../chunk-EQV632XF.mjs";
4
- export {
5
- setupArchieRouteListener
6
- };
@@ -1,48 +0,0 @@
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
- * Origin suffix patterns for Archie preview iframes (e.g. deploy previews).
11
- * The inspector allows any origin whose host ends with one of these suffixes
12
- * to send messages to the inspector (allowlist).
13
- */
14
- declare const ARCHIE_PREVIEW_ORIGIN_SUFFIXES: readonly [".staging.archie-platform.com", ".archie-platform.com", ".archie.com"];
15
- /**
16
- * Host suffixes that identify a **preview deploy** iframe (e.g. 0cf7f787-....previews.staging.archie-platform.com).
17
- * Used only by isPreviewOrigin() to decide "don't use referrer as targetOrigin" when the *current page*
18
- * is a preview iframe. Must be narrower than ARCHIE_PREVIEW_ORIGIN_SUFFIXES so that the parent
19
- * (e.g. app.dev.archie-platform.com) is not treated as a preview and its origin is used as targetOrigin.
20
- */
21
- declare const PREVIEW_DEPLOY_HOST_SUFFIXES: readonly [".previews.staging.archie-platform.com", ".previews.archie-platform.com", ".previews.archie.com"];
22
- /**
23
- * Common local origins for development. Add these when testing the inspector
24
- * with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
25
- */
26
- declare const LOCAL_DEV_ORIGINS: readonly ["http://localhost:3000", "http://localhost:3001"];
27
- type ArchieHostOrigin = (typeof ARCHIE_HOST_ORIGINS)[number];
28
- /**
29
- * Returns a list of origins allowed to communicate with the inspector.
30
- * Use in the host's message listener (allowlist for event.origin) or in
31
- * injectInspector({ allowedOrigins }) when you want to restrict to Archie + optional local.
32
- *
33
- * @param includeLocal - If true, appends LOCAL_DEV_ORIGINS for local testing
34
- */
35
- declare function getAllowedOrigins(includeLocal?: boolean): string[];
36
- /**
37
- * Returns origin suffix patterns for preview iframes. The inspector allows any origin
38
- * one of these suffixes (after the protocol).
39
- */
40
- declare function getAllowedOriginPatterns(): string[];
41
- /**
42
- * Returns true if the given origin is a preview **deploy** iframe (e.g. xxx.previews.staging.archie-platform.com).
43
- * Used so we don't use that origin as postMessage targetOrigin; the target must be the parent app.
44
- * Does not match app.dev.archie-platform.com / app.staging.archie-platform.com (so they can be used as target).
45
- */
46
- declare function isPreviewOrigin(origin: string): boolean;
47
-
48
- export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, PREVIEW_DEPLOY_HOST_SUFFIXES, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
@@ -1,48 +0,0 @@
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
- * Origin suffix patterns for Archie preview iframes (e.g. deploy previews).
11
- * The inspector allows any origin whose host ends with one of these suffixes
12
- * to send messages to the inspector (allowlist).
13
- */
14
- declare const ARCHIE_PREVIEW_ORIGIN_SUFFIXES: readonly [".staging.archie-platform.com", ".archie-platform.com", ".archie.com"];
15
- /**
16
- * Host suffixes that identify a **preview deploy** iframe (e.g. 0cf7f787-....previews.staging.archie-platform.com).
17
- * Used only by isPreviewOrigin() to decide "don't use referrer as targetOrigin" when the *current page*
18
- * is a preview iframe. Must be narrower than ARCHIE_PREVIEW_ORIGIN_SUFFIXES so that the parent
19
- * (e.g. app.dev.archie-platform.com) is not treated as a preview and its origin is used as targetOrigin.
20
- */
21
- declare const PREVIEW_DEPLOY_HOST_SUFFIXES: readonly [".previews.staging.archie-platform.com", ".previews.archie-platform.com", ".previews.archie.com"];
22
- /**
23
- * Common local origins for development. Add these when testing the inspector
24
- * with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
25
- */
26
- declare const LOCAL_DEV_ORIGINS: readonly ["http://localhost:3000", "http://localhost:3001"];
27
- type ArchieHostOrigin = (typeof ARCHIE_HOST_ORIGINS)[number];
28
- /**
29
- * Returns a list of origins allowed to communicate with the inspector.
30
- * Use in the host's message listener (allowlist for event.origin) or in
31
- * injectInspector({ allowedOrigins }) when you want to restrict to Archie + optional local.
32
- *
33
- * @param includeLocal - If true, appends LOCAL_DEV_ORIGINS for local testing
34
- */
35
- declare function getAllowedOrigins(includeLocal?: boolean): string[];
36
- /**
37
- * Returns origin suffix patterns for preview iframes. The inspector allows any origin
38
- * one of these suffixes (after the protocol).
39
- */
40
- declare function getAllowedOriginPatterns(): string[];
41
- /**
42
- * Returns true if the given origin is a preview **deploy** iframe (e.g. xxx.previews.staging.archie-platform.com).
43
- * Used so we don't use that origin as postMessage targetOrigin; the target must be the parent app.
44
- * Does not match app.dev.archie-platform.com / app.staging.archie-platform.com (so they can be used as target).
45
- */
46
- declare function isPreviewOrigin(origin: string): boolean;
47
-
48
- export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, PREVIEW_DEPLOY_HOST_SUFFIXES, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
@@ -1,77 +0,0 @@
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
- ARCHIE_PREVIEW_ORIGIN_SUFFIXES: () => ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
25
- LOCAL_DEV_ORIGINS: () => LOCAL_DEV_ORIGINS,
26
- PREVIEW_DEPLOY_HOST_SUFFIXES: () => PREVIEW_DEPLOY_HOST_SUFFIXES,
27
- getAllowedOriginPatterns: () => getAllowedOriginPatterns,
28
- getAllowedOrigins: () => getAllowedOrigins,
29
- isPreviewOrigin: () => isPreviewOrigin
30
- });
31
- module.exports = __toCommonJS(archieOrigins_exports);
32
- var ARCHIE_HOST_ORIGINS = [
33
- "https://app.dev.archie-platform.com",
34
- "https://app.staging.archie-platform.com",
35
- "https://app.archie.com"
36
- ];
37
- var ARCHIE_PREVIEW_ORIGIN_SUFFIXES = [
38
- ".staging.archie-platform.com",
39
- ".archie-platform.com",
40
- ".archie.com"
41
- ];
42
- var PREVIEW_DEPLOY_HOST_SUFFIXES = [
43
- ".previews.staging.archie-platform.com",
44
- ".previews.archie-platform.com",
45
- ".previews.archie.com"
46
- ];
47
- var LOCAL_DEV_ORIGINS = [
48
- "http://localhost:3000",
49
- "http://localhost:3001"
50
- ];
51
- function getAllowedOrigins(includeLocal = false) {
52
- const list = [...ARCHIE_HOST_ORIGINS];
53
- if (includeLocal) list.push(...LOCAL_DEV_ORIGINS);
54
- return list;
55
- }
56
- function getAllowedOriginPatterns() {
57
- return [...ARCHIE_PREVIEW_ORIGIN_SUFFIXES];
58
- }
59
- function isPreviewOrigin(origin) {
60
- if (!origin || typeof origin !== "string") return false;
61
- try {
62
- const host = new URL(origin).host;
63
- return PREVIEW_DEPLOY_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix));
64
- } catch {
65
- return false;
66
- }
67
- }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- ARCHIE_HOST_ORIGINS,
71
- ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
72
- LOCAL_DEV_ORIGINS,
73
- PREVIEW_DEPLOY_HOST_SUFFIXES,
74
- getAllowedOriginPatterns,
75
- getAllowedOrigins,
76
- isPreviewOrigin
77
- });
@@ -1,18 +0,0 @@
1
- import {
2
- ARCHIE_HOST_ORIGINS,
3
- ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
4
- LOCAL_DEV_ORIGINS,
5
- PREVIEW_DEPLOY_HOST_SUFFIXES,
6
- getAllowedOriginPatterns,
7
- getAllowedOrigins,
8
- isPreviewOrigin
9
- } from "../chunk-D5EA6RR5.mjs";
10
- export {
11
- ARCHIE_HOST_ORIGINS,
12
- ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
13
- LOCAL_DEV_ORIGINS,
14
- PREVIEW_DEPLOY_HOST_SUFFIXES,
15
- getAllowedOriginPatterns,
16
- getAllowedOrigins,
17
- isPreviewOrigin
18
- };