one
Version:
One is a React framework for web, iOS, and Android apps.
58 lines (56 loc) • 2.55 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var index_native_exports = {};
__export(index_native_exports, { SwiftPackageView: () => SwiftPackageView });
module.exports = __toCommonJS(index_native_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_OneSwiftHostNativeComponent = __toESM(require("../specs/OneSwiftHostNativeComponent.native.js"), 1);
var import_wire = require("../native-source/wire.native.js");
function SwiftPackageView(param) {
var { packageName, view, contractHash, props, fill, wires } = param;
var encoded = wires ? (0, import_wire.encodeNativeSourceProps)(props, wires.props, wires.structs) : props;
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneSwiftHostNativeComponent.default, {
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 ? (0, import_wire.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
});
}