only import G6 types
This commit is contained in:
1 parent
5051e2aefb
commit
b04b8de22b
6 files changed
+84
-53
No files matched your search
+38
-4
@@ -45,8 +45,8 @@ const url = process.env.VITE_DEV_SERVER_URL;
|
|||||||
const indexHtml = join(process.env.DIST, "index.html");
|
const indexHtml = join(process.env.DIST, "index.html");
|
||||||
const windows: Workspace[] = [];
|
const windows: Workspace[] = [];
|
||||||
|
|
||||||
let buildProject: string;
|
let buildProject: string | undefined;
|
||||||
let buildOutput: string;
|
let buildOutput: string | undefined;
|
||||||
let buildHelp: boolean = false;
|
let buildHelp: boolean = false;
|
||||||
|
|
||||||
for (let i = 0; i < argv.length; i++) {
|
for (let i = 0; i < argv.length; i++) {
|
||||||
@@ -79,7 +79,41 @@ if (buildOutput || buildProject || buildHelp) {
|
|||||||
printHelp();
|
printHelp();
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
}
|
}
|
||||||
console.log("todo: build output");
|
// try {
|
||||||
|
// let hasError = false;
|
||||||
|
// const project = Path.posixPath(buildProject!);
|
||||||
|
// const buildDir = Path.posixPath(buildOutput!);
|
||||||
|
// if (!project.endsWith(".b3-workspace")) {
|
||||||
|
// throw new Error(`'${project}' is not a workspace`);
|
||||||
|
// }
|
||||||
|
// const workdir = Path.dirname(project);
|
||||||
|
// b3util.initWorkdir(workdir, (msg) => {
|
||||||
|
// console.error(msg);
|
||||||
|
// });
|
||||||
|
// for (const path of Path.ls(Path.dirname(project), true)) {
|
||||||
|
// if (path.endsWith(".json")) {
|
||||||
|
// const buildpath = buildDir + "/" + path.substring(workdir.length + 1);
|
||||||
|
// const treeModel = b3util.createBuildData(path);
|
||||||
|
// if (treeModel && treeModel.export === false) {
|
||||||
|
// console.log("skip:", buildpath);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// console.log("build:", buildpath);
|
||||||
|
// if (!b3util.checkNodeData(treeModel?.root)) {
|
||||||
|
// hasError = true;
|
||||||
|
// }
|
||||||
|
// fs.mkdirSync(Path.dirname(buildpath), { recursive: true });
|
||||||
|
// fs.writeFileSync(buildpath, JSON.stringify(treeModel, null, 2));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (hasError) {
|
||||||
|
// console.error("build failed");
|
||||||
|
// } else {
|
||||||
|
// console.log("build completed");
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("build failed");
|
||||||
|
// }
|
||||||
app.exit(0);
|
app.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +234,7 @@ ipcMain.handle("open-win", (event, arg: string | undefined) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workspace = windows.find((v) => v.window.webContents.id === event.sender.id);
|
workspace = windows.find((v) => v.window.webContents.id === event.sender.id);
|
||||||
if (!workspace.projectPath) {
|
if (workspace && !workspace.projectPath) {
|
||||||
workspace.projectPath = arg;
|
workspace.projectPath = arg;
|
||||||
workspace.window.webContents.send("open-project", arg);
|
workspace.window.webContents.send("open-project", arg);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+40
-37
@@ -1,73 +1,76 @@
|
|||||||
import { app, ipcMain } from 'electron'
|
import { app, ipcMain } from "electron";
|
||||||
import {
|
import { type ProgressInfo, type UpdateDownloadedEvent, autoUpdater } from "electron-updater";
|
||||||
type ProgressInfo,
|
|
||||||
type UpdateDownloadedEvent,
|
|
||||||
autoUpdater
|
|
||||||
} from 'electron-updater'
|
|
||||||
|
|
||||||
export function update(win: Electron.BrowserWindow) {
|
export function update(win: Electron.BrowserWindow) {
|
||||||
|
|
||||||
// When set to false, the update download will be triggered through the API
|
// When set to false, the update download will be triggered through the API
|
||||||
autoUpdater.autoDownload = false
|
autoUpdater.autoDownload = false;
|
||||||
autoUpdater.disableWebInstaller = false
|
autoUpdater.disableWebInstaller = false;
|
||||||
autoUpdater.allowDowngrade = false
|
autoUpdater.allowDowngrade = false;
|
||||||
|
|
||||||
// start check
|
// start check
|
||||||
autoUpdater.on('checking-for-update', function () { })
|
autoUpdater.on("checking-for-update", function () {});
|
||||||
// update available
|
// update available
|
||||||
autoUpdater.on('update-available', (arg) => {
|
autoUpdater.on("update-available", (arg) => {
|
||||||
win.webContents.send('update-can-available', { update: true, version: app.getVersion(), newVersion: arg?.version })
|
win.webContents.send("update-can-available", {
|
||||||
})
|
update: true,
|
||||||
|
version: app.getVersion(),
|
||||||
|
newVersion: arg?.version,
|
||||||
|
});
|
||||||
|
});
|
||||||
// update not available
|
// update not available
|
||||||
autoUpdater.on('update-not-available', (arg) => {
|
autoUpdater.on("update-not-available", (arg) => {
|
||||||
win.webContents.send('update-can-available', { update: false, version: app.getVersion(), newVersion: arg?.version })
|
win.webContents.send("update-can-available", {
|
||||||
})
|
update: false,
|
||||||
|
version: app.getVersion(),
|
||||||
|
newVersion: arg?.version,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Checking for updates
|
// Checking for updates
|
||||||
ipcMain.handle('check-update', async () => {
|
ipcMain.handle("check-update", async () => {
|
||||||
if (!app.isPackaged) {
|
if (!app.isPackaged) {
|
||||||
const error = new Error('The update feature is only available after the package.')
|
const error = new Error("The update feature is only available after the package.");
|
||||||
return { message: error.message, error }
|
return { message: error.message, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await autoUpdater.checkForUpdatesAndNotify()
|
return await autoUpdater.checkForUpdatesAndNotify();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { message: 'Network error', error }
|
return { message: "Network error", error };
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// Start downloading and feedback on progress
|
// Start downloading and feedback on progress
|
||||||
ipcMain.handle('start-download', (event) => {
|
ipcMain.handle("start-download", (event) => {
|
||||||
startDownload(
|
startDownload(
|
||||||
(error, progressInfo) => {
|
(error, progressInfo) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
// feedback download error message
|
// feedback download error message
|
||||||
event.sender.send('update-error', { message: error.message, error })
|
event.sender.send("update-error", { message: error.message, error });
|
||||||
} else {
|
} else {
|
||||||
// feedback update progress message
|
// feedback update progress message
|
||||||
event.sender.send('download-progress', progressInfo)
|
event.sender.send("download-progress", progressInfo);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
// feedback update downloaded message
|
// feedback update downloaded message
|
||||||
event.sender.send('update-downloaded')
|
event.sender.send("update-downloaded");
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
// Install now
|
// Install now
|
||||||
ipcMain.handle('quit-and-install', () => {
|
ipcMain.handle("quit-and-install", () => {
|
||||||
autoUpdater.quitAndInstall(false, true)
|
autoUpdater.quitAndInstall(false, true);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function startDownload(
|
function startDownload(
|
||||||
callback: (error: Error | null, info: ProgressInfo) => void,
|
callback: (error: Error | null, info: ProgressInfo) => void,
|
||||||
complete: (event: UpdateDownloadedEvent) => void,
|
complete: (event: UpdateDownloadedEvent) => void
|
||||||
) {
|
) {
|
||||||
autoUpdater.on('download-progress', info => callback(null, info))
|
autoUpdater.on("download-progress", (info) => callback(null, info));
|
||||||
autoUpdater.on('error', error => callback(error, null))
|
autoUpdater.on("error", (error) => callback(error, null!));
|
||||||
autoUpdater.on('update-downloaded', complete)
|
autoUpdater.on("update-downloaded", complete);
|
||||||
autoUpdater.downloadUpdate()
|
autoUpdater.downloadUpdate();
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { TreeGraphData as G6TreeGraphData } from "@antv/g6";
|
import type { TreeGraphData as G6TreeGraphData } from "@antv/g6";
|
||||||
import { NodeDef } from "../behavior3/src/behavior3";
|
import type { NodeDef } from "../behavior3/src/behavior3";
|
||||||
|
|
||||||
export type NodeType = NodeDef["type"] | "Other" | "Error";
|
export type NodeType = NodeDef["type"] | "Other" | "Error";
|
||||||
export type NodeArg = Exclude<NodeDef["args"], undefined>[number];
|
export type NodeArg = Exclude<NodeDef["args"], undefined>[number];
|
||||||
|
|||||||
+1
-1
@@ -16,6 +16,6 @@
|
|||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx"
|
"jsx": "react-jsx"
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src", "electron"],
|
||||||
"references": [{ "path": "./tsconfig.node.json" }]
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,5 +6,5 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"allowSyntheticDefaultImports": true
|
"allowSyntheticDefaultImports": true
|
||||||
},
|
},
|
||||||
"include": ["vite.config.ts", "package.json", "electron"]
|
"include": ["vite.config.ts", "package.json"]
|
||||||
}
|
}
|
||||||
+2
-8
@@ -1,7 +1,6 @@
|
|||||||
import { rmSync } from "node:fs";
|
|
||||||
import path from "node:path";
|
|
||||||
import { defineConfig } from "vite";
|
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
|
import { rmSync } from "node:fs";
|
||||||
|
import { defineConfig } from "vite";
|
||||||
import electron from "vite-electron-plugin";
|
import electron from "vite-electron-plugin";
|
||||||
import { customStart, loadViteEnv } from "vite-electron-plugin/plugin";
|
import { customStart, loadViteEnv } from "vite-electron-plugin/plugin";
|
||||||
import renderer from "vite-plugin-electron-renderer";
|
import renderer from "vite-plugin-electron-renderer";
|
||||||
@@ -17,11 +16,6 @@ export default defineConfig(({ command }) => {
|
|||||||
build: {
|
build: {
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
},
|
},
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
"@": path.join(__dirname, "src"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [
|
plugins: [
|
||||||
react(),
|
react(),
|
||||||
electron({
|
electron({
|
||||||
|
|||||||
Reference in new issue
Block a user