@base44-preview/vite-plugin 0.2.20-pr.27.8bf9822 → 0.2.20-pr.27.bf4f26c

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.
Files changed (34) hide show
  1. package/README.md +15 -12
  2. package/dist/bridge.d.ts +5 -17
  3. package/dist/bridge.d.ts.map +1 -1
  4. package/dist/bridge.js +5 -30
  5. package/dist/bridge.js.map +1 -1
  6. package/dist/html-injections-plugin.d.ts +2 -4
  7. package/dist/html-injections-plugin.d.ts.map +1 -1
  8. package/dist/html-injections-plugin.js +72 -34
  9. package/dist/html-injections-plugin.js.map +1 -1
  10. package/dist/injections/navigation-notifier.d.ts +1 -2
  11. package/dist/injections/navigation-notifier.d.ts.map +1 -1
  12. package/dist/injections/navigation-notifier.js +2 -2
  13. package/dist/injections/navigation-notifier.js.map +1 -1
  14. package/dist/injections/sandbox-hmr-notifier.d.ts +1 -4
  15. package/dist/injections/sandbox-hmr-notifier.d.ts.map +1 -1
  16. package/dist/injections/sandbox-hmr-notifier.js +4 -4
  17. package/dist/injections/sandbox-hmr-notifier.js.map +1 -1
  18. package/dist/injections/sandbox-mount-observer.d.ts +1 -2
  19. package/dist/injections/sandbox-mount-observer.d.ts.map +1 -1
  20. package/dist/injections/sandbox-mount-observer.js +2 -2
  21. package/dist/injections/sandbox-mount-observer.js.map +1 -1
  22. package/dist/injections/unhandled-errors-handlers.d.ts +1 -4
  23. package/dist/injections/unhandled-errors-handlers.d.ts.map +1 -1
  24. package/dist/injections/unhandled-errors-handlers.js +67 -69
  25. package/dist/injections/unhandled-errors-handlers.js.map +1 -1
  26. package/dist/statics/index.mjs +1 -1
  27. package/dist/statics/index.mjs.map +1 -1
  28. package/package.json +1 -1
  29. package/src/bridge.ts +5 -34
  30. package/src/html-injections-plugin.ts +96 -45
  31. package/src/injections/navigation-notifier.ts +1 -2
  32. package/src/injections/sandbox-hmr-notifier.ts +3 -4
  33. package/src/injections/sandbox-mount-observer.ts +2 -2
  34. package/src/injections/unhandled-errors-handlers.ts +80 -84
