Skip to content

Commit 1352ef6

Browse files
feat(Sky): Replace Electron IPC service with Tauri service in build
Add Step 7 build hook in astro.config.ts that replaces the VS Code ElectronIPCMainProcessService with TauriMainProcessService at build time. This routes all IPC channel.call() invocations directly through Tauri invoke to Mountain's WindServiceHandlers, eliminating the binary IPC protocol entirely. Part of the Electron workbench loading effort (see recent commits) to enable the VS Code workbench to function within Tauri's WKWebView.
1 parent 949d261 commit 1352ef6

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

astro.config.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,63 @@ export default defineConfig({
220220
// May not exist yet
221221
}
222222

223+
// Step 7: When Electron=true, replace ElectronIPCMainProcessService
224+
// with TauriMainProcessService that routes channel.call() directly
225+
// through Tauri invoke to Mountain's WindServiceHandlers.
226+
// This eliminates the binary IPC protocol entirely.
227+
if (process.env["Electron"] === "true") {
228+
const MainProcessServicePath = join(
229+
Destination,
230+
"platform",
231+
"ipc",
232+
"electron-browser",
233+
"mainProcessService.js",
234+
);
235+
try {
236+
const TauriServiceSource = resolve(
237+
process.cwd(),
238+
"node_modules/@codeeditorland/wind/Target/Service/TauriMainProcessService.js",
239+
);
240+
let TauriServiceContent = await readFile(
241+
TauriServiceSource,
242+
"utf-8",
243+
);
244+
// Strip the compiled module's own exports and sourcemap
245+
// so we can re-export under the original name.
246+
TauriServiceContent = TauriServiceContent
247+
.replace(
248+
/^export\s*\{[^}]*\}\s*;?\s*$/gm,
249+
"",
250+
)
251+
.replace(
252+
/^\/\/# sourceMappingURL=.*$/gm,
253+
"",
254+
)
255+
.replace(
256+
/^export default .*$/gm,
257+
"",
258+
);
259+
const ReplacementModule = [
260+
"// TauriMainProcessService — routes IPC channels through Tauri invoke to Mountain",
261+
TauriServiceContent,
262+
"export { TauriMainProcessService as ElectronIPCMainProcessService };",
263+
].join("\n");
264+
await writeFile(
265+
MainProcessServicePath,
266+
ReplacementModule,
267+
"utf-8",
268+
);
269+
console.log(
270+
"[CopyVSCode] Step 7: Replaced ElectronIPCMainProcessService with TauriMainProcessService",
271+
);
272+
} catch (Error) {
273+
console.warn(
274+
"[CopyVSCode] Step 7: TauriMainProcessService replacement failed:",
275+
Error,
276+
);
277+
}
278+
}
279+
223280
console.log("[CopyVSCode] ✓ Assets ready in Target/");
224281
},
225282
},

0 commit comments

Comments
 (0)