@base44-preview/vite-plugin 1.0.37-pr.121.9ef7c71 → 1.0.38-pr.121.f18ee18
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/base44-runtime-plugin.d.ts +3 -0
- package/dist/base44-runtime-plugin.d.ts.map +1 -0
- package/dist/base44-runtime-plugin.js +95 -0
- package/dist/base44-runtime-plugin.js.map +1 -0
- package/dist/build-status-plugin.d.ts.map +1 -1
- package/dist/build-status-plugin.js +19 -12
- package/dist/build-status-plugin.js.map +1 -1
- package/dist/error-overlay-plugin.d.ts.map +1 -1
- package/dist/error-overlay-plugin.js +9 -0
- package/dist/error-overlay-plugin.js.map +1 -1
- package/dist/html-injections-plugin.d.ts +7 -0
- package/dist/html-injections-plugin.d.ts.map +1 -1
- package/dist/html-injections-plugin.js +34 -7
- package/dist/html-injections-plugin.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/injections/sandbox-hmr-socket-relay.d.ts.map +1 -1
- package/dist/injections/sandbox-hmr-socket-relay.js.map +1 -1
- package/package.json +1 -1
- package/src/base44-runtime-plugin.ts +103 -0
- package/src/build-status-plugin.ts +18 -12
- package/src/error-overlay-plugin.ts +11 -0
- package/src/html-injections-plugin.ts +38 -9
- package/src/index.ts +6 -0
- package/src/injections/sandbox-hmr-socket-relay.ts +3 -1
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). Their `src` is then a `virtual:base44-vite-plugin/...` id that the plugin resolves onto its own `dist/` directory, so the bundle does not depend on where npm placed the package.
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base44-runtime-plugin.d.ts","sourceRoot":"","sources":["../src/base44-runtime-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA4EnC,wBAAgB,mBAAmB,IAAI,MAAM,CA0B5C"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serves `base44:runtime` to full-stack server routes, so a route reads secrets
|
|
3
|
+
* and schedules background work with the SAME import a backend function uses:
|
|
4
|
+
*
|
|
5
|
+
* import { secrets, waitUntil } from "base44:runtime";
|
|
6
|
+
*
|
|
7
|
+
* WHY A BUILD-TIME VIRTUAL MODULE. The Workers runtime cannot resolve a custom
|
|
8
|
+
* scheme: the legacy module registry special-cases only `node:` / `cloudflare:` /
|
|
9
|
+
* `workerd:`, and the new registry (`new_module_registry`) explicitly rejects a
|
|
10
|
+
* bundle module whose name carries a non-`file:` scheme. Import maps are not
|
|
11
|
+
* supported either. So `base44:runtime` has to be resolved before upload — there
|
|
12
|
+
* is no runtime path to it, and no amount of wrapping the deployed entry creates
|
|
13
|
+
* one.
|
|
14
|
+
*
|
|
15
|
+
* WHY NO ASYNCLOCALSTORAGE / NO WRAPPER ENTRY. Cloudflare now ships both
|
|
16
|
+
* primitives ambiently from `cloudflare:workers` (`env` since 2025-03-17,
|
|
17
|
+
* `waitUntil` since 2025-08-08), backed by workerd's own AsyncContextFrame and
|
|
18
|
+
* IoContext. The backend-function bundler predates that and threads a context
|
|
19
|
+
* through `globalThis.Base44` because it owns the generated entry; here the
|
|
20
|
+
* framework owns the entry, and borrowing the platform's ambient accessors means
|
|
21
|
+
* we never have to.
|
|
22
|
+
*/
|
|
23
|
+
const SPECIFIER = "base44:runtime";
|
|
24
|
+
// Rollup convention: a resolved virtual id starts with NUL so no other plugin
|
|
25
|
+
// (and no filesystem lookup) tries to claim it.
|
|
26
|
+
const RESOLVED = "\0base44:runtime";
|
|
27
|
+
// Reserved so a route importing it fails with an explanation instead of a bare
|
|
28
|
+
// "failed to resolve import". Actors are never imported — they live in the app's
|
|
29
|
+
// actors directory, in server routes exactly as in backend functions.
|
|
30
|
+
const ACTORS_REASON = "Actors are defined in the app's actors directory, not imported into a route.";
|
|
31
|
+
function unsupportedReason(id) {
|
|
32
|
+
if (id === "base44:runtime/actors")
|
|
33
|
+
return ACTORS_REASON;
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `cloudflare:workers` stays external — workerd provides it, and Nitro's
|
|
38
|
+
* cloudflare preset already treats `cloudflare:*` that way.
|
|
39
|
+
*
|
|
40
|
+
* There is deliberately no separate dev body. Nitro's `cloudflareDev` preset
|
|
41
|
+
* (aliased for `cloudflare-module`, which is what these apps build with) sets
|
|
42
|
+
* `devServer.runner: "miniflare"`, so dev runs in workerd too and the same
|
|
43
|
+
* import resolves there. A `process.env` fallback would buy nothing and cost a
|
|
44
|
+
* dev/prod behaviour split — the shape that makes background work silently
|
|
45
|
+
* vanish locally while working in production. If someone overrides the runner
|
|
46
|
+
* away from workerd, this fails loudly at resolution rather than quietly
|
|
47
|
+
* serving a different value.
|
|
48
|
+
*
|
|
49
|
+
* `waitUntil` is WRAPPED rather than re-exported: ours returns the promise so it
|
|
50
|
+
* composes (`infra/base44-userapp-bundler/src/runtime/index.ts` in apper),
|
|
51
|
+
* Cloudflare's returns void. A bare re-export would make `const p = waitUntil(x)`
|
|
52
|
+
* work in a backend function and silently yield `undefined` here — one specifier
|
|
53
|
+
* with two behaviours is the exact failure this module exists to prevent.
|
|
54
|
+
*/
|
|
55
|
+
const RUNTIME_MODULE = `
|
|
56
|
+
import { env, waitUntil as cfWaitUntil } from "cloudflare:workers";
|
|
57
|
+
|
|
58
|
+
export function waitUntil(promise) {
|
|
59
|
+
cfWaitUntil(promise);
|
|
60
|
+
return promise;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const secrets = {
|
|
64
|
+
get(name) {
|
|
65
|
+
const value = env[name];
|
|
66
|
+
return typeof value === "string" ? value : undefined;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
`;
|
|
70
|
+
export function base44RuntimePlugin() {
|
|
71
|
+
return {
|
|
72
|
+
name: "base44-runtime",
|
|
73
|
+
// Ahead of Vite's own resolution so the bare `base44:` specifier is never
|
|
74
|
+
// mistaken for a URL protocol.
|
|
75
|
+
enforce: "pre",
|
|
76
|
+
resolveId(id) {
|
|
77
|
+
const reason = unsupportedReason(id);
|
|
78
|
+
if (reason) {
|
|
79
|
+
this.error(`"${id}" is not available in server routes. ${reason}`);
|
|
80
|
+
}
|
|
81
|
+
if (id !== SPECIFIER)
|
|
82
|
+
return null;
|
|
83
|
+
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
84
|
+
// would bundle a module that cannot run. Fail with the reason instead.
|
|
85
|
+
if (this.environment?.name === "client") {
|
|
86
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
|
|
87
|
+
}
|
|
88
|
+
return RESOLVED;
|
|
89
|
+
},
|
|
90
|
+
load(id) {
|
|
91
|
+
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=base44-runtime-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base44-runtime-plugin.js","sourceRoot":"","sources":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version":3,"file":"build-status-plugin.d.ts","sourceRoot":"","sources":["../src/build-status-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAiB,MAAM,MAAM,CAAC;AAsFnE;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA2ClE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"build-status-plugin.d.ts","sourceRoot":"","sources":["../src/build-status-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAiB,MAAM,MAAM,CAAC;AAsFnE;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA2ClE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAyG1C"}
|
|
@@ -18,11 +18,11 @@ 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: errors thrown before any client
|
|
22
|
-
* sent over the HMR channel, so a boot-time transform
|
|
23
|
-
* read `ok: true`. That window is covered server-side by
|
|
24
|
-
* dev_server_error_classifier.
|
|
25
|
-
*
|
|
21
|
+
* Cold-start caveat (middleware dev server): errors thrown before any client
|
|
22
|
+
* has connected are not sent over the HMR channel, so a boot-time transform
|
|
23
|
+
* failure may briefly read `ok: true`. That window is covered server-side by
|
|
24
|
+
* the existing dev_server_error_classifier. Under bundled dev the build hooks
|
|
25
|
+
* and logger below observe boot failures too.
|
|
26
26
|
*/
|
|
27
27
|
const ENDPOINT = "/__build_status";
|
|
28
28
|
/** Max characters kept per scrubbed string field. */
|
|
@@ -130,12 +130,13 @@ export function buildStatusPlugin() {
|
|
|
130
130
|
lastError = null;
|
|
131
131
|
},
|
|
132
132
|
configureServer(server) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
if (bundled) {
|
|
134
|
+
// Bundled dev reports build failures through the environment logger
|
|
135
|
+
// (`{ error }` option) and per-client sends, never the broadcast
|
|
136
|
+
// channel patched below. Any logged `{ error }` counts until the next
|
|
137
|
+
// successful build: the fail-safe direction for a health endpoint.
|
|
138
|
+
// Kept out of the endpoint's try so a logger surprise never unmounts it.
|
|
139
|
+
try {
|
|
139
140
|
const logger = server.environments.client.logger;
|
|
140
141
|
if (!logger.error[PATCHED]) {
|
|
141
142
|
const origError = logger.error.bind(logger);
|
|
@@ -148,8 +149,14 @@ export function buildStatusPlugin() {
|
|
|
148
149
|
logger.error = patched;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
152
|
+
catch {
|
|
153
|
+
// Build failures then surface only via buildEnd; the endpoint still mounts.
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
151
157
|
// Observe the HMR channel: an `error` payload records the last
|
|
152
|
-
// error; a successful `update` / `full-reload` clears it.
|
|
158
|
+
// error; a successful `update` / `full-reload` clears it. Left on in
|
|
159
|
+
// bundled dev too: nothing is broadcast there, so it is inert.
|
|
153
160
|
const ch = (server.hot ?? server.ws);
|
|
154
161
|
if (ch && typeof ch.send === "function") {
|
|
155
162
|
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,GAA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A2D;YAC7D,CAAC;QACH,CAAC;KACF,CAAC;AACJ,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,IA0C3B,MAAM,CACZ"}
|
|
@@ -12,6 +12,15 @@ 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
|
+
},
|
|
15
24
|
transform(code, id, opts = {}) {
|
|
16
25
|
if (opts?.ssr)
|
|
17
26
|
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,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,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,7 +1,14 @@
|
|
|
1
1
|
import type { ServerResponse } from "node:http";
|
|
2
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/";
|
|
3
9
|
/** This file lives in dist/ once built, so its directory is the served root. */
|
|
4
10
|
export declare const PLUGIN_DIST_DIR: string;
|
|
11
|
+
export declare function resolveBundledInjection(id: string, distDir?: string): string | undefined;
|
|
5
12
|
/**
|
|
6
13
|
* Bundled dev mounts no static/transform middleware, so the visual-edit agent's
|
|
7
14
|
* dynamic `import()` of dist/statics/index.mjs would fall through to the SPA
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAoC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAoC,MAAM,MAAM,CAAC;AAiD9E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAgDtE,gFAAgF;AAChF,eAAO,MAAM,eAAe,QAA+C,CAAC;AAG5E,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,SAAkB,GAAG,MAAM,GAAG,SAAS,CAGjG;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,IACzC,KAAK,OAAO,CAAC,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC,YAAY,UA0BtF;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,CAkIX"}
|
|
@@ -36,35 +36,41 @@ 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/";
|
|
39
45
|
const INJECTIONS = {
|
|
40
46
|
unhandledErrors: {
|
|
41
|
-
|
|
47
|
+
file: "injections/unhandled-errors-handlers.js",
|
|
42
48
|
injectTo: "head",
|
|
43
49
|
mode: "dev",
|
|
44
50
|
},
|
|
45
51
|
sandboxMount: {
|
|
46
|
-
|
|
52
|
+
file: "injections/sandbox-mount-observer.js",
|
|
47
53
|
injectTo: "body",
|
|
48
54
|
mode: "dev",
|
|
49
55
|
},
|
|
50
56
|
hmrNotifier: {
|
|
51
|
-
|
|
57
|
+
file: "injections/sandbox-hmr-notifier.js",
|
|
52
58
|
injectTo: "head",
|
|
53
59
|
mode: "dev",
|
|
54
60
|
},
|
|
55
61
|
navigationNotifier: {
|
|
56
|
-
|
|
62
|
+
file: "injections/navigation-notifier.js",
|
|
57
63
|
injectTo: "head",
|
|
58
64
|
mode: "dev",
|
|
59
65
|
},
|
|
60
66
|
buildErrorNotifier: {
|
|
61
|
-
|
|
67
|
+
file: "injections/sandbox-build-error-notifier.js",
|
|
62
68
|
injectTo: "head",
|
|
63
69
|
mode: "dev",
|
|
64
70
|
bundledOnly: true,
|
|
65
71
|
},
|
|
66
72
|
hmrSocketRelay: {
|
|
67
|
-
|
|
73
|
+
file: "injections/sandbox-hmr-socket-relay.js",
|
|
68
74
|
injectTo: "head",
|
|
69
75
|
mode: "dev",
|
|
70
76
|
bundledOnly: true,
|
|
@@ -82,6 +88,12 @@ const CONTENT_TYPES = {
|
|
|
82
88
|
};
|
|
83
89
|
/** This file lives in dist/ once built, so its directory is the served root. */
|
|
84
90
|
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
|
+
}
|
|
85
97
|
/**
|
|
86
98
|
* Bundled dev mounts no static/transform middleware, so the visual-edit agent's
|
|
87
99
|
* dynamic `import()` of dist/statics/index.mjs would fall through to the SPA
|
|
@@ -117,6 +129,9 @@ export function serveDistMiddleware(distDir) {
|
|
|
117
129
|
};
|
|
118
130
|
}
|
|
119
131
|
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.
|
|
120
135
|
const enabledInjections = {
|
|
121
136
|
unhandledErrors: true,
|
|
122
137
|
sandboxMount: true,
|
|
@@ -126,6 +141,8 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
126
141
|
hmrSocketRelay: true,
|
|
127
142
|
analyticsTracker,
|
|
128
143
|
};
|
|
144
|
+
// Written by `dev.configResolved`; the three plugins below are always
|
|
145
|
+
// registered together and read this shared state.
|
|
129
146
|
let resolvedEnv = {};
|
|
130
147
|
let isServe = false;
|
|
131
148
|
let bundled = false;
|
|
@@ -144,9 +161,12 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
144
161
|
injectTo: injection.injectTo,
|
|
145
162
|
};
|
|
146
163
|
}
|
|
164
|
+
const src = bundled
|
|
165
|
+
? `${BUNDLED_INJECTION_PREFIX}${injection.file}`
|
|
166
|
+
: `${DIST_URL_PREFIX}/${injection.file}`;
|
|
147
167
|
return {
|
|
148
168
|
tag: "script",
|
|
149
|
-
attrs: { src
|
|
169
|
+
attrs: { src, type: "module" },
|
|
150
170
|
injectTo: injection.injectTo,
|
|
151
171
|
};
|
|
152
172
|
});
|
|
@@ -186,6 +206,10 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
186
206
|
configureServer(server) {
|
|
187
207
|
if (!bundled)
|
|
188
208
|
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
|
+
}
|
|
189
213
|
server.middlewares.use(serveDistMiddleware(PLUGIN_DIST_DIR));
|
|
190
214
|
},
|
|
191
215
|
transformIndexHtml: {
|
|
@@ -200,6 +224,9 @@ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEd
|
|
|
200
224
|
// injecting after its own HTML processing, exactly as before.
|
|
201
225
|
const devBundled = {
|
|
202
226
|
name: "html-injections-bundled",
|
|
227
|
+
resolveId(id) {
|
|
228
|
+
return resolveBundledInjection(id);
|
|
229
|
+
},
|
|
203
230
|
transformIndexHtml: {
|
|
204
231
|
order: "pre",
|
|
205
232
|
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;AAGzC,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;
|
|
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;AAGzC,OAAO,EAAE,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AyB;QAC/B,SAAS,CAAC,EAAE;YACV,OAAO,uBAAuB,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,KAAK;YACZ,OAAO;gBACL,OAAO,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,CAAC;SACF;KACF,CAAC;IAEF,MAAM,UAAU,GAAW;QACzB,IAAI,EAAE,4BAA4B;QAClC,kBAAkB,EAAE;YAClB,OAAO;gBACL,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC9C,CAAC;SACF;KACF,CAAC;IAEF,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AA0B/C,eAAO,MAAM,uBAAuB,UAWnC,CAAC;AAeF,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,GAAE;IACJ,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,iBA6OP"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { visualEditPlugin } from "./visual-edit-plugin.js";
|
|
|
5
5
|
import { filterPackagesInProject } from "./utils.js";
|
|
6
6
|
import { htmlInjectionsPlugin } from "./html-injections-plugin.js";
|
|
7
7
|
import { buildStatusPlugin } from "./build-status-plugin.js";
|
|
8
|
+
import { base44RuntimePlugin } from "./base44-runtime-plugin.js";
|
|
8
9
|
const isRunningInSandbox = !!process.env.MODAL_SANDBOX_ID;
|
|
9
10
|
// Vite 8 pre-bundles deps with Rolldown instead of esbuild and deprecates
|
|
10
11
|
// `optimizeDeps.esbuildOptions`. Both spellings mean the same thing here:
|
|
@@ -215,6 +216,11 @@ export default function vitePlugin(opts = {}) {
|
|
|
215
216
|
...(process.env.BASE44_BUILD_STATUS_ENABLED === "1"
|
|
216
217
|
? [buildStatusPlugin()]
|
|
217
218
|
: []),
|
|
219
|
+
// Serves `base44:runtime` to full-stack server routes. Unconditional: it
|
|
220
|
+
// only claims the `base44:` specifiers, so an app with no server dir never
|
|
221
|
+
// notices it. Ordering comes from its own `enforce: "pre"`, not from its
|
|
222
|
+
// position here — several tests index this array from the front.
|
|
223
|
+
base44RuntimePlugin(),
|
|
218
224
|
];
|
|
219
225
|
}
|
|
220
226
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sour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CAAC,kBAAkB;YACpB,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,YAAY;oBAClB,eAAe,CAAC,MAAM;wBACpB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;4BACxC,yBAAyB;4BACzB,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;4BAC7C,GAAG,CAAC,SAAS,CAAC,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;4BAC/D,IAAI,EAAE,CAAC;wBACT,CAAC,CAAC,CAAC;oBACL,CAAC;iBACQ;gBACX,kBAAkB,EAAE;gBACpB,gBAAgB,EAAE;aACnB;YACH,CAAC,CAAC,EAAE,CAAC;QACP,yEAAyE;QACzE,GAAG,oBAAoB,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;QAC/F,yEAAyE;QACzE,iEAAiE;QACjE,sEAAsE;QACtE,wEAAwE;QACxE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG;YACjD,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACvB,CAAC,CAAC,EAAE,CAAC;QACP,yEAAyE;QACzE,2EAA2E;QAC3E,yEAAyE;QACzE,iEAAiE;QACjE,mBAAmB,EAAE;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -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":"AAQA,KAAK,SAAS,GAAG;IACf,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,KAAK,IAAI,CAAC;CACjE,CAAC;AAIF,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,GAAE,MAAe,QAkBxE"}
|
|
@@ -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;AAYrC,6EAA6E;AAC7E,kFAAkF;AAClF,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D,MAAM,UAAU,oBAAoB,CAAC,GAAc,EAAE,MAAc,MAAM;IACtE,GAA0C,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAC1E,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG;QAAE,OAAO;IACjC,MAAM,gBAAgB,GACpB,MAAM,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,CAAC;IACtF,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC7B,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAChC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,2EAA2E;IAC3E,4EAA4E;IAC5E,+EAA+E;IAC/E,GAAG,CAAC,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QACnC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,EAAE,GAAG,CAAC,CAAC;QACnE,OAAO,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,wEAAwE;AACxE,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG;IAAE,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Serves `base44:runtime` to full-stack server routes, so a route reads secrets
|
|
5
|
+
* and schedules background work with the SAME import a backend function uses:
|
|
6
|
+
*
|
|
7
|
+
* import { secrets, waitUntil } from "base44:runtime";
|
|
8
|
+
*
|
|
9
|
+
* WHY A BUILD-TIME VIRTUAL MODULE. The Workers runtime cannot resolve a custom
|
|
10
|
+
* scheme: the legacy module registry special-cases only `node:` / `cloudflare:` /
|
|
11
|
+
* `workerd:`, and the new registry (`new_module_registry`) explicitly rejects a
|
|
12
|
+
* bundle module whose name carries a non-`file:` scheme. Import maps are not
|
|
13
|
+
* supported either. So `base44:runtime` has to be resolved before upload — there
|
|
14
|
+
* is no runtime path to it, and no amount of wrapping the deployed entry creates
|
|
15
|
+
* one.
|
|
16
|
+
*
|
|
17
|
+
* WHY NO ASYNCLOCALSTORAGE / NO WRAPPER ENTRY. Cloudflare now ships both
|
|
18
|
+
* primitives ambiently from `cloudflare:workers` (`env` since 2025-03-17,
|
|
19
|
+
* `waitUntil` since 2025-08-08), backed by workerd's own AsyncContextFrame and
|
|
20
|
+
* IoContext. The backend-function bundler predates that and threads a context
|
|
21
|
+
* through `globalThis.Base44` because it owns the generated entry; here the
|
|
22
|
+
* framework owns the entry, and borrowing the platform's ambient accessors means
|
|
23
|
+
* we never have to.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const SPECIFIER = "base44:runtime";
|
|
27
|
+
// Rollup convention: a resolved virtual id starts with NUL so no other plugin
|
|
28
|
+
// (and no filesystem lookup) tries to claim it.
|
|
29
|
+
const RESOLVED = "\0base44:runtime";
|
|
30
|
+
|
|
31
|
+
// Reserved so a route importing it fails with an explanation instead of a bare
|
|
32
|
+
// "failed to resolve import". Actors are never imported — they live in the app's
|
|
33
|
+
// actors directory, in server routes exactly as in backend functions.
|
|
34
|
+
const ACTORS_REASON =
|
|
35
|
+
"Actors are defined in the app's actors directory, not imported into a route.";
|
|
36
|
+
|
|
37
|
+
function unsupportedReason(id: string): string | null {
|
|
38
|
+
if (id === "base44:runtime/actors") return ACTORS_REASON;
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* `cloudflare:workers` stays external — workerd provides it, and Nitro's
|
|
44
|
+
* cloudflare preset already treats `cloudflare:*` that way.
|
|
45
|
+
*
|
|
46
|
+
* There is deliberately no separate dev body. Nitro's `cloudflareDev` preset
|
|
47
|
+
* (aliased for `cloudflare-module`, which is what these apps build with) sets
|
|
48
|
+
* `devServer.runner: "miniflare"`, so dev runs in workerd too and the same
|
|
49
|
+
* import resolves there. A `process.env` fallback would buy nothing and cost a
|
|
50
|
+
* dev/prod behaviour split — the shape that makes background work silently
|
|
51
|
+
* vanish locally while working in production. If someone overrides the runner
|
|
52
|
+
* away from workerd, this fails loudly at resolution rather than quietly
|
|
53
|
+
* serving a different value.
|
|
54
|
+
*
|
|
55
|
+
* `waitUntil` is WRAPPED rather than re-exported: ours returns the promise so it
|
|
56
|
+
* composes (`infra/base44-userapp-bundler/src/runtime/index.ts` in apper),
|
|
57
|
+
* Cloudflare's returns void. A bare re-export would make `const p = waitUntil(x)`
|
|
58
|
+
* work in a backend function and silently yield `undefined` here — one specifier
|
|
59
|
+
* with two behaviours is the exact failure this module exists to prevent.
|
|
60
|
+
*/
|
|
61
|
+
const RUNTIME_MODULE = `
|
|
62
|
+
import { env, waitUntil as cfWaitUntil } from "cloudflare:workers";
|
|
63
|
+
|
|
64
|
+
export function waitUntil(promise) {
|
|
65
|
+
cfWaitUntil(promise);
|
|
66
|
+
return promise;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const secrets = {
|
|
70
|
+
get(name) {
|
|
71
|
+
const value = env[name];
|
|
72
|
+
return typeof value === "string" ? value : undefined;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
export function base44RuntimePlugin(): Plugin {
|
|
78
|
+
return {
|
|
79
|
+
name: "base44-runtime",
|
|
80
|
+
// Ahead of Vite's own resolution so the bare `base44:` specifier is never
|
|
81
|
+
// mistaken for a URL protocol.
|
|
82
|
+
enforce: "pre",
|
|
83
|
+
|
|
84
|
+
resolveId(id) {
|
|
85
|
+
const reason = unsupportedReason(id);
|
|
86
|
+
if (reason) {
|
|
87
|
+
this.error(`"${id}" is not available in server routes. ${reason}`);
|
|
88
|
+
}
|
|
89
|
+
if (id !== SPECIFIER) return null;
|
|
90
|
+
|
|
91
|
+
// `cloudflare:workers` has no browser equivalent, so a client-side import
|
|
92
|
+
// would bundle a module that cannot run. Fail with the reason instead.
|
|
93
|
+
if (this.environment?.name === "client") {
|
|
94
|
+
this.error(`"${SPECIFIER}" is server-only. Move this import into a server route.`);
|
|
95
|
+
}
|
|
96
|
+
return RESOLVED;
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
load(id) {
|
|
100
|
+
return id === RESOLVED ? RUNTIME_MODULE : null;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -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: errors thrown before any client
|
|
25
|
-
* sent over the HMR channel, so a boot-time transform
|
|
26
|
-
* read `ok: true`. That window is covered server-side by
|
|
27
|
-
* dev_server_error_classifier.
|
|
28
|
-
*
|
|
24
|
+
* Cold-start caveat (middleware dev server): errors thrown before any client
|
|
25
|
+
* has connected are not sent over the HMR channel, so a boot-time transform
|
|
26
|
+
* failure may briefly read `ok: true`. That window is covered server-side by
|
|
27
|
+
* the existing dev_server_error_classifier. Under bundled dev the build hooks
|
|
28
|
+
* and logger below observe boot failures too.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
const ENDPOINT = "/__build_status";
|
|
@@ -153,12 +153,13 @@ export function buildStatusPlugin(): Plugin {
|
|
|
153
153
|
if (bundled && isClientEnvironment(this)) lastError = null;
|
|
154
154
|
},
|
|
155
155
|
configureServer(server: ViteDevServer) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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 {
|
|
162
163
|
const logger = server.environments.client.logger as PatchableLogger;
|
|
163
164
|
if (!logger.error[PATCHED]) {
|
|
164
165
|
const origError = logger.error.bind(logger);
|
|
@@ -169,9 +170,14 @@ export function buildStatusPlugin(): Plugin {
|
|
|
169
170
|
patched[PATCHED] = true;
|
|
170
171
|
logger.error = patched;
|
|
171
172
|
}
|
|
173
|
+
} catch {
|
|
174
|
+
// Build failures then surface only via buildEnd; the endpoint still mounts.
|
|
172
175
|
}
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
173
178
|
// Observe the HMR channel: an `error` payload records the last
|
|
174
|
-
// error; a successful `update` / `full-reload` clears it.
|
|
179
|
+
// error; a successful `update` / `full-reload` clears it. Left on in
|
|
180
|
+
// bundled dev too: nothing is broadcast there, so it is inert.
|
|
175
181
|
const ch = (server.hot ?? server.ws) as unknown as SendChannel | undefined;
|
|
176
182
|
if (ch && typeof ch.send === "function") {
|
|
177
183
|
const orig = ch.send.bind(ch);
|
|
@@ -17,6 +17,17 @@ 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
|
+
},
|
|
20
31
|
transform(code, id, opts = {}) {
|
|
21
32
|
if (opts?.ssr) return;
|
|
22
33
|
|
|
@@ -7,8 +7,8 @@ import { loadEnv } from "vite";
|
|
|
7
7
|
import { isBundledDev } from "./bundled-dev.js";
|
|
8
8
|
|
|
9
9
|
type Injection = {
|
|
10
|
-
/** Script
|
|
11
|
-
|
|
10
|
+
/** Script path under this package's dist/, served from node_modules in dev. */
|
|
11
|
+
file?: string;
|
|
12
12
|
injectTo: "head" | "body";
|
|
13
13
|
mode: "dev" | "production";
|
|
14
14
|
/** Inline content for production builds (src paths don't work in built output) */
|
|
@@ -51,36 +51,42 @@ if (window.self === window.top) {
|
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
53
|
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/";
|
|
54
60
|
|
|
55
61
|
const INJECTIONS: Record<string, Injection> = {
|
|
56
62
|
unhandledErrors: {
|
|
57
|
-
|
|
63
|
+
file: "injections/unhandled-errors-handlers.js",
|
|
58
64
|
injectTo: "head",
|
|
59
65
|
mode: "dev",
|
|
60
66
|
},
|
|
61
67
|
sandboxMount: {
|
|
62
|
-
|
|
68
|
+
file: "injections/sandbox-mount-observer.js",
|
|
63
69
|
injectTo: "body",
|
|
64
70
|
mode: "dev",
|
|
65
71
|
},
|
|
66
72
|
hmrNotifier: {
|
|
67
|
-
|
|
73
|
+
file: "injections/sandbox-hmr-notifier.js",
|
|
68
74
|
injectTo: "head",
|
|
69
75
|
mode: "dev",
|
|
70
76
|
},
|
|
71
77
|
navigationNotifier: {
|
|
72
|
-
|
|
78
|
+
file: "injections/navigation-notifier.js",
|
|
73
79
|
injectTo: "head",
|
|
74
80
|
mode: "dev",
|
|
75
81
|
},
|
|
76
82
|
buildErrorNotifier: {
|
|
77
|
-
|
|
83
|
+
file: "injections/sandbox-build-error-notifier.js",
|
|
78
84
|
injectTo: "head",
|
|
79
85
|
mode: "dev",
|
|
80
86
|
bundledOnly: true,
|
|
81
87
|
},
|
|
82
88
|
hmrSocketRelay: {
|
|
83
|
-
|
|
89
|
+
file: "injections/sandbox-hmr-socket-relay.js",
|
|
84
90
|
injectTo: "head",
|
|
85
91
|
mode: "dev",
|
|
86
92
|
bundledOnly: true,
|
|
@@ -100,6 +106,12 @@ const CONTENT_TYPES: Record<string, string> = {
|
|
|
100
106
|
|
|
101
107
|
/** This file lives in dist/ once built, so its directory is the served root. */
|
|
102
108
|
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
|
+
}
|
|
103
115
|
|
|
104
116
|
/**
|
|
105
117
|
* Bundled dev mounts no static/transform middleware, so the visual-edit agent's
|
|
@@ -146,6 +158,9 @@ export function htmlInjectionsPlugin({
|
|
|
146
158
|
visualEditAgent: boolean;
|
|
147
159
|
analyticsTracker: boolean;
|
|
148
160
|
}): 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.
|
|
149
164
|
const enabledInjections: Record<string, boolean> = {
|
|
150
165
|
unhandledErrors: true,
|
|
151
166
|
sandboxMount: true,
|
|
@@ -156,6 +171,8 @@ export function htmlInjectionsPlugin({
|
|
|
156
171
|
analyticsTracker,
|
|
157
172
|
};
|
|
158
173
|
|
|
174
|
+
// Written by `dev.configResolved`; the three plugins below are always
|
|
175
|
+
// registered together and read this shared state.
|
|
159
176
|
let resolvedEnv: Record<string, string> = {};
|
|
160
177
|
let isServe = false;
|
|
161
178
|
let bundled = false;
|
|
@@ -182,9 +199,12 @@ export function htmlInjectionsPlugin({
|
|
|
182
199
|
injectTo: injection.injectTo,
|
|
183
200
|
};
|
|
184
201
|
}
|
|
202
|
+
const src = bundled
|
|
203
|
+
? `${BUNDLED_INJECTION_PREFIX}${injection.file}`
|
|
204
|
+
: `${DIST_URL_PREFIX}/${injection.file}`;
|
|
185
205
|
return {
|
|
186
206
|
tag: "script",
|
|
187
|
-
attrs: { src
|
|
207
|
+
attrs: { src, type: "module" },
|
|
188
208
|
injectTo: injection.injectTo,
|
|
189
209
|
};
|
|
190
210
|
});
|
|
@@ -225,6 +245,12 @@ export function htmlInjectionsPlugin({
|
|
|
225
245
|
},
|
|
226
246
|
configureServer(server: ViteDevServer) {
|
|
227
247
|
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
|
+
}
|
|
228
254
|
server.middlewares.use(serveDistMiddleware(PLUGIN_DIST_DIR));
|
|
229
255
|
},
|
|
230
256
|
transformIndexHtml: {
|
|
@@ -240,6 +266,9 @@ export function htmlInjectionsPlugin({
|
|
|
240
266
|
// injecting after its own HTML processing, exactly as before.
|
|
241
267
|
const devBundled: Plugin = {
|
|
242
268
|
name: "html-injections-bundled",
|
|
269
|
+
resolveId(id) {
|
|
270
|
+
return resolveBundledInjection(id);
|
|
271
|
+
},
|
|
243
272
|
transformIndexHtml: {
|
|
244
273
|
order: "pre",
|
|
245
274
|
handler() {
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { visualEditPlugin } from "./visual-edit-plugin.js";
|
|
|
6
6
|
import { filterPackagesInProject } from "./utils.js";
|
|
7
7
|
import { htmlInjectionsPlugin } from "./html-injections-plugin.js";
|
|
8
8
|
import { buildStatusPlugin } from "./build-status-plugin.js";
|
|
9
|
+
import { base44RuntimePlugin } from "./base44-runtime-plugin.js";
|
|
9
10
|
|
|
10
11
|
const isRunningInSandbox = !!process.env.MODAL_SANDBOX_ID;
|
|
11
12
|
|
|
@@ -288,5 +289,10 @@ export default function vitePlugin(
|
|
|
288
289
|
...(process.env.BASE44_BUILD_STATUS_ENABLED === "1"
|
|
289
290
|
? [buildStatusPlugin()]
|
|
290
291
|
: []),
|
|
292
|
+
// Serves `base44:runtime` to full-stack server routes. Unconditional: it
|
|
293
|
+
// only claims the `base44:` specifiers, so an app with no server dir never
|
|
294
|
+
// notices it. Ordering comes from its own `enforce: "pre"`, not from its
|
|
295
|
+
// position here — several tests index this array from the front.
|
|
296
|
+
base44RuntimePlugin(),
|
|
291
297
|
];
|
|
292
298
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
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
|
|
5
|
+
// reports the same events. The flag below is set only once the bundle runs, so
|
|
6
|
+
// the bridge (builder_bridge_inject.py) polls it for a while after its import
|
|
7
|
+
// fails before reporting the socket as unreachable.
|
|
6
8
|
|
|
7
9
|
type HotEvents = {
|
|
8
10
|
on: (event: string, cb: (payload?: unknown) => unknown) => void;
|