@noxfly/noxus 3.0.0-dev.1 → 3.0.0-dev.3
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 -2
- package/dist/child.js +3 -0
- package/dist/child.mjs +3 -0
- package/dist/main.d.mts +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +23 -9
- package/dist/main.mjs +24 -10
- package/dist/renderer.js +3 -0
- package/dist/renderer.mjs +3 -0
- package/package.json +9 -1
- package/src/DI/app-injector.ts +10 -1
- package/src/internal/bootstrap.ts +1 -0
- package/src/window/window-manager.ts +25 -12
package/README.md
CHANGED
|
@@ -451,9 +451,9 @@ class UserRepository {
|
|
|
451
451
|
|
|
452
452
|
```ts
|
|
453
453
|
// preload.ts
|
|
454
|
-
import {
|
|
454
|
+
import { exposeNoxusBridge } from '@noxfly/noxus/renderer';
|
|
455
455
|
|
|
456
|
-
|
|
456
|
+
exposeNoxusBridge(); // exposes window.__noxus__ to the renderer
|
|
457
457
|
```
|
|
458
458
|
|
|
459
459
|
### IPC client
|
package/dist/child.js
CHANGED
|
@@ -129,6 +129,9 @@ var init_app_injector = __esm({
|
|
|
129
129
|
return this._resolveForwardRef(target);
|
|
130
130
|
}
|
|
131
131
|
const k = keyOf(target);
|
|
132
|
+
if (this.singletons.has(k)) {
|
|
133
|
+
return this.singletons.get(k);
|
|
134
|
+
}
|
|
132
135
|
const binding = this.bindings.get(k);
|
|
133
136
|
if (!binding) {
|
|
134
137
|
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
package/dist/child.mjs
CHANGED
|
@@ -118,6 +118,9 @@ var init_app_injector = __esm({
|
|
|
118
118
|
return this._resolveForwardRef(target);
|
|
119
119
|
}
|
|
120
120
|
const k = keyOf(target);
|
|
121
|
+
if (this.singletons.has(k)) {
|
|
122
|
+
return this.singletons.get(k);
|
|
123
|
+
}
|
|
121
124
|
const binding = this.bindings.get(k);
|
|
122
125
|
if (!binding) {
|
|
123
126
|
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
package/dist/main.d.mts
CHANGED
|
@@ -347,6 +347,7 @@ declare class WindowManager {
|
|
|
347
347
|
*/
|
|
348
348
|
createSplash(options?: Electron.BrowserWindowConstructorOptions & {
|
|
349
349
|
animationDuration?: number;
|
|
350
|
+
expandToWorkArea?: boolean;
|
|
350
351
|
}): Promise<BrowserWindow>;
|
|
351
352
|
/** Returns all currently open windows. */
|
|
352
353
|
getAll(): BrowserWindow[];
|
package/dist/main.d.ts
CHANGED
|
@@ -347,6 +347,7 @@ declare class WindowManager {
|
|
|
347
347
|
*/
|
|
348
348
|
createSplash(options?: Electron.BrowserWindowConstructorOptions & {
|
|
349
349
|
animationDuration?: number;
|
|
350
|
+
expandToWorkArea?: boolean;
|
|
350
351
|
}): Promise<BrowserWindow>;
|
|
351
352
|
/** Returns all currently open windows. */
|
|
352
353
|
getAll(): BrowserWindow[];
|
package/dist/main.js
CHANGED
|
@@ -133,6 +133,9 @@ var init_app_injector = __esm({
|
|
|
133
133
|
return this._resolveForwardRef(target);
|
|
134
134
|
}
|
|
135
135
|
const k = keyOf(target);
|
|
136
|
+
if (this.singletons.has(k)) {
|
|
137
|
+
return this.singletons.get(k);
|
|
138
|
+
}
|
|
136
139
|
const binding = this.bindings.get(k);
|
|
137
140
|
if (!binding) {
|
|
138
141
|
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
|
@@ -1425,18 +1428,24 @@ var WindowManager = class {
|
|
|
1425
1428
|
* win.loadFile('index.html');
|
|
1426
1429
|
*/
|
|
1427
1430
|
async createSplash(options = {}) {
|
|
1428
|
-
const {
|
|
1431
|
+
const {
|
|
1432
|
+
animationDuration = 10,
|
|
1433
|
+
expandToWorkArea = true,
|
|
1434
|
+
...bwOptions
|
|
1435
|
+
} = options;
|
|
1429
1436
|
const win = new import_main.BrowserWindow({
|
|
1430
1437
|
width: 600,
|
|
1431
1438
|
height: 600,
|
|
1432
1439
|
center: true,
|
|
1433
|
-
frame: false,
|
|
1434
1440
|
show: true,
|
|
1435
1441
|
...bwOptions
|
|
1436
1442
|
});
|
|
1437
1443
|
this._register(win, true);
|
|
1438
1444
|
Logger.log(`[WindowManager] Splash window #${win.id} created`);
|
|
1439
|
-
|
|
1445
|
+
if (expandToWorkArea) {
|
|
1446
|
+
await (() => new Promise((r) => setTimeout(r, 500)))();
|
|
1447
|
+
await this._expandToWorkArea(win, animationDuration);
|
|
1448
|
+
}
|
|
1440
1449
|
return win;
|
|
1441
1450
|
}
|
|
1442
1451
|
// -------------------------------------------------------------------------
|
|
@@ -1495,7 +1504,9 @@ var WindowManager = class {
|
|
|
1495
1504
|
*/
|
|
1496
1505
|
broadcast(channel, ...args) {
|
|
1497
1506
|
for (const win of this._windows.values()) {
|
|
1498
|
-
if (!win.isDestroyed())
|
|
1507
|
+
if (!win.isDestroyed()) {
|
|
1508
|
+
win.webContents.send(channel, ...args);
|
|
1509
|
+
}
|
|
1499
1510
|
}
|
|
1500
1511
|
}
|
|
1501
1512
|
// -------------------------------------------------------------------------
|
|
@@ -1508,7 +1519,9 @@ var WindowManager = class {
|
|
|
1508
1519
|
}
|
|
1509
1520
|
win.once("closed", () => {
|
|
1510
1521
|
this._windows.delete(win.id);
|
|
1511
|
-
if (this._mainWindowId === win.id)
|
|
1522
|
+
if (this._mainWindowId === win.id) {
|
|
1523
|
+
this._mainWindowId = void 0;
|
|
1524
|
+
}
|
|
1512
1525
|
Logger.log(`[WindowManager] Window #${win.id} closed`);
|
|
1513
1526
|
});
|
|
1514
1527
|
}
|
|
@@ -1519,17 +1532,18 @@ var WindowManager = class {
|
|
|
1519
1532
|
*/
|
|
1520
1533
|
_expandToWorkArea(win, animationDuration) {
|
|
1521
1534
|
return new Promise((resolve) => {
|
|
1522
|
-
|
|
1523
|
-
win.setBounds({ x, y, width, height }, true);
|
|
1535
|
+
win.maximize();
|
|
1524
1536
|
let resolved = false;
|
|
1525
1537
|
const done = /* @__PURE__ */ __name(() => {
|
|
1526
|
-
if (resolved)
|
|
1538
|
+
if (resolved) {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1527
1541
|
resolved = true;
|
|
1528
1542
|
win.removeListener("resize", done);
|
|
1529
1543
|
resolve();
|
|
1530
1544
|
}, "done");
|
|
1531
1545
|
win.once("resize", done);
|
|
1532
|
-
setTimeout(done, animationDuration
|
|
1546
|
+
setTimeout(done, animationDuration);
|
|
1533
1547
|
});
|
|
1534
1548
|
}
|
|
1535
1549
|
};
|
package/dist/main.mjs
CHANGED
|
@@ -122,6 +122,9 @@ var init_app_injector = __esm({
|
|
|
122
122
|
return this._resolveForwardRef(target);
|
|
123
123
|
}
|
|
124
124
|
const k = keyOf(target);
|
|
125
|
+
if (this.singletons.has(k)) {
|
|
126
|
+
return this.singletons.get(k);
|
|
127
|
+
}
|
|
125
128
|
const binding = this.bindings.get(k);
|
|
126
129
|
if (!binding) {
|
|
127
130
|
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
|
@@ -1305,7 +1308,7 @@ import { app, BrowserWindow as BrowserWindow2, ipcMain, MessageChannelMain } fro
|
|
|
1305
1308
|
// src/window/window-manager.ts
|
|
1306
1309
|
init_injectable_decorator();
|
|
1307
1310
|
init_logger();
|
|
1308
|
-
import { BrowserWindow
|
|
1311
|
+
import { BrowserWindow } from "electron/main";
|
|
1309
1312
|
var WindowManager = class {
|
|
1310
1313
|
constructor() {
|
|
1311
1314
|
this._windows = /* @__PURE__ */ new Map();
|
|
@@ -1358,18 +1361,24 @@ var WindowManager = class {
|
|
|
1358
1361
|
* win.loadFile('index.html');
|
|
1359
1362
|
*/
|
|
1360
1363
|
async createSplash(options = {}) {
|
|
1361
|
-
const {
|
|
1364
|
+
const {
|
|
1365
|
+
animationDuration = 10,
|
|
1366
|
+
expandToWorkArea = true,
|
|
1367
|
+
...bwOptions
|
|
1368
|
+
} = options;
|
|
1362
1369
|
const win = new BrowserWindow({
|
|
1363
1370
|
width: 600,
|
|
1364
1371
|
height: 600,
|
|
1365
1372
|
center: true,
|
|
1366
|
-
frame: false,
|
|
1367
1373
|
show: true,
|
|
1368
1374
|
...bwOptions
|
|
1369
1375
|
});
|
|
1370
1376
|
this._register(win, true);
|
|
1371
1377
|
Logger.log(`[WindowManager] Splash window #${win.id} created`);
|
|
1372
|
-
|
|
1378
|
+
if (expandToWorkArea) {
|
|
1379
|
+
await (() => new Promise((r) => setTimeout(r, 500)))();
|
|
1380
|
+
await this._expandToWorkArea(win, animationDuration);
|
|
1381
|
+
}
|
|
1373
1382
|
return win;
|
|
1374
1383
|
}
|
|
1375
1384
|
// -------------------------------------------------------------------------
|
|
@@ -1428,7 +1437,9 @@ var WindowManager = class {
|
|
|
1428
1437
|
*/
|
|
1429
1438
|
broadcast(channel, ...args) {
|
|
1430
1439
|
for (const win of this._windows.values()) {
|
|
1431
|
-
if (!win.isDestroyed())
|
|
1440
|
+
if (!win.isDestroyed()) {
|
|
1441
|
+
win.webContents.send(channel, ...args);
|
|
1442
|
+
}
|
|
1432
1443
|
}
|
|
1433
1444
|
}
|
|
1434
1445
|
// -------------------------------------------------------------------------
|
|
@@ -1441,7 +1452,9 @@ var WindowManager = class {
|
|
|
1441
1452
|
}
|
|
1442
1453
|
win.once("closed", () => {
|
|
1443
1454
|
this._windows.delete(win.id);
|
|
1444
|
-
if (this._mainWindowId === win.id)
|
|
1455
|
+
if (this._mainWindowId === win.id) {
|
|
1456
|
+
this._mainWindowId = void 0;
|
|
1457
|
+
}
|
|
1445
1458
|
Logger.log(`[WindowManager] Window #${win.id} closed`);
|
|
1446
1459
|
});
|
|
1447
1460
|
}
|
|
@@ -1452,17 +1465,18 @@ var WindowManager = class {
|
|
|
1452
1465
|
*/
|
|
1453
1466
|
_expandToWorkArea(win, animationDuration) {
|
|
1454
1467
|
return new Promise((resolve) => {
|
|
1455
|
-
|
|
1456
|
-
win.setBounds({ x, y, width, height }, true);
|
|
1468
|
+
win.maximize();
|
|
1457
1469
|
let resolved = false;
|
|
1458
1470
|
const done = /* @__PURE__ */ __name(() => {
|
|
1459
|
-
if (resolved)
|
|
1471
|
+
if (resolved) {
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1460
1474
|
resolved = true;
|
|
1461
1475
|
win.removeListener("resize", done);
|
|
1462
1476
|
resolve();
|
|
1463
1477
|
}, "done");
|
|
1464
1478
|
win.once("resize", done);
|
|
1465
|
-
setTimeout(done, animationDuration
|
|
1479
|
+
setTimeout(done, animationDuration);
|
|
1466
1480
|
});
|
|
1467
1481
|
}
|
|
1468
1482
|
};
|
package/dist/renderer.js
CHANGED
|
@@ -95,6 +95,9 @@ var _AppInjector = class _AppInjector {
|
|
|
95
95
|
return this._resolveForwardRef(target);
|
|
96
96
|
}
|
|
97
97
|
const k = keyOf(target);
|
|
98
|
+
if (this.singletons.has(k)) {
|
|
99
|
+
return this.singletons.get(k);
|
|
100
|
+
}
|
|
98
101
|
const binding = this.bindings.get(k);
|
|
99
102
|
if (!binding) {
|
|
100
103
|
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
package/dist/renderer.mjs
CHANGED
|
@@ -66,6 +66,9 @@ var _AppInjector = class _AppInjector {
|
|
|
66
66
|
return this._resolveForwardRef(target);
|
|
67
67
|
}
|
|
68
68
|
const k = keyOf(target);
|
|
69
|
+
if (this.singletons.has(k)) {
|
|
70
|
+
return this.singletons.get(k);
|
|
71
|
+
}
|
|
69
72
|
const binding = this.bindings.get(k);
|
|
70
73
|
if (!binding) {
|
|
71
74
|
const name = target instanceof Token ? target.description : target.name ?? "unknown";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noxfly/noxus",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.3",
|
|
4
4
|
"main": "dist/main.js",
|
|
5
5
|
"module": "dist/main.mjs",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
"require": "./dist/child.js"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
+
"typesVersions": {
|
|
42
|
+
"*": {
|
|
43
|
+
"main": ["./dist/main.d.ts"],
|
|
44
|
+
"renderer": ["./dist/renderer.d.ts"],
|
|
45
|
+
"preload": ["./dist/preload.d.ts"],
|
|
46
|
+
"child": ["./dist/child.d.ts"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
41
49
|
"scripts": {
|
|
42
50
|
"build": "tsup",
|
|
43
51
|
"prepublishOnly": "npm run build",
|
package/src/DI/app-injector.ts
CHANGED
|
@@ -77,10 +77,19 @@ export class AppInjector {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const k = keyOf(target) as TokenKey<unknown>;
|
|
80
|
+
|
|
81
|
+
if (this.singletons.has(k)) {
|
|
82
|
+
return this.singletons.get(k) as T;
|
|
83
|
+
}
|
|
84
|
+
|
|
80
85
|
const binding = this.bindings.get(k);
|
|
81
86
|
|
|
82
87
|
if (!binding) {
|
|
83
|
-
const name = target instanceof Token
|
|
88
|
+
const name = target instanceof Token
|
|
89
|
+
? target.description
|
|
90
|
+
: (target as Type<unknown>).name
|
|
91
|
+
?? 'unknown';
|
|
92
|
+
|
|
84
93
|
throw new Error(
|
|
85
94
|
`[Noxus DI] No binding found for "${name}".\n`
|
|
86
95
|
+ `Did you forget to declare it in @Injectable({ deps }) or in bootstrapApplication({ singletons })?`,
|
|
@@ -78,6 +78,7 @@ export async function bootstrapApplication(config: BootstrapConfig = {}): Promis
|
|
|
78
78
|
|
|
79
79
|
// Build override map for the DI flush phase
|
|
80
80
|
const overrides = new Map<TokenKey, unknown>();
|
|
81
|
+
|
|
81
82
|
for (const { token, useValue } of config.singletons ?? []) {
|
|
82
83
|
overrides.set(token, useValue);
|
|
83
84
|
// Pre-register the binding so the injector knows the token exists
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author NoxFly
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { BrowserWindow
|
|
7
|
+
import { BrowserWindow } from 'electron/main';
|
|
8
8
|
import { Injectable } from '../decorators/injectable.decorator';
|
|
9
9
|
import { Logger } from '../utils/logger';
|
|
10
10
|
|
|
@@ -114,15 +114,21 @@ export class WindowManager {
|
|
|
114
114
|
* win.loadFile('index.html');
|
|
115
115
|
*/
|
|
116
116
|
public async createSplash(
|
|
117
|
-
options: Electron.BrowserWindowConstructorOptions & {
|
|
117
|
+
options: Electron.BrowserWindowConstructorOptions & {
|
|
118
|
+
animationDuration?: number;
|
|
119
|
+
expandToWorkArea?: boolean;
|
|
120
|
+
} = {},
|
|
118
121
|
): Promise<BrowserWindow> {
|
|
119
|
-
const {
|
|
122
|
+
const {
|
|
123
|
+
animationDuration = 10,
|
|
124
|
+
expandToWorkArea = true,
|
|
125
|
+
...bwOptions
|
|
126
|
+
} = options;
|
|
120
127
|
|
|
121
128
|
const win = new BrowserWindow({
|
|
122
129
|
width: 600,
|
|
123
130
|
height: 600,
|
|
124
131
|
center: true,
|
|
125
|
-
frame: false,
|
|
126
132
|
show: true,
|
|
127
133
|
...bwOptions,
|
|
128
134
|
});
|
|
@@ -131,7 +137,10 @@ export class WindowManager {
|
|
|
131
137
|
|
|
132
138
|
Logger.log(`[WindowManager] Splash window #${win.id} created`);
|
|
133
139
|
|
|
134
|
-
|
|
140
|
+
if(expandToWorkArea) {
|
|
141
|
+
await (() => new Promise((r) => setTimeout(r, 500)))();
|
|
142
|
+
await this._expandToWorkArea(win, animationDuration);
|
|
143
|
+
}
|
|
135
144
|
|
|
136
145
|
return win;
|
|
137
146
|
}
|
|
@@ -203,7 +212,9 @@ export class WindowManager {
|
|
|
203
212
|
*/
|
|
204
213
|
public broadcast(channel: string, ...args: unknown[]): void {
|
|
205
214
|
for (const win of this._windows.values()) {
|
|
206
|
-
if (!win.isDestroyed())
|
|
215
|
+
if (!win.isDestroyed()) {
|
|
216
|
+
win.webContents.send(channel, ...args);
|
|
217
|
+
}
|
|
207
218
|
}
|
|
208
219
|
}
|
|
209
220
|
|
|
@@ -220,7 +231,9 @@ export class WindowManager {
|
|
|
220
231
|
|
|
221
232
|
win.once('closed', () => {
|
|
222
233
|
this._windows.delete(win.id);
|
|
223
|
-
if (this._mainWindowId === win.id)
|
|
234
|
+
if (this._mainWindowId === win.id) {
|
|
235
|
+
this._mainWindowId = undefined;
|
|
236
|
+
}
|
|
224
237
|
Logger.log(`[WindowManager] Window #${win.id} closed`);
|
|
225
238
|
});
|
|
226
239
|
}
|
|
@@ -232,9 +245,7 @@ export class WindowManager {
|
|
|
232
245
|
*/
|
|
233
246
|
private _expandToWorkArea(win: BrowserWindow, animationDuration: number): Promise<void> {
|
|
234
247
|
return new Promise((resolve) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
win.setBounds({ x, y, width, height }, true);
|
|
248
|
+
win.maximize();
|
|
238
249
|
|
|
239
250
|
// Wait for the animation to finish before resolving.
|
|
240
251
|
// We listen to the 'resize' event which fires once the OS
|
|
@@ -242,14 +253,16 @@ export class WindowManager {
|
|
|
242
253
|
let resolved = false;
|
|
243
254
|
|
|
244
255
|
const done = (): void => {
|
|
245
|
-
if (resolved)
|
|
256
|
+
if (resolved) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
246
259
|
resolved = true;
|
|
247
260
|
win.removeListener('resize', done);
|
|
248
261
|
resolve();
|
|
249
262
|
};
|
|
250
263
|
|
|
251
264
|
win.once('resize', done);
|
|
252
|
-
setTimeout(done, animationDuration
|
|
265
|
+
setTimeout(done, animationDuration);
|
|
253
266
|
});
|
|
254
267
|
}
|
|
255
268
|
}
|