@rozenite/plugin-bridge
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"cdp-channel.d.ts","sourceRoot":"","sources":["../../../src/channel/device/cdp-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAE5D,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE;QACT,gBAAgB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;QACzD,mBAAmB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;KAC7D,CAAC;IACF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAkGF,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,OAAO,CAErD,CAAC"} | ||
| {"version":3,"file":"cdp-channel.d.ts","sourceRoot":"","sources":["../../../src/channel/device/cdp-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAE5D,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE;QACT,gBAAgB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;QACzD,mBAAmB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;KAC7D,CAAC;IACF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AA0GF,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,OAAO,CAErD,CAAC"} |
@@ -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;AAElC,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,OAAO,CAQlD,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,CAgBlD,CAAC"} |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),d="rozenite",D=()=>{const e=global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__,n=e.BINDING_NAME;return global[n]!=null?e.initializeDomain(d):null},v=()=>new Promise(e=>{const n=t=>{t.name===d&&(global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(n),setTimeout(()=>e(t)))};global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(n)}),f=async()=>{const e=new Set;let n=D();n||(n=await v());const t=()=>{if(!n)throw new Error("Domain not initialized");return n},s=o=>{o.name===d&&(n&&e.forEach(r=>{n.onMessage.removeEventListener(r)}),n=o,e.forEach(r=>{o.onMessage.addEventListener(r)}))};return global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(s),{send:o=>{t().sendMessage(o)},onMessage(o){return e.add(o),t().onMessage.addEventListener(o),{remove:()=>{e.delete(o),t().onMessage.removeEventListener(o)}}},close:()=>{global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(s)}}},T=async()=>f(),w=async()=>{const e=new Set,n=t=>{e.forEach(s=>{s(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)}}},C=async()=>"__ROZENITE_PANEL__"in window?w():T(),m=e=>typeof e!="object"||e===null||!("type"in e)||!("payload"in e)||!("pluginId"in e)?null:e,E=new Map,y=async e=>{const n=await C(),t=new Map,s=async l=>{const i=m(l);if(!i||i.pluginId!==e)return;const a=t.get(i.type);a!=null&&a.forEach(g=>{g(i.payload)})},c=(l,i)=>{n.send({pluginId:e,type:l,payload:i})},o=n.onMessage(s);return{send:c,onMessage:(l,i)=>{const a=t.get(l)??new Set;return a.add(i),t.set(l,a),{remove:()=>{a.delete(i)}}},close:()=>{t.clear(),o.remove(),n.close()}}},_=async e=>{const n=E.get(e);if(n!=null)return n;const t=y(e);E.set(e,t);const s=await t;return E.set(e,s),s},S=({pluginId:e})=>{const[n,t]=u.useState(null),[s,c]=u.useState(null);if(u.useEffect(()=>{let o=!0,r=null;const l=async()=>{try{r=await _(e),o&&t(r)}catch(a){console.error("Error setting up client",a),o&&c(a)}},i=async()=>{try{r!=null&&r.close()}catch{}};return l(),()=>{o=!1,i()}},[e]),s!=null)throw s;return n};exports.getRozeniteDevToolsClient=_;exports.useRozeniteDevToolsClient=S; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),_="rozenite",v=()=>{const e=global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__,n=e.BINDING_NAME;return global[n]!=null?e.initializeDomain(_):null},T=()=>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)}),f=async()=>{const e=new Set;let n=v();n||(n=await T());const t=()=>{if(!n)throw new Error("Domain not initialized");return n},i=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(i),{send:s=>{t().sendMessage(s)},onMessage(s){const o=a=>{setTimeout(()=>{s(a)})};return e.add(o),t().onMessage.addEventListener(o),{remove:()=>{e.delete(o),t().onMessage.removeEventListener(o)}}},close:()=>{global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener(i)}}},m=async()=>f(),w=async()=>{const e=new Set,n=t=>{e.forEach(i=>{i(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 y=async()=>c||(c="__ROZENITE_PANEL__"in window?w():m(),c.then(n=>{c=n}),c),C=e=>typeof e!="object"||e===null||!("type"in e)||!("payload"in e)||!("pluginId"in e)?null:e,E=new Map,S=async e=>{const n=await y(),t=new Map,i=async a=>{const r=C(a);if(!r||r.pluginId!==e)return;const l=t.get(r.type);l!=null&&l.forEach(D=>{D(r.payload)})},u=(a,r)=>{n.send({pluginId:e,type:a,payload:r})},s=n.onMessage(i);return{send:u,onMessage:(a,r)=>{const l=t.get(a)??new Set;return l.add(r),t.set(a,l),{remove:()=>{l.delete(r)}}},close:()=>{t.clear(),s.remove(),n.close()}}},g=async e=>{const n=E.get(e);if(n!=null)return n;const t=S(e);E.set(e,t);const i=await t;return E.set(e,i),i},L=({pluginId:e})=>{const[n,t]=d.useState(null),[i,u]=d.useState(null);if(d.useEffect(()=>{let s=!0,o=null;const a=async()=>{try{o=await g(e),s&&t(o)}catch(l){console.error("Error setting up client",l),s&&u(l)}},r=async()=>{try{o!=null&&o.close()}catch{}};return a(),()=>{s=!1,r()}},[e]),i!=null)throw i;return n};exports.getRozeniteDevToolsClient=g;exports.useRozeniteDevToolsClient=L; |
+66
-57
@@ -1,6 +0,6 @@ | ||
| import { useState as d, useEffect as g } from "react"; | ||
| const _ = "rozenite", D = () => { | ||
| import { useState as u, useEffect as D } from "react"; | ||
| const _ = "rozenite", f = () => { | ||
| const e = global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__, n = e.BINDING_NAME; | ||
| return global[n] != null ? e.initializeDomain(_) : null; | ||
| }, f = () => new Promise((e) => { | ||
| }, m = () => new Promise((e) => { | ||
| const n = (t) => { | ||
@@ -16,4 +16,4 @@ t.name === _ && (global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener( | ||
| const e = /* @__PURE__ */ new Set(); | ||
| let n = D(); | ||
| n || (n = await f()); | ||
| let n = f(); | ||
| n || (n = await m()); | ||
| const t = () => { | ||
@@ -23,16 +23,21 @@ if (!n) | ||
| return n; | ||
| }, s = (o) => { | ||
| o.name === _ && (n && e.forEach((r) => { | ||
| n.onMessage.removeEventListener(r); | ||
| }), n = o, e.forEach((r) => { | ||
| o.onMessage.addEventListener(r); | ||
| }, i = (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( | ||
| s | ||
| i | ||
| ), { | ||
| send: (o) => { | ||
| t().sendMessage(o); | ||
| send: (s) => { | ||
| t().sendMessage(s); | ||
| }, | ||
| onMessage(o) { | ||
| onMessage(s) { | ||
| const o = (a) => { | ||
| setTimeout(() => { | ||
| s(a); | ||
| }); | ||
| }; | ||
| return e.add(o), t().onMessage.addEventListener(o), { | ||
@@ -46,10 +51,10 @@ remove: () => { | ||
| global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.removeEventListener( | ||
| s | ||
| i | ||
| ); | ||
| } | ||
| }; | ||
| }, m = async () => v(), w = async () => { | ||
| }, w = async () => v(), T = async () => { | ||
| const e = /* @__PURE__ */ new Set(), n = (t) => { | ||
| e.forEach((s) => { | ||
| s(t.data); | ||
| e.forEach((i) => { | ||
| i(t.data); | ||
| }); | ||
@@ -73,25 +78,29 @@ }; | ||
| }; | ||
| }, C = async () => "__ROZENITE_PANEL__" in window ? w() : m(), T = (e) => typeof e != "object" || e === null || !("type" in e) || !("payload" in e) || !("pluginId" in e) ? null : e, E = /* @__PURE__ */ new Map(), y = async (e) => { | ||
| const n = await C(), t = /* @__PURE__ */ new Map(), s = async (l) => { | ||
| const i = T(l); | ||
| if (!i || i.pluginId !== e) | ||
| }; | ||
| let c = null; | ||
| const y = async () => c || (c = "__ROZENITE_PANEL__" in window ? T() : w(), c.then((n) => { | ||
| c = n; | ||
| }), c), C = (e) => typeof e != "object" || e === null || !("type" in e) || !("payload" in e) || !("pluginId" in e) ? null : e, d = /* @__PURE__ */ new Map(), L = async (e) => { | ||
| const n = await y(), t = /* @__PURE__ */ new Map(), i = async (a) => { | ||
| const r = C(a); | ||
| if (!r || r.pluginId !== e) | ||
| return; | ||
| const a = t.get(i.type); | ||
| a != null && a.forEach((u) => { | ||
| u(i.payload); | ||
| const l = t.get(r.type); | ||
| l != null && l.forEach((g) => { | ||
| g(r.payload); | ||
| }); | ||
| }, c = (l, i) => { | ||
| }, E = (a, r) => { | ||
| n.send({ | ||
| pluginId: e, | ||
| type: l, | ||
| payload: i | ||
| type: a, | ||
| payload: r | ||
| }); | ||
| }, o = n.onMessage(s); | ||
| }, s = n.onMessage(i); | ||
| return { | ||
| send: c, | ||
| onMessage: (l, i) => { | ||
| const a = t.get(l) ?? /* @__PURE__ */ new Set(); | ||
| return a.add(i), t.set(l, a), { | ||
| send: E, | ||
| onMessage: (a, r) => { | ||
| const l = t.get(a) ?? /* @__PURE__ */ new Set(); | ||
| return l.add(r), t.set(a, l), { | ||
| remove: () => { | ||
| a.delete(i); | ||
| l.delete(r); | ||
| } | ||
@@ -101,41 +110,41 @@ }; | ||
| close: () => { | ||
| t.clear(), o.remove(), n.close(); | ||
| t.clear(), s.remove(), n.close(); | ||
| } | ||
| }; | ||
| }, L = async (e) => { | ||
| const n = E.get(e); | ||
| }, M = async (e) => { | ||
| const n = d.get(e); | ||
| if (n != null) | ||
| return n; | ||
| const t = y(e); | ||
| E.set(e, t); | ||
| const s = await t; | ||
| return E.set(e, s), s; | ||
| }, S = ({ | ||
| const t = L(e); | ||
| d.set(e, t); | ||
| const i = await t; | ||
| return d.set(e, i), i; | ||
| }, h = ({ | ||
| pluginId: e | ||
| }) => { | ||
| const [n, t] = d(null), [s, c] = d(null); | ||
| if (g(() => { | ||
| let o = !0, r = null; | ||
| const l = async () => { | ||
| const [n, t] = u(null), [i, E] = u(null); | ||
| if (D(() => { | ||
| let s = !0, o = null; | ||
| const a = async () => { | ||
| try { | ||
| r = await L(e), o && t(r); | ||
| } catch (a) { | ||
| console.error("Error setting up client", a), o && c(a); | ||
| o = await M(e), s && t(o); | ||
| } catch (l) { | ||
| console.error("Error setting up client", l), s && E(l); | ||
| } | ||
| }, i = async () => { | ||
| }, r = async () => { | ||
| try { | ||
| r != null && r.close(); | ||
| o != null && o.close(); | ||
| } catch { | ||
| } | ||
| }; | ||
| return l(), () => { | ||
| o = !1, i(); | ||
| return a(), () => { | ||
| s = !1, r(); | ||
| }; | ||
| }, [e]), s != null) | ||
| throw s; | ||
| }, [e]), i != null) | ||
| throw i; | ||
| return n; | ||
| }; | ||
| export { | ||
| L as getRozeniteDevToolsClient, | ||
| S as useRozeniteDevToolsClient | ||
| M as getRozeniteDevToolsClient, | ||
| h as useRozeniteDevToolsClient | ||
| }; |
+1
-1
| { | ||
| "name": "@rozenite/plugin-bridge", | ||
| "version": "1.0.0-alpha.8", | ||
| "version": "1.0.0-alpha.9", | ||
| "description": "Communication layer for React Native DevTools plugins across React Native and web environments", | ||
@@ -5,0 +5,0 @@ "type": "module", |
18349
1.28%204
4.62%