1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Getting backend/frontend bridge to work

This commit is contained in:
Laurent Cozic 2017-11-04 15:42:20 +00:00
parent d35bd7906b
commit 243d6e9845
9 changed files with 1088 additions and 17 deletions

View File

@ -1,4 +1,5 @@
build/
app/locales/
app/node_modules/
app/lib/
app/lib/
*.min.js

View File

@ -0,0 +1,27 @@
const React = require('react');
const { render } = require('react-dom');
const { createStore } = require('redux');
const { Provider } = require('react-redux');
const { app } = require('electron').remote.require('./app');
class ReactRoot extends React.Component {
render() {
return (
<div>
Aaaa
</div>
)
}
}
const store = app().store();
render(
<Provider store={store}>
<ReactRoot />
</Provider>,
document.getElementById('react-root')
)

View File

@ -67,11 +67,13 @@ class Application extends BaseApplication {
let application_ = null;
function app() {
console.info('AAAAAAAAA');
if (!application_) throw new Error('Application has not been initialized');
return application_;
}
function initApp(electronApp) {
console.info('INIT');
if (application_) throw new Error('Application has already been initialized');
application_ = new Application(electronApp);
return application_;

View File

@ -1,2 +0,0 @@
require('app-module-path').addPath(__dirname);
const app = require('./app.js').app;

View File

@ -1,17 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<script src="app.js"></script>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
<script>
//console.info(initApp);
</script>
</body>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
<div id="react-root"></div>
<script src="ReactRoot.min.js"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,8 @@
},
"homepage": "https://github.com/laurent22/joplin#readme",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-react": "^6.24.1",
"electron": "^1.7.9",
"electron-builder": "^19.43.4",
"electron-rebuild": "^1.6.0"
@ -30,6 +32,9 @@
"node-fetch": "^1.7.3",
"promise": "^8.0.1",
"query-string": "^5.0.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"sprintf-js": "^1.1.1",
"sqlite3": "^3.1.13",

View File

@ -5,6 +5,11 @@ BUILD_DIR="$ROOT_DIR/app"
rsync -a "$ROOT_DIR/../ReactNativeClient/lib/" "$BUILD_DIR/lib/"
for JSX_FILE in "$BUILD_DIR"/*.jsx; do
JS_FILE="${JSX_FILE::-4}.min.js"
"$ROOT_DIR/app/node_modules/.bin/babel" --presets react "$JSX_FILE" > "$JS_FILE"
done
TRANSLATION_BUILD_SCRIPT="$ROOT_DIR/../CliClient/build/build-translation.js"
if [[ ! -f $TRANSLATION_BUILD_SCRIPT ]]; then
echo "Build the CLI app first ($TRANSLATION_BUILD_SCRIPT missing)"

View File

@ -15,6 +15,7 @@
"package-lock.json",
"ReactNativeClient/locales/*",
"src/log.txt",
"*.min.js",
],
"folder_exclude_patterns":
[