react-native-electron-platform 0.0.11 → 0.0.13
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/.editorconfig +18 -0
- package/.gitattributes +2 -0
- package/.npmignore +20 -0
- package/README.md +1157 -27
- package/electron-builder.json +3 -2
- package/index.mjs +83 -0
- package/package.json +6 -3
- package/src/icon.ico +0 -0
- package/src/main.mjs +515 -44
- package/src/webpackConfigHelper.mjs +1 -1
- package/test/package.json +43 -0
- package/test/test.mjs +27 -0
- package/test/electron/electron-builder.json +0 -94
package/electron-builder.json
CHANGED
|
@@ -55,13 +55,14 @@
|
|
|
55
55
|
"!**/node_modules/react-native-*/*",
|
|
56
56
|
"!**/node_modules/rn-fetch-blob/**",
|
|
57
57
|
"!**/locales/**",
|
|
58
|
-
"node_modules/react-native-electron-platform/src/**/*"
|
|
58
|
+
"node_modules/react-native-electron-platform/src/**/*",
|
|
59
|
+
"node_modules/react-native-electron-platform/index.mjs"
|
|
59
60
|
],
|
|
60
61
|
"asarUnpack": [
|
|
61
62
|
"**/*.node"
|
|
62
63
|
],
|
|
63
64
|
"extraMetadata": {
|
|
64
|
-
"main": "node_modules/react-native-electron-platform/
|
|
65
|
+
"main": "node_modules/react-native-electron-platform/index.mjs"
|
|
65
66
|
},
|
|
66
67
|
"win": {
|
|
67
68
|
"target": [
|
package/index.mjs
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
+
import { app, BrowserWindow, ipcMain } from "electron";
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import packageJson from "../../package.json" with { type: 'json' };
|
|
5
|
+
|
|
6
|
+
// Import modules
|
|
7
|
+
import { shouldUseSafeMode, applySafeMode } from './src/modules/safeMode.js';
|
|
8
|
+
import { registerDeepLinkingHandlers, sendOpenURL } from './src/modules/deepLinking.js';
|
|
9
|
+
import { registerAllIpcHandlers } from './src/modules/ipcHandlers/index.js';
|
|
10
|
+
import { setupAutoUpdater } from './src/modules/autoUpdater.js';
|
|
11
|
+
import { createMainWindow } from './src/modules/windowManager.js';
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
15
|
+
// ======================================================
|
|
16
|
+
// SAFE MODE DETECTION (applies before ready)
|
|
17
|
+
// ======================================================
|
|
18
|
+
if (shouldUseSafeMode()) {
|
|
19
|
+
applySafeMode();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let mainWindow;
|
|
23
|
+
|
|
24
|
+
// ======================================================
|
|
25
|
+
// REGISTER IPC HANDLERS
|
|
26
|
+
// ======================================================
|
|
27
|
+
registerAllIpcHandlers();
|
|
28
|
+
registerDeepLinkingHandlers(sendOpenURL);
|
|
29
|
+
|
|
30
|
+
// ======================================================
|
|
31
|
+
// APP LIFECYCLE
|
|
32
|
+
// ======================================================
|
|
33
|
+
|
|
34
|
+
// Single instance lock
|
|
35
|
+
const gotTheLock = app.requestSingleInstanceLock();
|
|
36
|
+
|
|
37
|
+
if (!gotTheLock) {
|
|
38
|
+
app.quit();
|
|
39
|
+
} else {
|
|
40
|
+
app.on('second-instance', (event, commandLine) => {
|
|
41
|
+
if (mainWindow) {
|
|
42
|
+
if (mainWindow.isMinimized()) mainWindow.restore();
|
|
43
|
+
mainWindow.focus();
|
|
44
|
+
|
|
45
|
+
// Handle deep link from second instance
|
|
46
|
+
const url = commandLine.pop();
|
|
47
|
+
if (url && (url.startsWith('myapp://') || url.startsWith('http'))) {
|
|
48
|
+
sendOpenURL(url);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
app.whenReady().then(() => {
|
|
55
|
+
if (process.platform === "win32") {
|
|
56
|
+
app.setAppUserModelId(`com.${packageJson.name}.desktop`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
mainWindow = createMainWindow(__dirname);
|
|
60
|
+
setupAutoUpdater(mainWindow);
|
|
61
|
+
|
|
62
|
+
// Log registered handlers
|
|
63
|
+
console.log("📊 IPC Handlers registered:",
|
|
64
|
+
ipcMain.eventNames().filter(name =>
|
|
65
|
+
typeof name === 'string' &&
|
|
66
|
+
!name.startsWith('ELECTRON_')
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
app.on("window-all-closed", () => {
|
|
72
|
+
if (process.platform !== "darwin") {
|
|
73
|
+
app.quit();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
app.on("activate", () => {
|
|
78
|
+
if (BrowserWindow.getAllWindows().length === 0) {
|
|
79
|
+
mainWindow = createMainWindow(__dirname);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Export webpack helper utilities
|
|
1
84
|
export * from './src/webpackConfigHelper.mjs';
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-electron-platform",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "A boilerplate and utilities for running React Native applications in Electron",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"start": "electron
|
|
7
|
+
"start": "electron index.mjs",
|
|
8
8
|
"build": "webpack --config webpack.config.mjs"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
"CHANGELOG.md",
|
|
50
50
|
"CODE_OF_CONDUCT.md",
|
|
51
51
|
"CONTRIBUTING.md",
|
|
52
|
-
"electron-builder.json"
|
|
52
|
+
"electron-builder.json",
|
|
53
|
+
".editorconfig",
|
|
54
|
+
".gitattributes",
|
|
55
|
+
".npmignore"
|
|
53
56
|
]
|
|
54
57
|
}
|
package/src/icon.ico
ADDED
|
Binary file
|