This commit is contained in:
Zef Hemel
2022-03-07 10:21:02 +01:00
parent b6046ca974
commit 653e77c4dd
32 changed files with 7274 additions and 323 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
}
+14
View File
@@ -0,0 +1,14 @@
node_modules/
.expo/
dist/
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/
# macOS
.DS_Store
+47
View File
@@ -0,0 +1,47 @@
import { StatusBar } from "expo-status-bar";
import React from "react";
import { SafeAreaView, StyleSheet, Text, View } from "react-native";
import { WebView } from "react-native-webview";
function safeRun(fn: () => Promise<void>) {
return fn().catch((e) => {
console.error(e);
});
}
export default function App() {
const html = require("./bundle.json");
let ref = React.useRef<WebView>(null);
return (
<SafeAreaView style={styles.container}>
<Text
style={{
color: "#fff",
backgroundColor: "#333",
height: 40,
}}
onPress={() => {
ref.current?.injectJavaScript('receiveMessage("Sup");');
}}
>
This is a header
</Text>
<WebView
style={styles.container}
ref={ref}
originWhitelist={["*"]}
source={{ html: html.html }}
onMessage={(event) => {
console.log("Got event", event.nativeEvent.data);
}}
/>
<StatusBar style="auto" />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
+32
View File
@@ -0,0 +1,32 @@
{
"expo": {
"name": "mobile",
"slug": "mobile",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

+6
View File
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
+1
View File
@@ -0,0 +1 @@
{ "html": "<h1><center>Hello world!!</center></h1>" }
+6
View File
@@ -0,0 +1,6 @@
import json
html = open("dist/index.html", "r").read()
f = open("bundle.json", "w")
f.write(json.dumps({"html": html}))
f.close()
File diff suppressed because one or more lines are too long
+48
View File
@@ -0,0 +1,48 @@
import { Editor } from "../../webapp/src/editor";
import { HttpRemoteSpace } from "../../webapp/src/space";
declare namespace window {
var ReactNativeWebView: any;
var receiveMessage: any;
}
function safeRun(fn: () => Promise<void>) {
fn().catch((e) => {
console.error(e);
});
}
window.receiveMessage = (msg: string) => {
console.log("Received message", msg);
};
// @ts-ignore
window.onerror = (msg, source, lineno, colno, error) => {
console.error("Error", msg, source, lineno, error);
};
console.log = (...args) => {
window.ReactNativeWebView.postMessage(
JSON.stringify({ type: "console.log", args: args })
);
};
console.error = (...args) => {
window.ReactNativeWebView.postMessage(
JSON.stringify({ type: "console.error", args: args })
);
};
try {
let editor = new Editor(
new HttpRemoteSpace(`http://192.168.2.22:3000/fs`, null),
document.getElementById("root")!
);
console.log("Initing editor");
safeRun(async () => {
await editor.loadPageList();
await editor.loadPlugs();
editor.focus();
console.log("Inited", editor.viewState);
});
} catch (e: any) {
console.error("Got an error", e.message);
}
+19
View File
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Page</title>
<style>
@import "../../webapp/src/styles/main.scss";
</style>
<script type="module" src="boot.ts"></script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
</head>
<body>
<div id="root"></div>
<script type="module">
import "./boot";
</script>
</body>
</html>
+31
View File
@@ -0,0 +1,31 @@
{
"name": "mobile",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-fs": "^2.19.0",
"react-native-web": "0.17.1",
"react-native-webview": "11.15.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@parcel/transformer-sass": "2.3.2",
"@types/react": "~17.0.21",
"@types/react-native": "~0.64.12",
"parcel": "^2.3.2",
"typescript": "~4.3.5"
},
"private": true
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true
}
}
+6892
View File
File diff suppressed because it is too large Load Diff