UNPKG

edge-core-js

Version:

Edge account & wallet management library

53 lines (35 loc) 1.32 kB
const _jsxFileName = "src/io/react-native/react-native-webview.tsx";import '../../client-side' import * as React from 'react' import { requireNativeComponent } from 'react-native' import { makeYaobCallbacks, } from './yaob-callbacks' /** * Launches the Edge core worker in a WebView and returns its API. */ export class EdgeCoreBridge extends React.Component { constructor(props) { super(props) const { onError, onLoad } = props // Set up the YAOB bridge: this.callbacks = makeYaobCallbacks((root) => { onLoad(root).catch(onError) }) } render() { const { allowDebugging = false, debug = false, onError } = this.props return ( React.createElement(NativeWebView, { ref: this.callbacks.setRef, allowDebugging: debug || allowDebugging, source: debug ? 'http://localhost:8080/edge-core.js' : null, style: { opacity: 0, position: 'absolute', height: 1, width: 1 }, onMessage: this.callbacks.handleMessage, onScriptError: event => { if (onError != null) { onError(new Error(`Cannot load "${event.nativeEvent.source}"`)) } }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 36}} ) ) } } const NativeWebView = requireNativeComponent('EdgeCoreWebView')