@base44-preview/vite-plugin 1.0.37-pr.121.03337a6 → 1.0.37-pr.121.de0cee3
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/README.md +1 -1
- package/dist/build-status-plugin.d.ts.map +1 -1
- package/dist/build-status-plugin.js +21 -41
- package/dist/build-status-plugin.js.map +1 -1
- package/dist/bundled-dev.js +1 -1
- package/dist/bundled-dev.js.map +1 -1
- package/dist/error-overlay-plugin.d.ts.map +1 -1
- package/dist/error-overlay-plugin.js +0 -9
- package/dist/error-overlay-plugin.js.map +1 -1
- package/dist/html-injections-plugin.d.ts +8 -10
- package/dist/html-injections-plugin.d.ts.map +1 -1
- package/dist/html-injections-plugin.js +9 -45
- package/dist/html-injections-plugin.js.map +1 -1
- package/dist/injections/sandbox-build-error-notifier.d.ts +0 -4
- package/dist/injections/sandbox-build-error-notifier.d.ts.map +1 -1
- package/dist/injections/sandbox-build-error-notifier.js +25 -22
- package/dist/injections/sandbox-build-error-notifier.js.map +1 -1
- package/dist/injections/sandbox-hmr-socket-relay.d.ts +0 -5
- package/dist/injections/sandbox-hmr-socket-relay.d.ts.map +1 -1
- package/dist/injections/sandbox-hmr-socket-relay.js +18 -22
- package/dist/injections/sandbox-hmr-socket-relay.js.map +1 -1
- package/package.json +1 -1
- package/src/build-status-plugin.ts +22 -46
- package/src/bundled-dev.ts +1 -1
- package/src/error-overlay-plugin.ts +0 -11
- package/src/html-injections-plugin.ts +17 -50
- package/src/injections/sandbox-build-error-notifier.ts +25 -28
- package/src/injections/sandbox-hmr-socket-relay.ts +15 -28
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ endpoint's job is **post-load HMR / compile errors**, not cold-start failures.
|
|
|
115
115
|
|
|
116
116
|
### Sandbox Injections
|
|
117
117
|
|
|
118
|
-
In **dev mode**, individual `<script type="module" src="...">` tags are injected for each feature, loaded directly from `node_modules`. Under bundled dev mode the tags are injected with `order: "pre"` instead, so they become part of the HTML entry and are folded into the bundle (with `import.meta.hot` available).
|
|
118
|
+
In **dev mode**, individual `<script type="module" src="...">` tags are injected for each feature, loaded directly from `node_modules`. Under bundled dev mode the tags are injected with `order: "pre"` instead, so they become part of the HTML entry and are folded into the bundle (with `import.meta.hot` available).
|
|
119
119
|
|
|
120
120
|
- **Error handlers** (`unhandled-errors-handlers.js`) — Global `error` and `unhandledrejection` listeners that report to the parent via `postMessage`.
|
|
121
121
|
- **Mount observer** (`sandbox-mount-observer.js`) — `MutationObserver` that detects when instrumented elements (`data-source-location`) are rendered.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-status-plugin.d.ts","sourceRoot":"","sources":["../src/build-status-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"build-status-plugin.d.ts","sourceRoot":"","sources":["../src/build-status-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,MAAM,EAAiB,MAAM,MAAM,CAAC;AA0E3D;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA2ClE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CA6F1C"}
|
|
@@ -18,24 +18,17 @@ import { isBundledDev } from "./bundled-dev.js";
|
|
|
18
18
|
* The status is always reported in the body with HTTP `200`, even on error:
|
|
19
19
|
* a `500` here would trip the preview proxy's own error path.
|
|
20
20
|
*
|
|
21
|
-
* Cold-start caveat
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
21
|
+
* Cold-start caveat: errors thrown before any client has connected are not
|
|
22
|
+
* sent over the HMR channel, so a boot-time transform failure may briefly
|
|
23
|
+
* read `ok: true`. That window is covered server-side by the existing
|
|
24
|
+
* dev_server_error_classifier. This endpoint reports post-load
|
|
25
|
+
* HMR / compile errors.
|
|
26
26
|
*/
|
|
27
27
|
const ENDPOINT = "/__build_status";
|
|
28
28
|
/** Max characters kept per scrubbed string field. */
|
|
29
29
|
const MAX_FIELD = 4000;
|
|
30
30
|
/** Max characters kept for the code frame. */
|
|
31
31
|
const MAX_FRAME = 2000;
|
|
32
|
-
const PATCHED = Symbol.for("base44.buildStatus.loggerPatched");
|
|
33
|
-
// Plugin hooks run once per environment in bundled dev; only the client's
|
|
34
|
-
// build is the preview. Older Vite has no `this.environment`.
|
|
35
|
-
function isClientEnvironment(ctx) {
|
|
36
|
-
const name = ctx?.environment?.name;
|
|
37
|
-
return name === undefined || name === "client";
|
|
38
|
-
}
|
|
39
32
|
const LOOPBACK_ADDRESSES = new Set([
|
|
40
33
|
"127.0.0.1",
|
|
41
34
|
"::1",
|
|
@@ -118,45 +111,32 @@ export function buildStatusPlugin() {
|
|
|
118
111
|
configResolved(config) {
|
|
119
112
|
bundled = isBundledDev(config);
|
|
120
113
|
},
|
|
121
|
-
// Bundled dev runs the rolldown build hooks on every rebuild
|
|
122
|
-
//
|
|
123
|
-
// was recorded before. Other environments' builds say nothing about the preview.
|
|
114
|
+
// Bundled dev runs the rolldown build hooks on every rebuild; a build that
|
|
115
|
+
// reaches generateBundle superseded whatever error was recorded before.
|
|
124
116
|
buildEnd(error) {
|
|
125
|
-
if (bundled && error
|
|
117
|
+
if (bundled && error)
|
|
126
118
|
lastError = error;
|
|
127
119
|
},
|
|
128
120
|
generateBundle() {
|
|
129
|
-
if (bundled
|
|
121
|
+
if (bundled)
|
|
130
122
|
lastError = null;
|
|
131
123
|
},
|
|
132
124
|
configureServer(server) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// Kept out of the endpoint's try so a logger surprise never unmounts it.
|
|
139
|
-
try {
|
|
125
|
+
try {
|
|
126
|
+
if (bundled) {
|
|
127
|
+
// Bundled dev reports build failures through the environment logger
|
|
128
|
+
// (`{ error }` option) and per-client sends, never the broadcast
|
|
129
|
+
// channel patched below.
|
|
140
130
|
const logger = server.environments.client.logger;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
patched[PATCHED] = true;
|
|
149
|
-
logger.error = patched;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
// Build failures then surface only via buildEnd; the endpoint still mounts.
|
|
131
|
+
const origError = logger.error.bind(logger);
|
|
132
|
+
logger.error = (msg, options) => {
|
|
133
|
+
if (options?.error)
|
|
134
|
+
lastError = options.error;
|
|
135
|
+
return origError(msg, options);
|
|
136
|
+
};
|
|
154
137
|
}
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
138
|
// Observe the HMR channel: an `error` payload records the last
|
|
158
|
-
// error; a successful `update` / `full-reload` clears it.
|
|
159
|
-
// bundled dev too: nothing is broadcast there, so it is inert.
|
|
139
|
+
// error; a successful `update` / `full-reload` clears it.
|
|
160
140
|
const ch = (server.hot ?? server.ws);
|
|
161
141
|
if (ch && typeof ch.send === "function") {
|
|
162
142
|
const orig = ch.send.bind(ch);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-status-plugin.js","sourceRoot":"","sources":["../src/build-status-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAEnC,qDAAqD;AACrD,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,8CAA8C;AAC9C,MAAM,SAAS,GAAG,IAAI,CAAC;AAIvB,MAAM,
|
|
1
|
+
{"version":3,"file":"build-status-plugin.js","sourceRoot":"","sources":["../src/build-status-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH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C7D,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/bundled-dev.js
CHANGED
package/dist/bundled-dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundled-dev.js","sourceRoot":"","sources":["../src/bundled-dev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,MAAM,YAAY,GAAI,MAAkE;QACtF,EAAE,YAAY,CAAC;IACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"bundled-dev.js","sourceRoot":"","sources":["../src/bundled-dev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,MAAM,YAAY,GAAI,MAAkE;QACtF,EAAE,YAAY,CAAC;IACjB,OAAO,YAAY,EAAE,UAAU,KAAK,IAAI,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-overlay-plugin.d.ts","sourceRoot":"","sources":["../src/error-overlay-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAUnC,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"error-overlay-plugin.d.ts","sourceRoot":"","sources":["../src/error-overlay-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAUnC,wBAAgB,kBAAkB,IA+B3B,MAAM,CACZ"}
|
|
@@ -12,15 +12,6 @@ export function errorOverlayPlugin() {
|
|
|
12
12
|
// Bundled dev never serves client.mjs, so the swap below cannot run. Turn
|
|
13
13
|
// Vite's overlay off and let sandbox-build-error-notifier forward the error.
|
|
14
14
|
config: (config) => isBundledDev(config) ? { server: { hmr: { overlay: false } } } : null,
|
|
15
|
-
// `config` sees only the user config; a later plugin or CLI flag can still
|
|
16
|
-
// turn bundled dev on, leaving Vite's overlay up next to the notifier.
|
|
17
|
-
configResolved(config) {
|
|
18
|
-
const hmr = config.server.hmr;
|
|
19
|
-
if (isBundledDev(config) && hmr !== false && (hmr === true || hmr?.overlay !== false)) {
|
|
20
|
-
console.warn("[error-overlay] Bundled dev mode is on but server.hmr.overlay is not false — " +
|
|
21
|
-
"Vite's own overlay will show alongside the app_error sent to the parent.");
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
15
|
transform(code, id, opts = {}) {
|
|
25
16
|
if (opts?.ssr)
|
|
26
17
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-overlay-plugin.js","sourceRoot":"","sources":["../src/error-overlay-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,oEAAoE;AACpE,iFAAiF;AACjF,gFAAgF;AAChF,kCAAkC;AAClC,MAAM,iBAAiB,GACrB,mFAAmF,CAAC;AAEtF,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa;QAChD,0EAA0E;QAC1E,6EAA6E;QAC7E,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CACjB,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;QACvE,
|
|
1
|
+
{"version":3,"file":"error-overlay-plugin.js","sourceRoot":"","sources":["../src/error-overlay-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,oEAAoE;AACpE,iFAAiF;AACjF,gFAAgF;AAChF,kCAAkC;AAClC,MAAM,iBAAiB,GACrB,mFAAmF,CAAC;AAEtF,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa;QAChD,0EAA0E;QAC1E,6EAA6E;QAC7E,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CACjB,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;QACvE,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,EAAE;YAC3B,IAAI,IAAI,EAAE,GAAG;gBAAE,OAAO;YAEtB,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;gBAAE,OAAO;YAExD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CACtE,gBAAgB;gBAChB,IAAI;gBACJ,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,kBAAkB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAC3E,CAAC;YACF,wEAAwE;YACxE,sEAAsE;YACtE,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CACV,oEAAoE;oBAClE,sEAAsE;oBACtE,oEAAoE,CACvE,CAAC;gBACF,4EAA4E;gBAC5E,OAAO;YACT,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACQ,CAAC;AACd,CAAC"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Connect, Plugin } from "vite";
|
|
3
|
-
/**
|
|
4
|
-
* Bundled dev resolves module-script `src` through the bundler instead of the
|
|
5
|
-
* dev server, so a node_modules URL would break on any non-flat install. These
|
|
6
|
-
* ids are mapped onto the plugin's own dist tree by `resolveId` below.
|
|
7
|
-
*/
|
|
8
|
-
export declare const BUNDLED_INJECTION_PREFIX = "virtual:base44-vite-plugin/";
|
|
1
|
+
import type { Plugin } from "vite";
|
|
9
2
|
/** This file lives in dist/ once built, so its directory is the served root. */
|
|
10
3
|
export declare const PLUGIN_DIST_DIR: string;
|
|
11
|
-
export declare function resolveBundledInjection(id: string, distDir?: string): string | undefined;
|
|
12
4
|
/**
|
|
13
5
|
* Bundled dev mounts no static/transform middleware, so the visual-edit agent's
|
|
14
6
|
* dynamic `import()` of dist/statics/index.mjs would fall through to the SPA
|
|
15
7
|
* fallback and receive index.html. Serve the plugin's own dist tree instead.
|
|
16
8
|
*/
|
|
17
|
-
export declare function serveDistMiddleware(distDir: string): (req:
|
|
9
|
+
export declare function serveDistMiddleware(distDir: string): (req: {
|
|
10
|
+
url?: string | undefined;
|
|
11
|
+
}, res: {
|
|
12
|
+
statusCode: number;
|
|
13
|
+
setHeader: (k: string, v: string) => void;
|
|
14
|
+
end: (b?: string) => void;
|
|
15
|
+
}, next: (err?: unknown) => void) => void;
|
|
18
16
|
export declare function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }: {
|
|
19
17
|
hmrNotifier: boolean;
|
|
20
18
|
navigationNotifier: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAoC,MAAM,MAAM,CAAC;AAgGrE,gFAAgF;AAChF,eAAO,MAAM,eAAe,QAA+C,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,IAE/C,KAAK;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EACjC,KAAK;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,EACjG,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,UAoBhC;AAED,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,GAAG,MAAM,EAAE,CAiHX"}
|
|
@@ -36,41 +36,35 @@ if (window.self === window.top) {
|
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
38
|
const DIST_URL_PREFIX = "/node_modules/@base44/vite-plugin/dist";
|
|
39
|
-
/**
|
|
40
|
-
* Bundled dev resolves module-script `src` through the bundler instead of the
|
|
41
|
-
* dev server, so a node_modules URL would break on any non-flat install. These
|
|
42
|
-
* ids are mapped onto the plugin's own dist tree by `resolveId` below.
|
|
43
|
-
*/
|
|
44
|
-
export const BUNDLED_INJECTION_PREFIX = "virtual:base44-vite-plugin/";
|
|
45
39
|
const INJECTIONS = {
|
|
46
40
|
unhandledErrors: {
|
|
47
|
-
|
|
41
|
+
src: `${DIST_URL_PREFIX}/injections/unhandled-errors-handlers.js`,
|
|
48
42
|
injectTo: "head",
|
|
49
43
|
mode: "dev",
|
|
50
44
|
},
|
|
51
45
|
sandboxMount: {
|
|
52
|
-
|
|
46
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-mount-observer.js`,
|
|
53
47
|
injectTo: "body",
|
|
54
48
|
mode: "dev",
|
|
55
49
|
},
|
|
56
50
|
hmrNotifier: {
|
|
57
|
-
|
|
51
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-hmr-notifier.js`,
|
|
58
52
|
injectTo: "head",
|
|
59
53
|
mode: "dev",
|
|
60
54
|
},
|
|
61
55
|
navigationNotifier: {
|
|
62
|
-
|
|
56
|
+
src: `${DIST_URL_PREFIX}/injections/navigation-notifier.js`,
|
|
63
57
|
injectTo: "head",
|
|
64
58
|
mode: "dev",
|
|
65
59
|
},
|
|
66
60
|
buildErrorNotifier: {
|
|
67
|
-
|
|
61
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-build-error-notifier.js`,
|
|
68
62
|
injectTo: "head",
|
|
69
63
|
mode: "dev",
|
|
70
64
|
bundledOnly: true,
|
|
71
65
|
},
|
|
72
66
|
hmrSocketRelay: {
|
|
73
|
-
|
|
67
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-hmr-socket-relay.js`,
|
|
74
68
|
injectTo: "head",
|
|
75
69
|
mode: "dev",
|
|
76
70
|
bundledOnly: true,
|
|
@@ -88,12 +82,6 @@ const CONTENT_TYPES = {
|
|
|
88
82
|
};
|
|
89
83
|
/** This file lives in dist/ once built, so its directory is the served root. */
|
|
90
84
|
export const PLUGIN_DIST_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
91
|
-
const VISUAL_EDIT_AGENT_FILE = "statics/index.mjs";
|
|
92
|
-
export function resolveBundledInjection(id, distDir = PLUGIN_DIST_DIR) {
|
|
93
|
-
if (!id.startsWith(BUNDLED_INJECTION_PREFIX))
|
|
94
|
-
return undefined;
|
|
95
|
-
return path.join(distDir, id.slice(BUNDLED_INJECTION_PREFIX.length));
|
|
96
|
-
}
|
|
97
85
|
/**
|
|
98
86
|
* Bundled dev mounts no static/transform middleware, so the visual-edit agent's
|
|
99
87
|
* dynamic `import()` of dist/statics/index.mjs would fall through to the SPA
|
|
@@ -104,15 +92,7 @@ export function serveDistMiddleware(distDir) {
|
|
|
104
92
|
const url = (req.url ?? "").split("?")[0] ?? "";
|
|
105
93
|
if (!url.startsWith(`${DIST_URL_PREFIX}/`))
|
|
106
94
|
return next();
|
|
107
|
-
|
|
108
|
-
return next();
|
|
109
|
-
let relative;
|
|
110
|
-
try {
|
|
111
|
-
relative = decodeURIComponent(url.slice(DIST_URL_PREFIX.length + 1));
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
return next();
|
|
115
|
-
}
|
|
95
|
+
const relative = decodeURIComponent(url.slice(DIST_URL_PREFIX.length + 1));
|
|
116
96
|
const filePath = path.resolve(distDir, relative);
|
|
117
97
|
const type = CONTENT_TYPES[path.extname(filePath)];
|
|
118
98
|
if (!type ||
|
|
@@ -124,14 +104,10 @@ export function serveDistMiddleware(distDir) {
|
|
|
124
104
|
res.statusCode = 200;
|
|
125
105
|
res.setHeader("Content-Type", type);
|
|
126
106
|
res.setHeader("Cache-Control", "no-store");
|
|
127
|
-
|
|
128
|
-
createReadStream(filePath).on("error", () => res.end()).pipe(res);
|
|
107
|
+
createReadStream(filePath).pipe(res);
|
|
129
108
|
};
|
|
130
109
|
}
|
|
131
110
|
export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }) {
|
|
132
|
-
// The two bundled-only scripts stand in for things that are unconditional in
|
|
133
|
-
// the middleware server (the error overlay swap and the preview bridge's
|
|
134
|
-
// `/@vite/client` import), so they do not follow the opt-in toggles.
|
|
135
111
|
const enabledInjections = {
|
|
136
112
|
unhandledErrors: true,
|
|
137
113
|
sandboxMount: true,
|
|
@@ -141,8 +117,6 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
141
117
|
hmrSocketRelay: true,
|
|
142
118
|
analyticsTracker,
|
|
143
119
|
};
|
|
144
|
-
// Written by `dev.configResolved`; the three plugins below are always
|
|
145
|
-
// registered together and read this shared state.
|
|
146
120
|
let resolvedEnv = {};
|
|
147
121
|
let isServe = false;
|
|
148
122
|
let bundled = false;
|
|
@@ -161,12 +135,9 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
161
135
|
injectTo: injection.injectTo,
|
|
162
136
|
};
|
|
163
137
|
}
|
|
164
|
-
const src = bundled
|
|
165
|
-
? `${BUNDLED_INJECTION_PREFIX}${injection.file}`
|
|
166
|
-
: `${DIST_URL_PREFIX}/${injection.file}`;
|
|
167
138
|
return {
|
|
168
139
|
tag: "script",
|
|
169
|
-
attrs: { src, type: "module" },
|
|
140
|
+
attrs: { src: injection.src, type: "module" },
|
|
170
141
|
injectTo: injection.injectTo,
|
|
171
142
|
};
|
|
172
143
|
});
|
|
@@ -206,10 +177,6 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
206
177
|
configureServer(server) {
|
|
207
178
|
if (!bundled)
|
|
208
179
|
return;
|
|
209
|
-
if (visualEditAgent && !existsSync(path.join(PLUGIN_DIST_DIR, VISUAL_EDIT_AGENT_FILE))) {
|
|
210
|
-
console.warn(`[html-injections] ${VISUAL_EDIT_AGENT_FILE} not found under ${PLUGIN_DIST_DIR}; ` +
|
|
211
|
-
"the visual edit agent will not load in bundled dev mode.");
|
|
212
|
-
}
|
|
213
180
|
server.middlewares.use(serveDistMiddleware(PLUGIN_DIST_DIR));
|
|
214
181
|
},
|
|
215
182
|
transformIndexHtml: {
|
|
@@ -224,9 +191,6 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
224
191
|
// injecting after its own HTML processing, exactly as before.
|
|
225
192
|
const devBundled = {
|
|
226
193
|
name: "html-injections-bundled",
|
|
227
|
-
resolveId(id) {
|
|
228
|
-
return resolveBundledInjection(id);
|
|
229
|
-
},
|
|
230
194
|
transformIndexHtml: {
|
|
231
195
|
order: "pre",
|
|
232
196
|
handler() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAahD,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BhC,CAAC;AAEF,MAAM,eAAe,GAAG,wCAAwC,CAAC;AAEjE,MAAM,UAAU,GAA8B;IAC5C,eAAe,EAAE;QACf,GAAG,EAAE,GAAG,eAAe,0CAA0C;QACjE,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,GAAG,eAAe,uCAAuC;QAC9D,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,WAAW,EAAE;QACX,GAAG,EAAE,GAAG,eAAe,qCAAqC;QAC5D,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,kBAAkB,EAAE;QAClB,GAAG,EAAE,GAAG,eAAe,oCAAoC;QAC3D,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,kBAAkB,EAAE;QAClB,GAAG,EAAE,GAAG,eAAe,6CAA6C;QACpE,QAAQ,EAAE,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-build-error-notifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sandbox-build-error-notifier.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-build-error-notifier.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,CAAC"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const stack = typeof err.stack === "string" ? err.stack : undefined;
|
|
6
|
-
const loc = err.loc;
|
|
7
|
-
const file = loc?.file ?? (typeof err.id === "string" ? err.id : undefined);
|
|
8
|
-
const where = file && loc?.line != null ? `${file}:${loc.line}:${loc.column ?? 0}` : file;
|
|
9
|
-
const details = [where, typeof err.frame === "string" ? err.frame : undefined, stack]
|
|
10
|
-
.filter(Boolean)
|
|
11
|
-
.join("\n");
|
|
12
|
-
win.parent?.postMessage({
|
|
13
|
-
type: "app_error",
|
|
14
|
-
error: {
|
|
15
|
-
title: message,
|
|
16
|
-
details: details || undefined,
|
|
17
|
-
componentName: undefined,
|
|
18
|
-
originalError: { message, stack, plugin: err.plugin, id: err.id, loc },
|
|
19
|
-
stack,
|
|
20
|
-
},
|
|
21
|
-
}, "*");
|
|
22
|
-
}
|
|
2
|
+
// Bundled dev mode keeps Vite's own client, so the ErrorOverlay swap in
|
|
3
|
+
// error-overlay-plugin never runs. The overlay is disabled server-side instead
|
|
4
|
+
// and build errors are forwarded here in the same `app_error` shape.
|
|
23
5
|
if (import.meta.hot) {
|
|
24
|
-
import.meta.hot.on("vite:error", (payload) =>
|
|
6
|
+
import.meta.hot.on("vite:error", (payload) => {
|
|
7
|
+
const err = payload?.err ?? {};
|
|
8
|
+
const message = typeof err.message === "string" ? err.message : "Build error";
|
|
9
|
+
const stack = typeof err.stack === "string" ? err.stack : undefined;
|
|
10
|
+
const loc = err.loc;
|
|
11
|
+
const file = loc?.file ?? (typeof err.id === "string" ? err.id : undefined);
|
|
12
|
+
const where = file && loc?.line != null ? `${file}:${loc.line}:${loc.column ?? 0}` : file;
|
|
13
|
+
const details = [where, typeof err.frame === "string" ? err.frame : undefined, stack]
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.join("\n");
|
|
16
|
+
window.parent?.postMessage({
|
|
17
|
+
type: "app_error",
|
|
18
|
+
error: {
|
|
19
|
+
title: message,
|
|
20
|
+
details: details || undefined,
|
|
21
|
+
componentName: undefined,
|
|
22
|
+
originalError: { message, stack, plugin: err.plugin, id: err.id, loc },
|
|
23
|
+
stack,
|
|
24
|
+
},
|
|
25
|
+
}, "*");
|
|
26
|
+
});
|
|
25
27
|
}
|
|
28
|
+
export {};
|
|
26
29
|
//# sourceMappingURL=sandbox-build-error-notifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-build-error-notifier.js","sourceRoot":"","sources":["../../src/injections/sandbox-build-error-notifier.ts"],"names":[],"mappings":"AAAA,qCAAqC;
|
|
1
|
+
{"version":3,"file":"sandbox-build-error-notifier.js","sourceRoot":"","sources":["../../src/injections/sandbox-build-error-notifier.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,wEAAwE;AACxE,+EAA+E;AAC/E,qEAAqE;AACrE,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,OAA0C,EAAE,EAAE;QAC9E,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;QAC9E,MAAM,KAAK,GAAG,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACpE,MAAM,GAAG,GAAG,GAAG,CAAC,GAAoE,CAAC;QACrF,MAAM,IAAI,GAAG,GAAG,EAAE,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1F,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC;aAClF,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,CAAC,MAAM,EAAE,WAAW,CACxB;YACE,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACL,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,OAAO,IAAI,SAAS;gBAC7B,aAAa,EAAE,SAAS;gBACxB,aAAa,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE;gBACtE,KAAK;aACN;SACF,EACD,GAAG,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
type HotEvents = {
|
|
2
|
-
on: (event: string, cb: (payload?: unknown) => unknown) => void;
|
|
3
|
-
};
|
|
4
|
-
export declare const PREVIEW_FE_VERSION_PARAM = "previewFE_version";
|
|
5
|
-
export declare function attachHmrSocketRelay(hot: HotEvents, win?: Window): void;
|
|
6
1
|
export {};
|
|
7
2
|
//# sourceMappingURL=sandbox-hmr-socket-relay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-hmr-socket-relay.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-socket-relay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sandbox-hmr-socket-relay.d.ts","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-socket-relay.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,CAAC"}
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
hot.on("vite:ws:connect", () => {
|
|
11
|
-
win.parent?.postMessage({ type: "SANDBOX_WS_CONNECT" }, "*");
|
|
2
|
+
// The preview proxy's bridge watches the HMR socket by importing /@vite/client,
|
|
3
|
+
// which bundled dev mode does not serve. This module ships inside the bundle and
|
|
4
|
+
// reports the same events; the bridge skips its own attach when it sees the flag.
|
|
5
|
+
window.__base44_bundled_dev__ = true;
|
|
6
|
+
if (import.meta.hot && window.self !== window.top) {
|
|
7
|
+
const previewFEVersion = Number(new URLSearchParams(window.location.search).get("previewFE_version")) || 0;
|
|
8
|
+
import.meta.hot.on("vite:ws:connect", () => {
|
|
9
|
+
window.parent?.postMessage({ type: "SANDBOX_WS_CONNECT" }, "*");
|
|
12
10
|
});
|
|
13
|
-
hot.on("vite:ws:disconnect", () => {
|
|
14
|
-
|
|
11
|
+
import.meta.hot.on("vite:ws:disconnect", () => {
|
|
12
|
+
window.parent?.postMessage({ type: "SANDBOX_WS_DISCONNECT" }, "*");
|
|
15
13
|
});
|
|
16
|
-
// Vite
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
// Vite awaits these listeners before reloading; a pending promise lets the
|
|
15
|
+
// editor swap in a fresh iframe instead of reloading in place.
|
|
16
|
+
import.meta.hot.on("vite:beforeFullReload", () => {
|
|
17
|
+
window.parent?.postMessage({ type: "sandbox:beforeFullReload" }, "*");
|
|
18
|
+
if (previewFEVersion > 0)
|
|
19
|
+
return new Promise(() => { });
|
|
20
|
+
return undefined;
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
// listeners above are always registered before the first connect event.
|
|
26
|
-
if (import.meta.hot)
|
|
27
|
-
attachHmrSocketRelay(import.meta.hot);
|
|
23
|
+
export {};
|
|
28
24
|
//# sourceMappingURL=sandbox-hmr-socket-relay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-hmr-socket-relay.js","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-socket-relay.ts"],"names":[],"mappings":"AAAA,qCAAqC;
|
|
1
|
+
{"version":3,"file":"sandbox-hmr-socket-relay.js","sourceRoot":"","sources":["../../src/injections/sandbox-hmr-socket-relay.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,gFAAgF;AAChF,iFAAiF;AACjF,kFAAkF;AACjF,MAA6C,CAAC,sBAAsB,GAAG,IAAI,CAAC;AAE7E,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;IAClD,MAAM,gBAAgB,GACpB,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC;IACpF,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IACH,2EAA2E;IAC3E,+DAA+D;IAC/D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,EAAE,GAAG,CAAC,CAAC;QACtE,IAAI,gBAAgB,GAAG,CAAC;YAAE,OAAO,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connect,
|
|
1
|
+
import type { Connect, Plugin, ViteDevServer } from "vite";
|
|
2
2
|
import type { ServerResponse } from "http";
|
|
3
3
|
import { isBundledDev } from "./bundled-dev.js";
|
|
4
4
|
|
|
@@ -21,11 +21,11 @@ import { isBundledDev } from "./bundled-dev.js";
|
|
|
21
21
|
* The status is always reported in the body with HTTP `200`, even on error:
|
|
22
22
|
* a `500` here would trip the preview proxy's own error path.
|
|
23
23
|
*
|
|
24
|
-
* Cold-start caveat
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* Cold-start caveat: errors thrown before any client has connected are not
|
|
25
|
+
* sent over the HMR channel, so a boot-time transform failure may briefly
|
|
26
|
+
* read `ok: true`. That window is covered server-side by the existing
|
|
27
|
+
* dev_server_error_classifier. This endpoint reports post-load
|
|
28
|
+
* HMR / compile errors.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
const ENDPOINT = "/__build_status";
|
|
@@ -37,18 +37,6 @@ const MAX_FRAME = 2000;
|
|
|
37
37
|
|
|
38
38
|
type SendChannel = { send: (...args: unknown[]) => void };
|
|
39
39
|
|
|
40
|
-
const PATCHED = Symbol.for("base44.buildStatus.loggerPatched");
|
|
41
|
-
type PatchableLogger = Omit<Logger, "error"> & {
|
|
42
|
-
error: Logger["error"] & { [PATCHED]?: boolean };
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Plugin hooks run once per environment in bundled dev; only the client's
|
|
46
|
-
// build is the preview. Older Vite has no `this.environment`.
|
|
47
|
-
function isClientEnvironment(ctx: unknown): boolean {
|
|
48
|
-
const name = (ctx as { environment?: { name?: string } } | undefined)?.environment?.name;
|
|
49
|
-
return name === undefined || name === "client";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
40
|
const LOOPBACK_ADDRESSES = new Set([
|
|
53
41
|
"127.0.0.1",
|
|
54
42
|
"::1",
|
|
@@ -143,41 +131,29 @@ export function buildStatusPlugin(): Plugin {
|
|
|
143
131
|
configResolved(config) {
|
|
144
132
|
bundled = isBundledDev(config);
|
|
145
133
|
},
|
|
146
|
-
// Bundled dev runs the rolldown build hooks on every rebuild
|
|
147
|
-
//
|
|
148
|
-
// was recorded before. Other environments' builds say nothing about the preview.
|
|
134
|
+
// Bundled dev runs the rolldown build hooks on every rebuild; a build that
|
|
135
|
+
// reaches generateBundle superseded whatever error was recorded before.
|
|
149
136
|
buildEnd(error) {
|
|
150
|
-
if (bundled && error
|
|
137
|
+
if (bundled && error) lastError = error;
|
|
151
138
|
},
|
|
152
139
|
generateBundle() {
|
|
153
|
-
if (bundled
|
|
140
|
+
if (bundled) lastError = null;
|
|
154
141
|
},
|
|
155
142
|
configureServer(server: ViteDevServer) {
|
|
156
|
-
if (bundled) {
|
|
157
|
-
// Bundled dev reports build failures through the environment logger
|
|
158
|
-
// (`{ error }` option) and per-client sends, never the broadcast
|
|
159
|
-
// channel patched below. Any logged `{ error }` counts until the next
|
|
160
|
-
// successful build: the fail-safe direction for a health endpoint.
|
|
161
|
-
// Kept out of the endpoint's try so a logger surprise never unmounts it.
|
|
162
|
-
try {
|
|
163
|
-
const logger = server.environments.client.logger as PatchableLogger;
|
|
164
|
-
if (!logger.error[PATCHED]) {
|
|
165
|
-
const origError = logger.error.bind(logger);
|
|
166
|
-
const patched: PatchableLogger["error"] = (msg, options) => {
|
|
167
|
-
if (options?.error) lastError = options.error;
|
|
168
|
-
return origError(msg, options);
|
|
169
|
-
};
|
|
170
|
-
patched[PATCHED] = true;
|
|
171
|
-
logger.error = patched;
|
|
172
|
-
}
|
|
173
|
-
} catch {
|
|
174
|
-
// Build failures then surface only via buildEnd; the endpoint still mounts.
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
143
|
try {
|
|
144
|
+
if (bundled) {
|
|
145
|
+
// Bundled dev reports build failures through the environment logger
|
|
146
|
+
// (`{ error }` option) and per-client sends, never the broadcast
|
|
147
|
+
// channel patched below.
|
|
148
|
+
const logger = server.environments.client.logger;
|
|
149
|
+
const origError = logger.error.bind(logger);
|
|
150
|
+
logger.error = (msg, options) => {
|
|
151
|
+
if (options?.error) lastError = options.error;
|
|
152
|
+
return origError(msg, options);
|
|
153
|
+
};
|
|
154
|
+
}
|
|
178
155
|
// Observe the HMR channel: an `error` payload records the last
|
|
179
|
-
// error; a successful `update` / `full-reload` clears it.
|
|
180
|
-
// bundled dev too: nothing is broadcast there, so it is inert.
|
|
156
|
+
// error; a successful `update` / `full-reload` clears it.
|
|
181
157
|
const ch = (server.hot ?? server.ws) as unknown as SendChannel | undefined;
|
|
182
158
|
if (ch && typeof ch.send === "function") {
|
|
183
159
|
const orig = ch.send.bind(ch);
|
package/src/bundled-dev.ts
CHANGED
|
@@ -17,17 +17,6 @@ export function errorOverlayPlugin() {
|
|
|
17
17
|
// Vite's overlay off and let sandbox-build-error-notifier forward the error.
|
|
18
18
|
config: (config) =>
|
|
19
19
|
isBundledDev(config) ? { server: { hmr: { overlay: false } } } : null,
|
|
20
|
-
// `config` sees only the user config; a later plugin or CLI flag can still
|
|
21
|
-
// turn bundled dev on, leaving Vite's overlay up next to the notifier.
|
|
22
|
-
configResolved(config) {
|
|
23
|
-
const hmr = config.server.hmr;
|
|
24
|
-
if (isBundledDev(config) && hmr !== false && (hmr === true || hmr?.overlay !== false)) {
|
|
25
|
-
console.warn(
|
|
26
|
-
"[error-overlay] Bundled dev mode is on but server.hmr.overlay is not false — " +
|
|
27
|
-
"Vite's own overlay will show alongside the app_error sent to the parent."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
20
|
transform(code, id, opts = {}) {
|
|
32
21
|
if (opts?.ssr) return;
|
|
33
22
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createReadStream, existsSync, statSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import type {
|
|
5
|
-
import type { Connect, Plugin, HtmlTagDescriptor, ViteDevServer } from "vite";
|
|
4
|
+
import type { Plugin, HtmlTagDescriptor, ViteDevServer } from "vite";
|
|
6
5
|
import { loadEnv } from "vite";
|
|
7
6
|
import { isBundledDev } from "./bundled-dev.js";
|
|
8
7
|
|
|
9
8
|
type Injection = {
|
|
10
|
-
/** Script path
|
|
11
|
-
|
|
9
|
+
/** Script src path for dev mode (served from node_modules) */
|
|
10
|
+
src?: string;
|
|
12
11
|
injectTo: "head" | "body";
|
|
13
12
|
mode: "dev" | "production";
|
|
14
13
|
/** Inline content for production builds (src paths don't work in built output) */
|
|
@@ -51,42 +50,36 @@ if (window.self === window.top) {
|
|
|
51
50
|
`;
|
|
52
51
|
|
|
53
52
|
const DIST_URL_PREFIX = "/node_modules/@base44/vite-plugin/dist";
|
|
54
|
-
/**
|
|
55
|
-
* Bundled dev resolves module-script `src` through the bundler instead of the
|
|
56
|
-
* dev server, so a node_modules URL would break on any non-flat install. These
|
|
57
|
-
* ids are mapped onto the plugin's own dist tree by `resolveId` below.
|
|
58
|
-
*/
|
|
59
|
-
export const BUNDLED_INJECTION_PREFIX = "virtual:base44-vite-plugin/";
|
|
60
53
|
|
|
61
54
|
const INJECTIONS: Record<string, Injection> = {
|
|
62
55
|
unhandledErrors: {
|
|
63
|
-
|
|
56
|
+
src: `${DIST_URL_PREFIX}/injections/unhandled-errors-handlers.js`,
|
|
64
57
|
injectTo: "head",
|
|
65
58
|
mode: "dev",
|
|
66
59
|
},
|
|
67
60
|
sandboxMount: {
|
|
68
|
-
|
|
61
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-mount-observer.js`,
|
|
69
62
|
injectTo: "body",
|
|
70
63
|
mode: "dev",
|
|
71
64
|
},
|
|
72
65
|
hmrNotifier: {
|
|
73
|
-
|
|
66
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-hmr-notifier.js`,
|
|
74
67
|
injectTo: "head",
|
|
75
68
|
mode: "dev",
|
|
76
69
|
},
|
|
77
70
|
navigationNotifier: {
|
|
78
|
-
|
|
71
|
+
src: `${DIST_URL_PREFIX}/injections/navigation-notifier.js`,
|
|
79
72
|
injectTo: "head",
|
|
80
73
|
mode: "dev",
|
|
81
74
|
},
|
|
82
75
|
buildErrorNotifier: {
|
|
83
|
-
|
|
76
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-build-error-notifier.js`,
|
|
84
77
|
injectTo: "head",
|
|
85
78
|
mode: "dev",
|
|
86
79
|
bundledOnly: true,
|
|
87
80
|
},
|
|
88
81
|
hmrSocketRelay: {
|
|
89
|
-
|
|
82
|
+
src: `${DIST_URL_PREFIX}/injections/sandbox-hmr-socket-relay.js`,
|
|
90
83
|
injectTo: "head",
|
|
91
84
|
mode: "dev",
|
|
92
85
|
bundledOnly: true,
|
|
@@ -106,12 +99,6 @@ const CONTENT_TYPES: Record<string, string> = {
|
|
|
106
99
|
|
|
107
100
|
/** This file lives in dist/ once built, so its directory is the served root. */
|
|
108
101
|
export const PLUGIN_DIST_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
109
|
-
const VISUAL_EDIT_AGENT_FILE = "statics/index.mjs";
|
|
110
|
-
|
|
111
|
-
export function resolveBundledInjection(id: string, distDir = PLUGIN_DIST_DIR): string | undefined {
|
|
112
|
-
if (!id.startsWith(BUNDLED_INJECTION_PREFIX)) return undefined;
|
|
113
|
-
return path.join(distDir, id.slice(BUNDLED_INJECTION_PREFIX.length));
|
|
114
|
-
}
|
|
115
102
|
|
|
116
103
|
/**
|
|
117
104
|
* Bundled dev mounts no static/transform middleware, so the visual-edit agent's
|
|
@@ -119,16 +106,14 @@ export function resolveBundledInjection(id: string, distDir = PLUGIN_DIST_DIR):
|
|
|
119
106
|
* fallback and receive index.html. Serve the plugin's own dist tree instead.
|
|
120
107
|
*/
|
|
121
108
|
export function serveDistMiddleware(distDir: string) {
|
|
122
|
-
return (
|
|
109
|
+
return (
|
|
110
|
+
req: { url?: string | undefined },
|
|
111
|
+
res: { statusCode: number; setHeader: (k: string, v: string) => void; end: (b?: string) => void },
|
|
112
|
+
next: (err?: unknown) => void
|
|
113
|
+
) => {
|
|
123
114
|
const url = (req.url ?? "").split("?")[0] ?? "";
|
|
124
115
|
if (!url.startsWith(`${DIST_URL_PREFIX}/`)) return next();
|
|
125
|
-
|
|
126
|
-
let relative: string;
|
|
127
|
-
try {
|
|
128
|
-
relative = decodeURIComponent(url.slice(DIST_URL_PREFIX.length + 1));
|
|
129
|
-
} catch {
|
|
130
|
-
return next();
|
|
131
|
-
}
|
|
116
|
+
const relative = decodeURIComponent(url.slice(DIST_URL_PREFIX.length + 1));
|
|
132
117
|
const filePath = path.resolve(distDir, relative);
|
|
133
118
|
const type = CONTENT_TYPES[path.extname(filePath)];
|
|
134
119
|
if (
|
|
@@ -142,8 +127,7 @@ export function serveDistMiddleware(distDir: string) {
|
|
|
142
127
|
res.statusCode = 200;
|
|
143
128
|
res.setHeader("Content-Type", type);
|
|
144
129
|
res.setHeader("Cache-Control", "no-store");
|
|
145
|
-
|
|
146
|
-
createReadStream(filePath).on("error", () => res.end()).pipe(res);
|
|
130
|
+
createReadStream(filePath).pipe(res as unknown as NodeJS.WritableStream);
|
|
147
131
|
};
|
|
148
132
|
}
|
|
149
133
|
|
|
@@ -158,9 +142,6 @@ export function htmlInjectionsPlugin({
|
|
|
158
142
|
visualEditAgent: boolean;
|
|
159
143
|
analyticsTracker: boolean;
|
|
160
144
|
}): Plugin[] {
|
|
161
|
-
// The two bundled-only scripts stand in for things that are unconditional in
|
|
162
|
-
// the middleware server (the error overlay swap and the preview bridge's
|
|
163
|
-
// `/@vite/client` import), so they do not follow the opt-in toggles.
|
|
164
145
|
const enabledInjections: Record<string, boolean> = {
|
|
165
146
|
unhandledErrors: true,
|
|
166
147
|
sandboxMount: true,
|
|
@@ -171,8 +152,6 @@ export function htmlInjectionsPlugin({
|
|
|
171
152
|
analyticsTracker,
|
|
172
153
|
};
|
|
173
154
|
|
|
174
|
-
// Written by `dev.configResolved`; the three plugins below are always
|
|
175
|
-
// registered together and read this shared state.
|
|
176
155
|
let resolvedEnv: Record<string, string> = {};
|
|
177
156
|
let isServe = false;
|
|
178
157
|
let bundled = false;
|
|
@@ -199,12 +178,9 @@ export function htmlInjectionsPlugin({
|
|
|
199
178
|
injectTo: injection.injectTo,
|
|
200
179
|
};
|
|
201
180
|
}
|
|
202
|
-
const src = bundled
|
|
203
|
-
? `${BUNDLED_INJECTION_PREFIX}${injection.file}`
|
|
204
|
-
: `${DIST_URL_PREFIX}/${injection.file}`;
|
|
205
181
|
return {
|
|
206
182
|
tag: "script",
|
|
207
|
-
attrs: { src, type: "module" },
|
|
183
|
+
attrs: { src: injection.src, type: "module" },
|
|
208
184
|
injectTo: injection.injectTo,
|
|
209
185
|
};
|
|
210
186
|
});
|
|
@@ -245,12 +221,6 @@ export function htmlInjectionsPlugin({
|
|
|
245
221
|
},
|
|
246
222
|
configureServer(server: ViteDevServer) {
|
|
247
223
|
if (!bundled) return;
|
|
248
|
-
if (visualEditAgent && !existsSync(path.join(PLUGIN_DIST_DIR, VISUAL_EDIT_AGENT_FILE))) {
|
|
249
|
-
console.warn(
|
|
250
|
-
`[html-injections] ${VISUAL_EDIT_AGENT_FILE} not found under ${PLUGIN_DIST_DIR}; ` +
|
|
251
|
-
"the visual edit agent will not load in bundled dev mode."
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
224
|
server.middlewares.use(serveDistMiddleware(PLUGIN_DIST_DIR));
|
|
255
225
|
},
|
|
256
226
|
transformIndexHtml: {
|
|
@@ -266,9 +236,6 @@ export function htmlInjectionsPlugin({
|
|
|
266
236
|
// injecting after its own HTML processing, exactly as before.
|
|
267
237
|
const devBundled: Plugin = {
|
|
268
238
|
name: "html-injections-bundled",
|
|
269
|
-
resolveId(id) {
|
|
270
|
-
return resolveBundledInjection(id);
|
|
271
|
-
},
|
|
272
239
|
transformIndexHtml: {
|
|
273
240
|
order: "pre",
|
|
274
241
|
handler() {
|
|
@@ -3,34 +3,31 @@
|
|
|
3
3
|
// Bundled dev mode keeps Vite's own client, so the ErrorOverlay swap in
|
|
4
4
|
// error-overlay-plugin never runs. The overlay is disabled server-side instead
|
|
5
5
|
// and build errors are forwarded here in the same `app_error` shape.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
stack,
|
|
6
|
+
if (import.meta.hot) {
|
|
7
|
+
import.meta.hot.on("vite:error", (payload: { err?: Record<string, unknown> }) => {
|
|
8
|
+
const err = payload?.err ?? {};
|
|
9
|
+
const message = typeof err.message === "string" ? err.message : "Build error";
|
|
10
|
+
const stack = typeof err.stack === "string" ? err.stack : undefined;
|
|
11
|
+
const loc = err.loc as { file?: string; line?: number; column?: number } | undefined;
|
|
12
|
+
const file = loc?.file ?? (typeof err.id === "string" ? err.id : undefined);
|
|
13
|
+
const where = file && loc?.line != null ? `${file}:${loc.line}:${loc.column ?? 0}` : file;
|
|
14
|
+
const details = [where, typeof err.frame === "string" ? err.frame : undefined, stack]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join("\n");
|
|
17
|
+
window.parent?.postMessage(
|
|
18
|
+
{
|
|
19
|
+
type: "app_error",
|
|
20
|
+
error: {
|
|
21
|
+
title: message,
|
|
22
|
+
details: details || undefined,
|
|
23
|
+
componentName: undefined,
|
|
24
|
+
originalError: { message, stack, plugin: err.plugin, id: err.id, loc },
|
|
25
|
+
stack,
|
|
26
|
+
},
|
|
28
27
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
28
|
+
"*"
|
|
29
|
+
);
|
|
30
|
+
});
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
import.meta.hot.on("vite:error", (payload) => reportBuildError(payload as BuildErrorPayload));
|
|
36
|
-
}
|
|
33
|
+
export {};
|
|
@@ -2,38 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
// The preview proxy's bridge watches the HMR socket by importing /@vite/client,
|
|
4
4
|
// which bundled dev mode does not serve. This module ships inside the bundle and
|
|
5
|
-
// reports the same events
|
|
6
|
-
|
|
7
|
-
// fails before reporting the socket as unreachable.
|
|
5
|
+
// reports the same events; the bridge skips its own attach when it sees the flag.
|
|
6
|
+
(window as unknown as Record<string, unknown>).__base44_bundled_dev__ = true;
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
on: (event: string, cb: (payload?: unknown) => unknown) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Query param the editor adds to the preview URL when it can swap in a fresh
|
|
14
|
-
// iframe on a full reload (mirrors builder_bridge_inject.py in base44-dev/apper).
|
|
15
|
-
export const PREVIEW_FE_VERSION_PARAM = "previewFE_version";
|
|
16
|
-
|
|
17
|
-
export function attachHmrSocketRelay(hot: HotEvents, win: Window = window) {
|
|
18
|
-
(win as unknown as Record<string, unknown>).__base44_bundled_dev__ = true;
|
|
19
|
-
if (win.self === win.top) return;
|
|
8
|
+
if (import.meta.hot && window.self !== window.top) {
|
|
20
9
|
const previewFEVersion =
|
|
21
|
-
Number(new URLSearchParams(
|
|
22
|
-
hot.on("vite:ws:connect", () => {
|
|
23
|
-
|
|
10
|
+
Number(new URLSearchParams(window.location.search).get("previewFE_version")) || 0;
|
|
11
|
+
import.meta.hot.on("vite:ws:connect", () => {
|
|
12
|
+
window.parent?.postMessage({ type: "SANDBOX_WS_CONNECT" }, "*");
|
|
24
13
|
});
|
|
25
|
-
hot.on("vite:ws:disconnect", () => {
|
|
26
|
-
|
|
14
|
+
import.meta.hot.on("vite:ws:disconnect", () => {
|
|
15
|
+
window.parent?.postMessage({ type: "SANDBOX_WS_DISCONNECT" }, "*");
|
|
27
16
|
});
|
|
28
|
-
// Vite
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return
|
|
17
|
+
// Vite awaits these listeners before reloading; a pending promise lets the
|
|
18
|
+
// editor swap in a fresh iframe instead of reloading in place.
|
|
19
|
+
import.meta.hot.on("vite:beforeFullReload", () => {
|
|
20
|
+
window.parent?.postMessage({ type: "sandbox:beforeFullReload" }, "*");
|
|
21
|
+
if (previewFEVersion > 0) return new Promise<void>(() => {});
|
|
22
|
+
return undefined;
|
|
34
23
|
});
|
|
35
24
|
}
|
|
36
25
|
|
|
37
|
-
|
|
38
|
-
// listeners above are always registered before the first connect event.
|
|
39
|
-
if (import.meta.hot) attachHmrSocketRelay(import.meta.hot);
|
|
26
|
+
export {};
|