WIP: Trying to get electron to work.
This commit is contained in:
parent
03e8ea921e
commit
06aa652a4e
|
@ -399,3 +399,12 @@ Temporary Items
|
||||||
|
|
||||||
.expo
|
.expo
|
||||||
.expo-shared
|
.expo-shared
|
||||||
|
|
||||||
|
|
||||||
|
# @generated: @expo/electron-adapter@0.0.14
|
||||||
|
/.expo/*
|
||||||
|
# Expo Web
|
||||||
|
/web-build/*
|
||||||
|
# electron-webpack
|
||||||
|
/dist
|
||||||
|
# @end @expo/electron-adapter
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
// temporary workaround for https://github.com/expo/expo-cli/issues/1385
|
||||||
|
// @ts-ignore
|
||||||
|
export { default } from './App.tsx';
|
|
@ -1,5 +1,6 @@
|
||||||
import React, {ReactElement} from 'react';
|
import React, {ReactElement} from 'react';
|
||||||
import {Button, Text, View} from 'react-native';
|
import {Button, Text, View} from 'react-native';
|
||||||
|
// @ts-ignore
|
||||||
import Barcode from 'react-native-barcode-builder';
|
import Barcode from 'react-native-barcode-builder';
|
||||||
import {BarCodeProps, ButtonProps, PrintingProps} from '../models/ElementProps';
|
import {BarCodeProps, ButtonProps, PrintingProps} from '../models/ElementProps';
|
||||||
import {styles} from './Styles';
|
import {styles} from './Styles';
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
const { withExpoAdapter } = require('@expo/electron-adapter');
|
||||||
|
|
||||||
|
module.exports = withExpoAdapter({
|
||||||
|
projectRoot: __dirname,
|
||||||
|
// Provide any overrides for electron-webpack: https://github.com/elecnpm i typescript electron -gtron-userland/electron-webpack/blob/master/docs/en/configuration.md
|
||||||
|
});
|
|
@ -0,0 +1,72 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { BrowserWindow, app } from 'electron';
|
||||||
|
import * as path from 'path';
|
||||||
|
import { format as formatUrl } from 'url';
|
||||||
|
|
||||||
|
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
|
// global reference to mainWindow (necessary to prevent window from being garbage collected)
|
||||||
|
let mainWindow;
|
||||||
|
|
||||||
|
function createMainWindow() {
|
||||||
|
const browserWindow = new BrowserWindow({ webPreferences: { nodeIntegration: true } });
|
||||||
|
|
||||||
|
if (isDevelopment) {
|
||||||
|
browserWindow.webContents.openDevTools();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDevelopment) {
|
||||||
|
browserWindow.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`);
|
||||||
|
} else {
|
||||||
|
browserWindow.loadURL(
|
||||||
|
formatUrl({
|
||||||
|
pathname: path.join(__dirname, 'index.html'),
|
||||||
|
protocol: 'file',
|
||||||
|
slashes: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
browserWindow.on('closed', () => {
|
||||||
|
mainWindow = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
browserWindow.webContents.on('devtools-opened', () => {
|
||||||
|
browserWindow.focus();
|
||||||
|
setImmediate(() => {
|
||||||
|
browserWindow.focus();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
browserWindow.webContents.executeJavaScript(`
|
||||||
|
navigator.mediaDevices.getUserMedia({video: true})
|
||||||
|
.then(function(stream) {
|
||||||
|
console.log('stream', stream);
|
||||||
|
}).catch(function() {
|
||||||
|
alert('could not connect stream');
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
return browserWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
// quit application when all windows are closed
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
// on macOS it is common for applications to stay open until the user explicitly quits
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
// on macOS it is common to re-create a window even after all windows have been closed
|
||||||
|
if (mainWindow === null) {
|
||||||
|
mainWindow = createMainWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// create main BrowserWindow when electron is ready
|
||||||
|
app.on('ready', () => {
|
||||||
|
mainWindow = createMainWindow();
|
||||||
|
});
|
|
@ -0,0 +1,5 @@
|
||||||
|
const { withExpoWebpack } = require('@expo/electron-adapter');
|
||||||
|
|
||||||
|
module.exports = config => {
|
||||||
|
return withExpoWebpack(config);
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
|
@ -5,19 +5,25 @@
|
||||||
"android": "expo start --android",
|
"android": "expo start --android",
|
||||||
"ios": "expo start --ios",
|
"ios": "expo start --ios",
|
||||||
"web": "expo start --web",
|
"web": "expo start --web",
|
||||||
"eject": "expo eject"
|
"eject": "expo eject",
|
||||||
|
"customize": "yarn expo-electron customize",
|
||||||
|
"desktop": "yarn expo-electron start",
|
||||||
|
"build:desktop": "yarn electron-webpack && yarn electron-builder --dir -c.compression=store -c.mac.identity=null (-c.compression=store"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-community/art": "^1.2.0",
|
"@expo/electron-adapter": "0.0.14",
|
||||||
|
"@expo/webpack-config": "^0.12.27",
|
||||||
|
"electron": "^10.1.0",
|
||||||
"expo": "~38.0.8",
|
"expo": "~38.0.8",
|
||||||
"expo-barcode-scanner": "~8.2.1",
|
"expo-barcode-scanner": "~8.2.1",
|
||||||
"expo-status-bar": "^1.0.2",
|
"expo-status-bar": "^1.0.2",
|
||||||
"jsbarcode": "^3.11.0",
|
"jsbarcode": "^3.11.0",
|
||||||
|
"node-hid": "^1.3.0",
|
||||||
"react": "~16.11.0",
|
"react": "~16.11.0",
|
||||||
"react-dom": "~16.11.0",
|
"react-dom": "~16.11.0",
|
||||||
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
|
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
|
||||||
"react-native-barcode-builder": "github:cdesch/react-native-barcode-builder#master",
|
"react-native-barcode-builder": "github:cdesch/react-native-barcode-builder#master",
|
||||||
"react-native-web": "~0.11.7"
|
"react-native-web": "^0.11.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.8.6",
|
"@babel/core": "^7.8.6",
|
||||||
|
@ -25,5 +31,28 @@
|
||||||
"@types/react-native": "~0.62.13",
|
"@types/react-native": "~0.62.13",
|
||||||
"typescript": "~3.9.5"
|
"typescript": "~3.9.5"
|
||||||
},
|
},
|
||||||
"private": true
|
"private": true,
|
||||||
|
"build": {
|
||||||
|
"extraMetadata": {
|
||||||
|
"main": "main.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"from": "dist/main/",
|
||||||
|
"to": "./",
|
||||||
|
"filter": [
|
||||||
|
"**/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "dist/renderer",
|
||||||
|
"to": "./",
|
||||||
|
"filter": [
|
||||||
|
"**/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"package.json",
|
||||||
|
"**/node_modules/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue