react-native-electron-platform 0.0.29 → 0.0.31
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/electron-builder.json +3 -3
- package/index.mjs +18 -3
- package/package.json +2 -3
- package/src/modules/autoUpdater.js +1 -1
- package/src/modules/ipcHandlers/index.js +2 -2
- package/src/modules/windowManager.js +17 -2
- package/src/preload.mjs +1 -1
- package/src/progress.mjs +53 -0
- package/webpack.config.mjs +15 -2
package/electron-builder.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"appId": "com.
|
|
3
|
-
"productName": "
|
|
2
|
+
"appId": "com.inv.desktop",
|
|
3
|
+
"productName": "inv",
|
|
4
4
|
"asar": {
|
|
5
5
|
"smartUnpack": true
|
|
6
6
|
},
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"allowToChangeInstallationDirectory": true,
|
|
80
80
|
"createDesktopShortcut": true,
|
|
81
81
|
"createStartMenuShortcut": true,
|
|
82
|
-
"shortcutName": "
|
|
82
|
+
"shortcutName": "inv",
|
|
83
83
|
"artifactName": "${productName} Setup ${version}.${ext}"
|
|
84
84
|
},
|
|
85
85
|
|
package/index.mjs
CHANGED
|
@@ -12,6 +12,21 @@ import { createMainWindow } from './src/modules/windowManager.js';
|
|
|
12
12
|
|
|
13
13
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
|
|
15
|
+
const color = {
|
|
16
|
+
reset: "\x1b[0m",
|
|
17
|
+
green: "\x1b[32m",
|
|
18
|
+
yellow: "\x1b[33m",
|
|
19
|
+
blue: "\x1b[34m",
|
|
20
|
+
red: "\x1b[31m",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const format = {
|
|
24
|
+
info: (text) => `${color.blue}${text}${color.reset}`,
|
|
25
|
+
success: (text) => `${color.green}${text}${color.reset}`,
|
|
26
|
+
warn: (text) => `${color.yellow}${text}${color.reset}`,
|
|
27
|
+
error: (text) => `${color.red}${text}${color.reset}`,
|
|
28
|
+
};
|
|
29
|
+
|
|
15
30
|
// ======================================================
|
|
16
31
|
// SAFE MODE DETECTION (applies before ready)
|
|
17
32
|
// ======================================================
|
|
@@ -60,9 +75,9 @@ app.whenReady().then(() => {
|
|
|
60
75
|
setupAutoUpdater(mainWindow);
|
|
61
76
|
|
|
62
77
|
// Log registered handlers
|
|
63
|
-
console.log("
|
|
64
|
-
ipcMain.eventNames().filter(name =>
|
|
65
|
-
typeof name === 'string' &&
|
|
78
|
+
console.log(format.info("IPC Handlers registered:"),
|
|
79
|
+
ipcMain.eventNames().filter(name =>
|
|
80
|
+
typeof name === 'string' &&
|
|
66
81
|
!name.startsWith('ELECTRON_')
|
|
67
82
|
)
|
|
68
83
|
);
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-electron-platform",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"description": "A boilerplate and utilities for running React Native applications in desktop environments using Electron.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "electron index.mjs",
|
|
8
|
-
"build": "webpack --config webpack.config.mjs"
|
|
9
|
-
"postinstall": "npm install"
|
|
8
|
+
"build": "webpack --config webpack.config.mjs"
|
|
10
9
|
},
|
|
11
10
|
"keywords": [
|
|
12
11
|
"react-native",
|
|
@@ -15,7 +15,7 @@ export function setupAutoUpdater(mainWindow) {
|
|
|
15
15
|
// Check if app-update.yml exists (required for auto-updates)
|
|
16
16
|
const appUpdatePath = path.join(process.resourcesPath, "app-update.yml");
|
|
17
17
|
if (!fs.existsSync(appUpdatePath)) {
|
|
18
|
-
console.log("
|
|
18
|
+
console.log(" Auto-update disabled: app-update.yml not found.");
|
|
19
19
|
console.log(" This file is only created when publishing updates.");
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
@@ -8,7 +8,7 @@ import { registerFileHandlers } from './fileOps.js';
|
|
|
8
8
|
import { registerUtilsHandlers } from './utils.js';
|
|
9
9
|
|
|
10
10
|
export function registerAllIpcHandlers() {
|
|
11
|
-
console.log("
|
|
11
|
+
console.log(" Registering IPC handlers...");
|
|
12
12
|
|
|
13
13
|
// Deep Linking (basic)
|
|
14
14
|
ipcMain.handle('react-native-open-url', async (_event, url) => {
|
|
@@ -29,5 +29,5 @@ export function registerAllIpcHandlers() {
|
|
|
29
29
|
event.returnValue = true;
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
console.log("
|
|
32
|
+
console.log(" All IPC handlers registered");
|
|
33
33
|
}
|
|
@@ -3,6 +3,21 @@ import path from "path";
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { app, dialog } from "electron";
|
|
5
5
|
|
|
6
|
+
const color = {
|
|
7
|
+
reset: "\x1b[0m",
|
|
8
|
+
green: "\x1b[32m",
|
|
9
|
+
yellow: "\x1b[33m",
|
|
10
|
+
blue: "\x1b[34m",
|
|
11
|
+
red: "\x1b[31m",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const format = {
|
|
15
|
+
info: (text) => `${color.blue}${text}${color.reset}`,
|
|
16
|
+
success: (text) => `${color.green}${text}${color.reset}`,
|
|
17
|
+
warn: (text) => `${color.yellow}${text}${color.reset}`,
|
|
18
|
+
error: (text) => `${color.red}${text}${color.reset}`,
|
|
19
|
+
};
|
|
20
|
+
|
|
6
21
|
export function createMainWindow(__dirname) {
|
|
7
22
|
const primaryDisplay = screen.getPrimaryDisplay();
|
|
8
23
|
const { x, y, width, height } = primaryDisplay.bounds;
|
|
@@ -53,7 +68,7 @@ export function createMainWindow(__dirname) {
|
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
mainWindow.webContents.on("did-finish-load", () => {
|
|
56
|
-
console.log("Page loaded successfully");
|
|
71
|
+
console.log(format.success("Page loaded successfully"));
|
|
57
72
|
});
|
|
58
73
|
|
|
59
74
|
return mainWindow;
|
|
@@ -91,7 +106,7 @@ function loadAppContent(mainWindow, __dirname) {
|
|
|
91
106
|
|
|
92
107
|
if (isDev) {
|
|
93
108
|
mainWindow.loadURL("http://localhost:5001");
|
|
94
|
-
console.log("DEV MODE: http://localhost:5001");
|
|
109
|
+
console.log(format.info("DEV MODE: http://localhost:5001"));
|
|
95
110
|
} else {
|
|
96
111
|
const possiblePaths = [
|
|
97
112
|
path.join(__dirname, "web-build/index.html"),
|
package/src/preload.mjs
CHANGED
package/src/progress.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
width: 24,
|
|
5
|
+
label: 'Building',
|
|
6
|
+
detailPrefix: 'Compiling',
|
|
7
|
+
colors: {
|
|
8
|
+
bar: '\x1b[32m',
|
|
9
|
+
info: '\x1b[34m',
|
|
10
|
+
percent: '\x1b[33m',
|
|
11
|
+
reset: '\x1b[0m',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function createProgressPlugin(options = {}) {
|
|
16
|
+
const opts = { ...defaultOptions, ...options };
|
|
17
|
+
opts.colors = { ...defaultOptions.colors, ...(options.colors || {}) };
|
|
18
|
+
|
|
19
|
+
let initialPrinted = false;
|
|
20
|
+
|
|
21
|
+
return new webpack.ProgressPlugin((percentage, message, ...args) => {
|
|
22
|
+
const percent = Math.round(percentage * 100);
|
|
23
|
+
const complete = Math.round(percentage * opts.width);
|
|
24
|
+
const green = opts.colors.bar;
|
|
25
|
+
const blue = opts.colors.info;
|
|
26
|
+
const yellow = opts.colors.percent;
|
|
27
|
+
const reset = opts.colors.reset;
|
|
28
|
+
|
|
29
|
+
const blocks = '█'.repeat(complete);
|
|
30
|
+
const empties = ' '.repeat(Math.max(0, opts.width - complete));
|
|
31
|
+
const bar = `${green}${blocks}${reset}${empties}`;
|
|
32
|
+
|
|
33
|
+
let detailText = message || 'starting...';
|
|
34
|
+
if (args && args.length > 0) {
|
|
35
|
+
const info = args.join(' ');
|
|
36
|
+
if (info.length > 0) {
|
|
37
|
+
detailText = `${detailText} ${info}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const detail = `${blue}${opts.detailPrefix}:${reset} ${detailText}`;
|
|
41
|
+
const text = `${blue}${opts.label}${reset} [${bar}] ${yellow}${percent}%${reset}`;
|
|
42
|
+
|
|
43
|
+
if (initialPrinted) {
|
|
44
|
+
process.stdout.write('\x1b[2A');
|
|
45
|
+
}
|
|
46
|
+
process.stdout.write(`\x1b[2K\r${detail}\n\x1b[2K\r${text}\n`);
|
|
47
|
+
initialPrinted = true;
|
|
48
|
+
|
|
49
|
+
if (percentage === 1) {
|
|
50
|
+
process.stdout.write('\n');
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
package/webpack.config.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import packageJson from '../../package.json' with { type: 'json' };
|
|
8
8
|
import { generateAlias, generateFallback } from './src/webpackConfigHelper.mjs';
|
|
9
|
+
import { createProgressPlugin } from './src/progress.mjs';
|
|
9
10
|
|
|
10
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
12
|
const port = process.env.PORT || 5001;
|
|
@@ -44,6 +45,10 @@ export default {
|
|
|
44
45
|
entry: path.resolve(process.cwd(), 'electron/index.js'),
|
|
45
46
|
devtool: 'source-map',
|
|
46
47
|
|
|
48
|
+
stats: 'none',
|
|
49
|
+
infrastructureLogging: {
|
|
50
|
+
level: 'error',
|
|
51
|
+
},
|
|
47
52
|
devServer: {
|
|
48
53
|
port: port,
|
|
49
54
|
host: host,
|
|
@@ -55,12 +60,17 @@ export default {
|
|
|
55
60
|
directory: path.join(process.cwd(), 'web-build'),
|
|
56
61
|
publicPath: '/',
|
|
57
62
|
},
|
|
63
|
+
devMiddleware: {
|
|
64
|
+
stats: 'errors-only',
|
|
65
|
+
},
|
|
58
66
|
client: {
|
|
67
|
+
logging: 'none',
|
|
59
68
|
overlay: {
|
|
60
69
|
errors: true,
|
|
61
70
|
warnings: false,
|
|
62
71
|
},
|
|
63
|
-
reconnect:
|
|
72
|
+
reconnect: false,
|
|
73
|
+
progress: false,
|
|
64
74
|
},
|
|
65
75
|
},
|
|
66
76
|
|
|
@@ -152,7 +162,10 @@ export default {
|
|
|
152
162
|
},
|
|
153
163
|
|
|
154
164
|
plugins: [
|
|
155
|
-
|
|
165
|
+
createProgressPlugin(),
|
|
166
|
+
new ReactRefreshWebpackPlugin({
|
|
167
|
+
overlay: false,
|
|
168
|
+
}),
|
|
156
169
|
new CopyFontsPlugin(),
|
|
157
170
|
new HtmlWebpackPlugin({
|
|
158
171
|
template: path.resolve(__dirname, 'src/index.html'),
|