UNPKG

one

Version:

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

49 lines (48 loc) • 2.06 kB
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-web"); const InsideContainer = (0, import_react.createContext)(false); const 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) { for (const child of import_react.Children.toArray(children)) { 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`); } }