Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: medlouraoui <med.louraoui@gmail.com>
- Loading branch information
1 parent
cc90c1d
commit 04d0555
Showing
113 changed files
with
4,708 additions
and
3,147 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
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const ts = require("typescript"); | ||
|
||
/** @type {Map<string, ts.SourceFile>} */ | ||
const sourceFileCache = new Map(); | ||
|
||
/** | ||
* @param {string} filePath | ||
*/ | ||
module.exports.getDeclaredTypesNames = function (filePath) { | ||
const sourceFile = | ||
sourceFileCache.get(filePath) ?? | ||
ts.createProgram([filePath], { noEmit: true }).getSourceFile(filePath); | ||
|
||
sourceFileCache.set(filePath, sourceFile); | ||
|
||
const out = []; | ||
ts.forEachChild(sourceFile, (node) => { | ||
if ( | ||
ts.isInterfaceDeclaration(node) || | ||
ts.isTypeAliasDeclaration(node) | ||
) { | ||
if (ts.SyntaxKind.DeclareKeyword === node.modifiers?.[0].kind) { | ||
out.push(node.name.getText(sourceFile)); | ||
} | ||
} | ||
}); | ||
|
||
return out; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
enabled: false |
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,30 +1,88 @@ | ||
import { app, ipcMain, ipcRenderer } from "electron"; | ||
import path from "path"; | ||
import { isMainThread, workerData } from "worker_threads"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
export const IS_MAIN = (ipcMain && !ipcRenderer) as boolean; | ||
export const IS_TEST = !!process.env.NODE_ENV?.startsWith("test"); | ||
export const IS_DEV = process.env.NODE_ENV !== "production" && !IS_TEST; | ||
export const IS_E2E = !!process.env.E2E; | ||
export const IS_MAC = process.platform === "darwin"; | ||
import { name } from "./utils/package"; | ||
|
||
export const IS_WORKER = !isMainThread; | ||
export const WORKER_CONFIG_TOKEN = "__config" as const; | ||
|
||
// electron is not available in Worker side so we fake it. | ||
const { app, ipcMain, ipcRenderer } = IS_WORKER | ||
? // eslint-disable-next-line @typescript-eslint/consistent-type-imports -- deal with it | ||
({} as typeof import("electron")) | ||
: // eslint-disable-next-line @typescript-eslint/no-require-imports -- yep, sad uh? | ||
require("electron"); | ||
|
||
export interface WorkerConfig { | ||
APP_CACHE: string; | ||
IS_DEV: boolean; | ||
IS_DIST_MODE: boolean; | ||
IS_E2E: boolean; | ||
IS_MAC: boolean; | ||
IS_MAIN: boolean; | ||
IS_PACKAGED: boolean; | ||
IS_TEST: boolean; | ||
STATIC_PATH: string; | ||
} | ||
|
||
const localWorkerConfig: Partial<WorkerConfig> = IS_WORKER | ||
? workerData[WORKER_CONFIG_TOKEN] | ||
: {}; | ||
|
||
export const IS_MAIN = | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
localWorkerConfig.IS_MAIN ?? ((ipcMain && !ipcRenderer) as boolean); | ||
export const IS_TEST = | ||
localWorkerConfig.IS_TEST ?? !!process.env.NODE_ENV?.startsWith("test"); | ||
export const IS_DEV = | ||
localWorkerConfig.IS_DEV ?? | ||
(process.env.NODE_ENV !== "production" && !IS_TEST); | ||
export const IS_E2E = localWorkerConfig.IS_E2E ?? !!process.env.E2E; | ||
export const IS_MAC = localWorkerConfig.IS_MAC ?? process.platform === "darwin"; | ||
const IS_PACKAGE_EVENT = "config.IS_PACKAGED"; | ||
if (IS_MAIN) { | ||
const APP_CACHE_EVENT = "config.APP_CACHE"; | ||
if (IS_MAIN && !IS_WORKER) { | ||
ipcMain.on(IS_PACKAGE_EVENT, (event) => { | ||
event.returnValue = app.isPackaged; | ||
}); | ||
ipcMain.on(APP_CACHE_EVENT, (event) => { | ||
event.returnValue = app.getPath("cache"); | ||
}); | ||
} | ||
|
||
export const IS_PACKAGED = (): boolean => { | ||
if (IS_WORKER) return localWorkerConfig.IS_PACKAGED!; | ||
if (IS_MAIN) { | ||
return app.isPackaged; | ||
} else return ipcRenderer.sendSync(IS_PACKAGE_EVENT, []) as boolean; | ||
} else return ipcRenderer.sendSync(IS_PACKAGE_EVENT) as boolean; | ||
}; | ||
|
||
export const APP_CACHE = (): string => { | ||
if (IS_WORKER) return localWorkerConfig.APP_CACHE!; | ||
if (IS_MAIN) { | ||
return path.resolve(app.getPath("cache"), name); | ||
} else return ipcRenderer.sendSync(APP_CACHE_EVENT) as string; | ||
}; | ||
|
||
export const IS_DIST_MODE = | ||
!IS_PACKAGED() && !process.env.ELECTRON_WEBPACK_WDS_PORT; | ||
localWorkerConfig.IS_DIST_MODE ?? | ||
(!IS_PACKAGED() && !process.env.ELECTRON_WEBPACK_WDS_PORT); | ||
|
||
export const STATIC_PATH = | ||
localWorkerConfig.STATIC_PATH ?? IS_PACKAGED() | ||
? __static // prod | ||
: !process.env.ELECTRON_WEBPACK_WDS_PORT | ||
? path.resolve(__dirname, "../../static") // dist / e2e | ||
: __static; // dev | ||
|
||
export const STATIC_PATH = IS_PACKAGED() | ||
? __static // prod | ||
: !process.env.ELECTRON_WEBPACK_WDS_PORT | ||
? path.resolve(__dirname, "../../static") // dist / e2e | ||
: __static; // dev | ||
export const workerConfig: WorkerConfig = { | ||
APP_CACHE: APP_CACHE(), | ||
IS_DEV, | ||
IS_DIST_MODE, | ||
IS_E2E, | ||
IS_MAC, | ||
IS_MAIN, | ||
IS_PACKAGED: IS_PACKAGED(), | ||
IS_TEST, | ||
STATIC_PATH, | ||
}; |
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,7 +1 @@ | ||
export const PST_EXTRACT_EVENT = "pstExtractor.event.extract"; | ||
export const PST_PROGRESS_EVENT = "pstExtractor.event.progress"; | ||
export const PST_PROGRESS_SUBSCRIBE_EVENT = | ||
"pstExtractor.event.progressSuscribe"; | ||
export const PST_STOP_EXTRACT_EVENT = "pstExtractor.event.stopExtract"; | ||
|
||
export const CONSOLE_LOG_EVENT = "archifiltre-mails-console.event.log"; |
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
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
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
Oops, something went wrong.