2025-01-05 04:56:57 +00:00
|
|
|
// Copyright 2025, Command Line Inc.
|
2024-06-13 23:49:25 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
2025-02-05 01:58:36 +00:00
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
2024-07-18 22:16:49 +00:00
|
|
|
import react from "@vitejs/plugin-react-swc";
|
2024-06-13 23:49:25 +00:00
|
|
|
import { defineConfig } from "electron-vite";
|
2024-07-18 22:16:49 +00:00
|
|
|
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
|
2024-07-30 18:44:19 +00:00
|
|
|
import svgr from "vite-plugin-svgr";
|
2024-06-13 23:49:25 +00:00
|
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
|
|
|
2025-09-12 22:36:03 +00:00
|
|
|
// from our electron build
|
|
|
|
|
const CHROME = "chrome140";
|
|
|
|
|
const NODE = "node22";
|
|
|
|
|
|
New AIPanel (#2370)
Massive PR, over 13k LOC updated, 128 commits to implement the first pass at the new Wave AI panel. Two backend adapters (OpenAI and Anthropic), layout changes to support the panel, keyboard shortcuts, and a huge focus/layout change to integrate the panel seamlessly into the UI.
Also fixes some small issues found during the Wave AI journey (zoom fixes, documentation, more scss removal, circular dependency issues, settings, etc)
2025-10-07 20:32:10 +00:00
|
|
|
// for debugging
|
|
|
|
|
// target is like -- path.resolve(__dirname, "frontend/app/workspace/workspace-layout-model.ts");
|
|
|
|
|
function whoImportsTarget(target: string) {
|
|
|
|
|
return {
|
|
|
|
|
name: "who-imports-target",
|
|
|
|
|
buildEnd() {
|
|
|
|
|
// Build reverse graph: child -> [importers...]
|
|
|
|
|
const parents = new Map<string, string[]>();
|
|
|
|
|
for (const id of (this as any).getModuleIds()) {
|
|
|
|
|
const info = (this as any).getModuleInfo(id);
|
|
|
|
|
if (!info) continue;
|
|
|
|
|
for (const child of [...info.importedIds, ...info.dynamicallyImportedIds]) {
|
|
|
|
|
const arr = parents.get(child) ?? [];
|
|
|
|
|
arr.push(id);
|
|
|
|
|
parents.set(child, arr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Walk upward from TARGET and print paths to entries
|
|
|
|
|
const entries = [...parents.keys()].filter((id) => {
|
|
|
|
|
const m = (this as any).getModuleInfo(id);
|
|
|
|
|
return m?.isEntry;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const seen = new Set<string>();
|
|
|
|
|
const stack: string[] = [];
|
|
|
|
|
const dfs = (node: string) => {
|
|
|
|
|
if (seen.has(node)) return;
|
|
|
|
|
seen.add(node);
|
|
|
|
|
stack.push(node);
|
|
|
|
|
const ps = parents.get(node) || [];
|
|
|
|
|
if (ps.length === 0) {
|
|
|
|
|
// hit a root (likely main entry or plugin virtual)
|
|
|
|
|
console.log("\nImporter chain:");
|
|
|
|
|
stack
|
|
|
|
|
.slice()
|
|
|
|
|
.reverse()
|
|
|
|
|
.forEach((s) => console.log(" ↳", s));
|
|
|
|
|
} else {
|
|
|
|
|
for (const p of ps) dfs(p);
|
|
|
|
|
}
|
|
|
|
|
stack.pop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!parents.has(target)) {
|
|
|
|
|
console.log(`[who-imports] TARGET not in MAIN graph: ${target}`);
|
|
|
|
|
} else {
|
|
|
|
|
dfs(target);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async resolveId(id: any, importer: any) {
|
|
|
|
|
const r = await (this as any).resolve(id, importer, { skipSelf: true });
|
|
|
|
|
if (r?.id === target) {
|
|
|
|
|
console.log(`[resolve] ${importer} -> ${id} -> ${r.id}`);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-13 23:49:25 +00:00
|
|
|
export default defineConfig({
|
|
|
|
|
main: {
|
|
|
|
|
root: ".",
|
|
|
|
|
build: {
|
2025-09-12 22:36:03 +00:00
|
|
|
target: NODE,
|
2024-06-13 23:49:25 +00:00
|
|
|
rollupOptions: {
|
|
|
|
|
input: {
|
2024-06-14 06:03:57 +00:00
|
|
|
index: "emain/emain.ts",
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
outDir: "dist/main",
|
2026-02-17 06:59:18 +00:00
|
|
|
externalizeDeps: false,
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
2025-09-12 22:36:03 +00:00
|
|
|
plugins: [tsconfigPaths()],
|
2024-06-26 19:22:27 +00:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": "frontend",
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-08-19 22:50:25 +00:00
|
|
|
server: {
|
|
|
|
|
open: false,
|
|
|
|
|
},
|
2024-09-19 19:37:16 +00:00
|
|
|
define: {
|
|
|
|
|
"process.env.WS_NO_BUFFER_UTIL": "true",
|
|
|
|
|
"process.env.WS_NO_UTF_8_VALIDATE": "true",
|
|
|
|
|
},
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
|
|
|
|
preload: {
|
|
|
|
|
root: ".",
|
|
|
|
|
build: {
|
2025-09-12 22:36:03 +00:00
|
|
|
target: NODE,
|
2024-06-13 23:49:25 +00:00
|
|
|
sourcemap: true,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
input: {
|
2024-06-14 06:03:57 +00:00
|
|
|
index: "emain/preload.ts",
|
2024-10-04 23:34:05 +00:00
|
|
|
"preload-webview": "emain/preload-webview.ts",
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
format: "cjs",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
outDir: "dist/preload",
|
2026-02-17 06:59:18 +00:00
|
|
|
externalizeDeps: false,
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
2025-08-19 22:50:25 +00:00
|
|
|
server: {
|
|
|
|
|
open: false,
|
|
|
|
|
},
|
2025-09-12 22:36:03 +00:00
|
|
|
plugins: [tsconfigPaths()],
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
|
|
|
|
renderer: {
|
|
|
|
|
root: ".",
|
|
|
|
|
build: {
|
2025-09-12 22:36:03 +00:00
|
|
|
target: CHROME,
|
2024-06-13 23:49:25 +00:00
|
|
|
sourcemap: true,
|
|
|
|
|
outDir: "dist/frontend",
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
input: {
|
2024-06-14 06:03:57 +00:00
|
|
|
index: "index.html",
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
2025-10-14 06:37:45 +00:00
|
|
|
output: {
|
|
|
|
|
manualChunks(id) {
|
|
|
|
|
const p = id.replace(/\\/g, "/");
|
|
|
|
|
if (p.includes("node_modules/monaco") || p.includes("node_modules/@monaco")) return "monaco";
|
2026-01-06 00:34:36 +00:00
|
|
|
if (p.includes("node_modules/mermaid") || p.includes("node_modules/@mermaid")) return "mermaid";
|
2025-10-14 06:37:45 +00:00
|
|
|
if (p.includes("node_modules/katex") || p.includes("node_modules/@katex")) return "katex";
|
|
|
|
|
if (p.includes("node_modules/shiki") || p.includes("node_modules/@shiki")) {
|
|
|
|
|
return "shiki";
|
|
|
|
|
}
|
|
|
|
|
if (p.includes("node_modules/cytoscape") || p.includes("node_modules/@cytoscape"))
|
|
|
|
|
return "cytoscape";
|
|
|
|
|
return undefined;
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-06-13 23:49:25 +00:00
|
|
|
},
|
|
|
|
|
},
|
2025-09-12 22:36:03 +00:00
|
|
|
optimizeDeps: {
|
|
|
|
|
include: ["monaco-yaml/yaml.worker.js"],
|
|
|
|
|
},
|
2024-06-17 16:58:28 +00:00
|
|
|
server: {
|
|
|
|
|
open: false,
|
2025-08-21 01:07:11 +00:00
|
|
|
watch: {
|
2026-01-06 00:34:36 +00:00
|
|
|
ignored: [
|
|
|
|
|
"dist/**",
|
|
|
|
|
"**/*.go",
|
|
|
|
|
"**/go.mod",
|
|
|
|
|
"**/go.sum",
|
|
|
|
|
"**/*.md",
|
2026-03-12 00:23:00 +00:00
|
|
|
"**/*.mdx",
|
2026-01-06 00:34:36 +00:00
|
|
|
"**/*.json",
|
2026-03-20 20:07:58 +00:00
|
|
|
"**/emain/**",
|
2026-01-06 00:34:36 +00:00
|
|
|
"**/*.txt",
|
|
|
|
|
"**/*.log",
|
|
|
|
|
],
|
2025-08-21 01:07:11 +00:00
|
|
|
},
|
2024-06-17 16:58:28 +00:00
|
|
|
},
|
2025-02-05 01:58:36 +00:00
|
|
|
css: {
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
scss: {
|
|
|
|
|
silenceDeprecations: ["mixed-decls"],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-06-13 23:49:25 +00:00
|
|
|
plugins: [
|
|
|
|
|
tsconfigPaths(),
|
2025-09-12 22:36:03 +00:00
|
|
|
{ ...ViteImageOptimizer(), apply: "build" },
|
2024-08-05 23:13:26 +00:00
|
|
|
svgr({
|
|
|
|
|
svgrOptions: { exportType: "default", ref: true, svgo: false, titleProp: true },
|
|
|
|
|
include: "**/*.svg",
|
|
|
|
|
}),
|
2024-07-18 22:16:49 +00:00
|
|
|
react({}),
|
2025-02-05 01:58:36 +00:00
|
|
|
tailwindcss(),
|
2024-06-13 23:49:25 +00:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
});
|