@cowprotocol/widget-lib 2.0.0 → 2.0.1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +27 -4
  3. package/src/IframeCowEventEmitter.d.ts +10 -0
  4. package/src/IframeCowEventEmitter.js +35 -0
  5. package/src/IframeCowEventEmitter.js.map +1 -0
  6. package/src/IframeSafeSdkBridge.d.ts +8 -0
  7. package/src/IframeSafeSdkBridge.js +53 -0
  8. package/src/IframeSafeSdkBridge.js.map +1 -0
  9. package/src/cowSwapWidget.d.ts +18 -0
  10. package/src/cowSwapWidget.js +189 -0
  11. package/src/cowSwapWidget.js.map +1 -0
  12. package/src/flexibleConfig.d.ts +5 -0
  13. package/src/flexibleConfig.js +30 -0
  14. package/src/flexibleConfig.js.map +1 -0
  15. package/src/index.d.ts +7 -0
  16. package/src/index.js +14 -0
  17. package/src/index.js.map +1 -0
  18. package/src/resolveFlexibleConfigValues.d.ts +2 -0
  19. package/src/resolveFlexibleConfigValues.js +14 -0
  20. package/src/resolveFlexibleConfigValues.js.map +1 -0
  21. package/src/themeUtils.d.ts +2 -0
  22. package/src/themeUtils.js +7 -0
  23. package/src/themeUtils.js.map +1 -0
  24. package/src/types.d.ts +365 -0
  25. package/src/types.js +42 -0
  26. package/src/types.js.map +1 -0
  27. package/src/urlUtils.d.ts +4 -0
  28. package/src/urlUtils.js +55 -0
  29. package/src/urlUtils.js.map +1 -0
  30. package/src/widgetIframeTransport.d.ts +3 -0
  31. package/src/widgetIframeTransport.js +6 -0
  32. package/src/widgetIframeTransport.js.map +1 -0
  33. package/jest.config.ts +0 -10
  34. package/project.json +0 -51
  35. package/src/IframeCowEventEmitter.ts +0 -47
  36. package/src/IframeSafeSdkBridge.ts +0 -77
  37. package/src/cowSwapWidget.ts +0 -259
  38. package/src/flexibleConfig.ts +0 -39
  39. package/src/index.ts +0 -7
  40. package/src/resolveFlexibleConfigValues.ts +0 -14
  41. package/src/themeUtils.ts +0 -7
  42. package/src/types.ts +0 -458
  43. package/src/urlUtils.spec.ts +0 -88
  44. package/src/urlUtils.ts +0 -66
  45. package/src/widgetIframeTransport.ts +0 -5
  46. package/tsconfig.json +0 -22
  47. package/tsconfig.lib.json +0 -10
  48. package/tsconfig.spec.json +0 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v2.0.0...widget-lib-v2.0.1) (2026-03-18)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * update libs publising and bundling ([#7173](https://github.com/cowprotocol/cowswap/issues/7173)) ([e3bc5f1](https://github.com/cowprotocol/cowswap/commit/e3bc5f179124c11590a992789db43d912f8ee4a6))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @cowprotocol/events bumped to 4.0.1
16
+ * @cowprotocol/iframe-transport bumped to 2.0.9
17
+
3
18
  ## [2.0.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.3.0...widget-lib-v2.0.0) (2026-03-11)
4
19
 
5
20
 
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@cowprotocol/widget-lib",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your website.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/cowprotocol/cowswap.git",
8
+ "directory": "libs/widget-lib"
9
+ },
5
10
  "type": "commonjs",
6
- "main": "./src/index.ts",
11
+ "main": "./src/index.js",
7
12
  "types": "./src/index.d.ts",
8
13
  "license": "ISC",
9
14
  "publishConfig": {
@@ -11,7 +16,25 @@
11
16
  },
12
17
  "dependencies": {
13
18
  "@cowprotocol/cow-sdk": "8.0.0",
14
- "@cowprotocol/events": "4.0.0",
15
- "@cowprotocol/iframe-transport": "2.0.8"
19
+ "@cowprotocol/events": "^4.0.1",
20
+ "@cowprotocol/iframe-transport": "^2.0.9",
21
+ "@cowprotocol/sdk-bridging": "3.0.0",
22
+ "@uniswap/sdk-core": "3.2.6",
23
+ "@web3-react/types": "8.2.3",
24
+ "eventemitter3": "4.0.7",
25
+ "@cowprotocol/types": "4.0.1",
26
+ "tslib": "1.14.1"
27
+ },
28
+ "resolutions": {
29
+ "@safe-global/safe-apps-sdk": "^9.1.0",
30
+ "@types/react": "19.1.3",
31
+ "@types/react-dom": "19.1.3",
32
+ "stylus": "npm:empty-npm-package@1.0.0",
33
+ "@babel/traverse": "^7.23.2",
34
+ "@walletconnect/ethereum-provider": "2.18.0",
35
+ "@walletconnect/sign-client": "2.18.0",
36
+ "@walletconnect/universal-provider": "2.18.0",
37
+ "@walletconnect/utils": "2.18.0",
38
+ "@walletconnect/types": "2.18.0"
16
39
  }
17
40
  }
