* chore: skeleton for building and creating menus. Need electron to renderer interface to dynamically set the menu * chore: skeleton typing for communication between nodes and web side * chore: more skeleton for the different roles within the menu options, need more type safety * chore: adding more skeleton and templates of what the menus could be * chore: implemented first pass for helpRole links * fix: syntax issue stopped the build step * feature: loading different menus based on your page * feature: Home page file role implemented * chore: handling the build workflow for the signin page * fix: moving edit actionst to the edit menu * chore: adding preferences to the file role * chore: redoing help roles based on the question mark widget * fix: auto fmt * chore: examples of accelerator strings for Menu.MenuItems keyboard shortcuts! * chore: oddly specific toggle API for disabling MenuItems from JS. No rules! * fix: do not implement a custom label disable thingy, use id on menu and use the native APIga * fix: auto fmt * fix: adding some typechecks and auto fmt fixes * fix: trying to fix custom type? * fix: nvm we back, the lsp on my editor borked for a second * fix: adding one more level to the custom type for the labels * chore: cleaning up type definitions to read easier * fix: resolving yarn lint errors * chore: adding file sign out * chore: adding more file bar actions * chore: ready for PR draft * fix: preemptive GC collectoin bug fix if somehow a user interacts with a menu while it is being GCed * fix: linking the OG source * fix: set application menu to null to avoid default electron menu * chore: trying to add more typescript * chore: BIG workflow changes... better typing, less IPC junk * fix: remapping the icp functions to the cb option select... * chore: all og events are rehooked up with new workflow pattern * feat: adding more options to the native bar! * fix: todo * chore: cleaning up some menus and adding more * fix: desktop vs browser and lint errors * fix: typescript did not like sample electorn JS code for the basic templates with isMac conditionals... * fix: PR clean up * fix: more PR cleanup * A snapshot a day keeps the bugs away! 📷🐛 * fix: added the new help menu to the default sign in and modeling page * fix: disabled two menu actions within sign in page since they will not do anything. * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * fix: mergining main, auto fixes * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * fix: fixed ipc renderer off/remove listener bug * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * fix: report a bug to refresha and report a bug * fix: new type for webContents send payload that does not brick TS * fix: removing import file from url since it is not working in the command palette for manual user input * fix: removing old comment * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * chore: adding some E2E tests. * chore: added E2E tests for each file menu * fix: auto fixes * chore: adding more edit role E2E tests * chore: e2e test * chore: adding help role e2e test * A snapshot a day keeps the bugs away! 📷🐛 * chore: e2e test for all the menu options you can interact with in the frontend --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
125 lines
3.9 KiB
TypeScript
125 lines
3.9 KiB
TypeScript
import fs from 'node:fs/promises'
|
|
import fsSync from 'node:fs'
|
|
import path from 'path'
|
|
import { dialog, shell } from 'electron'
|
|
import { MachinesListing } from 'components/MachineManagerProvider'
|
|
import type { Channel } from 'src/menu/channels'
|
|
import { Menu, WebContents } from 'electron'
|
|
import { ZooLabel, ZooMenuEvents } from 'menu/roles'
|
|
import type { MenuActionIPC } from 'menu/rules'
|
|
import type { WebContentSendPayload } from 'menu/channels'
|
|
|
|
// Extend the interface with additional custom properties
|
|
declare module 'electron' {
|
|
interface Menu {
|
|
label?: ZooLabel
|
|
}
|
|
}
|
|
|
|
type EnvFn = (value?: string) => string
|
|
|
|
export interface IElectronAPI {
|
|
resizeWindow: (width: number, height: number) => Promise<void>
|
|
open: typeof dialog.showOpenDialog
|
|
save: typeof dialog.showSaveDialog
|
|
openExternal: typeof shell.openExternal
|
|
takeElectronWindowScreenshot: ({
|
|
width,
|
|
height,
|
|
}: {
|
|
width: number
|
|
height: number
|
|
}) => Promise<string>
|
|
showInFolder: typeof shell.showItemInFolder
|
|
/** Require to be called first before {@link loginWithDeviceFlow} */
|
|
startDeviceFlow: (host: string) => Promise<string>
|
|
/** Registered by first calling {@link startDeviceFlow}, which sets up the device flow handle */
|
|
loginWithDeviceFlow: () => Promise<string>
|
|
platform: typeof process.env.platform
|
|
arch: typeof process.env.arch
|
|
version: typeof process.env.version
|
|
watchFileOn: (
|
|
path: string,
|
|
key: string,
|
|
callback: (eventType: string, path: string) => void
|
|
) => void
|
|
readFile: typeof fs.readFile
|
|
copyFile: typeof fs.copyFile
|
|
watchFileOff: (path: string, key: string) => void
|
|
writeFile: (
|
|
path: string,
|
|
data: string | Uint8Array
|
|
) => ReturnType<fs.writeFile>
|
|
readdir: (path: string) => ReturnType<fs.readdir>
|
|
exists: (path: string) => ReturnType<fs.exists>
|
|
getPath: (name: string) => Promise<string>
|
|
rm: typeof fs.rm
|
|
stat: (path: string) => ReturnType<fs.stat>
|
|
statIsDirectory: (path: string) => Promise<boolean>
|
|
canReadWriteDirectory: (
|
|
path: string
|
|
) => Promise<{ value: boolean; error: unknown }>
|
|
path: typeof path
|
|
mkdir: typeof fs.mkdir
|
|
join: typeof path.join
|
|
sep: typeof path.sep
|
|
rename: (prev: string, next: string) => typeof fs.rename
|
|
packageJson: {
|
|
name: string
|
|
}
|
|
os: {
|
|
isMac: boolean
|
|
isWindows: boolean
|
|
isLinux: boolean
|
|
}
|
|
process: {
|
|
env: {
|
|
BASE_URL: string
|
|
TEST_SETTINGS_FILE_KEY: string
|
|
IS_PLAYWRIGHT: string
|
|
VITE_KC_DEV_TOKEN: string
|
|
VITE_KC_API_WS_MODELING_URL: string
|
|
VITE_KC_API_BASE_URL: string
|
|
VITE_KC_SITE_BASE_URL: string
|
|
VITE_KC_SITE_APP_URL: string
|
|
VITE_KC_SKIP_AUTH: string
|
|
VITE_KC_CONNECTION_TIMEOUT_MS: string
|
|
VITE_KC_DEV_TOKEN: string
|
|
NODE_ENV: string
|
|
PROD: string
|
|
DEV: string
|
|
TEST: string
|
|
CI: string
|
|
}
|
|
}
|
|
kittycad: (access: string, args: any) => any
|
|
listMachines: (machineApiIp: string) => Promise<MachinesListing>
|
|
getMachineApiIp: () => Promise<string | null>
|
|
onUpdateDownloadStart: (
|
|
callback: (value: { version: string }) => void
|
|
) => Electron.IpcRenderer
|
|
onUpdateDownloaded: (
|
|
callback: (value: { version: string; releaseNotes: string }) => void
|
|
) => Electron.IpcRenderer
|
|
onUpdateError: (callback: (value: { error: Error }) => void) => Electron
|
|
appRestart: () => void
|
|
appCheckForUpdates: () => Promise<unknown>
|
|
getArgvParsed: () => any
|
|
getAppTestProperty: (propertyName: string) => any
|
|
|
|
// Helper functions to create application Menus
|
|
createHomePageMenu: () => Promise<any>
|
|
createModelingPageMenu: () => Promise<any>
|
|
createFallbackMenu: () => Promise<any>
|
|
enableMenu(menuId: string): Promise<any>
|
|
disableMenu(menuId: string): Promise<any>
|
|
menuOn: (callback: (payload: WebContentSendPayload) => void) => any
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
electron: IElectronAPI
|
|
openExternalLink: (e: React.MouseEvent<HTMLAnchorElement>) => void
|
|
}
|
|
}
|