@lvble/core 2.0.12 → 2.0.15
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/dist/_bundles/core.js +2 -0
- package/dist/_bundles/core.js.map +1 -0
- package/dist/_bundles/core.min.js +2 -0
- package/dist/_bundles/core.min.js.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/lvble.d.ts +93 -0
- package/dist/lib/lvble.d.ts.map +1 -0
- package/dist/lib/lvble.js +218 -0
- package/dist/lib/lvble.js.map +1 -0
- package/dist/lib-esm/index.d.ts +2 -0
- package/dist/lib-esm/index.d.ts.map +1 -0
- package/dist/lib-esm/index.js +2 -0
- package/dist/lib-esm/index.js.map +1 -0
- package/dist/lib-esm/lvble.d.ts +93 -0
- package/dist/lib-esm/lvble.d.ts.map +1 -0
- package/dist/lib-esm/lvble.js +215 -0
- package/dist/lib-esm/lvble.js.map +1 -0
- package/package.json +6 -6
- package/dist/index.js +0 -1
|
@@ -0,0 +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,c=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"}(a||(t.Environment=a={}));var s,l=((o={})[a.Local]="http://localhost:3001",o[a.Sandbox]="https://widget.sandbox.pms.nowlvble.com",o[a.Production]="https://api.production.partners.nowlvble.com",o),u=((i={})[a.Local]="http://localhost:3001",i[a.Sandbox]="https://experience.sandbox.pms.nowlvble.com",i[a.Production]="https://api.production.partners.nowlvble.com",i);!function(e){e.FinishOnboarding="finishOnboarding",e.FinishOffboarding="finishOffboarding",e.FinishSplit="finishSplit",e.FinishRepay="finishRepay"}(s||(s={})),s.FinishOnboarding,s.FinishOffboarding,s.FinishSplit,s.FinishRepay;var d=function(e){function t(){var t=e.call(this)||this;return Object.defineProperty(t,"_typeToEvent",{enumerable:!0,configurable:!0,writable:!0,value:{onboarding:s.FinishOnboarding,offboarding:s.FinishOffboarding,split:s.FinishSplit,repay:s.FinishRepay}}),Object.defineProperty(t,"_iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t.attachShadow({mode:"open"}),t}return c(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(l[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);null!==(r=customElements.get("lvble-widget"))&&void 0!==r||customElements.define("lvble-widget",d);var p={onboarding:customElements.get("lvble-widget"),repay:customElements.get("lvble-widget")};t.Lvble=function(e){return{createWidget:function(t){var n=t.mode?new p[t.mode]:new(customElements.get("lvble-widget"));return n.environment=e.environment,n.token=e.token,n.mode=t.mode,window.addEventListener("message",(function(n){if(n.origin==l[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(u[e.environment],"?token=").concat(e.token),offboarding:"".concat(u[e.environment],"?token=").concat(e.token),split:"".concat(u[e.environment],"?token=").concat(e.token),repay:"".concat(u[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==u[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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alModuleDefinition","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.get(\"lvble-widget\") ??\n customElements.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 = (\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","get","LvbleWidget","modeWidgetMap","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":""}
|
|
@@ -0,0 +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,c=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"}(a||(t.Environment=a={}));var s,l=((o={})[a.Local]="http://localhost:3001",o[a.Sandbox]="https://widget.sandbox.pms.nowlvble.com",o[a.Production]="https://api.production.partners.nowlvble.com",o),u=((i={})[a.Local]="http://localhost:3001",i[a.Sandbox]="https://experience.sandbox.pms.nowlvble.com",i[a.Production]="https://api.production.partners.nowlvble.com",i);!function(e){e.FinishOnboarding="finishOnboarding",e.FinishOffboarding="finishOffboarding",e.FinishSplit="finishSplit",e.FinishRepay="finishRepay"}(s||(s={})),s.FinishOnboarding,s.FinishOffboarding,s.FinishSplit,s.FinishRepay;var d=function(e){function t(){var t=e.call(this)||this;return Object.defineProperty(t,"_typeToEvent",{enumerable:!0,configurable:!0,writable:!0,value:{onboarding:s.FinishOnboarding,offboarding:s.FinishOffboarding,split:s.FinishSplit,repay:s.FinishRepay}}),Object.defineProperty(t,"_iframe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t.attachShadow({mode:"open"}),t}return c(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(l[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);null!==(r=customElements.get("lvble-widget"))&&void 0!==r||customElements.define("lvble-widget",d);var p={onboarding:customElements.get("lvble-widget"),repay:customElements.get("lvble-widget")};t.Lvble=function(e){return{createWidget:function(t){var n=t.mode?new p[t.mode]:new(customElements.get("lvble-widget"));return n.environment=e.environment,n.token=e.token,n.mode=t.mode,window.addEventListener("message",(function(n){if(n.origin==l[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(u[e.environment],"?token=").concat(e.token),offboarding:"".concat(u[e.environment],"?token=").concat(e.token),split:"".concat(u[e.environment],"?token=").concat(e.token),repay:"".concat(u[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==u[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)})()));
|
|
2
|
+
//# sourceMappingURL=core.min.js.map
|
|
@@ -0,0 +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,gCCAYC,E,uiBAAZ,SAAYA,GACV,gBACA,oBACA,yBACD,CAJD,CAAYA,IAAW,cAAXA,EAAW,KAKvB,IAuCKC,EAvCCC,IAAqB,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,EAAI,QAAUG,GA0BvEhB,OAAOC,iBAAiB,WAvBA,SAACC,GACvB,GACEA,EAAQC,QAAU9C,EAA0BuC,EAAYtB,aAD1D,CAQA,IAAM4C,EAAYhB,EAAQE,KACpBe,EAAU1C,SAAS2C,iBAAiB,gBAE1ClB,EAAUmB,KAAKC,MAAMD,KAAKE,UAAUrB,IAEpCiB,EAAQK,SAAQ,SAACT,G,QAGA,QAFd,GACa,QAAZ,EAAAA,EAAE5B,kBAAU,eAAEsC,cAAc,WAC5BC,qBAAa,SAAEC,YAAYzB,EAAS,IACxC,IAEAQ,EAAYL,QAAQa,EAAUZ,UAAWY,E,MAhBvCX,QAAQC,MACN,gDAAyCN,EAAQC,QAgBvD,GAGF,EAEJ,C,GChQIyB,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAarF,QAGrB,IAAIC,EAASiF,EAAyBE,GAAY,CAGjDpF,QAAS,CAAC,GAOX,OAHAuF,EAAoBH,GAAUI,KAAKvF,EAAOD,QAASC,EAAQA,EAAOD,QAASmF,GAGpElF,EAAOD,OACf,CCnB0BmF,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.get(\"lvble-widget\") ??\n customElements.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 = (\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","get","LvbleWidget","modeWidgetMap","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":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lvble"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare enum Environment {
|
|
2
|
+
Local = "local",
|
|
3
|
+
Sandbox = "sandbox",
|
|
4
|
+
Production = "production"
|
|
5
|
+
}
|
|
6
|
+
export type Mode = "onboarding" | "offboarding" | "split" | "repay";
|
|
7
|
+
export type ErrorData = {
|
|
8
|
+
type: "error";
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
export type OnboardingData = ErrorData | {
|
|
12
|
+
type: "success";
|
|
13
|
+
status: string;
|
|
14
|
+
};
|
|
15
|
+
export type SplitData = ErrorData | {
|
|
16
|
+
type: "success";
|
|
17
|
+
external_id: string;
|
|
18
|
+
settlement_id: string;
|
|
19
|
+
amount: number;
|
|
20
|
+
};
|
|
21
|
+
export type CloseData = ErrorData | {
|
|
22
|
+
type: "close";
|
|
23
|
+
};
|
|
24
|
+
export type EventData = OnboardingData | SplitData | CloseData;
|
|
25
|
+
declare enum EventType {
|
|
26
|
+
FinishOnboarding = "finishOnboarding",
|
|
27
|
+
FinishOffboarding = "finishOffboarding",
|
|
28
|
+
FinishSplit = "finishSplit",
|
|
29
|
+
FinishRepay = "finishRepay"
|
|
30
|
+
}
|
|
31
|
+
export interface InitOptions {
|
|
32
|
+
environment: Environment;
|
|
33
|
+
token: string;
|
|
34
|
+
}
|
|
35
|
+
export interface OpenOptions {
|
|
36
|
+
mode?: Mode;
|
|
37
|
+
onEvent: (eventType: string, data: any) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface CreateWidgetOptions extends OpenOptions {
|
|
40
|
+
mode?: Extract<Mode, "onboarding" | "repay">;
|
|
41
|
+
onEvent: (eventType: string, data: any) => void;
|
|
42
|
+
}
|
|
43
|
+
declare class LvbleWidget extends HTMLElement {
|
|
44
|
+
_typeToEvent: {
|
|
45
|
+
onboarding: EventType;
|
|
46
|
+
offboarding: EventType;
|
|
47
|
+
split: EventType;
|
|
48
|
+
repay: EventType;
|
|
49
|
+
};
|
|
50
|
+
_iframe?: HTMLIFrameElement;
|
|
51
|
+
constructor();
|
|
52
|
+
get mode(): Mode;
|
|
53
|
+
set mode(val: Mode | undefined);
|
|
54
|
+
get environment(): Environment;
|
|
55
|
+
set environment(val: Environment);
|
|
56
|
+
get token(): string;
|
|
57
|
+
set token(val: string);
|
|
58
|
+
connectedCallback(): void;
|
|
59
|
+
disconnectedCallback(): void;
|
|
60
|
+
}
|
|
61
|
+
declare const lvble: (initOptions: InitOptions) => {
|
|
62
|
+
/**
|
|
63
|
+
* This function creates a widget that can be embedded in your website.
|
|
64
|
+
*
|
|
65
|
+
* @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
|
|
66
|
+
* @returns The widget.
|
|
67
|
+
*/
|
|
68
|
+
createWidget: (createOptions: CreateWidgetOptions) => LvbleWidget;
|
|
69
|
+
/**
|
|
70
|
+
* This function opens a popup with the relevant mode.
|
|
71
|
+
* @param openOptions The options for opening the widget. See OpenOptions for more information.
|
|
72
|
+
* @returns undefined.
|
|
73
|
+
*/
|
|
74
|
+
open: (openOptions: OpenOptions) => void;
|
|
75
|
+
};
|
|
76
|
+
export type LvbleType = ReturnType<typeof lvble>;
|
|
77
|
+
export declare const Lvble: (initOptions: InitOptions) => {
|
|
78
|
+
/**
|
|
79
|
+
* This function creates a widget that can be embedded in your website.
|
|
80
|
+
*
|
|
81
|
+
* @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
|
|
82
|
+
* @returns The widget.
|
|
83
|
+
*/
|
|
84
|
+
createWidget: (createOptions: CreateWidgetOptions) => LvbleWidget;
|
|
85
|
+
/**
|
|
86
|
+
* This function opens a popup with the relevant mode.
|
|
87
|
+
* @param openOptions The options for opening the widget. See OpenOptions for more information.
|
|
88
|
+
* @returns undefined.
|
|
89
|
+
*/
|
|
90
|
+
open: (openOptions: OpenOptions) => void;
|
|
91
|
+
};
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=lvble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lvble.d.ts","sourceRoot":"","sources":["../../src/lib/lvble.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAaD,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AACpE,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,cAAc,GACtB,SAAS,GACT;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACN,MAAM,MAAM,SAAS,GACjB,SAAS,GACT;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAA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;;;OAKG;kCAE2B,mBAAmB;IA0BjD;;;;OAIG;wBACiB,WAAW;CAsDlC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AAEjD,eAAO,MAAM,KAAK,gBAlGU,WAAW;IAEnC;;;;;OAKG;kCAE2B,mBAAmB;IA0BjD;;;;OAIG;wBACiB,WAAW;CA0DT,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
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
|
+
var _c;
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Lvble = exports.Environment = void 0;
|
|
21
|
+
var Environment;
|
|
22
|
+
(function (Environment) {
|
|
23
|
+
Environment["Local"] = "local";
|
|
24
|
+
Environment["Sandbox"] = "sandbox";
|
|
25
|
+
Environment["Production"] = "production";
|
|
26
|
+
})(Environment || (exports.Environment = Environment = {}));
|
|
27
|
+
var envToBaseUrlMapWidget = (_a = {},
|
|
28
|
+
_a[Environment.Local] = "http://localhost:3001",
|
|
29
|
+
_a[Environment.Sandbox] = "https://widget.sandbox.pms.nowlvble.com",
|
|
30
|
+
_a[Environment.Production] = "https://api.production.partners.nowlvble.com",
|
|
31
|
+
_a);
|
|
32
|
+
var envToBaseUrlMapExperience = (_b = {},
|
|
33
|
+
_b[Environment.Local] = "http://localhost:3001",
|
|
34
|
+
_b[Environment.Sandbox] = "https://experience.sandbox.pms.nowlvble.com",
|
|
35
|
+
_b[Environment.Production] = "https://api.production.partners.nowlvble.com",
|
|
36
|
+
_b);
|
|
37
|
+
var EventType;
|
|
38
|
+
(function (EventType) {
|
|
39
|
+
EventType["FinishOnboarding"] = "finishOnboarding";
|
|
40
|
+
EventType["FinishOffboarding"] = "finishOffboarding";
|
|
41
|
+
EventType["FinishSplit"] = "finishSplit";
|
|
42
|
+
EventType["FinishRepay"] = "finishRepay";
|
|
43
|
+
})(EventType || (EventType = {}));
|
|
44
|
+
var modeToEventType = {
|
|
45
|
+
onboarding: EventType.FinishOnboarding,
|
|
46
|
+
offboarding: EventType.FinishOffboarding,
|
|
47
|
+
split: EventType.FinishSplit,
|
|
48
|
+
repay: EventType.FinishRepay,
|
|
49
|
+
};
|
|
50
|
+
var LvbleWidget = /** @class */ (function (_super) {
|
|
51
|
+
__extends(LvbleWidget, _super);
|
|
52
|
+
function LvbleWidget() {
|
|
53
|
+
var _this = _super.call(this) || this;
|
|
54
|
+
Object.defineProperty(_this, "_typeToEvent", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: {
|
|
59
|
+
onboarding: EventType.FinishOnboarding,
|
|
60
|
+
offboarding: EventType.FinishOffboarding,
|
|
61
|
+
split: EventType.FinishSplit,
|
|
62
|
+
repay: EventType.FinishRepay,
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(_this, "_iframe", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
_this.attachShadow({ mode: "open" });
|
|
72
|
+
return _this;
|
|
73
|
+
}
|
|
74
|
+
Object.defineProperty(LvbleWidget.prototype, "mode", {
|
|
75
|
+
get: function () {
|
|
76
|
+
return this.getAttribute("mode");
|
|
77
|
+
},
|
|
78
|
+
set: function (val) {
|
|
79
|
+
if (val) {
|
|
80
|
+
this.setAttribute("mode", val);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.removeAttribute("mode");
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(LvbleWidget.prototype, "environment", {
|
|
90
|
+
get: function () {
|
|
91
|
+
return this.getAttribute("environment");
|
|
92
|
+
},
|
|
93
|
+
set: function (val) {
|
|
94
|
+
if (val) {
|
|
95
|
+
this.setAttribute("environment", val);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.removeAttribute("environment");
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(LvbleWidget.prototype, "token", {
|
|
105
|
+
get: function () {
|
|
106
|
+
return this.getAttribute("token");
|
|
107
|
+
},
|
|
108
|
+
set: function (val) {
|
|
109
|
+
if (val) {
|
|
110
|
+
this.setAttribute("token", val);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
this.removeAttribute("token");
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
enumerable: false,
|
|
117
|
+
configurable: true
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(LvbleWidget.prototype, "connectedCallback", {
|
|
120
|
+
enumerable: false,
|
|
121
|
+
configurable: true,
|
|
122
|
+
writable: true,
|
|
123
|
+
value: function () {
|
|
124
|
+
var _a;
|
|
125
|
+
var iframeSrc = "".concat(envToBaseUrlMapWidget[this.environment], "?token=").concat(this.token, "&environment=").concat(this.environment);
|
|
126
|
+
var iframe = document.createElement("iframe");
|
|
127
|
+
iframe.src = iframeSrc;
|
|
128
|
+
iframe.width = "100%";
|
|
129
|
+
iframe.height = "100%";
|
|
130
|
+
iframe.style.borderStyle = "solid";
|
|
131
|
+
iframe.style.borderRadius = "10px";
|
|
132
|
+
iframe.style.borderColor = "transparent";
|
|
133
|
+
this._iframe = iframe;
|
|
134
|
+
(_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(LvbleWidget.prototype, "disconnectedCallback", {
|
|
138
|
+
enumerable: false,
|
|
139
|
+
configurable: true,
|
|
140
|
+
writable: true,
|
|
141
|
+
value: function () {
|
|
142
|
+
if (this.shadowRoot)
|
|
143
|
+
this.shadowRoot.innerHTML = "";
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return LvbleWidget;
|
|
147
|
+
}(HTMLElement));
|
|
148
|
+
(_c = customElements.get("lvble-widget")) !== null && _c !== void 0 ? _c : customElements.define("lvble-widget", LvbleWidget);
|
|
149
|
+
var modeWidgetMap = {
|
|
150
|
+
onboarding: customElements.get("lvble-widget"),
|
|
151
|
+
repay: customElements.get("lvble-widget"),
|
|
152
|
+
};
|
|
153
|
+
var _popup;
|
|
154
|
+
var lvble = function (initOptions) {
|
|
155
|
+
return {
|
|
156
|
+
/**
|
|
157
|
+
* This function creates a widget that can be embedded in your website.
|
|
158
|
+
*
|
|
159
|
+
* @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
|
|
160
|
+
* @returns The widget.
|
|
161
|
+
*/
|
|
162
|
+
// TODO: Add support for no mode
|
|
163
|
+
createWidget: function (createOptions) {
|
|
164
|
+
var widget = (createOptions.mode
|
|
165
|
+
? new modeWidgetMap[createOptions.mode]()
|
|
166
|
+
: new (customElements.get("lvble-widget"))());
|
|
167
|
+
widget.environment = initOptions.environment;
|
|
168
|
+
widget.token = initOptions.token;
|
|
169
|
+
widget.mode = createOptions.mode;
|
|
170
|
+
var messageListener = function (message) {
|
|
171
|
+
if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {
|
|
172
|
+
console.debug("Received message from unknown origin: ".concat(message.origin));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
var data = message.data;
|
|
176
|
+
createOptions.onEvent(data.eventType, data);
|
|
177
|
+
};
|
|
178
|
+
window.addEventListener("message", messageListener);
|
|
179
|
+
return widget;
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* This function opens a popup with the relevant mode.
|
|
183
|
+
* @param openOptions The options for opening the widget. See OpenOptions for more information.
|
|
184
|
+
* @returns undefined.
|
|
185
|
+
*/
|
|
186
|
+
open: function (openOptions) {
|
|
187
|
+
var modeUrlMap = {
|
|
188
|
+
onboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
189
|
+
offboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
190
|
+
split: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
191
|
+
repay: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
192
|
+
};
|
|
193
|
+
var modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : "";
|
|
194
|
+
var w = 450;
|
|
195
|
+
var h = 800;
|
|
196
|
+
var l = screen.width / 2 - w / 2;
|
|
197
|
+
var t = screen.height / 2 - h / 2;
|
|
198
|
+
_popup = window.open(modeUrl, "LvblePopup", "width=" + w + ",height=" + h + ",location=no,left=" + l + ",top=" + t);
|
|
199
|
+
var messageListener = function (message) {
|
|
200
|
+
if (message.origin != envToBaseUrlMapExperience[initOptions.environment]) {
|
|
201
|
+
console.debug("Received message from unknown origin: ".concat(message.origin));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
var eventData = message.data;
|
|
205
|
+
var iframes = document.querySelectorAll("lvble-widget");
|
|
206
|
+
message = JSON.parse(JSON.stringify(message));
|
|
207
|
+
iframes.forEach(function (w) {
|
|
208
|
+
var _a, _b;
|
|
209
|
+
(_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(message, "*");
|
|
210
|
+
});
|
|
211
|
+
openOptions.onEvent(eventData.eventType, eventData);
|
|
212
|
+
};
|
|
213
|
+
window.addEventListener("message", messageListener);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
exports.Lvble = lvble;
|
|
218
|
+
//# sourceMappingURL=lvble.js.map
|
|
@@ -0,0 +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;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,CAAA;IAC3B,wCAA2B,CAAA;AAC7B,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAED,IAAM,eAAe,GAAG;IACtB,UAAU,EAAE,SAAS,CAAC,gBAAgB;IACtC,WAAW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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare enum Environment {
|
|
2
|
+
Local = "local",
|
|
3
|
+
Sandbox = "sandbox",
|
|
4
|
+
Production = "production"
|
|
5
|
+
}
|
|
6
|
+
export type Mode = "onboarding" | "offboarding" | "split" | "repay";
|
|
7
|
+
export type ErrorData = {
|
|
8
|
+
type: "error";
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
export type OnboardingData = ErrorData | {
|
|
12
|
+
type: "success";
|
|
13
|
+
status: string;
|
|
14
|
+
};
|
|
15
|
+
export type SplitData = ErrorData | {
|
|
16
|
+
type: "success";
|
|
17
|
+
external_id: string;
|
|
18
|
+
settlement_id: string;
|
|
19
|
+
amount: number;
|
|
20
|
+
};
|
|
21
|
+
export type CloseData = ErrorData | {
|
|
22
|
+
type: "close";
|
|
23
|
+
};
|
|
24
|
+
export type EventData = OnboardingData | SplitData | CloseData;
|
|
25
|
+
declare enum EventType {
|
|
26
|
+
FinishOnboarding = "finishOnboarding",
|
|
27
|
+
FinishOffboarding = "finishOffboarding",
|
|
28
|
+
FinishSplit = "finishSplit",
|
|
29
|
+
FinishRepay = "finishRepay"
|
|
30
|
+
}
|
|
31
|
+
export interface InitOptions {
|
|
32
|
+
environment: Environment;
|
|
33
|
+
token: string;
|
|
34
|
+
}
|
|
35
|
+
export interface OpenOptions {
|
|
36
|
+
mode?: Mode;
|
|
37
|
+
onEvent: (eventType: string, data: any) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface CreateWidgetOptions extends OpenOptions {
|
|
40
|
+
mode?: Extract<Mode, "onboarding" | "repay">;
|
|
41
|
+
onEvent: (eventType: string, data: any) => void;
|
|
42
|
+
}
|
|
43
|
+
declare class LvbleWidget extends HTMLElement {
|
|
44
|
+
_typeToEvent: {
|
|
45
|
+
onboarding: EventType;
|
|
46
|
+
offboarding: EventType;
|
|
47
|
+
split: EventType;
|
|
48
|
+
repay: EventType;
|
|
49
|
+
};
|
|
50
|
+
_iframe?: HTMLIFrameElement;
|
|
51
|
+
constructor();
|
|
52
|
+
get mode(): Mode;
|
|
53
|
+
set mode(val: Mode | undefined);
|
|
54
|
+
get environment(): Environment;
|
|
55
|
+
set environment(val: Environment);
|
|
56
|
+
get token(): string;
|
|
57
|
+
set token(val: string);
|
|
58
|
+
connectedCallback(): void;
|
|
59
|
+
disconnectedCallback(): void;
|
|
60
|
+
}
|
|
61
|
+
declare const lvble: (initOptions: InitOptions) => {
|
|
62
|
+
/**
|
|
63
|
+
* This function creates a widget that can be embedded in your website.
|
|
64
|
+
*
|
|
65
|
+
* @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
|
|
66
|
+
* @returns The widget.
|
|
67
|
+
*/
|
|
68
|
+
createWidget: (createOptions: CreateWidgetOptions) => LvbleWidget;
|
|
69
|
+
/**
|
|
70
|
+
* This function opens a popup with the relevant mode.
|
|
71
|
+
* @param openOptions The options for opening the widget. See OpenOptions for more information.
|
|
72
|
+
* @returns undefined.
|
|
73
|
+
*/
|
|
74
|
+
open: (openOptions: OpenOptions) => void;
|
|
75
|
+
};
|
|
76
|
+
export type LvbleType = ReturnType<typeof lvble>;
|
|
77
|
+
export declare const Lvble: (initOptions: InitOptions) => {
|
|
78
|
+
/**
|
|
79
|
+
* This function creates a widget that can be embedded in your website.
|
|
80
|
+
*
|
|
81
|
+
* @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
|
|
82
|
+
* @returns The widget.
|
|
83
|
+
*/
|
|
84
|
+
createWidget: (createOptions: CreateWidgetOptions) => LvbleWidget;
|
|
85
|
+
/**
|
|
86
|
+
* This function opens a popup with the relevant mode.
|
|
87
|
+
* @param openOptions The options for opening the widget. See OpenOptions for more information.
|
|
88
|
+
* @returns undefined.
|
|
89
|
+
*/
|
|
90
|
+
open: (openOptions: OpenOptions) => void;
|
|
91
|
+
};
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=lvble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lvble.d.ts","sourceRoot":"","sources":["../../src/lib/lvble.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAaD,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AACpE,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,cAAc,GACtB,SAAS,GACT;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACN,MAAM,MAAM,SAAS,GACjB,SAAS,GACT;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACN,MAAM,MAAM,SAAS,GACjB,SAAS,GACT;IACE,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;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AIG;wBACiB,WAAW;CA0DT,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
var _c;
|
|
18
|
+
export var Environment;
|
|
19
|
+
(function (Environment) {
|
|
20
|
+
Environment["Local"] = "local";
|
|
21
|
+
Environment["Sandbox"] = "sandbox";
|
|
22
|
+
Environment["Production"] = "production";
|
|
23
|
+
})(Environment || (Environment = {}));
|
|
24
|
+
var envToBaseUrlMapWidget = (_a = {},
|
|
25
|
+
_a[Environment.Local] = "http://localhost:3001",
|
|
26
|
+
_a[Environment.Sandbox] = "https://widget.sandbox.pms.nowlvble.com",
|
|
27
|
+
_a[Environment.Production] = "https://api.production.partners.nowlvble.com",
|
|
28
|
+
_a);
|
|
29
|
+
var envToBaseUrlMapExperience = (_b = {},
|
|
30
|
+
_b[Environment.Local] = "http://localhost:3001",
|
|
31
|
+
_b[Environment.Sandbox] = "https://experience.sandbox.pms.nowlvble.com",
|
|
32
|
+
_b[Environment.Production] = "https://api.production.partners.nowlvble.com",
|
|
33
|
+
_b);
|
|
34
|
+
var EventType;
|
|
35
|
+
(function (EventType) {
|
|
36
|
+
EventType["FinishOnboarding"] = "finishOnboarding";
|
|
37
|
+
EventType["FinishOffboarding"] = "finishOffboarding";
|
|
38
|
+
EventType["FinishSplit"] = "finishSplit";
|
|
39
|
+
EventType["FinishRepay"] = "finishRepay";
|
|
40
|
+
})(EventType || (EventType = {}));
|
|
41
|
+
var modeToEventType = {
|
|
42
|
+
onboarding: EventType.FinishOnboarding,
|
|
43
|
+
offboarding: EventType.FinishOffboarding,
|
|
44
|
+
split: EventType.FinishSplit,
|
|
45
|
+
repay: EventType.FinishRepay,
|
|
46
|
+
};
|
|
47
|
+
var LvbleWidget = /** @class */ (function (_super) {
|
|
48
|
+
__extends(LvbleWidget, _super);
|
|
49
|
+
function LvbleWidget() {
|
|
50
|
+
var _this = _super.call(this) || this;
|
|
51
|
+
Object.defineProperty(_this, "_typeToEvent", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: {
|
|
56
|
+
onboarding: EventType.FinishOnboarding,
|
|
57
|
+
offboarding: EventType.FinishOffboarding,
|
|
58
|
+
split: EventType.FinishSplit,
|
|
59
|
+
repay: EventType.FinishRepay,
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(_this, "_iframe", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
_this.attachShadow({ mode: "open" });
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
Object.defineProperty(LvbleWidget.prototype, "mode", {
|
|
72
|
+
get: function () {
|
|
73
|
+
return this.getAttribute("mode");
|
|
74
|
+
},
|
|
75
|
+
set: function (val) {
|
|
76
|
+
if (val) {
|
|
77
|
+
this.setAttribute("mode", val);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.removeAttribute("mode");
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
enumerable: false,
|
|
84
|
+
configurable: true
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(LvbleWidget.prototype, "environment", {
|
|
87
|
+
get: function () {
|
|
88
|
+
return this.getAttribute("environment");
|
|
89
|
+
},
|
|
90
|
+
set: function (val) {
|
|
91
|
+
if (val) {
|
|
92
|
+
this.setAttribute("environment", val);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.removeAttribute("environment");
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(LvbleWidget.prototype, "token", {
|
|
102
|
+
get: function () {
|
|
103
|
+
return this.getAttribute("token");
|
|
104
|
+
},
|
|
105
|
+
set: function (val) {
|
|
106
|
+
if (val) {
|
|
107
|
+
this.setAttribute("token", val);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.removeAttribute("token");
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
enumerable: false,
|
|
114
|
+
configurable: true
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(LvbleWidget.prototype, "connectedCallback", {
|
|
117
|
+
enumerable: false,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: function () {
|
|
121
|
+
var _a;
|
|
122
|
+
var iframeSrc = "".concat(envToBaseUrlMapWidget[this.environment], "?token=").concat(this.token, "&environment=").concat(this.environment);
|
|
123
|
+
var iframe = document.createElement("iframe");
|
|
124
|
+
iframe.src = iframeSrc;
|
|
125
|
+
iframe.width = "100%";
|
|
126
|
+
iframe.height = "100%";
|
|
127
|
+
iframe.style.borderStyle = "solid";
|
|
128
|
+
iframe.style.borderRadius = "10px";
|
|
129
|
+
iframe.style.borderColor = "transparent";
|
|
130
|
+
this._iframe = iframe;
|
|
131
|
+
(_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(LvbleWidget.prototype, "disconnectedCallback", {
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true,
|
|
137
|
+
writable: true,
|
|
138
|
+
value: function () {
|
|
139
|
+
if (this.shadowRoot)
|
|
140
|
+
this.shadowRoot.innerHTML = "";
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return LvbleWidget;
|
|
144
|
+
}(HTMLElement));
|
|
145
|
+
(_c = customElements.get("lvble-widget")) !== null && _c !== void 0 ? _c : customElements.define("lvble-widget", LvbleWidget);
|
|
146
|
+
var modeWidgetMap = {
|
|
147
|
+
onboarding: customElements.get("lvble-widget"),
|
|
148
|
+
repay: customElements.get("lvble-widget"),
|
|
149
|
+
};
|
|
150
|
+
var _popup;
|
|
151
|
+
var lvble = function (initOptions) {
|
|
152
|
+
return {
|
|
153
|
+
/**
|
|
154
|
+
* This function creates a widget that can be embedded in your website.
|
|
155
|
+
*
|
|
156
|
+
* @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
|
|
157
|
+
* @returns The widget.
|
|
158
|
+
*/
|
|
159
|
+
// TODO: Add support for no mode
|
|
160
|
+
createWidget: function (createOptions) {
|
|
161
|
+
var widget = (createOptions.mode
|
|
162
|
+
? new modeWidgetMap[createOptions.mode]()
|
|
163
|
+
: new (customElements.get("lvble-widget"))());
|
|
164
|
+
widget.environment = initOptions.environment;
|
|
165
|
+
widget.token = initOptions.token;
|
|
166
|
+
widget.mode = createOptions.mode;
|
|
167
|
+
var messageListener = function (message) {
|
|
168
|
+
if (message.origin != envToBaseUrlMapWidget[initOptions.environment]) {
|
|
169
|
+
console.debug("Received message from unknown origin: ".concat(message.origin));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
var data = message.data;
|
|
173
|
+
createOptions.onEvent(data.eventType, data);
|
|
174
|
+
};
|
|
175
|
+
window.addEventListener("message", messageListener);
|
|
176
|
+
return widget;
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* This function opens a popup with the relevant mode.
|
|
180
|
+
* @param openOptions The options for opening the widget. See OpenOptions for more information.
|
|
181
|
+
* @returns undefined.
|
|
182
|
+
*/
|
|
183
|
+
open: function (openOptions) {
|
|
184
|
+
var modeUrlMap = {
|
|
185
|
+
onboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
186
|
+
offboarding: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
187
|
+
split: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
188
|
+
repay: "".concat(envToBaseUrlMapExperience[initOptions.environment], "?token=").concat(initOptions.token),
|
|
189
|
+
};
|
|
190
|
+
var modeUrl = openOptions.mode ? modeUrlMap[openOptions.mode] : "";
|
|
191
|
+
var w = 450;
|
|
192
|
+
var h = 800;
|
|
193
|
+
var l = screen.width / 2 - w / 2;
|
|
194
|
+
var t = screen.height / 2 - h / 2;
|
|
195
|
+
_popup = window.open(modeUrl, "LvblePopup", "width=" + w + ",height=" + h + ",location=no,left=" + l + ",top=" + t);
|
|
196
|
+
var messageListener = function (message) {
|
|
197
|
+
if (message.origin != envToBaseUrlMapExperience[initOptions.environment]) {
|
|
198
|
+
console.debug("Received message from unknown origin: ".concat(message.origin));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
var eventData = message.data;
|
|
202
|
+
var iframes = document.querySelectorAll("lvble-widget");
|
|
203
|
+
message = JSON.parse(JSON.stringify(message));
|
|
204
|
+
iframes.forEach(function (w) {
|
|
205
|
+
var _a, _b;
|
|
206
|
+
(_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(message, "*");
|
|
207
|
+
});
|
|
208
|
+
openOptions.onEvent(eventData.eventType, eventData);
|
|
209
|
+
};
|
|
210
|
+
window.addEventListener("message", messageListener);
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
export var Lvble = lvble;
|
|
215
|
+
//# sourceMappingURL=lvble.js.map
|
|
@@ -0,0 +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,CAAA;IAC3B,wCAA2B,CAAA;AAC7B,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAED,IAAM,eAAe,GAAG;IACtB,UAAU,EAAE,SAAS,CAAC,gBAAgB;IACtC,WAAW,EAAE,SAAS,CAAC,iBAAiB;IACxC,KAAK,EAAE,SAAS,CAAC,WAAW;IAC5B,KAAK,EAAE,SAAS,CAAC,WAAW;CAC7B,CAAC;AAsBF;IAA0B,+BAAW;IASnC;QAAA,YACE,iBAAO,SAER;QAXD;;;;mBAAe;gBACb,UAAU,EAAE,SAAS,CAAC,gBAAgB;gBACtC,WAAW,EAAE,SAAS,CAAC,iBAAiB;gBACxC,KAAK,EAAE,SAAS,CAAC,WAAW;gBAC5B,KAAK,EAAE,SAAS,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|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.0.
|
|
5
|
-
"main": "./dist
|
|
6
|
-
"module": "./dist
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
4
|
+
"version": "2.0.15",
|
|
5
|
+
"main": "./dist/_bundles/index.js",
|
|
6
|
+
"module": "./dist/lib-esm/index.js",
|
|
7
|
+
"types": "./dist/lib/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"import": "./dist
|
|
11
|
-
"require": "./dist
|
|
10
|
+
"import": "./dist/lib-esm/index.js",
|
|
11
|
+
"require": "./dist/lib/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./dist/style.css": "./dist/style.css"
|
|
14
14
|
},
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{"use strict";var e,t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{Environment:()=>e,Lvble:()=>l}),function(e){e.Local="local",e.Sandbox="sandbox",e.Production="production"}(e||(e={}));const o={[e.Local]:"http://localhost:3001",[e.Sandbox]:"https://widget.sandbox.pms.nowlvble.com",[e.Production]:"https://api.production.partners.nowlvble.com"},i={[e.Local]:"http://localhost:3001",[e.Sandbox]:"https://experience.sandbox.pms.nowlvble.com",[e.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{_typeToEvent={onboarding:r.FinishOnboarding,offboarding:r.FinishOffboarding,split:r.FinishSplit,repay:r.FinishRepay};_iframe;constructor(){super(),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(){const e=`${o[this.environment]}?token=${this.token}&environment=${this.environment}`,t=document.createElement("iframe");t.src=e,t.width="100%",t.height="100%",t.style.borderStyle="solid",t.style.borderRadius="10px",t.style.borderColor="transparent",this._iframe=t,this.shadowRoot?.appendChild(t)}disconnectedCallback(){this.shadowRoot&&(this.shadowRoot.innerHTML="")}}customElements.get("lvble-widget")??customElements.define("lvble-widget",s);const d={onboarding:customElements.get("lvble-widget"),repay:customElements.get("lvble-widget")};let a;const l=e=>({createWidget:t=>{const n=t.mode?new d[t.mode]:new(customElements.get("lvble-widget"));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;a=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=>{(e.shadowRoot?.querySelector("iframe")).contentWindow?.postMessage(n,"*")})),t.onEvent(o.eventType,o)}))}});module.exports=n})();
|