@archie/devtools 0.0.5 → 0.0.7
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/README.md +72 -13
- package/dist/chunk-DLRODACA.mjs +40 -0
- package/dist/{client.mjs → chunk-EQV632XF.mjs} +25 -24
- package/dist/chunk-JPNYFFBN.mjs +83 -0
- package/dist/client/client.d.mts +2 -0
- package/dist/client/client.d.ts +2 -0
- package/dist/{client.js → client/client.js} +26 -24
- package/dist/client/client.mjs +6 -0
- package/dist/client/inject-inspector/auto.d.mts +2 -0
- package/dist/client/inject-inspector/auto.d.ts +2 -0
- package/dist/client/inject-inspector/auto.js +1265 -0
- package/dist/client/inject-inspector/auto.mjs +7 -0
- package/dist/client/inject-inspector/injectInspector.d.mts +38 -0
- package/dist/client/inject-inspector/injectInspector.d.ts +38 -0
- package/dist/client/inject-inspector/injectInspector.js +1284 -0
- package/dist/client/inject-inspector/injectInspector.mjs +7 -0
- package/dist/client/route-listener/routeListener.js +90 -0
- package/dist/client/route-listener/routeListener.mjs +6 -0
- package/dist/constants/archieOrigins.d.mts +39 -0
- package/dist/constants/archieOrigins.d.ts +39 -0
- package/dist/constants/archieOrigins.js +69 -0
- package/dist/constants/archieOrigins.mjs +16 -0
- package/dist/inspector-QDRZLXRP.mjs +1139 -0
- package/package.json +21 -7
- package/dist/{client.d.mts → client/route-listener/routeListener.d.mts} +19 -19
- package/dist/{client.d.ts → client/route-listener/routeListener.d.ts} +19 -19
|
@@ -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,39 @@
|
|
|
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
|
+
*/
|
|
13
|
+
declare const ARCHIE_PREVIEW_ORIGIN_SUFFIXES: readonly [".archie-platform.com", ".archie.com"];
|
|
14
|
+
/**
|
|
15
|
+
* Common local origins for development. Add these when testing the inspector
|
|
16
|
+
* with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
|
|
17
|
+
*/
|
|
18
|
+
declare const LOCAL_DEV_ORIGINS: readonly ["http://localhost:3000", "http://localhost:3001"];
|
|
19
|
+
type ArchieHostOrigin = (typeof ARCHIE_HOST_ORIGINS)[number];
|
|
20
|
+
/**
|
|
21
|
+
* Returns a list of origins allowed to communicate with the inspector.
|
|
22
|
+
* Use in the host's message listener (allowlist for event.origin) or in
|
|
23
|
+
* injectInspector({ allowedOrigins }) when you want to restrict to Archie + optional local.
|
|
24
|
+
*
|
|
25
|
+
* @param includeLocal - If true, appends LOCAL_DEV_ORIGINS for local testing
|
|
26
|
+
*/
|
|
27
|
+
declare function getAllowedOrigins(includeLocal?: boolean): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns origin suffix patterns for preview iframes. The inspector allows any origin
|
|
30
|
+
* one of these suffixes (after the protocol).
|
|
31
|
+
*/
|
|
32
|
+
declare function getAllowedOriginPatterns(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the given origin is a known Archie preview origin (e.g. deploy preview iframe).
|
|
35
|
+
* When the inspector runs inside a preview iframe, targetOrigin for postMessage must be
|
|
36
|
+
*/
|
|
37
|
+
declare function isPreviewOrigin(origin: string): boolean;
|
|
38
|
+
|
|
39
|
+
export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
*/
|
|
13
|
+
declare const ARCHIE_PREVIEW_ORIGIN_SUFFIXES: readonly [".archie-platform.com", ".archie.com"];
|
|
14
|
+
/**
|
|
15
|
+
* Common local origins for development. Add these when testing the inspector
|
|
16
|
+
* with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
|
|
17
|
+
*/
|
|
18
|
+
declare const LOCAL_DEV_ORIGINS: readonly ["http://localhost:3000", "http://localhost:3001"];
|
|
19
|
+
type ArchieHostOrigin = (typeof ARCHIE_HOST_ORIGINS)[number];
|
|
20
|
+
/**
|
|
21
|
+
* Returns a list of origins allowed to communicate with the inspector.
|
|
22
|
+
* Use in the host's message listener (allowlist for event.origin) or in
|
|
23
|
+
* injectInspector({ allowedOrigins }) when you want to restrict to Archie + optional local.
|
|
24
|
+
*
|
|
25
|
+
* @param includeLocal - If true, appends LOCAL_DEV_ORIGINS for local testing
|
|
26
|
+
*/
|
|
27
|
+
declare function getAllowedOrigins(includeLocal?: boolean): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns origin suffix patterns for preview iframes. The inspector allows any origin
|
|
30
|
+
* one of these suffixes (after the protocol).
|
|
31
|
+
*/
|
|
32
|
+
declare function getAllowedOriginPatterns(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the given origin is a known Archie preview origin (e.g. deploy preview iframe).
|
|
35
|
+
* When the inspector runs inside a preview iframe, targetOrigin for postMessage must be
|
|
36
|
+
*/
|
|
37
|
+
declare function isPreviewOrigin(origin: string): boolean;
|
|
38
|
+
|
|
39
|
+
export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
getAllowedOriginPatterns: () => getAllowedOriginPatterns,
|
|
27
|
+
getAllowedOrigins: () => getAllowedOrigins,
|
|
28
|
+
isPreviewOrigin: () => isPreviewOrigin
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(archieOrigins_exports);
|
|
31
|
+
var ARCHIE_HOST_ORIGINS = [
|
|
32
|
+
"https://app.dev.archie-platform.com",
|
|
33
|
+
"https://app.staging.archie-platform.com",
|
|
34
|
+
"https://app.archie.com"
|
|
35
|
+
];
|
|
36
|
+
var ARCHIE_PREVIEW_ORIGIN_SUFFIXES = [
|
|
37
|
+
".archie-platform.com",
|
|
38
|
+
".archie.com"
|
|
39
|
+
];
|
|
40
|
+
var LOCAL_DEV_ORIGINS = [
|
|
41
|
+
"http://localhost:3000",
|
|
42
|
+
"http://localhost:3001"
|
|
43
|
+
];
|
|
44
|
+
function getAllowedOrigins(includeLocal = false) {
|
|
45
|
+
const list = [...ARCHIE_HOST_ORIGINS];
|
|
46
|
+
if (includeLocal) list.push(...LOCAL_DEV_ORIGINS);
|
|
47
|
+
return list;
|
|
48
|
+
}
|
|
49
|
+
function getAllowedOriginPatterns() {
|
|
50
|
+
return [...ARCHIE_PREVIEW_ORIGIN_SUFFIXES];
|
|
51
|
+
}
|
|
52
|
+
function isPreviewOrigin(origin) {
|
|
53
|
+
if (!origin || typeof origin !== "string") return false;
|
|
54
|
+
try {
|
|
55
|
+
const host = new URL(origin).host;
|
|
56
|
+
return ARCHIE_PREVIEW_ORIGIN_SUFFIXES.some((suffix) => host.endsWith(suffix));
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
ARCHIE_HOST_ORIGINS,
|
|
64
|
+
ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
|
|
65
|
+
LOCAL_DEV_ORIGINS,
|
|
66
|
+
getAllowedOriginPatterns,
|
|
67
|
+
getAllowedOrigins,
|
|
68
|
+
isPreviewOrigin
|
|
69
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ARCHIE_HOST_ORIGINS,
|
|
3
|
+
ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
|
|
4
|
+
LOCAL_DEV_ORIGINS,
|
|
5
|
+
getAllowedOriginPatterns,
|
|
6
|
+
getAllowedOrigins,
|
|
7
|
+
isPreviewOrigin
|
|
8
|
+
} from "../chunk-DLRODACA.mjs";
|
|
9
|
+
export {
|
|
10
|
+
ARCHIE_HOST_ORIGINS,
|
|
11
|
+
ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
|
|
12
|
+
LOCAL_DEV_ORIGINS,
|
|
13
|
+
getAllowedOriginPatterns,
|
|
14
|
+
getAllowedOrigins,
|
|
15
|
+
isPreviewOrigin
|
|
16
|
+
};
|