@base44-preview/vite-plugin 0.2.20-pr.27.20fa529 → 0.2.20-pr.27.45bb4b6
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/dist/bridge.d.ts +5 -17
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +5 -30
- package/dist/bridge.js.map +1 -1
- package/dist/html-injections-plugin.d.ts +3 -4
- package/dist/html-injections-plugin.d.ts.map +1 -1
- package/dist/html-injections-plugin.js +125 -33
- package/dist/html-injections-plugin.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/injections/navigation-notifier.d.ts +1 -2
- package/dist/injections/navigation-notifier.d.ts.map +1 -1
- package/dist/injections/navigation-notifier.js +2 -2
- package/dist/injections/navigation-notifier.js.map +1 -1
- package/dist/injections/sandbox-hmr-notifier.d.ts +1 -4
- package/dist/injections/sandbox-hmr-notifier.d.ts.map +1 -1
- package/dist/injections/sandbox-hmr-notifier.js +4 -4
- package/dist/injections/sandbox-hmr-notifier.js.map +1 -1
- package/dist/injections/sandbox-mount-observer.d.ts +1 -2
- package/dist/injections/sandbox-mount-observer.d.ts.map +1 -1
- package/dist/injections/sandbox-mount-observer.js +2 -2
- package/dist/injections/sandbox-mount-observer.js.map +1 -1
- package/dist/injections/unhandled-errors-handlers.d.ts +1 -4
- package/dist/injections/unhandled-errors-handlers.d.ts.map +1 -1
- package/dist/injections/unhandled-errors-handlers.js +67 -69
- package/dist/injections/unhandled-errors-handlers.js.map +1 -1
- package/dist/statics/index.mjs +1 -1
- package/dist/statics/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/bridge.ts +5 -34
- package/src/html-injections-plugin.ts +154 -40
- package/src/index.ts +4 -1
- package/src/injections/navigation-notifier.ts +1 -2
- package/src/injections/sandbox-hmr-notifier.ts +3 -4
- package/src/injections/sandbox-mount-observer.ts +2 -2
- package/src/injections/unhandled-errors-handlers.ts +80 -84
|
@@ -1,97 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
window.removeEventListener("unhandledrejection", handleUnhandledRejection);
|
|
4
|
+
window.removeEventListener("error", handleWindowError);
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
window.removeEventListener("error", handleWindowError);
|
|
6
|
+
window.addEventListener("unhandledrejection", handleUnhandledRejection);
|
|
7
|
+
window.addEventListener("error", handleWindowError);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let shouldPropagateErrors = true;
|
|
10
|
+
let suppressionTimer: ReturnType<typeof setTimeout> | null = null;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (import.meta.hot) {
|
|
13
|
+
import.meta.hot.on("vite:beforeUpdate", () => {
|
|
14
|
+
shouldPropagateErrors = false;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (suppressionTimer) {
|
|
20
|
-
clearTimeout(suppressionTimer);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
suppressionTimer = setTimeout(() => {
|
|
24
|
-
shouldPropagateErrors = true;
|
|
25
|
-
suppressionTimer = null;
|
|
26
|
-
}, ERROR_SUPPRESSION_TIMEOUT);
|
|
27
|
-
});
|
|
28
|
-
hmr.on("vite:beforeFullReload", () => {
|
|
29
|
-
shouldPropagateErrors = false;
|
|
30
|
-
if (suppressionTimer) {
|
|
31
|
-
clearTimeout(suppressionTimer);
|
|
32
|
-
suppressionTimer = null;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
16
|
+
if (suppressionTimer) {
|
|
17
|
+
clearTimeout(suppressionTimer);
|
|
18
|
+
}
|
|
36
19
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}) {
|
|
48
|
-
if (originalError?.response?.status === 402 || !shouldPropagateErrors) {
|
|
49
|
-
return;
|
|
20
|
+
suppressionTimer = setTimeout(() => {
|
|
21
|
+
shouldPropagateErrors = true;
|
|
22
|
+
suppressionTimer = null;
|
|
23
|
+
}, import.meta.env.VITE_HMR_ERROR_SUPPRESSION_DELAY ?? 10000);
|
|
24
|
+
});
|
|
25
|
+
import.meta.hot.on("vite:beforeFullReload", () => {
|
|
26
|
+
shouldPropagateErrors = false;
|
|
27
|
+
if (suppressionTimer) {
|
|
28
|
+
clearTimeout(suppressionTimer);
|
|
29
|
+
suppressionTimer = null;
|
|
50
30
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
type: "app_error",
|
|
54
|
-
error: {
|
|
55
|
-
title: title.toString(),
|
|
56
|
-
details: details?.toString(),
|
|
57
|
-
componentName: componentName?.toString(),
|
|
58
|
-
stack: originalError?.stack?.toString(),
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
"*"
|
|
62
|
-
);
|
|
63
|
-
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
64
33
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
34
|
+
function onAppError({
|
|
35
|
+
title,
|
|
36
|
+
details,
|
|
37
|
+
componentName,
|
|
38
|
+
originalError,
|
|
39
|
+
}: {
|
|
40
|
+
title: string;
|
|
41
|
+
details: string;
|
|
42
|
+
componentName: string;
|
|
43
|
+
originalError: any;
|
|
44
|
+
}) {
|
|
45
|
+
if (originalError?.response?.status === 402 || !shouldPropagateErrors) {
|
|
46
|
+
return;
|
|
78
47
|
}
|
|
48
|
+
window.parent?.postMessage(
|
|
49
|
+
{
|
|
50
|
+
type: "app_error",
|
|
51
|
+
error: {
|
|
52
|
+
title: title.toString(),
|
|
53
|
+
details: details?.toString(),
|
|
54
|
+
componentName: componentName?.toString(),
|
|
55
|
+
stack: originalError?.stack?.toString(),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
"*"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
79
61
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
62
|
+
function handleUnhandledRejection(event: any) {
|
|
63
|
+
const stack = event.reason.stack;
|
|
64
|
+
// extract function name from "at X (eval" where x is the function name
|
|
65
|
+
const functionName = stack.match(/at\s+(\w+)\s+\(eval/)?.[1];
|
|
66
|
+
const msg = functionName
|
|
67
|
+
? `Error in ${functionName}: ${event.reason.toString()}`
|
|
68
|
+
: event.reason.toString();
|
|
69
|
+
onAppError({
|
|
70
|
+
title: msg,
|
|
71
|
+
details: event.reason.toString(),
|
|
72
|
+
componentName: functionName,
|
|
73
|
+
originalError: event.reason,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
details: event.error.toString(),
|
|
93
|
-
componentName: functionName,
|
|
94
|
-
originalError: event.error,
|
|
95
|
-
});
|
|
77
|
+
function handleWindowError(event: any) {
|
|
78
|
+
const stack = event.error?.stack;
|
|
79
|
+
let functionName = stack.match(/at\s+(\w+)\s+\(eval/)?.[1];
|
|
80
|
+
if (functionName === "eval") {
|
|
81
|
+
functionName = null;
|
|
96
82
|
}
|
|
83
|
+
|
|
84
|
+
const msg = functionName
|
|
85
|
+
? `in ${functionName}: ${event.error.toString()}`
|
|
86
|
+
: event.error.toString();
|
|
87
|
+
onAppError({
|
|
88
|
+
title: msg,
|
|
89
|
+
details: event.error.toString(),
|
|
90
|
+
componentName: functionName,
|
|
91
|
+
originalError: event.error,
|
|
92
|
+
});
|
|
97
93
|
}
|