Added nw.js launch options
This commit is contained in:
parent
6aacec2c0d
commit
701f882136
5 changed files with 34 additions and 36 deletions
|
|
@ -250,8 +250,7 @@ export default class RcloneIntegration implements PluginType<SettingsType>
|
|||
UseJSONLog: true,
|
||||
LogLevel: "DEBUG",
|
||||
HumanReadable: true,
|
||||
Progress: true,
|
||||
DryRun: true
|
||||
Progress: true
|
||||
}
|
||||
});
|
||||
console.log(data);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import { BrowserParams, BuildParams } from './utils/browser-params';
|
|||
import os from 'node:os';
|
||||
import { EventEmitter } from 'node:stream';
|
||||
import { dlopen, FFIType, Pointer } from "bun:ffi";
|
||||
import { SERVER_URL } from '@/shared/constants';
|
||||
import { host } from './utils/host';
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
export default async function init (events: EventEmitter, forceBrowser: boolean, params: BrowserParams)
|
||||
{
|
||||
|
|
@ -19,6 +22,8 @@ export default async function init (events: EventEmitter, forceBrowser: boolean,
|
|||
await runBrowser(events, params);
|
||||
}
|
||||
}
|
||||
|
||||
await runNW(events, params);
|
||||
}
|
||||
|
||||
function focusWindow (id: Pointer)
|
||||
|
|
@ -44,8 +49,28 @@ function focusWindow (id: Pointer)
|
|||
}
|
||||
}
|
||||
|
||||
async function runNW (events: EventEmitter, params: BrowserParams)
|
||||
{
|
||||
const path = process.platform === 'win32' ? './bin/nw/nw.exe' : './bin/nw/nw';
|
||||
if (!await fs.exists(path))
|
||||
{
|
||||
console.error("Could not find NW.js");
|
||||
return;
|
||||
}
|
||||
const signalHandler = new AbortController();
|
||||
events.on('exitapp', () => signalHandler.abort());
|
||||
const args = [path, `--url=${SERVER_URL(host)}`];
|
||||
if (process.env.NODE_ENV !== 'development') args.push("--disable-devtools");
|
||||
const nwProcess = Bun.spawn(args, { signal: signalHandler.signal });
|
||||
await nwProcess.exited;
|
||||
}
|
||||
|
||||
async function runWebview (events: EventEmitter, params: BrowserParams)
|
||||
{
|
||||
if (process.platform !== 'win32')
|
||||
{
|
||||
throw new Error("Webview only supported on windows");
|
||||
}
|
||||
const webviewPath = process.env.IS_BINARY ? `./webview/${os.platform()}` : new URL(`./webview/${os.platform()}`, import.meta.url).href;
|
||||
console.log("Launching Webview Worker at: ", webviewPath);
|
||||
const config: Record<string, string> = {};
|
||||
|
|
|
|||
|
|
@ -1,36 +1,9 @@
|
|||
import { Size, SizeHint, Webview } from 'webview-bun';
|
||||
import webviewWorkerBase from "./base";
|
||||
|
||||
if (process.env.FLATPAK_BUILD === "true")
|
||||
{
|
||||
let webview: Bun.Subprocess | undefined = undefined;
|
||||
let hostUrl: string | undefined = undefined;
|
||||
webviewWorkerBase({
|
||||
navigate: (url) =>
|
||||
{
|
||||
hostUrl = url;
|
||||
|
||||
}, destroy: () => webview?.kill(), run: () =>
|
||||
{
|
||||
webview = Bun.spawn(["webview", hostUrl ?? ''], {
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
env: {
|
||||
...process.env,
|
||||
},
|
||||
onExit ()
|
||||
{
|
||||
postMessage({ data: 'destroyed' });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else
|
||||
{
|
||||
console.log("Launching Webview");
|
||||
let size: Size | undefined = undefined;
|
||||
if (process.env.WINDOW_WIDTH && process.env.WINDOW_HEIGHT)
|
||||
size = { width: Number(process.env.WINDOW_WIDTH), height: Number(process.env.WINDOW_HEIGHT), hint: SizeHint.NONE };
|
||||
const webview = new Webview(process.env.NODE_ENV === 'development', size);
|
||||
webviewWorkerBase(webview);
|
||||
}
|
||||
console.log("Launching Webview");
|
||||
let size: Size | undefined = undefined;
|
||||
if (process.env.WINDOW_WIDTH && process.env.WINDOW_HEIGHT)
|
||||
size = { width: Number(process.env.WINDOW_WIDTH), height: Number(process.env.WINDOW_HEIGHT), hint: SizeHint.NONE };
|
||||
const webview = new Webview(process.env.NODE_ENV === 'development', size);
|
||||
webviewWorkerBase(webview);
|
||||
|
|
@ -464,7 +464,7 @@ const assets = new Set<string>([
|
|||
]);
|
||||
|
||||
// Store basePath resolved from Vite config
|
||||
const BASE_PATH = "/";
|
||||
const BASE_PATH = "./";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue