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.

36 lines (35 loc) 1.18 kB
import { jsx as e, Fragment as l } from "react/jsx-runtime"; import { useRozeniteDevToolsClient as f } from "@rozenite/plugin-bridge"; import { useState as m, useEffect as v } from "react"; import { SafeAreaView as w } from "react-native"; import { P, g } from "./setup-plugin-wfDE4zX1.js"; import { r as x } from "./setup-plugin-wfDE4zX1.js"; function D(n) { return process.env.NODE_ENV !== "development" ? /* @__PURE__ */ e(l, { children: n.children }) : /* @__PURE__ */ e(E, { ...n }); } const E = (n) => { const { children: c } = n, r = f({ pluginId: P }), [, o] = m(null), [t, s] = m(null); return v(() => { if (!r) return; const p = r.onMessage( "preview-select", (i) => { o(i.name); const a = g(i.name); s(() => a || null); } ), u = r.onMessage("show-main-app", () => { o(null), s(null); }); return () => { p.remove(), u.remove(); }; }, [r]), t ? /* @__PURE__ */ e(w, { children: /* @__PURE__ */ e(t, {}) }) : /* @__PURE__ */ e(l, { children: c }); }; process.env.NODE_ENV !== "production" && require("./setup-plugin.js"); export { D as PreviewHost, x as registerPreview };