Skip to content

Commit

Permalink
feat: add electron/utility module for utility process
Browse files Browse the repository at this point in the history
  • Loading branch information
devm33 committed Oct 10, 2023
1 parent 4349439 commit 1983724
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions base/base_footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ declare module 'electron/renderer' {
export = Electron.Renderer;
}

declare module 'electron/utility' {
export = Electron.Utility;
}

interface NodeRequireFunction {
(moduleName: 'electron'): typeof Electron.CrossProcessExports;
(moduleName: 'electron/main'): typeof Electron.Main;
(moduleName: 'electron/common'): typeof Electron.Common;
(moduleName: 'electron/renderer'): typeof Electron.Renderer;
(moduleName: 'electron/utility'): typeof Electron.Utility;
}

interface NodeRequire {
(moduleName: 'electron'): typeof Electron.CrossProcessExports;
(moduleName: 'electron/main'): typeof Electron.Main;
(moduleName: 'electron/common'): typeof Electron.Common;
(moduleName: 'electron/renderer'): typeof Electron.Renderer;
(moduleName: 'electron/utility'): typeof Electron.Utility;
}

interface File {
Expand Down
12 changes: 9 additions & 3 deletions src/primary-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const generatePrimaryInterfaces = (
const CommonNamespace = ['namespace Common {', eventExport];
const MainNamespace = ['namespace Main {', eventExport];
const RendererNamespace = ['namespace Renderer {', eventExport];
const UtilityNamespace = ['namespace Utility {', eventExport];
const MainInterfaceForRemote = ['interface RemoteMainInterface {'];
const CrossProcessExportsNamespace = ['namespace CrossProcessExports {', eventExport];
const constDeclarations: string[] = [];
Expand Down Expand Up @@ -102,16 +103,18 @@ export const generatePrimaryInterfaces = (
}
if (TargetNamespace) {
debug(classify(module.name).toLowerCase(), EMRI[classify(module.name).toLowerCase()]);
if (!EMRI[classify(module.name).toLowerCase()]) {
if (moduleString) TargetNamespace.push(moduleString);
if (moduleString) CrossProcessExportsNamespace.push(moduleString);
if (!EMRI[classify(module.name).toLowerCase()] && moduleString) {
TargetNamespace.push(moduleString);
CrossProcessExportsNamespace.push(moduleString);
if (module.process.utility) UtilityNamespace.push(moduleString);
}
EMRI[classify(module.name).toLowerCase()] = true;
const declarations = [...newConstDeclarations, ...newTypeAliases].map(
s => ` ${s.substr(0, s.length - 1)}`,
);
TargetNamespace.push(...declarations);
CrossProcessExportsNamespace.push(...declarations);
if (module.process.utility) UtilityNamespace.push(...declarations);
}
});

Expand All @@ -122,12 +125,14 @@ export const generatePrimaryInterfaces = (
CommonNamespace.push(alias);
MainNamespace.push(alias);
RendererNamespace.push(alias);
UtilityNamespace.push(alias);
CrossProcessExportsNamespace.push(alias);
}

CommonNamespace.push('}');
MainNamespace.push('}');
RendererNamespace.push('}');
UtilityNamespace.push('}');
CrossProcessExportsNamespace.push('}');

const withSemicolons = (lines: string[]) => {
Expand All @@ -137,6 +142,7 @@ export const generatePrimaryInterfaces = (
addToOutput(withSemicolons(CommonNamespace));
addToOutput(withSemicolons(MainNamespace));
addToOutput(withSemicolons(RendererNamespace));
addToOutput(withSemicolons(UtilityNamespace));
addToOutput(withSemicolons(CrossProcessExportsNamespace));
addToOutput(constDeclarations);
};

0 comments on commit 1983724

Please sign in to comment.