@elementor/sandbox-dev-scripts-injector 0.0.2 → 0.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/sandbox-dev-scripts-injector",
3
- "version": "0.0.2",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "exports": {
@@ -4,6 +4,7 @@ if (gcsUrl) {
4
4
  const script = document.createElement('script');
5
5
  script.src = `${gcsUrl}/sandbox-web-client/loader.js?t=${Date.now()}`;
6
6
  document.head.appendChild(script);
7
+
7
8
  console.log('[Sandbox Client] Loading client from:', gcsUrl);
8
9
  } else {
9
10
  console.log('[Sandbox Client] In dev mode but no GCS URL configured');
@@ -13,9 +13,17 @@ sendToParent('LIVE_SIGNAL', { timestamp: Date.now() });
13
13
 
14
14
  // Global error handler
15
15
  window.addEventListener('error', (e) => {
16
+ const currentURL = createURL(window.location.href);
17
+
18
+ const errorURL = createURL(e.filename);
19
+
20
+ if (!currentURL || !errorURL || errorURL.hostname !== currentURL.hostname) {
21
+ return;
22
+ }
23
+
16
24
  sendToParent('ERROR_OCCURRED', {
17
25
  message: e.message,
18
- filename: e.filename,
26
+ filename: errorURL.pathname,
19
27
  lineno: e.lineno,
20
28
  colno: e.colno,
21
29
  stack: e.error ? e.error.stack : null,
@@ -27,3 +35,11 @@ window.addEventListener('error', (e) => {
27
35
  window.addEventListener('unhandledrejection', (e) => {
28
36
  sendToParent('ERROR_OCCURRED', { reason: String(e.reason) });
29
37
  });
38
+
39
+ function createURL(url: string) {
40
+ try {
41
+ return new URL(url);
42
+ } catch {
43
+ return null;
44
+ }
45
+ }