@noxfly/noxus 3.0.0-dev.2 → 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/dist/main.d.mts +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +20 -9
- package/dist/main.mjs +21 -10
- package/package.json +1 -1
- package/src/window/window-manager.ts +25 -12
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
|
@@ -1428,18 +1428,24 @@ var WindowManager = class {
|
|
|
1428
1428
|
* win.loadFile('index.html');
|
|
1429
1429
|
*/
|
|
1430
1430
|
async createSplash(options = {}) {
|
|
1431
|
-
const {
|
|
1431
|
+
const {
|
|
1432
|
+
animationDuration = 10,
|
|
1433
|
+
expandToWorkArea = true,
|
|
1434
|
+
...bwOptions
|
|
1435
|
+
} = options;
|
|
1432
1436
|
const win = new import_main.BrowserWindow({
|
|
1433
1437
|
width: 600,
|
|
1434
1438
|
height: 600,
|
|
1435
1439
|
center: true,
|
|
1436
|
-
frame: false,
|
|
1437
1440
|
show: true,
|
|
1438
1441
|
...bwOptions
|
|
1439
1442
|
});
|
|
1440
1443
|
this._register(win, true);
|
|
1441
1444
|
Logger.log(`[WindowManager] Splash window #${win.id} created`);
|
|
1442
|
-
|
|
1445
|
+
if (expandToWorkArea) {
|
|
1446
|
+
await (() => new Promise((r) => setTimeout(r, 500)))();
|
|
1447
|
+
await this._expandToWorkArea(win, animationDuration);
|
|
1448
|
+
}
|
|
1443
1449
|
return win;
|
|
1444
1450
|
}
|
|
1445
1451
|
// -------------------------------------------------------------------------
|
|
@@ -1498,7 +1504,9 @@ var WindowManager = class {
|
|
|
1498
1504
|
*/
|
|
1499
1505
|
broadcast(channel, ...args) {
|
|
1500
1506
|
for (const win of this._windows.values()) {
|
|
1501
|
-
if (!win.isDestroyed())
|
|
1507
|
+
if (!win.isDestroyed()) {
|
|
1508
|
+
win.webContents.send(channel, ...args);
|
|
1509
|
+
}
|
|
1502
1510
|
}
|
|
1503
1511
|
}
|
|
1504
1512
|
// -------------------------------------------------------------------------
|
|
@@ -1511,7 +1519,9 @@ var WindowManager = class {
|
|
|
1511
1519
|
}
|
|
1512
1520
|
win.once("closed", () => {
|
|
1513
1521
|
this._windows.delete(win.id);
|
|
1514
|
-
if (this._mainWindowId === win.id)
|
|
1522
|
+
if (this._mainWindowId === win.id) {
|
|
1523
|
+
this._mainWindowId = void 0;
|
|
1524
|
+
}
|
|
1515
1525
|
Logger.log(`[WindowManager] Window #${win.id} closed`);
|
|
1516
1526
|
});
|
|
1517
1527
|
}
|
|
@@ -1522,17 +1532,18 @@ var WindowManager = class {
|
|
|
1522
1532
|
*/
|
|
1523
1533
|
_expandToWorkArea(win, animationDuration) {
|
|
1524
1534
|
return new Promise((resolve) => {
|
|
1525
|
-
|
|
1526
|
-
win.setBounds({ x, y, width, height }, true);
|
|
1535
|
+
win.maximize();
|
|
1527
1536
|
let resolved = false;
|
|
1528
1537
|
const done = /* @__PURE__ */ __name(() => {
|
|
1529
|
-
if (resolved)
|
|
1538
|
+
if (resolved) {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1530
1541
|
resolved = true;
|
|
1531
1542
|
win.removeListener("resize", done);
|
|
1532
1543
|
resolve();
|
|
1533
1544
|
}, "done");
|
|
1534
1545
|
win.once("resize", done);
|
|
1535
|
-
setTimeout(done, animationDuration
|
|
1546
|
+
setTimeout(done, animationDuration);
|
|
1536
1547
|
});
|
|
1537
1548
|
}
|
|
1538
1549
|
};
|
package/dist/main.mjs
CHANGED
|
@@ -1308,7 +1308,7 @@ import { app, BrowserWindow as BrowserWindow2, ipcMain, MessageChannelMain } fro
|
|
|
1308
1308
|
// src/window/window-manager.ts
|
|
1309
1309
|
init_injectable_decorator();
|
|
1310
1310
|
init_logger();
|
|
1311
|
-
import { BrowserWindow
|
|
1311
|
+
import { BrowserWindow } from "electron/main";
|
|
1312
1312
|
var WindowManager = class {
|
|
1313
1313
|
constructor() {
|
|
1314
1314
|
this._windows = /* @__PURE__ */ new Map();
|
|
@@ -1361,18 +1361,24 @@ var WindowManager = class {
|
|
|
1361
1361
|
* win.loadFile('index.html');
|
|
1362
1362
|
*/
|
|
1363
1363
|
async createSplash(options = {}) {
|
|
1364
|
-
const {
|
|
1364
|
+
const {
|
|
1365
|
+
animationDuration = 10,
|
|
1366
|
+
expandToWorkArea = true,
|
|
1367
|
+
...bwOptions
|
|
1368
|
+
} = options;
|
|
1365
1369
|
const win = new BrowserWindow({
|
|
1366
1370
|
width: 600,
|
|
1367
1371
|
height: 600,
|
|
1368
1372
|
center: true,
|
|
1369
|
-
frame: false,
|
|
1370
1373
|
show: true,
|
|
1371
1374
|
...bwOptions
|
|
1372
1375
|
});
|
|
1373
1376
|
this._register(win, true);
|
|
1374
1377
|
Logger.log(`[WindowManager] Splash window #${win.id} created`);
|
|
1375
|
-
|
|
1378
|
+
if (expandToWorkArea) {
|
|
1379
|
+
await (() => new Promise((r) => setTimeout(r, 500)))();
|
|
1380
|
+
await this._expandToWorkArea(win, animationDuration);
|
|
1381
|
+
}
|
|
1376
1382
|
return win;
|
|
1377
1383
|
}
|
|
1378
1384
|
// -------------------------------------------------------------------------
|
|
@@ -1431,7 +1437,9 @@ var WindowManager = class {
|
|
|
1431
1437
|
*/
|
|
1432
1438
|
broadcast(channel, ...args) {
|
|
1433
1439
|
for (const win of this._windows.values()) {
|
|
1434
|
-
if (!win.isDestroyed())
|
|
1440
|
+
if (!win.isDestroyed()) {
|
|
1441
|
+
win.webContents.send(channel, ...args);
|
|
1442
|
+
}
|
|
1435
1443
|
}
|
|
1436
1444
|
}
|
|
1437
1445
|
// -------------------------------------------------------------------------
|
|
@@ -1444,7 +1452,9 @@ var WindowManager = class {
|
|
|
1444
1452
|
}
|
|
1445
1453
|
win.once("closed", () => {
|
|
1446
1454
|
this._windows.delete(win.id);
|
|
1447
|
-
if (this._mainWindowId === win.id)
|
|
1455
|
+
if (this._mainWindowId === win.id) {
|
|
1456
|
+
this._mainWindowId = void 0;
|
|
1457
|
+
}
|
|
1448
1458
|
Logger.log(`[WindowManager] Window #${win.id} closed`);
|
|
1449
1459
|
});
|
|
1450
1460
|
}
|
|
@@ -1455,17 +1465,18 @@ var WindowManager = class {
|
|
|
1455
1465
|
*/
|
|
1456
1466
|
_expandToWorkArea(win, animationDuration) {
|
|
1457
1467
|
return new Promise((resolve) => {
|
|
1458
|
-
|
|
1459
|
-
win.setBounds({ x, y, width, height }, true);
|
|
1468
|
+
win.maximize();
|
|
1460
1469
|
let resolved = false;
|
|
1461
1470
|
const done = /* @__PURE__ */ __name(() => {
|
|
1462
|
-
if (resolved)
|
|
1471
|
+
if (resolved) {
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1463
1474
|
resolved = true;
|
|
1464
1475
|
win.removeListener("resize", done);
|
|
1465
1476
|
resolve();
|
|
1466
1477
|
}, "done");
|
|
1467
1478
|
win.once("resize", done);
|
|
1468
|
-
setTimeout(done, animationDuration
|
|
1479
|
+
setTimeout(done, animationDuration);
|
|
1469
1480
|
});
|
|
1470
1481
|
}
|
|
1471
1482
|
};
|
package/package.json
CHANGED
|
@@ -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
|
}
|