@memberstack/dom 1.9.0 → 1.9.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/lib/index.d.ts +1 -1
- package/lib/methods/dom/methods.d.ts +1 -2
- package/lib/methods/dom/methods.js +84 -44
- package/lib/methods/index.d.ts +1 -1
- package/lib/methods/index.js +1 -4
- package/lib/uis/main-dom.d.ts +12 -0
- package/lib/uis/main-dom.js +4655 -0
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,5 @@ export declare const load: (props: {
|
|
|
16
16
|
export declare const showMessage: (msg: any, isError: any) => void;
|
|
17
17
|
export declare const showLoader: (element?: any) => void;
|
|
18
18
|
export declare const hideLoader: (element?: any) => void;
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const openModal: (props: OpenModalParams & DOMConfig) => Promise<unknown>;
|
|
19
|
+
export declare const openModal: (props: OpenModalParams & DOMConfig) => Promise<HTMLIFrameElement>;
|
|
21
20
|
export declare const hideModal: () => void;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
20
12
|
};
|
|
21
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -54,12 +46,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
54
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
47
|
}
|
|
56
48
|
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
57
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
-
exports.hideModal = exports.openModal = exports.
|
|
66
|
+
exports.hideModal = exports.openModal = exports.hideLoader = exports.showLoader = exports.showMessage = exports.load = void 0;
|
|
59
67
|
var window_1 = require("../../constants/window");
|
|
60
68
|
var endpoint_1 = require("../../constants/endpoint");
|
|
69
|
+
var cookies_1 = require("../../utils/cookies");
|
|
70
|
+
var persistence_1 = require("../../auth/persistence");
|
|
61
71
|
var logger_1 = require("../../utils/logger");
|
|
62
|
-
var
|
|
72
|
+
var cookies_2 = require("../../utils/cookies");
|
|
63
73
|
var isBrowser = typeof window !== "undefined";
|
|
64
74
|
var isInitialized = function () {
|
|
65
75
|
if (!isBrowser)
|
|
@@ -174,35 +184,65 @@ var hideLoader = function (element) {
|
|
|
174
184
|
(_a = document.querySelector("[data-ms-loader]")) === null || _a === void 0 ? void 0 : _a.remove();
|
|
175
185
|
};
|
|
176
186
|
exports.hideLoader = hideLoader;
|
|
177
|
-
var handleRedirect = function (redirect, redirectOverride) {
|
|
178
|
-
if (redirectOverride)
|
|
179
|
-
return window.location.href = redirectOverride;
|
|
180
|
-
if (redirect && (window.location.pathname !== redirect))
|
|
181
|
-
return window.location.href = redirect;
|
|
182
|
-
};
|
|
183
|
-
exports.handleRedirect = handleRedirect;
|
|
184
187
|
var openModal = function (props) { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
var appId, page, token, link, div, iframe, iframestyles;
|
|
189
|
+
var _a, _b;
|
|
190
|
+
return __generator(this, function (_c) {
|
|
191
|
+
switch (_c.label) {
|
|
188
192
|
case 0:
|
|
189
193
|
(0, logger_1.log)("call openModal()");
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
resolveModal = resolve;
|
|
193
|
-
});
|
|
194
|
-
return [4 /*yield*/, Modal()];
|
|
194
|
+
(0, exports.showLoader)();
|
|
195
|
+
return [4 /*yield*/, getAppId(props.publicKey)];
|
|
195
196
|
case 1:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
appId = _c.sent();
|
|
198
|
+
page = TYPE_PARAMS[props.type];
|
|
199
|
+
if (props.type === "PROFILE") {
|
|
200
|
+
token = (0, cookies_2.getMemberCookie)();
|
|
201
|
+
}
|
|
202
|
+
link = createLink(__assign({ pk: props.publicKey, planId: (_a = props.params) === null || _a === void 0 ? void 0 : _a.planId, priceId: (_b = props.params) === null || _b === void 0 ? void 0 : _b.priceId, appId: appId, page: page }, (token ? { token: token } : {})));
|
|
203
|
+
div = document.createElement("div");
|
|
204
|
+
div.setAttribute("data-ms-iframe", "true");
|
|
205
|
+
div.style["position"] = "fixed";
|
|
206
|
+
div.style["top"] = "0";
|
|
207
|
+
div.style["left"] = "0";
|
|
208
|
+
div.style["zIndex"] = "10000000";
|
|
209
|
+
iframe = document.createElement("iframe");
|
|
210
|
+
iframestyles = {
|
|
211
|
+
height: "100vh",
|
|
212
|
+
width: "100vw",
|
|
213
|
+
position: "absolute",
|
|
214
|
+
top: 0,
|
|
215
|
+
bottom: 0,
|
|
216
|
+
border: "none",
|
|
217
|
+
zIndex: "2000000",
|
|
218
|
+
};
|
|
219
|
+
Object.entries(iframestyles).map(function (_a) {
|
|
220
|
+
var _b = __read(_a, 2), attr = _b[0], value = _b[1];
|
|
221
|
+
iframe.style[attr] = value;
|
|
222
|
+
});
|
|
223
|
+
iframe.setAttribute("src", link);
|
|
224
|
+
iframe.addEventListener("load", function () {
|
|
225
|
+
(0, exports.hideLoader)();
|
|
226
|
+
});
|
|
227
|
+
div.append(iframe);
|
|
228
|
+
document.body.appendChild(div);
|
|
229
|
+
window.addEventListener("message", function (e) {
|
|
230
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
231
|
+
if (e.data.type === "CLOSE") {
|
|
232
|
+
return (0, exports.hideModal)();
|
|
233
|
+
}
|
|
234
|
+
if ((_b = (_a = e.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.member) {
|
|
235
|
+
(0, persistence_1.setPersistedMember)((_c = e.data) === null || _c === void 0 ? void 0 : _c.data.member, props.persistence);
|
|
236
|
+
}
|
|
237
|
+
if (props.useCookie && ((_f = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.tokens) === null || _f === void 0 ? void 0 : _f.accessToken)) {
|
|
238
|
+
(0, cookies_1.setMemberCookie)(e.data.data.tokens.accessToken);
|
|
239
|
+
}
|
|
240
|
+
// added to prevent non memberstack messages being sent from window
|
|
241
|
+
if (e.origin === endpoint_1.endpoints.hostedUI && ((_g = e.data) === null || _g === void 0 ? void 0 : _g.data)) {
|
|
242
|
+
(_j = (_h = props.options) === null || _h === void 0 ? void 0 : _h.onCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, (_k = e.data) === null || _k === void 0 ? void 0 : _k.data);
|
|
203
243
|
}
|
|
204
244
|
});
|
|
205
|
-
return [2 /*return*/,
|
|
245
|
+
return [2 /*return*/, iframe];
|
|
206
246
|
}
|
|
207
247
|
});
|
|
208
248
|
}); };
|
|
@@ -210,7 +250,7 @@ exports.openModal = openModal;
|
|
|
210
250
|
var hideModal = function () {
|
|
211
251
|
var _a;
|
|
212
252
|
(0, logger_1.log)("call hideModal()");
|
|
213
|
-
(_a = document.querySelector("
|
|
253
|
+
(_a = document.querySelector("[data-ms-iframe]")) === null || _a === void 0 ? void 0 : _a.remove();
|
|
214
254
|
(0, exports.hideLoader)();
|
|
215
255
|
};
|
|
216
256
|
exports.hideModal = hideModal;
|
package/lib/methods/index.d.ts
CHANGED
package/lib/methods/index.js
CHANGED
|
@@ -72,9 +72,6 @@ function init(props) {
|
|
|
72
72
|
}
|
|
73
73
|
var client = (0, proxy_1.default)((0, client_1.initClient)(__assign(__assign({}, props), { onMemberToken: function (token) { return (0, interceptor_1.handleMemberToken)({ persistence: props.persistence, token: token }); } })), props);
|
|
74
74
|
var methods = DOMMethods(props);
|
|
75
|
-
|
|
76
|
-
//@ts-ignore
|
|
77
|
-
window.$memberstackDom = dom;
|
|
78
|
-
return dom;
|
|
75
|
+
return Object.assign(client, methods);
|
|
79
76
|
}
|
|
80
77
|
exports.default = { init: function (props) { return init(props); } };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Main as default };
|
|
2
|
+
declare class Main extends SvelteComponent {
|
|
3
|
+
constructor(options: any);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Base class for Svelte components. Used when dev=false.
|
|
7
|
+
*/
|
|
8
|
+
declare class SvelteComponent {
|
|
9
|
+
$destroy(): void;
|
|
10
|
+
$on(type: any, callback: any): () => void;
|
|
11
|
+
$set($$props: any): void;
|
|
12
|
+
}
|