@swapper-finance/deposit-sdk 0.0.7 → 0.1.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.
- package/README.md +1 -1
- package/dist/SwapperIframe.d.ts.map +1 -1
- package/dist/SwapperIframe.js +1 -1
- package/dist/SwapperIframe.js.map +1 -1
- package/dist/SwapperModal.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapperIframe.d.ts","sourceRoot":"","sources":["../src/SwapperIframe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EAEnB,aAAa,EACb,YAAY,EACZ,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAUjB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,eAAe,CAAC,CAAgC;gBAM5C,OAAO,EAAE,oBAAoB;IA6BzC,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"SwapperIframe.d.ts","sourceRoot":"","sources":["../src/SwapperIframe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EAEnB,aAAa,EACb,YAAY,EACZ,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAUjB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,eAAe,CAAC,CAAgC;gBAM5C,OAAO,EAAE,oBAAoB;IA6BzC,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,YAAY;IAkFpB,OAAO,CAAC,oBAAoB;IAoCrB,KAAK,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;IAqB5C,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IAelD,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAQzC,yBAAyB,CAAC,mBAAmB,EAAE,YAAY,EAAE,GAAG,IAAI;IAQpE,6BAA6B,CAClC,uBAAuB,EAAE,sBAAsB,EAAE,GAChD,IAAI;IAQA,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAOjD,OAAO,CAAC,WAAW;IAUZ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAYzD,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAa1D,SAAS,IAAI,iBAAiB;IAO9B,SAAS,IAAI,aAAa;IAO1B,OAAO,IAAI,IAAI;CAcvB"}
|
package/dist/SwapperIframe.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const DEFAULT_IFRAME_URL="https://swapper-deposit-sdk.web.app/";export class SwapperIframe{constructor(t){this.eventHandlers=new Map,this.validateConfig(t),this.config={integratorId:t.integratorId,dstChainId:t.dstChainId,dstTokenAddr:t.dstTokenAddr,depositWalletAddress:t.depositWalletAddress,styles:t.styles,customContractCalls:t.customContractCalls,supportedDepositOptions:t.supportedDepositOptions,webhookUrl:t.webhookUrl},this.iframeUrl=t.iframeUrl||DEFAULT_IFRAME_URL,this.iframe=this.createIframe(t),this.setupMessageListener(),t.container&&this.mount(t.container)}validateConfig(t){const e=["integratorId","dstChainId","dstTokenAddr","depositWalletAddress"];for(const s of e)if(!t[s])throw new Error(`Missing required parameter: ${s}`)}createIframe(t){const e=document.createElement("iframe"),s=new URL(this.iframeUrl);
|
|
1
|
+
const DEFAULT_IFRAME_URL="https://swapper-deposit-sdk.web.app/";export class SwapperIframe{constructor(t){this.eventHandlers=new Map,this.validateConfig(t),this.config={integratorId:t.integratorId,dstChainId:t.dstChainId,dstTokenAddr:t.dstTokenAddr,depositWalletAddress:t.depositWalletAddress,styles:t.styles,customContractCalls:t.customContractCalls,supportedDepositOptions:t.supportedDepositOptions,webhookUrl:t.webhookUrl},this.iframeUrl=t.iframeUrl||DEFAULT_IFRAME_URL,this.iframe=this.createIframe(t),this.setupMessageListener(),t.container&&this.mount(t.container)}validateConfig(t){const e=["integratorId","dstChainId","dstTokenAddr","depositWalletAddress"];for(const s of e)if(!t[s])throw new Error(`Missing required parameter: ${s}`)}createIframe(t){const e=document.createElement("iframe"),s=new URL(this.iframeUrl);s.searchParams.set("integratorId",this.config.integratorId),s.searchParams.set("dstChainId",this.config.dstChainId),s.searchParams.set("dstTokenAddr",this.config.dstTokenAddr),s.searchParams.set("depositWalletAddress",this.config.depositWalletAddress),this.config.styles&&s.searchParams.set("styles",JSON.stringify(this.config.styles)),this.config.customContractCalls&&s.searchParams.set("customContractCalls",JSON.stringify(this.config.customContractCalls)),this.config.supportedDepositOptions&&s.searchParams.set("supportedDepositOptions",JSON.stringify(this.config.supportedDepositOptions)),this.config.webhookUrl&&s.searchParams.set("webhookUrl",this.config.webhookUrl),e.src=s.toString(),e.style.border="none",e.style.width=t.iframeAttributes?.width||"100%",e.style.height=t.iframeAttributes?.height||"600px",e.title=t.iframeAttributes?.title||"Swapper Deposit Widget";const i="camera clipboard-write",r=t.iframeAttributes?.allow||"",o=r?`${i} ${r}`:i;e.setAttribute("allow",o);const a="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts",n=t.iframeAttributes?.sandbox||"",d=n?`${a} ${n}`:a;return e.setAttribute("sandbox",d),t.iframeAttributes&&Object.entries(t.iframeAttributes).forEach(([t,s])=>{s&&"width"!==t&&"height"!==t&&"title"!==t&&"allow"!==t&&"sandbox"!==t&&e.setAttribute(t,s)}),e}setupMessageListener(){this.messageListener=t=>{const e=new URL(this.iframeUrl).origin;if(t.origin===e&&t.data&&"object"==typeof t.data){const e={type:t.data.type,data:t.data.data},s=this.eventHandlers.get(e.type);s&&s.forEach(t=>t(e));const i=this.eventHandlers.get("*");i&&i.forEach(t=>t(e))}},window.addEventListener("message",this.messageListener)}mount(t){const e="string"==typeof t?document.querySelector(t):t;if(!e)throw new Error(`Container not found: ${"string"==typeof t?t:"provided element"}`);e.appendChild(this.iframe)}updateConfig(t){this.config={...this.config,...t},this.sendMessage({type:"SWAPPER_CONFIG",config:t})}updateStyles(t){this.updateConfig({styles:t})}updateCustomContractCalls(t){this.updateConfig({customContractCalls:t})}updateSupportedDepositOptions(t){this.updateConfig({supportedDepositOptions:t})}updateWebhookUrl(t){this.updateConfig({webhookUrl:t})}sendMessage(t){const e=new URL(this.iframeUrl).origin;this.iframe.contentWindow?.postMessage(t,e)}on(t,e){this.eventHandlers.has(t)||this.eventHandlers.set(t,new Set),this.eventHandlers.get(t).add(e)}off(t,e){const s=this.eventHandlers.get(t);s&&(s.delete(e),0===s.size&&this.eventHandlers.delete(t))}getIframe(){return this.iframe}getConfig(){return{...this.config}}destroy(){this.messageListener&&window.removeEventListener("message",this.messageListener),this.eventHandlers.clear(),this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapperIframe.js","sourceRoot":"","sources":["../src/SwapperIframe.ts"],"names":[],"mappings":"AAaA,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AAKlE,MAAM,OAAO,aAAa;IAWxB,YAAY,OAA6B;QAPjC,kBAAa,GAA0C,IAAI,GAAG,EAAE,CAAC;QAQvE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE7B,IAAI,CAAC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d,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAKM,OAAO;QAEZ,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9D,CAAC;QAGD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAG3B,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF"}
|
package/dist/SwapperModal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SwapperIframe}from"./SwapperIframe";export class SwapperModal{constructor(e){this.iframe=null,this.overlay=null,this.modalContainer=null,this.iframeContainer=null,this.isOpen=!1,this.options=e}open(){this.isOpen||(this.createModal(),this.isOpen=!0)}close(){this.isOpen&&(this.destroyModal(),this.isOpen=!1,this.options.onClose&&this.options.onClose())}isModalOpen(){return this.isOpen}getIframe(){return this.iframe}createModal(){const e=this.options.modalStyle||{};if(this.overlay=document.createElement("div"),this.overlay.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: ${e.overlayColor||"rgba(0, 0, 0, 0.7)"};\n z-index: ${e.zIndex||1e4};\n display: flex;\n align-items: center;\n justify-content: center;\n animation: swapper-fade-in 0.2s ease-out;\n `,!document.getElementById("swapper-modal-styles")){const e=document.createElement("style");e.id="swapper-modal-styles",e.textContent="\n @keyframes swapper-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes swapper-scale-in {\n from {\n transform: scale(0.95);\n opacity: 0;\n }\n to {\n transform: scale(1);\n opacity: 1;\n }\n }\n ",document.head.appendChild(e)}this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.close()});const t=e=>{"Escape"===e.key&&(this.close(),document.removeEventListener("keydown",t))};if(document.addEventListener("keydown",t),this.modalContainer=document.createElement("div"),this.modalContainer.style.cssText=`\n position: relative;\n width: ${e.width||"
|
|
1
|
+
import{SwapperIframe}from"./SwapperIframe";export class SwapperModal{constructor(e){this.iframe=null,this.overlay=null,this.modalContainer=null,this.iframeContainer=null,this.isOpen=!1,this.options=e}open(){this.isOpen||(this.createModal(),this.isOpen=!0)}close(){this.isOpen&&(this.destroyModal(),this.isOpen=!1,this.options.onClose&&this.options.onClose())}isModalOpen(){return this.isOpen}getIframe(){return this.iframe}createModal(){const e=this.options.modalStyle||{};if(this.overlay=document.createElement("div"),this.overlay.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: ${e.overlayColor||"rgba(0, 0, 0, 0.7)"};\n z-index: ${e.zIndex||1e4};\n display: flex;\n align-items: center;\n justify-content: center;\n animation: swapper-fade-in 0.2s ease-out;\n `,!document.getElementById("swapper-modal-styles")){const e=document.createElement("style");e.id="swapper-modal-styles",e.textContent="\n @keyframes swapper-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes swapper-scale-in {\n from {\n transform: scale(0.95);\n opacity: 0;\n }\n to {\n transform: scale(1);\n opacity: 1;\n }\n }\n ",document.head.appendChild(e)}this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.close()});const t=e=>{"Escape"===e.key&&(this.close(),document.removeEventListener("keydown",t))};if(document.addEventListener("keydown",t),this.modalContainer=document.createElement("div"),this.modalContainer.style.cssText=`\n position: relative;\n width: ${e.width||"450px"};\n height: ${e.height||"560px"};\n background: transparent;\n border-radius: ${e.borderRadius||"16px"};\n overflow: hidden;\n animation: swapper-scale-in 0.3s ease-out;\n `,!0===e.showCloseButton){const t=document.createElement("button");t.innerHTML="×",t.style.cssText=`\n position: absolute;\n top: 12px;\n right: 12px;\n width: 32px;\n height: 32px;\n border: none;\n background: rgba(0, 0, 0, 0.5);\n color: white;\n font-size: 24px;\n line-height: 1;\n border-radius: 50%;\n cursor: pointer;\n z-index: ${(e.zIndex||1e4)+1};\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.2s ease;\n `,t.onmouseover=()=>{t.style.background="rgba(0, 0, 0, 0.7)"},t.onmouseout=()=>{t.style.background="rgba(0, 0, 0, 0.5)"},t.onclick=()=>this.close(),this.modalContainer.appendChild(t)}this.iframeContainer=document.createElement("div"),this.iframeContainer.style.cssText="\n width: 100%;\n height: 100%;\n ",this.modalContainer.appendChild(this.iframeContainer),this.overlay.appendChild(this.modalContainer),document.body.appendChild(this.overlay),document.body.style.overflow="hidden",this.iframe=new SwapperIframe({container:this.iframeContainer,integratorId:this.options.integratorId,dstChainId:this.options.dstChainId,dstTokenAddr:this.options.dstTokenAddr,depositWalletAddress:this.options.depositWalletAddress,styles:this.options.styles,customContractCalls:this.options.customContractCalls,supportedDepositOptions:this.options.supportedDepositOptions,webhookUrl:this.options.webhookUrl,iframeUrl:this.options.iframeUrl,iframeAttributes:{...this.options.iframeAttributes,width:"100%",height:"100%"}})}destroyModal(){this.iframe&&(this.iframe.destroy(),this.iframe=null),this.overlay&&this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay),document.body.style.overflow="",this.overlay=null,this.modalContainer=null,this.iframeContainer=null}destroy(){this.close()}}export function openSwapperModal(e){const t=new SwapperModal(e);return t.open(),t}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { SwapperIframe } from "./SwapperIframe";
|
|
2
2
|
export { SwapperModal, openSwapperModal } from "./SwapperModal";
|
|
3
3
|
export type { SwapperModalOptions } from "./SwapperModal";
|
|
4
|
-
export { ThemeMode,
|
|
4
|
+
export { ThemeMode, ComponentStyles, SwapperStyles, SupportedDepositOption, ContractCallType, ContractCall, SwapperConfig, SwapperIframeOptions, SwapperEvent, SwapperEventHandler, } from "./types";
|
|
5
5
|
export { approve, transfer, transferFrom, approveBalance, transferBalance, } from "./helpers";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,SAAS,EACT,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,OAAO,EACP,QAAQ,EACR,YAAY,EAEZ,cAAc,EACd,eAAe,GAChB,MAAM,WAAW,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAKL,gBAAgB,GAMjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,OAAO,EACP,QAAQ,EACR,YAAY,EAEZ,cAAc,EACd,eAAe,GAChB,MAAM,WAAW,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
export type ThemeMode = "light" | "dark";
|
|
2
|
-
export interface BrandTheme {
|
|
3
|
-
primaryColor?: string;
|
|
4
|
-
secondaryColor?: string;
|
|
5
|
-
}
|
|
6
2
|
export interface ComponentStyles {
|
|
7
|
-
backgroundColor?: string;
|
|
8
|
-
borderRadius?: string;
|
|
9
|
-
width?: string;
|
|
10
|
-
textColor?: string;
|
|
11
|
-
primaryButtonBackground?: string;
|
|
12
|
-
primaryButtonText?: string;
|
|
13
|
-
secondaryButtonBackground?: string;
|
|
14
|
-
secondaryButtonText?: string;
|
|
15
|
-
disabledButtonBackground?: string;
|
|
16
|
-
disabledButtonText?: string;
|
|
17
|
-
successColor?: string;
|
|
18
|
-
warningColor?: string;
|
|
19
|
-
errorColor?: string;
|
|
20
3
|
primaryColor?: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
inputBorder?: string;
|
|
24
|
-
cardBackground?: string;
|
|
25
|
-
borderColor?: string;
|
|
4
|
+
primaryBorderColor?: string;
|
|
5
|
+
accentColor?: string;
|
|
26
6
|
}
|
|
27
7
|
export interface SwapperStyles {
|
|
28
8
|
themeMode?: ThemeMode;
|
|
29
|
-
|
|
9
|
+
componentStyles?: ComponentStyles;
|
|
30
10
|
}
|
|
31
|
-
export type SupportedDepositOption = "transferCrypto" | "depositWithCash";
|
|
11
|
+
export type SupportedDepositOption = "transferCrypto" | "depositWithCash" | "walletDeposit";
|
|
32
12
|
export declare enum ContractCallType {
|
|
33
13
|
DEFAULT = 0,
|
|
34
14
|
FULL_TOKEN_BALANCE = 1,
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAKzC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAKzC,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,MAAM,WAAW,aAAa;IAI5B,SAAS,CAAC,EAAE,SAAS,CAAC;IAKtB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAKD,MAAM,MAAM,sBAAsB,GAC9B,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,CAAC;AAKpB,oBAAY,gBAAgB;IAC1B,OAAO,IAAI;IACX,kBAAkB,IAAI;IACtB,mBAAmB,IAAI;IACvB,qBAAqB,IAAI;CAC1B;AAKD,MAAM,WAAW,YAAY;IAI3B,QAAQ,EAAE,gBAAgB,CAAC;IAK3B,MAAM,EAAE,MAAM,CAAC;IAKf,KAAK,EAAE,MAAM,CAAC;IAKd,QAAQ,EAAE,MAAM,CAAC;IAKjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,MAAM,WAAW,aAAa;IAI5B,YAAY,EAAE,MAAM,CAAC;IAKrB,UAAU,EAAE,MAAM,CAAC;IAKnB,YAAY,EAAE,MAAM,CAAC;IAKrB,oBAAoB,EAAE,MAAM,CAAC;IAK7B,MAAM,CAAC,EAAE,aAAa,CAAC;IAKvB,mBAAmB,CAAC,EAAE,YAAY,EAAE,CAAC;IAKrC,uBAAuB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAKnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAKD,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IAKzD,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAKjC,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,gBAAgB,CAAC,EAAE;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KACnC,CAAC;CACH;AAKD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAKD,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAwCA,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6DAAW,CAAA;IACX,mFAAsB,CAAA;IACtB,qFAAuB,CAAA;IACvB,yFAAyB,CAAA;AAC3B,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B"}
|