@lvble/core 2.0.9 → 2.0.12

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/index.js ADDED
@@ -0,0 +1 @@
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})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lvble/core",
3
3
  "private": false,
4
- "version": "2.0.9",
4
+ "version": "2.0.12",
5
5
  "main": "./dist/@lvble/core.umd.js",
6
6
  "module": "./dist/@lvble/core.es.js",
7
7
  "types": "./dist/index.d.ts",
@@ -27,18 +27,9 @@
27
27
  "build:webpack" : "webpack --config webpack.config.js"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^17.0.2",
31
- "prop-types": "^15.7.2",
32
- "webpack-cli": "^4.7.2"
33
30
  },
34
31
  "devDependencies": {
35
- "@babel/core": "^7.14.6",
36
- "@babel/preset-env": "^7.14.7",
37
- "@babel/preset-react": "^7.14.5",
38
- "babel": "^6.23.0",
39
- "babel-loader": "^8.2.2",
40
- "webpack": "^5.44.0",
41
- "ts-loader": "^9.4.4"
32
+
42
33
  },
43
34
  "files": [
44
35
  "dist"
@@ -1,119 +0,0 @@
1
- var f = Object.defineProperty;
2
- var p = (e, o, t) => o in e ? f(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t;
3
- var l = (e, o, t) => (p(e, typeof o != "symbol" ? o + "" : o, t), t);
4
- var k = /* @__PURE__ */ ((e) => (e.Local = "local", e.Sandbox = "sandbox", e.Production = "production", e))(k || {});
5
- const h = {
6
- local: "http://localhost:3001",
7
- sandbox: "https://widget.sandbox.pms.nowlvble.com",
8
- production: "https://api.production.partners.nowlvble.com"
9
- }, d = {
10
- local: "http://localhost:3001",
11
- sandbox: "https://experience.sandbox.pms.nowlvble.com",
12
- production: "https://api.production.partners.nowlvble.com"
13
- };
14
- class y extends HTMLElement {
15
- constructor() {
16
- super();
17
- l(this, "_typeToEvent", {
18
- onboarding: "finishOnboarding",
19
- offboarding: "finishOffboarding",
20
- split: "finishSplit",
21
- repay: "finishRepay"
22
- /* FinishRepay */
23
- });
24
- l(this, "_iframe");
25
- this.attachShadow({ mode: "open" });
26
- }
27
- get mode() {
28
- return this.getAttribute("mode");
29
- }
30
- set mode(t) {
31
- t ? this.setAttribute("mode", t) : this.removeAttribute("mode");
32
- }
33
- get environment() {
34
- return this.getAttribute("environment");
35
- }
36
- set environment(t) {
37
- t ? this.setAttribute("environment", t) : this.removeAttribute("environment");
38
- }
39
- get token() {
40
- return this.getAttribute("token");
41
- }
42
- set token(t) {
43
- t ? this.setAttribute("token", t) : this.removeAttribute("token");
44
- }
45
- connectedCallback() {
46
- var r;
47
- const t = `${h[this.environment]}?token=${this.token}&environment=${this.environment}`, n = document.createElement("iframe");
48
- n.src = t, n.width = "100%", n.height = "100%", n.style.borderStyle = "solid", n.style.borderRadius = "10px", n.style.borderColor = "transparent", this._iframe = n, (r = this.shadowRoot) == null || r.appendChild(n);
49
- }
50
- disconnectedCallback() {
51
- this.shadowRoot && (this.shadowRoot.innerHTML = "");
52
- }
53
- }
54
- customElements.get("lvble-widget") ?? customElements.define("lvble-widget", y);
55
- const $ = {
56
- onboarding: customElements.get("lvble-widget"),
57
- repay: customElements.get("lvble-widget")
58
- }, E = (e) => ({
59
- /**
60
- * This function creates a widget that can be embedded in your website.
61
- *
62
- * @param createOptions The options for creating the widget. See CreateWidgetOptions for more information.
63
- * @returns The widget.
64
- */
65
- // TODO: Add support for no mode
66
- createWidget: (o) => {
67
- const t = o.mode ? new $[o.mode]() : new (customElements.get(
68
- "lvble-widget"
69
- ))();
70
- t.environment = e.environment, t.token = e.token, t.mode = o.mode;
71
- const n = (r) => {
72
- if (r.origin != h[e.environment]) {
73
- console.debug(
74
- `Received message from unknown origin: ${r.origin}`
75
- );
76
- return;
77
- }
78
- const s = r.data;
79
- o.onEvent(s.eventType, s);
80
- };
81
- return window.addEventListener("message", n), t;
82
- },
83
- /**
84
- * This function opens a popup with the relevant mode.
85
- * @param openOptions The options for opening the widget. See OpenOptions for more information.
86
- * @returns undefined.
87
- */
88
- open: (o) => {
89
- const t = {
90
- onboarding: `${d[e.environment]}?token=${e.token}`,
91
- offboarding: `${d[e.environment]}?token=${e.token}`,
92
- split: `${d[e.environment]}?token=${e.token}`,
93
- repay: `${d[e.environment]}?token=${e.token}`
94
- }, n = o.mode ? t[o.mode] : "", r = 450, s = 800, b = screen.width / 2 - r / 2, g = screen.height / 2 - s / 2;
95
- window.open(
96
- n,
97
- "LvblePopup",
98
- "width=" + r + ",height=" + s + ",location=no,left=" + b + ",top=" + g
99
- );
100
- const v = (i) => {
101
- if (i.origin != d[e.environment]) {
102
- console.debug(
103
- `Received message from unknown origin: ${i.origin}`
104
- );
105
- return;
106
- }
107
- const a = i.data, u = document.querySelectorAll("lvble-widget");
108
- i = JSON.parse(JSON.stringify(i)), u.forEach((w) => {
109
- var c, m;
110
- (m = ((c = w.shadowRoot) == null ? void 0 : c.querySelector("iframe")).contentWindow) == null || m.postMessage(i, "*");
111
- }), o.onEvent(a.eventType, a);
112
- };
113
- window.addEventListener("message", v);
114
- }
115
- }), A = E;
116
- export {
117
- k as Environment,
118
- A as Lvble
119
- };
@@ -1 +0,0 @@
1
- (function(o,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(o=typeof globalThis<"u"?globalThis:o||self,n(o["@lvble/core"]={}))})(this,function(o){"use strict";var $=Object.defineProperty;var x=(o,n,d)=>n in o?$(o,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):o[n]=d;var m=(o,n,d)=>(x(o,typeof n!="symbol"?n+"":n,d),d);var n=(e=>(e.Local="local",e.Sandbox="sandbox",e.Production="production",e))(n||{});const d={local:"http://localhost:3001",sandbox:"https://widget.sandbox.pms.nowlvble.com",production:"https://api.production.partners.nowlvble.com"},c={local:"http://localhost:3001",sandbox:"https://experience.sandbox.pms.nowlvble.com",production:"https://api.production.partners.nowlvble.com"};class v extends HTMLElement{constructor(){super();m(this,"_typeToEvent",{onboarding:"finishOnboarding",offboarding:"finishOffboarding",split:"finishSplit",repay:"finishRepay"});m(this,"_iframe");this.attachShadow({mode:"open"})}get mode(){return this.getAttribute("mode")}set mode(t){t?this.setAttribute("mode",t):this.removeAttribute("mode")}get environment(){return this.getAttribute("environment")}set environment(t){t?this.setAttribute("environment",t):this.removeAttribute("environment")}get token(){return this.getAttribute("token")}set token(t){t?this.setAttribute("token",t):this.removeAttribute("token")}connectedCallback(){var s;const t=`${d[this.environment]}?token=${this.token}&environment=${this.environment}`,r=document.createElement("iframe");r.src=t,r.width="100%",r.height="100%",r.style.borderStyle="solid",r.style.borderRadius="10px",r.style.borderColor="transparent",this._iframe=r,(s=this.shadowRoot)==null||s.appendChild(r)}disconnectedCallback(){this.shadowRoot&&(this.shadowRoot.innerHTML="")}}customElements.get("lvble-widget")??customElements.define("lvble-widget",v);const g={onboarding:customElements.get("lvble-widget"),repay:customElements.get("lvble-widget")},f=e=>({createWidget:i=>{const t=i.mode?new g[i.mode]:new(customElements.get("lvble-widget"));t.environment=e.environment,t.token=e.token,t.mode=i.mode;const r=s=>{if(s.origin!=d[e.environment]){console.debug(`Received message from unknown origin: ${s.origin}`);return}const a=s.data;i.onEvent(a.eventType,a)};return window.addEventListener("message",r),t},open:i=>{const t={onboarding:`${c[e.environment]}?token=${e.token}`,offboarding:`${c[e.environment]}?token=${e.token}`,split:`${c[e.environment]}?token=${e.token}`,repay:`${c[e.environment]}?token=${e.token}`},r=i.mode?t[i.mode]:"",s=450,a=800,p=screen.width/2-s/2,w=screen.height/2-a/2;window.open(r,"LvblePopup","width="+s+",height="+a+",location=no,left="+p+",top="+w);const k=l=>{if(l.origin!=c[e.environment]){console.debug(`Received message from unknown origin: ${l.origin}`);return}const h=l.data,y=document.querySelectorAll("lvble-widget");l=JSON.parse(JSON.stringify(l)),y.forEach(E=>{var b,u;(u=((b=E.shadowRoot)==null?void 0:b.querySelector("iframe")).contentWindow)==null||u.postMessage(l,"*")}),i.onEvent(h.eventType,h)};window.addEventListener("message",k)}});o.Environment=n,o.Lvble=f,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './lib/index'
@@ -1,2 +0,0 @@
1
- export * from './lvble';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -1,93 +0,0 @@
1
- export declare enum Environment {
2
- Local = "local",
3
- Sandbox = "sandbox",
4
- Production = "production"
5
- }
6
- export declare type Mode = "onboarding" | "offboarding" | "split" | "repay";
7
- export declare type ErrorData = {
8
- type: "error";
9
- reason: string;
10
- };
11
- export declare type OnboardingData = ErrorData | {
12
- type: "success";
13
- status: string;
14
- };
15
- export declare type SplitData = ErrorData | {
16
- type: "success";
17
- external_id: string;
18
- settlement_id: string;
19
- amount: number;
20
- };
21
- export declare type CloseData = ErrorData | {
22
- type: "close";
23
- };
24
- export declare 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 declare 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
@@ -1 +0,0 @@
1
- {"version":3,"file":"lvble.d.ts","sourceRoot":"","sources":["lvble.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAaD,oBAAY,IAAI,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AACpE,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,oBAAY,cAAc,GACtB,SAAS,GACT;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACN,oBAAY,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,oBAAY,SAAS,GACjB,SAAS,GACT;IACE,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEN,oBAAY,SAAS,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/D,aAAK,SAAS;IACZ,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;CAC5B;AASD,MAAM,WAAW,WAAW;IAE1B,WAAW,EAAE,WAAW,CAAC;IAEzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAE1B,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC;IAE7C,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CACjD;AAED,cAAM,WAAY,SAAQ,WAAW;IACnC,YAAY;;;;;MAKV;IACF,OAAO,CAAC,EAAE,iBAAiB,CAAC;;IAO5B,IAAI,IAAI,IAAI,IAAI,CAEf;IAED,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS,EAM7B;IAED,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED,IAAI,WAAW,CAAC,GAAG,EAJA,WAIA,EAMlB;IAED,IAAI,KAAK,IAIM,MAAM,CAFpB;IAED,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EAMpB;IAED,iBAAiB;IAiBjB,oBAAoB;CAGrB;AAeD,QAAA,MAAM,KAAK,gBAAiB,WAAW;IAEnC;;;;;OAKG;kCAE2B,mBAAmB;IA0BjD;;;;OAIG;wBACiB,WAAW;CAsDlC,CAAC;AAEF,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AAEjD,eAAO,MAAM,KAAK,gBAlGU,WAAW;IAEnC;;;;;OAKG;kCAE2B,mBAAmB;IA0BjD;;;;OAIG;wBACiB,WAAW;CA0DT,CAAC"}
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />