@lvble/core 2.0.18 → 2.0.19

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.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MyLib",[],t):"object"==typeof exports?exports.MyLib=t():e.MyLib=t()}(self,(()=>(()=>{"use strict";var e={915:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(755),t)},755:function(e,t){var n,o,i,r,a=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)});Object.defineProperty(t,"__esModule",{value:!0}),t.Lvble=t.Environment=void 0,function(e){e.Local="local",e.Sandbox="sandbox",e.Production="production"}(r||(t.Environment=r={}));var c,s=((o={})[r.Local]="http://localhost:3001",o[r.Sandbox]="https://widget.sandbox.pms.nowlvble.com",o[r.Production]="https://api.production.partners.nowlvble.com",o),l=((i={})[r.Local]="http://localhost:3001",i[r.Sandbox]="https://experience.sandbox.pms.nowlvble.com",i[r.Production]="https://api.production.partners.nowlvble.com",i);!function(e){e.FinishOnboarding="finishOnboarding",e.FinishOffboarding="finishOffboarding",e.FinishSplit="finishSplit",e.FinishRepay="finishRepay"}(c||(c={})),c.FinishOnboarding,c.FinishOffboarding,c.FinishSplit,c.FinishRepay;var u=function(e){function t(){var t=e.call(this)||this;return Object.defineProperty(t,"_typeToEvent",{enumerable:!0,configurable:!0,writable:!0,value:{onboarding:c.FinishOnboarding,offboarding:c.FinishOffboarding,split:c.FinishSplit,repay:c.FinishRepay}}),Object.defineProperty(t,"_iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t.attachShadow({mode:"open"}),t}return a(t,e),Object.defineProperty(t.prototype,"mode",{get:function(){return this.getAttribute("mode")},set:function(e){e?this.setAttribute("mode",e):this.removeAttribute("mode")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environment",{get:function(){return this.getAttribute("environment")},set:function(e){e?this.setAttribute("environment",e):this.removeAttribute("environment")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"token",{get:function(){return this.getAttribute("token")},set:function(e){e?this.setAttribute("token",e):this.removeAttribute("token")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectedCallback",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t="".concat(s[this.environment],"?token=").concat(this.token,"&environment=").concat(this.environment),n=document.createElement("iframe");n.src=t,n.width="100%",n.height="100%",n.style.borderStyle="solid",n.style.borderRadius="10px",n.style.borderColor="transparent",this._iframe=n,null===(e=this.shadowRoot)||void 0===e||e.appendChild(n)}}),Object.defineProperty(t.prototype,"disconnectedCallback",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.shadowRoot&&(this.shadowRoot.innerHTML="")}}),t}(HTMLElement);customElements.define("lvble-widget",u),customElements.get("lvble-widget"),customElements.get("lvble-widget"),t.Lvble=function(e){return{createWidget:function(t){var n=new u;return n.environment=e.environment,n.token=e.token,n.mode=t.mode,window.addEventListener("message",(function(n){if(n.origin==s[e.environment]){var o=n.data;t.onEvent(o.eventType,o)}else console.debug("Received message from unknown origin: ".concat(n.origin))})),n},open:function(t){var n={onboarding:"".concat(l[e.environment],"?token=").concat(e.token),offboarding:"".concat(l[e.environment],"?token=").concat(e.token),split:"".concat(l[e.environment],"?token=").concat(e.token),repay:"".concat(l[e.environment],"?token=").concat(e.token)},o=t.mode?n[t.mode]:"",i=screen.width/2-225,r=screen.height/2-400;window.open(o,"LvblePopup","width=450,height=800,location=no,left="+i+",top="+r),window.addEventListener("message",(function(n){if(n.origin==l[e.environment]){var o=n.data,i=document.querySelectorAll("lvble-widget");n=JSON.parse(JSON.stringify(n)),i.forEach((function(e){var t,o;null===(o=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector("iframe")).contentWindow)||void 0===o||o.postMessage(n,"*")})),t.onEvent(o.eventType,o)}else console.debug("Received message from unknown origin: ".concat(n.origin))}))}}}}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}(915)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MyLib",[],t):"object"==typeof exports?exports.MyLib=t():e.MyLib=t()}(self,(()=>(()=>{"use strict";var e={915:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(755),t)},755:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Lvble=t.Environment=void 0,function(e){e.Local="local",e.Sandbox="sandbox",e.Production="production"}(n||(t.Environment=n={}));const o={[n.Local]:"http://localhost:3001",[n.Sandbox]:"https://widget.sandbox.pms.nowlvble.com",[n.Production]:"https://api.production.partners.nowlvble.com"},i={[n.Local]:"http://localhost:3001",[n.Sandbox]:"https://experience.sandbox.pms.nowlvble.com",[n.Production]:"https://api.production.partners.nowlvble.com"};var r;!function(e){e.FinishOnboarding="finishOnboarding",e.FinishOffboarding="finishOffboarding",e.FinishSplit="finishSplit",e.FinishRepay="finishRepay"}(r||(r={})),r.FinishOnboarding,r.FinishOffboarding,r.FinishSplit,r.FinishRepay;class s extends HTMLElement{constructor(){super(),Object.defineProperty(this,"_typeToEvent",{enumerable:!0,configurable:!0,writable:!0,value:{onboarding:r.FinishOnboarding,offboarding:r.FinishOffboarding,split:r.FinishSplit,repay:r.FinishRepay}}),Object.defineProperty(this,"_iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.attachShadow({mode:"open"})}get mode(){return this.getAttribute("mode")}set mode(e){e?this.setAttribute("mode",e):this.removeAttribute("mode")}get environment(){return this.getAttribute("environment")}set environment(e){e?this.setAttribute("environment",e):this.removeAttribute("environment")}get token(){return this.getAttribute("token")}set token(e){e?this.setAttribute("token",e):this.removeAttribute("token")}connectedCallback(){var e;const t=`${o[this.environment]}?token=${this.token}&environment=${this.environment}`,n=document.createElement("iframe");n.src=t,n.width="100%",n.height="100%",n.style.borderStyle="solid",n.style.borderRadius="10px",n.style.borderColor="transparent",this._iframe=n,null===(e=this.shadowRoot)||void 0===e||e.appendChild(n)}disconnectedCallback(){this.shadowRoot&&(this.shadowRoot.innerHTML="")}}let d;customElements.define("lvble-widget",s),customElements.get("lvble-widget"),customElements.get("lvble-widget"),t.Lvble=e=>({createWidget:t=>{const n=new s;return n.environment=e.environment,n.token=e.token,n.mode=t.mode,window.addEventListener("message",(n=>{if(n.origin!=o[e.environment])return void console.debug(`Received message from unknown origin: ${n.origin}`);const i=n.data;t.onEvent(i.eventType,i)})),n},open:t=>{const n={onboarding:`${i[e.environment]}?token=${e.token}`,offboarding:`${i[e.environment]}?token=${e.token}`,split:`${i[e.environment]}?token=${e.token}`,repay:`${i[e.environment]}?token=${e.token}`},o=t.mode?n[t.mode]:"",r=screen.width/2-225,s=screen.height/2-400;d=window.open(o,"LvblePopup","width=450,height=800,location=no,left="+r+",top="+s),window.addEventListener("message",(n=>{if(n.origin!=i[e.environment])return void console.debug(`Received message from unknown origin: ${n.origin}`);const o=n.data,r=document.querySelectorAll("lvble-widget");n=JSON.parse(JSON.stringify(n)),r.forEach((e=>{var t,o;null===(o=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector("iframe")).contentWindow)||void 0===o||o.postMessage(n,"*")})),t.onEvent(o.eventType,o)}))}})}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}(915)})()));
2
2
  //# sourceMappingURL=core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,QAAS,GAAIH,GACM,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,GACjB,CATD,CASGK,MAAM,I,mhBCTT,W,8BCAYC,E,uiBAAZ,SAAYA,GACV,gBACA,oBACA,yBACD,CAJD,CAAYA,IAAW,cAAXA,EAAW,KAKvB,IAuCKC,EAvCCC,IAAqB,MACxBF,EAAYG,OAAQ,wBACrB,EAACH,EAAYI,SAAU,0CACvB,EAACJ,EAAYK,YAAa,+C,GAGtBC,IAAyB,MAC5BN,EAAYG,OAAQ,wBACrB,EAACH,EAAYI,SAAU,8CACvB,EAACJ,EAAYK,YAAa,+C,IA8B5B,SAAKJ,GACH,sCACA,wCACA,4BACA,2BACD,CALD,CAAKA,IAAAA,EAAS,KAQAA,EAAUM,iBACTN,EAAUO,kBAChBP,EAAUQ,YACVR,EAAUS,YAJnB,IA2BA,cASE,mBACE,cAAO,K,OATT,wC,gDAAe,CACb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,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAapF,QAGrB,IAAIC,EAASgF,EAAyBE,GAAY,CAGjDnF,QAAS,CAAC,GAOX,OAHAsF,EAAoBH,GAAUI,KAAKtF,EAAOD,QAASC,EAAQA,EAAOD,QAASkF,GAGpEjF,EAAOD,OACf,CCnB0BkF,CAAoB,I","sources":["webpack://MyLib/webpack/universalModuleDefinition","webpack://MyLib/./src/lib/index.ts","webpack://MyLib/./src/lib/lvble.ts","webpack://MyLib/webpack/bootstrap","webpack://MyLib/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MyLib\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLib\"] = factory();\n\telse\n\t\troot[\"MyLib\"] = factory();\n})(self, () => {\nreturn ","export * from './lvble'\n","export enum Environment {\n Local = \"local\",\n Sandbox = \"sandbox\",\n Production = \"production\",\n}\nconst envToBaseUrlMapWidget: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://widget.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nconst envToBaseUrlMapExperience: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://experience.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nexport type Mode = \"onboarding\" | \"offboarding\" | \"split\" | \"repay\";\nexport type ErrorData = {\n type: \"error\";\n reason: string;\n};\nexport type OnboardingData =\n | ErrorData\n | {\n type: \"success\";\n status: string;\n };\nexport type SplitData =\n | ErrorData\n | {\n type: \"success\";\n external_id: string;\n settlement_id: string;\n amount: number;\n };\nexport type CloseData =\n | ErrorData\n | {\n type: \"close\";\n };\n// TODO: Make this the event type in the onEvent callback signature\nexport type EventData = OnboardingData | SplitData | CloseData;\n\nenum EventType {\n FinishOnboarding = \"finishOnboarding\",\n FinishOffboarding = \"finishOffboarding\",\n FinishSplit = \"finishSplit\",\n FinishRepay = \"finishRepay\",\n}\n\nconst modeToEventType = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n};\n\nexport interface InitOptions {\n // The environment to use.\n environment: Environment;\n // The widget token to use.\n token: string;\n}\n\nexport interface OpenOptions {\n // The mode to open the popup in. See Mode for more information.\n mode?: Mode;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nexport interface CreateWidgetOptions extends OpenOptions {\n mode?: Extract<Mode, \"onboarding\" | \"repay\">;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nclass LvbleWidget extends HTMLElement {\n _typeToEvent = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n };\n _iframe?: HTMLIFrameElement;\n\n constructor() {\n super();\n this.attachShadow({ mode: \"open\" });\n }\n\n get mode(): Mode {\n return this.getAttribute(\"mode\") as Mode;\n }\n\n set mode(val: Mode | undefined) {\n if (val) {\n this.setAttribute(\"mode\", val);\n } else {\n this.removeAttribute(\"mode\");\n }\n }\n\n get environment(): Environment {\n return this.getAttribute(\"environment\") as Environment;\n }\n\n set environment(val) {\n if (val) {\n this.setAttribute(\"environment\", val);\n } else {\n this.removeAttribute(\"environment\");\n }\n }\n\n get token() {\n return this.getAttribute(\"token\") as string;\n }\n\n set token(val: string) {\n if (val) {\n this.setAttribute(\"token\", val);\n } else {\n this.removeAttribute(\"token\");\n }\n }\n\n connectedCallback() {\n const iframeSrc = `${envToBaseUrlMapWidget[this.environment]}?token=${\n this.token\n }&environment=${this.environment}`;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = iframeSrc;\n iframe.width = `100%`;\n iframe.height = `100%`;\n iframe.style.borderStyle = \"solid\";\n iframe.style.borderRadius = \"10px\";\n iframe.style.borderColor = \"transparent\";\n this._iframe = iframe;\n\n this.shadowRoot?.appendChild(iframe);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) this.shadowRoot.innerHTML = \"\";\n }\n}\n\ncustomElements.define(\"lvble-widget\", LvbleWidget);\n\nconst modeWidgetMap: Record<\n Extract<Mode, \"onboarding\" | \"repay\">,\n CustomElementConstructor | undefined\n> = {\n onboarding: customElements.get(\"lvble-widget\"),\n repay: customElements.get(\"lvble-widget\"),\n};\n\nlet _popup: Window;\n\nconst lvble = (initOptions: InitOptions) => {\n return {\n /**\n * This function creates a widget that can be embedded in your website.\n *\n * @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.\n * @returns The widget.\n */\n // TODO: Add support for no mode\n createWidget: (createOptions: CreateWidgetOptions) => {\n const widget = new LvbleWidget()\n \n // (\n // createOptions.mode\n // ? new modeWidgetMap[createOptions.mode]!()\n // : new (customElements.get(\n // \"lvble-widget\"\n // ) as CustomElementConstructor)()\n // ) as LvbleWidget;\n widget.environment = initOptions.environment;\n widget.token = initOptions.token;\n widget.mode = createOptions.mode;\n\n const messageListener = (message: MessageEvent) => {\n if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n\n const data = message.data;\n createOptions.onEvent(data.eventType, data);\n };\n window.addEventListener(\"message\", messageListener);\n return widget;\n },\n /**\n * This function opens a popup with the relevant mode.\n * @param openOptions The options for opening the widget. See OpenOptions for more information.\n * @returns undefined.\n */\n open: (openOptions: OpenOptions) => {\n const modeUrlMap: Record<Mode, string> = {\n onboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n offboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n split: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n repay: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n };\n\n const modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : \"\";\n\n const w = 450;\n const h = 800;\n const l = screen.width / 2 - w / 2;\n const t = screen.height / 2 - h / 2;\n _popup = window.open(\n modeUrl,\n \"LvblePopup\",\n \"width=\" + w + \",height=\" + h + \",location=no,left=\" + l + \",top=\" + t\n ) as Window;\n\n const messageListener = (message: MessageEvent) => {\n if (\n message.origin != envToBaseUrlMapExperience[initOptions.environment]\n ) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n const eventData = message.data;\n const iframes = document.querySelectorAll(\"lvble-widget\");\n\n message = JSON.parse(JSON.stringify(message));\n\n iframes.forEach((w) => {\n (\n w.shadowRoot?.querySelector(\"iframe\") as HTMLIFrameElement\n ).contentWindow?.postMessage(message, \"*\");\n });\n\n openOptions.onEvent(eventData.eventType, eventData);\n };\n\n window.addEventListener(\"message\", messageListener);\n },\n };\n};\n\nexport type LvbleType = ReturnType<typeof lvble>;\n\nexport const Lvble = lvble;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(915);\n"],"names":["root","factory","exports","module","define","amd","self","Environment","EventType","envToBaseUrlMapWidget","Local","Sandbox","Production","envToBaseUrlMapExperience","FinishOnboarding","FinishOffboarding","FinishSplit","FinishRepay","onboarding","offboarding","split","repay","attachShadow","mode","this","getAttribute","val","setAttribute","removeAttribute","iframeSrc","environment","token","iframe","document","createElement","src","width","height","style","borderStyle","borderRadius","borderColor","_iframe","shadowRoot","appendChild","innerHTML","HTMLElement","customElements","LvbleWidget","get","Lvble","initOptions","createWidget","createOptions","widget","window","addEventListener","message","origin","data","onEvent","eventType","console","debug","open","openOptions","modeUrlMap","modeUrl","l","screen","w","t","h","eventData","iframes","querySelectorAll","JSON","parse","stringify","forEach","querySelector","contentWindow","postMessage","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
1
+ {"version":3,"file":"core.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,QAAS,GAAIH,GACM,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,GACjB,CATD,CASGK,MAAM,I,mhBCTT,W,cCAA,IAAYC,E,8EAAZ,SAAYA,GACV,gBACA,oBACA,yBACD,CAJD,CAAYA,IAAW,cAAXA,EAAW,KAKvB,MAAMC,EAAqD,CACzD,CAACD,EAAYE,OAAQ,wBACrB,CAACF,EAAYG,SAAU,0CACvB,CAACH,EAAYI,YAAa,gDAGtBC,EAAyD,CAC7D,CAACL,EAAYE,OAAQ,wBACrB,CAACF,EAAYG,SAAU,8CACvB,CAACH,EAAYI,YAAa,gDA8B5B,IAAKE,GAAL,SAAKA,GACH,sCACA,wCACA,4BACA,2BACD,CALD,CAAKA,IAAAA,EAAS,KAQAA,EAAUC,iBACTD,EAAUE,kBAChBF,EAAUG,YACVH,EAAUI,YAuBnB,MAAMC,UAAoBC,YASxB,WAAAC,GACEC,QATF,2C,gDAAe,CACbC,W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,QAAS,CAAC,GAOX,OAHA2F,EAAoBH,GAAUI,KAAK3F,EAAOD,QAASC,EAAQA,EAAOD,QAASuF,GAGpEtF,EAAOD,OACf,CCnB0BuF,CAAoB,I","sources":["webpack://MyLib/webpack/universalModuleDefinition","webpack://MyLib/./src/lib/index.ts","webpack://MyLib/./src/lib/lvble.ts","webpack://MyLib/webpack/bootstrap","webpack://MyLib/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MyLib\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLib\"] = factory();\n\telse\n\t\troot[\"MyLib\"] = factory();\n})(self, () => {\nreturn ","export * from './lvble'\n","export enum Environment {\n Local = \"local\",\n Sandbox = \"sandbox\",\n Production = \"production\",\n}\nconst envToBaseUrlMapWidget: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://widget.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nconst envToBaseUrlMapExperience: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://experience.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nexport type Mode = \"onboarding\" | \"offboarding\" | \"split\" | \"repay\";\nexport type ErrorData = {\n type: \"error\";\n reason: string;\n};\nexport type OnboardingData =\n | ErrorData\n | {\n type: \"success\";\n status: string;\n };\nexport type SplitData =\n | ErrorData\n | {\n type: \"success\";\n external_id: string;\n settlement_id: string;\n amount: number;\n };\nexport type CloseData =\n | ErrorData\n | {\n type: \"close\";\n };\n// TODO: Make this the event type in the onEvent callback signature\nexport type EventData = OnboardingData | SplitData | CloseData;\n\nenum EventType {\n FinishOnboarding = \"finishOnboarding\",\n FinishOffboarding = \"finishOffboarding\",\n FinishSplit = \"finishSplit\",\n FinishRepay = \"finishRepay\",\n}\n\nconst modeToEventType = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n};\n\nexport interface InitOptions {\n // The environment to use.\n environment: Environment;\n // The widget token to use.\n token: string;\n}\n\nexport interface OpenOptions {\n // The mode to open the popup in. See Mode for more information.\n mode?: Mode;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nexport interface CreateWidgetOptions extends OpenOptions {\n mode?: Extract<Mode, \"onboarding\" | \"repay\">;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nclass LvbleWidget extends HTMLElement {\n _typeToEvent = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n };\n _iframe?: HTMLIFrameElement;\n\n constructor() {\n super();\n this.attachShadow({ mode: \"open\" });\n }\n\n get mode(): Mode {\n return this.getAttribute(\"mode\") as Mode;\n }\n\n set mode(val: Mode | undefined) {\n if (val) {\n this.setAttribute(\"mode\", val);\n } else {\n this.removeAttribute(\"mode\");\n }\n }\n\n get environment(): Environment {\n return this.getAttribute(\"environment\") as Environment;\n }\n\n set environment(val) {\n if (val) {\n this.setAttribute(\"environment\", val);\n } else {\n this.removeAttribute(\"environment\");\n }\n }\n\n get token() {\n return this.getAttribute(\"token\") as string;\n }\n\n set token(val: string) {\n if (val) {\n this.setAttribute(\"token\", val);\n } else {\n this.removeAttribute(\"token\");\n }\n }\n\n connectedCallback() {\n const iframeSrc = `${envToBaseUrlMapWidget[this.environment]}?token=${\n this.token\n }&environment=${this.environment}`;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = iframeSrc;\n iframe.width = `100%`;\n iframe.height = `100%`;\n iframe.style.borderStyle = \"solid\";\n iframe.style.borderRadius = \"10px\";\n iframe.style.borderColor = \"transparent\";\n this._iframe = iframe;\n\n this.shadowRoot?.appendChild(iframe);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) this.shadowRoot.innerHTML = \"\";\n }\n}\n\ncustomElements.define(\"lvble-widget\", LvbleWidget);\n\nconst modeWidgetMap: Record<\n Extract<Mode, \"onboarding\" | \"repay\">,\n CustomElementConstructor | undefined\n> = {\n onboarding: customElements.get(\"lvble-widget\"),\n repay: customElements.get(\"lvble-widget\"),\n};\n\nlet _popup: Window;\n\nconst lvble = (initOptions: InitOptions) => {\n return {\n /**\n * This function creates a widget that can be embedded in your website.\n *\n * @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.\n * @returns The widget.\n */\n // TODO: Add support for no mode\n createWidget: (createOptions: CreateWidgetOptions) => {\n const widget = new LvbleWidget()\n \n // (\n // createOptions.mode\n // ? new modeWidgetMap[createOptions.mode]!()\n // : new (customElements.get(\n // \"lvble-widget\"\n // ) as CustomElementConstructor)()\n // ) as LvbleWidget;\n widget.environment = initOptions.environment;\n widget.token = initOptions.token;\n widget.mode = createOptions.mode;\n\n const messageListener = (message: MessageEvent) => {\n if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n\n const data = message.data;\n createOptions.onEvent(data.eventType, data);\n };\n window.addEventListener(\"message\", messageListener);\n return widget;\n },\n /**\n * This function opens a popup with the relevant mode.\n * @param openOptions The options for opening the widget. See OpenOptions for more information.\n * @returns undefined.\n */\n open: (openOptions: OpenOptions) => {\n const modeUrlMap: Record<Mode, string> = {\n onboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n offboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n split: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n repay: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n };\n\n const modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : \"\";\n\n const w = 450;\n const h = 800;\n const l = screen.width / 2 - w / 2;\n const t = screen.height / 2 - h / 2;\n _popup = window.open(\n modeUrl,\n \"LvblePopup\",\n \"width=\" + w + \",height=\" + h + \",location=no,left=\" + l + \",top=\" + t\n ) as Window;\n\n const messageListener = (message: MessageEvent) => {\n if (\n message.origin != envToBaseUrlMapExperience[initOptions.environment]\n ) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n const eventData = message.data;\n const iframes = document.querySelectorAll(\"lvble-widget\");\n\n message = JSON.parse(JSON.stringify(message));\n\n iframes.forEach((w) => {\n (\n w.shadowRoot?.querySelector(\"iframe\") as HTMLIFrameElement\n ).contentWindow?.postMessage(message, \"*\");\n });\n\n openOptions.onEvent(eventData.eventType, eventData);\n };\n\n window.addEventListener(\"message\", messageListener);\n },\n };\n};\n\nexport type LvbleType = ReturnType<typeof lvble>;\n\nexport const Lvble = lvble;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(915);\n"],"names":["root","factory","exports","module","define","amd","self","Environment","envToBaseUrlMapWidget","Local","Sandbox","Production","envToBaseUrlMapExperience","EventType","FinishOnboarding","FinishOffboarding","FinishSplit","FinishRepay","LvbleWidget","HTMLElement","constructor","super","onboarding","offboarding","split","repay","this","attachShadow","mode","getAttribute","val","setAttribute","removeAttribute","environment","token","connectedCallback","iframeSrc","iframe","document","createElement","src","width","height","style","borderStyle","borderRadius","borderColor","_iframe","shadowRoot","appendChild","disconnectedCallback","innerHTML","_popup","customElements","get","Lvble","initOptions","createWidget","createOptions","widget","window","addEventListener","message","origin","console","debug","data","onEvent","eventType","open","openOptions","modeUrlMap","modeUrl","l","screen","w","t","h","eventData","iframes","querySelectorAll","JSON","parse","stringify","forEach","querySelector","contentWindow","postMessage","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MyLib",[],t):"object"==typeof exports?exports.MyLib=t():e.MyLib=t()}(self,(()=>(()=>{"use strict";var e={915:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(755),t)},755:function(e,t){var n,o,i,r,a=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)});Object.defineProperty(t,"__esModule",{value:!0}),t.Lvble=t.Environment=void 0,function(e){e.Local="local",e.Sandbox="sandbox",e.Production="production"}(r||(t.Environment=r={}));var c,s=((o={})[r.Local]="http://localhost:3001",o[r.Sandbox]="https://widget.sandbox.pms.nowlvble.com",o[r.Production]="https://api.production.partners.nowlvble.com",o),l=((i={})[r.Local]="http://localhost:3001",i[r.Sandbox]="https://experience.sandbox.pms.nowlvble.com",i[r.Production]="https://api.production.partners.nowlvble.com",i);!function(e){e.FinishOnboarding="finishOnboarding",e.FinishOffboarding="finishOffboarding",e.FinishSplit="finishSplit",e.FinishRepay="finishRepay"}(c||(c={})),c.FinishOnboarding,c.FinishOffboarding,c.FinishSplit,c.FinishRepay;var u=function(e){function t(){var t=e.call(this)||this;return Object.defineProperty(t,"_typeToEvent",{enumerable:!0,configurable:!0,writable:!0,value:{onboarding:c.FinishOnboarding,offboarding:c.FinishOffboarding,split:c.FinishSplit,repay:c.FinishRepay}}),Object.defineProperty(t,"_iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t.attachShadow({mode:"open"}),t}return a(t,e),Object.defineProperty(t.prototype,"mode",{get:function(){return this.getAttribute("mode")},set:function(e){e?this.setAttribute("mode",e):this.removeAttribute("mode")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environment",{get:function(){return this.getAttribute("environment")},set:function(e){e?this.setAttribute("environment",e):this.removeAttribute("environment")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"token",{get:function(){return this.getAttribute("token")},set:function(e){e?this.setAttribute("token",e):this.removeAttribute("token")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connectedCallback",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t="".concat(s[this.environment],"?token=").concat(this.token,"&environment=").concat(this.environment),n=document.createElement("iframe");n.src=t,n.width="100%",n.height="100%",n.style.borderStyle="solid",n.style.borderRadius="10px",n.style.borderColor="transparent",this._iframe=n,null===(e=this.shadowRoot)||void 0===e||e.appendChild(n)}}),Object.defineProperty(t.prototype,"disconnectedCallback",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.shadowRoot&&(this.shadowRoot.innerHTML="")}}),t}(HTMLElement);customElements.define("lvble-widget",u),customElements.get("lvble-widget"),customElements.get("lvble-widget"),t.Lvble=function(e){return{createWidget:function(t){var n=new u;return n.environment=e.environment,n.token=e.token,n.mode=t.mode,window.addEventListener("message",(function(n){if(n.origin==s[e.environment]){var o=n.data;t.onEvent(o.eventType,o)}else console.debug("Received message from unknown origin: ".concat(n.origin))})),n},open:function(t){var n={onboarding:"".concat(l[e.environment],"?token=").concat(e.token),offboarding:"".concat(l[e.environment],"?token=").concat(e.token),split:"".concat(l[e.environment],"?token=").concat(e.token),repay:"".concat(l[e.environment],"?token=").concat(e.token)},o=t.mode?n[t.mode]:"",i=screen.width/2-225,r=screen.height/2-400;window.open(o,"LvblePopup","width=450,height=800,location=no,left="+i+",top="+r),window.addEventListener("message",(function(n){if(n.origin==l[e.environment]){var o=n.data,i=document.querySelectorAll("lvble-widget");n=JSON.parse(JSON.stringify(n)),i.forEach((function(e){var t,o;null===(o=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector("iframe")).contentWindow)||void 0===o||o.postMessage(n,"*")})),t.onEvent(o.eventType,o)}else console.debug("Received message from unknown origin: ".concat(n.origin))}))}}}}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}(915)})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MyLib",[],t):"object"==typeof exports?exports.MyLib=t():e.MyLib=t()}(self,(()=>(()=>{"use strict";var e={915:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(755),t)},755:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Lvble=t.Environment=void 0,function(e){e.Local="local",e.Sandbox="sandbox",e.Production="production"}(n||(t.Environment=n={}));const o={[n.Local]:"http://localhost:3001",[n.Sandbox]:"https://widget.sandbox.pms.nowlvble.com",[n.Production]:"https://api.production.partners.nowlvble.com"},i={[n.Local]:"http://localhost:3001",[n.Sandbox]:"https://experience.sandbox.pms.nowlvble.com",[n.Production]:"https://api.production.partners.nowlvble.com"};var r;!function(e){e.FinishOnboarding="finishOnboarding",e.FinishOffboarding="finishOffboarding",e.FinishSplit="finishSplit",e.FinishRepay="finishRepay"}(r||(r={})),r.FinishOnboarding,r.FinishOffboarding,r.FinishSplit,r.FinishRepay;class s extends HTMLElement{constructor(){super(),Object.defineProperty(this,"_typeToEvent",{enumerable:!0,configurable:!0,writable:!0,value:{onboarding:r.FinishOnboarding,offboarding:r.FinishOffboarding,split:r.FinishSplit,repay:r.FinishRepay}}),Object.defineProperty(this,"_iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.attachShadow({mode:"open"})}get mode(){return this.getAttribute("mode")}set mode(e){e?this.setAttribute("mode",e):this.removeAttribute("mode")}get environment(){return this.getAttribute("environment")}set environment(e){e?this.setAttribute("environment",e):this.removeAttribute("environment")}get token(){return this.getAttribute("token")}set token(e){e?this.setAttribute("token",e):this.removeAttribute("token")}connectedCallback(){var e;const t=`${o[this.environment]}?token=${this.token}&environment=${this.environment}`,n=document.createElement("iframe");n.src=t,n.width="100%",n.height="100%",n.style.borderStyle="solid",n.style.borderRadius="10px",n.style.borderColor="transparent",this._iframe=n,null===(e=this.shadowRoot)||void 0===e||e.appendChild(n)}disconnectedCallback(){this.shadowRoot&&(this.shadowRoot.innerHTML="")}}let d;customElements.define("lvble-widget",s),customElements.get("lvble-widget"),customElements.get("lvble-widget"),t.Lvble=e=>({createWidget:t=>{const n=new s;return n.environment=e.environment,n.token=e.token,n.mode=t.mode,window.addEventListener("message",(n=>{if(n.origin!=o[e.environment])return void console.debug(`Received message from unknown origin: ${n.origin}`);const i=n.data;t.onEvent(i.eventType,i)})),n},open:t=>{const n={onboarding:`${i[e.environment]}?token=${e.token}`,offboarding:`${i[e.environment]}?token=${e.token}`,split:`${i[e.environment]}?token=${e.token}`,repay:`${i[e.environment]}?token=${e.token}`},o=t.mode?n[t.mode]:"",r=screen.width/2-225,s=screen.height/2-400;d=window.open(o,"LvblePopup","width=450,height=800,location=no,left="+r+",top="+s),window.addEventListener("message",(n=>{if(n.origin!=i[e.environment])return void console.debug(`Received message from unknown origin: ${n.origin}`);const o=n.data,r=document.querySelectorAll("lvble-widget");n=JSON.parse(JSON.stringify(n)),r.forEach((e=>{var t,o;null===(o=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector("iframe")).contentWindow)||void 0===o||o.postMessage(n,"*")})),t.onEvent(o.eventType,o)}))}})}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}(915)})()));
2
2
  //# sourceMappingURL=core.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,QAAS,GAAIH,GACM,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,GACjB,CATD,CASGK,MAAM,I,mhBCTT,W,8BCAYC,E,uiBAAZ,SAAYA,GACV,gBACA,oBACA,yBACD,CAJD,CAAYA,IAAW,cAAXA,EAAW,KAKvB,IAuCKC,EAvCCC,IAAqB,MACxBF,EAAYG,OAAQ,wBACrB,EAACH,EAAYI,SAAU,0CACvB,EAACJ,EAAYK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KE,UAAUrB,IAEpCiB,EAAQK,SAAQ,SAACT,G,QAGA,QAFd,GACa,QAAZ,EAAAA,EAAE3B,kBAAU,eAAEqC,cAAc,WAC5BC,qBAAa,SAAEC,YAAYzB,EAAS,IACxC,IAEAQ,EAAYL,QAAQa,EAAUZ,UAAWY,E,MAhBvCX,QAAQC,MACN,gDAAyCN,EAAQC,QAgBvD,GAGF,EAEJ,C,GCjQIyB,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAapF,QAGrB,IAAIC,EAASgF,EAAyBE,GAAY,CAGjDnF,QAAS,CAAC,GAOX,OAHAsF,EAAoBH,GAAUI,KAAKtF,EAAOD,QAASC,EAAQA,EAAOD,QAASkF,GAGpEjF,EAAOD,OACf,CCnB0BkF,CAAoB,I","sources":["webpack://MyLib/webpack/universalModuleDefinition","webpack://MyLib/./src/lib/index.ts","webpack://MyLib/./src/lib/lvble.ts","webpack://MyLib/webpack/bootstrap","webpack://MyLib/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MyLib\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLib\"] = factory();\n\telse\n\t\troot[\"MyLib\"] = factory();\n})(self, () => {\nreturn ","export * from './lvble'\n","export enum Environment {\n Local = \"local\",\n Sandbox = \"sandbox\",\n Production = \"production\",\n}\nconst envToBaseUrlMapWidget: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://widget.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nconst envToBaseUrlMapExperience: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://experience.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nexport type Mode = \"onboarding\" | \"offboarding\" | \"split\" | \"repay\";\nexport type ErrorData = {\n type: \"error\";\n reason: string;\n};\nexport type OnboardingData =\n | ErrorData\n | {\n type: \"success\";\n status: string;\n };\nexport type SplitData =\n | ErrorData\n | {\n type: \"success\";\n external_id: string;\n settlement_id: string;\n amount: number;\n };\nexport type CloseData =\n | ErrorData\n | {\n type: \"close\";\n };\n// TODO: Make this the event type in the onEvent callback signature\nexport type EventData = OnboardingData | SplitData | CloseData;\n\nenum EventType {\n FinishOnboarding = \"finishOnboarding\",\n FinishOffboarding = \"finishOffboarding\",\n FinishSplit = \"finishSplit\",\n FinishRepay = \"finishRepay\",\n}\n\nconst modeToEventType = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n};\n\nexport interface InitOptions {\n // The environment to use.\n environment: Environment;\n // The widget token to use.\n token: string;\n}\n\nexport interface OpenOptions {\n // The mode to open the popup in. See Mode for more information.\n mode?: Mode;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nexport interface CreateWidgetOptions extends OpenOptions {\n mode?: Extract<Mode, \"onboarding\" | \"repay\">;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nclass LvbleWidget extends HTMLElement {\n _typeToEvent = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n };\n _iframe?: HTMLIFrameElement;\n\n constructor() {\n super();\n this.attachShadow({ mode: \"open\" });\n }\n\n get mode(): Mode {\n return this.getAttribute(\"mode\") as Mode;\n }\n\n set mode(val: Mode | undefined) {\n if (val) {\n this.setAttribute(\"mode\", val);\n } else {\n this.removeAttribute(\"mode\");\n }\n }\n\n get environment(): Environment {\n return this.getAttribute(\"environment\") as Environment;\n }\n\n set environment(val) {\n if (val) {\n this.setAttribute(\"environment\", val);\n } else {\n this.removeAttribute(\"environment\");\n }\n }\n\n get token() {\n return this.getAttribute(\"token\") as string;\n }\n\n set token(val: string) {\n if (val) {\n this.setAttribute(\"token\", val);\n } else {\n this.removeAttribute(\"token\");\n }\n }\n\n connectedCallback() {\n const iframeSrc = `${envToBaseUrlMapWidget[this.environment]}?token=${\n this.token\n }&environment=${this.environment}`;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = iframeSrc;\n iframe.width = `100%`;\n iframe.height = `100%`;\n iframe.style.borderStyle = \"solid\";\n iframe.style.borderRadius = \"10px\";\n iframe.style.borderColor = \"transparent\";\n this._iframe = iframe;\n\n this.shadowRoot?.appendChild(iframe);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) this.shadowRoot.innerHTML = \"\";\n }\n}\n\ncustomElements.define(\"lvble-widget\", LvbleWidget);\n\nconst modeWidgetMap: Record<\n Extract<Mode, \"onboarding\" | \"repay\">,\n CustomElementConstructor | undefined\n> = {\n onboarding: customElements.get(\"lvble-widget\"),\n repay: customElements.get(\"lvble-widget\"),\n};\n\nlet _popup: Window;\n\nconst lvble = (initOptions: InitOptions) => {\n return {\n /**\n * This function creates a widget that can be embedded in your website.\n *\n * @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.\n * @returns The widget.\n */\n // TODO: Add support for no mode\n createWidget: (createOptions: CreateWidgetOptions) => {\n const widget = new LvbleWidget()\n \n // (\n // createOptions.mode\n // ? new modeWidgetMap[createOptions.mode]!()\n // : new (customElements.get(\n // \"lvble-widget\"\n // ) as CustomElementConstructor)()\n // ) as LvbleWidget;\n widget.environment = initOptions.environment;\n widget.token = initOptions.token;\n widget.mode = createOptions.mode;\n\n const messageListener = (message: MessageEvent) => {\n if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n\n const data = message.data;\n createOptions.onEvent(data.eventType, data);\n };\n window.addEventListener(\"message\", messageListener);\n return widget;\n },\n /**\n * This function opens a popup with the relevant mode.\n * @param openOptions The options for opening the widget. See OpenOptions for more information.\n * @returns undefined.\n */\n open: (openOptions: OpenOptions) => {\n const modeUrlMap: Record<Mode, string> = {\n onboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n offboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n split: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n repay: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n };\n\n const modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : \"\";\n\n const w = 450;\n const h = 800;\n const l = screen.width / 2 - w / 2;\n const t = screen.height / 2 - h / 2;\n _popup = window.open(\n modeUrl,\n \"LvblePopup\",\n \"width=\" + w + \",height=\" + h + \",location=no,left=\" + l + \",top=\" + t\n ) as Window;\n\n const messageListener = (message: MessageEvent) => {\n if (\n message.origin != envToBaseUrlMapExperience[initOptions.environment]\n ) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n const eventData = message.data;\n const iframes = document.querySelectorAll(\"lvble-widget\");\n\n message = JSON.parse(JSON.stringify(message));\n\n iframes.forEach((w) => {\n (\n w.shadowRoot?.querySelector(\"iframe\") as HTMLIFrameElement\n ).contentWindow?.postMessage(message, \"*\");\n });\n\n openOptions.onEvent(eventData.eventType, eventData);\n };\n\n window.addEventListener(\"message\", messageListener);\n },\n };\n};\n\nexport type LvbleType = ReturnType<typeof lvble>;\n\nexport const Lvble = lvble;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(915);\n"],"names":["root","factory","exports","module","define","amd","self","Environment","EventType","envToBaseUrlMapWidget","Local","Sandbox","Production","envToBaseUrlMapExperience","FinishOnboarding","FinishOffboarding","FinishSplit","FinishRepay","onboarding","offboarding","split","repay","attachShadow","mode","this","getAttribute","val","setAttribute","removeAttribute","iframeSrc","environment","token","iframe","document","createElement","src","width","height","style","borderStyle","borderRadius","borderColor","_iframe","shadowRoot","appendChild","innerHTML","HTMLElement","customElements","LvbleWidget","get","Lvble","initOptions","createWidget","createOptions","widget","window","addEventListener","message","origin","data","onEvent","eventType","console","debug","open","openOptions","modeUrlMap","modeUrl","l","screen","w","t","h","eventData","iframes","querySelectorAll","JSON","parse","stringify","forEach","querySelector","contentWindow","postMessage","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
1
+ {"version":3,"file":"core.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,QAAS,GAAIH,GACM,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,GACjB,CATD,CASGK,MAAM,I,mhBCTT,W,cCAA,IAAYC,E,8EAAZ,SAAYA,GACV,gBACA,oBACA,yBACD,CAJD,CAAYA,IAAW,cAAXA,EAAW,KAKvB,MAAMC,EAAqD,CACzD,CAACD,EAAYE,OAAQ,wBACrB,CAACF,EAAYG,SAAU,0CACvB,CAACH,EAAYI,YAAa,gDAGtBC,EAA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,EAAE3B,kBAAU,eAAEqC,cAAc,WAC5BC,qBAAa,SAAEC,YAAYzB,EAAS,IAAI,IAG5CQ,EAAYH,QAAQW,EAAUV,UAAWU,EAAU,GAGF,G,GC9PrDU,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAazF,QAGrB,IAAIC,EAASqF,EAAyBE,GAAY,CAGjDxF,QAAS,CAAC,GAOX,OAHA2F,EAAoBH,GAAUI,KAAK3F,EAAOD,QAASC,EAAQA,EAAOD,QAASuF,GAGpEtF,EAAOD,OACf,CCnB0BuF,CAAoB,I","sources":["webpack://MyLib/webpack/universalModuleDefinition","webpack://MyLib/./src/lib/index.ts","webpack://MyLib/./src/lib/lvble.ts","webpack://MyLib/webpack/bootstrap","webpack://MyLib/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MyLib\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLib\"] = factory();\n\telse\n\t\troot[\"MyLib\"] = factory();\n})(self, () => {\nreturn ","export * from './lvble'\n","export enum Environment {\n Local = \"local\",\n Sandbox = \"sandbox\",\n Production = \"production\",\n}\nconst envToBaseUrlMapWidget: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://widget.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nconst envToBaseUrlMapExperience: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3001\",\n [Environment.Sandbox]: \"https://experience.sandbox.pms.nowlvble.com\",\n [Environment.Production]: \"https://api.production.partners.nowlvble.com\",\n};\n\nexport type Mode = \"onboarding\" | \"offboarding\" | \"split\" | \"repay\";\nexport type ErrorData = {\n type: \"error\";\n reason: string;\n};\nexport type OnboardingData =\n | ErrorData\n | {\n type: \"success\";\n status: string;\n };\nexport type SplitData =\n | ErrorData\n | {\n type: \"success\";\n external_id: string;\n settlement_id: string;\n amount: number;\n };\nexport type CloseData =\n | ErrorData\n | {\n type: \"close\";\n };\n// TODO: Make this the event type in the onEvent callback signature\nexport type EventData = OnboardingData | SplitData | CloseData;\n\nenum EventType {\n FinishOnboarding = \"finishOnboarding\",\n FinishOffboarding = \"finishOffboarding\",\n FinishSplit = \"finishSplit\",\n FinishRepay = \"finishRepay\",\n}\n\nconst modeToEventType = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n};\n\nexport interface InitOptions {\n // The environment to use.\n environment: Environment;\n // The widget token to use.\n token: string;\n}\n\nexport interface OpenOptions {\n // The mode to open the popup in. See Mode for more information.\n mode?: Mode;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nexport interface CreateWidgetOptions extends OpenOptions {\n mode?: Extract<Mode, \"onboarding\" | \"repay\">;\n // The callback to invoke when the popup has sent an event (e.g. user clicked a button).\n onEvent: (eventType: string, data: any) => void;\n}\n\nclass LvbleWidget extends HTMLElement {\n _typeToEvent = {\n onboarding: EventType.FinishOnboarding,\n offboarding: EventType.FinishOffboarding,\n split: EventType.FinishSplit,\n repay: EventType.FinishRepay,\n };\n _iframe?: HTMLIFrameElement;\n\n constructor() {\n super();\n this.attachShadow({ mode: \"open\" });\n }\n\n get mode(): Mode {\n return this.getAttribute(\"mode\") as Mode;\n }\n\n set mode(val: Mode | undefined) {\n if (val) {\n this.setAttribute(\"mode\", val);\n } else {\n this.removeAttribute(\"mode\");\n }\n }\n\n get environment(): Environment {\n return this.getAttribute(\"environment\") as Environment;\n }\n\n set environment(val) {\n if (val) {\n this.setAttribute(\"environment\", val);\n } else {\n this.removeAttribute(\"environment\");\n }\n }\n\n get token() {\n return this.getAttribute(\"token\") as string;\n }\n\n set token(val: string) {\n if (val) {\n this.setAttribute(\"token\", val);\n } else {\n this.removeAttribute(\"token\");\n }\n }\n\n connectedCallback() {\n const iframeSrc = `${envToBaseUrlMapWidget[this.environment]}?token=${\n this.token\n }&environment=${this.environment}`;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = iframeSrc;\n iframe.width = `100%`;\n iframe.height = `100%`;\n iframe.style.borderStyle = \"solid\";\n iframe.style.borderRadius = \"10px\";\n iframe.style.borderColor = \"transparent\";\n this._iframe = iframe;\n\n this.shadowRoot?.appendChild(iframe);\n }\n\n disconnectedCallback() {\n if (this.shadowRoot) this.shadowRoot.innerHTML = \"\";\n }\n}\n\ncustomElements.define(\"lvble-widget\", LvbleWidget);\n\nconst modeWidgetMap: Record<\n Extract<Mode, \"onboarding\" | \"repay\">,\n CustomElementConstructor | undefined\n> = {\n onboarding: customElements.get(\"lvble-widget\"),\n repay: customElements.get(\"lvble-widget\"),\n};\n\nlet _popup: Window;\n\nconst lvble = (initOptions: InitOptions) => {\n return {\n /**\n * This function creates a widget that can be embedded in your website.\n *\n * @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.\n * @returns The widget.\n */\n // TODO: Add support for no mode\n createWidget: (createOptions: CreateWidgetOptions) => {\n const widget = new LvbleWidget()\n \n // (\n // createOptions.mode\n // ? new modeWidgetMap[createOptions.mode]!()\n // : new (customElements.get(\n // \"lvble-widget\"\n // ) as CustomElementConstructor)()\n // ) as LvbleWidget;\n widget.environment = initOptions.environment;\n widget.token = initOptions.token;\n widget.mode = createOptions.mode;\n\n const messageListener = (message: MessageEvent) => {\n if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n\n const data = message.data;\n createOptions.onEvent(data.eventType, data);\n };\n window.addEventListener(\"message\", messageListener);\n return widget;\n },\n /**\n * This function opens a popup with the relevant mode.\n * @param openOptions The options for opening the widget. See OpenOptions for more information.\n * @returns undefined.\n */\n open: (openOptions: OpenOptions) => {\n const modeUrlMap: Record<Mode, string> = {\n onboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n offboarding: `${\n envToBaseUrlMapExperience[initOptions.environment]\n }?token=${initOptions.token}`,\n split: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n repay: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${\n initOptions.token\n }`,\n };\n\n const modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : \"\";\n\n const w = 450;\n const h = 800;\n const l = screen.width / 2 - w / 2;\n const t = screen.height / 2 - h / 2;\n _popup = window.open(\n modeUrl,\n \"LvblePopup\",\n \"width=\" + w + \",height=\" + h + \",location=no,left=\" + l + \",top=\" + t\n ) as Window;\n\n const messageListener = (message: MessageEvent) => {\n if (\n message.origin != envToBaseUrlMapExperience[initOptions.environment]\n ) {\n console.debug(\n `Received message from unknown origin: ${message.origin}`\n );\n return;\n }\n const eventData = message.data;\n const iframes = document.querySelectorAll(\"lvble-widget\");\n\n message = JSON.parse(JSON.stringify(message));\n\n iframes.forEach((w) => {\n (\n w.shadowRoot?.querySelector(\"iframe\") as HTMLIFrameElement\n ).contentWindow?.postMessage(message, \"*\");\n });\n\n openOptions.onEvent(eventData.eventType, eventData);\n };\n\n window.addEventListener(\"message\", messageListener);\n },\n };\n};\n\nexport type LvbleType = ReturnType<typeof lvble>;\n\nexport const Lvble = lvble;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(915);\n"],"names":["root","factory","exports","module","define","amd","self","Environment","envToBaseUrlMapWidget","Local","Sandbox","Production","envToBaseUrlMapExperience","EventType","FinishOnboarding","FinishOffboarding","FinishSplit","FinishRepay","LvbleWidget","HTMLElement","constructor","super","onboarding","offboarding","split","repay","this","attachShadow","mode","getAttribute","val","setAttribute","removeAttribute","environment","token","connectedCallback","iframeSrc","iframe","document","createElement","src","width","height","style","borderStyle","borderRadius","borderColor","_iframe","shadowRoot","appendChild","disconnectedCallback","innerHTML","_popup","customElements","get","Lvble","initOptions","createWidget","createOptions","widget","window","addEventListener","message","origin","console","debug","data","onEvent","eventType","open","openOptions","modeUrlMap","modeUrl","l","screen","w","t","h","eventData","iframes","querySelectorAll","JSON","parse","stringify","forEach","querySelector","contentWindow","postMessage","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
package/dist/lib/lvble.js CHANGED
@@ -1,20 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var _a, _b;
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.Lvble = exports.Environment = void 0;
20
4
  var Environment;
@@ -23,16 +7,16 @@ var Environment;
23
7
  Environment["Sandbox"] = "sandbox";
24
8
  Environment["Production"] = "production";
25
9
  })(Environment || (exports.Environment = Environment = {}));
26
- var envToBaseUrlMapWidget = (_a = {},
27
- _a[Environment.Local] = "http://localhost:3001",
28
- _a[Environment.Sandbox] = "https://widget.sandbox.pms.nowlvble.com",
29
- _a[Environment.Production] = "https://api.production.partners.nowlvble.com",
30
- _a);
31
- var envToBaseUrlMapExperience = (_b = {},
32
- _b[Environment.Local] = "http://localhost:3001",
33
- _b[Environment.Sandbox] = "https://experience.sandbox.pms.nowlvble.com",
34
- _b[Environment.Production] = "https://api.production.partners.nowlvble.com",
35
- _b);
10
+ const envToBaseUrlMapWidget = {
11
+ [Environment.Local]: "http://localhost:3001",
12
+ [Environment.Sandbox]: "https://widget.sandbox.pms.nowlvble.com",
13
+ [Environment.Production]: "https://api.production.partners.nowlvble.com",
14
+ };
15
+ const envToBaseUrlMapExperience = {
16
+ [Environment.Local]: "http://localhost:3001",
17
+ [Environment.Sandbox]: "https://experience.sandbox.pms.nowlvble.com",
18
+ [Environment.Production]: "https://api.production.partners.nowlvble.com",
19
+ };
36
20
  var EventType;
37
21
  (function (EventType) {
38
22
  EventType["FinishOnboarding"] = "finishOnboarding";
@@ -40,17 +24,16 @@ var EventType;
40
24
  EventType["FinishSplit"] = "finishSplit";
41
25
  EventType["FinishRepay"] = "finishRepay";
42
26
  })(EventType || (EventType = {}));
43
- var modeToEventType = {
27
+ const modeToEventType = {
44
28
  onboarding: EventType.FinishOnboarding,
45
29
  offboarding: EventType.FinishOffboarding,
46
30
  split: EventType.FinishSplit,
47
31
  repay: EventType.FinishRepay,
48
32
  };
49
- var LvbleWidget = /** @class */ (function (_super) {
50
- __extends(LvbleWidget, _super);
51
- function LvbleWidget() {
52
- var _this = _super.call(this) || this;
53
- Object.defineProperty(_this, "_typeToEvent", {
33
+ class LvbleWidget extends HTMLElement {
34
+ constructor() {
35
+ super();
36
+ Object.defineProperty(this, "_typeToEvent", {
54
37
  enumerable: true,
55
38
  configurable: true,
56
39
  writable: true,
@@ -61,96 +44,72 @@ var LvbleWidget = /** @class */ (function (_super) {
61
44
  repay: EventType.FinishRepay,
62
45
  }
63
46
  });
64
- Object.defineProperty(_this, "_iframe", {
47
+ Object.defineProperty(this, "_iframe", {
65
48
  enumerable: true,
66
49
  configurable: true,
67
50
  writable: true,
68
51
  value: void 0
69
52
  });
70
- _this.attachShadow({ mode: "open" });
71
- return _this;
53
+ this.attachShadow({ mode: "open" });
72
54
  }
73
- Object.defineProperty(LvbleWidget.prototype, "mode", {
74
- get: function () {
75
- return this.getAttribute("mode");
76
- },
77
- set: function (val) {
78
- if (val) {
79
- this.setAttribute("mode", val);
80
- }
81
- else {
82
- this.removeAttribute("mode");
83
- }
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Object.defineProperty(LvbleWidget.prototype, "environment", {
89
- get: function () {
90
- return this.getAttribute("environment");
91
- },
92
- set: function (val) {
93
- if (val) {
94
- this.setAttribute("environment", val);
95
- }
96
- else {
97
- this.removeAttribute("environment");
98
- }
99
- },
100
- enumerable: false,
101
- configurable: true
102
- });
103
- Object.defineProperty(LvbleWidget.prototype, "token", {
104
- get: function () {
105
- return this.getAttribute("token");
106
- },
107
- set: function (val) {
108
- if (val) {
109
- this.setAttribute("token", val);
110
- }
111
- else {
112
- this.removeAttribute("token");
113
- }
114
- },
115
- enumerable: false,
116
- configurable: true
117
- });
118
- Object.defineProperty(LvbleWidget.prototype, "connectedCallback", {
119
- enumerable: false,
120
- configurable: true,
121
- writable: true,
122
- value: function () {
123
- var _a;
124
- var iframeSrc = "".concat(envToBaseUrlMapWidget[this.environment], "?token=").concat(this.token, "&environment=").concat(this.environment);
125
- var iframe = document.createElement("iframe");
126
- iframe.src = iframeSrc;
127
- iframe.width = "100%";
128
- iframe.height = "100%";
129
- iframe.style.borderStyle = "solid";
130
- iframe.style.borderRadius = "10px";
131
- iframe.style.borderColor = "transparent";
132
- this._iframe = iframe;
133
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
55
+ get mode() {
56
+ return this.getAttribute("mode");
57
+ }
58
+ set mode(val) {
59
+ if (val) {
60
+ this.setAttribute("mode", val);
61
+ }
62
+ else {
63
+ this.removeAttribute("mode");
64
+ }
65
+ }
66
+ get environment() {
67
+ return this.getAttribute("environment");
68
+ }
69
+ set environment(val) {
70
+ if (val) {
71
+ this.setAttribute("environment", val);
134
72
  }
135
- });
136
- Object.defineProperty(LvbleWidget.prototype, "disconnectedCallback", {
137
- enumerable: false,
138
- configurable: true,
139
- writable: true,
140
- value: function () {
141
- if (this.shadowRoot)
142
- this.shadowRoot.innerHTML = "";
73
+ else {
74
+ this.removeAttribute("environment");
143
75
  }
144
- });
145
- return LvbleWidget;
146
- }(HTMLElement));
76
+ }
77
+ get token() {
78
+ return this.getAttribute("token");
79
+ }
80
+ set token(val) {
81
+ if (val) {
82
+ this.setAttribute("token", val);
83
+ }
84
+ else {
85
+ this.removeAttribute("token");
86
+ }
87
+ }
88
+ connectedCallback() {
89
+ var _a;
90
+ const iframeSrc = `${envToBaseUrlMapWidget[this.environment]}?token=${this.token}&environment=${this.environment}`;
91
+ const iframe = document.createElement("iframe");
92
+ iframe.src = iframeSrc;
93
+ iframe.width = `100%`;
94
+ iframe.height = `100%`;
95
+ iframe.style.borderStyle = "solid";
96
+ iframe.style.borderRadius = "10px";
97
+ iframe.style.borderColor = "transparent";
98
+ this._iframe = iframe;
99
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
100
+ }
101
+ disconnectedCallback() {
102
+ if (this.shadowRoot)
103
+ this.shadowRoot.innerHTML = "";
104
+ }
105
+ }
147
106
  customElements.define("lvble-widget", LvbleWidget);
148
- var modeWidgetMap = {
107
+ const modeWidgetMap = {
149
108
  onboarding: customElements.get("lvble-widget"),
150
109
  repay: customElements.get("lvble-widget"),
151
110
  };
152
- var _popup;
153
- var lvble = function (initOptions) {
111
+ let _popup;
112
+ const lvble = (initOptions) => {
154
113
  return {
155
114
  /**
156
115
  * This function creates a widget that can be embedded in your website.
@@ -159,8 +118,8 @@ var lvble = function (initOptions) {
159
118
  * @returns The widget.
160
119
  */
161
120
  // TODO: Add support for no mode
162
- createWidget: function (createOptions) {
163
- var widget = new LvbleWidget();
121
+ createWidget: (createOptions) => {
122
+ const widget = new LvbleWidget();
164
123
  // (
165
124
  // createOptions.mode
166
125
  // ? new modeWidgetMap[createOptions.mode]!()
@@ -171,12 +130,12 @@ var lvble = function (initOptions) {
171
130
  widget.environment = initOptions.environment;
172
131
  widget.token = initOptions.token;
173
132
  widget.mode = createOptions.mode;
174
- var messageListener = function (message) {
133
+ const messageListener = (message) => {
175
134
  if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {
176
- console.debug("Received message from unknown origin: ".concat(message.origin));
135
+ console.debug(`Received message from unknown origin: ${message.origin}`);
177
136
  return;
178
137
  }
179
- var data = message.data;
138
+ const data = message.data;
180
139
  createOptions.onEvent(data.eventType, data);
181
140
  };
182
141
  window.addEventListener("message", messageListener);
@@ -187,28 +146,28 @@ var lvble = function (initOptions) {
187
146
  * @param openOptions The options for opening the widget. See OpenOptions for more information.
188
147
  * @returns undefined.
189
148
  */
190
- open: function (openOptions) {
191
- var modeUrlMap = {
192
- onboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
193
- offboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
194
- split: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
195
- repay: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
149
+ open: (openOptions) => {
150
+ const modeUrlMap = {
151
+ onboarding: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
152
+ offboarding: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
153
+ split: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
154
+ repay: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
196
155
  };
197
- var modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : "";
198
- var w = 450;
199
- var h = 800;
200
- var l = screen.width / 2 - w / 2;
201
- var t = screen.height / 2 - h / 2;
156
+ const modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : "";
157
+ const w = 450;
158
+ const h = 800;
159
+ const l = screen.width / 2 - w / 2;
160
+ const t = screen.height / 2 - h / 2;
202
161
  _popup = window.open(modeUrl, "LvblePopup", "width=" + w + ",height=" + h + ",location=no,left=" + l + ",top=" + t);
203
- var messageListener = function (message) {
162
+ const messageListener = (message) => {
204
163
  if (message.origin != envToBaseUrlMapExperience[initOptions.environment]) {
205
- console.debug("Received message from unknown origin: ".concat(message.origin));
164
+ console.debug(`Received message from unknown origin: ${message.origin}`);
206
165
  return;
207
166
  }
208
- var eventData = message.data;
209
- var iframes = document.querySelectorAll("lvble-widget");
167
+ const eventData = message.data;
168
+ const iframes = document.querySelectorAll("lvble-widget");
210
169
  message = JSON.parse(JSON.stringify(message));
211
- iframes.forEach(function (w) {
170
+ iframes.forEach((w) => {
212
171
  var _a, _b;
213
172
  (_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(message, "*");
214
173
  });
@@ -1 +1 @@
1
- {"version":3,"file":"lvble.js","sourceRoot":"","sources":["../../src/lib/lvble.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,wCAAyB,CAAA;AAC3B,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AACD,IAAM,qBAAqB;IACzB,GAAC,WAAW,CAAC,KAAK,IAAG,uBAAuB;IAC5C,GAAC,WAAW,CAAC,OAAO,IAAG,yCAAyC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AAA,CAAC,aAAa,0CAAE,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC7C,CAAC,CAAC,CAAC;gBAEH,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACtD,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAIW,QAAA,KAAK,GAAG,KAAK,CAAC"}
@@ -1,35 +1,19 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var _a, _b;
17
1
  export var Environment;
18
2
  (function (Environment) {
19
3
  Environment["Local"] = "local";
20
4
  Environment["Sandbox"] = "sandbox";
21
5
  Environment["Production"] = "production";
22
6
  })(Environment || (Environment = {}));
23
- var envToBaseUrlMapWidget = (_a = {},
24
- _a[Environment.Local] = "http://localhost:3001",
25
- _a[Environment.Sandbox] = "https://widget.sandbox.pms.nowlvble.com",
26
- _a[Environment.Production] = "https://api.production.partners.nowlvble.com",
27
- _a);
28
- var envToBaseUrlMapExperience = (_b = {},
29
- _b[Environment.Local] = "http://localhost:3001",
30
- _b[Environment.Sandbox] = "https://experience.sandbox.pms.nowlvble.com",
31
- _b[Environment.Production] = "https://api.production.partners.nowlvble.com",
32
- _b);
7
+ const envToBaseUrlMapWidget = {
8
+ [Environment.Local]: "http://localhost:3001",
9
+ [Environment.Sandbox]: "https://widget.sandbox.pms.nowlvble.com",
10
+ [Environment.Production]: "https://api.production.partners.nowlvble.com",
11
+ };
12
+ const envToBaseUrlMapExperience = {
13
+ [Environment.Local]: "http://localhost:3001",
14
+ [Environment.Sandbox]: "https://experience.sandbox.pms.nowlvble.com",
15
+ [Environment.Production]: "https://api.production.partners.nowlvble.com",
16
+ };
33
17
  var EventType;
34
18
  (function (EventType) {
35
19
  EventType["FinishOnboarding"] = "finishOnboarding";
@@ -37,17 +21,16 @@ var EventType;
37
21
  EventType["FinishSplit"] = "finishSplit";
38
22
  EventType["FinishRepay"] = "finishRepay";
39
23
  })(EventType || (EventType = {}));
40
- var modeToEventType = {
24
+ const modeToEventType = {
41
25
  onboarding: EventType.FinishOnboarding,
42
26
  offboarding: EventType.FinishOffboarding,
43
27
  split: EventType.FinishSplit,
44
28
  repay: EventType.FinishRepay,
45
29
  };
46
- var LvbleWidget = /** @class */ (function (_super) {
47
- __extends(LvbleWidget, _super);
48
- function LvbleWidget() {
49
- var _this = _super.call(this) || this;
50
- Object.defineProperty(_this, "_typeToEvent", {
30
+ class LvbleWidget extends HTMLElement {
31
+ constructor() {
32
+ super();
33
+ Object.defineProperty(this, "_typeToEvent", {
51
34
  enumerable: true,
52
35
  configurable: true,
53
36
  writable: true,
@@ -58,96 +41,72 @@ var LvbleWidget = /** @class */ (function (_super) {
58
41
  repay: EventType.FinishRepay,
59
42
  }
60
43
  });
61
- Object.defineProperty(_this, "_iframe", {
44
+ Object.defineProperty(this, "_iframe", {
62
45
  enumerable: true,
63
46
  configurable: true,
64
47
  writable: true,
65
48
  value: void 0
66
49
  });
67
- _this.attachShadow({ mode: "open" });
68
- return _this;
50
+ this.attachShadow({ mode: "open" });
69
51
  }
70
- Object.defineProperty(LvbleWidget.prototype, "mode", {
71
- get: function () {
72
- return this.getAttribute("mode");
73
- },
74
- set: function (val) {
75
- if (val) {
76
- this.setAttribute("mode", val);
77
- }
78
- else {
79
- this.removeAttribute("mode");
80
- }
81
- },
82
- enumerable: false,
83
- configurable: true
84
- });
85
- Object.defineProperty(LvbleWidget.prototype, "environment", {
86
- get: function () {
87
- return this.getAttribute("environment");
88
- },
89
- set: function (val) {
90
- if (val) {
91
- this.setAttribute("environment", val);
92
- }
93
- else {
94
- this.removeAttribute("environment");
95
- }
96
- },
97
- enumerable: false,
98
- configurable: true
99
- });
100
- Object.defineProperty(LvbleWidget.prototype, "token", {
101
- get: function () {
102
- return this.getAttribute("token");
103
- },
104
- set: function (val) {
105
- if (val) {
106
- this.setAttribute("token", val);
107
- }
108
- else {
109
- this.removeAttribute("token");
110
- }
111
- },
112
- enumerable: false,
113
- configurable: true
114
- });
115
- Object.defineProperty(LvbleWidget.prototype, "connectedCallback", {
116
- enumerable: false,
117
- configurable: true,
118
- writable: true,
119
- value: function () {
120
- var _a;
121
- var iframeSrc = "".concat(envToBaseUrlMapWidget[this.environment], "?token=").concat(this.token, "&environment=").concat(this.environment);
122
- var iframe = document.createElement("iframe");
123
- iframe.src = iframeSrc;
124
- iframe.width = "100%";
125
- iframe.height = "100%";
126
- iframe.style.borderStyle = "solid";
127
- iframe.style.borderRadius = "10px";
128
- iframe.style.borderColor = "transparent";
129
- this._iframe = iframe;
130
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
52
+ get mode() {
53
+ return this.getAttribute("mode");
54
+ }
55
+ set mode(val) {
56
+ if (val) {
57
+ this.setAttribute("mode", val);
58
+ }
59
+ else {
60
+ this.removeAttribute("mode");
61
+ }
62
+ }
63
+ get environment() {
64
+ return this.getAttribute("environment");
65
+ }
66
+ set environment(val) {
67
+ if (val) {
68
+ this.setAttribute("environment", val);
131
69
  }
132
- });
133
- Object.defineProperty(LvbleWidget.prototype, "disconnectedCallback", {
134
- enumerable: false,
135
- configurable: true,
136
- writable: true,
137
- value: function () {
138
- if (this.shadowRoot)
139
- this.shadowRoot.innerHTML = "";
70
+ else {
71
+ this.removeAttribute("environment");
140
72
  }
141
- });
142
- return LvbleWidget;
143
- }(HTMLElement));
73
+ }
74
+ get token() {
75
+ return this.getAttribute("token");
76
+ }
77
+ set token(val) {
78
+ if (val) {
79
+ this.setAttribute("token", val);
80
+ }
81
+ else {
82
+ this.removeAttribute("token");
83
+ }
84
+ }
85
+ connectedCallback() {
86
+ var _a;
87
+ const iframeSrc = `${envToBaseUrlMapWidget[this.environment]}?token=${this.token}&environment=${this.environment}`;
88
+ const iframe = document.createElement("iframe");
89
+ iframe.src = iframeSrc;
90
+ iframe.width = `100%`;
91
+ iframe.height = `100%`;
92
+ iframe.style.borderStyle = "solid";
93
+ iframe.style.borderRadius = "10px";
94
+ iframe.style.borderColor = "transparent";
95
+ this._iframe = iframe;
96
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
97
+ }
98
+ disconnectedCallback() {
99
+ if (this.shadowRoot)
100
+ this.shadowRoot.innerHTML = "";
101
+ }
102
+ }
144
103
  customElements.define("lvble-widget", LvbleWidget);
145
- var modeWidgetMap = {
104
+ const modeWidgetMap = {
146
105
  onboarding: customElements.get("lvble-widget"),
147
106
  repay: customElements.get("lvble-widget"),
148
107
  };
149
- var _popup;
150
- var lvble = function (initOptions) {
108
+ let _popup;
109
+ const lvble = (initOptions) => {
151
110
  return {
152
111
  /**
153
112
  * This function creates a widget that can be embedded in your website.
@@ -156,8 +115,8 @@ var lvble = function (initOptions) {
156
115
  * @returns The widget.
157
116
  */
158
117
  // TODO: Add support for no mode
159
- createWidget: function (createOptions) {
160
- var widget = new LvbleWidget();
118
+ createWidget: (createOptions) => {
119
+ const widget = new LvbleWidget();
161
120
  // (
162
121
  // createOptions.mode
163
122
  // ? new modeWidgetMap[createOptions.mode]!()
@@ -168,12 +127,12 @@ var lvble = function (initOptions) {
168
127
  widget.environment = initOptions.environment;
169
128
  widget.token = initOptions.token;
170
129
  widget.mode = createOptions.mode;
171
- var messageListener = function (message) {
130
+ const messageListener = (message) => {
172
131
  if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {
173
- console.debug("Received message from unknown origin: ".concat(message.origin));
132
+ console.debug(`Received message from unknown origin: ${message.origin}`);
174
133
  return;
175
134
  }
176
- var data = message.data;
135
+ const data = message.data;
177
136
  createOptions.onEvent(data.eventType, data);
178
137
  };
179
138
  window.addEventListener("message", messageListener);
@@ -184,28 +143,28 @@ var lvble = function (initOptions) {
184
143
  * @param openOptions The options for opening the widget. See OpenOptions for more information.
185
144
  * @returns undefined.
186
145
  */
187
- open: function (openOptions) {
188
- var modeUrlMap = {
189
- onboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
190
- offboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
191
- split: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
192
- repay: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
146
+ open: (openOptions) => {
147
+ const modeUrlMap = {
148
+ onboarding: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
149
+ offboarding: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
150
+ split: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
151
+ repay: `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`,
193
152
  };
194
- var modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : "";
195
- var w = 450;
196
- var h = 800;
197
- var l = screen.width / 2 - w / 2;
198
- var t = screen.height / 2 - h / 2;
153
+ const modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : "";
154
+ const w = 450;
155
+ const h = 800;
156
+ const l = screen.width / 2 - w / 2;
157
+ const t = screen.height / 2 - h / 2;
199
158
  _popup = window.open(modeUrl, "LvblePopup", "width=" + w + ",height=" + h + ",location=no,left=" + l + ",top=" + t);
200
- var messageListener = function (message) {
159
+ const messageListener = (message) => {
201
160
  if (message.origin != envToBaseUrlMapExperience[initOptions.environment]) {
202
- console.debug("Received message from unknown origin: ".concat(message.origin));
161
+ console.debug(`Received message from unknown origin: ${message.origin}`);
203
162
  return;
204
163
  }
205
- var eventData = message.data;
206
- var iframes = document.querySelectorAll("lvble-widget");
164
+ const eventData = message.data;
165
+ const iframes = document.querySelectorAll("lvble-widget");
207
166
  message = JSON.parse(JSON.stringify(message));
208
- iframes.forEach(function (w) {
167
+ iframes.forEach((w) => {
209
168
  var _a, _b;
210
169
  (_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(message, "*");
211
170
  });
@@ -215,5 +174,5 @@ var lvble = function (initOptions) {
215
174
  },
216
175
  };
217
176
  };
218
- export var Lvble = lvble;
177
+ export const Lvble = lvble;
219
178
  //# sourceMappingURL=lvble.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lvble.js","sourceRoot":"","sources":["../../src/lib/lvble.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,kCAAmB,CAAA;IACnB,wCAAyB,CAAA;AAC3B,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AACD,IAAM,qBAAqB;IACzB,GAAC,WAAW,CAAC,KAAK,IAAG,uBAAuB;IAC5C,GAAC,WAAW,CAAC,OAAO,IAAG,yCAAyC;IAChE,GAAC,WAAW,CAAC,UAAU,IAAG,8CAA8C;OACzE,CAAC;AAEF,IAAM,yBAAyB;IAC7B,GAAC,WAAW,CAAC,KAAK,IAAG,uBAAuB;IAC5C,GAAC,WAAW,CAAC,OAAO,IAAG,6CAA6C;IACpE,GAAC,WAAW,CAAC,UAAU,IAAG,8CAA8C;OACzE,CAAC;AA6BF,IAAK,SAKJ;AALD,WAAK,SAAS;IACZ,kDAAqC,CAAA;IACrC,oDAAuC,CAAA;IACvC,wCAA2B,CA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AAC,MAAM,KAAK,GAAG,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lvble/core",
3
3
  "private": false,
4
- "version": "2.0.18",
4
+ "version": "2.0.19",
5
5
  "main": "./dist/_bundles/index.js",
6
6
  "module": "./dist/lib-esm/index.js",
7
7
  "types": "./dist/lib/index.d.ts",