react-native-electron-platform 0.0.19 → 0.0.21
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/package.json +3 -2
- package/scripts/preelectron.mjs +23 -0
- package/src/modules/windowManager.js +4 -3
- package/webpack.config.mjs +5 -2
- /package/{test → templates}/electron/icon.ico +0 -0
- /package/{test → templates}/electron/index.js +0 -0
- /package/{test → templates}/electron/nonmodules.mjs +0 -0
- /package/{test → templates}/package.json +0 -0
- /package/{test → templates}/test.mjs +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-electron-platform",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "A boilerplate and utilities for running React Native applications in Electron",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -51,8 +51,9 @@
|
|
|
51
51
|
"files": [
|
|
52
52
|
"index.mjs",
|
|
53
53
|
"webpack.config.mjs",
|
|
54
|
+
"scripts/",
|
|
54
55
|
"src/",
|
|
55
|
-
"
|
|
56
|
+
"templates/",
|
|
56
57
|
"README.md",
|
|
57
58
|
"LICENSE",
|
|
58
59
|
"CHANGELOG.md",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
const src = path.join(
|
|
5
|
+
process.cwd(),
|
|
6
|
+
"node_modules",
|
|
7
|
+
"react-native-electron-platform",
|
|
8
|
+
"test",
|
|
9
|
+
"electron"
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const dest = path.join(process.cwd(), "electron");
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
if (!fs.existsSync(dest)) {
|
|
16
|
+
fs.cpSync(src, dest, { recursive: true });
|
|
17
|
+
console.log("Electron template copied successfully");
|
|
18
|
+
} else {
|
|
19
|
+
console.log("Electron folder already exists");
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error("Error copying electron folder:", err);
|
|
23
|
+
}
|
|
@@ -2,6 +2,7 @@ import { BrowserWindow, screen, session } from "electron";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { app, dialog } from "electron";
|
|
5
|
+
import { ApiUrl } from "react-native-electron-platform/webpack.config.mjs";
|
|
5
6
|
|
|
6
7
|
export function createMainWindow(__dirname) {
|
|
7
8
|
const primaryDisplay = screen.getPrimaryDisplay();
|
|
@@ -23,7 +24,7 @@ export function createMainWindow(__dirname) {
|
|
|
23
24
|
nodeIntegration: false,
|
|
24
25
|
contextIsolation: true,
|
|
25
26
|
sandbox: false,
|
|
26
|
-
webSecurity:
|
|
27
|
+
webSecurity: true,
|
|
27
28
|
disableBlinkFeatures: "AutoLoadIconsForPage",
|
|
28
29
|
nativeWindowOpen: true,
|
|
29
30
|
spellcheck: true,
|
|
@@ -90,8 +91,8 @@ function loadAppContent(mainWindow, __dirname) {
|
|
|
90
91
|
const isDev = isDevMode();
|
|
91
92
|
|
|
92
93
|
if (isDev) {
|
|
93
|
-
mainWindow.loadURL(
|
|
94
|
-
console.log("DEV MODE:
|
|
94
|
+
mainWindow.loadURL(ApiUrl);
|
|
95
|
+
console.log("DEV MODE:", ApiUrl);
|
|
95
96
|
} else {
|
|
96
97
|
const possiblePaths = [
|
|
97
98
|
path.join(__dirname, "web-build/index.html"),
|
package/webpack.config.mjs
CHANGED
|
@@ -8,6 +8,9 @@ import packageJson from '../../package.json' with { type: 'json' };
|
|
|
8
8
|
import { generateAlias, generateFallback } from './src/webpackConfigHelper.mjs';
|
|
9
9
|
|
|
10
10
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const port = process.env.PORT || 5001;
|
|
12
|
+
const host = process.env.HOST || 'localhost';
|
|
13
|
+
export const ApiUrl = `http://${host}:${port}`;
|
|
11
14
|
|
|
12
15
|
// Plugin to copy vector icon fonts
|
|
13
16
|
class CopyFontsPlugin {
|
|
@@ -42,8 +45,8 @@ export default {
|
|
|
42
45
|
devtool: 'source-map',
|
|
43
46
|
|
|
44
47
|
devServer: {
|
|
45
|
-
port:
|
|
46
|
-
host:
|
|
48
|
+
port: port,
|
|
49
|
+
host: host,
|
|
47
50
|
hot: true,
|
|
48
51
|
compress: true,
|
|
49
52
|
historyApiFallback: true,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|