@base44-preview/vite-plugin 1.0.38-pr.121.f18ee18 → 1.0.40-pr.123.79d914d
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/injections/unhandled-errors-handlers.d.ts +5 -0
- package/dist/injections/unhandled-errors-handlers.d.ts.map +1 -1
- package/dist/injections/unhandled-errors-handlers.js +19 -0
- package/dist/injections/unhandled-errors-handlers.js.map +1 -1
- package/package.json +1 -1
- package/src/injections/unhandled-errors-handlers.ts +23 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare function onHmrSocketConnect(): void;
|
|
2
|
+
export declare function isHmrSocketAttachError(reason: unknown, { bundled, connected }?: {
|
|
3
|
+
bundled?: boolean | undefined;
|
|
4
|
+
connected?: boolean | undefined;
|
|
5
|
+
}): boolean;
|
|
1
6
|
export declare function handleUnhandledRejection(event: any): void;
|
|
2
7
|
export declare function handleWindowError(event: any): void;
|
|
3
8
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"unhandled-errors-handlers.d.ts","sourceRoot":"","sources":["../../src/injections/unhandled-errors-handlers.ts"],"names":[],"mappings":"AAaA,wBAAgB,kBAAkB,SAEjC;AA8FD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,EACf,EAAE,OAAyD,EAAE,SAA8B,EAAE;;;CAAK,GACjG,OAAO,CAGT;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,QAelD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,QAmB3C"}
|
|
@@ -6,7 +6,12 @@ window.addEventListener("error", handleWindowError);
|
|
|
6
6
|
let shouldPropagateErrors = true;
|
|
7
7
|
let suppressionTimer = null;
|
|
8
8
|
let hadSuppressedErrors = false;
|
|
9
|
+
let hmrSocketConnected = false;
|
|
10
|
+
export function onHmrSocketConnect() {
|
|
11
|
+
hmrSocketConnected = true;
|
|
12
|
+
}
|
|
9
13
|
if (import.meta.hot) {
|
|
14
|
+
import.meta.hot.on("vite:ws:connect", onHmrSocketConnect);
|
|
10
15
|
import.meta.hot.on("vite:beforeUpdate", () => {
|
|
11
16
|
shouldPropagateErrors = false;
|
|
12
17
|
hadSuppressedErrors = false;
|
|
@@ -75,8 +80,22 @@ function describeErrorValue(value) {
|
|
|
75
80
|
return Object.prototype.toString.call(value);
|
|
76
81
|
}
|
|
77
82
|
}
|
|
83
|
+
// Vite 8's bundled client (verified through 8.3.0) sends `vite:client-connected`
|
|
84
|
+
// at bundle evaluation without a catch. When the HMR socket never opened (sandbox
|
|
85
|
+
// asleep or restarting) Vite still marks the transport connected, so that send
|
|
86
|
+
// rejects with `ws.send` on undefined. It is the only signal that the socket
|
|
87
|
+
// failed to attach, so report it as such instead of as an app error.
|
|
88
|
+
export function isHmrSocketAttachError(reason, { bundled = Boolean(window.__base44_bundled_dev__), connected = hmrSocketConnected } = {}) {
|
|
89
|
+
if (connected || !bundled || !(reason instanceof TypeError))
|
|
90
|
+
return false;
|
|
91
|
+
return /\bsend\b/.test(`${reason.message}\n${reason.stack ?? ""}`);
|
|
92
|
+
}
|
|
78
93
|
export function handleUnhandledRejection(event) {
|
|
79
94
|
const reason = event?.reason;
|
|
95
|
+
if (isHmrSocketAttachError(reason)) {
|
|
96
|
+
window.parent?.postMessage({ type: "SANDBOX_WS_ATTACH_FAILED", error: String(reason) }, "*");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
80
99
|
const functionName = extractFunctionName(reason?.stack);
|
|
81
100
|
const text = describeErrorValue(reason);
|
|
82
101
|
const msg = functionName ? `Error in ${functionName}: ${text}` : text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unhandled-errors-handlers.js","sourceRoot":"","sources":["../../src/injections/unhandled-errors-handlers.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAC;AAC3E,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAEvD,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAC;AACxE,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAEpD,IAAI,qBAAqB,GAAG,IAAI,CAAC;AACjC,IAAI,gBAAgB,GAAyC,IAAI,CAAC;AAClE,IAAI,mBAAmB,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"unhandled-errors-handlers.js","sourceRoot":"","sources":["../../src/injections/unhandled-errors-handlers.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAC;AAC3E,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAEvD,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAC;AACxE,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAEpD,IAAI,qBAAqB,GAAG,IAAI,CAAC;AACjC,IAAI,gBAAgB,GAAyC,IAAI,CAAC;AAClE,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAChC,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,MAAM,UAAU,kBAAkB;IAChC,kBAAkB,GAAG,IAAI,CAAC;AAC5B,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;IAC1D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,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,IAAI,GACR,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,EAAE,OAAO,KAAK,QAAQ;QACjD,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,YAAY,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,UAAU,CAAC;QACT,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,YAAY;QAC3B,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -9,8 +9,14 @@ window.addEventListener("error", handleWindowError);
|
|
|
9
9
|
let shouldPropagateErrors = true;
|
|
10
10
|
let suppressionTimer: ReturnType<typeof setTimeout> | null = null;
|
|
11
11
|
let hadSuppressedErrors = false;
|
|
12
|
+
let hmrSocketConnected = false;
|
|
13
|
+
|
|
14
|
+
export function onHmrSocketConnect() {
|
|
15
|
+
hmrSocketConnected = true;
|
|
16
|
+
}
|
|
12
17
|
|
|
13
18
|
if (import.meta.hot) {
|
|
19
|
+
import.meta.hot.on("vite:ws:connect", onHmrSocketConnect);
|
|
14
20
|
import.meta.hot.on("vite:beforeUpdate", () => {
|
|
15
21
|
shouldPropagateErrors = false;
|
|
16
22
|
hadSuppressedErrors = false;
|
|
@@ -96,8 +102,25 @@ function describeErrorValue(value: unknown): string {
|
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
|
|
105
|
+
// Vite 8's bundled client (verified through 8.3.0) sends `vite:client-connected`
|
|
106
|
+
// at bundle evaluation without a catch. When the HMR socket never opened (sandbox
|
|
107
|
+
// asleep or restarting) Vite still marks the transport connected, so that send
|
|
108
|
+
// rejects with `ws.send` on undefined. It is the only signal that the socket
|
|
109
|
+
// failed to attach, so report it as such instead of as an app error.
|
|
110
|
+
export function isHmrSocketAttachError(
|
|
111
|
+
reason: unknown,
|
|
112
|
+
{ bundled = Boolean((window as any).__base44_bundled_dev__), connected = hmrSocketConnected } = {}
|
|
113
|
+
): boolean {
|
|
114
|
+
if (connected || !bundled || !(reason instanceof TypeError)) return false;
|
|
115
|
+
return /\bsend\b/.test(`${reason.message}\n${reason.stack ?? ""}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
99
118
|
export function handleUnhandledRejection(event: any) {
|
|
100
119
|
const reason = event?.reason;
|
|
120
|
+
if (isHmrSocketAttachError(reason)) {
|
|
121
|
+
window.parent?.postMessage({ type: "SANDBOX_WS_ATTACH_FAILED", error: String(reason) }, "*");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
101
124
|
const functionName = extractFunctionName(reason?.stack);
|
|
102
125
|
const text = describeErrorValue(reason);
|
|
103
126
|
const msg = functionName ? `Error in ${functionName}: ${text}` : text;
|