@@ -0,0 +1,10 @@
1
+ import { CowWidgetEventListeners } from '@cowprotocol/events';
2
+ export declare class IframeCowEventEmitter {
3
+ private contentWindow;
4
+ private eventEmitter;
5
+ private listeners;
6
+ private widgetListener;
7
+ constructor(contentWindow: Window, listeners?: CowWidgetEventListeners);
8
+ stopListeningIframe(): void;
9
+ updateListeners(listeners?: CowWidgetEventListeners): void;
10
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IframeCowEventEmitter = void 0;
4
+ const events_1 = require("@cowprotocol/events");
5
+ const types_1 = require("./types");
6
+ const widgetIframeTransport_1 = require("./widgetIframeTransport");
7
+ class IframeCowEventEmitter {
8
+ contentWindow;
9
+ eventEmitter = new events_1.SimpleCowEventEmitter();
10
+ listeners = [];
11
+ widgetListener;
12
+ constructor(contentWindow, listeners = []) {
13
+ this.contentWindow = contentWindow;
14
+ // Subscribe listeners to local event emitter
15
+ this.updateListeners(listeners);
16
+ // Listen to iFrame, and forward to local event emitter
17
+ this.widgetListener = widgetIframeTransport_1.widgetIframeTransport.listenToMessageFromWindow(this.contentWindow, types_1.WidgetMethodsEmit.EMIT_COW_EVENT, (cowEvent) => this.eventEmitter.emit(cowEvent.event, cowEvent.payload));
18
+ }
19
+ stopListeningIframe() {
20
+ widgetIframeTransport_1.widgetIframeTransport.stopListeningWindowListener(this.contentWindow, this.widgetListener);
21
+ }
22
+ updateListeners(listeners) {
23
+ // Unsubscribe from previous listeners
24
+ for (const listener of this.listeners) {
25
+ this.eventEmitter.off(listener);
26
+ }
27
+ // Subscribe to events
28
+ this.listeners = listeners || [];
29
+ for (const listener of this.listeners) {
30
+ this.eventEmitter.on(listener);
31
+ }
32
+ }
33
+ }
34
+ exports.IframeCowEventEmitter = IframeCowEventEmitter;
35
+ //# sourceMappingURL=IframeCowEventEmitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IframeCowEventEmitter.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/IframeCowEventEmitter.ts"],"names":[],"mappings":";;;AAAA,gDAK4B;AAE5B,mCAA2D;AAC3D,mEAA+D;AAE/D,MAAa,qBAAqB;IAMtB;IALF,YAAY,GAAG,IAAI,8BAAqB,EAA6C,CAAA;IACrF,SAAS,GAA4B,EAAE,CAAA;IACvC,cAAc,CAAgB;IAEtC,YACU,aAAqB,EAC7B,YAAqC,EAAE;QAD/B,kBAAa,GAAb,aAAa,CAAQ;QAG7B,6CAA6C;QAC7C,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;QAE/B,uDAAuD;QACvD,IAAI,CAAC,cAAc,GAAG,6CAAqB,CAAC,yBAAyB,CACnE,IAAI,CAAC,aAAa,EAClB,yBAAiB,CAAC,cAAc,EAChC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CACvE,CAAA;IACH,CAAC;IAEM,mBAAmB;QACxB,6CAAqB,CAAC,2BAA2B,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAC5F,CAAC;IAEM,eAAe,CAAC,SAAmC;QACxD,sCAAsC;QACtC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACjC,CAAC;QAED,sBAAsB;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAA;QAChC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;CACF;AApCD,sDAoCC"}
@@ -0,0 +1,8 @@
1
+ export declare class IframeSafeSdkBridge {
2
+ private appWindow;
3
+ private iframeWidow;
4
+ forwardSdkMessage: (event: MessageEvent<unknown>) => void;
5
+ constructor(appWindow: Window, iframeWidow: Window);
6
+ private startListening;
7
+ stopListening(): void;
8
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IframeSafeSdkBridge = void 0;
4
+ class IframeSafeSdkBridge {
5
+ appWindow;
6
+ iframeWidow;
7
+ forwardSdkMessage;
8
+ constructor(appWindow, iframeWidow) {
9
+ this.appWindow = appWindow;
10
+ this.iframeWidow = iframeWidow;
11
+ this.forwardSdkMessage = (event) => {
12
+ if (!isSafeMessage(event.data)) {
13
+ return;
14
+ }
15
+ if (typeof window !== 'undefined' && event.origin === window.location.origin) {
16
+ return;
17
+ }
18
+ if (isSafeMessageRequest(event.data)) {
19
+ this.appWindow.parent.postMessage(event.data, '*');
20
+ }
21
+ else if (isSafeMessageResponse(event.data)) {
22
+ this.iframeWidow.postMessage(event.data, '*');
23
+ }
24
+ };
25
+ this.startListening();
26
+ }
27
+ startListening() {
28
+ this.appWindow.addEventListener('message', this.forwardSdkMessage);
29
+ }
30
+ stopListening() {
31
+ this.appWindow.removeEventListener('message', this.forwardSdkMessage);
32
+ }
33
+ }
34
+ exports.IframeSafeSdkBridge = IframeSafeSdkBridge;
35
+ function isSafeMessage(obj) {
36
+ return typeof obj === 'object' && obj !== null && 'id' in obj && typeof obj.id === 'string';
37
+ }
38
+ function isSafeMessageRequest(message) {
39
+ return ('method' in message &&
40
+ typeof message.method === 'string' &&
41
+ 'params' in message &&
42
+ 'env' in message &&
43
+ typeof message.env === 'object' &&
44
+ message.env !== null &&
45
+ 'sdkVersion' in message.env);
46
+ }
47
+ function isSafeMessageResponse(message) {
48
+ return ('success' in message &&
49
+ typeof message.success === 'boolean' &&
50
+ 'version' in message &&
51
+ typeof message.version === 'string');
52
+ }
53
+ //# sourceMappingURL=IframeSafeSdkBridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IframeSafeSdkBridge.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/IframeSafeSdkBridge.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAmB;IAIpB;IACA;IAJV,iBAAiB,CAAwC;IAEzD,YACU,SAAiB,EACjB,WAAmB;QADnB,cAAS,GAAT,SAAS,CAAQ;QACjB,gBAAW,GAAX,WAAW,CAAQ;QAE3B,IAAI,CAAC,iBAAiB,GAAG,CAAC,KAA4B,EAAE,EAAE;YACxD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,OAAM;YACR,CAAC;YAED,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC7E,OAAM;YACR,CAAC;YAED,IAAI,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CA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import { CowSwapWidgetParams, CowSwapWidgetProps, EthereumProvider } from './types';
3
+ /**
4
+ * Callback function signature for updating the CoW Swap Widget.
5
+ */
6
+ export interface CowSwapWidgetHandler {
7
+ updateParams: (params: CowSwapWidgetParams) => void;
8
+ updateListeners: (newListeners?: CowWidgetEventListeners) => void;
9
+ updateProvider: (newProvider?: EthereumProvider) => void;
10
+ destroy: () => void;
11
+ }
12
+ /**
13
+ * Generates and injects a CoW Swap Widget into the provided container.
14
+ * @param container - The HTML element to inject the widget into.
15
+ * @param params - Parameters for configuring the widget.
16
+ * @returns A callback function to update the widget with new settings.
17
+ */
18
+ export declare function createCowSwapWidget(container: HTMLElement, props: CowSwapWidgetProps): CowSwapWidgetHandler;
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCowSwapWidget = createCowSwapWidget;
4
+ const iframe_transport_1 = require("@cowprotocol/iframe-transport");
5
+ const IframeCowEventEmitter_1 = require("./IframeCowEventEmitter");
6
+ const IframeSafeSdkBridge_1 = require("./IframeSafeSdkBridge");
7
+ const types_1 = require("./types");
8
+ const urlUtils_1 = require("./urlUtils");
9
+ const widgetIframeTransport_1 = require("./widgetIframeTransport");
10
+ const DEFAULT_HEIGHT = '640px';
11
+ const DEFAULT_WIDTH = '450px';
12
+ /**
13
+ * Reference: IframeResizer (apps/cowswap-frontend/src/modules/injectedWidget/updaters/IframeResizer.ts)
14
+ * Sometimes MutationObserver doesn't trigger when the height of the widget changes and the widget displays with a scrollbar.
15
+ * To avoid this we add a threshold to the height.
16
+ * 20px
17
+ */
18
+ const HEIGHT_THRESHOLD = 20;
19
+ const noopHandler = {
20
+ updateParams: () => void 0,
21
+ updateListeners: () => void 0,
22
+ updateProvider: () => void 0,
23
+ destroy: () => void 0,
24
+ };
25
+ /**
26
+ * Generates and injects a CoW Swap Widget into the provided container.
27
+ * @param container - The HTML element to inject the widget into.
28
+ * @param params - Parameters for configuring the widget.
29
+ * @returns A callback function to update the widget with new settings.
30
+ */
31
+ function createCowSwapWidget(container, props) {
32
+ const { params, provider: providerAux, listeners } = props;
33
+ let provider = providerAux;
34
+ let currentParams = params;
35
+ if (typeof window === 'undefined')
36
+ return noopHandler;
37
+ // 1. Create a brand new iframe
38
+ const iframe = createIframe(params);
39
+ // 2. Clear the content (delete any previous iFrame if it exists)
40
+ container.innerHTML = '';
41
+ container.appendChild(iframe);
42
+ const { contentWindow: iframeWindow } = iframe;
43
+ if (!iframeWindow) {
44
+ console.error('Iframe does not contain a window', iframe);
45
+ throw new Error('Iframe does not contain a window!');
46
+ }
47
+ // 3. Send appCode (once the widget posts the ACTIVATE message)
48
+ const windowListeners = [];
49
+ windowListeners.push(sendAppCodeOnActivation(iframeWindow, params.appCode));
50
+ // 4. Handle widget height changes
51
+ windowListeners.push(...listenToHeightChanges(iframe, params.height, params.maxHeight));
52
+ // 5. Intercept deeplinks navigation in the iframe
53
+ windowListeners.push(interceptDeepLinks());
54
+ // 6. Handle and forward widget events to the listeners
55
+ const iFrameCowEventEmitter = new IframeCowEventEmitter_1.IframeCowEventEmitter(window, listeners);
56
+ // 7. Wire up the iframeRpcProviderBridge with the provider (so RPC calls flow back and forth)
57
+ let iframeRpcProviderBridge = updateProvider(iframeWindow, null, provider);
58
+ // 8. Schedule the uploading of the params, once the iframe is loaded
59
+ iframe.addEventListener('load', () => updateParams(iframeWindow, currentParams, provider));
60
+ // 9. Listen for messages from the iframe
61
+ const iframeSafeSdkBridge = new IframeSafeSdkBridge_1.IframeSafeSdkBridge(window, iframeWindow);
62
+ // 10. Return the handler, so the widget, listeners, and provider can be updated
63
+ return {
64
+ updateParams: (newParams) => {
65
+ currentParams = newParams;
66
+ updateParams(iframeWindow, currentParams, provider);
67
+ },
68
+ updateListeners: (newListeners) => iFrameCowEventEmitter.updateListeners(newListeners),
69
+ updateProvider: (newProvider) => {
70
+ provider = newProvider;
71
+ iframeRpcProviderBridge = updateProvider(iframeWindow, iframeRpcProviderBridge, newProvider);
72
+ },
73
+ destroy: () => {
74
+ // Disconnect rpc provider and unsubscribe to events
75
+ iframeRpcProviderBridge.disconnect();
76
+ // Stop listening for cow events
77
+ iFrameCowEventEmitter.stopListeningIframe();
78
+ // Disconnect all listeners
79
+ windowListeners.forEach((listener) => window.removeEventListener('message', listener));
80
+ // Stop listening for SDK messages
81
+ iframeSafeSdkBridge.stopListening();
82
+ // Destroy the iframe
83
+ container.removeChild(iframe);
84
+ },
85
+ };
86
+ }
87
+ /**
88
+ * Update the provider for the iframeRpcProviderBridge.
89
+ *
90
+ * It will disconnect from the previous provider and connect to the new one.
91
+ *
92
+ * @param iframe iframe window
93
+ * @param iframeRpcProviderBridge iframe RPC manager
94
+ * @param newProvider new provider
95
+ *
96
+ * @returns the iframeRpcProviderBridge
97
+ */
98
+ function updateProvider(iframe, iframeRpcProviderBridge, newProvider) {
99
+ // Disconnect from the previous provider bridge
100
+ if (iframeRpcProviderBridge) {
101
+ iframeRpcProviderBridge.disconnect();
102
+ }
103
+ const providerBridge = iframeRpcProviderBridge || new iframe_transport_1.IframeRpcProviderBridge(iframe);
104
+ // Connect to the new provider
105
+ if (newProvider) {
106
+ providerBridge.onConnect(newProvider);
107
+ }
108
+ return providerBridge;
109
+ }
110
+ /**
111
+ * Creates an iframe element for the CoW Swap Widget based on provided parameters and settings.
112
+ * @param params - Parameters for the widget.
113
+ * @returns The generated HTMLIFrameElement.
114
+ */
115
+ function createIframe(params) {
116
+ const { width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT } = params;
117
+ const iframe = document.createElement('iframe');
118
+ iframe.src = (0, urlUtils_1.buildWidgetUrl)(params);
119
+ iframe.width = width;
120
+ iframe.height = height;
121
+ iframe.style.border = '0';
122
+ iframe.allow = 'clipboard-read; clipboard-write';
123
+ return iframe;
124
+ }
125
+ /**
126
+ * Updates the CoW Swap Widget based on the new settings provided.
127
+ * @param params - New params for the widget.
128
+ * @param contentWindow - Window object of the widget's iframe.
129
+ */
130
+ function updateParams(contentWindow, params, provider) {
131
+ const hasProvider = !!provider;
132
+ const pathname = (0, urlUtils_1.buildWidgetPath)(params);
133
+ const search = (0, urlUtils_1.buildWidgetUrlQuery)(params).toString();
134
+ // Omit theme from appParams
135
+ const { theme: _theme, ...appParams } = params;
136
+ widgetIframeTransport_1.widgetIframeTransport.postMessageToWindow(contentWindow, types_1.WidgetMethodsListen.UPDATE_PARAMS, {
137
+ urlParams: {
138
+ pathname,
139
+ search,
140
+ },
141
+ appParams,
142
+ hasProvider,
143
+ });
144
+ }
145
+ /**
146
+ * Sends appCode to the contentWindow of the widget once the widget is activated.
147
+ *
148
+ * @param contentWindow - Window object of the widget's iframe.
149
+ * @param appCode - A unique identifier for the app.
150
+ */
151
+ function sendAppCodeOnActivation(contentWindow, appCode) {
152
+ return widgetIframeTransport_1.widgetIframeTransport.listenToMessageFromWindow(window, types_1.WidgetMethodsEmit.ACTIVATE, () => {
153
+ // Update the appData
154
+ widgetIframeTransport_1.widgetIframeTransport.postMessageToWindow(contentWindow, types_1.WidgetMethodsListen.UPDATE_APP_DATA, {
155
+ metaData: appCode ? { appCode } : undefined,
156
+ });
157
+ });
158
+ }
159
+ /**
160
+ * Since deeplinks are not supported in iframes, this function intercepts the window.open calls from the widget and opens
161
+ */
162
+ function interceptDeepLinks() {
163
+ return widgetIframeTransport_1.widgetIframeTransport.listenToMessageFromWindow(window, types_1.WidgetMethodsEmit.INTERCEPT_WINDOW_OPEN, ({ href, rel, target }) => {
164
+ const url = href.toString();
165
+ if (!url.startsWith('http') && url.match(/^[a-zA-Z0-9]+:\/\//)) {
166
+ window.open(url, target, rel);
167
+ return;
168
+ }
169
+ });
170
+ }
171
+ /**
172
+ * Listens for iframeHeight emitted by the widget, and applies dynamic height adjustments to the widget's iframe.
173
+ *
174
+ * @param iframe - The HTMLIFrameElement of the widget.
175
+ * @param defaultHeight - Default height for the widget.
176
+ * @param maxHeight - Maximum height for the widget.
177
+ */
178
+ function listenToHeightChanges(iframe, defaultHeight = DEFAULT_HEIGHT, maxHeight) {
179
+ return [
180
+ widgetIframeTransport_1.widgetIframeTransport.listenToMessageFromWindow(window, types_1.WidgetMethodsEmit.UPDATE_HEIGHT, (data) => {
181
+ const newHeight = data.height ? data.height + HEIGHT_THRESHOLD : undefined;
182
+ iframe.style.height = newHeight ? `${maxHeight ? Math.min(newHeight, maxHeight) : newHeight}px` : defaultHeight;
183
+ }),
184
+ widgetIframeTransport_1.widgetIframeTransport.listenToMessageFromWindow(window, types_1.WidgetMethodsEmit.SET_FULL_HEIGHT, ({ isUpToSmall }) => {
185
+ iframe.style.height = isUpToSmall ? defaultHeight : `${maxHeight || document.body.offsetHeight}px`;
186
+ }),
187
+ ];
188
+ }
189
+ //# sourceMappingURL=cowSwapWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cowSwapWidget.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/cowSwapWidget.ts"],"names":[],"mappings":";;AAkDA,kDAsEC;AAvHD,oEAAuE;AAEvE,mEAA+D;AAC/D,+DAA2D;AAC3D,mCAOgB;AAChB,yCAAiF;AACjF,mEAA+D;AAE/D,MAAM,cAAc,GAAG,OAAO,CAAA;AAC9B,MAAM,aAAa,GAAG,OAAO,CAAA;AAE7B;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAE3B,MAAM,WAAW,GAAyB;IACxC,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IAC1B,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IAC7B,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;IAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;CACtB,CAAA;AAYD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,SAAsB,EAAE,KAAyB;IACnF,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;IAC1D,IAAI,QAAQ,GAAG,WAAW,CAAA;I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CAAA;QACjH,CAAC,CAAC;QACF,6CAAqB,CAAC,yBAAyB,CAAC,MAAM,EAAE,yBAAiB,CAAC,eAAe,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;YAC7G,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,IAAI,CAAA;QACpG,CAAC,CAAC;KACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { SupportedChainId } from '@cowprotocol/cow-sdk';
2
+ import { FlexibleConfig, PerNetworkConfig, PerTradeTypeConfig, TradeType } from './types';
3
+ export declare function resolveFlexibleConfig<T>(config: FlexibleConfig<T>, chainId: SupportedChainId, tradeType: TradeType): T | undefined;
4
+ export declare function isPerTradeTypeConfig<T>(config: FlexibleConfig<T>): config is PerTradeTypeConfig<T>;
5
+ export declare function isPerNetworkConfig<T>(config: FlexibleConfig<T>): config is PerNetworkConfig<T>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveFlexibleConfig = resolveFlexibleConfig;
4
+ exports.isPerTradeTypeConfig = isPerTradeTypeConfig;
5
+ exports.isPerNetworkConfig = isPerNetworkConfig;
6
+ const types_1 = require("./types");
7
+ const TradeTypes = Object.values(types_1.TradeType);
8
+ function resolveFlexibleConfig(config, chainId, tradeType) {
9
+ if (isPerTradeTypeConfig(config)) {
10
+ const value = config[tradeType];
11
+ return isPerNetworkConfig(value) ? value[chainId] : value;
12
+ }
13
+ if (isPerNetworkConfig(config)) {
14
+ const value = config[chainId];
15
+ return isPerTradeTypeConfig(value) ? value[tradeType] : value;
16
+ }
17
+ return config;
18
+ }
19
+ function isPerTradeTypeConfig(config) {
20
+ if (typeof config !== 'object')
21
+ return false;
22
+ return Object.keys(config).every((key) => TradeTypes.includes(key));
23
+ }
24
+ const D_REGEX = /^\d+$/;
25
+ function isPerNetworkConfig(config) {
26
+ if (typeof config !== 'object')
27
+ return false;
28
+ return Object.keys(config).every((key) => D_REGEX.test(key));
29
+ }
30
+ //# sourceMappingURL=flexibleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flexibleConfig.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/flexibleConfig.ts"],"names":[],"mappings":";;AAMA,sDAkBC;AAED,oDAIC;AAID,gDAIC;AApCD,mCAAyF;AAEzF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAS,CAAC,CAAA;AAE3C,SAAgB,qBAAqB,CACnC,MAAyB,EACzB,OAAyB,EACzB,SAAoB;IAEpB,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;QAE/B,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAC3D,CAAC;IAED,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAC/D,CAAC;IAED,OAAO,MAAW,CAAA;AACpB,CAAC;AAED,SAAgB,oBAAoB,CAAI,MAAyB;IAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAE5C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAgB,CAAC,CAAC,CAAA;AAC5F,CAAC;AAED,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB,SAAgB,kBAAkB,CAAI,MAAyB;IAC7D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAE5C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AACxE,CAAC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { createCowSwapWidget } from './cowSwapWidget';
2
+ export { widgetIframeTransport } from './widgetIframeTransport';
3
+ export type { CowSwapWidgetHandler } from './cowSwapWidget';
4
+ export { resolveFlexibleConfigValues } from './resolveFlexibleConfigValues';
5
+ export * from './types';
6
+ export * from './themeUtils';
7
+ export * from './flexibleConfig';
package/src/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveFlexibleConfigValues = exports.widgetIframeTransport = exports.createCowSwapWidget = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var cowSwapWidget_1 = require("./cowSwapWidget");
6
+ Object.defineProperty(exports, "createCowSwapWidget", { enumerable: true, get: function () { return cowSwapWidget_1.createCowSwapWidget; } });
7
+ var widgetIframeTransport_1 = require("./widgetIframeTransport");
8
+ Object.defineProperty(exports, "widgetIframeTransport", { enumerable: true, get: function () { return widgetIframeTransport_1.widgetIframeTransport; } });
9
+ var resolveFlexibleConfigValues_1 = require("./resolveFlexibleConfigValues");
10
+ Object.defineProperty(exports, "resolveFlexibleConfigValues", { enumerable: true, get: function () { return resolveFlexibleConfigValues_1.resolveFlexibleConfigValues; } });
11
+ tslib_1.__exportStar(require("./types"), exports);
12
+ tslib_1.__exportStar(require("./themeUtils"), exports);
13
+ tslib_1.__exportStar(require("./flexibleConfig"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/index.ts"],"names":[],"mappings":";;;;AAAA,iDAAqD;AAA5C,oHAAA,mBAAmB,OAAA;AAC5B,iEAA+D;AAAtD,8HAAA,qBAAqB,OAAA;AAE9B,6EAA2E;AAAlE,0IAAA,2BAA2B,OAAA;AAEpC,kDAAuB;AACvB,uDAA4B;AAC5B,2DAAgC"}
@@ -0,0 +1,2 @@
1
+ import { FlexibleConfig } from './types';
2
+ export declare function resolveFlexibleConfigValues<T>(config: FlexibleConfig<T>): T[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveFlexibleConfigValues = resolveFlexibleConfigValues;
4
+ const flexibleConfig_1 = require("./flexibleConfig");
5
+ function resolveFlexibleConfigValues(config) {
6
+ if ((0, flexibleConfig_1.isPerTradeTypeConfig)(config)) {
7
+ return Object.values(config).flatMap((value) => ((0, flexibleConfig_1.isPerNetworkConfig)(value) ? Object.values(value) : [value]));
8
+ }
9
+ if ((0, flexibleConfig_1.isPerNetworkConfig)(config)) {
10
+ return Object.values(config).flatMap((value) => ((0, flexibleConfig_1.isPerTradeTypeConfig)(value) ? Object.values(value) : [value]));
11
+ }
12
+ return [config];
13
+ }
14
+ //# sourceMappingURL=resolveFlexibleConfigValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveFlexibleConfigValues.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/resolveFlexibleConfigValues.ts"],"names":[],"mappings":";;AAGA,kEAUC;AAbD,qDAA2E;AAG3E,SAAgB,2BAA2B,CAAI,MAAyB;IACtE,IAAI,IAAA,qCAAoB,EAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAA,mCAAkB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC/G,CAAC;IAED,IAAI,IAAA,mCAAkB,EAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAA,qCAAoB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACjH,CAAC;IAED,OAAO,CAAC,MAAM,CAAQ,CAAA;AACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { CowSwapTheme, CowSwapWidgetPalette } from './types';
2
+ export declare function isCowSwapWidgetPalette(palette: CowSwapTheme | CowSwapWidgetPalette | undefined): palette is CowSwapWidgetPalette;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isCowSwapWidgetPalette = isCowSwapWidgetPalette;
4
+ function isCowSwapWidgetPalette(palette) {
5
+ return Boolean(palette && typeof palette === 'object');
6
+ }
7
+ //# sourceMappingURL=themeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themeUtils.js","sourceRoot":"","sources":["../../../../libs/widget-lib/src/themeUtils.ts"],"names":[],"mappings":";;AAEA,wDAIC;AAJD,SAAgB,sBAAsB,CACpC,OAAwD;IAExD,OAAO,OAAO,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAA;AACxD,CAAC"}