save work

This commit is contained in:
Evan Simkowitz 2024-03-01 16:21:18 -08:00
parent 5c436198af
commit 07f176ea53
No known key found for this signature in database
5 changed files with 662 additions and 55 deletions

View File

@ -0,0 +1,70 @@
const pkg = require("./package.json");
/**
* @type {import('electron-builder').Configuration}
* @see https://www.electron.build/configuration/configuration
*/
const config = {
artifactName: "${productName}-${version}-${arch}.${ext}",
npmRebuild: false,
nodeGypRebuild: false,
electronCompile: false,
files: [
{
from: "./dist",
to: "./dist",
filter: ["**/*"],
},
{
from: "./public",
to: "./public",
filter: ["**/*"],
},
{
from: "./bin",
to: "./bin",
filter: ["**/*"],
},
{
from: "./node_modules",
to: "./node_modules",
filter: ["monaco-editor/min/*"],
},
{
from: ".",
to: ".",
filter: ["package.json"],
},
],
directories: {
output: "buildres/builder",
},
appId: pkg.build.appId,
productName: pkg.productName,
mac: {
target: {
target: "zip",
arch: "universal",
},
icon: "public/waveterm.icns",
category: "public.app-category.developer-tools",
minimumSystemVersion: "10.15.0",
asarUnpack: ["bin/**/*"],
},
linux: {
executableName: pkg.productName,
category: "TerminalEmulator",
icon: "public/waveterm.icns",
target: ["zip", "rpm", "deb", "flatpak", "pacman"],
desktop: {
Name: pkg.productName,
Comment: pkg.description,
Exec: pkg.productName,
Icon: pkg.build.appId,
Keywords: "developer;terminal;emulator;",
category: "Development;Utility;",
},
},
};
module.exports = config;

View File

@ -14,6 +14,9 @@
"url": "https://github.com/wavetermdev/waveterm"
},
"homepage": "https://waveterm.dev",
"build": {
"appId": "dev.commandline.waveterm"
},
"dependencies": {
"@monaco-editor/react": "^4.5.1",
"@table-nav/core": "^0.0.7",
@ -66,7 +69,6 @@
"@electron-forge/maker-snap": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.3.0",
"@electron/rebuild": "^3.4.0",
"@svgr/webpack": "^8.1.0",
"@types/classnames": "^2.3.1",
"@types/electron": "^1.6.10",
@ -82,6 +84,7 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"electron": "29.0.1",
"electron-builder": "^24.12.0",
"file-loader": "^6.2.0",
"http-server": "^14.1.1",
"less": "^4.1.2",
@ -99,5 +102,7 @@
"webpack-dev-server": "^4.9.1",
"webpack-merge": "^5.8.0"
},
"scripts": {}
"scripts": {
"postinstall": "electron-builder install-app-deps"
}
}

View File