package/README.md CHANGED
@@ -44,25 +44,28 @@ The plugin registers four sub-plugins when running in a sandbox (`MODAL_SANDBOX_
44
44
  1. **base44** — Core configuration: path aliases (`@/` → `/src/`), environment variables, dependency optimization, and legacy SDK import resolution.
45
45
  2. **iframe-hmr** — Sets CORS and `frame-ancestors` headers to allow iframe embedding.
46
46
  3. **error-overlay** — Replaces Vite's default error overlay with a custom one that reports errors to the parent window.
47
- 4. **html-injections** — Injects the sandbox bridge script into the HTML.
47
+ 4. **html-injections** — Injects sandbox-side scripts into the HTML.
48
48
 
49
49
  Outside a sandbox, only the core plugin runs (with optional API proxy support via `VITE_BASE44_APP_BASE_URL`).
50
50
 
51
- ### Sandbox Bridge
51
+ ### Sandbox Injections
52
52
 
53
- The bridge (`src/bridge.ts`) is a single ES module that consolidates all sandbox-side features. Instead of injecting multiple individual `<script>` tags, the HTML injections plugin injects one inline script that dynamically imports the bridge and calls `init()` with the configured options.
53
+ In **dev mode**, individual `<script type="module" src="...">` tags are injected for each feature, loaded directly from `node_modules`:
54
54
 
55
- The bridge conditionally sets up:
55
+ - **Error handlers** (`unhandled-errors-handlers.js`) — Global `error` and `unhandledrejection` listeners that report to the parent via `postMessage`.
56
+ - **Mount observer** (`sandbox-mount-observer.js`) — `MutationObserver` that detects when instrumented elements (`data-source-location`) are rendered.
57
+ - **HMR notifier** (`sandbox-hmr-notifier.js`) — Forwards Vite's `beforeUpdate`/`afterUpdate` events to the parent.
58
+ - **Navigation notifier** (`navigation-notifier.js`) — Intercepts `pushState`, `replaceState`, and `popstate` to track URL changes.
56
59
 
57
- - **Error handlers** Global `error` and `unhandledrejection` listeners that report to the parent via `postMessage`.
58
- - **Mount observer** — `MutationObserver` that detects when instrumented elements (`data-source-location`) are rendered.
59
- - **HMR notifier** — Forwards Vite's `beforeUpdate`/`afterUpdate` events to the parent.
60
- - **Navigation notifier** — Intercepts `pushState`, `replaceState`, and `popstate` to track URL changes.
61
- - **Visual edit agent** — Overlay system for selecting and editing elements with source location awareness.
60
+ These are self-executing scriptsthey run as soon as the browser loads them, with no setup call required.
62
61
 
63
- ### Local Development
62
+ The **visual edit agent** is the exception. It's a larger module (~560 lines) that is bundled separately via `tsup` into `dist/statics/index.mjs` and loaded via a dynamic `import()`. This allows local dev iteration: add `?sandbox-bridge=local` to load it from a local HTTPS dev server instead of `node_modules`.
64
63
 
65
- For developing the bridge itself, you can load it from a local dev server instead of the installed package:
64
+ In **production**, an inline analytics tracker script is injected instead.
65
+
66
+ ### Local Development (Visual Edit Agent)
67
+
68
+ To iterate on the visual edit agent locally without publishing:
66
69
 
67
70
  1. Generate local HTTPS certificates:
68
71
  ```bash
@@ -75,7 +78,7 @@ For developing the bridge itself, you can load it from a local dev server instea
75
78
  npm run dev -- -w # same, with auto-rebuild on changes
76
79
  ```
77
80
 
78
- 3. Add `?sandbox-bridge=local` to your app's URL to load the bridge from `localhost:3201` instead of `node_modules`.
81
+ 3. Add `?sandbox-bridge=local` to your app's URL to load the agent from `localhost:3201` instead of `node_modules`.
79
82
 
80
83
  ### Legacy SDK Compatibility
81
84
 
package/dist/bridge.d.ts CHANGED
@@ -1,20 +1,8 @@
1
1
  /**
2
- * Sandbox bridge entry point dynamically imported by the inline script
3
- * injected via html-injections-plugin. Conditionally initialises each
4
- * sandbox-side feature based on the supplied options.
2
+ * Sandbox bridge — bundled via tsup into dist/statics/index.mjs.
3
+ * Only the visual edit agent needs the bridge (for local dev iteration
4
+ * via ?sandbox-bridge=local). All other features load as individual
5
+ * sync script tags from node_modules.
5
6
  */
6
- /**
7
- * Initialise the sandbox bridge. Called once from the injected inline script.
8
- * @param options Feature flags — each defaults to enabled unless explicitly disabled.
9
- * @param hmr Vite's HMR client (`import.meta.hot`), passed only in dev mode.
10
- */
11
- export declare function init(options?: {
12
- unhandledErrors?: boolean;
13
- mountObserver?: boolean;
14
- hmrNotifier?: boolean;
15
- navigationNotifier?: boolean;
16
- visualEditAgent?: boolean;
17
- }, hmr?: {
18
- on(event: string, cb: (...args: any[]) => void): void;
19
- }): void;
7
+ export { setupVisualEditAgent } from "./injections/visual-edit-agent.js";
20
8
  //# sourceMappingURL=bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;GAIG;AACH,wBAAgB,IAAI,CAClB,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;CACtB,EACN,GAAG,CAAC,EAAE;IAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAA;CAAE,QAWhE"}
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
package/dist/bridge.js CHANGED
@@ -1,33 +1,8 @@
1
1
  /**
2
- * Sandbox bridge entry point dynamically imported by the inline script
3
- * injected via html-injections-plugin. Conditionally initialises each
4
- * sandbox-side feature based on the supplied options.
2
+ * Sandbox bridge — bundled via tsup into dist/statics/index.mjs.
3
+ * Only the visual edit agent needs the bridge (for local dev iteration
4
+ * via ?sandbox-bridge=local). All other features load as individual
5
+ * sync script tags from node_modules.
5
6
  */
6
- import { setupUnhandledErrors } from "./injections/unhandled-errors-handlers.js";
7
- import { setupHmrNotifier } from "./injections/sandbox-hmr-notifier.js";
8
- import { setupMountObserver } from "./injections/sandbox-mount-observer.js";
9
- import { setupNavigationNotifier } from "./injections/navigation-notifier.js";
10
- import { setupVisualEditAgent } from "./injections/visual-edit-agent.js";
11
- /**
12
- * Initialise the sandbox bridge. Called once from the injected inline script.
13
- * @param options Feature flags — each defaults to enabled unless explicitly disabled.
14
- * @param hmr Vite's HMR client (`import.meta.hot`), passed only in dev mode.
15
- */
16
- export function init(options = {}, hmr) {
17
- if (window.self === window.top)
18
- return;
19
- if (globalThis.__sandboxBridgeInitialized)
20
- return;
21
- globalThis.__sandboxBridgeInitialized = true;
22
- if (options.unhandledErrors !== false)
23
- setupUnhandledErrors(hmr);
24
- if (options.mountObserver !== false)
25
- setupMountObserver();
26
- if (options.hmrNotifier && hmr)
27
- setupHmrNotifier(hmr);
28
- if (options.navigationNotifier)
29
- setupNavigationNotifier();
30
- if (options.visualEditAgent)
31
- setupVisualEditAgent();
32
- }
7
+ export { setupVisualEditAgent } from "./injections/visual-edit-agent.js";
33
8
  //# sourceMappingURL=bridge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAClB,UAMI,EAAE,EACN,GAA+D;IAE/D,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,GAAG;QAAE,OAAO;IACvC,IAAK,UAAkB,CAAC,0BAA0B;QAAE,OAAO;IAC1D,UAAkB,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAEtD,IAAI,OAAO,CAAC,eAAe,KAAK,KAAK;QAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACjE,IAAI,OAAO,CAAC,aAAa,KAAK,KAAK;QAAE,kBAAkB,EAAE,CAAC;IAC1D,IAAI,OAAO,CAAC,WAAW,IAAI,GAAG;QAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtD,IAAI,OAAO,CAAC,kBAAkB;QAAE,uBAAuB,EAAE,CAAC;IAC1D,IAAI,OAAO,CAAC,eAAe;QAAE,oBAAoB,EAAE,CAAC;AACtD,CAAC"}
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
@@ -1,10 +1,8 @@
1
1
  import type { Plugin } from "vite";
2
- interface HtmlInjectionOptions {
2
+ export declare function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }: {
3
3
  hmrNotifier: boolean;
4
4
  navigationNotifier: boolean;
5
5
  visualEditAgent: boolean;
6
6
  analyticsTracker: boolean;
7
- }
8
- export declare function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }: HtmlInjectionOptions): Plugin;
9
- export {};
7
+ }): Plugin;
10
8
  //# sourceMappingURL=html-injections-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,MAAM,CAAC;AAmCtD,UAAU,oBAAoB;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,EAAE,oBAAoB,GAAG,MAAM,CAkE/B"}
1
+ {"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,MAAM,CAAC;AAwEtD,wBAAgB,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,GAiFM,MAAM,CACZ"}
@@ -30,7 +30,41 @@ history.replaceState = function (...args) {
30
30
  window.addEventListener("popstate", trackPageView);
31
31
  trackPageView();
32
32
  `;
33
+ const INJECTIONS = {
34
+ unhandledErrors: {
35
+ src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
36
+ injectTo: "head",
37
+ mode: "dev",
38
+ },
39
+ sandboxMount: {
40
+ src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
41
+ injectTo: "body",
42
+ mode: "dev",
43
+ },
44
+ hmrNotifier: {
45
+ src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
46
+ injectTo: "head",
47
+ mode: "dev",
48
+ },
49
+ navigationNotifier: {
50
+ src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
51
+ injectTo: "head",
52
+ mode: "dev",
53
+ },
54
+ analyticsTracker: {
55
+ injectTo: "head",
56
+ mode: "production",
57
+ inlineContent: ANALYTICS_TRACKER_SCRIPT,
58
+ },
59
+ };
33
60
  export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }) {
61
+ const enabledInjections = {
62
+ unhandledErrors: true,
63
+ sandboxMount: true,
64
+ hmrNotifier,
65
+ navigationNotifier,
66
+ analyticsTracker,
67
+ };
34
68
  let resolvedEnv = {};
35
69
  return {
36
70
  name: "html-injections",
@@ -41,48 +75,52 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
41
75
  },
42
76
  transformIndexHtml: {
43
77
  handler(_html, ctx) {
44
- const tags = [];
45
78
  const currentMode = ctx.server ? "dev" : "production";
46
- if (currentMode === "dev") {
47
- // Dev mode: use sandbox-bridge dynamic loader
48
- const options = JSON.stringify({
49
- hmrNotifier,
50
- navigationNotifier,
51
- visualEditAgent,
52
- unhandledErrors: true,
53
- mountObserver: true,
54
- });
79
+ const tags = Object.entries(INJECTIONS)
80
+ .filter(([key, injection]) => enabledInjections[key] && injection.mode === currentMode)
81
+ .map(([, injection]) => {
82
+ // Production injections use inline content (src paths don't work in built output)
83
+ if (injection.inlineContent) {
84
+ // Replace import.meta.env references with actual values
85
+ // Vite doesn't replace these in inline script content
86
+ let content = injection.inlineContent;
87
+ content = content.replace(/import\.meta\.env\.(\w+)/g, (_, envKey) => JSON.stringify(resolvedEnv[envKey] ?? ""));
88
+ return {
89
+ tag: "script",
90
+ attrs: { type: "module" },
91
+ children: content,
92
+ injectTo: injection.injectTo,
93
+ };
94
+ }
95
+ // Dev injections use src path (served from node_modules)
96
+ return {
97
+ tag: "script",
98
+ attrs: {
99
+ src: injection.src,
100
+ type: "module",
101
+ },
102
+ injectTo: injection.injectTo,
103
+ };
104
+ });
105
+ // Visual edit agent — loaded via dynamic import to support
106
+ // local dev iteration with ?sandbox-bridge=local
107
+ if (currentMode === "dev" && visualEditAgent) {
108
+ const dist = "/node_modules/@base44/vite-plugin/dist";
55
109
  tags.push({
56
110
  tag: "script",
57
111
  attrs: { type: "module" },
58
112
  children: [
59
113
  `if (window.self !== window.top) {`,
60
- ` (async () => {`,
61
- ` try {`,
62
- ` const mode = new URLSearchParams(location.search).get("sandbox-bridge");`,
63
- ` const url = mode === "local"`,
64
- ` ? "https://localhost:3201/index.mjs"`,
65
- ` : "/node_modules/@base44/vite-plugin/dist/statics/index.mjs";`,
66
- ` const mod = await import(url);`,
67
- ` if (typeof mod.init === "function") mod.init(${options}, import.meta.hot);`,
68
- ` } catch (e) {`,
69
- ` console.error("[sandbox-bridge] Failed to load:", e);`,
70
- ` }`,
71
- ` })();`,
114
+ ` const mode = new URLSearchParams(location.search).get("sandbox-bridge");`,
115
+ ` const url = mode === "local"`,
116
+ ` ? "https://localhost:3201/index.mjs"`,
117
+ ` : "${dist}/statics/index.mjs";`,
118
+ ` import(url)`,
119
+ ` .then(mod => { if (typeof mod.setupVisualEditAgent === "function") mod.setupVisualEditAgent(); })`,
120
+ ` .catch(e => console.error("[visual-edit-agent] Failed to load:", e));`,
72
121
  `}`,
73
122
  ].join("\n"),
74
- injectTo: "head",
75
- });
76
- }
77
- // Production: inline analytics tracker with env var replacement
78
- if (currentMode === "production" && analyticsTracker) {
79
- let content = ANALYTICS_TRACKER_SCRIPT;
80
- content = content.replace(/import\.meta\.env\.(\w+)/g, (_, envKey) => JSON.stringify(resolvedEnv[envKey] ?? ""));
81
- tags.push({
82
- tag: "script",
83
- attrs: { type: "module" },
84
- children: content,
85
- injectTo: "head",
123
+ injectTo: "body",
86
124
  });
87
125
  }
88
126
  return tags;
@@ -1 +1 @@
1
- {"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BhC,CAAC;AASF,MAAM,UAAU,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACK;IACrB,IAAI,WAAW,GAA2B,EAAE,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,cAAc,CAAC,MAAM;YACnB,iDAAiD;YACjD,0DAA0D;YAC1D,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,kB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AAQ,EAAE;wBACzB,QAAQ,EAAE,OAAO;wBACjB,QAAQ,EAAE,MAAM;qBACjB,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAW/B,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BhC,CAAC;AAEF,MAAM,UAAU,GAA8B;IAC5C,eAAe,EAAE;QACf,GAAG,EAAE,gFAAgF;QACrF,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,6EAA6E;QAClF,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,WAAW,EAAE;QACX,GAAG,EAAE,2EAA2E;QAChF,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,kBAAkB,EAAE;QAClB,GAAG,EAAE,0EAA0E;QAC/E,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,gBAAgB,EAAE;QAChB,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,YAAY;QAClB,aAAa,EAAE,wBAAwB;KACxC;CACF,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GAMjB;IACC,MAAM,iBAAiB,GAA4B;QACjD,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,WAAW;QACX,kBAAkB;QAClB,gBAAgB;KACjB,CAAC;IAEF,IAAI,WAAW,GAA2B,EAAE,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,cAAc,CAAC,MAAM;YACnB,iDAAiD;YAC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C;gBACJ,CAAC,CAAC,CAAC;gBAEL,2DAA2D;gBAC3D,iDAAiD;gBACjD,IAAI,WAAW,KAAK,KAAK,IAAI,eAAe,EAAE,CAAC;oBAC7C,MAAM,IAAI,GAAG,wCAAwC,CAAC;oBACtD,IAAI,CAAC,IAAI,CAAC;wBACR,GAAG,EAAE,QAAQ;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,QAAQ,EAAE;4BACR,mCAAmC;4BACnC,4EAA4E;4BAC5E,gCAAgC;4BAChC,0CAA0C;4BAC1C,UAAU,IAAI,sBAAsB;4BACpC,eAAe;4BACf,uGAAuG;4BACvG,2EAA2E;4BAC3E,GAAG;yBACJ,CAAC,IAAI,CAAC,IAAI,CAAC;wBACZ,QAAQ,EAAE,MAAM;qBACjB,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF;KACQ,CAAC;AACd,CAAC"}
@@ -1,3 +1,2 @@
1
- /** Intercept pushState / replaceState / popstate and notify the parent of URL changes. */
2
- export declare function setupNavigationNotifier(): void;
1
+ export {};
3
2
  //# sourceMappingURL=navigation-notifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-notifier.d.ts","sourceRoot":"","sources":["../../src/injections/navigation-notifier.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,wBAAgB,uBAAuB,SA0CtC"}
1
+ {"version":3,"file":"navigation-notifier.d.ts","sourceRoot":"","sources":["../../src/injections/navigation-notifier.ts"],"names":[],"mappings":""}
@@ -1,5 +1,4 @@
1
- /** Intercept pushState / replaceState / popstate and notify the parent of URL changes. */
2
- export function setupNavigationNotifier() {
1
+ if (window.self !== window.top) {
3
2
  let lastUrl = window.location.href;
4
3
  function notifyNavigation() {
5
4
  const currentUrl = window.location.href;
@@ -31,4 +30,5 @@ export function setupNavigationNotifier() {
31
30
  url: window.location.href,
32
31
  }, "*");
33
32
  }
33
+ export {};
34
34
  //# sourceMappingURL=navigation-notifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-notifier.js","sourceRoot":"","sources":["../../src/injections/navigation-notifier.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB;IACrC,IAAI,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAEnC,SAAS,gBAAgB;QACvB,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACxC,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;YAC3B,OAAO,GAAG,UAAU,CAAC;YACrB,MAAM,CAAC,MAAM,EAAE,WAAW,CACxB;gBACE,IAAI,EAAE,iBAAiB;gBACvB,GAAG,EAAE,UAAU;aAChB,EACD,GAAG,CACJ,CAAC;QACJ,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,MAAM,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,CAAC,SAAS,GAAG,UAAU,GAAG,IAAI;QACnC,iBAAiB,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,gBAAgB,EAAE,CAAC;IACrB,CAAC,CAAC;IAEF,iCAAiC;IACjC,MAAM,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChE,OAAO,CAAC,YAAY,GAAG,UAAU,GAAG,IAAI;QACtC,oBAAoB,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9B,gBAAgB,EAAE,CAAC;IACrB,CAAC,CAAC;IAEF,yCAAyC;IACzC,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAEtD,6BAA6B;IAC7B,MAAM,CAAC,MAAM,EAAE,WAAW,CACxB;QACE,IAAI,EAAE,iBAAiB;QACvB,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;KAC1B,EACD,GAAG,CACJ,CAAC;AACJ,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ACJ,CAAC"}
@@ -1,5 +1,2 @@
1
- /** Forward Vite HMR lifecycle events (beforeUpdate / afterUpdate) to the parent window. */
2
- export declare function setupHmrNotifier(hmr: {
3
- on(event: string, cb: (...args: any[]) => void): void;
4
- }): void;
1
+ export {};
5
2
  //# sourceMappingURL=sandbox-hmr-notifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-hmr-notifier.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-notifier.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE;IAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAA;CAAE,QAO9F"}
1
+ {"version":3,"file":"sandbox-hmr-notifier.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-notifier.ts"],"names":[],"mappings":""}
@@ -1,10 +1,10 @@
1
- /** Forward Vite HMR lifecycle events (beforeUpdate / afterUpdate) to the parent window. */
2
- export function setupHmrNotifier(hmr) {
3
- hmr.on("vite:beforeUpdate", () => {
1
+ if (import.meta.hot) {
2
+ import.meta.hot.on("vite:beforeUpdate", () => {
4
3
  window.parent?.postMessage({ type: "sandbox:beforeUpdate" }, "*");
5
4
  });
6
- hmr.on("vite:afterUpdate", () => {
5
+ import.meta.hot.on("vite:afterUpdate", () => {
7
6
  window.parent?.postMessage({ type: "sandbox:afterUpdate" }, "*");
8
7
  });
9
8
  }
9
+ export {};
10
10
  //# sourceMappingURL=sandbox-hmr-notifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-hmr-notifier.js","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-notifier.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,UAAU,gBAAgB,CAAC,GAA8D;IAC7F,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"sandbox-hmr-notifier.js","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-notifier.ts"],"names":[],"mappings":"AAAA,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,2 @@
1
- /** Observe DOM mutations and notify the parent when instrumented elements are mounted or unmounted. */
2
- export declare function setupMountObserver(): void;
1
+ export {};
3
2
  //# sourceMappingURL=sandbox-mount-observer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-mount-observer.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-mount-observer.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,wBAAgB,kBAAkB,SAuBjC"}
1
+ {"version":3,"file":"sandbox-mount-observer.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-mount-observer.ts"],"names":[],"mappings":""}
@@ -1,5 +1,4 @@
1
- /** Observe DOM mutations and notify the parent when instrumented elements are mounted or unmounted. */
2
- export function setupMountObserver() {
1
+ if (window.self !== window.top) {
3
2
  const observer = new MutationObserver((mutations) => {
4
3
  const nodesAdded = mutations.some((mutation) => mutation.addedNodes.length > 0);
5
4
  const nodesRemoved = mutations.some((mutation) => mutation.removedNodes.length > 0);
@@ -15,4 +14,5 @@ export function setupMountObserver() {
15
14
  });
16
15
  observer.observe(document.body, { childList: true, subtree: true });
17
16
  }
17
+ export {};
18
18
  //# sourceMappingURL=sandbox-mount-observer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-mount-observer.js","sourceRoot":"","sources":["../../src/injections/sandbox-mount-observer.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,MAAM,UAAU,kBAAkB;IAChC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,CAAC,SAAS,EAAE,EAAE;QAClD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,CAC/B,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAC7C,CAAC;QACF,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CACjC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAC/C,CAAC;QACF,IAAI,UAAU,IAAI,YAAY,EAAE,CAAC;YAC/B,MAAM,yBAAyB,GAC7B,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAC5B,gDAAgD,CACjD,CAAC,MAAM,GAAG,CAAC,CAAC;YAEf,IAAI,yBAAyB,EAAE,CAAC;gBAC9B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,GAAG,CAAC,CAAC;YACjE,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,MAAM,EAAE,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AAC,QAAQ,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC"}
@@ -1,5 +1,2 @@
1
- /** Register global error and unhandled-rejection listeners that report to the parent window. */
2
- export declare function setupUnhandledErrors(hmr?: {
3
- on(event: string, cb: (...args: any[]) => void): void;
4
- }): void;
1
+ export {};
5
2
  //# sourceMappingURL=unhandled-errors-handlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unhandled-errors-handlers.d.ts","sourceRoot":"","sources":["../../src/injections/unhandled-errors-handlers.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAIhG,wBAAgB,oBAAoB,CAAC,GAAG,CAAC,EAAE;IAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAA;CAAE,QA4FnG"}
1
+ {"version":3,"file":"unhandled-errors-handlers.d.ts","sourceRoot":"","sources":["../../src/injections/unhandled-errors-handlers.ts"],"names":[],"mappings":""}
@@ -1,74 +1,72 @@
1
- /** Register global error and unhandled-rejection listeners that report to the parent window. */
2
- const ERROR_SUPPRESSION_TIMEOUT = 10000;
3
- export function setupUnhandledErrors(hmr) {
4
- window.removeEventListener("unhandledrejection", handleUnhandledRejection);
5
- window.removeEventListener("error", handleWindowError);
6
- window.addEventListener("unhandledrejection", handleUnhandledRejection);
7
- window.addEventListener("error", handleWindowError);
8
- let shouldPropagateErrors = true;
9
- let suppressionTimer = null;
10
- if (hmr) {
11
- hmr.on("vite:beforeUpdate", () => {
12
- shouldPropagateErrors = false;
13
- if (suppressionTimer) {
14
- clearTimeout(suppressionTimer);
15
- }
16
- suppressionTimer = setTimeout(() => {
17
- shouldPropagateErrors = true;
18
- suppressionTimer = null;
19
- }, ERROR_SUPPRESSION_TIMEOUT);
20
- });
21
- hmr.on("vite:beforeFullReload", () => {
22
- shouldPropagateErrors = false;
23
- if (suppressionTimer) {
24
- clearTimeout(suppressionTimer);
25
- suppressionTimer = null;
26
- }
27
- });
28
- }
29
- function onAppError({ title, details, componentName, originalError, }) {
30
- if (originalError?.response?.status === 402 || !shouldPropagateErrors) {
31
- return;
1
+ /// <reference types="vite/client" />
2
+ window.removeEventListener("unhandledrejection", handleUnhandledRejection);
3
+ window.removeEventListener("error", handleWindowError);
4
+ window.addEventListener("unhandledrejection", handleUnhandledRejection);
5
+ window.addEventListener("error", handleWindowError);
6
+ let shouldPropagateErrors = true;
7
+ let suppressionTimer = null;
8
+ if (import.meta.hot) {
9
+ import.meta.hot.on("vite:beforeUpdate", () => {
10
+ shouldPropagateErrors = false;
11
+ if (suppressionTimer) {
12
+ clearTimeout(suppressionTimer);
32
13
  }
33
- window.parent?.postMessage({
34
- type: "app_error",
35
- error: {
36
- title: title.toString(),
37
- details: details?.toString(),
38
- componentName: componentName?.toString(),
39
- stack: originalError?.stack?.toString(),
40
- },
41
- }, "*");
42
- }
43
- function handleUnhandledRejection(event) {
44
- const stack = event.reason.stack;
45
- // extract function name from "at X (eval" where x is the function name
46
- const functionName = stack.match(/at\s+(\w+)\s+\(eval/)?.[1];
47
- const msg = functionName
48
- ? `Error in ${functionName}: ${event.reason.toString()}`
49
- : event.reason.toString();
50
- onAppError({
51
- title: msg,
52
- details: event.reason.toString(),
53
- componentName: functionName,
54
- originalError: event.reason,
55
- });
56
- }
57
- function handleWindowError(event) {
58
- const stack = event.error?.stack;
59
- let functionName = stack.match(/at\s+(\w+)\s+\(eval/)?.[1];
60
- if (functionName === "eval") {
61
- functionName = null;
14
+ suppressionTimer = setTimeout(() => {
15
+ shouldPropagateErrors = true;
16
+ suppressionTimer = null;
17
+ }, import.meta.env.VITE_HMR_ERROR_SUPPRESSION_DELAY ?? 10000);
18
+ });
19
+ import.meta.hot.on("vite:beforeFullReload", () => {
20
+ shouldPropagateErrors = false;
21
+ if (suppressionTimer) {
22
+ clearTimeout(suppressionTimer);
23
+ suppressionTimer = null;
62
24
  }
63
- const msg = functionName
64
- ? `in ${functionName}: ${event.error.toString()}`
65
- : event.error.toString();
66
- onAppError({
67
- title: msg,
68
- details: event.error.toString(),
69
- componentName: functionName,
70
- originalError: event.error,
71
- });
25
+ });
26
+ }
27
+ function onAppError({ title, details, componentName, originalError, }) {
28
+ if (originalError?.response?.status === 402 || !shouldPropagateErrors) {
29
+ return;
30
+ }
31
+ window.parent?.postMessage({
32
+ type: "app_error",
33
+ error: {
34
+ title: title.toString(),
35
+ details: details?.toString(),
36
+ componentName: componentName?.toString(),
37
+ stack: originalError?.stack?.toString(),
38
+ },
39
+ }, "*");
40
+ }
41
+ function handleUnhandledRejection(event) {
42
+ const stack = event.reason.stack;
43
+ // extract function name from "at X (eval" where x is the function name
44
+ const functionName = stack.match(/at\s+(\w+)\s+\(eval/)?.[1];
45
+ const msg = functionName
46
+ ? `Error in ${functionName}: ${event.reason.toString()}`
47
+ : event.reason.toString();
48
+ onAppError({
49
+ title: msg,
50
+ details: event.reason.toString(),
51
+ componentName: functionName,
52
+ originalError: event.reason,
53
+ });
54
+ }
55
+ function handleWindowError(event) {
56
+ const stack = event.error?.stack;
57
+ let functionName = stack.match(/at\s+(\w+)\s+\(eval/)?.[1];
58
+ if (functionName === "eval") {
59
+ functionName = null;
72
60
  }
61
+ const msg = functionName
62
+ ? `in ${functionName}: ${event.error.toString()}`
63
+ : event.error.toString();
64
+ onAppError({
65
+ title: msg,
66
+ details: event.error.toString(),
67
+ componentName: functionName,
68
+ originalError: event.error,
69
+ });
73
70
  }
71
+ export {};
74
72
  //# sourceMappingURL=unhandled-errors-handlers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unhandled-errors-handlers.js","sourceRoot":"","sources":["../../src/injections/unhandled-errors-handlers.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAExC,MAAM,UAAU,oBAAoB,CAAC,GAA+D;IAClG,MAAM,CAAC,mBA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