one
Version:
One is a React framework for web, iOS, and Android apps.
31 lines (28 loc) • 1.27 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import NativeSwiftHost from "../specs/OneSwiftHostNativeComponent.native.js";
import { decodeNativeSourceCallback, encodeNativeSourceProps } from "../native-source/wire.native.js";
function SwiftPackageView(param) {
var { packageName, view, contractHash, props, fill, wires } = param;
var encoded = wires ? encodeNativeSourceProps(props, wires.props, wires.structs) : props;
return /* @__PURE__ */ jsx(NativeSwiftHost, {
packageName,
view,
contractHash,
props: JSON.stringify(encoded, function(_key, value) {
return typeof value === "function" ? true : value;
}),
fill,
onHostEvent: function onHostEvent(event) {
var callback = props[event.nativeEvent.name];
if (typeof callback === "function") {
var _ref;
var args = JSON.parse(event.nativeEvent.args);
var argWires = wires === null || wires === void 0 ? void 0 : wires.callbacks[event.nativeEvent.name];
callback(...argWires ? decodeNativeSourceCallback(args, argWires, (_ref = wires === null || wires === void 0 ? void 0 : wires.structs) !== null && _ref !== void 0 ? _ref : {}, event.nativeEvent.name) : args);
}
},
style: fill ? { flex: 1 } : void 0
});
}
export { SwiftPackageView };
//# sourceMappingURL=index.native.js.map