@ -50,7 +50,7 @@ GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')"
(cd waveshell; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-linux.amd64 main-waveshell.go)
(cd waveshell; CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.4-linux.arm64 main-waveshell.go)
(cd wavesrv; CGO_ENABLED=1 go build -tags "osusergo,netgo,sqlite_omit_load_extension" -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M') -X main.WaveVersion=$WAVESRV_VERSION" -o ../bin/wavesrv ./cmd)
node_modules/.bin/electron-forge make
yarn run electron-builder -c electron-builder.config.js
```
```bash

View File

@ -69,9 +69,10 @@ function log(...msg: any[]) {
console.log = log;
console.log(
sprintf(
"waveterm-app starting, WAVETERM_HOME=%s, apppath=%s arch=%s/%s",
"waveterm-app starting, WAVETERM_HOME=%s, electronpath=%s gopath=%s arch=%s/%s",
waveHome,
getAppBasePath(),
getElectronAppBasePath(),
getGoAppBasePath(),
unamePlatform,
unameArch
)
@ -130,31 +131,46 @@ function checkPromptMigrate() {
}
}
// for dev, this is just the waveterm directory
// for prod, this is .../Wave.app/Contents/Resources/app
function getAppBasePath() {
/**
* Gets the base path to the Electron app resources. For dev, this is the root of the project. For packaged apps, this is the app.asar archive.
* @returns The base path of the Electron application
*/
function getElectronAppBasePath(): string {
return path.dirname(__dirname);
}
function getBaseHostPort() {
/**
* Gets the base path to the Go backend. If the app is packaged as an asar, the path will be in a separate unpacked directory.
* @returns The base path of the Go backend
*/
function getGoAppBasePath(): string {
const appDir = getElectronAppBasePath();
if (appDir.endsWith(".asar")) {
return `${appDir}.unpacked`;
} else {
return appDir;
}
}
function getBaseHostPort(): string {
if (isDev) {
return DevServerEndpoint;
}
return ProdServerEndpoint;
}
function getWaveSrvPath() {
return path.join(getAppBasePath(), "bin", "wavesrv");
function getWaveSrvPath(): string {
return path.join(getGoAppBasePath(), "bin", "wavesrv");
}
function getWaveSrvCmd() {
function getWaveSrvCmd(): string {
const waveSrvPath = getWaveSrvPath();
const waveHome = getWaveHomeDir();
const logFile = path.join(waveHome, "wavesrv.log");
return `"${waveSrvPath}" >> "${logFile}" 2>&1`;
}
function getWaveSrvCwd() {
function getWaveSrvCwd(): string {
return getWaveHomeDir();
}
@ -162,7 +178,7 @@ function ensureDir(dir: fs.PathLike) {
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
}
function readAuthKey() {
function readAuthKey(): string {
const homeDir = getWaveHomeDir();
const authKeyFileName = path.join(homeDir, AuthKeyFile);
if (!fs.existsSync(authKeyFileName)) {
@ -259,7 +275,7 @@ electron.Menu.setApplicationMenu(menu);
let MainWindow: Electron.BrowserWindow | null = null;
function getMods(input: any) {
function getMods(input: any): object {
return { meta: input.meta, shift: input.shift, ctrl: input.control, alt: input.alt };
}
@ -291,7 +307,7 @@ function shFrameNavHandler(event: Electron.Event<Electron.WebContentsWillFrameNa
console.log("frame navigation canceled");
}
function createMainWindow(clientData: ClientDataType | null) {
function createMainWindow(clientData: ClientDataType | null): Electron.BrowserWindow {
const bounds = calcBounds(clientData);
setKeyUtilPlatform(platform());
const win = new electron.BrowserWindow({
@ -305,11 +321,11 @@ function createMainWindow(clientData: ClientDataType | null) {
transparent: true,
icon: unamePlatform == "linux" ? "public/logos/wave-logo-dark.png" : undefined,
webPreferences: {
preload: path.join(getAppBasePath(), DistDir, "preload.js"),
preload: path.join(getElectronAppBasePath(), DistDir, "preload.js"),
},
});
const indexHtml = isDev ? "index-dev.html" : "index.html";
win.loadFile(path.join(getAppBasePath(), "public", indexHtml));
win.loadFile(path.join(getElectronAppBasePath(), "public", indexHtml));
win.webContents.on("before-input-event", (e, input) => {
const waveEvent = adaptFromElectronKeyEvent(input);
if (win.isFocused()) {
@ -450,7 +466,7 @@ function mainResizeHandler(_: any, win: Electron.BrowserWindow) {
});
}
function calcBounds(clientData: ClientDataType) {
function calcBounds(clientData: ClientDataType): Electron.Rectangle {
const primaryDisplay = electron.screen.getPrimaryDisplay();
const pdBounds = primaryDisplay.bounds;
const size = { x: 100, y: 100, width: pdBounds.width - 200, height: pdBounds.height - 200 };
@ -572,7 +588,7 @@ function readLastLinesOfFile(filePath: string, lineCount: number) {
});
}
function getContextMenu(): any {
function getContextMenu(): electron.Menu {
const menu = new electron.Menu();
const menuItem = new electron.MenuItem({ label: "Testing", click: () => console.log("click testing!") });
menu.append(menuItem);
@ -585,7 +601,7 @@ function getFetchHeaders() {
};
}
async function getClientDataPoll(loopNum: number) {
async function getClientDataPoll(loopNum: number): Promise<ClientDataType | null> {
const lastTime = loopNum >= 6;
const cdata = await getClientData(!lastTime, loopNum);
if (lastTime || cdata != null) {
@ -595,7 +611,7 @@ async function getClientDataPoll(loopNum: number) {
return getClientDataPoll(loopNum + 1);
}
async function getClientData(willRetry: boolean, retryNum: number) {
async function getClientData(willRetry: boolean, retryNum: number): Promise<ClientDataType | null> {
const url = new URL(getBaseHostPort() + "/api/get-client-data");
const fetchHeaders = getFetchHeaders();
return fetch(url, { headers: fetchHeaders })
@ -634,13 +650,13 @@ function runWaveSrv() {
pReject = argReject;
});
const envCopy = { ...process.env };
envCopy[WaveAppPathVarName] = getAppBasePath();
envCopy[WaveAppPathVarName] = getGoAppBasePath();
if (isDev) {
envCopy[WaveDevVarName] = "1";
}
const waveSrvCmd = getWaveSrvCmd();
console.log("trying to run local server", waveSrvCmd);
const proc = child_process.spawn("bash", ["-c", waveSrvCmd], {
const proc = child_process.execFile("bash", ["-c", waveSrvCmd], {
cwd: getWaveSrvCwd(),
env: envCopy,
});

578
yarn.lock

File diff suppressed because it is too large Load Diff