react-native-electron-platform 0.0.11 → 0.0.12
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 +1157 -27
- package/electron-builder.json +3 -2
- package/index.mjs +83 -0
- package/package.json +2 -2
- package/src/webpackConfigHelper.mjs +1 -1
- package/test/package.json +43 -0
- package/src/main.mjs +0 -81
- 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.12",
|
|
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": [
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import fs from 'fs';
|
|
5
|
-
import { WEB_UNSUPPORTED_PACKAGES } from '
|
|
5
|
+
import { WEB_UNSUPPORTED_PACKAGES } from '../../../electron/nonmodules.mjs';
|
|
6
6
|
|
|
7
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-electron-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A React Native app with Electron support using react-native-electron-platform",
|
|
5
|
+
"private": true,
|
|
6
|
+
"main": "node_modules/react-native-electron-platform/index.mjs",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"android": "react-native run-android",
|
|
9
|
+
"ios": "react-native run-ios",
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"start": "react-native start",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"web": "webpack serve --config node_modules/react-native-electron-platform/webpack.config.mjs --mode development",
|
|
14
|
+
"web:build": "webpack --config node_modules/react-native-electron-platform/webpack.config.mjs --mode production",
|
|
15
|
+
"electron": "cross-env NODE_ENV=development concurrently \"npm run web\" \"wait-on http://localhost:5001 && electron .\"",
|
|
16
|
+
"electron:dev": "cross-env NODE_ENV=development electron . --enable-remote-module",
|
|
17
|
+
"electron:build": "npm run web:build && electron-builder --config node_modules/react-native-electron-platform/electron-builder.json",
|
|
18
|
+
"electron:build:nsis": "npm run web:build && electron-builder --config node_modules/react-native-electron-platform/electron-builder.json --win nsis --publish never",
|
|
19
|
+
"electron:build:msi": "npm run web:build && electron-builder --config node_modules/react-native-electron-platform/electron-builder.json --win msi --publish never"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"react": "^18.0.0",
|
|
23
|
+
"react-native": "^0.71.0",
|
|
24
|
+
"react-native-electron-platform": "^0.0.12",
|
|
25
|
+
"cross-env": "^7.0.3",
|
|
26
|
+
"concurrently": "^8.0.0",
|
|
27
|
+
"wait-on": "^7.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"webpack": "^5.0.0",
|
|
31
|
+
"webpack-cli": "^5.0.0",
|
|
32
|
+
"webpack-dev-server": "^4.0.0",
|
|
33
|
+
"html-webpack-plugin": "^5.0.0",
|
|
34
|
+
"@babel/core": "^7.0.0",
|
|
35
|
+
"@babel/preset-react": "^7.0.0",
|
|
36
|
+
"@babel/preset-env": "^7.0.0",
|
|
37
|
+
"babel-loader": "^9.0.0",
|
|
38
|
+
"electron": "^25.0.0",
|
|
39
|
+
"electron-builder": "^24.0.0",
|
|
40
|
+
"eslint": "^8.0.0",
|
|
41
|
+
"jest": "^29.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/main.mjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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 './modules/safeMode.js';
|
|
8
|
-
import { registerDeepLinkingHandlers, sendOpenURL } from './modules/deepLinking.js';
|
|
9
|
-
import { registerAllIpcHandlers } from './modules/ipcHandlers/index.js';
|
|
10
|
-
import { setupAutoUpdater } from './modules/autoUpdater.js';
|
|
11
|
-
import { createMainWindow } from './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
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"appId": "com.app.desktop",
|
|
3
|
-
"productName": "app",
|
|
4
|
-
"asar": {
|
|
5
|
-
"smartUnpack": true
|
|
6
|
-
},
|
|
7
|
-
"compression": "maximum",
|
|
8
|
-
"electronLanguages": ["en-US"],
|
|
9
|
-
"removePackageScripts": true,
|
|
10
|
-
"removePackageKeywords": true,
|
|
11
|
-
"buildDependenciesFromSource": false,
|
|
12
|
-
"npmRebuild": false,
|
|
13
|
-
"nodeGypRebuild": false,
|
|
14
|
-
"directories": {
|
|
15
|
-
"output": "dist",
|
|
16
|
-
"buildResources": "node_modules/react-native-electron-platform/src"
|
|
17
|
-
},
|
|
18
|
-
"publish": [
|
|
19
|
-
{
|
|
20
|
-
"provider": "generic",
|
|
21
|
-
"url": "https://yourdomain.com/updates/"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"files": [
|
|
25
|
-
"electron/**/*",
|
|
26
|
-
"web-build/**/*",
|
|
27
|
-
"package.json",
|
|
28
|
-
"!**/*.map",
|
|
29
|
-
"!**/*.md",
|
|
30
|
-
"!**/*.ts",
|
|
31
|
-
"!**/*.tsx",
|
|
32
|
-
"!**/*.log",
|
|
33
|
-
"!**/test/**",
|
|
34
|
-
"!**/__tests__/**",
|
|
35
|
-
"!**/tests/**",
|
|
36
|
-
"!**/docs/**",
|
|
37
|
-
"!**/example/**",
|
|
38
|
-
"!**/examples/**",
|
|
39
|
-
"!**/.vscode/**",
|
|
40
|
-
"!**/.github/**",
|
|
41
|
-
"!**/node_modules/.bin",
|
|
42
|
-
"!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md}",
|
|
43
|
-
"!**/node_modules/*/{test,__tests__,tests,example,examples}",
|
|
44
|
-
"!**/node_modules/**/*.d.ts",
|
|
45
|
-
"!**/android/**",
|
|
46
|
-
"!**/ios/**",
|
|
47
|
-
"!**/build/**",
|
|
48
|
-
"!**/*.gradle",
|
|
49
|
-
"!**/*.java",
|
|
50
|
-
"!**/*.kt",
|
|
51
|
-
"!**/node_modules/**/android/**",
|
|
52
|
-
"!**/node_modules/**/ios/**",
|
|
53
|
-
"!**/node_modules/**/build/**",
|
|
54
|
-
"!**/node_modules/react-native/**",
|
|
55
|
-
"!**/node_modules/react-native-*/*",
|
|
56
|
-
"!**/node_modules/rn-fetch-blob/**",
|
|
57
|
-
"!**/locales/**",
|
|
58
|
-
"node_modules/react-native-electron-platform/src/**/*"
|
|
59
|
-
],
|
|
60
|
-
"asarUnpack": [
|
|
61
|
-
"**/*.node"
|
|
62
|
-
],
|
|
63
|
-
"extraMetadata": {
|
|
64
|
-
"main": "node_modules/react-native-electron-platform/src/main.mjs"
|
|
65
|
-
},
|
|
66
|
-
"win": {
|
|
67
|
-
"target": [
|
|
68
|
-
{
|
|
69
|
-
"target": "nsis",
|
|
70
|
-
"arch": ["x64"]
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"target": "msi",
|
|
74
|
-
"arch": ["x64"]
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"icon": "electron/icon.ico"
|
|
78
|
-
},
|
|
79
|
-
"nsis": {
|
|
80
|
-
"oneClick": false,
|
|
81
|
-
"allowToChangeInstallationDirectory": true,
|
|
82
|
-
"createDesktopShortcut": true,
|
|
83
|
-
"createStartMenuShortcut": true,
|
|
84
|
-
"shortcutName": "ris",
|
|
85
|
-
"artifactName": "${productName} Setup ${version}.${ext}"
|
|
86
|
-
},
|
|
87
|
-
"msi": {
|
|
88
|
-
"oneClick": false,
|
|
89
|
-
"perMachine": true,
|
|
90
|
-
"createDesktopShortcut": true,
|
|
91
|
-
"createStartMenuShortcut": true,
|
|
92
|
-
"warningsAsErrors": false
|
|
93
|
-
}
|
|
94
|
-
}
|