@archie/devtools 0.0.7 → 0.0.10

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 +1,9 @@
1
1
  import {
2
+ REMOTE_INSPECTOR_SCRIPT_URL,
2
3
  injectInspector
3
- } from "../../chunk-JPNYFFBN.mjs";
4
- import "../../chunk-DLRODACA.mjs";
4
+ } from "../../chunk-REJDPYAO.mjs";
5
+ import "../../chunk-D5EA6RR5.mjs";
5
6
  export {
7
+ REMOTE_INSPECTOR_SCRIPT_URL,
6
8
  injectInspector
7
9
  };
@@ -8,9 +8,17 @@
8
8
  declare const ARCHIE_HOST_ORIGINS: readonly ["https://app.dev.archie-platform.com", "https://app.staging.archie-platform.com", "https://app.archie.com"];
9
9
  /**
10
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,
11
+ * The inspector allows any origin whose host ends with one of these suffixes
12
+ * to send messages to the inspector (allowlist).
12
13
  */
13
- declare const ARCHIE_PREVIEW_ORIGIN_SUFFIXES: readonly [".archie-platform.com", ".archie.com"];
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"];
14
22
  /**
15
23
  * Common local origins for development. Add these when testing the inspector
16
24
  * with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
@@ -31,9 +39,10 @@ declare function getAllowedOrigins(includeLocal?: boolean): string[];
31
39
  */
32
40
  declare function getAllowedOriginPatterns(): string[];
33
41
  /**
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
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).
36
45
  */
37
46
  declare function isPreviewOrigin(origin: string): boolean;
38
47
 
39
- export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
48
+ export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, PREVIEW_DEPLOY_HOST_SUFFIXES, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
@@ -8,9 +8,17 @@
8
8
  declare const ARCHIE_HOST_ORIGINS: readonly ["https://app.dev.archie-platform.com", "https://app.staging.archie-platform.com", "https://app.archie.com"];
9
9
  /**
10
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,
11
+ * The inspector allows any origin whose host ends with one of these suffixes
12
+ * to send messages to the inspector (allowlist).
12
13
  */
13
- declare const ARCHIE_PREVIEW_ORIGIN_SUFFIXES: readonly [".archie-platform.com", ".archie.com"];
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"];
14
22
  /**
15
23
  * Common local origins for development. Add these when testing the inspector
16
24
  * with the host running on localhost (e.g. host on :3000, preview iframe on :5173).
@@ -31,9 +39,10 @@ declare function getAllowedOrigins(includeLocal?: boolean): string[];
31
39
  */
32
40
  declare function getAllowedOriginPatterns(): string[];
33
41
  /**
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
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).
36
45
  */
37
46
  declare function isPreviewOrigin(origin: string): boolean;
38
47
 
39
- export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
48
+ export { ARCHIE_HOST_ORIGINS, ARCHIE_PREVIEW_ORIGIN_SUFFIXES, type ArchieHostOrigin, LOCAL_DEV_ORIGINS, PREVIEW_DEPLOY_HOST_SUFFIXES, getAllowedOriginPatterns, getAllowedOrigins, isPreviewOrigin };
@@ -23,6 +23,7 @@ __export(archieOrigins_exports, {
23
23
  ARCHIE_HOST_ORIGINS: () => ARCHIE_HOST_ORIGINS,
24
24
  ARCHIE_PREVIEW_ORIGIN_SUFFIXES: () => ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
25
25
  LOCAL_DEV_ORIGINS: () => LOCAL_DEV_ORIGINS,
26
+ PREVIEW_DEPLOY_HOST_SUFFIXES: () => PREVIEW_DEPLOY_HOST_SUFFIXES,
26
27
  getAllowedOriginPatterns: () => getAllowedOriginPatterns,
27
28
  getAllowedOrigins: () => getAllowedOrigins,
28
29
  isPreviewOrigin: () => isPreviewOrigin
@@ -34,9 +35,15 @@ var ARCHIE_HOST_ORIGINS = [
34
35
  "https://app.archie.com"
35
36
  ];
36
37
  var ARCHIE_PREVIEW_ORIGIN_SUFFIXES = [
38
+ ".staging.archie-platform.com",
37
39
  ".archie-platform.com",
38
40
  ".archie.com"
39
41
  ];
42
+ var PREVIEW_DEPLOY_HOST_SUFFIXES = [
43
+ ".previews.staging.archie-platform.com",
44
+ ".previews.archie-platform.com",
45
+ ".previews.archie.com"
46
+ ];
40
47
  var LOCAL_DEV_ORIGINS = [
41
48
  "http://localhost:3000",
42
49
  "http://localhost:3001"
@@ -53,7 +60,7 @@ function isPreviewOrigin(origin) {
53
60
  if (!origin || typeof origin !== "string") return false;
54
61
  try {
55
62
  const host = new URL(origin).host;
56
- return ARCHIE_PREVIEW_ORIGIN_SUFFIXES.some((suffix) => host.endsWith(suffix));
63
+ return PREVIEW_DEPLOY_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix));
57
64
  } catch {
58
65
  return false;
59
66
  }
@@ -63,6 +70,7 @@ function isPreviewOrigin(origin) {
63
70
  ARCHIE_HOST_ORIGINS,
64
71
  ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
65
72
  LOCAL_DEV_ORIGINS,
73
+ PREVIEW_DEPLOY_HOST_SUFFIXES,
66
74
  getAllowedOriginPatterns,
67
75
  getAllowedOrigins,
68
76
  isPreviewOrigin
@@ -2,14 +2,16 @@ import {
2
2
  ARCHIE_HOST_ORIGINS,
3
3
  ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
4
4
  LOCAL_DEV_ORIGINS,
5
+ PREVIEW_DEPLOY_HOST_SUFFIXES,
5
6
  getAllowedOriginPatterns,
6
7
  getAllowedOrigins,
7
8
  isPreviewOrigin
8
- } from "../chunk-DLRODACA.mjs";
9
+ } from "../chunk-D5EA6RR5.mjs";
9
10
  export {
10
11
  ARCHIE_HOST_ORIGINS,
11
12
  ARCHIE_PREVIEW_ORIGIN_SUFFIXES,
12
13
  LOCAL_DEV_ORIGINS,
14
+ PREVIEW_DEPLOY_HOST_SUFFIXES,
13
15
  getAllowedOriginPatterns,
14
16
  getAllowedOrigins,
15
17
  isPreviewOrigin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archie/devtools",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "description": "DevTools for Archie generated applications - Route synchronization and editor communication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -30,6 +30,7 @@
30
30
  "scripts": {
31
31
  "test": "vitest run",
32
32
  "test:watch": "vitest",
33
+ "inspector:local": "node scripts/generate-inspector-local.js",
33
34
  "build": "tsup src/index.ts src/client/client.ts src/client/inject-inspector/injectInspector.ts src/client/inject-inspector/auto.ts src/client/route-listener/routeListener.ts src/constants/archieOrigins.ts --format cjs,esm --dts",
34
35
  "dev": "tsup src/index.ts src/client/client.ts src/client/inject-inspector/injectInspector.ts src/client/inject-inspector/auto.ts src/client/route-listener/routeListener.ts src/constants/archieOrigins.ts --format cjs,esm --dts --watch",
35
36
  "typecheck": "tsc --noEmit",