@meshconnect/web-link-sdk 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Link.d.ts +2 -2
- package/Link.js +145 -144
- package/README.md +127 -127
- package/cjs/Link.js +149 -148
- package/cjs/index.js +21 -21
- package/cjs/utils/event-types.js +31 -19
- package/cjs/utils/popup.js +39 -39
- package/cjs/utils/style.js +18 -18
- package/cjs/utils/types.js +2 -2
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/package.json +2 -2
- package/utils/event-types.d.ts +152 -68
- package/utils/event-types.js +27 -15
- package/utils/popup.d.ts +3 -3
- package/utils/popup.js +34 -34
- package/utils/style.d.ts +3 -3
- package/utils/style.js +13 -13
- package/utils/types.d.ts +108 -108
- package/utils/types.js +1 -1
package/cjs/Link.js
CHANGED
@@ -1,148 +1,149 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
-
function step(op) {
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
-
switch (op[0]) {
|
21
|
-
case 0: case 1: t = op; break;
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
-
default:
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
-
if (t[2]) _.ops.pop();
|
31
|
-
_.trys.pop(); continue;
|
32
|
-
}
|
33
|
-
op = body.call(thisArg, _);
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
-
}
|
37
|
-
};
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
exports.createLink = void 0;
|
40
|
-
var popup_1 = require("./utils/popup");
|
41
|
-
var event_types_1 = require("./utils/event-types");
|
42
|
-
var currentOptions;
|
43
|
-
var iframeUrlObject;
|
44
|
-
var iframeElement = function () {
|
45
|
-
return document.getElementById(popup_1.iframeId);
|
46
|
-
};
|
47
|
-
function eventsListener(event) {
|
48
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
49
|
-
switch (event.data.type) {
|
50
|
-
case 'brokerageAccountAccessToken': {
|
51
|
-
var payload = {
|
52
|
-
accessToken: event.data.payload
|
53
|
-
};
|
54
|
-
(_a = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _a === void 0 ? void 0 : _a.call(currentOptions, {
|
55
|
-
type: 'integrationConnected',
|
56
|
-
payload: payload
|
57
|
-
});
|
58
|
-
(_b = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _b === void 0 ? void 0 : _b.call(currentOptions, payload);
|
59
|
-
break;
|
60
|
-
}
|
61
|
-
case 'delayedAuthentication': {
|
62
|
-
var payload = {
|
63
|
-
delayedAuth: event.data.payload
|
64
|
-
};
|
65
|
-
(_c = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _c === void 0 ? void 0 : _c.call(currentOptions, {
|
66
|
-
type: 'integrationConnected',
|
67
|
-
payload: payload
|
68
|
-
});
|
69
|
-
(_d = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _d === void 0 ? void 0 : _d.call(currentOptions, payload);
|
70
|
-
break;
|
71
|
-
}
|
72
|
-
case 'transferFinished': {
|
73
|
-
var payload = event.data.payload;
|
74
|
-
(_e = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _e === void 0 ? void 0 : _e.call(currentOptions, {
|
75
|
-
type: 'transferCompleted',
|
76
|
-
payload: payload
|
77
|
-
});
|
78
|
-
(_f = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onTransferFinished) === null || _f === void 0 ? void 0 : _f.call(currentOptions, payload);
|
79
|
-
break;
|
80
|
-
}
|
81
|
-
case 'close':
|
82
|
-
case 'done': {
|
83
|
-
(_g =
|
84
|
-
(0
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
var
|
91
|
-
var
|
92
|
-
var
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
}
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
var
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
(
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
(
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
};
|
148
|
-
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
exports.createLink = void 0;
|
40
|
+
var popup_1 = require("./utils/popup");
|
41
|
+
var event_types_1 = require("./utils/event-types");
|
42
|
+
var currentOptions;
|
43
|
+
var iframeUrlObject;
|
44
|
+
var iframeElement = function () {
|
45
|
+
return document.getElementById(popup_1.iframeId);
|
46
|
+
};
|
47
|
+
function eventsListener(event) {
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
49
|
+
switch (event.data.type) {
|
50
|
+
case 'brokerageAccountAccessToken': {
|
51
|
+
var payload = {
|
52
|
+
accessToken: event.data.payload
|
53
|
+
};
|
54
|
+
(_a = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _a === void 0 ? void 0 : _a.call(currentOptions, {
|
55
|
+
type: 'integrationConnected',
|
56
|
+
payload: payload
|
57
|
+
});
|
58
|
+
(_b = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _b === void 0 ? void 0 : _b.call(currentOptions, payload);
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
case 'delayedAuthentication': {
|
62
|
+
var payload = {
|
63
|
+
delayedAuth: event.data.payload
|
64
|
+
};
|
65
|
+
(_c = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _c === void 0 ? void 0 : _c.call(currentOptions, {
|
66
|
+
type: 'integrationConnected',
|
67
|
+
payload: payload
|
68
|
+
});
|
69
|
+
(_d = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onIntegrationConnected) === null || _d === void 0 ? void 0 : _d.call(currentOptions, payload);
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
case 'transferFinished': {
|
73
|
+
var payload = event.data.payload;
|
74
|
+
(_e = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _e === void 0 ? void 0 : _e.call(currentOptions, {
|
75
|
+
type: 'transferCompleted',
|
76
|
+
payload: payload
|
77
|
+
});
|
78
|
+
(_f = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onTransferFinished) === null || _f === void 0 ? void 0 : _f.call(currentOptions, payload);
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
case 'close':
|
82
|
+
case 'done': {
|
83
|
+
var payload = (_g = event.data) === null || _g === void 0 ? void 0 : _g.payload;
|
84
|
+
(_h = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onExit) === null || _h === void 0 ? void 0 : _h.call(currentOptions, payload.errorMessage, payload);
|
85
|
+
(0, popup_1.removePopup)();
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
case 'oauthLinkOpen': {
|
89
|
+
if (event.data.link) {
|
90
|
+
var w = 700;
|
91
|
+
var h = 800;
|
92
|
+
var left = screen.width / 2 - w / 2;
|
93
|
+
var top_1 = screen.height / 2 - h / 2;
|
94
|
+
(_j = window
|
95
|
+
.open(event.data.link, '_blank', "popup,noopener,noreferrer,resizable,scrollbars,width=".concat(w, ",height=").concat(h, ",top=").concat(top_1, ",left=").concat(left))) === null || _j === void 0 ? void 0 : _j.focus();
|
96
|
+
}
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
case 'loaded': {
|
100
|
+
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.accessTokens) {
|
101
|
+
(_k = iframeElement().contentWindow) === null || _k === void 0 ? void 0 : _k.postMessage({ type: 'frontAccessTokens', payload: currentOptions.accessTokens }, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
|
102
|
+
}
|
103
|
+
if (currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.transferDestinationTokens) {
|
104
|
+
(_l = iframeElement().contentWindow) === null || _l === void 0 ? void 0 : _l.postMessage({
|
105
|
+
type: 'frontTransferDestinationTokens',
|
106
|
+
payload: currentOptions.transferDestinationTokens
|
107
|
+
}, (iframeUrlObject === null || iframeUrlObject === void 0 ? void 0 : iframeUrlObject.origin) || 'https://web.meshconnect.com');
|
108
|
+
}
|
109
|
+
(_m = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _m === void 0 ? void 0 : _m.call(currentOptions, { type: 'pageLoaded' });
|
110
|
+
break;
|
111
|
+
}
|
112
|
+
default: {
|
113
|
+
if ((0, event_types_1.isLinkEventTypeKey)(event.data.type)) {
|
114
|
+
(_o = currentOptions === null || currentOptions === void 0 ? void 0 : currentOptions.onEvent) === null || _o === void 0 ? void 0 : _o.call(currentOptions, event.data);
|
115
|
+
}
|
116
|
+
break;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
var createLink = function (options) {
|
121
|
+
var openLink = function (linkToken) { return __awaiter(void 0, void 0, void 0, function () {
|
122
|
+
var linkUrl;
|
123
|
+
var _a;
|
124
|
+
return __generator(this, function (_b) {
|
125
|
+
if (!linkToken) {
|
126
|
+
(_a = options === null || options === void 0 ? void 0 : options.onExit) === null || _a === void 0 ? void 0 : _a.call(options, 'Invalid link token!');
|
127
|
+
return [2 /*return*/];
|
128
|
+
}
|
129
|
+
currentOptions = options;
|
130
|
+
linkUrl = window.atob(linkToken);
|
131
|
+
iframeUrlObject = new URL(linkUrl);
|
132
|
+
window.removeEventListener('message', eventsListener);
|
133
|
+
(0, popup_1.addPopup)(linkUrl);
|
134
|
+
window.addEventListener('message', eventsListener);
|
135
|
+
return [2 /*return*/];
|
136
|
+
});
|
137
|
+
}); };
|
138
|
+
var closeLink = function () {
|
139
|
+
var _a;
|
140
|
+
(0, popup_1.removePopup)();
|
141
|
+
window.removeEventListener('message', eventsListener);
|
142
|
+
(_a = options.onExit) === null || _a === void 0 ? void 0 : _a.call(options);
|
143
|
+
};
|
144
|
+
return {
|
145
|
+
openLink: openLink,
|
146
|
+
closeLink: closeLink
|
147
|
+
};
|
148
|
+
};
|
149
|
+
exports.createLink = createLink;
|
package/cjs/index.js
CHANGED
@@ -1,21 +1,21 @@
|
|
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
|
-
exports.createLink = void 0;
|
18
|
-
__exportStar(require("./utils/types"), exports);
|
19
|
-
__exportStar(require("./utils/event-types"), exports);
|
20
|
-
var Link_1 = require("./Link");
|
21
|
-
Object.defineProperty(exports, "createLink", { enumerable: true, get: function () { return Link_1.createLink; } });
|
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
|
+
exports.createLink = void 0;
|
18
|
+
__exportStar(require("./utils/types"), exports);
|
19
|
+
__exportStar(require("./utils/event-types"), exports);
|
20
|
+
var Link_1 = require("./Link");
|
21
|
+
Object.defineProperty(exports, "createLink", { enumerable: true, get: function () { return Link_1.createLink; } });
|
package/cjs/utils/event-types.js
CHANGED
@@ -1,19 +1,31 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isLinkEventTypeKey = void 0;
|
4
|
-
var LINK_EVENT_TYPE_KEYS = [
|
5
|
-
'integrationConnected',
|
6
|
-
'integrationConnectionError',
|
7
|
-
'
|
8
|
-
'
|
9
|
-
'
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isLinkEventTypeKey = void 0;
|
4
|
+
var LINK_EVENT_TYPE_KEYS = [
|
5
|
+
'integrationConnected',
|
6
|
+
'integrationConnectionError',
|
7
|
+
'integrationMfaRequired',
|
8
|
+
'integrationMfaEntered',
|
9
|
+
'integrationOAuthStarted',
|
10
|
+
'integrationAccountSelectionRequired',
|
11
|
+
'transferCompleted',
|
12
|
+
'integrationSelected',
|
13
|
+
'credentialsEntered',
|
14
|
+
'transferStarted',
|
15
|
+
'transferPreviewed',
|
16
|
+
'transferPreviewError',
|
17
|
+
'transferExecutionError',
|
18
|
+
'pageLoaded',
|
19
|
+
'transferAssetSelected',
|
20
|
+
'transferNetworkSelected',
|
21
|
+
'transferAmountEntered',
|
22
|
+
'transferMfaRequired',
|
23
|
+
'transferMfaEntered',
|
24
|
+
'transferKycRequired',
|
25
|
+
'done',
|
26
|
+
'close'
|
27
|
+
];
|
28
|
+
function isLinkEventTypeKey(key) {
|
29
|
+
return LINK_EVENT_TYPE_KEYS.includes(key);
|
30
|
+
}
|
31
|
+
exports.isLinkEventTypeKey = isLinkEventTypeKey;
|
package/cjs/utils/popup.js
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.addPopup = exports.removePopup = exports.iframeId = void 0;
|
4
|
-
var style_1 = require("./style");
|
5
|
-
var popupId = 'mesh-link-popup';
|
6
|
-
var backdropId = 'mesh-link-popup__backdrop';
|
7
|
-
var popupContentId = 'mesh-link-popup__popup-content';
|
8
|
-
var stylesId = 'mesh-link-popup__styles';
|
9
|
-
exports.iframeId = 'mesh-link-popup__iframe';
|
10
|
-
var getPopupHtml = function (link) { return "\n<div id=\"".concat(popupId, "\">\n <div id=\"").concat(backdropId, "\"></div>\n <div id=\"").concat(popupContentId, "\">\n <iframe id=\"").concat(exports.iframeId, "\" src=\"").concat(link, "\" allow=\"clipboard-read *; clipboard-write *\" />\n </div>\n</div>\n"); };
|
11
|
-
var getStyles = function (style) { return "\n<style id=\"".concat(stylesId, "\">\n body {\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n overflow: hidden;\n }\n\n #").concat(popupId, " {\n all: unset;\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n }\n\n #").concat(backdropId, " {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10000;\n background: black;\n opacity: ").concat((0, style_1.getNumber)(0.6, style === null || style === void 0 ? void 0 : style.io), ";\n }\n\n #").concat(popupContentId, " {\n position: absolute;\n height: 80%;\n max-height: 710px;\n min-height: 685px;\n margin: auto;\n z-index: 10001;\n width: 30%;\n max-width: 430px;\n min-width: 380px;\n display: flex;\n flex-direction: column;\n border-radius: ").concat((0, style_1.getNumber)(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n background: white;\n flex-grow: 1;\n }\n\n #").concat(popupContentId, " iframe {\n border: none;\n width: 100%;\n flex-grow: 1;\n border-radius: ").concat((0, style_1.getNumber)(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n }\n\n @media only screen and (max-width: 768px) {\n #").concat(popupContentId, " {\n height: 100vh;\n width: 100vw;\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n min-height: 100%;\n border-radius: 0px;\n }\n\n #").concat(popupContentId, " iframe {\n border-radius: 0px;\n }\n }\n\n @media only screen and (max-height: 710px) {\n #").concat(popupContentId, " {\n max-height: 100%;\n min-height: 100%;\n }\n }\n</style>\n"); };
|
12
|
-
function removePopup() {
|
13
|
-
var _a, _b;
|
14
|
-
var existingPopup = window.document.getElementById(popupId);
|
15
|
-
(_a = existingPopup === null || existingPopup === void 0 ? void 0 : existingPopup.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(existingPopup);
|
16
|
-
var existingStyles = window.document.getElementById(stylesId);
|
17
|
-
(_b = existingStyles === null || existingStyles === void 0 ? void 0 : existingStyles.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(existingStyles);
|
18
|
-
}
|
19
|
-
exports.removePopup = removePopup;
|
20
|
-
function addPopup(iframeLink) {
|
21
|
-
var style = (0, style_1.getLinkStyle)(iframeLink);
|
22
|
-
removePopup();
|
23
|
-
var popup = getPopupHtml(iframeLink);
|
24
|
-
var stylesElement = htmlToElement(getStyles(style));
|
25
|
-
if (stylesElement) {
|
26
|
-
window.document.head.appendChild(stylesElement);
|
27
|
-
}
|
28
|
-
var popupElement = htmlToElement(popup);
|
29
|
-
if (popupElement) {
|
30
|
-
window.document.body.appendChild(popupElement);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
exports.addPopup = addPopup;
|
34
|
-
function htmlToElement(html) {
|
35
|
-
var template = document.createElement('template');
|
36
|
-
html = html.trim();
|
37
|
-
template.innerHTML = html;
|
38
|
-
return template.content.firstChild;
|
39
|
-
}
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.addPopup = exports.removePopup = exports.iframeId = void 0;
|
4
|
+
var style_1 = require("./style");
|
5
|
+
var popupId = 'mesh-link-popup';
|
6
|
+
var backdropId = 'mesh-link-popup__backdrop';
|
7
|
+
var popupContentId = 'mesh-link-popup__popup-content';
|
8
|
+
var stylesId = 'mesh-link-popup__styles';
|
9
|
+
exports.iframeId = 'mesh-link-popup__iframe';
|
10
|
+
var getPopupHtml = function (link) { return "\n<div id=\"".concat(popupId, "\">\n <div id=\"").concat(backdropId, "\"></div>\n <div id=\"").concat(popupContentId, "\">\n <iframe id=\"").concat(exports.iframeId, "\" src=\"").concat(link, "\" allow=\"clipboard-read *; clipboard-write *\" />\n </div>\n</div>\n"); };
|
11
|
+
var getStyles = function (style) { return "\n<style id=\"".concat(stylesId, "\">\n body {\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n overflow: hidden;\n }\n\n #").concat(popupId, " {\n all: unset;\n position: fixed;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 10000;\n }\n\n #").concat(backdropId, " {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10000;\n background: black;\n opacity: ").concat((0, style_1.getNumber)(0.6, style === null || style === void 0 ? void 0 : style.io), ";\n }\n\n #").concat(popupContentId, " {\n position: absolute;\n height: 80%;\n max-height: 710px;\n min-height: 685px;\n margin: auto;\n z-index: 10001;\n width: 30%;\n max-width: 430px;\n min-width: 380px;\n display: flex;\n flex-direction: column;\n border-radius: ").concat((0, style_1.getNumber)(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n background: white;\n flex-grow: 1;\n }\n\n #").concat(popupContentId, " iframe {\n border: none;\n width: 100%;\n flex-grow: 1;\n border-radius: ").concat((0, style_1.getNumber)(24, style === null || style === void 0 ? void 0 : style.ir), "px;\n }\n\n @media only screen and (max-width: 768px) {\n #").concat(popupContentId, " {\n height: 100vh;\n width: 100vw;\n max-width: 100%;\n min-width: 100%;\n max-height: 100%;\n min-height: 100%;\n border-radius: 0px;\n }\n\n #").concat(popupContentId, " iframe {\n border-radius: 0px;\n }\n }\n\n @media only screen and (max-height: 710px) {\n #").concat(popupContentId, " {\n max-height: 100%;\n min-height: 100%;\n }\n }\n</style>\n"); };
|
12
|
+
function removePopup() {
|
13
|
+
var _a, _b;
|
14
|
+
var existingPopup = window.document.getElementById(popupId);
|
15
|
+
(_a = existingPopup === null || existingPopup === void 0 ? void 0 : existingPopup.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(existingPopup);
|
16
|
+
var existingStyles = window.document.getElementById(stylesId);
|
17
|
+
(_b = existingStyles === null || existingStyles === void 0 ? void 0 : existingStyles.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(existingStyles);
|
18
|
+
}
|
19
|
+
exports.removePopup = removePopup;
|
20
|
+
function addPopup(iframeLink) {
|
21
|
+
var style = (0, style_1.getLinkStyle)(iframeLink);
|
22
|
+
removePopup();
|
23
|
+
var popup = getPopupHtml(iframeLink);
|
24
|
+
var stylesElement = htmlToElement(getStyles(style));
|
25
|
+
if (stylesElement) {
|
26
|
+
window.document.head.appendChild(stylesElement);
|
27
|
+
}
|
28
|
+
var popupElement = htmlToElement(popup);
|
29
|
+
if (popupElement) {
|
30
|
+
window.document.body.appendChild(popupElement);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
exports.addPopup = addPopup;
|
34
|
+
function htmlToElement(html) {
|
35
|
+
var template = document.createElement('template');
|
36
|
+
html = html.trim();
|
37
|
+
template.innerHTML = html;
|
38
|
+
return template.content.firstChild;
|
39
|
+
}
|
package/cjs/utils/style.js
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getNumber = exports.getLinkStyle = void 0;
|
4
|
-
function getLinkStyle(url) {
|
5
|
-
try {
|
6
|
-
var params = new URLSearchParams(new URL(url).search);
|
7
|
-
var style = params.get('link_style');
|
8
|
-
return style && JSON.parse(window.atob(style));
|
9
|
-
}
|
10
|
-
catch (e) {
|
11
|
-
return undefined;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
exports.getLinkStyle = getLinkStyle;
|
15
|
-
function getNumber(def, value) {
|
16
|
-
return value !== undefined ? value : def;
|
17
|
-
}
|
18
|
-
exports.getNumber = getNumber;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getNumber = exports.getLinkStyle = void 0;
|
4
|
+
function getLinkStyle(url) {
|
5
|
+
try {
|
6
|
+
var params = new URLSearchParams(new URL(url).search);
|
7
|
+
var style = params.get('link_style');
|
8
|
+
return style && JSON.parse(window.atob(style));
|
9
|
+
}
|
10
|
+
catch (e) {
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.getLinkStyle = getLinkStyle;
|
15
|
+
function getNumber(def, value) {
|
16
|
+
return value !== undefined ? value : def;
|
17
|
+
}
|
18
|
+
exports.getNumber = getNumber;
|
package/cjs/utils/types.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from './utils/types';
|
2
|
-
export * from './utils/event-types';
|
3
|
-
export { createLink } from './Link';
|
1
|
+
export * from './utils/types';
|
2
|
+
export * from './utils/event-types';
|
3
|
+
export { createLink } from './Link';
|
package/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from './utils/types';
|
2
|
-
export * from './utils/event-types';
|
3
|
-
export { createLink } from './Link';
|
1
|
+
export * from './utils/types';
|
2
|
+
export * from './utils/event-types';
|
3
|
+
export { createLink } from './Link';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@meshconnect/web-link-sdk",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.1",
|
4
4
|
"description": "A client-side JS library for integrating with Mesh Connect",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "https://github.com/FrontFin/mesh-web-sdk.git",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"jest-environment-jsdom": "^29.6.4"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"@meshconnect/node-api": "^2.0.
|
23
|
+
"@meshconnect/node-api": "^2.0.1"
|
24
24
|
},
|
25
25
|
"jest": {
|
26
26
|
"preset": "ts-jest",
|