mirror of
https://github.com/meshtastic/web.git
synced 2025-12-23 15:51:28 -05:00
Initial sandbox commit (not fully working)
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
"@serialport/bindings-cpp",
|
||||
"@tailwindcss/oxide",
|
||||
"core-js",
|
||||
"electron",
|
||||
"esbuild",
|
||||
"simple-git-hooks"
|
||||
]
|
||||
|
||||
74
packages/desktop/main.ts
Normal file
74
packages/desktop/main.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { app, BrowserWindow } from "electron";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const __webroot = path.join(__dirname, "./built-web-app");
|
||||
|
||||
console.log("Hello, world!");
|
||||
console.log(__filename);
|
||||
console.log(__dirname);
|
||||
console.log(__webroot);
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
});
|
||||
|
||||
// if (process.env.NODE_ENV === "development") {
|
||||
// // Optionally run Vite dev server and load URL
|
||||
// win.loadURL("http://localhost:3000");
|
||||
// win.webContents.openDevTools();
|
||||
// } else {
|
||||
// win.loadFile(path.join(__dirname, "../dist/index.html"));
|
||||
// }
|
||||
|
||||
win.webContents.openDevTools();
|
||||
win.loadFile(path.join(__webroot, "index.html"));
|
||||
|
||||
// Serial permission handler
|
||||
win.webContents.session.on(
|
||||
"select-serial-port",
|
||||
(event, portList, webContents, callback) => {
|
||||
console.log("portList", portList);
|
||||
event.preventDefault();
|
||||
const selectedPort = portList[portList.length - 1];
|
||||
console.log("selectedPort", selectedPort);
|
||||
if (!selectedPort) {
|
||||
callback("");
|
||||
} else {
|
||||
callback(selectedPort.portId);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// // Bluetooth selection event
|
||||
// win.webContents.on(
|
||||
// "select-bluetooth-device",
|
||||
// (event, deviceList, callback) => {
|
||||
// event.preventDefault();
|
||||
// // Example: pick first device, or show your own UI
|
||||
// if (deviceList.length > 0) {
|
||||
// callback(deviceList[0].deviceId);
|
||||
// } else {
|
||||
// callback(""); // cancel
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
app.commandLine.appendSwitch("enable-web-bluetooth");
|
||||
app.commandLine.appendSwitch("enable-experimental-web-platform-features");
|
||||
createWindow();
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
});
|
||||
22
packages/desktop/package.json
Normal file
22
packages/desktop/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "desktop",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "cd ../web && pnpm run build && cd ../desktop/ && rm -rf dist && mkdir -p dist/ && cp -r ../web/dist ./dist/built-web-app && tsc && electron ./dist/main.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@10.11.1",
|
||||
"dependencies": {
|
||||
"electron": "^39.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.9.2",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
44
packages/desktop/tsconfig.json
Normal file
44
packages/desktop/tsconfig.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
// Visit https://aka.ms/tsconfig to read more about this file
|
||||
"compilerOptions": {
|
||||
// File Layout
|
||||
// "rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
|
||||
// Environment Settings
|
||||
// See also https://aka.ms/tsconfig/module
|
||||
"module": "nodenext",
|
||||
"target": "esnext",
|
||||
"types": [],
|
||||
// For nodejs:
|
||||
// "lib": ["esnext"],
|
||||
// "types": ["node"],
|
||||
// and npm install -D @types/node
|
||||
|
||||
// Other Outputs
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
|
||||
// Stricter Typechecking Options
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
|
||||
// Style Options
|
||||
// "noImplicitReturns": true,
|
||||
// "noImplicitOverride": true,
|
||||
// "noUnusedLocals": true,
|
||||
// "noUnusedParameters": true,
|
||||
// "noFallthroughCasesInSwitch": true,
|
||||
// "noPropertyAccessFromIndexSignature": true,
|
||||
|
||||
// Recommended Options
|
||||
"strict": true,
|
||||
"jsx": "react-jsx",
|
||||
// "verbatimModuleSyntax": true,
|
||||
"isolatedModules": true,
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"moduleDetection": "force",
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
@@ -87,21 +87,21 @@ export const CommandPalette = () => {
|
||||
label: t("goto.command.messages"),
|
||||
icon: MessageSquareIcon,
|
||||
action() {
|
||||
navigate({ to: "/messages" });
|
||||
navigate({ to: "./messages" });
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("goto.command.map"),
|
||||
icon: MapIcon,
|
||||
action() {
|
||||
navigate({ to: "/map" });
|
||||
navigate({ to: "./map" });
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("goto.command.config"),
|
||||
icon: SettingsIcon,
|
||||
action() {
|
||||
navigate({ to: "/config" });
|
||||
navigate({ to: "./config" });
|
||||
},
|
||||
tags: ["settings"],
|
||||
},
|
||||
@@ -109,7 +109,7 @@ export const CommandPalette = () => {
|
||||
label: t("goto.command.nodes"),
|
||||
icon: UsersIcon,
|
||||
action() {
|
||||
navigate({ to: "/nodes" });
|
||||
navigate({ to: "./nodes" });
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -14,8 +14,10 @@ export function useBrowserFeatureDetection(): BrowserSupport {
|
||||
["Web Serial", !!navigator.serial],
|
||||
[
|
||||
"Secure Context",
|
||||
globalThis.location.protocol === "https:" ||
|
||||
globalThis.location.hostname === "localhost",
|
||||
true,
|
||||
// globalThis.location.protocol === "https:" ||
|
||||
// globalThis.location.hostname === "localhost" ||
|
||||
// globalThis.location.hostname === "file:",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ i18next
|
||||
.init({
|
||||
backend: {
|
||||
// With this setup, {{lng}} will correctly resolve to 'en-US', 'fi-FI', etc.
|
||||
loadPath: "/i18n/locales/{{lng}}/{{ns}}.json",
|
||||
loadPath: "./i18n/locales/{{lng}}/{{ns}}.json",
|
||||
},
|
||||
react: {
|
||||
useSuspense: true,
|
||||
|
||||
@@ -33,7 +33,7 @@ const indexRoute = createRoute({
|
||||
component: Dashboard,
|
||||
loader: () => {
|
||||
// Redirect to the broadcast messages page on initial load
|
||||
return redirect({ to: "/messages/broadcast/0", replace: true });
|
||||
return redirect({ to: "./messages/broadcast/0", replace: true });
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ export default defineConfig(({ mode }) => {
|
||||
const isTest = env.VITE_IS_TEST;
|
||||
|
||||
return {
|
||||
base: "./",
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
|
||||
1015
pnpm-lock.yaml
generated
1015
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user