@lvble/core 2.0.20 → 2.0.21
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 +1 -1
- package/dist/_bundles/core.js.map +1 -1
- package/dist/_bundles/core.min.js +1 -1
- package/dist/_bundles/core.min.js.map +1 -1
- package/dist/lib/lvble.js +8 -8
- package/dist/lib/lvble.js.map +1 -1
- package/dist/lib-esm/lvble.js +8 -8
- package/dist/lib-esm/lvble.js.map +1 -1
- package/package.json +1 -1
package/dist/_bundles/core.js
CHANGED
|
@@ -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:(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.
|
|
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.pms.sandbox.nowlvble.com",[n.Production]:"https://widget.pms.production.nowlvble.com"},i={[n.Local]:"http://localhost:3000",[n.Sandbox]:"https://experience.pms.sandbox.nowlvble.com",[n.Production]:"https://experience.pms.production.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.data)})),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]:`${i[e.environment]}?token=${e.token}`,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,n;null===(n=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector("iframe")).contentWindow)||void 0===n||n.postMessage(o,"*")})),t.onEvent(o.eventType,o.data)}))}})}},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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AAOC,iBAAiB,WAvBCC,IACvB,GACEA,EAAQC,QAAUnD,EAA0B4C,EAAYvB,aAKxD,YAHA+B,QAAQC,MACN,yCAAyCH,EAAQC,UAIrD,MAAMe,EAAYhB,EAAQI,KACpBa,EAAUzC,SAAS0C,iBAAiB,gBAE1ClB,EAAUmB,KAAKC,MAAMD,KAAKE,UAAUrB,IAEpCiB,EAAQK,SAAST,I,QAGA,QAFd,GACa,QAAZ,EAAAA,EAAE3B,kBAAU,eAAEqC,cAAc,WAC5BC,qBAAa,SAAEC,YAAYzB,EAAS,IAAI,IAG5CQ,EAAYH,QAAQW,EAAUV,UAAWU,EAAU,GAGF,G,GChQrDU,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 ? \n modeUrlMap[openOptions.mode] : \n `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`;\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
|
+
{"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,G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A0BvEhB,OAAOC,iBAAiB,WAvBCC,IACvB,GACEA,EAAQC,QAAUnD,EAA0B4C,EAAYvB,aAKxD,YAHA+B,QAAQC,MACN,yCAAyCH,EAAQC,UAIrD,MAAMe,EAAYhB,EAAQI,KACpBa,EAAUzC,SAAS0C,iBAAiB,gBAE1ClB,EAAUmB,KAAKC,MAAMD,KAAKE,UAAUrB,IAEpCiB,EAAQK,SAAST,I,QAGA,QAFd,GACa,QAAZ,EAAAA,EAAE3B,kBAAU,eAAEqC,cAAc,WAC5BC,qBAAa,SAAEC,YAAYT,EAAW,IAAI,IAG9CR,EAAYH,QAAQW,EAAUV,UAAWU,EAAUZ,KAAK,GAGP,G,GChQrDsB,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.pms.sandbox.nowlvble.com\",\n [Environment.Production]: \"https://widget.pms.production.nowlvble.com\",\n};\n\nconst envToBaseUrlMapExperience: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3000\",\n [Environment.Sandbox]: \"https://experience.pms.sandbox.nowlvble.com\",\n [Environment.Production]: \"https://experience.pms.production.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.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 ? \n modeUrlMap[openOptions.mode] : \n `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`;\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(eventData, \"*\");\n });\n\n openOptions.onEvent(eventData.eventType, eventData.data);\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:(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.
|
|
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.pms.sandbox.nowlvble.com",[n.Production]:"https://widget.pms.production.nowlvble.com"},i={[n.Local]:"http://localhost:3000",[n.Sandbox]:"https://experience.pms.sandbox.nowlvble.com",[n.Production]:"https://experience.pms.production.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.data)})),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]:`${i[e.environment]}?token=${e.token}`,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,n;null===(n=(null===(t=e.shadowRoot)||void 0===t?void 0:t.querySelector("iframe")).contentWindow)||void 0===n||n.postMessage(o,"*")})),t.onEvent(o.eventType,o.data)}))}})}},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,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,WAAYT,EAAUC,iBACtBS,Y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,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 ? \n modeUrlMap[openOptions.mode] : \n `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`;\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
|
+
{"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,8CAGtBC,EAAyD,CAC7D,CAACL,EAAYE,OAAQ,wBACrB,CAACF,EAAYG,SAAU,8CACvB,CAACH,EAAYI,YAAa,kDA8B5B,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,WAAYT,EAAUC,iBAC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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.pms.sandbox.nowlvble.com\",\n [Environment.Production]: \"https://widget.pms.production.nowlvble.com\",\n};\n\nconst envToBaseUrlMapExperience: Record<Environment, string> = {\n [Environment.Local]: \"http://localhost:3000\",\n [Environment.Sandbox]: \"https://experience.pms.sandbox.nowlvble.com\",\n [Environment.Production]: \"https://experience.pms.production.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.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 ? \n modeUrlMap[openOptions.mode] : \n `${envToBaseUrlMapExperience[initOptions.environment]}?token=${initOptions.token}`;\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(eventData, \"*\");\n });\n\n openOptions.onEvent(eventData.eventType, eventData.data);\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
|
@@ -9,13 +9,13 @@ var Environment;
|
|
|
9
9
|
})(Environment || (exports.Environment = Environment = {}));
|
|
10
10
|
const envToBaseUrlMapWidget = {
|
|
11
11
|
[Environment.Local]: "http://localhost:3001",
|
|
12
|
-
[Environment.Sandbox]: "https://widget.sandbox.
|
|
13
|
-
[Environment.Production]: "https://
|
|
12
|
+
[Environment.Sandbox]: "https://widget.pms.sandbox.nowlvble.com",
|
|
13
|
+
[Environment.Production]: "https://widget.pms.production.nowlvble.com",
|
|
14
14
|
};
|
|
15
15
|
const envToBaseUrlMapExperience = {
|
|
16
|
-
[Environment.Local]: "http://localhost:
|
|
17
|
-
[Environment.Sandbox]: "https://experience.sandbox.
|
|
18
|
-
[Environment.Production]: "https://
|
|
16
|
+
[Environment.Local]: "http://localhost:3000",
|
|
17
|
+
[Environment.Sandbox]: "https://experience.pms.sandbox.nowlvble.com",
|
|
18
|
+
[Environment.Production]: "https://experience.pms.production.nowlvble.com",
|
|
19
19
|
};
|
|
20
20
|
var EventType;
|
|
21
21
|
(function (EventType) {
|
|
@@ -136,7 +136,7 @@ const lvble = (initOptions) => {
|
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
const data = message.data;
|
|
139
|
-
createOptions.onEvent(data.eventType, data);
|
|
139
|
+
createOptions.onEvent(data.eventType, data.data);
|
|
140
140
|
};
|
|
141
141
|
window.addEventListener("message", messageListener);
|
|
142
142
|
return widget;
|
|
@@ -171,9 +171,9 @@ const lvble = (initOptions) => {
|
|
|
171
171
|
message = JSON.parse(JSON.stringify(message));
|
|
172
172
|
iframes.forEach((w) => {
|
|
173
173
|
var _a, _b;
|
|
174
|
-
(_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(
|
|
174
|
+
(_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(eventData, "*");
|
|
175
175
|
});
|
|
176
|
-
openOptions.onEvent(eventData.eventType, eventData);
|
|
176
|
+
openOptions.onEvent(eventData.eventType, eventData.data);
|
|
177
177
|
};
|
|
178
178
|
window.addEventListener("message", messageListener);
|
|
179
179
|
},
|
package/dist/lib/lvble.js.map
CHANGED
|
@@ -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,MAAM,qBAAqB,GAAgC;IACzD,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,uBAAuB;IAC5C,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,yCAAyC;IAChE,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"lvble.js","sourceRoot":"","sources":["../../src/lib/lvble.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WA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G,CAAC,GAAG,OAAO,GAAG,CAAC,CAC7D,CAAC;YAEZ,MAAM,eAAe,GAAG,CAAC,OAAqB,EAAE,EAAE;gBAChD,IACE,OAAO,CAAC,MAAM,IAAI,yBAAyB,CAAC,WAAW,CAAC,WAAW,CAAC,EACpE;oBACA,OAAO,CAAC,KAAK,CACX,yCAAyC,OAAO,CAAC,MAAM,EAAE,CAC1D,CAAC;oBACF,OAAO;iBACR;gBACD,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;gBAC/B,MAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;gBAE1D,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBAE9C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;;oBACpB,MAAA,CACE,MAAA,CAAC,CAAC,UAAU,0CAAE,aAAa,CAAC,QAAQ,CACrC,CAAA,CAAC,aAAa,0CAAE,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;gBAEH,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YAC3D,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"}
|
package/dist/lib-esm/lvble.js
CHANGED
|
@@ -6,13 +6,13 @@ export var Environment;
|
|
|
6
6
|
})(Environment || (Environment = {}));
|
|
7
7
|
const envToBaseUrlMapWidget = {
|
|
8
8
|
[Environment.Local]: "http://localhost:3001",
|
|
9
|
-
[Environment.Sandbox]: "https://widget.sandbox.
|
|
10
|
-
[Environment.Production]: "https://
|
|
9
|
+
[Environment.Sandbox]: "https://widget.pms.sandbox.nowlvble.com",
|
|
10
|
+
[Environment.Production]: "https://widget.pms.production.nowlvble.com",
|
|
11
11
|
};
|
|
12
12
|
const envToBaseUrlMapExperience = {
|
|
13
|
-
[Environment.Local]: "http://localhost:
|
|
14
|
-
[Environment.Sandbox]: "https://experience.sandbox.
|
|
15
|
-
[Environment.Production]: "https://
|
|
13
|
+
[Environment.Local]: "http://localhost:3000",
|
|
14
|
+
[Environment.Sandbox]: "https://experience.pms.sandbox.nowlvble.com",
|
|
15
|
+
[Environment.Production]: "https://experience.pms.production.nowlvble.com",
|
|
16
16
|
};
|
|
17
17
|
var EventType;
|
|
18
18
|
(function (EventType) {
|
|
@@ -133,7 +133,7 @@ const lvble = (initOptions) => {
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
const data = message.data;
|
|
136
|
-
createOptions.onEvent(data.eventType, data);
|
|
136
|
+
createOptions.onEvent(data.eventType, data.data);
|
|
137
137
|
};
|
|
138
138
|
window.addEventListener("message", messageListener);
|
|
139
139
|
return widget;
|
|
@@ -168,9 +168,9 @@ const lvble = (initOptions) => {
|
|
|
168
168
|
message = JSON.parse(JSON.stringify(message));
|
|
169
169
|
iframes.forEach((w) => {
|
|
170
170
|
var _a, _b;
|
|
171
|
-
(_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(
|
|
171
|
+
(_b = ((_a = w.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("iframe")).contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(eventData, "*");
|
|
172
172
|
});
|
|
173
|
-
openOptions.onEvent(eventData.eventType, eventData);
|
|
173
|
+
openOptions.onEvent(eventData.eventType, eventData.data);
|
|
174
174
|
};
|
|
175
175
|
window.addEventListener("message", messageListener);
|
|
176
176
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lvble.js","sourceRoot":"","sources":["../../src/lib/lvble.ts"],"names":[],"m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