@elementor/sandbox-dev-scripts-injector 0.0.2

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 ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@elementor/sandbox-dev-scripts-injector",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "main": "./src/index.ts",
6
+ "exports": {
7
+ ".": "./src/index.ts"
8
+ },
9
+ "files": [
10
+ "src"
11
+ ],
12
+ "nx": {
13
+ "tags": [
14
+ "scope:client",
15
+ "type:lib"
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ const gcsUrl = import.meta.env.VITE_SCRIPTS_GCS_URL;
2
+
3
+ if (gcsUrl) {
4
+ const script = document.createElement('script');
5
+ script.src = `${gcsUrl}/sandbox-web-client/loader.js?t=${Date.now()}`;
6
+ document.head.appendChild(script);
7
+ console.log('[Sandbox Client] Loading client from:', gcsUrl);
8
+ } else {
9
+ console.log('[Sandbox Client] In dev mode but no GCS URL configured');
10
+ }
@@ -0,0 +1,29 @@
1
+ function sendToParent(type: string, data: Record<string, unknown>) {
2
+ try {
3
+ if (window.parent && window.parent !== window) {
4
+ window.parent.postMessage({ type, data }, '*');
5
+ }
6
+ } catch {
7
+ // silently fail if parent is not accessible
8
+ }
9
+ }
10
+
11
+ // Send live signal
12
+ sendToParent('LIVE_SIGNAL', { timestamp: Date.now() });
13
+
14
+ // Global error handler
15
+ window.addEventListener('error', (e) => {
16
+ sendToParent('ERROR_OCCURRED', {
17
+ message: e.message,
18
+ filename: e.filename,
19
+ lineno: e.lineno,
20
+ colno: e.colno,
21
+ stack: e.error ? e.error.stack : null,
22
+ name: e.error ? e.error.name : null,
23
+ });
24
+ });
25
+
26
+ // Unhandled promise rejection handler
27
+ window.addEventListener('unhandledrejection', (e) => {
28
+ sendToParent('ERROR_OCCURRED', { reason: String(e.reason) });
29
+ });
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ import './error-logger';
2
+ import './client-loader';