@rozenite/plugin-bridge
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/channel/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,OAAO,CAmBlD,CAAC"} | ||
| {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/channel/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,OAAO,CAoBlD,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC,MAAM,MAAM,sBAAsB,CAChC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACjE;IACF,IAAI,EAAE,CAAC,KAAK,SAAS,MAAM,SAAS,EAClC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,KACtB,IAAI,CAAC;IACV,SAAS,EAAE,CAAC,KAAK,SAAS,MAAM,SAAS,EACvC,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,KAC1C,YAAY,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAgEF,eAAO,MAAM,yBAAyB,GACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEnE,UAAU,MAAM,KACf,OAAO,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAe3C,CAAC"} | ||
| {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,MAAM,MAAM,sBAAsB,CAChC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACjE;IACF,IAAI,EAAE,CAAC,KAAK,SAAS,MAAM,SAAS,EAClC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,KACtB,IAAI,CAAC;IACV,SAAS,EAAE,CAAC,KAAK,SAAS,MAAM,SAAS,EACvC,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,KAC1C,YAAY,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAgEF,eAAO,MAAM,yBAAyB,GACpC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEnE,UAAU,MAAM,KACf,OAAO,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAE3C,CAAC"} |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),w=()=>typeof window<"u"&&typeof window.document<"u";class _ extends Error{constructor(t){super(`Unsupported platform: ${t}`),this.name="UnsupportedPlatformError"}}const f="rozenite",m=()=>{const e=global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__,t=e.BINDING_NAME;return global[t]!=null?e.initializeDomain(f):null},D=()=>new Promise(e=>{const t=n=>{n.name===f&&(global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(t),setTimeout(()=>e(n)))};global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(t)}),v=async()=>{const e=new Set;let t=m();t||(t=await D());const n=()=>{if(!t)throw new Error("Domain not initialized");return t},r=s=>{s.name===f&&(t&&e.forEach(o=>{t.onMessage.removeEventListener(o)}),t=s,e.forEach(o=>{s.onMessage.addEventListener(o)}))};return global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(r),{send:s=>{n().sendMessage(s)},onMessage(s){const o=a=>{setTimeout(()=>{s(a)})};return e.add(o),n().onMessage.addEventListener(o),{remove:()=>{e.delete(o),n().onMessage.removeEventListener(o)}}},close:()=>{global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(r)}}},y=async()=>{if(w())throw new _("web");return v()},T=async()=>{const e=new Set,t=n=>{e.forEach(r=>{r(n.data)})};return window.addEventListener("message",t),{send:n=>{window.parent.postMessage({type:"rozenite-message",payload:n},"*")},onMessage:n=>(e.add(n),{remove:()=>{e.delete(n)}}),close:()=>{e.clear(),window.removeEventListener("message",t)}}};let u=null;const C=async()=>{if(u)return u;const t="__ROZENITE_PANEL__"in window?T():y();try{const n=await t;return u=n,n}catch(n){throw u=null,n}},h=e=>typeof e!="object"||e===null||!("type"in e)||!("payload"in e)||!("pluginId"in e)?null:e,E=new Map,S=async e=>{const t=await C(),n=new Map,r=async a=>{const i=h(a);if(!i||i.pluginId!==e)return;const l=n.get(i.type);l!=null&&l.forEach(p=>{p(i.payload)})},c=(a,i)=>{t.send({pluginId:e,type:a,payload:i})},s=t.onMessage(r);return{send:c,onMessage:(a,i)=>{const l=n.get(a)??new Set;return l.add(i),n.set(a,l),{remove:()=>{l.delete(i)}}},close:()=>{n.clear(),s.remove(),t.close()}}},g=async e=>{const t=E.get(e);if(t!=null)return t;const n=S(e);E.set(e,n);const r=await n;return E.set(e,r),r},L=({pluginId:e})=>{const[t,n]=d.useState(null),[r,c]=d.useState(null);if(d.useEffect(()=>{let s=!0,o=null;const a=async()=>{try{o=await g(e),s&&n(o)}catch(l){if(l instanceof _){console.warn(`[Rozenite, ${e}] Unsupported platform, skipping setup.`);return}console.error("Error setting up client",l),s&&c(l)}},i=async()=>{try{o!=null&&o.close()}catch{}};return a(),()=>{s=!1,i()}},[e]),r!=null)throw r;return t};exports.UnsupportedPlatformError=_;exports.getRozeniteDevToolsClient=g;exports.useRozeniteDevToolsClient=L; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),f=()=>typeof window<"u"&&typeof window.document<"u";class E extends Error{constructor(n){super(`Unsupported platform: ${n}`),this.name="UnsupportedPlatformError"}}const _="rozenite",w=()=>{const e=global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__,n=e.BINDING_NAME;return global[n]!=null?e.initializeDomain(_):null},m=()=>new Promise(e=>{const n=t=>{t.name===_&&(global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(n),setTimeout(()=>e(t)))};global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(n)}),D=async()=>{const e=new Set;let n=w();n||(n=await m());const t=()=>{if(!n)throw new Error("Domain not initialized");return n},l=s=>{s.name===_&&(n&&e.forEach(o=>{n.onMessage.removeEventListener(o)}),n=s,e.forEach(o=>{s.onMessage.addEventListener(o)}))};return global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(l),{send:s=>{t().sendMessage(s)},onMessage(s){const o=i=>{setTimeout(()=>{s(i)})};return e.add(o),t().onMessage.addEventListener(o),{remove:()=>{e.delete(o),t().onMessage.removeEventListener(o)}}},close:()=>{global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(l)}}},v=async()=>{if(f())throw new E("web");return D()},y=async()=>{const e=new Set,n=t=>{e.forEach(l=>{l(t.data)})};return window.addEventListener("message",n),{send:t=>{window.parent.postMessage({type:"rozenite-message",payload:t},"*")},onMessage:t=>(e.add(t),{remove:()=>{e.delete(t)}}),close:()=>{e.clear(),window.removeEventListener("message",n)}}};let c=null;const T=async()=>{if(c)return c;const n="__ROZENITE_PANEL__"in window?y():v();c=n;try{const t=await n;return c=t,t}catch(t){throw c=null,t}},h=e=>typeof e!="object"||e===null||!("type"in e)||!("payload"in e)||!("pluginId"in e)?null:e,C=async e=>{const n=await T(),t=new Map,l=async i=>{const r=h(i);if(!r||r.pluginId!==e)return;const a=t.get(r.type);a!=null&&a.forEach(p=>{p(r.payload)})},d=(i,r)=>{n.send({pluginId:e,type:i,payload:r})},s=n.onMessage(l);return{send:d,onMessage:(i,r)=>{const a=t.get(i)??new Set;return a.add(r),t.set(i,a),{remove:()=>{a.delete(r)}}},close:()=>{t.clear(),s.remove(),n.close()}}},g=async e=>C(e),S=({pluginId:e})=>{const[n,t]=u.useState(null),[l,d]=u.useState(null);if(u.useEffect(()=>{let s=!0,o=null;const i=async()=>{try{o=await g(e),s&&t(o)}catch(a){if(a instanceof E){console.warn(`[Rozenite, ${e}] Unsupported platform, skipping setup.`);return}console.error("Error setting up client",a),s&&d(a)}},r=async()=>{try{o!=null&&o.close()}catch{}};return i(),()=>{s=!1,r()}},[e]),l!=null)throw l;return n};exports.UnsupportedPlatformError=E;exports.getRozeniteDevToolsClient=g;exports.useRozeniteDevToolsClient=S; |
+89
-96
@@ -1,32 +0,32 @@ | ||
| import { useState as _, useEffect as p } from "react"; | ||
| const w = () => typeof window < "u" && typeof window.document < "u"; | ||
| class f extends Error { | ||
| constructor(t) { | ||
| super(`Unsupported platform: ${t}`), this.name = "UnsupportedPlatformError"; | ||
| import { useState as E, useEffect as f } from "react"; | ||
| const g = () => typeof window < "u" && typeof window.document < "u"; | ||
| class _ extends Error { | ||
| constructor(n) { | ||
| super(`Unsupported platform: ${n}`), this.name = "UnsupportedPlatformError"; | ||
| } | ||
| } | ||
| const E = "rozenite", m = () => { | ||
| const e = global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__, t = e.BINDING_NAME; | ||
| return global[t] != null ? e.initializeDomain(E) : null; | ||
| }, D = () => new Promise((e) => { | ||
| const t = (n) => { | ||
| n.name === E && (global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener( | ||
| t | ||
| ), setTimeout(() => e(n))); | ||
| const u = "rozenite", w = () => { | ||
| const e = global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__, n = e.BINDING_NAME; | ||
| return global[n] != null ? e.initializeDomain(u) : null; | ||
| }, m = () => new Promise((e) => { | ||
| const n = (t) => { | ||
| t.name === u && (global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener( | ||
| n | ||
| ), setTimeout(() => e(t))); | ||
| }; | ||
| global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener( | ||
| t | ||
| n | ||
| ); | ||
| }), v = async () => { | ||
| }), D = async () => { | ||
| const e = /* @__PURE__ */ new Set(); | ||
| let t = m(); | ||
| t || (t = await D()); | ||
| const n = () => { | ||
| if (!t) | ||
| let n = w(); | ||
| n || (n = await m()); | ||
| const t = () => { | ||
| if (!n) | ||
| throw new Error("Domain not initialized"); | ||
| return t; | ||
| }, r = (s) => { | ||
| s.name === E && (t && e.forEach((o) => { | ||
| t.onMessage.removeEventListener(o); | ||
| }), t = s, e.forEach((o) => { | ||
| return n; | ||
| }, l = (s) => { | ||
| s.name === u && (n && e.forEach((o) => { | ||
| n.onMessage.removeEventListener(o); | ||
| }), n = s, e.forEach((o) => { | ||
| s.onMessage.addEventListener(o); | ||
@@ -36,16 +36,16 @@ })); | ||
| return global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener( | ||
| r | ||
| l | ||
| ), { | ||
| send: (s) => { | ||
| n().sendMessage(s); | ||
| t().sendMessage(s); | ||
| }, | ||
| onMessage(s) { | ||
| const o = (a) => { | ||
| const o = (i) => { | ||
| setTimeout(() => { | ||
| s(a); | ||
| s(i); | ||
| }); | ||
| }; | ||
| return e.add(o), n().onMessage.addEventListener(o), { | ||
| return e.add(o), t().onMessage.addEventListener(o), { | ||
| remove: () => { | ||
| e.delete(o), n().onMessage.removeEventListener(o); | ||
| e.delete(o), t().onMessage.removeEventListener(o); | ||
| } | ||
@@ -56,67 +56,68 @@ }; | ||
| global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener( | ||
| r | ||
| l | ||
| ); | ||
| } | ||
| }; | ||
| }, v = async () => { | ||
| if (g()) | ||
| throw new _("web"); | ||
| return D(); | ||
| }, y = async () => { | ||
| if (w()) | ||
| throw new f("web"); | ||
| return v(); | ||
| }, h = async () => { | ||
| const e = /* @__PURE__ */ new Set(), t = (n) => { | ||
| e.forEach((r) => { | ||
| r(n.data); | ||
| const e = /* @__PURE__ */ new Set(), n = (t) => { | ||
| e.forEach((l) => { | ||
| l(t.data); | ||
| }); | ||
| }; | ||
| return window.addEventListener("message", t), { | ||
| send: (n) => { | ||
| return window.addEventListener("message", n), { | ||
| send: (t) => { | ||
| window.parent.postMessage( | ||
| { type: "rozenite-message", payload: n }, | ||
| { type: "rozenite-message", payload: t }, | ||
| "*" | ||
| ); | ||
| }, | ||
| onMessage: (n) => (e.add(n), { | ||
| onMessage: (t) => (e.add(t), { | ||
| remove: () => { | ||
| e.delete(n); | ||
| e.delete(t); | ||
| } | ||
| }), | ||
| close: () => { | ||
| e.clear(), window.removeEventListener("message", t); | ||
| e.clear(), window.removeEventListener("message", n); | ||
| } | ||
| }; | ||
| }; | ||
| let d = null; | ||
| const T = async () => { | ||
| if (d) | ||
| return d; | ||
| const t = "__ROZENITE_PANEL__" in window ? h() : y(); | ||
| let c = null; | ||
| const h = async () => { | ||
| if (c) | ||
| return c; | ||
| const n = "__ROZENITE_PANEL__" in window ? y() : v(); | ||
| c = n; | ||
| try { | ||
| const n = await t; | ||
| return d = n, n; | ||
| } catch (n) { | ||
| throw d = null, n; | ||
| const t = await n; | ||
| return c = t, t; | ||
| } catch (t) { | ||
| throw c = null, t; | ||
| } | ||
| }, C = (e) => typeof e != "object" || e === null || !("type" in e) || !("payload" in e) || !("pluginId" in e) ? null : e, u = /* @__PURE__ */ new Map(), L = async (e) => { | ||
| const t = await T(), n = /* @__PURE__ */ new Map(), r = async (a) => { | ||
| const i = C(a); | ||
| if (!i || i.pluginId !== e) | ||
| }, T = (e) => typeof e != "object" || e === null || !("type" in e) || !("payload" in e) || !("pluginId" in e) ? null : e, C = async (e) => { | ||
| const n = await h(), t = /* @__PURE__ */ new Map(), l = async (i) => { | ||
| const r = T(i); | ||
| if (!r || r.pluginId !== e) | ||
| return; | ||
| const l = n.get(i.type); | ||
| l != null && l.forEach((g) => { | ||
| g(i.payload); | ||
| const a = t.get(r.type); | ||
| a != null && a.forEach((p) => { | ||
| p(r.payload); | ||
| }); | ||
| }, c = (a, i) => { | ||
| t.send({ | ||
| }, d = (i, r) => { | ||
| n.send({ | ||
| pluginId: e, | ||
| type: a, | ||
| payload: i | ||
| type: i, | ||
| payload: r | ||
| }); | ||
| }, s = t.onMessage(r); | ||
| }, s = n.onMessage(l); | ||
| return { | ||
| send: c, | ||
| onMessage: (a, i) => { | ||
| const l = n.get(a) ?? /* @__PURE__ */ new Set(); | ||
| return l.add(i), n.set(a, l), { | ||
| send: d, | ||
| onMessage: (i, r) => { | ||
| const a = t.get(i) ?? /* @__PURE__ */ new Set(); | ||
| return a.add(r), t.set(i, a), { | ||
| remove: () => { | ||
| l.delete(i); | ||
| a.delete(r); | ||
| } | ||
@@ -126,24 +127,16 @@ }; | ||
| close: () => { | ||
| n.clear(), s.remove(), t.close(); | ||
| t.clear(), s.remove(), n.close(); | ||
| } | ||
| }; | ||
| }, M = async (e) => { | ||
| const t = u.get(e); | ||
| if (t != null) | ||
| return t; | ||
| const n = L(e); | ||
| u.set(e, n); | ||
| const r = await n; | ||
| return u.set(e, r), r; | ||
| }, O = ({ | ||
| }, L = async (e) => C(e), M = ({ | ||
| pluginId: e | ||
| }) => { | ||
| const [t, n] = _(null), [r, c] = _(null); | ||
| if (p(() => { | ||
| const [n, t] = E(null), [l, d] = E(null); | ||
| if (f(() => { | ||
| let s = !0, o = null; | ||
| const a = async () => { | ||
| const i = async () => { | ||
| try { | ||
| o = await M(e), s && n(o); | ||
| } catch (l) { | ||
| if (l instanceof f) { | ||
| o = await L(e), s && t(o); | ||
| } catch (a) { | ||
| if (a instanceof _) { | ||
| console.warn( | ||
@@ -154,5 +147,5 @@ `[Rozenite, ${e}] Unsupported platform, skipping setup.` | ||
| } | ||
| console.error("Error setting up client", l), s && c(l); | ||
| console.error("Error setting up client", a), s && d(a); | ||
| } | ||
| }, i = async () => { | ||
| }, r = async () => { | ||
| try { | ||
@@ -163,13 +156,13 @@ o != null && o.close(); | ||
| }; | ||
| return a(), () => { | ||
| s = !1, i(); | ||
| return i(), () => { | ||
| s = !1, r(); | ||
| }; | ||
| }, [e]), r != null) | ||
| throw r; | ||
| return t; | ||
| }, [e]), l != null) | ||
| throw l; | ||
| return n; | ||
| }; | ||
| export { | ||
| f as UnsupportedPlatformError, | ||
| M as getRozeniteDevToolsClient, | ||
| O as useRozeniteDevToolsClient | ||
| _ as UnsupportedPlatformError, | ||
| L as getRozeniteDevToolsClient, | ||
| M as useRozeniteDevToolsClient | ||
| }; |
+1
-1
| { | ||
| "name": "@rozenite/plugin-bridge", | ||
| "version": "1.0.0-alpha.11", | ||
| "version": "1.0.0-alpha.12", | ||
| "description": "Communication layer for React Native DevTools plugins across React Native and web environments", | ||
@@ -5,0 +5,0 @@ "type": "module", |
19629
-1.27%228
-3.39%