@cowprotocol/widget-react 0.5.0-RC.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.mjs +79 -88
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var V=Object.defineProperty;var b=(n,e,t)=>e in n?V(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var p=(n,e,t)=>(b(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),d=require("react"),S="cowSwapWidget";function R(n,e,t){const s={key:S,method:e,...typeof t=="object"?t:{}};n.postMessage(s,"*")}function P(n,e,t){const r=s=>{!N(s.data)||s.data.key!==S||s.data.method!==e||t(s.data)};return n.addEventListener("message",r),r}function N(n){return typeof n=="object"&&n!==null&&"key"in n&&"method"in n&&typeof n.key=="string"&&typeof n.method=="string"}function O(n,e,t){n.removeEventListener("message",t)}function _(n,e){n.removeEventListener("message",e)}var l=(n=>(n.ACTIVATE="ACTIVATE",n.UPDATE_HEIGHT="UPDATE_HEIGHT",n.EMIT_COW_EVENT="EMIT_COW_EVENT",n.PROVIDER_RPC_REQUEST="PROVIDER_RPC_REQUEST",n))(l||{}),w=(n=>(n.UPDATE_PARAMS="UPDATE_PARAMS",n.UPDATE_APP_DATA="UPDATE_APP_DATA",n.PROVIDER_RPC_RESPONSE="PROVIDER_RPC_RESPONSE",n.PROVIDER_ON_EVENT="PROVIDER_ON_EVENT",n))(w||{}),A=(n=>(n.SWAP="swap",n.LIMIT="limit",n.ADVANCED="advanced",n))(A||{});const F=["connect","disconnect","close","chainChanged","accountsChanged"];class H{constructor(e){p(this,"ethereumProvider",null);p(this,"requestWaitingForConnection",{});p(this,"processRpcCallFromWindow",({rpcRequest:e})=>{if(!this.ethereumProvider){e.id&&(this.requestWaitingForConnection[e.id]=e);return}this.processRpcRequest(e)});this.iframeWidow=e}disconnect(){this.ethereumProvider=null,O(window,l.PROVIDER_RPC_REQUEST,this.processRpcCallFromWindow)}onConnect(e){this.ethereumProvider?this.disconnect():P(window,l.PROVIDER_RPC_REQUEST,this.processRpcCallFromWindow),this.ethereumProvider=e,this.processPendingRequests(),F.forEach(t=>{e.on(t,r=>this.onProviderEvent(t,r))})}processPendingRequests(){Object.keys(this.requestWaitingForConnection).forEach(e=>{this.processRpcRequest(this.requestWaitingForConnection[e])}),this.requestWaitingForConnection={}}processRpcRequest(e){const{id:t,jsonrpc:r,method:s}=e;if(!this.ethereumProvider||!t)return;(s==="enable"?this.ethereumProvider.enable():this.ethereumProvider.request({...e,id:t})).then(i=>this.forwardRpcResponseToIframe({rpcResponse:{jsonrpc:r,id:t,result:i}})).catch(i=>this.forwardRpcResponseToIframe({rpcResponse:{jsonrpc:r,id:t,error:i}}))}onProviderEvent(e,t){R(this.iframeWidow,w.PROVIDER_ON_EVENT,{event:e,params:t})}forwardRpcResponseToIframe(e){R(this.iframeWidow,w.PROVIDER_RPC_RESPONSE,e)}}const I="_";function M(n){const e=typeof n.baseUrl=="string"?n.baseUrl:"https://swap.cow.fi",t=L(n),r=y(n);return e+"/#"+t+"?"+r}function L(n){const{chainId:e=1,sell:t,buy:r,tradeType:s=A.SWAP}=n,c=[(t==null?void 0:t.asset)||I,(r==null?void 0:r.asset)||I].map(encodeURIComponent).join("/");return`/${e}/widget/${s}/${c}`}function y(n){const{sell:e,buy:t,theme:r}=n,s=new URLSearchParams;return e!=null&&e.amount&&s.append("sellAmount",e.amount),t!=null&&t.amount&&s.append("buyAmount",t.amount),r&&s.append("theme",typeof r=="string"?r:r.baseTheme),s}class q{constructor(){p(this,"subscriptions",{})}on(e){const{event:t,handler:r}=e;this.subscriptions[t]||(this.subscriptions[t]=[]),this.subscriptions[t].push(r)}off(e){const{event:t,handler:r}=e;this.subscriptions[t]&&(this.subscriptions[t]=this.subscriptions[t].filter(s=>s!==r))}emit(e,t){this.subscriptions[e]&&this.subscriptions[e].forEach(r=>r(t))}}let x=1;class G{constructor(e,t=[]){p(this,"eventEmitter",new q);p(this,"listeners",[]);p(this,"widgetListener");p(this,"instanceNumber",x++);this.contentWindow=e,this.updateListeners(t),this.widgetListener=P(this.contentWindow,l.EMIT_COW_EVENT,r=>this.eventEmitter.emit(r.event,r.payload))}stopListeningIframe(){_(this.contentWindow,this.widgetListener)}updateListeners(e){for(const t of this.listeners)this.eventEmitter.off(t);this.listeners=e||[];for(const t of this.listeners)this.eventEmitter.on(t)}}const U="640px",$="450px",k=20;function T(n,e){const{params:t,provider:r,listeners:s}=e;let c=r;const i=j(t);n.innerHTML="",n.appendChild(i);const{contentWindow:a}=i;if(!a)throw console.error("Iframe does not contain a window",i),new Error("Iframe does not contain a window!");const m=[];m.push(Q(a,t.appCode)),m.push(J(i,t.height));const E=new G(window,s);let u=W(a,null,c);return i.addEventListener("load",()=>D(a,t,c)),{updateParams:o=>D(a,o,c),updateListeners:o=>E.updateListeners(o),updateProvider:o=>{c=o,u=W(a,u,o)},destroy:()=>{E.stopListeningIframe(),m.forEach(o=>window.removeEventListener("message",o)),n.removeChild(i)}}}function W(n,e,t){e&&e.disconnect();const r=e||new H(n);return t&&r.onConnect(t),r}function j(n){const{width:e=$,height:t=U}=n,r=document.createElement("iframe");return r.src=M(n),r.width=e,r.height=t,r.style.border="0",r}function D(n,e,t){const r=!!t,s=L(e),c=y(e).toString();R(n,w.UPDATE_PARAMS,{urlParams:{pathname:s,search:c},appParams:{...e},hasProvider:r})}function Q(n,e){const t=P(window,l.ACTIVATE,()=>{_(window,t),R(n,w.UPDATE_APP_DATA,{metaData:e?{appCode:e}:void 0})});return t}function J(n,e=U){return P(window,l.UPDATE_HEIGHT,t=>{n.style.height=t.height?`${t.height+k}px`:e})}function K(n){const{params:e,provider:t,listeners:r}=n,[s,c]=d.useState(null),i=d.useRef(null),a=d.useRef(t),m=d.useRef(r),E=d.useRef(null),u=d.useRef(null),o=d.useCallback((h,f)=>{try{console.log(`[WIDGET] ${h}`),f()}catch(v){const C=`Error ${h.toLowerCase()}`;console.error(`[WIDGET] ${C}`,v),c({message:C,error:v})}},[c]);return d.useEffect(()=>{if(!E.current||JSON.stringify(i.current)===JSON.stringify(e))return;const h=E.current,f=u.current;i.current=e,f===null?o("Creating a new widget",()=>{u.current=T(h,{params:e,provider:a.current,listeners:r}),m.current=r}):o("Updating the widget",()=>f.updateParams(e))},[e]),d.useEffect(()=>{if(!u.current||a.current===t)return;a.current=t;const h=E.current;h&&o("Updating the provider",()=>{var f;(f=u.current)==null||f.destroy(),u.current=T(h,{params:e,provider:a.current,listeners:r})})},[t]),d.useEffect(()=>{if(!u.current||m.current===r)return;const h=u.current;o("Updating the listeners",()=>h.updateListeners(r))},[r]),s?g.jsxs("div",{style:{color:"#ff3a3a"},children:[s.message,s.error.message&&g.jsx("pre",{style:{whiteSpace:"pre-wrap",fontSize:"0.75em"},children:s.error.message})]}):g.jsx("div",{ref:E})}exports.CowSwapWidget=K;exports.TradeType=A;exports.WidgetMethodsEmit=l;exports.WidgetMethodsListen=w;exports.createCowSwapWidget=T;exports.listenToMessageFromWindow=P;exports.postMessageToWindow=R;exports.stopListeningToMessageFromWindow=O;exports.stopListeningWindowListener=_;
|
package/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var N = (n, e, t) => e in n ? V(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import { useState as
|
|
3
|
+
var h = (n, e, t) => (N(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { jsxs as b, jsx as A } from "react/jsx-runtime";
|
|
5
|
+
import { useState as H, useRef as l, useCallback as F, useEffect as T } from "react";
|
|
6
6
|
const W = "cowSwapWidget";
|
|
7
7
|
function P(n, e, t) {
|
|
8
8
|
const s = {
|
|
@@ -31,9 +31,9 @@ function M(n, e, t) {
|
|
|
31
31
|
function O(n, e) {
|
|
32
32
|
n.removeEventListener("message", e);
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var m = /* @__PURE__ */ ((n) => (n.ACTIVATE = "ACTIVATE", n.UPDATE_HEIGHT = "UPDATE_HEIGHT", n.EMIT_COW_EVENT = "EMIT_COW_EVENT", n.PROVIDER_RPC_REQUEST = "PROVIDER_RPC_REQUEST", n))(m || {}), w = /* @__PURE__ */ ((n) => (n.UPDATE_PARAMS = "UPDATE_PARAMS", n.UPDATE_APP_DATA = "UPDATE_APP_DATA", n.PROVIDER_RPC_RESPONSE = "PROVIDER_RPC_RESPONSE", n.PROVIDER_ON_EVENT = "PROVIDER_ON_EVENT", n))(w || {}), S = /* @__PURE__ */ ((n) => (n.SWAP = "swap", n.LIMIT = "limit", n.ADVANCED = "advanced", n))(S || {});
|
|
35
35
|
const G = ["connect", "disconnect", "close", "chainChanged", "accountsChanged"];
|
|
36
|
-
class
|
|
36
|
+
class x {
|
|
37
37
|
/**
|
|
38
38
|
* Creates an instance of IframeRpcProviderBridge.
|
|
39
39
|
* @param iframeWidow - The iFrame window that will post up general RPC messages and to which the IframeRpcProviderBridge will forward the RPC result.
|
|
@@ -44,10 +44,10 @@ class $ {
|
|
|
44
44
|
* The Ethereum provider instance.
|
|
45
45
|
* When is null the JSON-RPC bridge is disconnected from the Ethereum provider.
|
|
46
46
|
* */
|
|
47
|
-
|
|
47
|
+
h(this, "ethereumProvider", null);
|
|
48
48
|
/** Stored JSON-RPC requests, to queue them when disconnected. */
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
h(this, "requestWaitingForConnection", {});
|
|
50
|
+
h(this, "processRpcCallFromWindow", ({ rpcRequest: e }) => {
|
|
51
51
|
if (!this.ethereumProvider) {
|
|
52
52
|
e.id && (this.requestWaitingForConnection[e.id] = e);
|
|
53
53
|
return;
|
|
@@ -60,14 +60,14 @@ class $ {
|
|
|
60
60
|
* Disconnects the JSON-RPC bridge from the Ethereum provider.
|
|
61
61
|
*/
|
|
62
62
|
disconnect() {
|
|
63
|
-
this.ethereumProvider = null, M(window,
|
|
63
|
+
this.ethereumProvider = null, M(window, m.PROVIDER_RPC_REQUEST, this.processRpcCallFromWindow);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Handles the 'connect' event and sets up event listeners for Ethereum provider events.
|
|
67
67
|
* @param newProvider - The Ethereum provider to connect.
|
|
68
68
|
*/
|
|
69
69
|
onConnect(e) {
|
|
70
|
-
this.ethereumProvider ? this.disconnect() : R(window,
|
|
70
|
+
this.ethereumProvider ? this.disconnect() : R(window, m.PROVIDER_RPC_REQUEST, this.processRpcCallFromWindow), this.ethereumProvider = e, this.processPendingRequests(), G.forEach((t) => {
|
|
71
71
|
e.on(t, (r) => this.onProviderEvent(t, r));
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -85,12 +85,12 @@ class $ {
|
|
|
85
85
|
if (!this.ethereumProvider || !t)
|
|
86
86
|
return;
|
|
87
87
|
(s === "enable" ? this.ethereumProvider.enable() : this.ethereumProvider.request({ ...e, id: t })).then(
|
|
88
|
-
(
|
|
89
|
-
rpcResponse: { jsonrpc: r, id: t, result:
|
|
88
|
+
(i) => this.forwardRpcResponseToIframe({
|
|
89
|
+
rpcResponse: { jsonrpc: r, id: t, result: i }
|
|
90
90
|
})
|
|
91
91
|
).catch(
|
|
92
|
-
(
|
|
93
|
-
rpcResponse: { jsonrpc: r, id: t, error:
|
|
92
|
+
(i) => this.forwardRpcResponseToIframe({
|
|
93
|
+
rpcResponse: { jsonrpc: r, id: t, error: i }
|
|
94
94
|
})
|
|
95
95
|
);
|
|
96
96
|
}
|
|
@@ -107,30 +107,22 @@ class $ {
|
|
|
107
107
|
P(this.iframeWidow, w.PROVIDER_RPC_RESPONSE, e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const k = {
|
|
114
|
-
local: "http://localhost:3000",
|
|
115
|
-
prod: "https://swap.cow.fi",
|
|
116
|
-
dev: "https://dev.swap.cow.fi",
|
|
117
|
-
pr: x()
|
|
118
|
-
}, A = "_";
|
|
119
|
-
function Q(n) {
|
|
120
|
-
const e = k[n.env || "prod"], t = y(n), r = L(n);
|
|
110
|
+
const v = "_";
|
|
111
|
+
function $(n) {
|
|
112
|
+
const e = typeof n.baseUrl == "string" ? n.baseUrl : "https://swap.cow.fi", t = y(n), r = L(n);
|
|
121
113
|
return e + "/#" + t + "?" + r;
|
|
122
114
|
}
|
|
123
115
|
function y(n) {
|
|
124
|
-
const { chainId: e = 1, sell: t, buy: r, tradeType: s = S.SWAP } = n, c = [(t == null ? void 0 : t.asset) ||
|
|
116
|
+
const { chainId: e = 1, sell: t, buy: r, tradeType: s = S.SWAP } = n, c = [(t == null ? void 0 : t.asset) || v, (r == null ? void 0 : r.asset) || v].map(encodeURIComponent).join("/");
|
|
125
117
|
return `/${e}/widget/${s}/${c}`;
|
|
126
118
|
}
|
|
127
119
|
function L(n) {
|
|
128
120
|
const { sell: e, buy: t, theme: r } = n, s = new URLSearchParams();
|
|
129
121
|
return e != null && e.amount && s.append("sellAmount", e.amount), t != null && t.amount && s.append("buyAmount", t.amount), r && s.append("theme", typeof r == "string" ? r : r.baseTheme), s;
|
|
130
122
|
}
|
|
131
|
-
class
|
|
123
|
+
class k {
|
|
132
124
|
constructor() {
|
|
133
|
-
|
|
125
|
+
h(this, "subscriptions", {});
|
|
134
126
|
}
|
|
135
127
|
on(e) {
|
|
136
128
|
const { event: t, handler: r } = e;
|
|
@@ -144,16 +136,16 @@ class K {
|
|
|
144
136
|
this.subscriptions[e] && this.subscriptions[e].forEach((r) => r(t));
|
|
145
137
|
}
|
|
146
138
|
}
|
|
147
|
-
let
|
|
148
|
-
class
|
|
139
|
+
let Q = 1;
|
|
140
|
+
class j {
|
|
149
141
|
constructor(e, t = []) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
h(this, "eventEmitter", new k());
|
|
143
|
+
h(this, "listeners", []);
|
|
144
|
+
h(this, "widgetListener");
|
|
145
|
+
h(this, "instanceNumber", Q++);
|
|
154
146
|
this.contentWindow = e, this.updateListeners(t), this.widgetListener = R(
|
|
155
147
|
this.contentWindow,
|
|
156
|
-
|
|
148
|
+
m.EMIT_COW_EVENT,
|
|
157
149
|
(r) => this.eventEmitter.emit(r.event, r.payload)
|
|
158
150
|
);
|
|
159
151
|
}
|
|
@@ -168,38 +160,38 @@ class J {
|
|
|
168
160
|
this.eventEmitter.on(t);
|
|
169
161
|
}
|
|
170
162
|
}
|
|
171
|
-
const U = "640px",
|
|
163
|
+
const U = "640px", J = "450px", K = 20;
|
|
172
164
|
function C(n, e) {
|
|
173
165
|
const { params: t, provider: r, listeners: s } = e;
|
|
174
166
|
let c = r;
|
|
175
|
-
const
|
|
176
|
-
n.innerHTML = "", n.appendChild(
|
|
177
|
-
const { contentWindow: a } =
|
|
167
|
+
const i = Y(t);
|
|
168
|
+
n.innerHTML = "", n.appendChild(i);
|
|
169
|
+
const { contentWindow: a } = i;
|
|
178
170
|
if (!a)
|
|
179
|
-
throw console.error("Iframe does not contain a window",
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
let
|
|
184
|
-
return
|
|
185
|
-
updateParams: (
|
|
186
|
-
updateListeners: (
|
|
187
|
-
updateProvider: (
|
|
188
|
-
c =
|
|
171
|
+
throw console.error("Iframe does not contain a window", i), new Error("Iframe does not contain a window!");
|
|
172
|
+
const f = [];
|
|
173
|
+
f.push(z(a, t.appCode)), f.push(B(i, t.height));
|
|
174
|
+
const p = new j(window, s);
|
|
175
|
+
let u = I(a, null, c);
|
|
176
|
+
return i.addEventListener("load", () => D(a, t, c)), {
|
|
177
|
+
updateParams: (o) => D(a, o, c),
|
|
178
|
+
updateListeners: (o) => p.updateListeners(o),
|
|
179
|
+
updateProvider: (o) => {
|
|
180
|
+
c = o, u = I(a, u, o);
|
|
189
181
|
},
|
|
190
182
|
destroy: () => {
|
|
191
|
-
|
|
183
|
+
p.stopListeningIframe(), f.forEach((o) => window.removeEventListener("message", o)), n.removeChild(i);
|
|
192
184
|
}
|
|
193
185
|
};
|
|
194
186
|
}
|
|
195
187
|
function I(n, e, t) {
|
|
196
188
|
e && e.disconnect();
|
|
197
|
-
const r = e || new
|
|
189
|
+
const r = e || new x(n);
|
|
198
190
|
return t && r.onConnect(t), r;
|
|
199
191
|
}
|
|
200
|
-
function
|
|
201
|
-
const { width: e =
|
|
202
|
-
return r.src =
|
|
192
|
+
function Y(n) {
|
|
193
|
+
const { width: e = J, height: t = U } = n, r = document.createElement("iframe");
|
|
194
|
+
return r.src = $(n), r.width = e, r.height = t, r.style.border = "0", r;
|
|
203
195
|
}
|
|
204
196
|
function D(n, e, t) {
|
|
205
197
|
const r = !!t, s = y(e), c = L(e).toString();
|
|
@@ -214,62 +206,61 @@ function D(n, e, t) {
|
|
|
214
206
|
hasProvider: r
|
|
215
207
|
});
|
|
216
208
|
}
|
|
217
|
-
function
|
|
218
|
-
const t = R(window,
|
|
209
|
+
function z(n, e) {
|
|
210
|
+
const t = R(window, m.ACTIVATE, () => {
|
|
219
211
|
O(window, t), P(n, w.UPDATE_APP_DATA, {
|
|
220
212
|
metaData: e ? { appCode: e } : void 0
|
|
221
213
|
});
|
|
222
214
|
});
|
|
223
215
|
return t;
|
|
224
216
|
}
|
|
225
|
-
function
|
|
226
|
-
return R(window,
|
|
227
|
-
n.style.height = t.height ? `${t.height +
|
|
217
|
+
function B(n, e = U) {
|
|
218
|
+
return R(window, m.UPDATE_HEIGHT, (t) => {
|
|
219
|
+
n.style.height = t.height ? `${t.height + K}px` : e;
|
|
228
220
|
});
|
|
229
221
|
}
|
|
230
|
-
function
|
|
231
|
-
const { params: e, provider: t, listeners: r } = n, [s, c] =
|
|
232
|
-
(
|
|
222
|
+
function te(n) {
|
|
223
|
+
const { params: e, provider: t, listeners: r } = n, [s, c] = H(null), i = l(null), a = l(t), f = l(r), p = l(null), u = l(null), o = F(
|
|
224
|
+
(d, E) => {
|
|
233
225
|
try {
|
|
234
|
-
console.log(`[WIDGET] ${
|
|
235
|
-
} catch (
|
|
236
|
-
const _ = `Error ${
|
|
237
|
-
console.error(`[WIDGET] ${_}`,
|
|
226
|
+
console.log(`[WIDGET] ${d}`), E();
|
|
227
|
+
} catch (g) {
|
|
228
|
+
const _ = `Error ${d.toLowerCase()}`;
|
|
229
|
+
console.error(`[WIDGET] ${_}`, g), c({ message: _, error: g });
|
|
238
230
|
}
|
|
239
231
|
},
|
|
240
232
|
[c]
|
|
241
233
|
);
|
|
242
|
-
return
|
|
243
|
-
if (!
|
|
234
|
+
return T(() => {
|
|
235
|
+
if (!p.current || JSON.stringify(i.current) === JSON.stringify(e))
|
|
244
236
|
return;
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}) :
|
|
249
|
-
}, [e]),
|
|
250
|
-
if (!
|
|
237
|
+
const d = p.current, E = u.current;
|
|
238
|
+
i.current = e, E === null ? o("Creating a new widget", () => {
|
|
239
|
+
u.current = C(d, { params: e, provider: a.current, listeners: r }), f.current = r;
|
|
240
|
+
}) : o("Updating the widget", () => E.updateParams(e));
|
|
241
|
+
}, [e]), T(() => {
|
|
242
|
+
if (!u.current || a.current === t)
|
|
251
243
|
return;
|
|
252
244
|
a.current = t;
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
var
|
|
256
|
-
(
|
|
245
|
+
const d = p.current;
|
|
246
|
+
d && o("Updating the provider", () => {
|
|
247
|
+
var E;
|
|
248
|
+
(E = u.current) == null || E.destroy(), u.current = C(d, { params: e, provider: a.current, listeners: r });
|
|
257
249
|
});
|
|
258
|
-
}, [t]),
|
|
259
|
-
if (!
|
|
250
|
+
}, [t]), T(() => {
|
|
251
|
+
if (!u.current || f.current === r)
|
|
260
252
|
return;
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
}, [r]), s ? /* @__PURE__ */
|
|
253
|
+
const d = u.current;
|
|
254
|
+
o("Updating the listeners", () => d.updateListeners(r));
|
|
255
|
+
}, [r]), s ? /* @__PURE__ */ b("div", { style: { color: "#ff3a3a" }, children: [
|
|
264
256
|
s.message,
|
|
265
|
-
s.error.message && /* @__PURE__ */
|
|
266
|
-
] }) : /* @__PURE__ */
|
|
257
|
+
s.error.message && /* @__PURE__ */ A("pre", { style: { whiteSpace: "pre-wrap", fontSize: "0.75em" }, children: s.error.message })
|
|
258
|
+
] }) : /* @__PURE__ */ A("div", { ref: p });
|
|
267
259
|
}
|
|
268
260
|
export {
|
|
269
|
-
|
|
270
|
-
re as CowSwapWidget,
|
|
261
|
+
te as CowSwapWidget,
|
|
271
262
|
S as TradeType,
|
|
272
|
-
|
|
263
|
+
m as WidgetMethodsEmit,
|
|
273
264
|
w as WidgetMethodsListen,
|
|
274
265
|
C as createCowSwapWidget,
|
|
275
266
|
R as listenToMessageFromWindow,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/widget-react",
|
|
3
|
-
"version": "0.5.0
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your React application.",
|
|
6
6
|
"main": "index.js",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"react"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@cowprotocol/widget-lib": "^0.
|
|
25
|
+
"@cowprotocol/widget-lib": "^0.7.0"
|
|
26
26
|
}
|
|
27
27
|
}
|