forked from intel/AI-Playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix most eslint error (and ignore some others 🙈)
Signed-off-by: Markus Schuettler <[email protected]>
- Loading branch information
1 parent
1097cda
commit 4f7572d
Showing
50 changed files
with
2,500 additions
and
1,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,78 @@ | ||
/// <reference types="vite-plugin-electron/electron-env" /> | ||
|
||
declare namespace NodeJS { | ||
interface ProcessEnv { | ||
/** | ||
* The built directory structure | ||
* | ||
* ```tree | ||
* ├─┬─┬ dist | ||
* │ │ └── index.html | ||
* │ │ | ||
* │ ├─┬ dist-electron | ||
* │ │ ├── main.js | ||
* │ │ └── preload.js | ||
* │ | ||
* ``` | ||
*/ | ||
DIST: string; | ||
/** /dist/ or /public/ */ | ||
VITE_PUBLIC: string; | ||
} | ||
} | ||
|
||
// Used in Renderer process, expose in `preload.ts` | ||
interface Window { | ||
ipcRenderer: import("electron").IpcRenderer; | ||
} | ||
|
||
type KVObject = { | ||
[key: string]: any; | ||
}; | ||
|
||
type Theme = 'dark' | 'lnl' | 'bmg'; | ||
|
||
type LocalSettings = { | ||
debug: number; | ||
comfyUiParameters?:string[]; | ||
} & KVObject; | ||
|
||
type ThemeSettings = { | ||
availableThemes: Theme[]; | ||
currentTheme: Theme; | ||
} | ||
|
||
type ModelPaths = { | ||
llm: string, | ||
embedding: string, | ||
stableDiffusion: string, | ||
inpaint: string, | ||
lora: string, | ||
vae: string, | ||
} & StringKV | ||
|
||
type ModelLists = { | ||
llm: string[], | ||
stableDiffusion: string[], | ||
lora: string[], | ||
vae: string[], | ||
scheduler: string[], | ||
embedding: string[], | ||
inpaint: string[] | ||
} & { [key: string]: Array<string> } | ||
|
||
type SetupData = { | ||
modelPaths: ModelPaths, | ||
modelLists: ModelLists, | ||
isAdminExec:boolean, | ||
version:string, | ||
} | ||
|
||
type UpdateWorkflowsFromIntelResult = { | ||
success: boolean | ||
backupDir: string | ||
} | ||
|
||
type BackendStatus = 'notYetStarted' | 'starting' | 'running' | 'stopped' | 'stopping' | 'failed' | 'notInstalled' | 'installationFailed' | 'installing' | 'uninitializedStatus' | ||
|
||
/// <reference types="vite-plugin-electron/electron-env" /> | ||
|
||
declare namespace NodeJS { | ||
interface ProcessEnv { | ||
/** | ||
* The built directory structure | ||
* | ||
* ```tree | ||
* ├─┬─┬ dist | ||
* │ │ └── index.html | ||
* │ │ | ||
* │ ├─┬ dist-electron | ||
* │ │ ├── main.js | ||
* │ │ └── preload.js | ||
* │ | ||
* ``` | ||
*/ | ||
DIST: string; | ||
/** /dist/ or /public/ */ | ||
VITE_PUBLIC: string; | ||
} | ||
} | ||
|
||
// Used in Renderer process, expose in `preload.ts` | ||
interface Window { | ||
ipcRenderer: import("electron").IpcRenderer; | ||
} | ||
|
||
type KVObject = { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
[key: string]: any; | ||
}; | ||
|
||
type Theme = 'dark' | 'lnl' | 'bmg'; | ||
|
||
type LocalSettings = { | ||
debug: number; | ||
comfyUiParameters?:string[]; | ||
} & KVObject; | ||
|
||
type ThemeSettings = { | ||
availableThemes: Theme[]; | ||
currentTheme: Theme; | ||
} | ||
|
||
type ModelPaths = { | ||
llm: string, | ||
embedding: string, | ||
stableDiffusion: string, | ||
inpaint: string, | ||
lora: string, | ||
vae: string, | ||
} & StringKV | ||
|
||
type ModelLists = { | ||
llm: string[], | ||
stableDiffusion: string[], | ||
lora: string[], | ||
vae: string[], | ||
scheduler: string[], | ||
embedding: string[], | ||
inpaint: string[] | ||
} & { [key: string]: Array<string> } | ||
|
||
type SetupData = { | ||
modelPaths: ModelPaths, | ||
modelLists: ModelLists, | ||
isAdminExec:boolean, | ||
version:string, | ||
} | ||
|
||
type UpdateWorkflowsFromIntelResult = { | ||
success: boolean | ||
backupDir: string | ||
} | ||
|
||
type BackendStatus = 'notYetStarted' | 'starting' | 'running' | 'stopped' | 'stopping' | 'failed' | 'notInstalled' | 'installationFailed' | 'installing' | 'uninitializedStatus' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,97 @@ | ||
import WebContents = Electron.WebContents; | ||
import fs from "fs"; | ||
import path from "node:path"; | ||
import {app} from "electron"; | ||
|
||
|
||
class Logger { | ||
webContents: WebContents | null = null | ||
private pathToLogFiles: string = path.resolve(app.isPackaged ? process.resourcesPath : path.join(__dirname, "../../external/")); | ||
private startupMessageCache: { | ||
message: string, | ||
source: string, | ||
level: 'error' | 'warn' | 'info' | ||
}[] = [] | ||
|
||
constructor() { | ||
} | ||
|
||
onWebcontentReady(webContents: WebContents) { | ||
this.webContents = webContents | ||
this.startupMessageCache.forEach((logEntry) => { | ||
this.webContents!.send('debugLog', logEntry) | ||
}); | ||
this.startupMessageCache = [] | ||
} | ||
|
||
info(message: string, source: string, alsoLogToFile: boolean = false) { | ||
if (alsoLogToFile) { | ||
this.logMessageToFile(message, source) | ||
} | ||
console.info(`[${source}]: ${message}`); | ||
if (this.webContents) { | ||
try { | ||
this.webContents.send('debugLog', {level: 'info', source, message}) | ||
} catch (error) { | ||
console.error('Could not send debug log to renderer process'); | ||
} | ||
} else { | ||
this.startupMessageCache.push({level: 'info', source, message}) | ||
} | ||
} | ||
|
||
warn(message: string, source: string, alsoLogToFile: boolean = false) { | ||
if (alsoLogToFile) { | ||
this.logMessageToFile(message, source) | ||
} | ||
console.warn(`[${source}]: ${message}`); | ||
if (this.webContents) { | ||
try { | ||
this.webContents.send('debugLog', {level: 'warn', source, message}) | ||
} catch (error) { | ||
console.error('Could not send debug log to renderer process'); | ||
} | ||
} else { | ||
this.startupMessageCache.push({level: 'error', source, message}) | ||
} | ||
} | ||
|
||
error(message: string, source: string, alsoLogToFile: boolean = false) { | ||
if (alsoLogToFile) { | ||
this.logMessageToFile(message, source) | ||
} | ||
|
||
console.error(`[${source}]: ${message}`); | ||
|
||
if (this.webContents) { | ||
try { | ||
this.webContents.send('debugLog', {level: 'error', source, message}) | ||
} catch (error) { | ||
console.error('Could not send debug log to renderer process'); | ||
} | ||
} else { | ||
this.startupMessageCache.push({level: 'error', source, message}) | ||
} | ||
} | ||
|
||
|
||
logMessageToFile(message: string, source: string) { | ||
const fileName = `${this.getDebugFileName()}.log` | ||
const currentDate = new Date(); | ||
const hours = currentDate.getHours().toString().padStart(2, '0'); | ||
const minutes = currentDate.getMinutes().toString().padStart(2, '0'); | ||
const seconds = currentDate.getSeconds().toString().padStart(2, '0'); | ||
|
||
const formattedTime = `${hours}:${minutes}:${seconds}`; | ||
const logMessage = `${formattedTime}|${source}|${message}` | ||
fs.appendFileSync(path.join(this.pathToLogFiles, fileName), logMessage + "\r\n"); | ||
} | ||
|
||
getDebugFileName(): string { | ||
const currentDate = new Date(); | ||
const formattedDate = currentDate.toISOString().split('T')[0]; | ||
return `aip-${formattedDate}` | ||
} | ||
} | ||
|
||
export const appLoggerInstance = new Logger() | ||
import WebContents = Electron.WebContents; | ||
import fs from "fs"; | ||
import path from "node:path"; | ||
import {app} from "electron"; | ||
|
||
|
||
class Logger { | ||
webContents: WebContents | null = null | ||
private pathToLogFiles: string = path.resolve(app.isPackaged ? process.resourcesPath : path.join(__dirname, "../../external/")); | ||
private startupMessageCache: { | ||
message: string, | ||
source: string, | ||
level: 'error' | 'warn' | 'info' | ||
}[] = [] | ||
|
||
constructor() { | ||
} | ||
|
||
onWebcontentReady(webContents: WebContents) { | ||
this.webContents = webContents | ||
this.startupMessageCache.forEach((logEntry) => { | ||
this.webContents!.send('debugLog', logEntry) | ||
}); | ||
this.startupMessageCache = [] | ||
} | ||
|
||
info(message: string, source: string, alsoLogToFile: boolean = false) { | ||
if (alsoLogToFile) { | ||
this.logMessageToFile(message, source) | ||
} | ||
console.info(`[${source}]: ${message}`); | ||
if (this.webContents) { | ||
try { | ||
this.webContents.send('debugLog', {level: 'info', source, message}) | ||
} catch (_error) { | ||
console.error('Could not send debug log to renderer process'); | ||
} | ||
} else { | ||
this.startupMessageCache.push({level: 'info', source, message}) | ||
} | ||
} | ||
|
||
warn(message: string, source: string, alsoLogToFile: boolean = false) { | ||
if (alsoLogToFile) { | ||
this.logMessageToFile(message, source) | ||
} | ||
console.warn(`[${source}]: ${message}`); | ||
if (this.webContents) { | ||
try { | ||
this.webContents.send('debugLog', {level: 'warn', source, message}) | ||
} catch (_error) { | ||
console.error('Could not send debug log to renderer process'); | ||
} | ||
} else { | ||
this.startupMessageCache.push({level: 'error', source, message}) | ||
} | ||
} | ||
|
||
error(message: string, source: string, alsoLogToFile: boolean = false) { | ||
if (alsoLogToFile) { | ||
this.logMessageToFile(message, source) | ||
} | ||
|
||
console.error(`[${source}]: ${message}`); | ||
|
||
if (this.webContents) { | ||
try { | ||
this.webContents.send('debugLog', {level: 'error', source, message}) | ||
} catch (_error) { | ||
console.error('Could not send debug log to renderer process'); | ||
} | ||
} else { | ||
this.startupMessageCache.push({level: 'error', source, message}) | ||
} | ||
} | ||
|
||
|
||
logMessageToFile(message: string, source: string) { | ||
const fileName = `${this.getDebugFileName()}.log` | ||
const currentDate = new Date(); | ||
const hours = currentDate.getHours().toString().padStart(2, '0'); | ||
const minutes = currentDate.getMinutes().toString().padStart(2, '0'); | ||
const seconds = currentDate.getSeconds().toString().padStart(2, '0'); | ||
|
||
const formattedTime = `${hours}:${minutes}:${seconds}`; | ||
const logMessage = `${formattedTime}|${source}|${message}` | ||
fs.appendFileSync(path.join(this.pathToLogFiles, fileName), logMessage + "\r\n"); | ||
} | ||
|
||
getDebugFileName(): string { | ||
const currentDate = new Date(); | ||
const formattedDate = currentDate.toISOString().split('T')[0]; | ||
return `aip-${formattedDate}` | ||
} | ||
} | ||
|
||
export const appLoggerInstance = new Logger() |
Oops, something went wrong.