UNPKG

rozenite-preview

Version:

A Rozenite plugin that lets you select React Native components in DevTools and preview them live on your simulator. Ideal for rapid UI development, component testing, and debugging complex apps.

2 lines (1 loc) 939 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("@rozenite/plugin-bridge"),r=require("react"),g=require("react-native"),s=require("./setup-plugin-Cz-cTgEb.cjs");function w(n){return process.env.NODE_ENV!=="development"?e.jsx(e.Fragment,{children:n.children}):e.jsx(P,{...n})}const P=n=>{const{children:l}=n,t=p.useRozeniteDevToolsClient({pluginId:s.PREVIEW_PLUGIN_ID}),[,i]=r.useState(null),[o,u]=r.useState(null);return r.useEffect(()=>{if(!t)return;const a=t.onMessage("preview-select",c=>{i(c.name);const v=s.getComponentByName(c.name);u(()=>v||null)}),m=t.onMessage("show-main-app",()=>{i(null),u(null)});return()=>{a.remove(),m.remove()}},[t]),o?e.jsx(g.SafeAreaView,{children:e.jsx(o,{})}):e.jsx(e.Fragment,{children:l})};process.env.NODE_ENV!=="production"&&require("./setup-plugin.cjs");exports.registerPreview=s.registerPreview;exports.PreviewHost=w;