UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

68 lines (66 loc) • 2.59 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var containerChildren_exports = {}; __export(containerChildren_exports, { InsideContainer: () => InsideContainer, assertOneNativeChildren: () => assertOneNativeChildren }); module.exports = __toCommonJS(containerChildren_exports); var import_react = require("react"); var import_react_native = require("react-native"); var InsideContainer = (0, import_react.createContext)(false); var reactNativeChildren = new Set([ import_react_native.View, import_react_native.Text, import_react_native.Image, import_react_native.ScrollView, import_react_native.TextInput ].filter(Boolean)); function assertOneNativeChildren(children, owner) { var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0; try { for (var _iterator = import_react.Children.toArray(children)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var child = _step.value; if (child === null || child === void 0 || typeof child === "boolean") continue; if (typeof child === "string" || typeof child === "number") throw new Error(`${owner} takes SwiftUI children, not raw text or numbers`); if (!(0, import_react.isValidElement)(child)) continue; if (child.type === import_react.Fragment) { assertOneNativeChildren(child.props.children, owner); continue; } if (typeof child.type === "string" || reactNativeChildren.has(child.type)) throw new Error(`${owner} takes SwiftUI children; move React Native content into Swift.Slot`); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } }