Compare commits

...
7 changed files with 137 additions and 5 deletions
+2
View File
@@ -1046,7 +1046,9 @@
"@ai-sdk/mistral@3.0.51": "patches/@ai-sdk%2Fmistral@3.0.51.patch",
"@npmcli/agent@4.0.2": "patches/@npmcli%2Fagent@4.0.2.patch",
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
"@brendonovich/vite-plugin-opencode@0.1.1": "patches/@brendonovich%2Fvite-plugin-opencode@0.1.1.patch",
"solid-js@1.9.15": "patches/solid-js@1.9.15.patch",
"vite@8.2.2": "patches/vite@8.2.2.patch",
"@ff-labs/fff-bun@0.10.5": "patches/@ff-labs%2Ffff-bun@0.10.5.patch",
"@ai-sdk/google@3.0.73": "patches/@ai-sdk%2Fgoogle@3.0.73.patch",
"@dnd-kit/dom@0.5.0": "patches/@dnd-kit%2Fdom@0.5.0.patch",
+3 -1
View File
@@ -178,6 +178,8 @@
"@pierre/trees@1.0.0-beta.4": "patches/@pierre%2Ftrees@1.0.0-beta.4.patch",
"@modelcontextprotocol/sdk@1.29.0": "patches/@modelcontextprotocol%2Fsdk@1.29.0.patch",
"@tanstack/virtual-core@3.17.8": "patches/@tanstack%2Fvirtual-core@3.17.8.patch",
"@ff-labs/fff-bun@0.10.5": "patches/@ff-labs%2Ffff-bun@0.10.5.patch"
"@ff-labs/fff-bun@0.10.5": "patches/@ff-labs%2Ffff-bun@0.10.5.patch",
"vite@8.2.2": "patches/vite@8.2.2.patch",
"@brendonovich/vite-plugin-opencode@0.1.1": "patches/@brendonovich%2Fvite-plugin-opencode@0.1.1.patch"
}
}
+1 -1
View File
@@ -90,7 +90,7 @@ const require = __cjs_mod__.createRequire(import.meta.url);
"import.meta.env.OPENCODE_VERSION": JSON.stringify(process.env.OPENCODE_VERSION),
"import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel),
},
plugins: [{ ...picker, transformIndexHtml: undefined }, appPlugin, sentry],
plugins: [picker, appPlugin, sentry],
publicDir: "../../../app/public",
root: "src/renderer",
build: {
+5 -1
View File
@@ -1,5 +1,6 @@
import { $ } from "bun"
import { join } from "node:path"
import { fileURLToPath } from "node:url"
import { downloadCliToResources, windowsify } from "./utils"
type ServerSource = { type: "build" } | { type: "download"; version: string }
@@ -49,7 +50,10 @@ async function prepareServer(source: ServerSource) {
}
async function startDesktop(args: string[]) {
await $`electron-vite dev ${args}`
process.exitCode = await Bun.spawn(
["node", fileURLToPath(new URL("../bin/electron-vite.js", import.meta.resolve("electron-vite"))), "dev", ...args],
{ stdio: ["inherit", "inherit", "inherit"] },
).exited
}
await main()
-2
View File
@@ -20,5 +20,3 @@ startDesktopMenu(api)
startDeepLinks(api)
render(() => <DesktopApp api={api} updater={updater} version={version} />, root)
if (import.meta.env.DEV) void import("virtual:vite-opencode-picker/client")
@@ -0,0 +1,42 @@
diff --git a/node_modules/@brendonovich/vite-plugin-opencode/.bun-tag-6275558c8a7c92ef b/.bun-tag-6275558c8a7c92ef
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/dist/index.d.ts b/dist/index.d.ts
index 5cae5fab5558327a6782272d094bac56d73a6f06..7d308ccf38a162e4d0a85664884a7d687abb461c 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -15,10 +15,11 @@ interface PickerPlugin {
readonly resolveId: (id: string) => string | undefined;
readonly load: (id: string) => string | undefined;
readonly transformIndexHtml: {
- readonly order: "post";
+ readonly order: "pre";
readonly handler: () => Array<{
readonly tag: string;
readonly attrs: Readonly<Record<string, string>>;
+ readonly children: string;
readonly injectTo: "body";
}>;
};
diff --git a/dist/index.js b/dist/index.js
index 7dda18114a778b15449b93a52a1d15197474678f..a1c933e067dc124473c1e56a97c38fe6609ad793 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -887,14 +887,14 @@ setInterval(refreshSessions, 1500);
return e === m ? _(u) : void 0;
},
transformIndexHtml: {
- order: "post",
+ order: "pre",
handler() {
return [{
tag: "script",
attrs: {
- type: "module",
- src: `${u.slice(0, -22)}@id/__x00__${p}`
+ type: "module"
},
+ children: `import ${JSON.stringify(p)}`,
injectTo: "body"
}];
}
+84
View File
@@ -0,0 +1,84 @@
diff --git a/dist/client/bundledDevClient.mjs b/dist/client/bundledDevClient.mjs
index 4c4a3f6f884795001ffbae43cd3c3d6bf84169dc..b5e80b68140824e7460439b125eec8ec3fa14e8a 100644
--- a/dist/client/bundledDevClient.mjs
+++ b/dist/client/bundledDevClient.mjs
@@ -1796,6 +1796,13 @@ function injectQuery(url, queryToInject) {
if (typeof DevRuntime !== "undefined") {
var _ref;
class ViteDevRuntime extends DevRuntime {
+ payloadDelivered(filename) {
+ transport.send({
+ type: "custom",
+ event: "vite:bundled-dev:payload-delivered",
+ data: { filename }
+ });
+ }
createModuleHotContext(moduleId) {
const ctx = new BundledDevHMRContext(bundledDevHmrClient, moduleId);
ctx._internal = {
diff --git a/dist/node/chunks/node.js b/dist/node/chunks/node.js
index 87cfa480c3d4132f9dd1b74c6c1bbe2b90385d3f..83da417e7b9c380d06b7679d3fbfaeed998f5277 100644
--- a/dist/node/chunks/node.js
+++ b/dist/node/chunks/node.js
@@ -26309,7 +26309,6 @@ function memoryFilesMiddleware(server) {
const mime = lookup(filePath);
if (mime) res.setHeader("Content-Type", mime);
for (const name in headers) res.setHeader(name, headers[name]);
- res.on("finish", () => bundledDev.markPayloadDelivered(filePath));
return res.end(file.source);
}
next();
@@ -26339,7 +26338,6 @@ function triggerLazyBundlingMiddleware(server) {
}
if (result == null) return next();
res.setHeader("Content-Type", "application/javascript");
- res.on("finish", () => bundledDev.markPayloadDelivered(result.filename));
return res.end(result.code);
};
}
@@ -35155,6 +35153,9 @@ var BundledDev = class {
this.clients.setupIfNeeded(client, payload.clientId);
this.devEngine.registerClient(payload.clientId);
});
+ this.environment.hot.on("vite:bundled-dev:payload-delivered", (payload) => {
+ this.markPayloadDelivered(payload.filename);
+ });
this.environment.hot.on("vite:client:connect", (_payload, client) => {
if (this.lastBuildError) {
debug$1?.("REPLAY: replaying last build error to newly connected client");
@@ -35287,12 +35288,11 @@ var BundledDev = class {
debug$1?.(`TRIGGER-LAZY: trigger lazy bundling for module ${moduleId} for client ${clientId}`);
const result = await this.devEngine.compileEntry(moduleId, clientId);
this.pendingPayloadFilenames.add(result.filename);
- return result;
+ return { filename: result.filename, code: result.code + payloadDeliveredAck(result.filename) };
}
/**
- * Called by the serving middlewares when the response for a payload completed.
- * Only delivered payloads are recorded on the server's per-client ship map, so
- * later chunks may omit a module only if the payload carrying it was delivered.
+ * Called after the client evaluates a payload and registers its factories.
+ * HTTP response completion alone does not mean the factories are available.
*
* Note: the payload filename is unique across all clients.
*/
@@ -35364,7 +35364,7 @@ var BundledDev = class {
code: typeof hmrOutput.code === "string" ? "[code]" : hmrOutput.code
});
this.pendingPayloadFilenames.add(hmrOutput.filename);
- this.memoryFiles.set(hmrOutput.filename, { source: hmrOutput.code + "\n; export {}" });
+ this.memoryFiles.set(hmrOutput.filename, { source: hmrOutput.code + payloadDeliveredAck(hmrOutput.filename) + "\n; export {}" });
if (hmrOutput.sourcemapFilename && hmrOutput.sourcemap) this.memoryFiles.set(hmrOutput.sourcemapFilename, { source: hmrOutput.sourcemap });
client.send({
type: "bundled-dev-update",
@@ -35407,6 +35407,10 @@ var Clients = class {
}
}
};
+// Backport https://github.com/vitejs/vite/pull/23373.
+function payloadDeliveredAck(filename) {
+ return `\n;__rolldown_runtime__.payloadDelivered(${JSON.stringify(filename)});`;
+}
function debounce(time, cb) {
let timer;
return () => {