@devisfuture/electron-modular 1.1.8 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/@core/__tests__/container.test.d.ts +1 -0
- package/dist/@core/__tests__/container.test.js +409 -0
- package/dist/@core/bootstrap/__tests__/bootstrap.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/bootstrap.test.js +131 -0
- package/dist/@core/bootstrap/__tests__/initialize-module.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/initialize-module.test.js +140 -0
- package/dist/@core/bootstrap/__tests__/instantiate-module.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/instantiate-module.test.js +174 -0
- package/dist/@core/bootstrap/__tests__/register-imports.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/register-imports.test.js +112 -0
- package/dist/@core/bootstrap/__tests__/register-ipc-handlers.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/register-ipc-handlers.test.js +68 -0
- package/dist/@core/bootstrap/__tests__/register-providers.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/register-providers.test.js +132 -0
- package/dist/@core/bootstrap/__tests__/register-windows.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/register-windows.test.js +109 -0
- package/dist/@core/bootstrap/__tests__/settings.test.d.ts +1 -0
- package/dist/@core/bootstrap/__tests__/settings.test.js +141 -0
- package/dist/@core/control-window/__tests__/cache.test.d.ts +1 -0
- package/dist/@core/control-window/__tests__/cache.test.js +50 -0
- package/dist/@core/control-window/__tests__/destroy.test.d.ts +1 -0
- package/dist/@core/control-window/__tests__/destroy.test.js +69 -0
- package/dist/@core/control-window/__tests__/receive.test.d.ts +1 -0
- package/dist/@core/control-window/__tests__/receive.test.js +68 -0
- package/dist/@core/decorators/__tests__/inject.test.d.ts +1 -0
- package/dist/@core/decorators/__tests__/inject.test.js +174 -0
- package/dist/@core/decorators/__tests__/injectable.test.d.ts +1 -0
- package/dist/@core/decorators/__tests__/injectable.test.js +73 -0
- package/dist/@core/decorators/__tests__/ipc-handler.test.d.ts +1 -0
- package/dist/@core/decorators/__tests__/ipc-handler.test.js +72 -0
- package/dist/@core/decorators/__tests__/rg-module.test.d.ts +1 -0
- package/dist/@core/decorators/__tests__/rg-module.test.js +135 -0
- package/dist/@core/decorators/__tests__/window-manager.test.d.ts +1 -0
- package/dist/@core/decorators/__tests__/window-manager.test.js +110 -0
- package/dist/@core/errors/__tests__/index.test.d.ts +1 -0
- package/dist/@core/errors/__tests__/index.test.js +82 -0
- package/dist/@core/utils/__tests__/dependency-tokens.test.d.ts +1 -0
- package/dist/@core/utils/__tests__/dependency-tokens.test.js +186 -0
- package/dist/__mocks__/electron.d.ts +88 -0
- package/dist/__mocks__/electron.js +76 -0
- package/dist/__tests__/config.test.d.ts +1 -0
- package/dist/__tests__/config.test.js +24 -0
- package/dist/__tests__/setup.d.ts +1 -0
- package/dist/__tests__/setup.js +9 -0
- package/package.json +6 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export declare const mockApp: {
|
|
2
|
+
getPath: import("vitest").Mock<(name: string) => string>;
|
|
3
|
+
getVersion: import("vitest").Mock<() => string>;
|
|
4
|
+
getName: import("vitest").Mock<() => string>;
|
|
5
|
+
quit: import("vitest").Mock<(...args: any[]) => any>;
|
|
6
|
+
exit: import("vitest").Mock<(...args: any[]) => any>;
|
|
7
|
+
on: import("vitest").Mock<(...args: any[]) => any>;
|
|
8
|
+
once: import("vitest").Mock<(...args: any[]) => any>;
|
|
9
|
+
removeListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
10
|
+
whenReady: import("vitest").Mock<() => Promise<void>>;
|
|
11
|
+
isReady: import("vitest").Mock<() => boolean>;
|
|
12
|
+
getAppPath: import("vitest").Mock<() => string>;
|
|
13
|
+
};
|
|
14
|
+
export declare const mockBrowserWindow: import("vitest").Mock<(...args: any[]) => any>;
|
|
15
|
+
export declare const mockIpcMain: {
|
|
16
|
+
on: import("vitest").Mock<(...args: any[]) => any>;
|
|
17
|
+
once: import("vitest").Mock<(...args: any[]) => any>;
|
|
18
|
+
handle: import("vitest").Mock<(...args: any[]) => any>;
|
|
19
|
+
removeHandler: import("vitest").Mock<(...args: any[]) => any>;
|
|
20
|
+
removeListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
21
|
+
removeAllListeners: import("vitest").Mock<(...args: any[]) => any>;
|
|
22
|
+
};
|
|
23
|
+
export declare const mockDialog: {
|
|
24
|
+
showOpenDialog: import("vitest").Mock<() => Promise<{
|
|
25
|
+
canceled: boolean;
|
|
26
|
+
filePaths: string[];
|
|
27
|
+
}>>;
|
|
28
|
+
showSaveDialog: import("vitest").Mock<() => Promise<{
|
|
29
|
+
canceled: boolean;
|
|
30
|
+
filePath: string;
|
|
31
|
+
}>>;
|
|
32
|
+
showMessageBox: import("vitest").Mock<() => Promise<{
|
|
33
|
+
response: number;
|
|
34
|
+
}>>;
|
|
35
|
+
showErrorBox: import("vitest").Mock<(...args: any[]) => any>;
|
|
36
|
+
};
|
|
37
|
+
export declare const mockSession: {
|
|
38
|
+
defaultSession: {
|
|
39
|
+
webRequest: {
|
|
40
|
+
onHeadersReceived: import("vitest").Mock<(...args: any[]) => any>;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const mockElectron: {
|
|
45
|
+
app: {
|
|
46
|
+
getPath: import("vitest").Mock<(name: string) => string>;
|
|
47
|
+
getVersion: import("vitest").Mock<() => string>;
|
|
48
|
+
getName: import("vitest").Mock<() => string>;
|
|
49
|
+
quit: import("vitest").Mock<(...args: any[]) => any>;
|
|
50
|
+
exit: import("vitest").Mock<(...args: any[]) => any>;
|
|
51
|
+
on: import("vitest").Mock<(...args: any[]) => any>;
|
|
52
|
+
once: import("vitest").Mock<(...args: any[]) => any>;
|
|
53
|
+
removeListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
54
|
+
whenReady: import("vitest").Mock<() => Promise<void>>;
|
|
55
|
+
isReady: import("vitest").Mock<() => boolean>;
|
|
56
|
+
getAppPath: import("vitest").Mock<() => string>;
|
|
57
|
+
};
|
|
58
|
+
BrowserWindow: import("vitest").Mock<(...args: any[]) => any>;
|
|
59
|
+
ipcMain: {
|
|
60
|
+
on: import("vitest").Mock<(...args: any[]) => any>;
|
|
61
|
+
once: import("vitest").Mock<(...args: any[]) => any>;
|
|
62
|
+
handle: import("vitest").Mock<(...args: any[]) => any>;
|
|
63
|
+
removeHandler: import("vitest").Mock<(...args: any[]) => any>;
|
|
64
|
+
removeListener: import("vitest").Mock<(...args: any[]) => any>;
|
|
65
|
+
removeAllListeners: import("vitest").Mock<(...args: any[]) => any>;
|
|
66
|
+
};
|
|
67
|
+
dialog: {
|
|
68
|
+
showOpenDialog: import("vitest").Mock<() => Promise<{
|
|
69
|
+
canceled: boolean;
|
|
70
|
+
filePaths: string[];
|
|
71
|
+
}>>;
|
|
72
|
+
showSaveDialog: import("vitest").Mock<() => Promise<{
|
|
73
|
+
canceled: boolean;
|
|
74
|
+
filePath: string;
|
|
75
|
+
}>>;
|
|
76
|
+
showMessageBox: import("vitest").Mock<() => Promise<{
|
|
77
|
+
response: number;
|
|
78
|
+
}>>;
|
|
79
|
+
showErrorBox: import("vitest").Mock<(...args: any[]) => any>;
|
|
80
|
+
};
|
|
81
|
+
session: {
|
|
82
|
+
defaultSession: {
|
|
83
|
+
webRequest: {
|
|
84
|
+
onHeadersReceived: import("vitest").Mock<(...args: any[]) => any>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { vi } from "vitest";
|
|
2
|
+
export const mockApp = {
|
|
3
|
+
getPath: vi.fn((name) => `/mock/path/${name}`),
|
|
4
|
+
getVersion: vi.fn(() => "1.0.0"),
|
|
5
|
+
getName: vi.fn(() => "MockApp"),
|
|
6
|
+
quit: vi.fn(),
|
|
7
|
+
exit: vi.fn(),
|
|
8
|
+
on: vi.fn(),
|
|
9
|
+
once: vi.fn(),
|
|
10
|
+
removeListener: vi.fn(),
|
|
11
|
+
whenReady: vi.fn(() => Promise.resolve()),
|
|
12
|
+
isReady: vi.fn(() => true),
|
|
13
|
+
getAppPath: vi.fn(() => "/mock/app"),
|
|
14
|
+
};
|
|
15
|
+
export const mockBrowserWindow = vi.fn().mockImplementation(() => ({
|
|
16
|
+
loadURL: vi.fn(() => Promise.resolve()),
|
|
17
|
+
loadFile: vi.fn(() => Promise.resolve()),
|
|
18
|
+
on: vi.fn(),
|
|
19
|
+
once: vi.fn(),
|
|
20
|
+
webContents: {
|
|
21
|
+
send: vi.fn(),
|
|
22
|
+
on: vi.fn(),
|
|
23
|
+
executeJavaScript: vi.fn(() => Promise.resolve()),
|
|
24
|
+
openDevTools: vi.fn(),
|
|
25
|
+
closeDevTools: vi.fn(),
|
|
26
|
+
},
|
|
27
|
+
show: vi.fn(),
|
|
28
|
+
hide: vi.fn(),
|
|
29
|
+
close: vi.fn(),
|
|
30
|
+
destroy: vi.fn(),
|
|
31
|
+
isDestroyed: vi.fn(() => false),
|
|
32
|
+
isFocused: vi.fn(() => true),
|
|
33
|
+
focus: vi.fn(),
|
|
34
|
+
id: 1,
|
|
35
|
+
}));
|
|
36
|
+
// Add static methods to mockBrowserWindow
|
|
37
|
+
Object.assign(mockBrowserWindow, {
|
|
38
|
+
getAllWindows: vi.fn(() => []),
|
|
39
|
+
});
|
|
40
|
+
export const mockIpcMain = {
|
|
41
|
+
on: vi.fn(),
|
|
42
|
+
once: vi.fn(),
|
|
43
|
+
handle: vi.fn(),
|
|
44
|
+
removeHandler: vi.fn(),
|
|
45
|
+
removeListener: vi.fn(),
|
|
46
|
+
removeAllListeners: vi.fn(),
|
|
47
|
+
};
|
|
48
|
+
export const mockDialog = {
|
|
49
|
+
showOpenDialog: vi.fn(() => Promise.resolve({
|
|
50
|
+
canceled: false,
|
|
51
|
+
filePaths: ["/mock/file.txt"],
|
|
52
|
+
})),
|
|
53
|
+
showSaveDialog: vi.fn(() => Promise.resolve({
|
|
54
|
+
canceled: false,
|
|
55
|
+
filePath: "/mock/save.txt",
|
|
56
|
+
})),
|
|
57
|
+
showMessageBox: vi.fn(() => Promise.resolve({
|
|
58
|
+
response: 0,
|
|
59
|
+
})),
|
|
60
|
+
showErrorBox: vi.fn(),
|
|
61
|
+
};
|
|
62
|
+
export const mockSession = {
|
|
63
|
+
defaultSession: {
|
|
64
|
+
webRequest: {
|
|
65
|
+
onHeadersReceived: vi.fn(),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export const mockElectron = {
|
|
70
|
+
app: mockApp,
|
|
71
|
+
BrowserWindow: mockBrowserWindow,
|
|
72
|
+
ipcMain: mockIpcMain,
|
|
73
|
+
dialog: mockDialog,
|
|
74
|
+
session: mockSession,
|
|
75
|
+
};
|
|
76
|
+
vi.mock("electron", () => mockElectron);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { folders } from "../config.js";
|
|
3
|
+
describe("config", () => {
|
|
4
|
+
describe("folders", () => {
|
|
5
|
+
it("should export distRenderer folder name", () => {
|
|
6
|
+
expect(folders.distRenderer).toBe("dist-renderer");
|
|
7
|
+
});
|
|
8
|
+
it("should export distMain folder name", () => {
|
|
9
|
+
expect(folders.distMain).toBe("dist-main");
|
|
10
|
+
});
|
|
11
|
+
it("should have both folder properties", () => {
|
|
12
|
+
expect(folders).toHaveProperty("distRenderer");
|
|
13
|
+
expect(folders).toHaveProperty("distMain");
|
|
14
|
+
});
|
|
15
|
+
it("should contain string values", () => {
|
|
16
|
+
expect(typeof folders.distRenderer).toBe("string");
|
|
17
|
+
expect(typeof folders.distMain).toBe("string");
|
|
18
|
+
});
|
|
19
|
+
it("should not be empty strings", () => {
|
|
20
|
+
expect(folders.distRenderer.length).toBeGreaterThan(0);
|
|
21
|
+
expect(folders.distMain.length).toBeGreaterThan(0);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "reflect-metadata/lite";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devisfuture/electron-modular",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "Core module system, DI container, IPC handlers, and window utilities for Electron main process.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,11 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsc -p tsconfig.json",
|
|
28
|
-
"test": "vitest run
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest",
|
|
30
|
+
"test:ui": "vitest --ui",
|
|
31
|
+
"test:coverage": "vitest run --coverage",
|
|
32
|
+
"test:ci": "vitest run --coverage --reporter=verbose --reporter=json",
|
|
29
33
|
"prepublishOnly": "npm run build"
|
|
30
34
|
},
|
|
31
35
|
"peerDependencies": {
|