1 | !function(root, factory) {
|
2 | "object" == typeof exports && "object" == typeof module ? module.exports = factory() : "function" == typeof define && define.amd ? define("zoid", [], factory) : "object" == typeof exports ? exports.zoid = factory() : root.zoid = factory();
|
3 | }("undefined" != typeof self ? self : this, function() {
|
4 | return function(modules) {
|
5 | var installedModules = {};
|
6 | function __webpack_require__(moduleId) {
|
7 | if (installedModules[moduleId]) return installedModules[moduleId].exports;
|
8 | var module = installedModules[moduleId] = {
|
9 | i: moduleId,
|
10 | l: !1,
|
11 | exports: {}
|
12 | };
|
13 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
14 | module.l = !0;
|
15 | return module.exports;
|
16 | }
|
17 | __webpack_require__.m = modules;
|
18 | __webpack_require__.c = installedModules;
|
19 | __webpack_require__.d = function(exports, name, getter) {
|
20 | __webpack_require__.o(exports, name) || Object.defineProperty(exports, name, {
|
21 | configurable: !1,
|
22 | enumerable: !0,
|
23 | get: getter
|
24 | });
|
25 | };
|
26 | __webpack_require__.n = function(module) {
|
27 | var getter = module && module.__esModule ? function() {
|
28 | return module.default;
|
29 | } : function() {
|
30 | return module;
|
31 | };
|
32 | __webpack_require__.d(getter, "a", getter);
|
33 | return getter;
|
34 | };
|
35 | __webpack_require__.o = function(object, property) {
|
36 | return Object.prototype.hasOwnProperty.call(object, property);
|
37 | };
|
38 | __webpack_require__.p = "";
|
39 | return __webpack_require__(__webpack_require__.s = "./src/index.js");
|
40 | }({
|
41 | "./node_modules/belter/src/css.js": function(module, __webpack_exports__, __webpack_require__) {
|
42 | "use strict";
|
43 | __webpack_exports__.a = isPerc;
|
44 | __webpack_exports__.b = isPx;
|
45 | __webpack_exports__.d = function(val) {
|
46 | return "number" == typeof val ? toPx(val) : isPerc(val) ? val : toPx(val);
|
47 | };
|
48 | __webpack_exports__.c = function(dim, max) {
|
49 | if ("number" == typeof dim) return dim;
|
50 | if (isPerc(dim)) return parseInt(max * toNum(dim) / 100, 10);
|
51 | if (isPx(dim)) return toNum(dim);
|
52 | throw new Error("Can not normalize dimension: " + dim);
|
53 | };
|
54 | function isPerc(str) {
|
55 | return "string" == typeof str && /^[0-9]+%$/.test(str);
|
56 | }
|
57 | function isPx(str) {
|
58 | return "string" == typeof str && /^[0-9]+px$/.test(str);
|
59 | }
|
60 | function toNum(val) {
|
61 | if ("number" == typeof val) return val;
|
62 | var match = val.match(/^([0-9]+)(px|%)$/);
|
63 | if (!match) throw new Error("Could not match css value from " + val);
|
64 | return parseInt(match[1], 10);
|
65 | }
|
66 | function toPx(val) {
|
67 | return toNum(val) + "px";
|
68 | }
|
69 | },
|
70 | "./node_modules/belter/src/decorators.js": function(module, __webpack_exports__, __webpack_require__) {
|
71 | "use strict";
|
72 | __webpack_exports__.a = function(target, name, descriptor) {
|
73 | descriptor.value = Object(__WEBPACK_IMPORTED_MODULE_0__util__.n)(descriptor.value, {
|
74 | name: name,
|
75 | thisNamespace: !0
|
76 | });
|
77 | };
|
78 | var __WEBPACK_IMPORTED_MODULE_0__util__ = __webpack_require__("./node_modules/belter/src/util.js");
|
79 | },
|
80 | "./node_modules/belter/src/device.js": function(module, __webpack_exports__, __webpack_require__) {
|
81 | "use strict";
|
82 | __webpack_exports__.a = function() {
|
83 | return !!(window.navigator.mockUserAgent || window.navigator.userAgent).match(/Android|webOS|iPhone|iPad|iPod|bada|Symbian|Palm|CriOS|BlackBerry|IEMobile|WindowsMobile|Opera Mini/i);
|
84 | };
|
85 | },
|
86 | "./node_modules/belter/src/dom.js": function(module, __webpack_exports__, __webpack_require__) {
|
87 | "use strict";
|
88 | var src = __webpack_require__("./node_modules/zalgo-promise/src/index.js"), cross_domain_utils_src = __webpack_require__("./node_modules/cross-domain-utils/src/index.js"), cross_domain_safe_weakmap_src = __webpack_require__("./node_modules/cross-domain-safe-weakmap/src/index.js"), util = __webpack_require__("./node_modules/belter/src/util.js");
|
89 | __webpack_require__("./node_modules/belter/src/device.js");
|
90 | __webpack_exports__.t = function() {
|
91 | return waitForDocumentReady().then(function() {
|
92 | if (document.body) return document.body;
|
93 | throw new Error("Document ready but document.body not present");
|
94 | });
|
95 | };
|
96 | __webpack_exports__.j = function(url) {
|
97 | var originalHash, options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, query = options.query || {}, hash = options.hash || {}, originalUrl = void 0, _url$split = url.split("#");
|
98 | originalUrl = _url$split[0];
|
99 | originalHash = _url$split[1];
|
100 | var _originalUrl$split = originalUrl.split("?");
|
101 | originalUrl = _originalUrl$split[0];
|
102 | var queryString = extendQuery(_originalUrl$split[1], query), hashString = extendQuery(originalHash, hash);
|
103 | queryString && (originalUrl = originalUrl + "?" + queryString);
|
104 | hashString && (originalUrl = originalUrl + "#" + hashString);
|
105 | return originalUrl;
|
106 | };
|
107 | __webpack_exports__.n = function isLocalStorageEnabled() {
|
108 | return Object(util.k)(isLocalStorageEnabled, function() {
|
109 | try {
|
110 | if ("undefined" == typeof window) return !1;
|
111 | if (window.localStorage) {
|
112 | var value = Math.random().toString();
|
113 | window.localStorage.setItem("__test__localStorage__", value);
|
114 | var result = window.localStorage.getItem("__test__localStorage__");
|
115 | window.localStorage.removeItem("__test__localStorage__");
|
116 | if (value === result) return !0;
|
117 | }
|
118 | } catch (err) {}
|
119 | return !1;
|
120 | });
|
121 | };
|
122 | __webpack_exports__.e = appendChild;
|
123 | __webpack_exports__.k = getElement;
|
124 | __webpack_exports__.i = function(id) {
|
125 | return new src.a(function(resolve, reject) {
|
126 | var name = Object(util.u)(id), el = getElementSafe(id);
|
127 | if (el) return resolve(el);
|
128 | if (isDocumentReady()) return reject(new Error("Document is ready and element " + name + " does not exist"));
|
129 | var interval = setInterval(function() {
|
130 | if (el = getElementSafe(id)) {
|
131 | clearInterval(interval);
|
132 | return resolve(el);
|
133 | }
|
134 | if (isDocumentReady()) {
|
135 | clearInterval(interval);
|
136 | return reject(new Error("Document is ready and element " + name + " does not exist"));
|
137 | }
|
138 | }, 10);
|
139 | });
|
140 | };
|
141 | __webpack_exports__.a = PopupOpenError;
|
142 | __webpack_exports__.p = function(url, options) {
|
143 | var _options = options = options || {}, width = _options.width, height = _options.height, top = 0, left = 0;
|
144 | width && (window.outerWidth ? left = Math.round((window.outerWidth - width) / 2) + window.screenX : window.screen.width && (left = Math.round((window.screen.width - width) / 2)));
|
145 | height && (window.outerHeight ? top = Math.round((window.outerHeight - height) / 2) + window.screenY : window.screen.height && (top = Math.round((window.screen.height - height) / 2)));
|
146 | var name = (options = _extends({
|
147 | top: top,
|
148 | left: left,
|
149 | width: width,
|
150 | height: height,
|
151 | status: 1,
|
152 | toolbar: 0,
|
153 | menubar: 0,
|
154 | resizable: 1,
|
155 | scrollbars: 1
|
156 | }, options)).name || "";
|
157 | delete options.name;
|
158 | var params = Object.keys(options).map(function(key) {
|
159 | if (options[key]) return key + "=" + Object(util.u)(options[key]);
|
160 | }).filter(Boolean).join(","), win = void 0;
|
161 | try {
|
162 | win = window.open(url, name, params, !0);
|
163 | } catch (err) {
|
164 | throw new PopupOpenError("Can not open popup window - " + (err.stack || err.message));
|
165 | }
|
166 | if (Object(cross_domain_utils_src.isWindowClosed)(win)) {
|
167 | var err;
|
168 | throw new PopupOpenError("Can not open popup window - blocked");
|
169 | }
|
170 | return win;
|
171 | };
|
172 | __webpack_exports__.v = function(win, el) {
|
173 | var tag = el.tagName.toLowerCase();
|
174 | if ("html" !== tag) throw new Error("Expected element to be html, got " + tag);
|
175 | for (var documentElement = win.document.documentElement; documentElement.children && documentElement.children.length; ) documentElement.removeChild(documentElement.children[0]);
|
176 | for (;el.children.length; ) documentElement.appendChild(el.children[0]);
|
177 | };
|
178 | __webpack_exports__.f = awaitFrameLoad;
|
179 | __webpack_exports__.g = function(frame) {
|
180 | return frame.contentWindow ? src.a.resolve(frame.contentWindow) : awaitFrameLoad(frame).then(function(loadedFrame) {
|
181 | if (!loadedFrame.contentWindow) throw new Error("Could not find window in iframe");
|
182 | return loadedFrame.contentWindow;
|
183 | });
|
184 | };
|
185 | __webpack_exports__.m = function iframe() {
|
186 | var options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, container = arguments[1], attempts = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 3, el = getElement(container), attributes = options.attributes || {}, style = options.style || {}, frame = function() {
|
187 | var tag = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "div", options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, container = arguments[2];
|
188 | tag = tag.toLowerCase();
|
189 | var element = document.createElement(tag);
|
190 | options.style && Object(util.h)(element.style, options.style);
|
191 | options.class && (element.className = options.class.join(" "));
|
192 | if (options.attributes) for (var _i6 = 0, _Object$keys2 = Object.keys(options.attributes), _length6 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i6 < _length6; _i6++) {
|
193 | var key = _Object$keys2[_i6];
|
194 | element.setAttribute(key, options.attributes[key]);
|
195 | }
|
196 | options.styleSheet && function(el, styleText) {
|
197 | var doc = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : window.document;
|
198 | el.styleSheet ? el.styleSheet.cssText = styleText : el.appendChild(doc.createTextNode(styleText));
|
199 | }(element, options.styleSheet);
|
200 | container && appendChild(container, element);
|
201 | if (options.html) if ("iframe" === tag) {
|
202 | if (!container || !element.contentWindow) throw new Error("Iframe html can not be written unless container provided and iframe in DOM");
|
203 | !function(win, html) {
|
204 | try {
|
205 | win.document.open();
|
206 | win.document.write(html);
|
207 | win.document.close();
|
208 | } catch (err) {
|
209 | try {
|
210 | win.location = "javascript: document.open(); document.write(" + JSON.stringify(html) + "); document.close();";
|
211 | } catch (err2) {}
|
212 | }
|
213 | }(element.contentWindow, options.html);
|
214 | } else element.innerHTML = options.html;
|
215 | return element;
|
216 | }("iframe", {
|
217 | attributes: _extends({
|
218 | frameBorder: "0",
|
219 | allowTransparency: "true"
|
220 | }, attributes),
|
221 | style: _extends({
|
222 | backgroundColor: "transparent"
|
223 | }, style),
|
224 | html: options.html,
|
225 | class: options.class
|
226 | });
|
227 | awaitFrameLoad(frame);
|
228 | el.appendChild(frame);
|
229 | var win = frame.contentWindow;
|
230 | if (win) try {
|
231 | Object(util.p)(win.name);
|
232 | } catch (err) {
|
233 | el.removeChild(frame);
|
234 | if (!attempts) throw new Error("Frame is cross-domain: " + err.stack);
|
235 | return iframe(options, container, attempts - 1);
|
236 | }
|
237 | (options.url || window.navigator.userAgent.match(/MSIE|Edge/i)) && frame.setAttribute("src", options.url || "about:blank");
|
238 | return frame;
|
239 | };
|
240 | __webpack_exports__.c = function(obj, event, handler) {
|
241 | obj.addEventListener(event, handler);
|
242 | return {
|
243 | cancel: function() {
|
244 | obj.removeEventListener(event, handler);
|
245 | }
|
246 | };
|
247 | };
|
248 | __webpack_exports__.s = showElement;
|
249 | __webpack_exports__.l = hideElement;
|
250 | __webpack_exports__.h = function(element) {
|
251 | element.parentNode && element.parentNode.removeChild(element);
|
252 | };
|
253 | __webpack_exports__.r = function(element, name, clean) {
|
254 | var animation = animate(element, name, clean);
|
255 | showElement(element);
|
256 | return animation;
|
257 | };
|
258 | __webpack_exports__.d = function(element, name, clean) {
|
259 | return animate(element, name, clean).then(function() {
|
260 | hideElement(element);
|
261 | });
|
262 | };
|
263 | __webpack_exports__.b = function(element, name) {
|
264 | element.classList ? element.classList.add(name) : -1 === element.className.split(/\s+/).indexOf(name) && (element.className += " " + name);
|
265 | };
|
266 | __webpack_exports__.q = function(element, name) {
|
267 | element.classList ? element.classList.remove(name) : -1 !== element.className.split(/\s+/).indexOf(name) && (element.className = element.className.replace(name, ""));
|
268 | };
|
269 | __webpack_exports__.u = function(element, handler) {
|
270 | handler = Object(util.q)(handler);
|
271 | var interval = void 0;
|
272 | isElementClosed(element) ? handler() : interval = Object(util.t)(function() {
|
273 | if (isElementClosed(element)) {
|
274 | interval.cancel();
|
275 | handler();
|
276 | }
|
277 | }, 50);
|
278 | return {
|
279 | cancel: function() {
|
280 | interval && interval.cancel();
|
281 | }
|
282 | };
|
283 | };
|
284 | __webpack_exports__.o = function(el, handler) {
|
285 | var _ref6 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, _ref6$width = _ref6.width, width = void 0 === _ref6$width || _ref6$width, _ref6$height = _ref6.height, height = void 0 === _ref6$height || _ref6$height, _ref6$interval = _ref6.interval, interval = void 0 === _ref6$interval ? 100 : _ref6$interval, _ref6$win = _ref6.win, win = void 0 === _ref6$win ? window : _ref6$win, currentWidth = el.offsetWidth, currentHeight = el.offsetHeight;
|
286 | handler({
|
287 | width: currentWidth,
|
288 | height: currentHeight
|
289 | });
|
290 | var check = function() {
|
291 | var newWidth = el.offsetWidth, newHeight = el.offsetHeight;
|
292 | (width && newWidth !== currentWidth || height && newHeight !== currentHeight) && handler({
|
293 | width: newWidth,
|
294 | height: newHeight
|
295 | });
|
296 | currentWidth = newWidth;
|
297 | currentHeight = newHeight;
|
298 | }, observer = void 0, timeout = void 0;
|
299 | if (void 0 !== win.ResizeObserver) (observer = new win.ResizeObserver(check)).observe(el); else if (void 0 !== win.MutationObserver) {
|
300 | (observer = new win.MutationObserver(check)).observe(el, {
|
301 | attributes: !0,
|
302 | childList: !0,
|
303 | subtree: !0,
|
304 | characterData: !1
|
305 | });
|
306 | win.addEventListener("resize", check);
|
307 | } else !function loop() {
|
308 | check();
|
309 | timeout = setTimeout(loop, interval);
|
310 | }();
|
311 | return {
|
312 | cancel: function() {
|
313 | observer.disconnect();
|
314 | window.removeEventListener("resize", check);
|
315 | clearTimeout(timeout);
|
316 | }
|
317 | };
|
318 | };
|
319 | var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
320 | return typeof obj;
|
321 | } : function(obj) {
|
322 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
323 | }, _extends = Object.assign || function(target) {
|
324 | for (var i = 1; i < arguments.length; i++) {
|
325 | var source = arguments[i];
|
326 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
327 | }
|
328 | return target;
|
329 | };
|
330 | function isDocumentReady() {
|
331 | return Boolean(document.body) && "complete" === document.readyState;
|
332 | }
|
333 | function urlEncode(str) {
|
334 | return str.replace(/\?/g, "%3F").replace(/&/g, "%26").replace(/#/g, "%23").replace(/\+/g, "%2B");
|
335 | }
|
336 | function waitForDocumentReady() {
|
337 | return Object(util.k)(waitForDocumentReady, function() {
|
338 | return new src.a(function(resolve) {
|
339 | if (isDocumentReady()) return resolve();
|
340 | var interval = setInterval(function() {
|
341 | if (isDocumentReady()) {
|
342 | clearInterval(interval);
|
343 | return resolve();
|
344 | }
|
345 | }, 10);
|
346 | });
|
347 | });
|
348 | }
|
349 | function parseQuery(queryString) {
|
350 | return Object(util.k)(parseQuery, function() {
|
351 | var params = {};
|
352 | if (!queryString) return params;
|
353 | if (-1 === queryString.indexOf("=")) return params;
|
354 | for (var _i2 = 0, _queryString$split2 = queryString.split("&"), _length2 = null == _queryString$split2 ? 0 : _queryString$split2.length; _i2 < _length2; _i2++) {
|
355 | var pair = _queryString$split2[_i2];
|
356 | (pair = pair.split("="))[0] && pair[1] && (params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]));
|
357 | }
|
358 | return params;
|
359 | }, [ queryString ]);
|
360 | }
|
361 | function extendQuery(originalQuery) {
|
362 | var props = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
363 | return props && Object.keys(props).length ? function() {
|
364 | var obj = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
365 | return Object.keys(obj).filter(function(key) {
|
366 | return "string" == typeof obj[key];
|
367 | }).map(function(key) {
|
368 | return urlEncode(key) + "=" + urlEncode(obj[key]);
|
369 | }).join("&");
|
370 | }(_extends({}, parseQuery(originalQuery), props)) : originalQuery;
|
371 | }
|
372 | function appendChild(container, child) {
|
373 | container.appendChild(child);
|
374 | }
|
375 | function getElementSafe(id) {
|
376 | var element, doc = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : document;
|
377 | return (element = id) instanceof window.Element || null !== element && "object" === (void 0 === element ? "undefined" : _typeof(element)) && 1 === element.nodeType && "object" === _typeof(element.style) && "object" === _typeof(element.ownerDocument) ? id : "string" == typeof id ? doc.querySelector(id) : void 0;
|
378 | }
|
379 | function getElement(id) {
|
380 | var element = getElementSafe(id, arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : document);
|
381 | if (element) return element;
|
382 | throw new Error("Can not find element: " + Object(util.u)(id));
|
383 | }
|
384 | function PopupOpenError(message) {
|
385 | this.message = message;
|
386 | }
|
387 | PopupOpenError.prototype = Object.create(Error.prototype);
|
388 | var awaitFrameLoadPromises = void 0;
|
389 | function awaitFrameLoad(frame) {
|
390 | if ((awaitFrameLoadPromises = awaitFrameLoadPromises || new cross_domain_safe_weakmap_src.a()).has(frame)) {
|
391 | var _promise = awaitFrameLoadPromises.get(frame);
|
392 | if (_promise) return _promise;
|
393 | }
|
394 | var promise = new src.a(function(resolve, reject) {
|
395 | frame.addEventListener("load", function() {
|
396 | Object(cross_domain_utils_src.linkFrameWindow)(frame);
|
397 | resolve(frame);
|
398 | });
|
399 | frame.addEventListener("error", function(err) {
|
400 | frame.contentWindow ? resolve(frame) : reject(err);
|
401 | });
|
402 | });
|
403 | awaitFrameLoadPromises.set(frame, promise);
|
404 | return promise;
|
405 | }
|
406 | function bindEvents(element, eventNames, handler) {
|
407 | handler = Object(util.q)(handler);
|
408 | for (var _i8 = 0, _length8 = null == eventNames ? 0 : eventNames.length; _i8 < _length8; _i8++) {
|
409 | var eventName = eventNames[_i8];
|
410 | element.addEventListener(eventName, handler);
|
411 | }
|
412 | return {
|
413 | cancel: Object(util.q)(function() {
|
414 | for (var _i10 = 0, _length10 = null == eventNames ? 0 : eventNames.length; _i10 < _length10; _i10++) {
|
415 | var _eventName = eventNames[_i10];
|
416 | element.removeEventListener(_eventName, handler);
|
417 | }
|
418 | })
|
419 | };
|
420 | }
|
421 | var VENDOR_PREFIXES = [ "webkit", "moz", "ms", "o" ];
|
422 | function setVendorCSS(element, name, value) {
|
423 | element.style[name] = value;
|
424 | for (var capitalizedName = Object(util.c)(name), _i12 = 0, _length12 = null == VENDOR_PREFIXES ? 0 : VENDOR_PREFIXES.length; _i12 < _length12; _i12++) {
|
425 | var prefix = VENDOR_PREFIXES[_i12];
|
426 | element.style["" + prefix + capitalizedName] = value;
|
427 | }
|
428 | }
|
429 | var ANIMATION_START_EVENTS = [ "animationstart", "webkitAnimationStart", "oAnimationStart", "MSAnimationStart" ], ANIMATION_END_EVENTS = [ "animationend", "webkitAnimationEnd", "oAnimationEnd", "MSAnimationEnd" ];
|
430 | function animate(element, name, clean) {
|
431 | var timeout = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 1e3;
|
432 | return new src.a(function(resolve, reject) {
|
433 | var el = getElement(element);
|
434 | if (!el || !function(element, name) {
|
435 | var CSSRule = window.CSSRule, KEYFRAMES_RULE = CSSRule.KEYFRAMES_RULE || CSSRule.WEBKIT_KEYFRAMES_RULE || CSSRule.MOZ_KEYFRAMES_RULE || CSSRule.O_KEYFRAMES_RULE || CSSRule.MS_KEYFRAMES_RULE, stylesheets = element.ownerDocument.styleSheets;
|
436 | try {
|
437 | for (var i = 0; i < stylesheets.length; i++) {
|
438 | var cssRules = stylesheets[i].cssRules;
|
439 | if (cssRules) for (var j = 0; j < cssRules.length; j++) {
|
440 | var cssRule = cssRules[j];
|
441 | if (cssRule && cssRule.type === KEYFRAMES_RULE && cssRule.name === name) return !0;
|
442 | }
|
443 | }
|
444 | } catch (err) {
|
445 | return !1;
|
446 | }
|
447 | return !1;
|
448 | }(el, name)) return resolve();
|
449 | var hasStarted = !1, startTimeout = void 0, endTimeout = void 0, startEvent = void 0, endEvent = void 0;
|
450 | function cleanUp() {
|
451 | setVendorCSS(el, "animationName", "");
|
452 | clearTimeout(startTimeout);
|
453 | clearTimeout(endTimeout);
|
454 | startEvent.cancel();
|
455 | endEvent.cancel();
|
456 | }
|
457 | startEvent = bindEvents(el, ANIMATION_START_EVENTS, function(event) {
|
458 | if (event.target === el && event.animationName === name) {
|
459 | clearTimeout(startTimeout);
|
460 | event.stopPropagation();
|
461 | startEvent.cancel();
|
462 | hasStarted = !0;
|
463 | endTimeout = setTimeout(function() {
|
464 | cleanUp();
|
465 | resolve();
|
466 | }, timeout);
|
467 | }
|
468 | });
|
469 | endEvent = bindEvents(el, ANIMATION_END_EVENTS, function(event) {
|
470 | if (event.target === el && event.animationName === name) {
|
471 | cleanUp();
|
472 | return "string" == typeof event.animationName && event.animationName !== name ? reject("Expected animation name to be " + name + ", found " + event.animationName) : resolve();
|
473 | }
|
474 | });
|
475 | setVendorCSS(el, "animationName", name);
|
476 | startTimeout = setTimeout(function() {
|
477 | if (!hasStarted) {
|
478 | cleanUp();
|
479 | return resolve();
|
480 | }
|
481 | }, 200);
|
482 | clean && clean(cleanUp);
|
483 | });
|
484 | }
|
485 | var STYLE = {
|
486 | DISPLAY: {
|
487 | NONE: "none",
|
488 | BLOCK: "block"
|
489 | },
|
490 | VISIBILITY: {
|
491 | VISIBLE: "visible",
|
492 | HIDDEN: "hidden"
|
493 | },
|
494 | IMPORTANT: "important"
|
495 | };
|
496 | function showElement(element) {
|
497 | element.style.setProperty("display", "");
|
498 | }
|
499 | function hideElement(element) {
|
500 | element.style.setProperty("display", STYLE.DISPLAY.NONE, STYLE.IMPORTANT);
|
501 | }
|
502 | function isElementClosed(el) {
|
503 | return !el || !el.parentNode;
|
504 | }
|
505 | },
|
506 | "./node_modules/belter/src/experiment.js": function(module, __webpack_exports__, __webpack_require__) {
|
507 | "use strict";
|
508 | __webpack_require__("./node_modules/belter/src/util.js"), __webpack_require__("./node_modules/belter/src/storage.js");
|
509 | },
|
510 | "./node_modules/belter/src/global.js": function(module, __webpack_exports__, __webpack_require__) {
|
511 | "use strict";
|
512 | __webpack_require__("./node_modules/belter/src/util.js");
|
513 | },
|
514 | "./node_modules/belter/src/http.js": function(module, __webpack_exports__, __webpack_require__) {
|
515 | "use strict";
|
516 | __webpack_require__("./node_modules/zalgo-promise/src/index.js"), __webpack_require__("./node_modules/cross-domain-utils/src/index.js");
|
517 | },
|
518 | "./node_modules/belter/src/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
519 | "use strict";
|
520 | __webpack_require__("./node_modules/belter/src/device.js");
|
521 | var __WEBPACK_IMPORTED_MODULE_1__dom__ = __webpack_require__("./node_modules/belter/src/dom.js");
|
522 | __webpack_require__.d(__webpack_exports__, "PopupOpenError", function() {
|
523 | return __WEBPACK_IMPORTED_MODULE_1__dom__.a;
|
524 | });
|
525 | __webpack_require__.d(__webpack_exports__, "addClass", function() {
|
526 | return __WEBPACK_IMPORTED_MODULE_1__dom__.b;
|
527 | });
|
528 | __webpack_require__.d(__webpack_exports__, "addEventListener", function() {
|
529 | return __WEBPACK_IMPORTED_MODULE_1__dom__.c;
|
530 | });
|
531 | __webpack_require__.d(__webpack_exports__, "animateAndHide", function() {
|
532 | return __WEBPACK_IMPORTED_MODULE_1__dom__.d;
|
533 | });
|
534 | __webpack_require__.d(__webpack_exports__, "appendChild", function() {
|
535 | return __WEBPACK_IMPORTED_MODULE_1__dom__.e;
|
536 | });
|
537 | __webpack_require__.d(__webpack_exports__, "awaitFrameLoad", function() {
|
538 | return __WEBPACK_IMPORTED_MODULE_1__dom__.f;
|
539 | });
|
540 | __webpack_require__.d(__webpack_exports__, "awaitFrameWindow", function() {
|
541 | return __WEBPACK_IMPORTED_MODULE_1__dom__.g;
|
542 | });
|
543 | __webpack_require__.d(__webpack_exports__, "destroyElement", function() {
|
544 | return __WEBPACK_IMPORTED_MODULE_1__dom__.h;
|
545 | });
|
546 | __webpack_require__.d(__webpack_exports__, "elementReady", function() {
|
547 | return __WEBPACK_IMPORTED_MODULE_1__dom__.i;
|
548 | });
|
549 | __webpack_require__.d(__webpack_exports__, "extendUrl", function() {
|
550 | return __WEBPACK_IMPORTED_MODULE_1__dom__.j;
|
551 | });
|
552 | __webpack_require__.d(__webpack_exports__, "getElement", function() {
|
553 | return __WEBPACK_IMPORTED_MODULE_1__dom__.k;
|
554 | });
|
555 | __webpack_require__.d(__webpack_exports__, "hideElement", function() {
|
556 | return __WEBPACK_IMPORTED_MODULE_1__dom__.l;
|
557 | });
|
558 | __webpack_require__.d(__webpack_exports__, "iframe", function() {
|
559 | return __WEBPACK_IMPORTED_MODULE_1__dom__.m;
|
560 | });
|
561 | __webpack_require__.d(__webpack_exports__, "onResize", function() {
|
562 | return __WEBPACK_IMPORTED_MODULE_1__dom__.o;
|
563 | });
|
564 | __webpack_require__.d(__webpack_exports__, "popup", function() {
|
565 | return __WEBPACK_IMPORTED_MODULE_1__dom__.p;
|
566 | });
|
567 | __webpack_require__.d(__webpack_exports__, "removeClass", function() {
|
568 | return __WEBPACK_IMPORTED_MODULE_1__dom__.q;
|
569 | });
|
570 | __webpack_require__.d(__webpack_exports__, "showAndAnimate", function() {
|
571 | return __WEBPACK_IMPORTED_MODULE_1__dom__.r;
|
572 | });
|
573 | __webpack_require__.d(__webpack_exports__, "showElement", function() {
|
574 | return __WEBPACK_IMPORTED_MODULE_1__dom__.s;
|
575 | });
|
576 | __webpack_require__.d(__webpack_exports__, "waitForDocumentBody", function() {
|
577 | return __WEBPACK_IMPORTED_MODULE_1__dom__.t;
|
578 | });
|
579 | __webpack_require__.d(__webpack_exports__, "watchElementForClose", function() {
|
580 | return __WEBPACK_IMPORTED_MODULE_1__dom__.u;
|
581 | });
|
582 | __webpack_require__.d(__webpack_exports__, "writeElementToWindow", function() {
|
583 | return __WEBPACK_IMPORTED_MODULE_1__dom__.v;
|
584 | });
|
585 | __webpack_require__("./node_modules/belter/src/experiment.js"), __webpack_require__("./node_modules/belter/src/global.js"),
|
586 | __webpack_require__("./node_modules/belter/src/storage.js");
|
587 | var __WEBPACK_IMPORTED_MODULE_5__util__ = __webpack_require__("./node_modules/belter/src/util.js");
|
588 | __webpack_require__.d(__webpack_exports__, "base64decode", function() {
|
589 | return __WEBPACK_IMPORTED_MODULE_5__util__.a;
|
590 | });
|
591 | __webpack_require__.d(__webpack_exports__, "base64encode", function() {
|
592 | return __WEBPACK_IMPORTED_MODULE_5__util__.b;
|
593 | });
|
594 | __webpack_require__.d(__webpack_exports__, "dasherizeToCamel", function() {
|
595 | return __WEBPACK_IMPORTED_MODULE_5__util__.d;
|
596 | });
|
597 | __webpack_require__.d(__webpack_exports__, "dotify", function() {
|
598 | return __WEBPACK_IMPORTED_MODULE_5__util__.f;
|
599 | });
|
600 | __webpack_require__.d(__webpack_exports__, "eventEmitter", function() {
|
601 | return __WEBPACK_IMPORTED_MODULE_5__util__.g;
|
602 | });
|
603 | __webpack_require__.d(__webpack_exports__, "extend", function() {
|
604 | return __WEBPACK_IMPORTED_MODULE_5__util__.h;
|
605 | });
|
606 | __webpack_require__.d(__webpack_exports__, "getOrSet", function() {
|
607 | return __WEBPACK_IMPORTED_MODULE_5__util__.j;
|
608 | });
|
609 | __webpack_require__.d(__webpack_exports__, "isDefined", function() {
|
610 | return __WEBPACK_IMPORTED_MODULE_5__util__.l;
|
611 | });
|
612 | __webpack_require__.d(__webpack_exports__, "isRegex", function() {
|
613 | return __WEBPACK_IMPORTED_MODULE_5__util__.m;
|
614 | });
|
615 | __webpack_require__.d(__webpack_exports__, "memoize", function() {
|
616 | return __WEBPACK_IMPORTED_MODULE_5__util__.n;
|
617 | });
|
618 | __webpack_require__.d(__webpack_exports__, "memoizePromise", function() {
|
619 | return __WEBPACK_IMPORTED_MODULE_5__util__.o;
|
620 | });
|
621 | __webpack_require__.d(__webpack_exports__, "noop", function() {
|
622 | return __WEBPACK_IMPORTED_MODULE_5__util__.p;
|
623 | });
|
624 | __webpack_require__.d(__webpack_exports__, "once", function() {
|
625 | return __WEBPACK_IMPORTED_MODULE_5__util__.q;
|
626 | });
|
627 | __webpack_require__.d(__webpack_exports__, "promisify", function() {
|
628 | return __WEBPACK_IMPORTED_MODULE_5__util__.r;
|
629 | });
|
630 | __webpack_require__.d(__webpack_exports__, "replaceObject", function() {
|
631 | return __WEBPACK_IMPORTED_MODULE_5__util__.s;
|
632 | });
|
633 | __webpack_require__.d(__webpack_exports__, "safeInterval", function() {
|
634 | return __WEBPACK_IMPORTED_MODULE_5__util__.t;
|
635 | });
|
636 | __webpack_require__.d(__webpack_exports__, "stringify", function() {
|
637 | return __WEBPACK_IMPORTED_MODULE_5__util__.u;
|
638 | });
|
639 | __webpack_require__.d(__webpack_exports__, "stringifyError", function() {
|
640 | return __WEBPACK_IMPORTED_MODULE_5__util__.v;
|
641 | });
|
642 | __webpack_require__.d(__webpack_exports__, "uniqueID", function() {
|
643 | return __WEBPACK_IMPORTED_MODULE_5__util__.w;
|
644 | });
|
645 | __webpack_require__.d(__webpack_exports__, "weakMapMemoize", function() {
|
646 | return __WEBPACK_IMPORTED_MODULE_5__util__.x;
|
647 | });
|
648 | __webpack_require__.d(__webpack_exports__, "weakMapMemoizePromise", function() {
|
649 | return __WEBPACK_IMPORTED_MODULE_5__util__.y;
|
650 | });
|
651 | __webpack_require__("./node_modules/belter/src/http.js");
|
652 | var __WEBPACK_IMPORTED_MODULE_7__types__ = __webpack_require__("./node_modules/belter/src/types.js");
|
653 | __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__types__);
|
654 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_7__types__, "isPerc") && __webpack_require__.d(__webpack_exports__, "isPerc", function() {
|
655 | return __WEBPACK_IMPORTED_MODULE_7__types__.isPerc;
|
656 | });
|
657 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_7__types__, "isPx") && __webpack_require__.d(__webpack_exports__, "isPx", function() {
|
658 | return __WEBPACK_IMPORTED_MODULE_7__types__.isPx;
|
659 | });
|
660 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_7__types__, "memoized") && __webpack_require__.d(__webpack_exports__, "memoized", function() {
|
661 | return __WEBPACK_IMPORTED_MODULE_7__types__.memoized;
|
662 | });
|
663 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_7__types__, "normalizeDimension") && __webpack_require__.d(__webpack_exports__, "normalizeDimension", function() {
|
664 | return __WEBPACK_IMPORTED_MODULE_7__types__.normalizeDimension;
|
665 | });
|
666 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_7__types__, "toCSS") && __webpack_require__.d(__webpack_exports__, "toCSS", function() {
|
667 | return __WEBPACK_IMPORTED_MODULE_7__types__.toCSS;
|
668 | });
|
669 | var __WEBPACK_IMPORTED_MODULE_8__decorators__ = __webpack_require__("./node_modules/belter/src/decorators.js");
|
670 | __webpack_require__.d(__webpack_exports__, "memoized", function() {
|
671 | return __WEBPACK_IMPORTED_MODULE_8__decorators__.a;
|
672 | });
|
673 | var __WEBPACK_IMPORTED_MODULE_9__css__ = __webpack_require__("./node_modules/belter/src/css.js");
|
674 | __webpack_require__.d(__webpack_exports__, "isPerc", function() {
|
675 | return __WEBPACK_IMPORTED_MODULE_9__css__.a;
|
676 | });
|
677 | __webpack_require__.d(__webpack_exports__, "isPx", function() {
|
678 | return __WEBPACK_IMPORTED_MODULE_9__css__.b;
|
679 | });
|
680 | __webpack_require__.d(__webpack_exports__, "normalizeDimension", function() {
|
681 | return __WEBPACK_IMPORTED_MODULE_9__css__.c;
|
682 | });
|
683 | __webpack_require__.d(__webpack_exports__, "toCSS", function() {
|
684 | return __WEBPACK_IMPORTED_MODULE_9__css__.d;
|
685 | });
|
686 | __webpack_require__("./node_modules/belter/src/test.js");
|
687 | },
|
688 | "./node_modules/belter/src/storage.js": function(module, __webpack_exports__, __webpack_require__) {
|
689 | "use strict";
|
690 | __webpack_exports__.a = function getStorage(_ref) {
|
691 | var name = _ref.name, _ref$version = _ref.version, version = void 0 === _ref$version ? "latest" : _ref$version, _ref$lifetime = _ref.lifetime, lifetime = void 0 === _ref$lifetime ? 3e5 : _ref$lifetime;
|
692 | return Object(__WEBPACK_IMPORTED_MODULE_0__util__.k)(getStorage, function() {
|
693 | var STORAGE_KEY = "__" + name + "_" + version + "_storage__", accessedStorage = void 0;
|
694 | function getState(handler) {
|
695 | var localStorageEnabled = Object(__WEBPACK_IMPORTED_MODULE_1__dom__.n)(), storage = void 0;
|
696 | accessedStorage && (storage = accessedStorage);
|
697 | if (!storage && localStorageEnabled) {
|
698 | var rawStorage = window.localStorage.getItem(STORAGE_KEY);
|
699 | rawStorage && (storage = JSON.parse(rawStorage));
|
700 | }
|
701 | storage || (storage = Object(__WEBPACK_IMPORTED_MODULE_0__util__.i)()[STORAGE_KEY]);
|
702 | storage || (storage = {
|
703 | id: Object(__WEBPACK_IMPORTED_MODULE_0__util__.w)()
|
704 | });
|
705 | storage.id || (storage.id = Object(__WEBPACK_IMPORTED_MODULE_0__util__.w)());
|
706 | accessedStorage = storage;
|
707 | var result = handler(storage);
|
708 | localStorageEnabled ? window.localStorage.setItem(STORAGE_KEY, JSON.stringify(storage)) : Object(__WEBPACK_IMPORTED_MODULE_0__util__.i)()[STORAGE_KEY] = storage;
|
709 | accessedStorage = null;
|
710 | return result;
|
711 | }
|
712 | function getSession(handler) {
|
713 | return getState(function(storage) {
|
714 | var session = storage.__session__, now = Date.now();
|
715 | session && now - session.created > lifetime && (session = null);
|
716 | session || (session = {
|
717 | guid: Object(__WEBPACK_IMPORTED_MODULE_0__util__.w)(),
|
718 | created: now
|
719 | });
|
720 | storage.__session__ = session;
|
721 | return handler(session);
|
722 | });
|
723 | }
|
724 | return {
|
725 | getState: getState,
|
726 | getID: function() {
|
727 | return getState(function(storage) {
|
728 | return storage.id;
|
729 | });
|
730 | },
|
731 | getSessionState: function(handler) {
|
732 | return getSession(function(session) {
|
733 | session.state = session.state || {};
|
734 | return handler(session.state);
|
735 | });
|
736 | },
|
737 | getSessionID: function() {
|
738 | return getSession(function(session) {
|
739 | return session.guid;
|
740 | });
|
741 | }
|
742 | };
|
743 | }, [ {
|
744 | name: name,
|
745 | version: version,
|
746 | lifetime: lifetime
|
747 | } ]);
|
748 | };
|
749 | var __WEBPACK_IMPORTED_MODULE_0__util__ = __webpack_require__("./node_modules/belter/src/util.js"), __WEBPACK_IMPORTED_MODULE_1__dom__ = __webpack_require__("./node_modules/belter/src/dom.js");
|
750 | },
|
751 | "./node_modules/belter/src/test.js": function(module, __webpack_exports__, __webpack_require__) {
|
752 | "use strict";
|
753 | __webpack_require__("./node_modules/zalgo-promise/src/index.js"), __webpack_require__("./node_modules/belter/src/util.js");
|
754 | },
|
755 | "./node_modules/belter/src/types.js": function(module, exports) {},
|
756 | "./node_modules/belter/src/util.js": function(module, __webpack_exports__, __webpack_require__) {
|
757 | "use strict";
|
758 | __webpack_exports__.b = base64encode;
|
759 | __webpack_exports__.a = function(str) {
|
760 | if ("undefined" != typeof window && "function" == typeof window.atob) return window.atob(str);
|
761 | if ("undefined" != typeof Buffer) return Buffer.from(str, "base64").toString("utf8");
|
762 | throw new Error("Can not find window.atob or Buffer");
|
763 | };
|
764 | __webpack_exports__.w = uniqueID;
|
765 | __webpack_exports__.i = function() {
|
766 | if ("undefined" != typeof window) return window;
|
767 | if ("undefined" != typeof window) return window;
|
768 | if ("undefined" != typeof global) return global;
|
769 | throw new Error("No global found");
|
770 | };
|
771 | __webpack_exports__.n = function(method) {
|
772 | var _this = this, options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, cacheMap = new __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__.a();
|
773 | function memoizedFunction() {
|
774 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
|
775 | var cache = cacheMap.getOrSet(options.thisNamespace ? this : method, function() {
|
776 | return {};
|
777 | }), key = serializeArgs(args), cacheTime = options.time;
|
778 | cache[key] && cacheTime && Date.now() - cache[key].time < cacheTime && delete cache[key];
|
779 | if (cache[key]) return cache[key].value;
|
780 | var time = Date.now(), value = method.apply(this, arguments);
|
781 | cache[key] = {
|
782 | time: time,
|
783 | value: value
|
784 | };
|
785 | return cache[key].value;
|
786 | }
|
787 | memoizedFunction.reset = function() {
|
788 | cacheMap.delete(options.thisNamespace ? _this : method);
|
789 | };
|
790 | options.name && (memoizedFunction.displayName = options.name + ":memoized");
|
791 | return memoizedFunction;
|
792 | };
|
793 | __webpack_exports__.o = function(method) {
|
794 | var cache = {};
|
795 | function memoizedPromiseFunction() {
|
796 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) args[_key2] = arguments[_key2];
|
797 | var key = serializeArgs(args);
|
798 | if (cache.hasOwnProperty(key)) return cache[key];
|
799 | cache[key] = method.apply(this, arguments).finally(function() {
|
800 | delete cache[key];
|
801 | });
|
802 | return cache[key];
|
803 | }
|
804 | memoizedPromiseFunction.reset = function() {
|
805 | cache = {};
|
806 | };
|
807 | return memoizedPromiseFunction;
|
808 | };
|
809 | __webpack_exports__.r = function(method) {
|
810 | var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
811 | function promisifiedFunction() {
|
812 | return __WEBPACK_IMPORTED_MODULE_0_zalgo_promise_src__.a.try(method, this, arguments);
|
813 | }
|
814 | options.name && (promisifiedFunction.displayName = options.name + ":promisified");
|
815 | return promisifiedFunction;
|
816 | };
|
817 | __webpack_exports__.k = function(method, logic) {
|
818 | var args = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : [], cache = method.__inline_memoize_cache__ = method.__inline_memoize_cache__ || {}, key = serializeArgs(args);
|
819 | return cache.hasOwnProperty(key) ? cache[key] : cache[key] = logic.apply(void 0, args);
|
820 | };
|
821 | __webpack_exports__.p = function() {};
|
822 | __webpack_exports__.q = function(method) {
|
823 | var called = !1;
|
824 | return function() {
|
825 | if (!called) {
|
826 | called = !0;
|
827 | return method.apply(this, arguments);
|
828 | }
|
829 | };
|
830 | };
|
831 | __webpack_exports__.v = function stringifyError(err) {
|
832 | var level = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1;
|
833 | if (level >= 3) return "stringifyError stack overflow";
|
834 | try {
|
835 | if (!err) return "<unknown error: " + Object.prototype.toString.call(err) + ">";
|
836 | if ("string" == typeof err) return err;
|
837 | if (err instanceof Error) {
|
838 | var stack = err && err.stack, message = err && err.message;
|
839 | if (stack && message) return -1 !== stack.indexOf(message) ? stack : message + "\n" + stack;
|
840 | if (stack) return stack;
|
841 | if (message) return message;
|
842 | }
|
843 | return "function" == typeof err.toString ? err.toString() : Object.prototype.toString.call(err);
|
844 | } catch (newErr) {
|
845 | return "Error while stringifying error: " + stringifyError(newErr, level + 1);
|
846 | }
|
847 | };
|
848 | __webpack_exports__.u = function(item) {
|
849 | return "string" == typeof item ? item : item && "function" == typeof item.toString ? item.toString() : Object.prototype.toString.call(item);
|
850 | };
|
851 | __webpack_exports__.h = function(obj, source) {
|
852 | if (!source) return obj;
|
853 | if (Object.assign) return Object.assign(obj, source);
|
854 | for (var key in source) source.hasOwnProperty(key) && (obj[key] = source[key]);
|
855 | return obj;
|
856 | };
|
857 | __webpack_exports__.t = function(method, time) {
|
858 | var timeout = void 0;
|
859 | !function loop() {
|
860 | timeout = setTimeout(function() {
|
861 | method();
|
862 | loop();
|
863 | }, time);
|
864 | }();
|
865 | return {
|
866 | cancel: function() {
|
867 | clearTimeout(timeout);
|
868 | }
|
869 | };
|
870 | };
|
871 | __webpack_exports__.f = function dotify(obj) {
|
872 | var prefix = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "", newobj = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
873 | prefix = prefix ? prefix + "." : prefix;
|
874 | for (var key in obj) obj.hasOwnProperty(key) && void 0 !== obj[key] && null !== obj[key] && "function" != typeof obj[key] && (obj[key] && Array.isArray(obj[key]) && obj[key].length && obj[key].every(function(val) {
|
875 | return "object" !== (void 0 === val ? "undefined" : _typeof(val));
|
876 | }) ? newobj["" + prefix + key + "[]"] = obj[key].join(",") : obj[key] && "object" === _typeof(obj[key]) ? newobj = dotify(obj[key], "" + prefix + key, newobj) : newobj["" + prefix + key] = obj[key].toString());
|
877 | return newobj;
|
878 | };
|
879 | __webpack_exports__.g = function() {
|
880 | var triggered = {}, handlers = {};
|
881 | return {
|
882 | on: function(eventName, handler) {
|
883 | var handlerList = handlers[eventName] = handlers[eventName] || [];
|
884 | handlerList.push(handler);
|
885 | var cancelled = !1;
|
886 | return {
|
887 | cancel: function() {
|
888 | if (!cancelled) {
|
889 | cancelled = !0;
|
890 | handlerList.splice(handlerList.indexOf(handler), 1);
|
891 | }
|
892 | }
|
893 | };
|
894 | },
|
895 | once: function(eventName, handler) {
|
896 | var listener = this.on(eventName, function() {
|
897 | listener.cancel();
|
898 | handler();
|
899 | });
|
900 | return listener;
|
901 | },
|
902 | trigger: function(eventName) {
|
903 | var handlerList = handlers[eventName];
|
904 | if (handlerList) for (var _i2 = 0, _length2 = null == handlerList ? 0 : handlerList.length; _i2 < _length2; _i2++) (0,
|
905 | handlerList[_i2])();
|
906 | },
|
907 | triggerOnce: function(eventName) {
|
908 | if (!triggered[eventName]) {
|
909 | triggered[eventName] = !0;
|
910 | this.trigger(eventName);
|
911 | }
|
912 | }
|
913 | };
|
914 | };
|
915 | __webpack_exports__.d = function(string) {
|
916 | return string.replace(/-([a-z])/g, function(g) {
|
917 | return g[1].toUpperCase();
|
918 | });
|
919 | };
|
920 | __webpack_exports__.c = function(string) {
|
921 | return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
922 | };
|
923 | __webpack_exports__.s = function replaceObject(item, replacer) {
|
924 | var fullKey = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "";
|
925 | if (Array.isArray(item)) {
|
926 | for (var _length3 = item.length, result = [], _loop = function(i) {
|
927 | defineLazyProp(result, i, function() {
|
928 | var itemKey = fullKey ? fullKey + "." + i : "" + i, el = item[i], child = replacer(el, i, itemKey);
|
929 | (isPlainObject(child) || Array.isArray(child)) && (child = replaceObject(child, replacer, itemKey));
|
930 | return child;
|
931 | });
|
932 | }, i = 0; i < _length3; i++) _loop(i);
|
933 | return result;
|
934 | }
|
935 | if (isPlainObject(item)) {
|
936 | var _result = {}, _loop2 = function(key) {
|
937 | if (!item.hasOwnProperty(key)) return "continue";
|
938 | defineLazyProp(_result, key, function() {
|
939 | var itemKey = fullKey ? fullKey + "." + key : "" + key, el = item[key], child = replacer(el, key, itemKey);
|
940 | (isPlainObject(child) || Array.isArray(child)) && (child = replaceObject(child, replacer, itemKey));
|
941 | return child;
|
942 | });
|
943 | };
|
944 | for (var key in item) _loop2(key);
|
945 | return _result;
|
946 | }
|
947 | throw new Error("Pass an object or array");
|
948 | };
|
949 | __webpack_exports__.l = function(value) {
|
950 | return null !== value && void 0 !== value;
|
951 | };
|
952 | __webpack_exports__.e = function(method) {
|
953 | var time = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 100, timeout = void 0;
|
954 | return function() {
|
955 | var _this3 = this, _arguments2 = arguments;
|
956 | clearTimeout(timeout);
|
957 | timeout = setTimeout(function() {
|
958 | return method.apply(_this3, _arguments2);
|
959 | }, time);
|
960 | };
|
961 | };
|
962 | __webpack_exports__.m = function(item) {
|
963 | return "[object RegExp]" === Object.prototype.toString.call(item);
|
964 | };
|
965 | __webpack_require__.d(__webpack_exports__, "x", function() {
|
966 | return weakMapMemoize;
|
967 | });
|
968 | __webpack_require__.d(__webpack_exports__, "y", function() {
|
969 | return weakMapMemoizePromise;
|
970 | });
|
971 | __webpack_exports__.j = function(obj, key, getter) {
|
972 | if (obj.hasOwnProperty(key)) return obj[key];
|
973 | var val = getter();
|
974 | obj[key] = val;
|
975 | return val;
|
976 | };
|
977 | var __WEBPACK_IMPORTED_MODULE_0_zalgo_promise_src__ = __webpack_require__("./node_modules/zalgo-promise/src/index.js"), __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__ = __webpack_require__("./node_modules/cross-domain-safe-weakmap/src/index.js"), _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
978 | return typeof obj;
|
979 | } : function(obj) {
|
980 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
981 | };
|
982 | function base64encode(str) {
|
983 | if ("undefined" != typeof window && "function" == typeof window.btoa) return window.btoa(str);
|
984 | if ("undefined" != typeof Buffer) return Buffer.from(str, "utf8").toString("base64");
|
985 | throw new Error("Can not find window.btoa or Buffer");
|
986 | }
|
987 | function uniqueID() {
|
988 | var chars = "0123456789abcdef";
|
989 | return "xxxxxxxxxx".replace(/./g, function() {
|
990 | return chars.charAt(Math.floor(Math.random() * chars.length));
|
991 | }) + "_" + base64encode(new Date().toISOString().slice(11, 19).replace("T", ".")).replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
992 | }
|
993 | var objectIDs = void 0;
|
994 | function serializeArgs(args) {
|
995 | try {
|
996 | return JSON.stringify(Array.prototype.slice.call(args), function(subkey, val) {
|
997 | return "function" == typeof val ? "memoize[" + function(obj) {
|
998 | objectIDs = objectIDs || new __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__.a();
|
999 | if (null === obj || void 0 === obj || "object" !== (void 0 === obj ? "undefined" : _typeof(obj)) && "function" != typeof obj) throw new Error("Invalid object");
|
1000 | var uid = objectIDs.get(obj);
|
1001 | if (!uid) {
|
1002 | uid = (void 0 === obj ? "undefined" : _typeof(obj)) + ":" + uniqueID();
|
1003 | objectIDs.set(obj, uid);
|
1004 | }
|
1005 | return uid;
|
1006 | }(val) + "]" : val;
|
1007 | });
|
1008 | } catch (err) {
|
1009 | throw new Error("Arguments not serializable -- can not be used to memoize");
|
1010 | }
|
1011 | }
|
1012 | function defineLazyProp(obj, key, getter) {
|
1013 | if (Array.isArray(obj)) {
|
1014 | if ("number" != typeof key) throw new TypeError("Array key must be number");
|
1015 | } else if ("object" === (void 0 === obj ? "undefined" : _typeof(obj)) && null !== obj && "string" != typeof key) throw new TypeError("Object key must be string");
|
1016 | Object.defineProperty(obj, key, {
|
1017 | configurable: !0,
|
1018 | enumerable: !0,
|
1019 | get: function() {
|
1020 | delete obj[key];
|
1021 | var value = getter();
|
1022 | obj[key] = value;
|
1023 | return value;
|
1024 | },
|
1025 | set: function(value) {
|
1026 | delete obj[key];
|
1027 | obj[key] = value;
|
1028 | }
|
1029 | });
|
1030 | }
|
1031 | function isObjectObject(obj) {
|
1032 | return "object" === (void 0 === (item = obj) ? "undefined" : _typeof(item)) && null !== item && "[object Object]" === Object.prototype.toString.call(obj);
|
1033 | var item;
|
1034 | }
|
1035 | function isPlainObject(obj) {
|
1036 | if (!isObjectObject(obj)) return !1;
|
1037 | var constructor = obj.constructor;
|
1038 | if ("function" != typeof constructor) return !1;
|
1039 | var prototype = constructor.prototype;
|
1040 | return !!isObjectObject(prototype) && !!prototype.hasOwnProperty("isPrototypeOf");
|
1041 | }
|
1042 | var weakMapMemoize = function(method) {
|
1043 | var weakmap = new __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__.a();
|
1044 | return function(arg) {
|
1045 | var _this4 = this;
|
1046 | return weakmap.getOrSet(arg, function() {
|
1047 | return method.call(_this4, arg);
|
1048 | });
|
1049 | };
|
1050 | }, weakMapMemoizePromise = function(method) {
|
1051 | var weakmap = new __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__.a();
|
1052 | return function(arg) {
|
1053 | var _this5 = this;
|
1054 | return weakmap.getOrSet(arg, function() {
|
1055 | return method.call(_this5, arg).finally(function() {
|
1056 | weakmap.delete(arg);
|
1057 | });
|
1058 | });
|
1059 | };
|
1060 | };
|
1061 | },
|
1062 | "./node_modules/cross-domain-safe-weakmap/src/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
1063 | "use strict";
|
1064 | __webpack_require__.d({}, "WeakMap", function() {
|
1065 | return weakmap_CrossDomainSafeWeakMap;
|
1066 | });
|
1067 | var src = __webpack_require__("./node_modules/cross-domain-utils/src/index.js");
|
1068 | function safeIndexOf(collection, item) {
|
1069 | for (var i = 0; i < collection.length; i++) try {
|
1070 | if (collection[i] === item) return i;
|
1071 | } catch (err) {}
|
1072 | return -1;
|
1073 | }
|
1074 | var defineProperty = Object.defineProperty, counter = Date.now() % 1e9, weakmap_CrossDomainSafeWeakMap = function() {
|
1075 | function CrossDomainSafeWeakMap() {
|
1076 | !function(instance, Constructor) {
|
1077 | if (!(instance instanceof CrossDomainSafeWeakMap)) throw new TypeError("Cannot call a class as a function");
|
1078 | }(this);
|
1079 | counter += 1;
|
1080 | this.name = "__weakmap_" + (1e9 * Math.random() >>> 0) + "__" + counter;
|
1081 | if (function() {
|
1082 | if ("undefined" == typeof WeakMap) return !1;
|
1083 | if (void 0 === Object.freeze) return !1;
|
1084 | try {
|
1085 | var testWeakMap = new WeakMap(), testKey = {};
|
1086 | Object.freeze(testKey);
|
1087 | testWeakMap.set(testKey, "__testvalue__");
|
1088 | return "__testvalue__" === testWeakMap.get(testKey);
|
1089 | } catch (err) {
|
1090 | return !1;
|
1091 | }
|
1092 | }()) try {
|
1093 | this.weakmap = new WeakMap();
|
1094 | } catch (err) {}
|
1095 | this.keys = [];
|
1096 | this.values = [];
|
1097 | }
|
1098 | CrossDomainSafeWeakMap.prototype._cleanupClosedWindows = function() {
|
1099 | for (var weakmap = this.weakmap, keys = this.keys, i = 0; i < keys.length; i++) {
|
1100 | var value = keys[i];
|
1101 | if (Object(src.isWindow)(value) && Object(src.isWindowClosed)(value)) {
|
1102 | if (weakmap) try {
|
1103 | weakmap.delete(value);
|
1104 | } catch (err) {}
|
1105 | keys.splice(i, 1);
|
1106 | this.values.splice(i, 1);
|
1107 | i -= 1;
|
1108 | }
|
1109 | }
|
1110 | };
|
1111 | CrossDomainSafeWeakMap.prototype.isSafeToReadWrite = function(key) {
|
1112 | if (Object(src.isWindow)(key)) return !1;
|
1113 | try {
|
1114 | key && key.self;
|
1115 | key && key[this.name];
|
1116 | } catch (err) {
|
1117 | return !1;
|
1118 | }
|
1119 | return !0;
|
1120 | };
|
1121 | CrossDomainSafeWeakMap.prototype.set = function(key, value) {
|
1122 | if (!key) throw new Error("WeakMap expected key");
|
1123 | var weakmap = this.weakmap;
|
1124 | if (weakmap) try {
|
1125 | weakmap.set(key, value);
|
1126 | } catch (err) {
|
1127 | delete this.weakmap;
|
1128 | }
|
1129 | if (this.isSafeToReadWrite(key)) {
|
1130 | var name = this.name, entry = key[name];
|
1131 | entry && entry[0] === key ? entry[1] = value : defineProperty(key, name, {
|
1132 | value: [ key, value ],
|
1133 | writable: !0
|
1134 | });
|
1135 | } else {
|
1136 | this._cleanupClosedWindows();
|
1137 | var keys = this.keys, values = this.values, index = safeIndexOf(keys, key);
|
1138 | if (-1 === index) {
|
1139 | keys.push(key);
|
1140 | values.push(value);
|
1141 | } else values[index] = value;
|
1142 | }
|
1143 | };
|
1144 | CrossDomainSafeWeakMap.prototype.get = function(key) {
|
1145 | if (!key) throw new Error("WeakMap expected key");
|
1146 | var weakmap = this.weakmap;
|
1147 | if (weakmap) try {
|
1148 | if (weakmap.has(key)) return weakmap.get(key);
|
1149 | } catch (err) {
|
1150 | delete this.weakmap;
|
1151 | }
|
1152 | if (!this.isSafeToReadWrite(key)) {
|
1153 | this._cleanupClosedWindows();
|
1154 | var index = safeIndexOf(this.keys, key);
|
1155 | if (-1 === index) return;
|
1156 | return this.values[index];
|
1157 | }
|
1158 | var entry = key[this.name];
|
1159 | if (entry && entry[0] === key) return entry[1];
|
1160 | };
|
1161 | CrossDomainSafeWeakMap.prototype.delete = function(key) {
|
1162 | if (!key) throw new Error("WeakMap expected key");
|
1163 | var weakmap = this.weakmap;
|
1164 | if (weakmap) try {
|
1165 | weakmap.delete(key);
|
1166 | } catch (err) {
|
1167 | delete this.weakmap;
|
1168 | }
|
1169 | if (this.isSafeToReadWrite(key)) {
|
1170 | var entry = key[this.name];
|
1171 | entry && entry[0] === key && (entry[0] = entry[1] = void 0);
|
1172 | } else {
|
1173 | this._cleanupClosedWindows();
|
1174 | var keys = this.keys, index = safeIndexOf(keys, key);
|
1175 | if (-1 !== index) {
|
1176 | keys.splice(index, 1);
|
1177 | this.values.splice(index, 1);
|
1178 | }
|
1179 | }
|
1180 | };
|
1181 | CrossDomainSafeWeakMap.prototype.has = function(key) {
|
1182 | if (!key) throw new Error("WeakMap expected key");
|
1183 | var weakmap = this.weakmap;
|
1184 | if (weakmap) try {
|
1185 | if (weakmap.has(key)) return !0;
|
1186 | } catch (err) {
|
1187 | delete this.weakmap;
|
1188 | }
|
1189 | if (this.isSafeToReadWrite(key)) {
|
1190 | var entry = key[this.name];
|
1191 | return !(!entry || entry[0] !== key);
|
1192 | }
|
1193 | this._cleanupClosedWindows();
|
1194 | return -1 !== safeIndexOf(this.keys, key);
|
1195 | };
|
1196 | CrossDomainSafeWeakMap.prototype.getOrSet = function(key, getter) {
|
1197 | if (this.has(key)) return this.get(key);
|
1198 | var value = getter();
|
1199 | this.set(key, value);
|
1200 | return value;
|
1201 | };
|
1202 | return CrossDomainSafeWeakMap;
|
1203 | }();
|
1204 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
1205 | return weakmap_CrossDomainSafeWeakMap;
|
1206 | });
|
1207 | },
|
1208 | "./node_modules/cross-domain-utils/src/constants.js": function(module, __webpack_exports__, __webpack_require__) {
|
1209 | "use strict";
|
1210 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
1211 | return PROTOCOL;
|
1212 | });
|
1213 | __webpack_require__.d(__webpack_exports__, "b", function() {
|
1214 | return WILDCARD;
|
1215 | });
|
1216 | var PROTOCOL = {
|
1217 | MOCK: "mock:",
|
1218 | FILE: "file:",
|
1219 | ABOUT: "about:"
|
1220 | }, WILDCARD = "*";
|
1221 | },
|
1222 | "./node_modules/cross-domain-utils/src/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
1223 | "use strict";
|
1224 | var __WEBPACK_IMPORTED_MODULE_0__utils__ = __webpack_require__("./node_modules/cross-domain-utils/src/utils.js");
|
1225 | __webpack_require__.d(__webpack_exports__, "assertSameDomain", function() {
|
1226 | return __WEBPACK_IMPORTED_MODULE_0__utils__.a;
|
1227 | });
|
1228 | __webpack_require__.d(__webpack_exports__, "getActualDomain", function() {
|
1229 | return __WEBPACK_IMPORTED_MODULE_0__utils__.b;
|
1230 | });
|
1231 | __webpack_require__.d(__webpack_exports__, "getAllFramesInWindow", function() {
|
1232 | return __WEBPACK_IMPORTED_MODULE_0__utils__.c;
|
1233 | });
|
1234 | __webpack_require__.d(__webpack_exports__, "getAncestor", function() {
|
1235 | return __WEBPACK_IMPORTED_MODULE_0__utils__.d;
|
1236 | });
|
1237 | __webpack_require__.d(__webpack_exports__, "getDistanceFromTop", function() {
|
1238 | return __WEBPACK_IMPORTED_MODULE_0__utils__.e;
|
1239 | });
|
1240 | __webpack_require__.d(__webpack_exports__, "getDomain", function() {
|
1241 | return __WEBPACK_IMPORTED_MODULE_0__utils__.f;
|
1242 | });
|
1243 | __webpack_require__.d(__webpack_exports__, "getDomainFromUrl", function() {
|
1244 | return __WEBPACK_IMPORTED_MODULE_0__utils__.g;
|
1245 | });
|
1246 | __webpack_require__.d(__webpack_exports__, "getFrameByName", function() {
|
1247 | return __WEBPACK_IMPORTED_MODULE_0__utils__.h;
|
1248 | });
|
1249 | __webpack_require__.d(__webpack_exports__, "getNthParentFromTop", function() {
|
1250 | return __WEBPACK_IMPORTED_MODULE_0__utils__.i;
|
1251 | });
|
1252 | __webpack_require__.d(__webpack_exports__, "getOpener", function() {
|
1253 | return __WEBPACK_IMPORTED_MODULE_0__utils__.j;
|
1254 | });
|
1255 | __webpack_require__.d(__webpack_exports__, "getParent", function() {
|
1256 | return __WEBPACK_IMPORTED_MODULE_0__utils__.k;
|
1257 | });
|
1258 | __webpack_require__.d(__webpack_exports__, "getTop", function() {
|
1259 | return __WEBPACK_IMPORTED_MODULE_0__utils__.l;
|
1260 | });
|
1261 | __webpack_require__.d(__webpack_exports__, "getUserAgent", function() {
|
1262 | return __WEBPACK_IMPORTED_MODULE_0__utils__.m;
|
1263 | });
|
1264 | __webpack_require__.d(__webpack_exports__, "isActuallySameDomain", function() {
|
1265 | return __WEBPACK_IMPORTED_MODULE_0__utils__.n;
|
1266 | });
|
1267 | __webpack_require__.d(__webpack_exports__, "isAncestor", function() {
|
1268 | return __WEBPACK_IMPORTED_MODULE_0__utils__.o;
|
1269 | });
|
1270 | __webpack_require__.d(__webpack_exports__, "isBlankDomain", function() {
|
1271 | return __WEBPACK_IMPORTED_MODULE_0__utils__.p;
|
1272 | });
|
1273 | __webpack_require__.d(__webpack_exports__, "isOpener", function() {
|
1274 | return __WEBPACK_IMPORTED_MODULE_0__utils__.q;
|
1275 | });
|
1276 | __webpack_require__.d(__webpack_exports__, "isSameDomain", function() {
|
1277 | return __WEBPACK_IMPORTED_MODULE_0__utils__.r;
|
1278 | });
|
1279 | __webpack_require__.d(__webpack_exports__, "isSameTopWindow", function() {
|
1280 | return __WEBPACK_IMPORTED_MODULE_0__utils__.s;
|
1281 | });
|
1282 | __webpack_require__.d(__webpack_exports__, "isTop", function() {
|
1283 | return __WEBPACK_IMPORTED_MODULE_0__utils__.t;
|
1284 | });
|
1285 | __webpack_require__.d(__webpack_exports__, "isWindow", function() {
|
1286 | return __WEBPACK_IMPORTED_MODULE_0__utils__.u;
|
1287 | });
|
1288 | __webpack_require__.d(__webpack_exports__, "isWindowClosed", function() {
|
1289 | return __WEBPACK_IMPORTED_MODULE_0__utils__.v;
|
1290 | });
|
1291 | __webpack_require__.d(__webpack_exports__, "linkFrameWindow", function() {
|
1292 | return __WEBPACK_IMPORTED_MODULE_0__utils__.w;
|
1293 | });
|
1294 | __webpack_require__.d(__webpack_exports__, "matchDomain", function() {
|
1295 | return __WEBPACK_IMPORTED_MODULE_0__utils__.x;
|
1296 | });
|
1297 | __webpack_require__.d(__webpack_exports__, "normalizeMockUrl", function() {
|
1298 | return __WEBPACK_IMPORTED_MODULE_0__utils__.y;
|
1299 | });
|
1300 | __webpack_require__.d(__webpack_exports__, "onCloseWindow", function() {
|
1301 | return __WEBPACK_IMPORTED_MODULE_0__utils__.z;
|
1302 | });
|
1303 | __webpack_require__.d(__webpack_exports__, "stringifyDomainPattern", function() {
|
1304 | return __WEBPACK_IMPORTED_MODULE_0__utils__.A;
|
1305 | });
|
1306 | var __WEBPACK_IMPORTED_MODULE_1__types__ = __webpack_require__("./node_modules/cross-domain-utils/src/types.js");
|
1307 | __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__types__), __webpack_require__("./node_modules/cross-domain-utils/src/constants.js");
|
1308 | },
|
1309 | "./node_modules/cross-domain-utils/src/types.js": function(module, exports) {},
|
1310 | "./node_modules/cross-domain-utils/src/utils.js": function(module, __webpack_exports__, __webpack_require__) {
|
1311 | "use strict";
|
1312 | function isRegex(item) {
|
1313 | return "[object RegExp]" === Object.prototype.toString.call(item);
|
1314 | }
|
1315 | var constants = __webpack_require__("./node_modules/cross-domain-utils/src/constants.js");
|
1316 | __webpack_exports__.k = getParent;
|
1317 | __webpack_exports__.j = getOpener;
|
1318 | __webpack_exports__.b = getActualDomain;
|
1319 | __webpack_exports__.f = getDomain;
|
1320 | __webpack_exports__.p = function(win) {
|
1321 | try {
|
1322 | if (!win.location.href) return !0;
|
1323 | if ("about:blank" === win.location.href) return !0;
|
1324 | } catch (err) {}
|
1325 | return !1;
|
1326 | };
|
1327 | __webpack_exports__.n = isActuallySameDomain;
|
1328 | __webpack_exports__.r = isSameDomain;
|
1329 | __webpack_exports__.a = function(win) {
|
1330 | if (!isSameDomain(win)) throw new Error("Expected window to be same domain");
|
1331 | return win;
|
1332 | };
|
1333 | __webpack_exports__.l = getTop;
|
1334 | __webpack_exports__.c = getAllFramesInWindow;
|
1335 | __webpack_exports__.t = function(win) {
|
1336 | return win === getTop(win);
|
1337 | };
|
1338 | __webpack_exports__.v = isWindowClosed;
|
1339 | __webpack_exports__.w = function(frame) {
|
1340 | !function() {
|
1341 | for (var i = 0; i < iframeWindows.length; i++) if (isWindowClosed(iframeWindows[i])) {
|
1342 | iframeFrames.splice(i, 1);
|
1343 | iframeWindows.splice(i, 1);
|
1344 | }
|
1345 | }();
|
1346 | if (frame && frame.contentWindow) try {
|
1347 | iframeWindows.push(frame.contentWindow);
|
1348 | iframeFrames.push(frame);
|
1349 | } catch (err) {}
|
1350 | };
|
1351 | __webpack_exports__.m = function(win) {
|
1352 | return (win = win || window).navigator.mockUserAgent || win.navigator.userAgent;
|
1353 | };
|
1354 | __webpack_exports__.h = function(win, name) {
|
1355 | for (var winFrames = getFrames(win), _i9 = 0, _length8 = null == winFrames ? 0 : winFrames.length; _i9 < _length8; _i9++) {
|
1356 | var childFrame = winFrames[_i9];
|
1357 | try {
|
1358 | if (isSameDomain(childFrame) && childFrame.name === name && -1 !== winFrames.indexOf(childFrame)) return childFrame;
|
1359 | } catch (err) {}
|
1360 | }
|
1361 | try {
|
1362 | if (-1 !== winFrames.indexOf(win.frames[name])) return win.frames[name];
|
1363 | } catch (err) {}
|
1364 | try {
|
1365 | if (-1 !== winFrames.indexOf(win[name])) return win[name];
|
1366 | } catch (err) {}
|
1367 | };
|
1368 | __webpack_exports__.q = function(parent, child) {
|
1369 | return parent === getOpener(child);
|
1370 | };
|
1371 | __webpack_exports__.d = getAncestor;
|
1372 | __webpack_exports__.o = function(parent, child) {
|
1373 | var actualParent = getAncestor(child);
|
1374 | if (actualParent) return actualParent === parent;
|
1375 | if (child === parent) return !1;
|
1376 | if (getTop(child) === child) return !1;
|
1377 | for (var _i15 = 0, _getFrames8 = getFrames(parent), _length14 = null == _getFrames8 ? 0 : _getFrames8.length; _i15 < _length14; _i15++) if (_getFrames8[_i15] === child) return !0;
|
1378 | return !1;
|
1379 | };
|
1380 | __webpack_exports__.e = getDistanceFromTop;
|
1381 | __webpack_exports__.i = function(win) {
|
1382 | var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1;
|
1383 | return function(win) {
|
1384 | for (var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1, parent = win, i = 0; i < n; i++) {
|
1385 | if (!parent) return;
|
1386 | parent = getParent(parent);
|
1387 | }
|
1388 | return parent;
|
1389 | }(win, getDistanceFromTop(win) - n);
|
1390 | };
|
1391 | __webpack_exports__.s = function(win1, win2) {
|
1392 | var top1 = getTop(win1) || win1, top2 = getTop(win2) || win2;
|
1393 | try {
|
1394 | if (top1 && top2) return top1 === top2;
|
1395 | } catch (err) {}
|
1396 | var allFrames1 = getAllFramesInWindow(win1), allFrames2 = getAllFramesInWindow(win2);
|
1397 | if (anyMatch(allFrames1, allFrames2)) return !0;
|
1398 | var opener1 = getOpener(top1), opener2 = getOpener(top2);
|
1399 | return !(opener1 && anyMatch(getAllFramesInWindow(opener1), allFrames2) || (opener2 && anyMatch(getAllFramesInWindow(opener2), allFrames1),
|
1400 | 1));
|
1401 | };
|
1402 | __webpack_exports__.x = function matchDomain(pattern, origin) {
|
1403 | if ("string" == typeof pattern) {
|
1404 | if ("string" == typeof origin) return pattern === constants.b || origin === pattern;
|
1405 | if (isRegex(origin)) return !1;
|
1406 | if (Array.isArray(origin)) return !1;
|
1407 | }
|
1408 | return isRegex(pattern) ? isRegex(origin) ? pattern.toString() === origin.toString() : !Array.isArray(origin) && Boolean(origin.match(pattern)) : !!Array.isArray(pattern) && (Array.isArray(origin) ? JSON.stringify(pattern) === JSON.stringify(origin) : !isRegex(origin) && pattern.some(function(subpattern) {
|
1409 | return matchDomain(subpattern, origin);
|
1410 | }));
|
1411 | };
|
1412 | __webpack_exports__.A = function(pattern) {
|
1413 | return Array.isArray(pattern) ? "(" + pattern.join(" | ") + ")" : isRegex(pattern) ? "RegExp(" + pattern.toString() : pattern.toString();
|
1414 | };
|
1415 | __webpack_exports__.g = getDomainFromUrl;
|
1416 | __webpack_exports__.z = function(win, callback) {
|
1417 | var delay = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1e3, maxtime = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 1 / 0, timeout = void 0;
|
1418 | !function check() {
|
1419 | if (isWindowClosed(win)) {
|
1420 | timeout && clearTimeout(timeout);
|
1421 | return callback();
|
1422 | }
|
1423 | if (maxtime <= 0) clearTimeout(timeout); else {
|
1424 | maxtime -= delay;
|
1425 | timeout = setTimeout(check, delay);
|
1426 | }
|
1427 | }();
|
1428 | return {
|
1429 | cancel: function() {
|
1430 | timeout && clearTimeout(timeout);
|
1431 | }
|
1432 | };
|
1433 | };
|
1434 | __webpack_exports__.u = function(obj) {
|
1435 | try {
|
1436 | if (obj === window) return !0;
|
1437 | } catch (err) {
|
1438 | if (err && err.message === IE_WIN_ACCESS_ERROR) return !0;
|
1439 | }
|
1440 | try {
|
1441 | if ("[object Window]" === Object.prototype.toString.call(obj)) return !0;
|
1442 | } catch (err) {
|
1443 | if (err && err.message === IE_WIN_ACCESS_ERROR) return !0;
|
1444 | }
|
1445 | try {
|
1446 | if (window.Window && obj instanceof window.Window) return !0;
|
1447 | } catch (err) {
|
1448 | if (err && err.message === IE_WIN_ACCESS_ERROR) return !0;
|
1449 | }
|
1450 | try {
|
1451 | if (obj && obj.self === obj) return !0;
|
1452 | } catch (err) {
|
1453 | if (err && err.message === IE_WIN_ACCESS_ERROR) return !0;
|
1454 | }
|
1455 | try {
|
1456 | if (obj && obj.parent === obj) return !0;
|
1457 | } catch (err) {
|
1458 | if (err && err.message === IE_WIN_ACCESS_ERROR) return !0;
|
1459 | }
|
1460 | try {
|
1461 | if (obj && obj.top === obj) return !0;
|
1462 | } catch (err) {
|
1463 | if (err && err.message === IE_WIN_ACCESS_ERROR) return !0;
|
1464 | }
|
1465 | try {
|
1466 | obj && obj.__cross_domain_utils_window_check__;
|
1467 | } catch (err) {
|
1468 | return !0;
|
1469 | }
|
1470 | return !1;
|
1471 | };
|
1472 | __webpack_exports__.y = function(url) {
|
1473 | if (!(domain = getDomainFromUrl(url), 0 === domain.indexOf(constants.a.MOCK))) return url;
|
1474 | var domain;
|
1475 | throw new Error("Mock urls not supported out of test mode");
|
1476 | };
|
1477 | var IE_WIN_ACCESS_ERROR = "Call was rejected by callee.\r\n";
|
1478 | function isAboutProtocol() {
|
1479 | return (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : window).location.protocol === constants.a.ABOUT;
|
1480 | }
|
1481 | function getParent(win) {
|
1482 | if (win) try {
|
1483 | if (win.parent && win.parent !== win) return win.parent;
|
1484 | } catch (err) {}
|
1485 | }
|
1486 | function getOpener(win) {
|
1487 | if (win && !getParent(win)) try {
|
1488 | return win.opener;
|
1489 | } catch (err) {}
|
1490 | }
|
1491 | function canReadFromWindow(win) {
|
1492 | try {
|
1493 | win && win.location && win.location.href;
|
1494 | return !0;
|
1495 | } catch (err) {}
|
1496 | return !1;
|
1497 | }
|
1498 | function getActualDomain(win) {
|
1499 | var location = (win = win || window).location;
|
1500 | if (!location) throw new Error("Can not read window location");
|
1501 | var protocol = location.protocol;
|
1502 | if (!protocol) throw new Error("Can not read window protocol");
|
1503 | if (protocol === constants.a.FILE) return constants.a.FILE + "//";
|
1504 | if (protocol === constants.a.ABOUT) {
|
1505 | var parent = getParent(win);
|
1506 | return parent && canReadFromWindow(parent) ? getActualDomain(parent) : constants.a.ABOUT + "//";
|
1507 | }
|
1508 | var host = location.host;
|
1509 | if (!host) throw new Error("Can not read window host");
|
1510 | return protocol + "//" + host;
|
1511 | }
|
1512 | function getDomain(win) {
|
1513 | var domain = getActualDomain(win = win || window);
|
1514 | return domain && win.mockDomain && 0 === win.mockDomain.indexOf(constants.a.MOCK) ? win.mockDomain : domain;
|
1515 | }
|
1516 | function isActuallySameDomain(win) {
|
1517 | try {
|
1518 | if (win === window) return !0;
|
1519 | } catch (err) {}
|
1520 | try {
|
1521 | var desc = Object.getOwnPropertyDescriptor(win, "location");
|
1522 | if (desc && !1 === desc.enumerable) return !1;
|
1523 | } catch (err) {}
|
1524 | try {
|
1525 | if (isAboutProtocol(win) && canReadFromWindow(win)) return !0;
|
1526 | } catch (err) {}
|
1527 | try {
|
1528 | if (getActualDomain(win) === getActualDomain(window)) return !0;
|
1529 | } catch (err) {}
|
1530 | return !1;
|
1531 | }
|
1532 | function isSameDomain(win) {
|
1533 | if (!isActuallySameDomain(win)) return !1;
|
1534 | try {
|
1535 | if (win === window) return !0;
|
1536 | if (isAboutProtocol(win) && canReadFromWindow(win)) return !0;
|
1537 | if (getDomain(window) === getDomain(win)) return !0;
|
1538 | } catch (err) {}
|
1539 | return !1;
|
1540 | }
|
1541 | function isAncestorParent(parent, child) {
|
1542 | if (!parent || !child) return !1;
|
1543 | var childParent = getParent(child);
|
1544 | return childParent ? childParent === parent : -1 !== function(win) {
|
1545 | var result = [];
|
1546 | try {
|
1547 | for (;win.parent !== win; ) {
|
1548 | result.push(win.parent);
|
1549 | win = win.parent;
|
1550 | }
|
1551 | } catch (err) {}
|
1552 | return result;
|
1553 | }(child).indexOf(parent);
|
1554 | }
|
1555 | function getFrames(win) {
|
1556 | var result = [], frames = void 0;
|
1557 | try {
|
1558 | frames = win.frames;
|
1559 | } catch (err) {
|
1560 | frames = win;
|
1561 | }
|
1562 | var len = void 0;
|
1563 | try {
|
1564 | len = frames.length;
|
1565 | } catch (err) {}
|
1566 | if (0 === len) return result;
|
1567 | if (len) {
|
1568 | for (var i = 0; i < len; i++) {
|
1569 | var frame = void 0;
|
1570 | try {
|
1571 | frame = frames[i];
|
1572 | } catch (err) {
|
1573 | continue;
|
1574 | }
|
1575 | result.push(frame);
|
1576 | }
|
1577 | return result;
|
1578 | }
|
1579 | for (var _i = 0; _i < 100; _i++) {
|
1580 | var _frame = void 0;
|
1581 | try {
|
1582 | _frame = frames[_i];
|
1583 | } catch (err) {
|
1584 | return result;
|
1585 | }
|
1586 | if (!_frame) return result;
|
1587 | result.push(_frame);
|
1588 | }
|
1589 | return result;
|
1590 | }
|
1591 | function getAllChildFrames(win) {
|
1592 | for (var result = [], _i3 = 0, _getFrames2 = getFrames(win), _length2 = null == _getFrames2 ? 0 : _getFrames2.length; _i3 < _length2; _i3++) {
|
1593 | var frame = _getFrames2[_i3];
|
1594 | result.push(frame);
|
1595 | for (var _i5 = 0, _getAllChildFrames2 = getAllChildFrames(frame), _length4 = null == _getAllChildFrames2 ? 0 : _getAllChildFrames2.length; _i5 < _length4; _i5++) {
|
1596 | var childFrame = _getAllChildFrames2[_i5];
|
1597 | result.push(childFrame);
|
1598 | }
|
1599 | }
|
1600 | return result;
|
1601 | }
|
1602 | function getTop(win) {
|
1603 | if (win) {
|
1604 | try {
|
1605 | if (win.top) return win.top;
|
1606 | } catch (err) {}
|
1607 | if (getParent(win) === win) return win;
|
1608 | try {
|
1609 | if (isAncestorParent(window, win) && window.top) return window.top;
|
1610 | } catch (err) {}
|
1611 | try {
|
1612 | if (isAncestorParent(win, window) && window.top) return window.top;
|
1613 | } catch (err) {}
|
1614 | for (var _i7 = 0, _getAllChildFrames4 = getAllChildFrames(win), _length6 = null == _getAllChildFrames4 ? 0 : _getAllChildFrames4.length; _i7 < _length6; _i7++) {
|
1615 | var frame = _getAllChildFrames4[_i7];
|
1616 | try {
|
1617 | if (frame.top) return frame.top;
|
1618 | } catch (err) {}
|
1619 | if (getParent(frame) === frame) return frame;
|
1620 | }
|
1621 | }
|
1622 | }
|
1623 | function getAllFramesInWindow(win) {
|
1624 | var top = getTop(win);
|
1625 | if (!top) throw new Error("Can not determine top window");
|
1626 | return [].concat(getAllChildFrames(top), [ top ]);
|
1627 | }
|
1628 | var iframeWindows = [], iframeFrames = [];
|
1629 | function isWindowClosed(win) {
|
1630 | var allowMock = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
|
1631 | try {
|
1632 | if (win === window) return !1;
|
1633 | } catch (err) {
|
1634 | return !0;
|
1635 | }
|
1636 | try {
|
1637 | if (!win) return !0;
|
1638 | } catch (err) {
|
1639 | return !0;
|
1640 | }
|
1641 | try {
|
1642 | if (win.closed) return !0;
|
1643 | } catch (err) {
|
1644 | return !err || err.message !== IE_WIN_ACCESS_ERROR;
|
1645 | }
|
1646 | if (allowMock && isSameDomain(win)) try {
|
1647 | if (win.mockclosed) return !0;
|
1648 | } catch (err) {}
|
1649 | try {
|
1650 | if (!win.parent || !win.top) return !0;
|
1651 | } catch (err) {}
|
1652 | var iframeIndex = function(collection, item) {
|
1653 | for (var i = 0; i < collection.length; i++) try {
|
1654 | if (collection[i] === item) return i;
|
1655 | } catch (err) {}
|
1656 | return -1;
|
1657 | }(iframeWindows, win);
|
1658 | if (-1 !== iframeIndex) {
|
1659 | var frame = iframeFrames[iframeIndex];
|
1660 | if (frame && function(frame) {
|
1661 | if (!frame.contentWindow) return !0;
|
1662 | if (!frame.parentNode) return !0;
|
1663 | var doc = frame.ownerDocument;
|
1664 | return !(!doc || !doc.documentElement || doc.documentElement.contains(frame));
|
1665 | }(frame)) return !0;
|
1666 | }
|
1667 | return !1;
|
1668 | }
|
1669 | function getAncestor(win) {
|
1670 | return getOpener(win = win || window) || getParent(win) || void 0;
|
1671 | }
|
1672 | function anyMatch(collection1, collection2) {
|
1673 | for (var _i17 = 0, _length16 = null == collection1 ? 0 : collection1.length; _i17 < _length16; _i17++) for (var item1 = collection1[_i17], _i19 = 0, _length18 = null == collection2 ? 0 : collection2.length; _i19 < _length18; _i19++) if (item1 === collection2[_i19]) return !0;
|
1674 | return !1;
|
1675 | }
|
1676 | function getDistanceFromTop() {
|
1677 | for (var distance = 0, parent = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : window; parent; ) (parent = getParent(parent)) && (distance += 1);
|
1678 | return distance;
|
1679 | }
|
1680 | function getDomainFromUrl(url) {
|
1681 | return url.match(/^(https?|mock|file):\/\//) ? url.split("/").slice(0, 3).join("/") : getDomain();
|
1682 | }
|
1683 | },
|
1684 | "./node_modules/post-robot/src/bridge/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
1685 | "use strict";
|
1686 | Object.defineProperty(__webpack_exports__, "__esModule", {
|
1687 | value: !0
|
1688 | });
|
1689 | var src = __webpack_require__("./node_modules/zalgo-promise/src/index.js"), cross_domain_utils_src = __webpack_require__("./node_modules/cross-domain-utils/src/index.js"), belter_src = __webpack_require__("./node_modules/belter/src/index.js"), conf = __webpack_require__("./node_modules/post-robot/src/conf/index.js"), global = __webpack_require__("./node_modules/post-robot/src/global.js"), tunnelWindows = Object(global.b)("tunnelWindows");
|
1690 | global.a.openTunnelToParent = function(_ref2) {
|
1691 | var name = _ref2.name, source = _ref2.source, canary = _ref2.canary, sendMessage = _ref2.sendMessage, parentWindow = Object(cross_domain_utils_src.getParent)(window);
|
1692 | if (!parentWindow) throw new Error("No parent window found to open tunnel to");
|
1693 | var id = function(_ref) {
|
1694 | var name = _ref.name, source = _ref.source, canary = _ref.canary, sendMessage = _ref.sendMessage;
|
1695 | !function() {
|
1696 | for (var _i2 = 0, _tunnelWindows$keys2 = tunnelWindows.keys(), _length2 = null == _tunnelWindows$keys2 ? 0 : _tunnelWindows$keys2.length; _i2 < _length2; _i2++) {
|
1697 | var key = _tunnelWindows$keys2[_i2], tunnelWindow = tunnelWindows[key];
|
1698 | try {
|
1699 | Object(belter_src.noop)(tunnelWindow.source);
|
1700 | } catch (err) {
|
1701 | tunnelWindows.del(key);
|
1702 | continue;
|
1703 | }
|
1704 | Object(cross_domain_utils_src.isWindowClosed)(tunnelWindow.source) && tunnelWindows.del(key);
|
1705 | }
|
1706 | }();
|
1707 | var id = Object(belter_src.uniqueID)();
|
1708 | tunnelWindows.set(id, {
|
1709 | name: name,
|
1710 | source: source,
|
1711 | canary: canary,
|
1712 | sendMessage: sendMessage
|
1713 | });
|
1714 | return id;
|
1715 | }({
|
1716 | name: name,
|
1717 | source: source,
|
1718 | canary: canary,
|
1719 | sendMessage: sendMessage
|
1720 | });
|
1721 | return global.a.send(parentWindow, conf.d.OPEN_TUNNEL, {
|
1722 | name: name,
|
1723 | sendMessage: function() {
|
1724 | var tunnelWindow = tunnelWindows.get(id);
|
1725 | try {
|
1726 | Object(belter_src.noop)(tunnelWindow && tunnelWindow.source);
|
1727 | } catch (err) {
|
1728 | tunnelWindows.del(id);
|
1729 | return;
|
1730 | }
|
1731 | if (tunnelWindow && tunnelWindow.source && !Object(cross_domain_utils_src.isWindowClosed)(tunnelWindow.source)) {
|
1732 | try {
|
1733 | tunnelWindow.canary();
|
1734 | } catch (err) {
|
1735 | return;
|
1736 | }
|
1737 | tunnelWindow.sendMessage.apply(this, arguments);
|
1738 | }
|
1739 | }
|
1740 | }, {
|
1741 | domain: conf.i
|
1742 | });
|
1743 | };
|
1744 | function needsBridgeForBrowser() {
|
1745 | return !!Object(cross_domain_utils_src.getUserAgent)(window).match(/MSIE|trident|edge\/12|edge\/13/i) || !conf.b.ALLOW_POSTMESSAGE_POPUP;
|
1746 | }
|
1747 | function needsBridgeForWin(win) {
|
1748 | return !Object(cross_domain_utils_src.isSameTopWindow)(window, win);
|
1749 | }
|
1750 | function needsBridgeForDomain(domain, win) {
|
1751 | if (domain) {
|
1752 | if (Object(cross_domain_utils_src.getDomain)() !== Object(cross_domain_utils_src.getDomainFromUrl)(domain)) return !0;
|
1753 | } else if (win && !Object(cross_domain_utils_src.isSameDomain)(win)) return !0;
|
1754 | return !1;
|
1755 | }
|
1756 | function needsBridge(_ref) {
|
1757 | var win = _ref.win, domain = _ref.domain;
|
1758 | return !(!needsBridgeForBrowser() || domain && !needsBridgeForDomain(domain, win) || win && !needsBridgeForWin(win));
|
1759 | }
|
1760 | function getBridgeName(domain) {
|
1761 | var sanitizedDomain = (domain = domain || Object(cross_domain_utils_src.getDomainFromUrl)(domain)).replace(/[^a-zA-Z0-9]+/g, "_");
|
1762 | return conf.a + "_" + sanitizedDomain;
|
1763 | }
|
1764 | function isBridge() {
|
1765 | return Boolean(window.name && window.name === getBridgeName(Object(cross_domain_utils_src.getDomain)()));
|
1766 | }
|
1767 | var documentBodyReady = new src.a(function(resolve) {
|
1768 | if (window.document && window.document.body) return resolve(window.document.body);
|
1769 | var interval = setInterval(function() {
|
1770 | if (window.document && window.document.body) {
|
1771 | clearInterval(interval);
|
1772 | return resolve(window.document.body);
|
1773 | }
|
1774 | }, 10);
|
1775 | }), remoteWindows = Object(global.c)("remoteWindows");
|
1776 | function registerRemoteWindow(win) {
|
1777 | remoteWindows.getOrSet(win, function() {
|
1778 | return new src.a();
|
1779 | });
|
1780 | }
|
1781 | function findRemoteWindow(win) {
|
1782 | var remoteWin = remoteWindows.get(win);
|
1783 | if (!remoteWin) throw new Error("Remote window not found");
|
1784 | return remoteWin;
|
1785 | }
|
1786 | function registerRemoteSendMessage(win, domain, sendMessage) {
|
1787 | findRemoteWindow(win).resolve(function(remoteWin, remoteDomain, message) {
|
1788 | if (remoteWin !== win) throw new Error("Remote window does not match window");
|
1789 | if (!Object(cross_domain_utils_src.matchDomain)(remoteDomain, domain)) throw new Error("Remote domain " + remoteDomain + " does not match domain " + domain);
|
1790 | sendMessage(message);
|
1791 | });
|
1792 | }
|
1793 | function rejectRemoteSendMessage(win, err) {
|
1794 | findRemoteWindow(win).reject(err).catch(belter_src.noop);
|
1795 | }
|
1796 | function sendBridgeMessage(win, domain, message) {
|
1797 | var messagingChild = Object(cross_domain_utils_src.isOpener)(window, win), messagingParent = Object(cross_domain_utils_src.isOpener)(win, window);
|
1798 | if (!messagingChild && !messagingParent) throw new Error("Can only send messages to and from parent and popup windows");
|
1799 | return findRemoteWindow(win).then(function(sendMessage) {
|
1800 | return sendMessage(win, domain, message);
|
1801 | });
|
1802 | }
|
1803 | var awaitRemoteBridgeForWindow = Object(belter_src.weakMapMemoize)(function(win) {
|
1804 | return src.a.try(function() {
|
1805 | try {
|
1806 | var frame = Object(cross_domain_utils_src.getFrameByName)(win, getBridgeName(Object(cross_domain_utils_src.getDomain)()));
|
1807 | if (!frame) return;
|
1808 | return Object(cross_domain_utils_src.isSameDomain)(frame) && frame[conf.j.POSTROBOT] ? frame : new src.a(function(resolve) {
|
1809 | var interval = void 0, timeout = void 0;
|
1810 | interval = setInterval(function() {
|
1811 | if (frame && Object(cross_domain_utils_src.isSameDomain)(frame) && frame[conf.j.POSTROBOT]) {
|
1812 | clearInterval(interval);
|
1813 | clearTimeout(timeout);
|
1814 | return resolve(frame);
|
1815 | }
|
1816 | }, 100);
|
1817 | timeout = setTimeout(function() {
|
1818 | clearInterval(interval);
|
1819 | return resolve();
|
1820 | }, 2e3);
|
1821 | });
|
1822 | } catch (err) {}
|
1823 | });
|
1824 | });
|
1825 | function openTunnelToOpener() {
|
1826 | return src.a.try(function() {
|
1827 | var opener = Object(cross_domain_utils_src.getOpener)(window);
|
1828 | if (opener && needsBridge({
|
1829 | win: opener
|
1830 | })) {
|
1831 | registerRemoteWindow(opener);
|
1832 | return awaitRemoteBridgeForWindow(opener).then(function(bridge) {
|
1833 | return bridge ? window.name ? bridge[conf.j.POSTROBOT].openTunnelToParent({
|
1834 | name: window.name,
|
1835 | source: window,
|
1836 | canary: function() {},
|
1837 | sendMessage: function(message) {
|
1838 | try {
|
1839 | Object(belter_src.noop)(window);
|
1840 | } catch (err) {
|
1841 | return;
|
1842 | }
|
1843 | if (window && !window.closed) try {
|
1844 | global.a.receiveMessage({
|
1845 | data: message,
|
1846 | origin: this.origin,
|
1847 | source: this.source
|
1848 | });
|
1849 | } catch (err) {
|
1850 | src.a.reject(err);
|
1851 | }
|
1852 | }
|
1853 | }).then(function(_ref) {
|
1854 | var source = _ref.source, origin = _ref.origin, data = _ref.data;
|
1855 | if (source !== opener) throw new Error("Source does not match opener");
|
1856 | registerRemoteSendMessage(source, origin, data.sendMessage);
|
1857 | }).catch(function(err) {
|
1858 | rejectRemoteSendMessage(opener, err);
|
1859 | throw err;
|
1860 | }) : rejectRemoteSendMessage(opener, new Error("Can not register with opener: window does not have a name")) : rejectRemoteSendMessage(opener, new Error("Can not register with opener: no bridge found in opener"));
|
1861 | });
|
1862 | }
|
1863 | });
|
1864 | }
|
1865 | var lib = __webpack_require__("./node_modules/post-robot/src/lib/index.js"), bridges = Object(global.b)("bridges"), bridgeFrames = Object(global.b)("bridgeFrames"), popupWindowsByName = Object(global.b)("popupWindowsByName"), popupWindowsByWin = Object(global.c)("popupWindowsByWin");
|
1866 | function hasBridge(url, domain) {
|
1867 | return bridges.has(domain || Object(cross_domain_utils_src.getDomainFromUrl)(url));
|
1868 | }
|
1869 | function openBridge(url, domain) {
|
1870 | domain = domain || Object(cross_domain_utils_src.getDomainFromUrl)(url);
|
1871 | return bridges.getOrSet(domain, function() {
|
1872 | return src.a.try(function() {
|
1873 | if (Object(cross_domain_utils_src.getDomain)() === domain) throw new Error("Can not open bridge on the same domain as current domain: " + domain);
|
1874 | var name = getBridgeName(domain);
|
1875 | if (Object(cross_domain_utils_src.getFrameByName)(window, name)) throw new Error("Frame with name " + name + " already exists on page");
|
1876 | var iframe = function(name, url) {
|
1877 | var iframe = document.createElement("iframe");
|
1878 | iframe.setAttribute("name", name);
|
1879 | iframe.setAttribute("id", name);
|
1880 | iframe.setAttribute("style", "display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;");
|
1881 | iframe.setAttribute("frameborder", "0");
|
1882 | iframe.setAttribute("border", "0");
|
1883 | iframe.setAttribute("scrolling", "no");
|
1884 | iframe.setAttribute("allowTransparency", "true");
|
1885 | iframe.setAttribute("tabindex", "-1");
|
1886 | iframe.setAttribute("hidden", "true");
|
1887 | iframe.setAttribute("title", "");
|
1888 | iframe.setAttribute("role", "presentation");
|
1889 | iframe.src = url;
|
1890 | return iframe;
|
1891 | }(name, url);
|
1892 | bridgeFrames.set(domain, iframe);
|
1893 | return documentBodyReady.then(function(body) {
|
1894 | body.appendChild(iframe);
|
1895 | var bridge = iframe.contentWindow;
|
1896 | !function(source, domain) {
|
1897 | global.a.on(conf.d.OPEN_TUNNEL, {
|
1898 | window: source,
|
1899 | domain: domain
|
1900 | }, function(_ref) {
|
1901 | var origin = _ref.origin, data = _ref.data;
|
1902 | if (origin !== domain) throw new Error("Domain " + domain + " does not match origin " + origin);
|
1903 | if (!data.name) throw new Error("Register window expected to be passed window name");
|
1904 | if (!data.sendMessage) throw new Error("Register window expected to be passed sendMessage method");
|
1905 | if (!popupWindowsByName.has(data.name)) throw new Error("Window with name " + data.name + " does not exist, or was not opened by this window");
|
1906 | if (!popupWindowsByName.get(data.name).domain) throw new Error("We do not have a registered domain for window " + data.name);
|
1907 | if (popupWindowsByName.get(data.name).domain !== origin) throw new Error("Message origin " + origin + " does not matched registered window origin " + popupWindowsByName.get(data.name).domain);
|
1908 | registerRemoteSendMessage(popupWindowsByName.get(data.name).win, domain, data.sendMessage);
|
1909 | return {
|
1910 | sendMessage: function(message) {
|
1911 | if (window && !window.closed) {
|
1912 | var winDetails = popupWindowsByName.get(data.name);
|
1913 | if (winDetails) try {
|
1914 | global.a.receiveMessage({
|
1915 | data: message,
|
1916 | origin: winDetails.domain,
|
1917 | source: winDetails.win
|
1918 | });
|
1919 | } catch (err) {
|
1920 | src.a.reject(err);
|
1921 | }
|
1922 | }
|
1923 | }
|
1924 | };
|
1925 | });
|
1926 | }(bridge, domain);
|
1927 | return new src.a(function(resolve, reject) {
|
1928 | iframe.onload = resolve;
|
1929 | iframe.onerror = reject;
|
1930 | }).then(function() {
|
1931 | return Object(lib.a)(bridge, conf.b.BRIDGE_TIMEOUT, "Bridge " + url);
|
1932 | }).then(function() {
|
1933 | return bridge;
|
1934 | });
|
1935 | });
|
1936 | });
|
1937 | });
|
1938 | }
|
1939 | var windowOpen = window.open;
|
1940 | window.open = function(url, name, options, last) {
|
1941 | var domain = url;
|
1942 | if (url && 0 === url.indexOf(conf.f.MOCK)) {
|
1943 | var _url$split = url.split("|");
|
1944 | domain = _url$split[0];
|
1945 | url = _url$split[1];
|
1946 | }
|
1947 | domain && (domain = Object(cross_domain_utils_src.getDomainFromUrl)(domain));
|
1948 | var win = windowOpen.call(this, url, name, options, last);
|
1949 | if (!win) return win;
|
1950 | url && registerRemoteWindow(win);
|
1951 | for (var _i2 = 0, _popupWindowsByName$k2 = popupWindowsByName.keys(), _length2 = null == _popupWindowsByName$k2 ? 0 : _popupWindowsByName$k2.length; _i2 < _length2; _i2++) {
|
1952 | var winName = _popupWindowsByName$k2[_i2];
|
1953 | Object(cross_domain_utils_src.isWindowClosed)(popupWindowsByName.get(winName).win) && popupWindowsByName.del(winName);
|
1954 | }
|
1955 | if (name && win) {
|
1956 | var winOptions = popupWindowsByWin.getOrSet(win, function() {
|
1957 | return {};
|
1958 | });
|
1959 | winOptions.name = winOptions.name || name;
|
1960 | winOptions.win = winOptions.win || win;
|
1961 | winOptions.domain = winOptions.domain || domain;
|
1962 | popupWindowsByWin.set(win, winOptions);
|
1963 | popupWindowsByName.set(name, winOptions);
|
1964 | }
|
1965 | return win;
|
1966 | };
|
1967 | function linkUrl(win, url) {
|
1968 | if (popupWindowsByWin.has(win)) {
|
1969 | popupWindowsByWin.get(win).domain = Object(cross_domain_utils_src.getDomainFromUrl)(url);
|
1970 | registerRemoteWindow(win);
|
1971 | }
|
1972 | }
|
1973 | function destroyBridges() {
|
1974 | for (var _i4 = 0, _bridgeFrames$keys2 = bridgeFrames.keys(), _length4 = null == _bridgeFrames$keys2 ? 0 : _bridgeFrames$keys2.length; _i4 < _length4; _i4++) {
|
1975 | var domain = _bridgeFrames$keys2[_i4], frame = bridgeFrames.get(domain);
|
1976 | frame && frame.parentNode && frame.parentNode.removeChild(frame);
|
1977 | }
|
1978 | bridgeFrames.reset();
|
1979 | bridges.reset();
|
1980 | }
|
1981 | __webpack_require__.d(__webpack_exports__, "openTunnelToOpener", function() {
|
1982 | return openTunnelToOpener;
|
1983 | });
|
1984 | __webpack_require__.d(__webpack_exports__, "needsBridgeForBrowser", function() {
|
1985 | return needsBridgeForBrowser;
|
1986 | });
|
1987 | __webpack_require__.d(__webpack_exports__, "needsBridgeForWin", function() {
|
1988 | return needsBridgeForWin;
|
1989 | });
|
1990 | __webpack_require__.d(__webpack_exports__, "needsBridgeForDomain", function() {
|
1991 | return needsBridgeForDomain;
|
1992 | });
|
1993 | __webpack_require__.d(__webpack_exports__, "needsBridge", function() {
|
1994 | return needsBridge;
|
1995 | });
|
1996 | __webpack_require__.d(__webpack_exports__, "getBridgeName", function() {
|
1997 | return getBridgeName;
|
1998 | });
|
1999 | __webpack_require__.d(__webpack_exports__, "isBridge", function() {
|
2000 | return isBridge;
|
2001 | });
|
2002 | __webpack_require__.d(__webpack_exports__, "documentBodyReady", function() {
|
2003 | return documentBodyReady;
|
2004 | });
|
2005 | __webpack_require__.d(__webpack_exports__, "registerRemoteWindow", function() {
|
2006 | return registerRemoteWindow;
|
2007 | });
|
2008 | __webpack_require__.d(__webpack_exports__, "findRemoteWindow", function() {
|
2009 | return findRemoteWindow;
|
2010 | });
|
2011 | __webpack_require__.d(__webpack_exports__, "registerRemoteSendMessage", function() {
|
2012 | return registerRemoteSendMessage;
|
2013 | });
|
2014 | __webpack_require__.d(__webpack_exports__, "rejectRemoteSendMessage", function() {
|
2015 | return rejectRemoteSendMessage;
|
2016 | });
|
2017 | __webpack_require__.d(__webpack_exports__, "sendBridgeMessage", function() {
|
2018 | return sendBridgeMessage;
|
2019 | });
|
2020 | __webpack_require__.d(__webpack_exports__, "hasBridge", function() {
|
2021 | return hasBridge;
|
2022 | });
|
2023 | __webpack_require__.d(__webpack_exports__, "openBridge", function() {
|
2024 | return openBridge;
|
2025 | });
|
2026 | __webpack_require__.d(__webpack_exports__, "linkUrl", function() {
|
2027 | return linkUrl;
|
2028 | });
|
2029 | __webpack_require__.d(__webpack_exports__, "destroyBridges", function() {
|
2030 | return destroyBridges;
|
2031 | });
|
2032 | },
|
2033 | "./node_modules/post-robot/src/bridge/interface.js": function(module, __webpack_exports__, __webpack_require__) {
|
2034 | "use strict";
|
2035 | Object.defineProperty(__webpack_exports__, "__esModule", {
|
2036 | value: !0
|
2037 | });
|
2038 | var __WEBPACK_IMPORTED_MODULE_0__index__ = __webpack_require__("./node_modules/post-robot/src/bridge/index.js");
|
2039 | __webpack_require__.d(__webpack_exports__, "openBridge", function() {
|
2040 | return __WEBPACK_IMPORTED_MODULE_0__index__.openBridge;
|
2041 | });
|
2042 | __webpack_require__.d(__webpack_exports__, "linkUrl", function() {
|
2043 | return __WEBPACK_IMPORTED_MODULE_0__index__.linkUrl;
|
2044 | });
|
2045 | __webpack_require__.d(__webpack_exports__, "isBridge", function() {
|
2046 | return __WEBPACK_IMPORTED_MODULE_0__index__.isBridge;
|
2047 | });
|
2048 | __webpack_require__.d(__webpack_exports__, "needsBridge", function() {
|
2049 | return __WEBPACK_IMPORTED_MODULE_0__index__.needsBridge;
|
2050 | });
|
2051 | __webpack_require__.d(__webpack_exports__, "needsBridgeForBrowser", function() {
|
2052 | return __WEBPACK_IMPORTED_MODULE_0__index__.needsBridgeForBrowser;
|
2053 | });
|
2054 | __webpack_require__.d(__webpack_exports__, "hasBridge", function() {
|
2055 | return __WEBPACK_IMPORTED_MODULE_0__index__.hasBridge;
|
2056 | });
|
2057 | __webpack_require__.d(__webpack_exports__, "needsBridgeForWin", function() {
|
2058 | return __WEBPACK_IMPORTED_MODULE_0__index__.needsBridgeForWin;
|
2059 | });
|
2060 | __webpack_require__.d(__webpack_exports__, "needsBridgeForDomain", function() {
|
2061 | return __WEBPACK_IMPORTED_MODULE_0__index__.needsBridgeForDomain;
|
2062 | });
|
2063 | __webpack_require__.d(__webpack_exports__, "openTunnelToOpener", function() {
|
2064 | return __WEBPACK_IMPORTED_MODULE_0__index__.openTunnelToOpener;
|
2065 | });
|
2066 | __webpack_require__.d(__webpack_exports__, "destroyBridges", function() {
|
2067 | return __WEBPACK_IMPORTED_MODULE_0__index__.destroyBridges;
|
2068 | });
|
2069 | },
|
2070 | "./node_modules/post-robot/src/compat/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
2071 | "use strict";
|
2072 | Object.defineProperty(__webpack_exports__, "__esModule", {
|
2073 | value: !0
|
2074 | });
|
2075 | var src = __webpack_require__("./node_modules/cross-domain-utils/src/index.js"), conf = __webpack_require__("./node_modules/post-robot/src/conf/index.js");
|
2076 | function emulateIERestrictions(sourceWindow, targetWindow) {
|
2077 | if (!conf.b.ALLOW_POSTMESSAGE_POPUP && !1 === Object(src.isSameTopWindow)(sourceWindow, targetWindow)) throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)");
|
2078 | }
|
2079 | __webpack_require__.d(__webpack_exports__, "emulateIERestrictions", function() {
|
2080 | return emulateIERestrictions;
|
2081 | });
|
2082 | },
|
2083 | "./node_modules/post-robot/src/conf/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
2084 | "use strict";
|
2085 | var _ALLOWED_POST_MESSAGE, MESSAGE_TYPE = {
|
2086 | REQUEST: "postrobot_message_request",
|
2087 | RESPONSE: "postrobot_message_response",
|
2088 | ACK: "postrobot_message_ack"
|
2089 | }, MESSAGE_ACK = {
|
2090 | SUCCESS: "success",
|
2091 | ERROR: "error"
|
2092 | }, MESSAGE_NAME = {
|
2093 | METHOD: "postrobot_method",
|
2094 | HELLO: "postrobot_hello",
|
2095 | OPEN_TUNNEL: "postrobot_open_tunnel"
|
2096 | }, WINDOW_PROP = {
|
2097 | POSTROBOT: "__postRobot__"
|
2098 | }, SEND_STRATEGY = {
|
2099 | POST_MESSAGE: "postrobot_post_message",
|
2100 | BRIDGE: "postrobot_bridge",
|
2101 | GLOBAL: "postrobot_global"
|
2102 | }, PROTOCOL = {
|
2103 | MOCK: "mock:",
|
2104 | FILE: "file:"
|
2105 | }, SERIALIZATION_TYPE = {
|
2106 | CROSS_DOMAIN_ZALGO_PROMISE: "cross_domain_zalgo_promise",
|
2107 | CROSS_DOMAIN_FUNCTION: "cross_domain_function",
|
2108 | CROSS_DOMAIN_WINDOW: "cross_domain_window"
|
2109 | }, CONFIG = {
|
2110 | ALLOW_POSTMESSAGE_POPUP: !("__ALLOW_POSTMESSAGE_POPUP__" in window) || window.__ALLOW_POSTMESSAGE_POPUP__,
|
2111 | BRIDGE_TIMEOUT: 5e3,
|
2112 | CHILD_WINDOW_TIMEOUT: 5e3,
|
2113 | ACK_TIMEOUT: 2e3,
|
2114 | ACK_TIMEOUT_KNOWN: 1e4,
|
2115 | RES_TIMEOUT: -1,
|
2116 | ALLOWED_POST_MESSAGE_METHODS: (_ALLOWED_POST_MESSAGE = {}, _ALLOWED_POST_MESSAGE[SEND_STRATEGY.POST_MESSAGE] = !0,
|
2117 | _ALLOWED_POST_MESSAGE[SEND_STRATEGY.BRIDGE] = !0, _ALLOWED_POST_MESSAGE[SEND_STRATEGY.GLOBAL] = !0,
|
2118 | _ALLOWED_POST_MESSAGE)
|
2119 | };
|
2120 | 0 === window.location.href.indexOf(PROTOCOL.FILE) && (CONFIG.ALLOW_POSTMESSAGE_POPUP = !0);
|
2121 | __webpack_require__.d(__webpack_exports__, "b", function() {
|
2122 | return CONFIG;
|
2123 | });
|
2124 | __webpack_require__.d(__webpack_exports__, "e", function() {
|
2125 | return MESSAGE_TYPE;
|
2126 | });
|
2127 | __webpack_require__.d(__webpack_exports__, "c", function() {
|
2128 | return MESSAGE_ACK;
|
2129 | });
|
2130 | __webpack_require__.d(__webpack_exports__, "d", function() {
|
2131 | return MESSAGE_NAME;
|
2132 | });
|
2133 | __webpack_require__.d(__webpack_exports__, "j", function() {
|
2134 | return WINDOW_PROP;
|
2135 | });
|
2136 | __webpack_require__.d(__webpack_exports__, "g", function() {
|
2137 | return SEND_STRATEGY;
|
2138 | });
|
2139 | __webpack_require__.d(__webpack_exports__, "f", function() {
|
2140 | return PROTOCOL;
|
2141 | });
|
2142 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2143 | return "__postrobot_bridge__";
|
2144 | });
|
2145 | __webpack_require__.d(__webpack_exports__, !1, function() {
|
2146 | return "__postrobot_proxy__";
|
2147 | });
|
2148 | __webpack_require__.d(__webpack_exports__, "i", function() {
|
2149 | return "*";
|
2150 | });
|
2151 | __webpack_require__.d(__webpack_exports__, "h", function() {
|
2152 | return SERIALIZATION_TYPE;
|
2153 | });
|
2154 | },
|
2155 | "./node_modules/post-robot/src/global.js": function(module, __webpack_exports__, __webpack_require__) {
|
2156 | "use strict";
|
2157 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2158 | return global;
|
2159 | });
|
2160 | __webpack_exports__.c = function(key) {
|
2161 | var defStore = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : getObj;
|
2162 | function getStore(win) {
|
2163 | return winStore.getOrSet(win, defStore);
|
2164 | }
|
2165 | return {
|
2166 | has: function(win) {
|
2167 | return getStore(win).hasOwnProperty(key);
|
2168 | },
|
2169 | get: function(win, defVal) {
|
2170 | var store = getStore(win);
|
2171 | return store.hasOwnProperty(key) ? store[key] : defVal;
|
2172 | },
|
2173 | set: function(win, val) {
|
2174 | getStore(win)[key] = val;
|
2175 | return val;
|
2176 | },
|
2177 | del: function(win) {
|
2178 | delete getStore(win)[key];
|
2179 | },
|
2180 | getOrSet: function(win, getter) {
|
2181 | var store = getStore(win);
|
2182 | if (store.hasOwnProperty(key)) return store[key];
|
2183 | var val = getter();
|
2184 | store[key] = val;
|
2185 | return val;
|
2186 | }
|
2187 | };
|
2188 | };
|
2189 | __webpack_exports__.b = function(key) {
|
2190 | var defStore = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : getObj, store = Object(__WEBPACK_IMPORTED_MODULE_2_belter_src__.getOrSet)(global, key, defStore);
|
2191 | return {
|
2192 | has: function(storeKey) {
|
2193 | return store.hasOwnProperty(storeKey);
|
2194 | },
|
2195 | get: function(storeKey, defVal) {
|
2196 | return store.hasOwnProperty(storeKey) ? store[storeKey] : defVal;
|
2197 | },
|
2198 | set: function(storeKey, val) {
|
2199 | store[storeKey] = val;
|
2200 | return val;
|
2201 | },
|
2202 | del: function(storeKey) {
|
2203 | delete store[storeKey];
|
2204 | },
|
2205 | getOrSet: function(storeKey, getter) {
|
2206 | if (store.hasOwnProperty(storeKey)) return store[storeKey];
|
2207 | var val = getter();
|
2208 | store[storeKey] = val;
|
2209 | return val;
|
2210 | },
|
2211 | reset: function() {
|
2212 | store = defStore();
|
2213 | },
|
2214 | keys: function() {
|
2215 | return Object.keys(store);
|
2216 | }
|
2217 | };
|
2218 | };
|
2219 | __webpack_require__("./node_modules/cross-domain-utils/src/index.js");
|
2220 | var __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__ = __webpack_require__("./node_modules/cross-domain-safe-weakmap/src/index.js"), __WEBPACK_IMPORTED_MODULE_2_belter_src__ = __webpack_require__("./node_modules/belter/src/index.js"), __WEBPACK_IMPORTED_MODULE_3__conf__ = __webpack_require__("./node_modules/post-robot/src/conf/index.js"), global = window[__WEBPACK_IMPORTED_MODULE_3__conf__.j.POSTROBOT] = window[__WEBPACK_IMPORTED_MODULE_3__conf__.j.POSTROBOT] || {}, winStore = global.windowStore = global.windowStore || new __WEBPACK_IMPORTED_MODULE_1_cross_domain_safe_weakmap_src__.a(), getObj = function() {
|
2221 | return {};
|
2222 | };
|
2223 | },
|
2224 | "./node_modules/post-robot/src/lib/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
2225 | "use strict";
|
2226 | var src = __webpack_require__("./node_modules/cross-domain-utils/src/index.js"), zalgo_promise_src = __webpack_require__("./node_modules/zalgo-promise/src/index.js"), belter_src = __webpack_require__("./node_modules/belter/src/index.js"), conf = __webpack_require__("./node_modules/post-robot/src/conf/index.js"), global = __webpack_require__("./node_modules/post-robot/src/global.js");
|
2227 | global.a.instanceID = global.a.instanceID || Object(belter_src.uniqueID)();
|
2228 | var helloPromises = Object(global.c)("helloPromises");
|
2229 | function getHelloPromise(win) {
|
2230 | return helloPromises.getOrSet(win, function() {
|
2231 | return new zalgo_promise_src.a();
|
2232 | });
|
2233 | }
|
2234 | var listenForHello = Object(belter_src.once)(function() {
|
2235 | global.a.on(conf.d.HELLO, {
|
2236 | domain: conf.i
|
2237 | }, function(_ref) {
|
2238 | var source = _ref.source, origin = _ref.origin;
|
2239 | getHelloPromise(source).resolve({
|
2240 | win: source,
|
2241 | domain: origin
|
2242 | });
|
2243 | return {
|
2244 | instanceID: global.a.instanceID
|
2245 | };
|
2246 | });
|
2247 | });
|
2248 | function sayHello(win) {
|
2249 | return global.a.send(win, conf.d.HELLO, {
|
2250 | instanceID: global.a.instanceID
|
2251 | }, {
|
2252 | domain: conf.i,
|
2253 | timeout: -1
|
2254 | }).then(function(_ref2) {
|
2255 | var origin = _ref2.origin, instanceID = _ref2.data.instanceID;
|
2256 | getHelloPromise(win).resolve({
|
2257 | win: win,
|
2258 | domain: origin
|
2259 | });
|
2260 | return {
|
2261 | win: win,
|
2262 | domain: origin,
|
2263 | instanceID: instanceID
|
2264 | };
|
2265 | });
|
2266 | }
|
2267 | var getWindowInstanceID = Object(belter_src.weakMapMemoizePromise)(function(win) {
|
2268 | return sayHello(win).then(function(_ref3) {
|
2269 | return _ref3.instanceID;
|
2270 | });
|
2271 | });
|
2272 | function initHello() {
|
2273 | listenForHello();
|
2274 | var parent = Object(src.getAncestor)();
|
2275 | parent && sayHello(parent).catch(belter_src.noop);
|
2276 | }
|
2277 | function awaitWindowHello(win) {
|
2278 | var timeout = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 5e3, name = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "Window", promise = getHelloPromise(win);
|
2279 | -1 !== timeout && (promise = promise.timeout(timeout, new Error(name + " did not load after " + timeout + "ms")));
|
2280 | return promise;
|
2281 | }
|
2282 | function needsGlobalMessagingForBrowser() {
|
2283 | return !!Object(src.getUserAgent)(window).match(/MSIE|trident|edge\/12|edge\/13/i) || !conf.b.ALLOW_POSTMESSAGE_POPUP;
|
2284 | }
|
2285 | var knownWindows = Object(global.c)("knownWindows");
|
2286 | function markWindowKnown(win) {
|
2287 | knownWindows.set(win, !0);
|
2288 | }
|
2289 | function isWindowKnown(win) {
|
2290 | return knownWindows.get(win, !1);
|
2291 | }
|
2292 | __webpack_require__.d(__webpack_exports__, "g", function() {
|
2293 | return sayHello;
|
2294 | });
|
2295 | __webpack_require__.d(__webpack_exports__, "b", function() {
|
2296 | return getWindowInstanceID;
|
2297 | });
|
2298 | __webpack_require__.d(__webpack_exports__, "c", function() {
|
2299 | return initHello;
|
2300 | });
|
2301 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2302 | return awaitWindowHello;
|
2303 | });
|
2304 | __webpack_require__.d(__webpack_exports__, "f", function() {
|
2305 | return needsGlobalMessagingForBrowser;
|
2306 | });
|
2307 | __webpack_require__.d(__webpack_exports__, "e", function() {
|
2308 | return markWindowKnown;
|
2309 | });
|
2310 | __webpack_require__.d(__webpack_exports__, "d", function() {
|
2311 | return isWindowKnown;
|
2312 | });
|
2313 | },
|
2314 | "./node_modules/zalgo-promise/src/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
2315 | "use strict";
|
2316 | function utils_isPromise(item) {
|
2317 | try {
|
2318 | if (!item) return !1;
|
2319 | if ("undefined" != typeof Promise && item instanceof Promise) return !0;
|
2320 | if ("undefined" != typeof window && window.Window && item instanceof window.Window) return !1;
|
2321 | if ("undefined" != typeof window && window.constructor && item instanceof window.constructor) return !1;
|
2322 | var _toString = {}.toString;
|
2323 | if (_toString) {
|
2324 | var name = _toString.call(item);
|
2325 | if ("[object Window]" === name || "[object global]" === name || "[object DOMWindow]" === name) return !1;
|
2326 | }
|
2327 | if ("function" == typeof item.then) return !0;
|
2328 | } catch (err) {
|
2329 | return !1;
|
2330 | }
|
2331 | return !1;
|
2332 | }
|
2333 | function getGlobal() {
|
2334 | var glob = void 0;
|
2335 | if ("undefined" != typeof window) glob = window; else {
|
2336 | if ("undefined" == typeof window) throw new TypeError("Can not find global");
|
2337 | glob = window;
|
2338 | }
|
2339 | var zalgoGlobal = glob.__zalgopromise__ = glob.__zalgopromise__ || {};
|
2340 | zalgoGlobal.flushPromises = zalgoGlobal.flushPromises || [];
|
2341 | zalgoGlobal.activeCount = zalgoGlobal.activeCount || 0;
|
2342 | zalgoGlobal.possiblyUnhandledPromiseHandlers = zalgoGlobal.possiblyUnhandledPromiseHandlers || [];
|
2343 | zalgoGlobal.dispatchedErrors = zalgoGlobal.dispatchedErrors || [];
|
2344 | return zalgoGlobal;
|
2345 | }
|
2346 | var promise_ZalgoPromise = function() {
|
2347 | function ZalgoPromise(handler) {
|
2348 | var _this = this;
|
2349 | !function(instance, Constructor) {
|
2350 | if (!(instance instanceof ZalgoPromise)) throw new TypeError("Cannot call a class as a function");
|
2351 | }(this);
|
2352 | this.resolved = !1;
|
2353 | this.rejected = !1;
|
2354 | this.errorHandled = !1;
|
2355 | this.handlers = [];
|
2356 | if (handler) {
|
2357 | var _result = void 0, _error = void 0, resolved = !1, rejected = !1, isAsync = !1;
|
2358 | try {
|
2359 | handler(function(res) {
|
2360 | if (isAsync) _this.resolve(res); else {
|
2361 | resolved = !0;
|
2362 | _result = res;
|
2363 | }
|
2364 | }, function(err) {
|
2365 | if (isAsync) _this.reject(err); else {
|
2366 | rejected = !0;
|
2367 | _error = err;
|
2368 | }
|
2369 | });
|
2370 | } catch (err) {
|
2371 | this.reject(err);
|
2372 | return;
|
2373 | }
|
2374 | isAsync = !0;
|
2375 | resolved ? this.resolve(_result) : rejected && this.reject(_error);
|
2376 | }
|
2377 | }
|
2378 | ZalgoPromise.prototype.resolve = function(result) {
|
2379 | if (this.resolved || this.rejected) return this;
|
2380 | if (utils_isPromise(result)) throw new Error("Can not resolve promise with another promise");
|
2381 | this.resolved = !0;
|
2382 | this.value = result;
|
2383 | this.dispatch();
|
2384 | return this;
|
2385 | };
|
2386 | ZalgoPromise.prototype.reject = function(error) {
|
2387 | var _this2 = this;
|
2388 | if (this.resolved || this.rejected) return this;
|
2389 | if (utils_isPromise(error)) throw new Error("Can not reject promise with another promise");
|
2390 | if (!error) {
|
2391 | var _err = error && "function" == typeof error.toString ? error.toString() : Object.prototype.toString.call(error);
|
2392 | error = new Error("Expected reject to be called with Error, got " + _err);
|
2393 | }
|
2394 | this.rejected = !0;
|
2395 | this.error = error;
|
2396 | this.errorHandled || setTimeout(function() {
|
2397 | _this2.errorHandled || function(err, promise) {
|
2398 | if (-1 === getGlobal().dispatchedErrors.indexOf(err)) {
|
2399 | getGlobal().dispatchedErrors.push(err);
|
2400 | setTimeout(function() {
|
2401 | throw err;
|
2402 | }, 1);
|
2403 | for (var j = 0; j < getGlobal().possiblyUnhandledPromiseHandlers.length; j++) getGlobal().possiblyUnhandledPromiseHandlers[j](err, promise);
|
2404 | }
|
2405 | }(error, _this2);
|
2406 | }, 1);
|
2407 | this.dispatch();
|
2408 | return this;
|
2409 | };
|
2410 | ZalgoPromise.prototype.asyncReject = function(error) {
|
2411 | this.errorHandled = !0;
|
2412 | this.reject(error);
|
2413 | };
|
2414 | ZalgoPromise.prototype.dispatch = function() {
|
2415 | var _this3 = this, dispatching = this.dispatching, resolved = this.resolved, rejected = this.rejected, handlers = this.handlers;
|
2416 | if (!dispatching && (resolved || rejected)) {
|
2417 | this.dispatching = !0;
|
2418 | getGlobal().activeCount += 1;
|
2419 | for (var _loop = function(i) {
|
2420 | var _handlers$i = handlers[i], onSuccess = _handlers$i.onSuccess, onError = _handlers$i.onError, promise = _handlers$i.promise, result = void 0;
|
2421 | if (resolved) try {
|
2422 | result = onSuccess ? onSuccess(_this3.value) : _this3.value;
|
2423 | } catch (err) {
|
2424 | promise.reject(err);
|
2425 | return "continue";
|
2426 | } else if (rejected) {
|
2427 | if (!onError) {
|
2428 | promise.reject(_this3.error);
|
2429 | return "continue";
|
2430 | }
|
2431 | try {
|
2432 | result = onError(_this3.error);
|
2433 | } catch (err) {
|
2434 | promise.reject(err);
|
2435 | return "continue";
|
2436 | }
|
2437 | }
|
2438 | if (result instanceof ZalgoPromise && (result.resolved || result.rejected)) {
|
2439 | result.resolved ? promise.resolve(result.value) : promise.reject(result.error);
|
2440 | result.errorHandled = !0;
|
2441 | } else utils_isPromise(result) ? result instanceof ZalgoPromise && (result.resolved || result.rejected) ? result.resolved ? promise.resolve(result.value) : promise.reject(result.error) : result.then(function(res) {
|
2442 | promise.resolve(res);
|
2443 | }, function(err) {
|
2444 | promise.reject(err);
|
2445 | }) : promise.resolve(result);
|
2446 | }, i = 0; i < handlers.length; i++) _loop(i);
|
2447 | handlers.length = 0;
|
2448 | this.dispatching = !1;
|
2449 | getGlobal().activeCount -= 1;
|
2450 | 0 === getGlobal().activeCount && ZalgoPromise.flushQueue();
|
2451 | }
|
2452 | };
|
2453 | ZalgoPromise.prototype.then = function(onSuccess, onError) {
|
2454 | if (onSuccess && "function" != typeof onSuccess && !onSuccess.call) throw new Error("Promise.then expected a function for success handler");
|
2455 | if (onError && "function" != typeof onError && !onError.call) throw new Error("Promise.then expected a function for error handler");
|
2456 | var promise = new ZalgoPromise();
|
2457 | this.handlers.push({
|
2458 | promise: promise,
|
2459 | onSuccess: onSuccess,
|
2460 | onError: onError
|
2461 | });
|
2462 | this.errorHandled = !0;
|
2463 | this.dispatch();
|
2464 | return promise;
|
2465 | };
|
2466 | ZalgoPromise.prototype.catch = function(onError) {
|
2467 | return this.then(void 0, onError);
|
2468 | };
|
2469 | ZalgoPromise.prototype.finally = function(onFinally) {
|
2470 | if (onFinally && "function" != typeof onFinally && !onFinally.call) throw new Error("Promise.finally expected a function");
|
2471 | return this.then(function(result) {
|
2472 | return ZalgoPromise.try(onFinally).then(function() {
|
2473 | return result;
|
2474 | });
|
2475 | }, function(err) {
|
2476 | return ZalgoPromise.try(onFinally).then(function() {
|
2477 | throw err;
|
2478 | });
|
2479 | });
|
2480 | };
|
2481 | ZalgoPromise.prototype.timeout = function(time, err) {
|
2482 | var _this4 = this;
|
2483 | if (this.resolved || this.rejected) return this;
|
2484 | var timeout = setTimeout(function() {
|
2485 | _this4.resolved || _this4.rejected || _this4.reject(err || new Error("Promise timed out after " + time + "ms"));
|
2486 | }, time);
|
2487 | return this.then(function(result) {
|
2488 | clearTimeout(timeout);
|
2489 | return result;
|
2490 | });
|
2491 | };
|
2492 | ZalgoPromise.prototype.toPromise = function() {
|
2493 | if ("undefined" == typeof Promise) throw new TypeError("Could not find Promise");
|
2494 | return Promise.resolve(this);
|
2495 | };
|
2496 | ZalgoPromise.resolve = function(value) {
|
2497 | return value instanceof ZalgoPromise ? value : utils_isPromise(value) ? new ZalgoPromise(function(resolve, reject) {
|
2498 | return value.then(resolve, reject);
|
2499 | }) : new ZalgoPromise().resolve(value);
|
2500 | };
|
2501 | ZalgoPromise.reject = function(error) {
|
2502 | return new ZalgoPromise().reject(error);
|
2503 | };
|
2504 | ZalgoPromise.all = function(promises) {
|
2505 | var promise = new ZalgoPromise(), count = promises.length, results = [];
|
2506 | if (!count) {
|
2507 | promise.resolve(results);
|
2508 | return promise;
|
2509 | }
|
2510 | for (var _loop2 = function(i) {
|
2511 | var prom = promises[i];
|
2512 | if (prom instanceof ZalgoPromise) {
|
2513 | if (prom.resolved) {
|
2514 | results[i] = prom.value;
|
2515 | count -= 1;
|
2516 | return "continue";
|
2517 | }
|
2518 | } else if (!utils_isPromise(prom)) {
|
2519 | results[i] = prom;
|
2520 | count -= 1;
|
2521 | return "continue";
|
2522 | }
|
2523 | ZalgoPromise.resolve(prom).then(function(result) {
|
2524 | results[i] = result;
|
2525 | 0 == (count -= 1) && promise.resolve(results);
|
2526 | }, function(err) {
|
2527 | promise.reject(err);
|
2528 | });
|
2529 | }, i = 0; i < promises.length; i++) _loop2(i);
|
2530 | 0 === count && promise.resolve(results);
|
2531 | return promise;
|
2532 | };
|
2533 | ZalgoPromise.hash = function(promises) {
|
2534 | var result = {};
|
2535 | return ZalgoPromise.all(Object.keys(promises).map(function(key) {
|
2536 | return ZalgoPromise.resolve(promises[key]).then(function(value) {
|
2537 | result[key] = value;
|
2538 | });
|
2539 | })).then(function() {
|
2540 | return result;
|
2541 | });
|
2542 | };
|
2543 | ZalgoPromise.map = function(items, method) {
|
2544 | return ZalgoPromise.all(items.map(method));
|
2545 | };
|
2546 | ZalgoPromise.onPossiblyUnhandledException = function(handler) {
|
2547 | return function(handler) {
|
2548 | getGlobal().possiblyUnhandledPromiseHandlers.push(handler);
|
2549 | return {
|
2550 | cancel: function() {
|
2551 | getGlobal().possiblyUnhandledPromiseHandlers.splice(getGlobal().possiblyUnhandledPromiseHandlers.indexOf(handler), 1);
|
2552 | }
|
2553 | };
|
2554 | }(handler);
|
2555 | };
|
2556 | ZalgoPromise.try = function(method, context, args) {
|
2557 | if (method && "function" != typeof method && !method.call) throw new Error("Promise.try expected a function");
|
2558 | var result = void 0;
|
2559 | try {
|
2560 | result = method.apply(context, args || []);
|
2561 | } catch (err) {
|
2562 | return ZalgoPromise.reject(err);
|
2563 | }
|
2564 | return ZalgoPromise.resolve(result);
|
2565 | };
|
2566 | ZalgoPromise.delay = function(_delay) {
|
2567 | return new ZalgoPromise(function(resolve) {
|
2568 | setTimeout(resolve, _delay);
|
2569 | });
|
2570 | };
|
2571 | ZalgoPromise.isPromise = function(value) {
|
2572 | return !!(value && value instanceof ZalgoPromise) || utils_isPromise(value);
|
2573 | };
|
2574 | ZalgoPromise.flush = function() {
|
2575 | var promise = new ZalgoPromise();
|
2576 | getGlobal().flushPromises.push(promise);
|
2577 | 0 === getGlobal().activeCount && ZalgoPromise.flushQueue();
|
2578 | return promise;
|
2579 | };
|
2580 | ZalgoPromise.flushQueue = function() {
|
2581 | var promisesToFlush = getGlobal().flushPromises;
|
2582 | getGlobal().flushPromises = [];
|
2583 | for (var _i2 = 0, _length2 = null == promisesToFlush ? 0 : promisesToFlush.length; _i2 < _length2; _i2++) promisesToFlush[_i2].resolve();
|
2584 | };
|
2585 | return ZalgoPromise;
|
2586 | }();
|
2587 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2588 | return promise_ZalgoPromise;
|
2589 | });
|
2590 | },
|
2591 | "./src/constants.js": function(module, __webpack_exports__, __webpack_require__) {
|
2592 | "use strict";
|
2593 | Object.defineProperty(__webpack_exports__, "__esModule", {
|
2594 | value: !0
|
2595 | });
|
2596 | __webpack_require__.d(__webpack_exports__, "ZOID", function() {
|
2597 | return ZOID;
|
2598 | });
|
2599 | __webpack_require__.d(__webpack_exports__, "__ZOID__", function() {
|
2600 | return __ZOID__;
|
2601 | });
|
2602 | __webpack_require__.d(__webpack_exports__, "POST_MESSAGE", function() {
|
2603 | return POST_MESSAGE;
|
2604 | });
|
2605 | __webpack_require__.d(__webpack_exports__, "PROP_TYPES", function() {
|
2606 | return PROP_TYPES;
|
2607 | });
|
2608 | __webpack_require__.d(__webpack_exports__, "INITIAL_PROPS", function() {
|
2609 | return INITIAL_PROPS;
|
2610 | });
|
2611 | __webpack_require__.d(__webpack_exports__, "WINDOW_REFERENCES", function() {
|
2612 | return WINDOW_REFERENCES;
|
2613 | });
|
2614 | __webpack_require__.d(__webpack_exports__, "PROP_SERIALIZATION", function() {
|
2615 | return PROP_SERIALIZATION;
|
2616 | });
|
2617 | __webpack_require__.d(__webpack_exports__, "PROP_TYPES_LIST", function() {
|
2618 | return PROP_TYPES_LIST;
|
2619 | });
|
2620 | __webpack_require__.d(__webpack_exports__, "CONTEXT", function() {
|
2621 | return CONTEXT;
|
2622 | });
|
2623 | __webpack_require__.d(__webpack_exports__, "CLASS_NAMES", function() {
|
2624 | return CLASS_NAMES;
|
2625 | });
|
2626 | __webpack_require__.d(__webpack_exports__, "EVENTS", function() {
|
2627 | return EVENTS;
|
2628 | });
|
2629 | __webpack_require__.d(__webpack_exports__, "ATTRIBUTES", function() {
|
2630 | return ATTRIBUTES;
|
2631 | });
|
2632 | __webpack_require__.d(__webpack_exports__, "ANIMATION_NAMES", function() {
|
2633 | return ANIMATION_NAMES;
|
2634 | });
|
2635 | __webpack_require__.d(__webpack_exports__, "EVENT_NAMES", function() {
|
2636 | return EVENT_NAMES;
|
2637 | });
|
2638 | __webpack_require__.d(__webpack_exports__, "CLOSE_REASONS", function() {
|
2639 | return CLOSE_REASONS;
|
2640 | });
|
2641 | __webpack_require__.d(__webpack_exports__, "CONTEXT_LIST", function() {
|
2642 | return CONTEXT_LIST;
|
2643 | });
|
2644 | __webpack_require__.d(__webpack_exports__, "DELEGATE", function() {
|
2645 | return DELEGATE;
|
2646 | });
|
2647 | __webpack_require__.d(__webpack_exports__, "WILDCARD", function() {
|
2648 | return WILDCARD;
|
2649 | });
|
2650 | __webpack_require__.d(__webpack_exports__, "DEFAULT_DIMENSIONS", function() {
|
2651 | return DEFAULT_DIMENSIONS;
|
2652 | });
|
2653 | var ZOID = "zoid", __ZOID__ = "__" + ZOID + "__", POST_MESSAGE = {
|
2654 | DELEGATE: ZOID + "_delegate",
|
2655 | ALLOW_DELEGATE: ZOID + "_allow_delegate"
|
2656 | }, PROP_TYPES = {
|
2657 | STRING: "string",
|
2658 | OBJECT: "object",
|
2659 | FUNCTION: "function",
|
2660 | BOOLEAN: "boolean",
|
2661 | NUMBER: "number",
|
2662 | ARRAY: "array"
|
2663 | }, INITIAL_PROPS = {
|
2664 | RAW: "raw",
|
2665 | UID: "uid"
|
2666 | }, WINDOW_REFERENCES = {
|
2667 | OPENER: "opener",
|
2668 | TOP: "top",
|
2669 | PARENT: "parent",
|
2670 | GLOBAL: "global"
|
2671 | }, PROP_SERIALIZATION = {
|
2672 | JSON: "json",
|
2673 | DOTIFY: "dotify",
|
2674 | BASE64: "base64"
|
2675 | }, PROP_TYPES_LIST = Object.keys(PROP_TYPES).map(function(key) {
|
2676 | return PROP_TYPES[key];
|
2677 | }), CONTEXT = {
|
2678 | IFRAME: "iframe",
|
2679 | POPUP: "popup"
|
2680 | }, CLASS_NAMES = {
|
2681 | ZOID: "" + ZOID,
|
2682 | OUTLET: ZOID + "-outlet",
|
2683 | COMPONENT_FRAME: ZOID + "-component-frame",
|
2684 | PRERENDER_FRAME: ZOID + "-prerender-frame",
|
2685 | VISIBLE: ZOID + "-visible",
|
2686 | INVISIBLE: ZOID + "-invisible"
|
2687 | }, EVENTS = {
|
2688 | CLOSE: ZOID + "-close"
|
2689 | }, ATTRIBUTES = {
|
2690 | IFRAME_PLACEHOLDER: "data-zoid-" + ZOID + "-placeholder"
|
2691 | }, ANIMATION_NAMES = {
|
2692 | SHOW_CONTAINER: ZOID + "-show-container",
|
2693 | SHOW_COMPONENT: ZOID + "-show-component",
|
2694 | HIDE_CONTAINER: ZOID + "-hide-container",
|
2695 | HIDE_COMPONENT: ZOID + "-hide-component"
|
2696 | }, EVENT_NAMES = {
|
2697 | CLICK: "click"
|
2698 | }, CLOSE_REASONS = {
|
2699 | PARENT_CALL: "parent_call",
|
2700 | CHILD_CALL: "child_call",
|
2701 | CLOSE_DETECTED: "close_detected",
|
2702 | USER_CLOSED: "user_closed",
|
2703 | PARENT_CLOSE_DETECTED: "parent_close_detected"
|
2704 | }, CONTEXT_LIST = Object.keys(CONTEXT).map(function(key) {
|
2705 | return CONTEXT[key];
|
2706 | }), DELEGATE = {
|
2707 | CALL_ORIGINAL: "call_original",
|
2708 | CALL_DELEGATE: "call_delegate"
|
2709 | }, WILDCARD = "*", DEFAULT_DIMENSIONS = {
|
2710 | WIDTH: "300px",
|
2711 | HEIGHT: "150px"
|
2712 | };
|
2713 | },
|
2714 | "./src/drivers/angular.js": function(module, __webpack_exports__, __webpack_require__) {
|
2715 | "use strict";
|
2716 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2717 | return angular;
|
2718 | });
|
2719 | var __WEBPACK_IMPORTED_MODULE_0_belter_src__ = __webpack_require__("./node_modules/belter/src/index.js"), __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__("./src/constants.js"), angular = {
|
2720 | global: function() {
|
2721 | return window.angular;
|
2722 | },
|
2723 | register: function(component, ng) {
|
2724 | return ng.module(component.tag, []).directive(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.dasherizeToCamel)(component.tag), function() {
|
2725 | for (var scope = {}, _i2 = 0, _component$getPropNam2 = component.getPropNames(), _length2 = null == _component$getPropNam2 ? 0 : _component$getPropNam2.length; _i2 < _length2; _i2++) {
|
2726 | var key = _component$getPropNam2[_i2];
|
2727 | scope[key] = "=";
|
2728 | }
|
2729 | scope.props = "=";
|
2730 | return {
|
2731 | scope: scope,
|
2732 | restrict: "E",
|
2733 | controller: [ "$scope", "$element", function($scope, $element) {
|
2734 | component.log("instantiate_angular_component");
|
2735 | var getProps = function() {
|
2736 | var scopeProps = void 0;
|
2737 | if ($scope.props) scopeProps = $scope.props; else {
|
2738 | scopeProps = {};
|
2739 | for (var _i4 = 0, _Object$keys2 = Object.keys(scope), _length4 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i4 < _length4; _i4++) {
|
2740 | var _key = _Object$keys2[_i4];
|
2741 | void 0 !== $scope[_key] && (scopeProps[_key] = $scope[_key]);
|
2742 | }
|
2743 | }
|
2744 | return Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.replaceObject)(scopeProps, function(item) {
|
2745 | return "function" == typeof item ? function() {
|
2746 | var result = item.apply(this, arguments);
|
2747 | !function() {
|
2748 | if ("$apply" !== $scope.$root.$$phase && "$digest" !== $scope.$root.$$phase) try {
|
2749 | $scope.$apply();
|
2750 | } catch (err) {}
|
2751 | }();
|
2752 | return result;
|
2753 | } : item;
|
2754 | });
|
2755 | }, parent = component.init(getProps(), null, $element[0]);
|
2756 | parent.render(__WEBPACK_IMPORTED_MODULE_1__constants__.CONTEXT.IFRAME, $element[0]);
|
2757 | $scope.$watch(function() {
|
2758 | parent.updateProps(getProps());
|
2759 | });
|
2760 | } ]
|
2761 | };
|
2762 | });
|
2763 | }
|
2764 | };
|
2765 | },
|
2766 | "./src/drivers/angular2.js": function(module, __webpack_exports__, __webpack_require__) {
|
2767 | "use strict";
|
2768 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2769 | return angular2;
|
2770 | });
|
2771 | var __WEBPACK_IMPORTED_MODULE_0_belter_src__ = __webpack_require__("./node_modules/belter/src/index.js"), __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__("./src/constants.js"), _extends = Object.assign || function(target) {
|
2772 | for (var i = 1; i < arguments.length; i++) {
|
2773 | var source = arguments[i];
|
2774 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
2775 | }
|
2776 | return target;
|
2777 | }, angular2 = {
|
2778 | global: function() {},
|
2779 | register: function(zoid, _ref) {
|
2780 | var AngularComponent = _ref.Component, NgModule = _ref.NgModule, ElementRef = _ref.ElementRef, NgZone = _ref.NgZone;
|
2781 | zoid.log("initializing angular2 component");
|
2782 | var getProps = function(component) {
|
2783 | return Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.replaceObject)(_extends({}, component.internalProps, component.props), function(item) {
|
2784 | return "function" == typeof item ? function() {
|
2785 | var _this = this, _arguments = arguments;
|
2786 | return component.zone.run(function() {
|
2787 | return item.apply(_this, _arguments);
|
2788 | });
|
2789 | } : item;
|
2790 | });
|
2791 | }, ComponentInstance = AngularComponent({
|
2792 | selector: zoid.tag,
|
2793 | template: "<div></div>",
|
2794 | inputs: [ "props" ]
|
2795 | }).Class({
|
2796 | constructor: [ ElementRef, NgZone, function(elementRef, zone) {
|
2797 | this.elementRef = elementRef;
|
2798 | this.zone = zone;
|
2799 | } ],
|
2800 | ngOnInit: function() {
|
2801 | var targetElement = this.elementRef.nativeElement, parent = zoid.init(getProps(this), null, targetElement);
|
2802 | parent.render(__WEBPACK_IMPORTED_MODULE_1__constants__.CONTEXT.IFRAME, targetElement);
|
2803 | this.parent = parent;
|
2804 | },
|
2805 | ngOnChanges: function() {
|
2806 | this.parent && this.parent.updateProps(getProps(this));
|
2807 | }
|
2808 | });
|
2809 | return NgModule({
|
2810 | declarations: [ ComponentInstance ],
|
2811 | exports: [ ComponentInstance ]
|
2812 | }).Class({
|
2813 | constructor: function() {}
|
2814 | });
|
2815 | }
|
2816 | };
|
2817 | },
|
2818 | "./src/drivers/ember.js": function(module, exports) {},
|
2819 | "./src/drivers/glimmer.js": function(module, __webpack_exports__, __webpack_require__) {
|
2820 | "use strict";
|
2821 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2822 | return glimmer;
|
2823 | });
|
2824 | var _extends = Object.assign || function(target) {
|
2825 | for (var i = 1; i < arguments.length; i++) {
|
2826 | var source = arguments[i];
|
2827 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
2828 | }
|
2829 | return target;
|
2830 | }, glimmer = {
|
2831 | global: function() {},
|
2832 | register: function(component, GlimmerComponent) {
|
2833 | return function(_GlimmerComponent) {
|
2834 | !function(subClass, superClass) {
|
2835 | if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
2836 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
2837 | constructor: {
|
2838 | value: subClass,
|
2839 | enumerable: !1,
|
2840 | writable: !0,
|
2841 | configurable: !0
|
2842 | }
|
2843 | });
|
2844 | superClass && (Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass);
|
2845 | }(_class, _GlimmerComponent);
|
2846 | function _class() {
|
2847 | !function(instance, Constructor) {
|
2848 | if (!(instance instanceof _class)) throw new TypeError("Cannot call a class as a function");
|
2849 | }(this);
|
2850 | return function(self, call) {
|
2851 | if (!self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
2852 | return !call || "object" != typeof call && "function" != typeof call ? self : call;
|
2853 | }(this, _GlimmerComponent.apply(this, arguments));
|
2854 | }
|
2855 | _class.prototype.didInsertElement = function() {
|
2856 | component.render(_extends({}, this.args), this.element);
|
2857 | };
|
2858 | return _class;
|
2859 | }(GlimmerComponent);
|
2860 | }
|
2861 | };
|
2862 | },
|
2863 | "./src/drivers/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
2864 | "use strict";
|
2865 | var __WEBPACK_IMPORTED_MODULE_0__react__ = __webpack_require__("./src/drivers/react.js");
|
2866 | __webpack_require__.d(__webpack_exports__, "react", function() {
|
2867 | return __WEBPACK_IMPORTED_MODULE_0__react__.a;
|
2868 | });
|
2869 | var __WEBPACK_IMPORTED_MODULE_1__vue__ = __webpack_require__("./src/drivers/vue.js");
|
2870 | __webpack_require__.d(__webpack_exports__, "vue", function() {
|
2871 | return __WEBPACK_IMPORTED_MODULE_1__vue__.a;
|
2872 | });
|
2873 | var __WEBPACK_IMPORTED_MODULE_2__angular__ = __webpack_require__("./src/drivers/angular.js");
|
2874 | __webpack_require__.d(__webpack_exports__, "angular", function() {
|
2875 | return __WEBPACK_IMPORTED_MODULE_2__angular__.a;
|
2876 | });
|
2877 | var __WEBPACK_IMPORTED_MODULE_3__ember__ = __webpack_require__("./src/drivers/ember.js");
|
2878 | __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__ember__);
|
2879 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_3__ember__, "angular2") && __webpack_require__.d(__webpack_exports__, "angular2", function() {
|
2880 | return __WEBPACK_IMPORTED_MODULE_3__ember__.angular2;
|
2881 | });
|
2882 | __webpack_require__.o(__WEBPACK_IMPORTED_MODULE_3__ember__, "glimmer") && __webpack_require__.d(__webpack_exports__, "glimmer", function() {
|
2883 | return __WEBPACK_IMPORTED_MODULE_3__ember__.glimmer;
|
2884 | });
|
2885 | var __WEBPACK_IMPORTED_MODULE_4__glimmer__ = __webpack_require__("./src/drivers/glimmer.js");
|
2886 | __webpack_require__.d(__webpack_exports__, "glimmer", function() {
|
2887 | return __WEBPACK_IMPORTED_MODULE_4__glimmer__.a;
|
2888 | });
|
2889 | var __WEBPACK_IMPORTED_MODULE_5__angular2__ = __webpack_require__("./src/drivers/angular2.js");
|
2890 | __webpack_require__.d(__webpack_exports__, "angular2", function() {
|
2891 | return __WEBPACK_IMPORTED_MODULE_5__angular2__.a;
|
2892 | });
|
2893 | },
|
2894 | "./src/drivers/react.js": function(module, __webpack_exports__, __webpack_require__) {
|
2895 | "use strict";
|
2896 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2897 | return react;
|
2898 | });
|
2899 | var __WEBPACK_IMPORTED_MODULE_0_belter_src__ = __webpack_require__("./node_modules/belter/src/index.js"), __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__("./src/constants.js"), react = {
|
2900 | global: function() {
|
2901 | if (window.React && window.ReactDOM) return {
|
2902 | React: window.React,
|
2903 | ReactDOM: window.ReactDOM
|
2904 | };
|
2905 | },
|
2906 | register: function(component, _ref) {
|
2907 | var React = _ref.React, ReactDOM = _ref.ReactDOM;
|
2908 | React.createClass ? component.react = React.createClass({
|
2909 | render: function() {
|
2910 | return React.createElement("div", null);
|
2911 | },
|
2912 | componentDidMount: function() {
|
2913 | component.log("instantiate_react_component");
|
2914 | var el = ReactDOM.findDOMNode(this), parent = component.init(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.extend)({}, this.props), null, el);
|
2915 | this.setState({
|
2916 | parent: parent
|
2917 | });
|
2918 | parent.render(__WEBPACK_IMPORTED_MODULE_1__constants__.CONTEXT.IFRAME, el);
|
2919 | },
|
2920 | componentDidUpdate: function() {
|
2921 | this.state && this.state.parent && this.state.parent.updateProps(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.extend)({}, this.props));
|
2922 | }
|
2923 | }) : component.react = function(_React$Component) {
|
2924 | !function(subClass, superClass) {
|
2925 | if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
2926 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
2927 | constructor: {
|
2928 | value: subClass,
|
2929 | enumerable: !1,
|
2930 | writable: !0,
|
2931 | configurable: !0
|
2932 | }
|
2933 | });
|
2934 | superClass && (Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass);
|
2935 | }(_class, _React$Component);
|
2936 | function _class() {
|
2937 | !function(instance, Constructor) {
|
2938 | if (!(instance instanceof _class)) throw new TypeError("Cannot call a class as a function");
|
2939 | }(this);
|
2940 | return function(self, call) {
|
2941 | if (!self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
2942 | return !call || "object" != typeof call && "function" != typeof call ? self : call;
|
2943 | }(this, _React$Component.apply(this, arguments));
|
2944 | }
|
2945 | _class.prototype.render = function() {
|
2946 | return React.createElement("div", null);
|
2947 | };
|
2948 | _class.prototype.componentDidMount = function() {
|
2949 | component.log("instantiate_react_component");
|
2950 | var el = ReactDOM.findDOMNode(this), parent = component.init(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.extend)({}, this.props), null, el);
|
2951 | this.setState({
|
2952 | parent: parent
|
2953 | });
|
2954 | parent.render(__WEBPACK_IMPORTED_MODULE_1__constants__.CONTEXT.IFRAME, el);
|
2955 | };
|
2956 | _class.prototype.componentDidUpdate = function() {
|
2957 | this.state && this.state.parent && this.state.parent.updateProps(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.extend)({}, this.props));
|
2958 | };
|
2959 | return _class;
|
2960 | }(React.Component);
|
2961 | return component.react;
|
2962 | }
|
2963 | };
|
2964 | },
|
2965 | "./src/drivers/vue.js": function(module, __webpack_exports__, __webpack_require__) {
|
2966 | "use strict";
|
2967 | __webpack_require__.d(__webpack_exports__, "a", function() {
|
2968 | return vue;
|
2969 | });
|
2970 | var __WEBPACK_IMPORTED_MODULE_0_belter_src__ = __webpack_require__("./node_modules/belter/src/index.js"), __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__("./src/constants.js"), vue = {
|
2971 | global: function() {},
|
2972 | register: function(component) {
|
2973 | return {
|
2974 | render: function(createElement) {
|
2975 | return createElement("div");
|
2976 | },
|
2977 | inheritAttrs: !1,
|
2978 | mounted: function() {
|
2979 | var el = this.$el;
|
2980 | this.parent = component.init(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.extend)({}, this.$attrs), null, el);
|
2981 | this.parent.render(__WEBPACK_IMPORTED_MODULE_1__constants__.CONTEXT.IFRAME, el);
|
2982 | },
|
2983 | beforeUpdate: function() {
|
2984 | this.parent && this.$attrs && this.parent.updateProps(Object(__WEBPACK_IMPORTED_MODULE_0_belter_src__.extend)({}, this.$attrs));
|
2985 | }
|
2986 | };
|
2987 | }
|
2988 | };
|
2989 | },
|
2990 | "./src/index.js": function(module, __webpack_exports__, __webpack_require__) {
|
2991 | "use strict";
|
2992 | Object.defineProperty(__webpack_exports__, "__esModule", {
|
2993 | value: !0
|
2994 | });
|
2995 | var interface_namespaceObject = {};
|
2996 | __webpack_require__.d(interface_namespaceObject, "markWindowKnown", function() {
|
2997 | return lib.e;
|
2998 | });
|
2999 | __webpack_require__.d(interface_namespaceObject, "serializeMessage", function() {
|
3000 | return serializeMessage;
|
3001 | });
|
3002 | __webpack_require__.d(interface_namespaceObject, "deserializeMessage", function() {
|
3003 | return deserializeMessage;
|
3004 | });
|
3005 | __webpack_require__.d(interface_namespaceObject, "ProxyWindow", function() {
|
3006 | return window_ProxyWindow;
|
3007 | });
|
3008 | __webpack_require__.d(interface_namespaceObject, "cleanUpWindow", function() {
|
3009 | return cleanUpWindow;
|
3010 | });
|
3011 | __webpack_require__.d(interface_namespaceObject, "Promise", function() {
|
3012 | return src.a;
|
3013 | });
|
3014 | __webpack_require__.d(interface_namespaceObject, "bridge", function() {
|
3015 | return bridge;
|
3016 | });
|
3017 | __webpack_require__.d(interface_namespaceObject, "parent", function() {
|
3018 | return public_parent;
|
3019 | });
|
3020 | __webpack_require__.d(interface_namespaceObject, "send", function() {
|
3021 | return _send;
|
3022 | });
|
3023 | __webpack_require__.d(interface_namespaceObject, "requestPromises", function() {
|
3024 | return requestPromises;
|
3025 | });
|
3026 | __webpack_require__.d(interface_namespaceObject, "request", function() {
|
3027 | return request;
|
3028 | });
|
3029 | __webpack_require__.d(interface_namespaceObject, "sendToParent", function() {
|
3030 | return sendToParent;
|
3031 | });
|
3032 | __webpack_require__.d(interface_namespaceObject, "client", function() {
|
3033 | return client;
|
3034 | });
|
3035 | __webpack_require__.d(interface_namespaceObject, "on", function() {
|
3036 | return _on;
|
3037 | });
|
3038 | __webpack_require__.d(interface_namespaceObject, "listen", function() {
|
3039 | return listen;
|
3040 | });
|
3041 | __webpack_require__.d(interface_namespaceObject, "once", function() {
|
3042 | return once;
|
3043 | });
|
3044 | __webpack_require__.d(interface_namespaceObject, "listener", function() {
|
3045 | return server_listener;
|
3046 | });
|
3047 | __webpack_require__.d(interface_namespaceObject, "CONFIG", function() {
|
3048 | return conf.b;
|
3049 | });
|
3050 | __webpack_require__.d(interface_namespaceObject, "disable", function() {
|
3051 | return disable;
|
3052 | });
|
3053 | var post_robot_src_namespaceObject = {};
|
3054 | __webpack_require__.d(post_robot_src_namespaceObject, "default", function() {
|
3055 | return post_robot_src;
|
3056 | });
|
3057 | __webpack_require__.d(post_robot_src_namespaceObject, "markWindowKnown", function() {
|
3058 | return lib.e;
|
3059 | });
|
3060 | __webpack_require__.d(post_robot_src_namespaceObject, "serializeMessage", function() {
|
3061 | return serializeMessage;
|
3062 | });
|
3063 | __webpack_require__.d(post_robot_src_namespaceObject, "deserializeMessage", function() {
|
3064 | return deserializeMessage;
|
3065 | });
|
3066 | __webpack_require__.d(post_robot_src_namespaceObject, "ProxyWindow", function() {
|
3067 | return window_ProxyWindow;
|
3068 | });
|
3069 | __webpack_require__.d(post_robot_src_namespaceObject, "cleanUpWindow", function() {
|
3070 | return cleanUpWindow;
|
3071 | });
|
3072 | __webpack_require__.d(post_robot_src_namespaceObject, "Promise", function() {
|
3073 | return src.a;
|
3074 | });
|
3075 | __webpack_require__.d(post_robot_src_namespaceObject, "bridge", function() {
|
3076 | return bridge;
|
3077 | });
|
3078 | __webpack_require__.d(post_robot_src_namespaceObject, "parent", function() {
|
3079 | return public_parent;
|
3080 | });
|
3081 | __webpack_require__.d(post_robot_src_namespaceObject, "send", function() {
|
3082 | return _send;
|
3083 | });
|
3084 | __webpack_require__.d(post_robot_src_namespaceObject, "requestPromises", function() {
|
3085 | return requestPromises;
|
3086 | });
|
3087 | __webpack_require__.d(post_robot_src_namespaceObject, "request", function() {
|
3088 | return request;
|
3089 | });
|
3090 | __webpack_require__.d(post_robot_src_namespaceObject, "sendToParent", function() {
|
3091 | return sendToParent;
|
3092 | });
|
3093 | __webpack_require__.d(post_robot_src_namespaceObject, "client", function() {
|
3094 | return client;
|
3095 | });
|
3096 | __webpack_require__.d(post_robot_src_namespaceObject, "on", function() {
|
3097 | return _on;
|
3098 | });
|
3099 | __webpack_require__.d(post_robot_src_namespaceObject, "listen", function() {
|
3100 | return listen;
|
3101 | });
|
3102 | __webpack_require__.d(post_robot_src_namespaceObject, "once", function() {
|
3103 | return once;
|
3104 | });
|
3105 | __webpack_require__.d(post_robot_src_namespaceObject, "listener", function() {
|
3106 | return server_listener;
|
3107 | });
|
3108 | __webpack_require__.d(post_robot_src_namespaceObject, "CONFIG", function() {
|
3109 | return conf.b;
|
3110 | });
|
3111 | __webpack_require__.d(post_robot_src_namespaceObject, "disable", function() {
|
3112 | return disable;
|
3113 | });
|
3114 | var src_interface_namespaceObject = {};
|
3115 | __webpack_require__.d(src_interface_namespaceObject, "PopupOpenError", function() {
|
3116 | return belter_src.PopupOpenError;
|
3117 | });
|
3118 | __webpack_require__.d(src_interface_namespaceObject, "create", function() {
|
3119 | return create;
|
3120 | });
|
3121 | __webpack_require__.d(src_interface_namespaceObject, "getByTag", function() {
|
3122 | return getByTag;
|
3123 | });
|
3124 | __webpack_require__.d(src_interface_namespaceObject, "getCurrentScriptDir", function() {
|
3125 | return getCurrentScriptDir;
|
3126 | });
|
3127 | __webpack_require__.d(src_interface_namespaceObject, "useLogger", function() {
|
3128 | return useLogger;
|
3129 | });
|
3130 | __webpack_require__.d(src_interface_namespaceObject, "destroyAll", function() {
|
3131 | return interface_destroyAll;
|
3132 | });
|
3133 | __webpack_require__.d(src_interface_namespaceObject, "postRobot", function() {
|
3134 | return postRobot;
|
3135 | });
|
3136 | __webpack_require__.d(src_interface_namespaceObject, "CONSTANTS", function() {
|
3137 | return CONSTANTS;
|
3138 | });
|
3139 | var _SERIALIZER, src = __webpack_require__("./node_modules/zalgo-promise/src/index.js"), lib = __webpack_require__("./node_modules/post-robot/src/lib/index.js"), cross_domain_utils_src = __webpack_require__("./node_modules/cross-domain-utils/src/index.js"), belter_src = __webpack_require__("./node_modules/belter/src/index.js"), conf = __webpack_require__("./node_modules/post-robot/src/conf/index.js"), TYPE = {
|
3140 | FUNCTION: "function",
|
3141 | ERROR: "error",
|
3142 | PROMISE: "promise",
|
3143 | REGEX: "regex",
|
3144 | DATE: "date",
|
3145 | ARRAY: "array",
|
3146 | OBJECT: "object",
|
3147 | STRING: "string",
|
3148 | NUMBER: "number",
|
3149 | BOOLEAN: "boolean",
|
3150 | NULL: "null",
|
3151 | UNDEFINED: "undefined"
|
3152 | }, _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
3153 | return typeof obj;
|
3154 | } : function(obj) {
|
3155 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
3156 | };
|
3157 | function isSerializedType(item) {
|
3158 | return "object" === (void 0 === item ? "undefined" : _typeof(item)) && null !== item && "string" == typeof item.__type__;
|
3159 | }
|
3160 | function determineType(val) {
|
3161 | return void 0 === val ? TYPE.UNDEFINED : null === val ? TYPE.NULL : Array.isArray(val) ? TYPE.ARRAY : "function" == typeof val ? TYPE.FUNCTION : "object" === (void 0 === val ? "undefined" : _typeof(val)) ? val instanceof Error ? TYPE.ERROR : "function" == typeof val.then ? TYPE.PROMISE : "[object RegExp]" === Object.prototype.toString.call(val) ? TYPE.REGEX : "[object Date]" === Object.prototype.toString.call(val) ? TYPE.DATE : TYPE.OBJECT : "string" == typeof val ? TYPE.STRING : "number" == typeof val ? TYPE.NUMBER : "boolean" == typeof val ? TYPE.BOOLEAN : void 0;
|
3162 | }
|
3163 | function serializeType(type, val) {
|
3164 | return {
|
3165 | __type__: type,
|
3166 | __val__: val
|
3167 | };
|
3168 | }
|
3169 | var _DESERIALIZER, SERIALIZER = ((_SERIALIZER = {})[TYPE.FUNCTION] = function() {},
|
3170 | _SERIALIZER[TYPE.ERROR] = function(_ref) {
|
3171 | var message = _ref.message, stack = _ref.stack, code = _ref.code;
|
3172 | return serializeType(TYPE.ERROR, {
|
3173 | message: message,
|
3174 | stack: stack,
|
3175 | code: code
|
3176 | });
|
3177 | }, _SERIALIZER[TYPE.PROMISE] = function() {}, _SERIALIZER[TYPE.REGEX] = function(val) {
|
3178 | return serializeType(TYPE.REGEX, val.source);
|
3179 | }, _SERIALIZER[TYPE.DATE] = function(val) {
|
3180 | return serializeType(TYPE.DATE, val.toJSON());
|
3181 | }, _SERIALIZER[TYPE.ARRAY] = function(val) {
|
3182 | return val;
|
3183 | }, _SERIALIZER[TYPE.OBJECT] = function(val) {
|
3184 | return val;
|
3185 | }, _SERIALIZER[TYPE.STRING] = function(val) {
|
3186 | return val;
|
3187 | }, _SERIALIZER[TYPE.NUMBER] = function(val) {
|
3188 | return val;
|
3189 | }, _SERIALIZER[TYPE.BOOLEAN] = function(val) {
|
3190 | return val;
|
3191 | }, _SERIALIZER[TYPE.NULL] = function(val) {
|
3192 | return val;
|
3193 | }, _SERIALIZER), defaultSerializers = {}, DESERIALIZER = ((_DESERIALIZER = {})[TYPE.FUNCTION] = function() {
|
3194 | throw new Error("Function serialization is not implemented; nothing to deserialize");
|
3195 | }, _DESERIALIZER[TYPE.ERROR] = function(_ref2) {
|
3196 | var message = _ref2.message, stack = _ref2.stack, code = _ref2.code, error = new Error(message);
|
3197 | error.code = code;
|
3198 | error.stack = stack + "\n\n" + error.stack;
|
3199 | return error;
|
3200 | }, _DESERIALIZER[TYPE.PROMISE] = function() {
|
3201 | throw new Error("Promise serialization is not implemented; nothing to deserialize");
|
3202 | }, _DESERIALIZER[TYPE.REGEX] = function(val) {
|
3203 | return new RegExp(val);
|
3204 | }, _DESERIALIZER[TYPE.DATE] = function(val) {
|
3205 | return new Date(val);
|
3206 | }, _DESERIALIZER[TYPE.ARRAY] = function(val) {
|
3207 | return val;
|
3208 | }, _DESERIALIZER[TYPE.OBJECT] = function(val) {
|
3209 | return val;
|
3210 | }, _DESERIALIZER[TYPE.STRING] = function(val) {
|
3211 | return val;
|
3212 | }, _DESERIALIZER[TYPE.NUMBER] = function(val) {
|
3213 | return val;
|
3214 | }, _DESERIALIZER[TYPE.BOOLEAN] = function(val) {
|
3215 | return val;
|
3216 | }, _DESERIALIZER[TYPE.NULL] = function(val) {
|
3217 | return val;
|
3218 | }, _DESERIALIZER), defaultDeserializers = {}, src_global = __webpack_require__("./node_modules/post-robot/src/global.js"), winToProxyWindow = Object(src_global.c)("winToProxyWindow"), idToProxyWindow = Object(src_global.b)("idToProxyWindow");
|
3219 | function cleanupProxyWindows() {
|
3220 | for (var _i2 = 0, _idToProxyWindow$keys2 = idToProxyWindow.keys(), _length2 = null == _idToProxyWindow$keys2 ? 0 : _idToProxyWindow$keys2.length; _i2 < _length2; _i2++) {
|
3221 | var _id = _idToProxyWindow$keys2[_i2];
|
3222 | idToProxyWindow.get(_id).shouldClean() && idToProxyWindow.del(_id);
|
3223 | }
|
3224 | }
|
3225 | var window_ProxyWindow = function() {
|
3226 | function ProxyWindow(serializedWindow, actualWindow) {
|
3227 | !function(instance, Constructor) {
|
3228 | if (!(instance instanceof ProxyWindow)) throw new TypeError("Cannot call a class as a function");
|
3229 | }(this);
|
3230 | this.serializedWindow = serializedWindow;
|
3231 | this.actualWindowPromise = new src.a();
|
3232 | actualWindow && this.setWindow(actualWindow);
|
3233 | this.serializedWindow.getInstanceID = Object(belter_src.memoizePromise)(this.serializedWindow.getInstanceID);
|
3234 | }
|
3235 | ProxyWindow.prototype.setLocation = function(href) {
|
3236 | var _this = this;
|
3237 | return src.a.try(function() {
|
3238 | if (!_this.actualWindow) return _this.serializedWindow.setLocation(href);
|
3239 | _this.actualWindow.location = href;
|
3240 | }).then(function() {
|
3241 | return _this;
|
3242 | });
|
3243 | };
|
3244 | ProxyWindow.prototype.setName = function(name) {
|
3245 | var _this2 = this;
|
3246 | return src.a.try(function() {
|
3247 | if (!_this2.actualWindow) return _this2.serializedWindow.setName(name);
|
3248 | if (!Object(cross_domain_utils_src.isSameDomain)(_this2.actualWindow)) throw new Error("Can not set name for window on different domain");
|
3249 | _this2.actualWindow.name = name;
|
3250 | _this2.actualWindow.frameElement && _this2.actualWindow.frameElement.setAttribute("name", name);
|
3251 | }).then(function() {
|
3252 | return _this2;
|
3253 | });
|
3254 | };
|
3255 | ProxyWindow.prototype.close = function() {
|
3256 | var _this3 = this;
|
3257 | return src.a.try(function() {
|
3258 | if (!_this3.actualWindow) return _this3.serializedWindow.close();
|
3259 | _this3.actualWindow.close();
|
3260 | }).then(function() {
|
3261 | return _this3;
|
3262 | });
|
3263 | };
|
3264 | ProxyWindow.prototype.focus = function() {
|
3265 | var _this4 = this;
|
3266 | return src.a.try(function() {
|
3267 | _this4.actualWindow && _this4.actualWindow.focus();
|
3268 | return _this4.serializedWindow.focus();
|
3269 | }).then(function() {
|
3270 | return _this4;
|
3271 | });
|
3272 | };
|
3273 | ProxyWindow.prototype.isClosed = function() {
|
3274 | var _this5 = this;
|
3275 | return src.a.try(function() {
|
3276 | return _this5.actualWindow ? Object(cross_domain_utils_src.isWindowClosed)(_this5.actualWindow) : _this5.serializedWindow.isClosed();
|
3277 | });
|
3278 | };
|
3279 | ProxyWindow.prototype.setWindow = function(win) {
|
3280 | this.actualWindow = win;
|
3281 | this.actualWindowPromise.resolve(win);
|
3282 | };
|
3283 | ProxyWindow.prototype.matchWindow = function(win) {
|
3284 | var _this6 = this;
|
3285 | return src.a.try(function() {
|
3286 | return _this6.actualWindow ? win === _this6.actualWindow : src.a.all([ _this6.getInstanceID(), Object(lib.b)(win) ]).then(function(_ref) {
|
3287 | var match = _ref[0] === _ref[1];
|
3288 | match && _this6.setWindow(win);
|
3289 | return match;
|
3290 | });
|
3291 | });
|
3292 | };
|
3293 | ProxyWindow.prototype.unwrap = function() {
|
3294 | return this.actualWindow || this;
|
3295 | };
|
3296 | ProxyWindow.prototype.awaitWindow = function() {
|
3297 | return this.actualWindowPromise;
|
3298 | };
|
3299 | ProxyWindow.prototype.getInstanceID = function() {
|
3300 | return this.actualWindow ? Object(lib.b)(this.actualWindow) : this.serializedWindow.getInstanceID();
|
3301 | };
|
3302 | ProxyWindow.prototype.serialize = function() {
|
3303 | return this.serializedWindow;
|
3304 | };
|
3305 | ProxyWindow.prototype.shouldClean = function() {
|
3306 | return this.actualWindow && Object(cross_domain_utils_src.isWindowClosed)(this.actualWindow);
|
3307 | };
|
3308 | ProxyWindow.unwrap = function(win) {
|
3309 | return ProxyWindow.isProxyWindow(win) ? win.unwrap() : win;
|
3310 | };
|
3311 | ProxyWindow.serialize = function(win) {
|
3312 | cleanupProxyWindows();
|
3313 | return ProxyWindow.toProxyWindow(win).serialize();
|
3314 | };
|
3315 | ProxyWindow.deserialize = function(serializedWindow) {
|
3316 | cleanupProxyWindows();
|
3317 | return idToProxyWindow.getOrSet(serializedWindow.id, function() {
|
3318 | return new ProxyWindow(serializedWindow);
|
3319 | });
|
3320 | };
|
3321 | ProxyWindow.isProxyWindow = function(obj) {
|
3322 | return obj instanceof ProxyWindow;
|
3323 | };
|
3324 | ProxyWindow.toProxyWindow = function(win) {
|
3325 | cleanupProxyWindows();
|
3326 | return ProxyWindow.isProxyWindow(win) ? win : winToProxyWindow.getOrSet(win, function() {
|
3327 | var id = Object(belter_src.uniqueID)();
|
3328 | return idToProxyWindow.set(id, new ProxyWindow({
|
3329 | id: id,
|
3330 | getInstanceID: function() {
|
3331 | return Object(lib.b)(win);
|
3332 | },
|
3333 | close: function() {
|
3334 | return src.a.try(function() {
|
3335 | win.close();
|
3336 | });
|
3337 | },
|
3338 | focus: function() {
|
3339 | return src.a.try(function() {
|
3340 | win.focus();
|
3341 | });
|
3342 | },
|
3343 | isClosed: function() {
|
3344 | return src.a.try(function() {
|
3345 | return Object(cross_domain_utils_src.isWindowClosed)(win);
|
3346 | });
|
3347 | },
|
3348 | setLocation: function(href) {
|
3349 | return src.a.try(function() {
|
3350 | if (Object(cross_domain_utils_src.isSameDomain)(win)) try {
|
3351 | if (win.location && "function" == typeof win.location.replace) {
|
3352 | win.location.replace(href);
|
3353 | return;
|
3354 | }
|
3355 | } catch (err) {}
|
3356 | win.location = href;
|
3357 | });
|
3358 | },
|
3359 | setName: function(name) {
|
3360 | return src.a.try(function() {
|
3361 | win.name = name;
|
3362 | });
|
3363 | }
|
3364 | }, win));
|
3365 | });
|
3366 | };
|
3367 | return ProxyWindow;
|
3368 | }(), _extends = Object.assign || function(target) {
|
3369 | for (var i = 1; i < arguments.length; i++) {
|
3370 | var source = arguments[i];
|
3371 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
3372 | }
|
3373 | return target;
|
3374 | }, methodStore = Object(src_global.c)("methodStore"), proxyWindowMethods = Object(src_global.b)("proxyWindowMethods");
|
3375 | src_global.a.listeningForFunctions = src_global.a.listeningForFunctions || !1;
|
3376 | var listenForFunctionCalls = Object(belter_src.once)(function() {
|
3377 | if (!src_global.a.listeningForFunctions) {
|
3378 | src_global.a.listeningForFunctions = !0;
|
3379 | src_global.a.on(conf.d.METHOD, {
|
3380 | origin: conf.i
|
3381 | }, function(_ref) {
|
3382 | var source = _ref.source, origin = _ref.origin, data = _ref.data, id = data.id, name = data.name;
|
3383 | return src.a.try(function() {
|
3384 | var meth = methodStore.getOrSet(source, function() {
|
3385 | return {};
|
3386 | })[data.id] || proxyWindowMethods.get(id);
|
3387 | if (!meth) throw new Error("Could not find method '" + data.name + "' with id: " + data.id + " in " + Object(cross_domain_utils_src.getDomain)(window));
|
3388 | var proxy = meth.proxy, domain = meth.domain, val = meth.val;
|
3389 | if (!Object(cross_domain_utils_src.matchDomain)(domain, origin)) throw new Error("Method '" + data.name + "' domain " + JSON.stringify(meth.domain) + " does not match origin " + origin + " in " + Object(cross_domain_utils_src.getDomain)(window));
|
3390 | return proxy ? proxy.matchWindow(source).then(function(match) {
|
3391 | if (!match) throw new Error("Method call '" + data.name + "' failed - proxy window does not match source in " + Object(cross_domain_utils_src.getDomain)(window));
|
3392 | return val;
|
3393 | }) : val;
|
3394 | }).then(function(method) {
|
3395 | return method.apply({
|
3396 | source: source,
|
3397 | origin: origin,
|
3398 | data: data
|
3399 | }, data.args);
|
3400 | }).then(function(result) {
|
3401 | return {
|
3402 | result: result,
|
3403 | id: id,
|
3404 | name: name
|
3405 | };
|
3406 | });
|
3407 | });
|
3408 | }
|
3409 | });
|
3410 | function function_serializeFunction(destination, domain, val, key) {
|
3411 | listenForFunctionCalls();
|
3412 | var id = Object(belter_src.uniqueID)();
|
3413 | destination = window_ProxyWindow.unwrap(destination);
|
3414 | if (window_ProxyWindow.isProxyWindow(destination)) {
|
3415 | proxyWindowMethods.set(id, {
|
3416 | proxy: destination,
|
3417 | domain: domain,
|
3418 | val: val
|
3419 | });
|
3420 | destination.awaitWindow().then(function(win) {
|
3421 | proxyWindowMethods.del(id);
|
3422 | methodStore.getOrSet(win, function() {
|
3423 | return {};
|
3424 | })[id] = {
|
3425 | domain: domain,
|
3426 | val: val
|
3427 | };
|
3428 | });
|
3429 | } else methodStore.getOrSet(destination, function() {
|
3430 | return {};
|
3431 | })[id] = {
|
3432 | domain: domain,
|
3433 | val: val
|
3434 | };
|
3435 | return serializeType(conf.h.CROSS_DOMAIN_FUNCTION, {
|
3436 | id: id,
|
3437 | name: val.name || key
|
3438 | });
|
3439 | }
|
3440 | function serializeMessage(destination, domain, obj) {
|
3441 | var _serialize;
|
3442 | return function(obj) {
|
3443 | var serializers = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : defaultSerializers, result = JSON.stringify(obj, function(key) {
|
3444 | var val = this[key];
|
3445 | if (isSerializedType(this)) return val;
|
3446 | var type = determineType(val);
|
3447 | if (!type) return val;
|
3448 | var serializer = serializers[type] || SERIALIZER[type];
|
3449 | return serializer ? serializer(val, key) : val;
|
3450 | });
|
3451 | return void 0 === result ? TYPE.UNDEFINED : result;
|
3452 | }(obj, ((_serialize = {})[TYPE.PROMISE] = function(val, key) {
|
3453 | return function(destination, domain, val, key) {
|
3454 | return serializeType(conf.h.CROSS_DOMAIN_ZALGO_PROMISE, {
|
3455 | then: function_serializeFunction(destination, domain, function(resolve, reject) {
|
3456 | return val.then(resolve, reject);
|
3457 | }, key)
|
3458 | });
|
3459 | }(destination, domain, val, key);
|
3460 | }, _serialize[TYPE.FUNCTION] = function(val, key) {
|
3461 | return function_serializeFunction(destination, domain, val, key);
|
3462 | }, _serialize[TYPE.OBJECT] = function(val) {
|
3463 | return Object(cross_domain_utils_src.isWindow)(val) || window_ProxyWindow.isProxyWindow(val) ? (win = val,
|
3464 | serializeType(conf.h.CROSS_DOMAIN_WINDOW, window_ProxyWindow.serialize(win))) : val;
|
3465 | var win;
|
3466 | }, _serialize));
|
3467 | }
|
3468 | function deserializeMessage(source, origin, message) {
|
3469 | var _deserialize;
|
3470 | return function(str) {
|
3471 | var deserializers = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : defaultDeserializers;
|
3472 | if (str !== TYPE.UNDEFINED) return JSON.parse(str, function(key, val) {
|
3473 | if (isSerializedType(this)) return val;
|
3474 | var type = void 0, value = void 0;
|
3475 | if (isSerializedType(val)) {
|
3476 | type = val.__type__;
|
3477 | value = val.__val__;
|
3478 | } else {
|
3479 | type = determineType(val);
|
3480 | value = val;
|
3481 | }
|
3482 | if (!type) return value;
|
3483 | var deserializer = deserializers[type] || DESERIALIZER[type];
|
3484 | return deserializer ? deserializer(value, key) : value;
|
3485 | });
|
3486 | }(message, ((_deserialize = {})[conf.h.CROSS_DOMAIN_ZALGO_PROMISE] = function(serializedPromise) {
|
3487 | return then = serializedPromise.then, new src.a(then);
|
3488 | var then;
|
3489 | }, _deserialize[conf.h.CROSS_DOMAIN_FUNCTION] = function(serializedFunction) {
|
3490 | return function(source, origin, _ref2) {
|
3491 | var id = _ref2.id, name = _ref2.name;
|
3492 | function innerWrapper(args) {
|
3493 | var opts = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
3494 | return src.a.try(function() {
|
3495 | return window_ProxyWindow.isProxyWindow(source) ? source.awaitWindow() : source;
|
3496 | }).then(function(win) {
|
3497 | return src_global.a.send(win, conf.d.METHOD, {
|
3498 | id: id,
|
3499 | name: name,
|
3500 | args: args
|
3501 | }, _extends({
|
3502 | domain: origin
|
3503 | }, opts));
|
3504 | });
|
3505 | }
|
3506 | function crossDomainFunctionWrapper() {
|
3507 | return innerWrapper(Array.prototype.slice.call(arguments)).then(function(_ref3) {
|
3508 | return _ref3.data.result;
|
3509 | });
|
3510 | }
|
3511 | crossDomainFunctionWrapper.fireAndForget = function() {
|
3512 | return innerWrapper(Array.prototype.slice.call(arguments), {
|
3513 | fireAndForget: !0
|
3514 | });
|
3515 | };
|
3516 | crossDomainFunctionWrapper.__name__ = name;
|
3517 | crossDomainFunctionWrapper.__xdomain__ = !0;
|
3518 | crossDomainFunctionWrapper.origin = origin;
|
3519 | return crossDomainFunctionWrapper;
|
3520 | }(source, origin, serializedFunction);
|
3521 | }, _deserialize[conf.h.CROSS_DOMAIN_WINDOW] = function(serializedWindow) {
|
3522 | return win = serializedWindow, window_ProxyWindow.deserialize(win);
|
3523 | var win;
|
3524 | }, _deserialize));
|
3525 | }
|
3526 | var SEND_MESSAGE_STRATEGIES = {};
|
3527 | SEND_MESSAGE_STRATEGIES[conf.g.POST_MESSAGE] = function(win, serializedMessage, domain) {
|
3528 | try {
|
3529 | __webpack_require__("./node_modules/post-robot/src/compat/index.js").emulateIERestrictions(window, win);
|
3530 | } catch (err) {
|
3531 | return;
|
3532 | }
|
3533 | (Array.isArray(domain) ? domain : "string" == typeof domain ? [ domain ] : [ conf.i ]).map(function(dom) {
|
3534 | if (0 === dom.indexOf(conf.f.MOCK)) {
|
3535 | if (window.location.protocol === conf.f.FILE) return conf.i;
|
3536 | if (!Object(cross_domain_utils_src.isActuallySameDomain)(win)) throw new Error("Attempting to send messsage to mock domain " + dom + ", but window is actually cross-domain");
|
3537 | return Object(cross_domain_utils_src.getActualDomain)(win);
|
3538 | }
|
3539 | return 0 === dom.indexOf(conf.f.FILE) ? conf.i : dom;
|
3540 | }).forEach(function(dom) {
|
3541 | return win.postMessage(serializedMessage, dom);
|
3542 | });
|
3543 | };
|
3544 | var _require = __webpack_require__("./node_modules/post-robot/src/bridge/index.js"), sendBridgeMessage = _require.sendBridgeMessage, needsBridgeForBrowser = _require.needsBridgeForBrowser, isBridge = _require.isBridge;
|
3545 | SEND_MESSAGE_STRATEGIES[conf.g.BRIDGE] = function(win, serializedMessage, domain) {
|
3546 | if (needsBridgeForBrowser() || isBridge()) {
|
3547 | if (Object(cross_domain_utils_src.isSameDomain)(win)) throw new Error("Post message through bridge disabled between same domain windows");
|
3548 | if (!1 !== Object(cross_domain_utils_src.isSameTopWindow)(window, win)) throw new Error("Can only use bridge to communicate between two different windows, not between frames");
|
3549 | return sendBridgeMessage(win, domain, serializedMessage);
|
3550 | }
|
3551 | };
|
3552 | SEND_MESSAGE_STRATEGIES[conf.g.GLOBAL] = function(win, serializedMessage) {
|
3553 | if (Object(lib.f)()) {
|
3554 | if (!Object(cross_domain_utils_src.isSameDomain)(win)) throw new Error("Post message through global disabled between different domain windows");
|
3555 | if (!1 !== Object(cross_domain_utils_src.isSameTopWindow)(window, win)) throw new Error("Can only use global to communicate between two different windows, not between frames");
|
3556 | var foreignGlobal = win[conf.j.POSTROBOT];
|
3557 | if (!foreignGlobal) throw new Error("Can not find postRobot global on foreign window");
|
3558 | return foreignGlobal.receiveMessage({
|
3559 | source: window,
|
3560 | origin: Object(cross_domain_utils_src.getDomain)(),
|
3561 | data: serializedMessage
|
3562 | });
|
3563 | }
|
3564 | };
|
3565 | var send__extends = Object.assign || function(target) {
|
3566 | for (var i = 1; i < arguments.length; i++) {
|
3567 | var source = arguments[i];
|
3568 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
3569 | }
|
3570 | return target;
|
3571 | };
|
3572 | function sendMessage(win, domain, message) {
|
3573 | return src.a.try(function() {
|
3574 | var _serializeMessage;
|
3575 | if (Object(cross_domain_utils_src.isWindowClosed)(win)) throw new Error("Window is closed");
|
3576 | var serializedMessage = serializeMessage(win, domain, ((_serializeMessage = {})[conf.j.POSTROBOT] = send__extends({
|
3577 | id: Object(belter_src.uniqueID)()
|
3578 | }, message), _serializeMessage)), messages = [];
|
3579 | return src.a.map(Object.keys(SEND_MESSAGE_STRATEGIES), function(strategyName) {
|
3580 | return src.a.try(function() {
|
3581 | if (!conf.b.ALLOWED_POST_MESSAGE_METHODS[strategyName]) throw new Error("Strategy disallowed: " + strategyName);
|
3582 | return SEND_MESSAGE_STRATEGIES[strategyName](win, serializedMessage, domain);
|
3583 | }).then(function() {
|
3584 | messages.push(strategyName + ": success");
|
3585 | return !0;
|
3586 | }, function(err) {
|
3587 | messages.push(strategyName + ": " + Object(belter_src.stringifyError)(err) + "\n");
|
3588 | return !1;
|
3589 | });
|
3590 | }).then(function(results) {
|
3591 | var success = results.some(Boolean), status = message.type + " " + message.name + " " + (success ? "success" : "error") + ":\n - " + messages.join("\n - ") + "\n";
|
3592 | if (!success) throw new Error(status);
|
3593 | });
|
3594 | });
|
3595 | }
|
3596 | var responseListeners = Object(src_global.b)("responseListeners"), requestListeners = Object(src_global.c)("requestListeners"), erroredResponseListeners = Object(src_global.b)("erroredResponseListeners");
|
3597 | src_global.a.WINDOW_WILDCARD = src_global.a.WINDOW_WILDCARD || new function() {}();
|
3598 | var _RECEIVE_MESSAGE_TYPE, __DOMAIN_REGEX__ = "__domain_regex__";
|
3599 | function getResponseListener(hash) {
|
3600 | return responseListeners.get(hash);
|
3601 | }
|
3602 | function deleteResponseListener(hash) {
|
3603 | responseListeners.del(hash);
|
3604 | }
|
3605 | function isResponseListenerErrored(hash) {
|
3606 | return erroredResponseListeners.has(hash);
|
3607 | }
|
3608 | function getRequestListener(_ref) {
|
3609 | var name = _ref.name, win = _ref.win, domain = _ref.domain;
|
3610 | win === conf.i && (win = null);
|
3611 | domain === conf.i && (domain = null);
|
3612 | if (!name) throw new Error("Name required to get request listener");
|
3613 | for (var _i2 = 0, _ref3 = [ win, src_global.a.WINDOW_WILDCARD ], _length2 = null == _ref3 ? 0 : _ref3.length; _i2 < _length2; _i2++) {
|
3614 | var winQualifier = _ref3[_i2];
|
3615 | if (winQualifier) {
|
3616 | var nameListeners = requestListeners.get(winQualifier);
|
3617 | if (nameListeners) {
|
3618 | var domainListeners = nameListeners[name];
|
3619 | if (domainListeners) {
|
3620 | if (domain && "string" == typeof domain) {
|
3621 | if (domainListeners[domain]) return domainListeners[domain];
|
3622 | if (domainListeners[__DOMAIN_REGEX__]) for (var _i4 = 0, _domainListeners$__DO2 = domainListeners[__DOMAIN_REGEX__], _length4 = null == _domainListeners$__DO2 ? 0 : _domainListeners$__DO2.length; _i4 < _length4; _i4++) {
|
3623 | var _ref5 = _domainListeners$__DO2[_i4], regex = _ref5.regex, listener = _ref5.listener;
|
3624 | if (Object(cross_domain_utils_src.matchDomain)(regex, domain)) return listener;
|
3625 | }
|
3626 | }
|
3627 | if (domainListeners[conf.i]) return domainListeners[conf.i];
|
3628 | }
|
3629 | }
|
3630 | }
|
3631 | }
|
3632 | }
|
3633 | var types__extends = Object.assign || function(target) {
|
3634 | for (var i = 1; i < arguments.length; i++) {
|
3635 | var source = arguments[i];
|
3636 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
3637 | }
|
3638 | return target;
|
3639 | }, RECEIVE_MESSAGE_TYPES = ((_RECEIVE_MESSAGE_TYPE = {})[conf.e.REQUEST] = function(source, origin, message) {
|
3640 | var options = getRequestListener({
|
3641 | name: message.name,
|
3642 | win: source,
|
3643 | domain: origin
|
3644 | });
|
3645 | function sendResponse(type) {
|
3646 | var data = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
3647 | return message.fireAndForget || Object(cross_domain_utils_src.isWindowClosed)(source) ? src.a.resolve() : sendMessage(source, origin, types__extends({
|
3648 | type: type,
|
3649 | hash: message.hash,
|
3650 | name: message.name
|
3651 | }, data));
|
3652 | }
|
3653 | return src.a.all([ sendResponse(conf.e.ACK), src.a.try(function() {
|
3654 | if (!options) throw new Error("No handler found for post message: " + message.name + " from " + origin + " in " + window.location.protocol + "//" + window.location.host + window.location.pathname);
|
3655 | if (!Object(cross_domain_utils_src.matchDomain)(options.domain, origin)) throw new Error("Request origin " + origin + " does not match domain " + options.domain.toString());
|
3656 | var data = message.data;
|
3657 | return options.handler({
|
3658 | source: source,
|
3659 | origin: origin,
|
3660 | data: data
|
3661 | });
|
3662 | }).then(function(data) {
|
3663 | return sendResponse(conf.e.RESPONSE, {
|
3664 | ack: conf.c.SUCCESS,
|
3665 | data: data
|
3666 | });
|
3667 | }, function(error) {
|
3668 | return sendResponse(conf.e.RESPONSE, {
|
3669 | ack: conf.c.ERROR,
|
3670 | error: error
|
3671 | });
|
3672 | }) ]).then(belter_src.noop).catch(function(err) {
|
3673 | if (options && options.handleError) return options.handleError(err);
|
3674 | throw err;
|
3675 | });
|
3676 | }, _RECEIVE_MESSAGE_TYPE[conf.e.ACK] = function(source, origin, message) {
|
3677 | if (!isResponseListenerErrored(message.hash)) {
|
3678 | var options = getResponseListener(message.hash);
|
3679 | if (!options) throw new Error("No handler found for post message ack for message: " + message.name + " from " + origin + " in " + window.location.protocol + "//" + window.location.host + window.location.pathname);
|
3680 | if (!Object(cross_domain_utils_src.matchDomain)(options.domain, origin)) throw new Error("Ack origin " + origin + " does not match domain " + options.domain.toString());
|
3681 | options.ack = !0;
|
3682 | }
|
3683 | }, _RECEIVE_MESSAGE_TYPE[conf.e.RESPONSE] = function(source, origin, message) {
|
3684 | if (!isResponseListenerErrored(message.hash)) {
|
3685 | var options = getResponseListener(message.hash);
|
3686 | if (!options) throw new Error("No handler found for post message response for message: " + message.name + " from " + origin + " in " + window.location.protocol + "//" + window.location.host + window.location.pathname);
|
3687 | if (!Object(cross_domain_utils_src.matchDomain)(options.domain, origin)) throw new Error("Response origin " + origin + " does not match domain " + Object(cross_domain_utils_src.stringifyDomainPattern)(options.domain));
|
3688 | deleteResponseListener(message.hash);
|
3689 | if (message.ack === conf.c.ERROR) return options.respond(message.error, null);
|
3690 | if (message.ack === conf.c.SUCCESS) {
|
3691 | var data = message.data;
|
3692 | return options.respond(null, {
|
3693 | source: source,
|
3694 | origin: origin,
|
3695 | data: data
|
3696 | });
|
3697 | }
|
3698 | }
|
3699 | }, _RECEIVE_MESSAGE_TYPE), receive__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
3700 | return typeof obj;
|
3701 | } : function(obj) {
|
3702 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
3703 | }, receivedMessages = Object(src_global.b)("receivedMessages");
|
3704 | function receiveMessage(event) {
|
3705 | if (!window || window.closed) throw new Error("Message recieved in closed window");
|
3706 | try {
|
3707 | if (!event.source) return;
|
3708 | } catch (err) {
|
3709 | return;
|
3710 | }
|
3711 | var source = event.source, origin = event.origin, message = function(message, source, origin) {
|
3712 | var parsedMessage = void 0;
|
3713 | try {
|
3714 | parsedMessage = deserializeMessage(source, origin, message);
|
3715 | } catch (err) {
|
3716 | return;
|
3717 | }
|
3718 | if (parsedMessage && "object" === (void 0 === parsedMessage ? "undefined" : receive__typeof(parsedMessage)) && null !== parsedMessage && (parsedMessage = parsedMessage[conf.j.POSTROBOT]) && "object" === (void 0 === parsedMessage ? "undefined" : receive__typeof(parsedMessage)) && null !== parsedMessage && parsedMessage.type && "string" == typeof parsedMessage.type && RECEIVE_MESSAGE_TYPES[parsedMessage.type]) return parsedMessage;
|
3719 | }(event.data, source, origin);
|
3720 | if (message) {
|
3721 | Object(lib.e)(source);
|
3722 | if (!receivedMessages.has(message.id)) {
|
3723 | receivedMessages.set(message.id, !0);
|
3724 | Object(cross_domain_utils_src.isWindowClosed)(source) && !message.fireAndForget || RECEIVE_MESSAGE_TYPES[message.type](source, origin, message);
|
3725 | }
|
3726 | }
|
3727 | }
|
3728 | function messageListener(event) {
|
3729 | try {
|
3730 | Object(belter_src.noop)(event.source);
|
3731 | } catch (err) {
|
3732 | return;
|
3733 | }
|
3734 | var messageEvent = {
|
3735 | source: event.source || event.sourceElement,
|
3736 | origin: event.origin || event.originalEvent && event.originalEvent.origin,
|
3737 | data: event.data
|
3738 | };
|
3739 | try {
|
3740 | __webpack_require__("./node_modules/post-robot/src/compat/index.js").emulateIERestrictions(messageEvent.source, window);
|
3741 | } catch (err) {
|
3742 | return;
|
3743 | }
|
3744 | receiveMessage(messageEvent);
|
3745 | }
|
3746 | src_global.a.receiveMessage = receiveMessage;
|
3747 | var requestPromises = Object(src_global.c)("requestPromises");
|
3748 | function request(options) {
|
3749 | return src.a.try(function() {
|
3750 | if (!options.name) throw new Error("Expected options.name");
|
3751 | var name = options.name, targetWindow = void 0, domain = void 0;
|
3752 | if ("string" == typeof options.window) {
|
3753 | var el = document.getElementById(options.window);
|
3754 | if (!el) throw new Error("Expected options.window " + Object.prototype.toString.call(options.window) + " to be a valid element id");
|
3755 | if ("iframe" !== el.tagName.toLowerCase()) throw new Error("Expected options.window " + Object.prototype.toString.call(options.window) + " to be an iframe");
|
3756 | if (!el.contentWindow) throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");
|
3757 | targetWindow = el.contentWindow;
|
3758 | } else if (options.window instanceof HTMLIFrameElement) {
|
3759 | if ("iframe" !== options.window.tagName.toLowerCase()) throw new Error("Expected options.window " + Object.prototype.toString.call(options.window) + " to be an iframe");
|
3760 | if (options.window && !options.window.contentWindow) throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");
|
3761 | options.window && options.window.contentWindow && (targetWindow = options.window.contentWindow);
|
3762 | } else targetWindow = options.window;
|
3763 | if (!targetWindow) throw new Error("Expected options.window to be a window object, iframe, or iframe element id.");
|
3764 | var win = targetWindow;
|
3765 | domain = options.domain || conf.i;
|
3766 | var hash = options.name + "_" + Object(belter_src.uniqueID)();
|
3767 | if (Object(cross_domain_utils_src.isWindowClosed)(win)) throw new Error("Target window is closed");
|
3768 | var hasResult = !1, reqPromises = requestPromises.getOrSet(win, function() {
|
3769 | return [];
|
3770 | }), requestPromise = src.a.try(function() {
|
3771 | if (Object(cross_domain_utils_src.isAncestor)(window, win)) return Object(lib.a)(win, options.timeout || conf.b.CHILD_WINDOW_TIMEOUT);
|
3772 | }).then(function() {
|
3773 | var origin = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).domain;
|
3774 | if (Object(belter_src.isRegex)(domain) && !origin) return Object(lib.g)(win);
|
3775 | }).then(function() {
|
3776 | var origin = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).domain;
|
3777 | if (Object(belter_src.isRegex)(domain)) {
|
3778 | if (!Object(cross_domain_utils_src.matchDomain)(domain, origin)) throw new Error("Remote window domain " + origin + " does not match regex: " + domain.toString());
|
3779 | domain = origin;
|
3780 | }
|
3781 | if ("string" != typeof domain && !Array.isArray(domain)) throw new TypeError("Expected domain to be a string or array");
|
3782 | var actualDomain = domain;
|
3783 | return new src.a(function(resolve, reject) {
|
3784 | var responseListener = void 0;
|
3785 | options.fireAndForget || function(hash, listener) {
|
3786 | responseListeners.set(hash, listener);
|
3787 | }(hash, responseListener = {
|
3788 | name: name,
|
3789 | window: win,
|
3790 | domain: actualDomain,
|
3791 | respond: function(err, result) {
|
3792 | if (!err) {
|
3793 | hasResult = !0;
|
3794 | reqPromises.splice(reqPromises.indexOf(requestPromise, 1));
|
3795 | }
|
3796 | err ? reject(err) : resolve(result);
|
3797 | }
|
3798 | });
|
3799 | sendMessage(win, actualDomain, {
|
3800 | type: conf.e.REQUEST,
|
3801 | hash: hash,
|
3802 | name: name,
|
3803 | data: options.data,
|
3804 | fireAndForget: Boolean(options.fireAndForget)
|
3805 | }).catch(reject);
|
3806 | if (options.fireAndForget) return resolve();
|
3807 | var totalAckTimeout = Object(lib.d)(win) ? conf.b.ACK_TIMEOUT_KNOWN : conf.b.ACK_TIMEOUT, totalResTimeout = options.timeout || conf.b.RES_TIMEOUT, ackTimeout = totalAckTimeout, resTimeout = totalResTimeout, cycleTime = 100;
|
3808 | setTimeout(function cycle() {
|
3809 | if (!hasResult) {
|
3810 | if (Object(cross_domain_utils_src.isWindowClosed)(win)) return responseListener.ack ? reject(new Error("Window closed for " + name + " before response")) : reject(new Error("Window closed for " + name + " before ack"));
|
3811 | ackTimeout = Math.max(ackTimeout - cycleTime, 0);
|
3812 | -1 !== resTimeout && (resTimeout = Math.max(resTimeout - cycleTime, 0));
|
3813 | if (responseListener.ack) {
|
3814 | if (-1 === resTimeout) return;
|
3815 | cycleTime = Math.min(resTimeout, 2e3);
|
3816 | } else {
|
3817 | if (0 === ackTimeout) return reject(new Error("No ack for postMessage " + name + " in " + Object(cross_domain_utils_src.getDomain)() + " in " + totalAckTimeout + "ms"));
|
3818 | if (0 === resTimeout) return reject(new Error("No response for postMessage " + name + " in " + Object(cross_domain_utils_src.getDomain)() + " in " + totalResTimeout + "ms"));
|
3819 | }
|
3820 | setTimeout(cycle, cycleTime);
|
3821 | }
|
3822 | }, cycleTime);
|
3823 | });
|
3824 | });
|
3825 | requestPromise.catch(function() {
|
3826 | !function(hash) {
|
3827 | erroredResponseListeners.set(hash, !0);
|
3828 | }(hash);
|
3829 | deleteResponseListener(hash);
|
3830 | });
|
3831 | reqPromises.push(requestPromise);
|
3832 | return requestPromise;
|
3833 | });
|
3834 | }
|
3835 | function _send(window, name, data, options) {
|
3836 | (options = options || {}).window = window;
|
3837 | options.name = name;
|
3838 | options.data = data;
|
3839 | return request(options);
|
3840 | }
|
3841 | function sendToParent(name, data, options) {
|
3842 | var win = Object(cross_domain_utils_src.getAncestor)();
|
3843 | return win ? _send(win, name, data, options) : new src.a(function(resolve, reject) {
|
3844 | return reject(new Error("Window does not have a parent"));
|
3845 | });
|
3846 | }
|
3847 | function client() {
|
3848 | var options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
3849 | if (!options.window) throw new Error("Expected options.window");
|
3850 | var win = options.window;
|
3851 | return {
|
3852 | send: function(name, data) {
|
3853 | return _send(win, name, data, options);
|
3854 | }
|
3855 | };
|
3856 | }
|
3857 | src_global.a.send = _send;
|
3858 | var server__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
3859 | return typeof obj;
|
3860 | } : function(obj) {
|
3861 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
3862 | };
|
3863 | function listen(options) {
|
3864 | if (!options.name) throw new Error("Expected options.name");
|
3865 | if (!options.handler) throw new Error("Expected options.handler");
|
3866 | var name = options.name, win = options.window, domain = options.domain, listenerOptions = {
|
3867 | handler: options.handler,
|
3868 | handleError: options.errorHandler || function(err) {
|
3869 | throw err;
|
3870 | },
|
3871 | window: win,
|
3872 | domain: domain || conf.i,
|
3873 | name: name
|
3874 | }, requestListener = function addRequestListener(_ref6, listener) {
|
3875 | var name = _ref6.name, win = _ref6.win, domain = _ref6.domain;
|
3876 | if (!name || "string" != typeof name) throw new Error("Name required to add request listener");
|
3877 | if (Array.isArray(win)) {
|
3878 | for (var listenersCollection = [], _i6 = 0, _win2 = win, _length6 = null == _win2 ? 0 : _win2.length; _i6 < _length6; _i6++) {
|
3879 | var item = _win2[_i6];
|
3880 | listenersCollection.push(addRequestListener({
|
3881 | name: name,
|
3882 | domain: domain,
|
3883 | win: item
|
3884 | }, listener));
|
3885 | }
|
3886 | return {
|
3887 | cancel: function() {
|
3888 | for (var _i8 = 0, _length8 = null == listenersCollection ? 0 : listenersCollection.length; _i8 < _length8; _i8++) listenersCollection[_i8].cancel();
|
3889 | }
|
3890 | };
|
3891 | }
|
3892 | if (Array.isArray(domain)) {
|
3893 | for (var _listenersCollection = [], _i10 = 0, _domain2 = domain, _length10 = null == _domain2 ? 0 : _domain2.length; _i10 < _length10; _i10++) {
|
3894 | var _item = _domain2[_i10];
|
3895 | _listenersCollection.push(addRequestListener({
|
3896 | name: name,
|
3897 | win: win,
|
3898 | domain: _item
|
3899 | }, listener));
|
3900 | }
|
3901 | return {
|
3902 | cancel: function() {
|
3903 | for (var _i12 = 0, _length12 = null == _listenersCollection ? 0 : _listenersCollection.length; _i12 < _length12; _i12++) _listenersCollection[_i12].cancel();
|
3904 | }
|
3905 | };
|
3906 | }
|
3907 | var existingListener = getRequestListener({
|
3908 | name: name,
|
3909 | win: win,
|
3910 | domain: domain
|
3911 | });
|
3912 | win && win !== conf.i || (win = src_global.a.WINDOW_WILDCARD);
|
3913 | domain = domain || conf.i;
|
3914 | if (existingListener) throw win && domain ? new Error("Request listener already exists for " + name + " on domain " + domain.toString() + " for " + (win === src_global.a.WINDOW_WILDCARD ? "wildcard" : "specified") + " window") : win ? new Error("Request listener already exists for " + name + " for " + (win === src_global.a.WINDOW_WILDCARD ? "wildcard" : "specified") + " window") : domain ? new Error("Request listener already exists for " + name + " on domain " + domain.toString()) : new Error("Request listener already exists for " + name);
|
3915 | var nameListeners = requestListeners.getOrSet(win, function() {
|
3916 | return {};
|
3917 | }), domainListeners = Object(belter_src.getOrSet)(nameListeners, name, function() {
|
3918 | return {};
|
3919 | }), strDomain = domain.toString(), regexListeners = void 0, regexListener = void 0;
|
3920 | if (Object(belter_src.isRegex)(domain)) {
|
3921 | regexListeners = Object(belter_src.getOrSet)(domainListeners, __DOMAIN_REGEX__, function() {
|
3922 | return [];
|
3923 | });
|
3924 | regexListener = {
|
3925 | regex: domain,
|
3926 | listener: listener
|
3927 | };
|
3928 | regexListeners.push(regexListener);
|
3929 | } else domainListeners[strDomain] = listener;
|
3930 | return {
|
3931 | cancel: function() {
|
3932 | delete domainListeners[strDomain];
|
3933 | if (regexListener) {
|
3934 | regexListeners.splice(regexListeners.indexOf(regexListener, 1));
|
3935 | regexListeners.length || delete domainListeners[__DOMAIN_REGEX__];
|
3936 | }
|
3937 | Object.keys(domainListeners).length || delete nameListeners[name];
|
3938 | win && !Object.keys(nameListeners).length && requestListeners.del(win);
|
3939 | }
|
3940 | };
|
3941 | }({
|
3942 | name: name,
|
3943 | win: win,
|
3944 | domain: domain
|
3945 | }, listenerOptions);
|
3946 | if (options.once) {
|
3947 | var _handler = listenerOptions.handler;
|
3948 | listenerOptions.handler = Object(belter_src.once)(function() {
|
3949 | requestListener.cancel();
|
3950 | return _handler.apply(this, arguments);
|
3951 | });
|
3952 | }
|
3953 | if (listenerOptions.window && options.errorOnClose) var interval = Object(belter_src.safeInterval)(function() {
|
3954 | if (win && "object" === (void 0 === win ? "undefined" : server__typeof(win)) && Object(cross_domain_utils_src.isWindowClosed)(win)) {
|
3955 | interval.cancel();
|
3956 | listenerOptions.handleError(new Error("Post message target window is closed"));
|
3957 | }
|
3958 | }, 50);
|
3959 | return {
|
3960 | cancel: function() {
|
3961 | requestListener.cancel();
|
3962 | }
|
3963 | };
|
3964 | }
|
3965 | function _on(name, options, handler) {
|
3966 | if ("function" == typeof options) {
|
3967 | handler = options;
|
3968 | options = {};
|
3969 | }
|
3970 | (options = options || {}).name = name;
|
3971 | options.handler = handler || options.handler;
|
3972 | return listen(options);
|
3973 | }
|
3974 | function once(name) {
|
3975 | var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, handler = arguments[2];
|
3976 | if ("function" == typeof options) {
|
3977 | handler = options;
|
3978 | options = {};
|
3979 | }
|
3980 | options = options || {};
|
3981 | handler = handler || options.handler;
|
3982 | var errorHandler = options.errorHandler, promise = new src.a(function(resolve, reject) {
|
3983 | (options = options || {}).name = name;
|
3984 | options.once = !0;
|
3985 | options.handler = function(event) {
|
3986 | resolve(event);
|
3987 | if (handler) return handler(event);
|
3988 | };
|
3989 | options.errorHandler = function(err) {
|
3990 | reject(err);
|
3991 | if (errorHandler) return errorHandler(err);
|
3992 | };
|
3993 | }), onceListener = listen(options);
|
3994 | promise.cancel = onceListener.cancel;
|
3995 | return promise;
|
3996 | }
|
3997 | function server_listener() {
|
3998 | var options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
3999 | return {
|
4000 | on: function(name, handler) {
|
4001 | return _on(name, options, handler);
|
4002 | }
|
4003 | };
|
4004 | }
|
4005 | src_global.a.on = _on;
|
4006 | function disable() {
|
4007 | delete window[conf.j.POSTROBOT];
|
4008 | window.removeEventListener("message", messageListener);
|
4009 | }
|
4010 | var public_parent = Object(cross_domain_utils_src.getAncestor)();
|
4011 | function cleanUpWindow(win) {
|
4012 | for (var _i2 = 0, _requestPromises$get2 = requestPromises.get(win, []), _length2 = null == _requestPromises$get2 ? 0 : _requestPromises$get2.length; _i2 < _length2; _i2++) _requestPromises$get2[_i2].reject(new Error("Window cleaned up before response"));
|
4013 | }
|
4014 | var bridge = __webpack_require__("./node_modules/post-robot/src/bridge/interface.js");
|
4015 | if (!src_global.a.initialized) {
|
4016 | src_global.a.initialized = !0;
|
4017 | Object(belter_src.addEventListener)(window, "message", messageListener);
|
4018 | bridge && bridge.openTunnelToOpener();
|
4019 | Object(lib.c)();
|
4020 | }
|
4021 | var post_robot_src = interface_namespaceObject, node__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
4022 | return typeof obj;
|
4023 | } : function(obj) {
|
4024 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
4025 | };
|
4026 | function _possibleConstructorReturn(self, call) {
|
4027 | if (!self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
4028 | return !call || "object" != typeof call && "function" != typeof call ? self : call;
|
4029 | }
|
4030 | function _inherits(subClass, superClass) {
|
4031 | if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
4032 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
4033 | constructor: {
|
4034 | value: subClass,
|
4035 | enumerable: !1,
|
4036 | writable: !0,
|
4037 | configurable: !0
|
4038 | }
|
4039 | });
|
4040 | superClass && (Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass);
|
4041 | }
|
4042 | function node__classCallCheck(instance, Constructor) {
|
4043 | if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
4044 | }
|
4045 | var Node = function() {
|
4046 | function Node() {
|
4047 | node__classCallCheck(this, Node);
|
4048 | }
|
4049 | Node.prototype.isElementNode = function() {
|
4050 | return !1;
|
4051 | };
|
4052 | Node.prototype.isTextNode = function() {
|
4053 | return !1;
|
4054 | };
|
4055 | Node.prototype.isFragmentNode = function() {
|
4056 | return !1;
|
4057 | };
|
4058 | return Node;
|
4059 | }(), ElementNode = function(_Node) {
|
4060 | _inherits(ElementNode, _Node);
|
4061 | function ElementNode(name, props, children) {
|
4062 | node__classCallCheck(this, ElementNode);
|
4063 | var _this = _possibleConstructorReturn(this, _Node.call(this));
|
4064 | _this.name = name;
|
4065 | _this.props = props;
|
4066 | _this.children = children;
|
4067 | if ("function" == typeof props.onRender) {
|
4068 | _this.onRender = props.onRender;
|
4069 | delete props.onRender;
|
4070 | }
|
4071 | return _this;
|
4072 | }
|
4073 | ElementNode.prototype.getTag = function() {
|
4074 | return this.name;
|
4075 | };
|
4076 | ElementNode.prototype.isTag = function(name) {
|
4077 | return name === this.name;
|
4078 | };
|
4079 | ElementNode.prototype.isElementNode = function() {
|
4080 | return !0;
|
4081 | };
|
4082 | ElementNode.prototype.render = function(renderer) {
|
4083 | var element = renderer(this.name, this.props, this.children);
|
4084 | this.onRender && this.onRender(element);
|
4085 | return element;
|
4086 | };
|
4087 | ElementNode.prototype.getText = function() {
|
4088 | throw new Error("Can not get text of an element node");
|
4089 | };
|
4090 | return ElementNode;
|
4091 | }(Node), TextNode = function(_Node2) {
|
4092 | _inherits(TextNode, _Node2);
|
4093 | function TextNode(text) {
|
4094 | node__classCallCheck(this, TextNode);
|
4095 | var _this2 = _possibleConstructorReturn(this, _Node2.call(this));
|
4096 | _this2.text = text;
|
4097 | return _this2;
|
4098 | }
|
4099 | TextNode.prototype.getTag = function() {
|
4100 | throw new Error("Can not get tag of text node");
|
4101 | };
|
4102 | TextNode.prototype.isTag = function(name) {
|
4103 | throw new Error("Can not check tag of text node");
|
4104 | };
|
4105 | TextNode.prototype.isTextNode = function() {
|
4106 | return !0;
|
4107 | };
|
4108 | TextNode.prototype.render = function(renderer) {
|
4109 | throw new Error("Can not render a text node");
|
4110 | };
|
4111 | TextNode.prototype.getText = function() {
|
4112 | return this.text;
|
4113 | };
|
4114 | return TextNode;
|
4115 | }(Node), FragmentNode = function(_Node3) {
|
4116 | _inherits(FragmentNode, _Node3);
|
4117 | function FragmentNode(children) {
|
4118 | node__classCallCheck(this, FragmentNode);
|
4119 | var _this3 = _possibleConstructorReturn(this, _Node3.call(this));
|
4120 | _this3.children = children;
|
4121 | return _this3;
|
4122 | }
|
4123 | FragmentNode.prototype.getTag = function() {
|
4124 | throw new Error("Can not get tag of fragment node");
|
4125 | };
|
4126 | FragmentNode.prototype.isTag = function(name) {
|
4127 | throw new Error("Can not check tag of fragment node");
|
4128 | };
|
4129 | FragmentNode.prototype.isFragmentNode = function() {
|
4130 | return !0;
|
4131 | };
|
4132 | FragmentNode.prototype.render = function(renderer) {
|
4133 | throw new Error("Can not render a fragment node");
|
4134 | };
|
4135 | FragmentNode.prototype.getText = function() {
|
4136 | throw new Error("Can not get text of a fragment node");
|
4137 | };
|
4138 | return FragmentNode;
|
4139 | }(Node);
|
4140 | function normalizeChild(child) {
|
4141 | if ("string" == typeof child) return new TextNode(child);
|
4142 | if (child instanceof ElementNode || child instanceof TextNode || child instanceof FragmentNode) return child;
|
4143 | if (Array.isArray(child)) return new FragmentNode(normalizeChildren(child));
|
4144 | if (null !== child && void 0 !== child) throw new Error("Child node must be string or instance of jsx-pragmatic node; got " + (void 0 === child ? "undefined" : node__typeof(child)));
|
4145 | }
|
4146 | function normalizeChildren(children) {
|
4147 | for (var result = [], _i2 = 0, _length2 = null == children ? 0 : children.length; _i2 < _length2; _i2++) {
|
4148 | var normalizedChild = normalizeChild(children[_i2]);
|
4149 | if (normalizedChild) if (normalizedChild instanceof FragmentNode) for (var _i4 = 0, _normalizedChild$chil2 = normalizedChild.children, _length4 = null == _normalizedChild$chil2 ? 0 : _normalizedChild$chil2.length; _i4 < _length4; _i4++) {
|
4150 | var subchild = _normalizedChild$chil2[_i4];
|
4151 | result.push(subchild);
|
4152 | } else result.push(normalizedChild);
|
4153 | }
|
4154 | return result;
|
4155 | }
|
4156 | var _CREATE_ELEMENT, _ADD_CHILDREN, node = function(element, props) {
|
4157 | for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) children[_key - 2] = arguments[_key];
|
4158 | if ("string" == typeof element) return new ElementNode(element, props || {}, normalizeChildren(children));
|
4159 | if ("function" == typeof element) return normalizeChild(element(props || {}, normalizeChildren(children)));
|
4160 | throw new TypeError("Expected jsx Element to be a string or a function");
|
4161 | }, dom__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
4162 | return typeof obj;
|
4163 | } : function(obj) {
|
4164 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
4165 | }, ELEMENT_TAG_HTML = "html", ELEMENT_TAG_IFRAME = "iframe", ELEMENT_TAG_SCRIPT = "script", ELEMENT_TAG_NODE = "node", ELEMENT_TAG_DEFAULT = "default", ELEMENT_PROP_INNER_HTML = "innerHTML", ELEMENT_PROP_EL = "el", DOM_EVENT = {
|
4166 | onBlur: "blur",
|
4167 | onCancel: "cancel",
|
4168 | onClick: "click",
|
4169 | onClose: "close",
|
4170 | onContextMenu: "contextMenu",
|
4171 | onCopy: "copy",
|
4172 | onCut: "cut",
|
4173 | onAuxClick: "auxClick",
|
4174 | onDoubleClick: "doubleClick",
|
4175 | onDragEnd: "dragEnd",
|
4176 | onDragStart: "dragStart",
|
4177 | onDrop: "drop",
|
4178 | onFocus: "focus",
|
4179 | onInput: "input",
|
4180 | onInvalid: "invalid",
|
4181 | onKeyDown: "keyDown",
|
4182 | onKeyPress: "keyPress",
|
4183 | onKeyUp: "keyUp",
|
4184 | onMouseDown: "mouseDown",
|
4185 | onMouseUp: "mouseUp",
|
4186 | onPaste: "paste",
|
4187 | onPause: "pause",
|
4188 | onPlay: "play",
|
4189 | onPointerCancel: "pointerCancel",
|
4190 | onPointerDown: "pointerDown",
|
4191 | onPointerUp: "pointerUp",
|
4192 | onRateChange: "rateChange",
|
4193 | onReset: "reset",
|
4194 | onSeeked: "seeked",
|
4195 | onSubmit: "submit",
|
4196 | onTouchCancel: "touchCancel",
|
4197 | onTouchEnd: "touchEnd",
|
4198 | onTouchStart: "touchStart",
|
4199 | onVolumeChange: "volumeChange",
|
4200 | onAbort: "abort",
|
4201 | onAnimationEnd: "animationEnd",
|
4202 | onAnimationIteration: "animationIteration",
|
4203 | onAnimationStart: "animationStart",
|
4204 | onCanPlay: "canPlay",
|
4205 | onCanPlayThrough: "canPlayThrough",
|
4206 | onDrag: "drag",
|
4207 | onDragEnter: "dragEnter",
|
4208 | onDragExit: "dragExit",
|
4209 | onDragLeave: "dragLeave",
|
4210 | onDragOver: "dragOver",
|
4211 | onDurationChange: "durationChange",
|
4212 | onEmptied: "emptied",
|
4213 | onEncrypted: "encrypted",
|
4214 | onEnded: "ended",
|
4215 | onError: "error",
|
4216 | onGotPointerCapture: "gotPointerCapture",
|
4217 | onLoad: "load",
|
4218 | onLoadedData: "loadedData",
|
4219 | onLoadedMetadata: "loadedMetadata",
|
4220 | onLoadStart: "loadStart",
|
4221 | onLostPointerCapture: "lostPointerCapture",
|
4222 | onMouseMove: "mouseMove",
|
4223 | onMouseOut: "mouseOut",
|
4224 | onMouseOver: "mouseOver",
|
4225 | onPlaying: "playing",
|
4226 | onPointerMove: "pointerMove",
|
4227 | onPointerOut: "pointerOut",
|
4228 | onPointerOver: "pointerOver",
|
4229 | onProgress: "progress",
|
4230 | onScroll: "scroll",
|
4231 | onSeeking: "seeking",
|
4232 | onStalled: "stalled",
|
4233 | onSuspend: "suspend",
|
4234 | onTimeUpdate: "timeUpdate",
|
4235 | onToggle: "toggle",
|
4236 | onTouchMove: "touchMove",
|
4237 | onTransitionEnd: "transitionEnd",
|
4238 | onWaiting: "waiting",
|
4239 | onWheel: "wheel"
|
4240 | }, CREATE_ELEMENT = ((_CREATE_ELEMENT = {})[ELEMENT_TAG_NODE] = function(_ref) {
|
4241 | var props = _ref.props;
|
4242 | if (!props[ELEMENT_PROP_EL]) throw new Error("Must pass " + ELEMENT_PROP_EL + " prop to " + ELEMENT_TAG_NODE + " element");
|
4243 | if (Object.keys(props).length > 1) throw new Error("Must not pass any prop other than " + ELEMENT_PROP_EL + " to " + ELEMENT_TAG_NODE + " element");
|
4244 | return props[ELEMENT_PROP_EL];
|
4245 | }, _CREATE_ELEMENT[ELEMENT_TAG_DEFAULT] = function(_ref2) {
|
4246 | var name = _ref2.name;
|
4247 | return _ref2.doc.createElement(name);
|
4248 | }, _CREATE_ELEMENT), ADD_CHILDREN = ((_ADD_CHILDREN = {})[ELEMENT_TAG_IFRAME] = function(_ref5) {
|
4249 | var el = _ref5.el, children = _ref5.children, firstChild = children[0];
|
4250 | if (children.length > 1 || !firstChild.isElementNode()) throw new Error("Expected only single element node as child of " + ELEMENT_TAG_IFRAME + " element");
|
4251 | if (!firstChild.isTag(ELEMENT_TAG_HTML)) throw new Error("Expected element to be inserted into frame to be html, got " + firstChild.getTag());
|
4252 | el.addEventListener("load", function() {
|
4253 | var win = el.contentWindow;
|
4254 | if (!win) throw new Error("Expected frame to have contentWindow");
|
4255 | for (var doc = win.document, docElement = doc.documentElement; docElement.children && docElement.children.length; ) docElement.removeChild(docElement.children[0]);
|
4256 | for (var child = firstChild.render(dom_dom({
|
4257 | doc: doc
|
4258 | })); child.children.length; ) docElement.appendChild(child.children[0]);
|
4259 | });
|
4260 | }, _ADD_CHILDREN[ELEMENT_TAG_SCRIPT] = function(_ref6) {
|
4261 | var el = _ref6.el, children = _ref6.children, firstChild = children[0];
|
4262 | if (1 !== children.length || !firstChild.isTextNode()) throw new Error("Expected only single text node as child of " + ELEMENT_TAG_SCRIPT + " element");
|
4263 | el.text = firstChild.getText();
|
4264 | }, _ADD_CHILDREN[ELEMENT_TAG_DEFAULT] = function(_ref7) {
|
4265 | for (var el = _ref7.el, children = _ref7.children, doc = _ref7.doc, domRenderer = _ref7.domRenderer, _i6 = 0, _length6 = null == children ? 0 : children.length; _i6 < _length6; _i6++) {
|
4266 | var child = children[_i6];
|
4267 | child.isTextNode() ? el.appendChild(doc.createTextNode(child.getText())) : el.appendChild(child.render(domRenderer));
|
4268 | }
|
4269 | }, _ADD_CHILDREN), dom_dom = function() {
|
4270 | var _ref9$doc = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).doc, doc = void 0 === _ref9$doc ? document : _ref9$doc;
|
4271 | return function domRenderer(name, props, children) {
|
4272 | var el = function(_ref3) {
|
4273 | var doc = _ref3.doc, name = _ref3.name, props = _ref3.props;
|
4274 | return (CREATE_ELEMENT[name] || CREATE_ELEMENT[ELEMENT_TAG_DEFAULT])({
|
4275 | name: name,
|
4276 | props: props,
|
4277 | doc: doc
|
4278 | });
|
4279 | }({
|
4280 | name: name,
|
4281 | props: props,
|
4282 | doc: doc
|
4283 | });
|
4284 | !function(_ref4) {
|
4285 | for (var el = _ref4.el, props = _ref4.props, _i4 = 0, _Object$keys2 = Object.keys(props), _length4 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i4 < _length4; _i4++) {
|
4286 | var prop = _Object$keys2[_i4], val = props[prop];
|
4287 | if (null !== val && void 0 !== val && prop !== ELEMENT_PROP_EL && prop !== ELEMENT_PROP_INNER_HTML) if (DOM_EVENT.hasOwnProperty(prop)) {
|
4288 | if (void 0 !== val && "function" != typeof val) throw new TypeError("Prop " + prop + " must be function");
|
4289 | el.addEventListener(DOM_EVENT[prop], val);
|
4290 | } else if ("string" == typeof val || "number" == typeof val) el.setAttribute(prop, val.toString()); else {
|
4291 | if ("boolean" != typeof val) throw new TypeError("Can not render prop " + prop + " of type " + (void 0 === val ? "undefined" : dom__typeof(val)));
|
4292 | !0 === val && el.setAttribute(prop, "");
|
4293 | }
|
4294 | }
|
4295 | }({
|
4296 | el: el,
|
4297 | props: props
|
4298 | });
|
4299 | !function(_ref8) {
|
4300 | var el = _ref8.el, name = _ref8.name, props = _ref8.props, children = _ref8.children, doc = _ref8.doc, domRenderer = _ref8.domRenderer;
|
4301 | if (props.hasOwnProperty(ELEMENT_PROP_INNER_HTML)) {
|
4302 | if (children.length >= 1) throw new Error("Expected no children to be passed when " + ELEMENT_PROP_INNER_HTML + " prop is set");
|
4303 | var html = props[ELEMENT_PROP_INNER_HTML];
|
4304 | if ("string" != typeof html) throw new TypeError(ELEMENT_PROP_INNER_HTML + " prop must be string");
|
4305 | if (name === ELEMENT_TAG_SCRIPT) el.text = html; else {
|
4306 | el.innerHTML = html;
|
4307 | !function(el) {
|
4308 | for (var doc = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : window.document, _i2 = 0, _el$querySelectorAll2 = el.querySelectorAll("script"), _length2 = null == _el$querySelectorAll2 ? 0 : _el$querySelectorAll2.length; _i2 < _length2; _i2++) {
|
4309 | var script = _el$querySelectorAll2[_i2], parentNode = script.parentNode;
|
4310 | if (parentNode) {
|
4311 | var newScript = doc.createElement("script");
|
4312 | newScript.text = script.textContent;
|
4313 | parentNode.replaceChild(newScript, script);
|
4314 | }
|
4315 | }
|
4316 | }(el, doc);
|
4317 | }
|
4318 | } else (ADD_CHILDREN[name] || ADD_CHILDREN[ELEMENT_TAG_DEFAULT])({
|
4319 | el: el,
|
4320 | name: name,
|
4321 | props: props,
|
4322 | children: children,
|
4323 | doc: doc,
|
4324 | domRenderer: domRenderer
|
4325 | });
|
4326 | }({
|
4327 | el: el,
|
4328 | name: name,
|
4329 | props: props,
|
4330 | children: children,
|
4331 | doc: doc,
|
4332 | domRenderer: domRenderer
|
4333 | });
|
4334 | return el;
|
4335 | };
|
4336 | };
|
4337 | "function" == typeof Symbol && Symbol.iterator;
|
4338 | function getCurrentScriptDir() {
|
4339 | console.warn("Do not use zoid.getCurrentScriptDir() in production -- browser support is limited");
|
4340 | return document.currentScript ? document.currentScript.src.split("/").slice(0, -1).join("/") : ".";
|
4341 | }
|
4342 | var logger = void 0;
|
4343 | function useLogger(newLogger) {
|
4344 | logger = newLogger;
|
4345 | }
|
4346 | var constants = __webpack_require__("./src/constants.js");
|
4347 | function globalFor(win) {
|
4348 | if (Object(cross_domain_utils_src.isSameDomain)(win)) {
|
4349 | win[constants.__ZOID__] || (win[constants.__ZOID__] = {});
|
4350 | return win[constants.__ZOID__];
|
4351 | }
|
4352 | }
|
4353 | var global_global = function() {
|
4354 | var global = globalFor(window);
|
4355 | if (!global) throw new Error("Could not get local global");
|
4356 | return global;
|
4357 | }();
|
4358 | function cleanup(obj) {
|
4359 | var tasks = [], cleaned = !1;
|
4360 | return {
|
4361 | set: function(name, item) {
|
4362 | if (cleaned) return item;
|
4363 | obj[name] = item;
|
4364 | this.register(function() {
|
4365 | delete obj[name];
|
4366 | });
|
4367 | return item;
|
4368 | },
|
4369 | register: function(name, method) {
|
4370 | if ("function" == typeof name) {
|
4371 | method = name;
|
4372 | name = "<anonymous-cleanup-handler>";
|
4373 | }
|
4374 | if ("function" != typeof method) throw new TypeError("Expected to be passed function to clean.register");
|
4375 | cleaned ? method() : tasks.push({
|
4376 | complete: !1,
|
4377 | name: name,
|
4378 | run: function() {
|
4379 | if (!this.complete) {
|
4380 | this.complete = !0;
|
4381 | method && method();
|
4382 | }
|
4383 | }
|
4384 | });
|
4385 | },
|
4386 | hasTasks: function() {
|
4387 | return Boolean(tasks.filter(function(item) {
|
4388 | return !item.complete;
|
4389 | }).length);
|
4390 | },
|
4391 | all: function() {
|
4392 | var results = [];
|
4393 | cleaned = !0;
|
4394 | for (;tasks.length; ) results.push(tasks.pop().run());
|
4395 | return src.a.all(results).then(function() {});
|
4396 | },
|
4397 | run: function(name) {
|
4398 | for (var results = [], _i2 = 0, _length2 = null == tasks ? 0 : tasks.length; _i2 < _length2; _i2++) {
|
4399 | var item = tasks[_i2];
|
4400 | item.name === name && results.push(item.run());
|
4401 | }
|
4402 | return src.a.all(results).then(belter_src.noop);
|
4403 | }
|
4404 | };
|
4405 | }
|
4406 | var _class, parseChildWindowName = Object(belter_src.memoize)(function() {
|
4407 | if (!window.name) throw new Error("No window name");
|
4408 | var _window$name$split = window.name.split("__"), zoidcomp = _window$name$split[1], name = _window$name$split[2], encodedPayload = _window$name$split[3];
|
4409 | if (zoidcomp !== constants.ZOID) throw new Error("Window not rendered by zoid - got " + zoidcomp);
|
4410 | if (!name) throw new Error("Expected component name");
|
4411 | if (!encodedPayload) throw new Error("Expected encoded payload");
|
4412 | try {
|
4413 | return JSON.parse(Object(belter_src.base64decode)(encodedPayload));
|
4414 | } catch (err) {
|
4415 | throw new Error("Can not decode window name payload: " + encodedPayload + ": " + Object(belter_src.stringifyError)(err));
|
4416 | }
|
4417 | }), isZoidComponentWindow = Object(belter_src.memoize)(function() {
|
4418 | try {
|
4419 | parseChildWindowName();
|
4420 | } catch (err) {
|
4421 | return !1;
|
4422 | }
|
4423 | return !0;
|
4424 | });
|
4425 | function normalizeChildProp(component, props, key, value) {
|
4426 | var prop = component.getProp(key);
|
4427 | return prop && "function" == typeof prop.childDecorate ? prop.childDecorate(value) : value;
|
4428 | }
|
4429 | var child_ChildComponent = (function(target, property, decorators, descriptor, context) {
|
4430 | var desc = {};
|
4431 | Object.keys(descriptor).forEach(function(key) {
|
4432 | desc[key] = descriptor[key];
|
4433 | });
|
4434 | desc.enumerable = !!desc.enumerable;
|
4435 | desc.configurable = !!desc.configurable;
|
4436 | ("value" in desc || desc.initializer) && (desc.writable = !0);
|
4437 | desc = decorators.slice().reverse().reduce(function(desc, decorator) {
|
4438 | return decorator(target, "watchForResize", desc) || desc;
|
4439 | }, desc);
|
4440 | if (context && void 0 !== desc.initializer) {
|
4441 | desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
|
4442 | desc.initializer = void 0;
|
4443 | }
|
4444 | if (void 0 === desc.initializer) {
|
4445 | Object.defineProperty(target, "watchForResize", desc);
|
4446 | desc = null;
|
4447 | }
|
4448 | }((_class = function() {
|
4449 | function ChildComponent(component) {
|
4450 | var _this = this;
|
4451 | !function(instance, Constructor) {
|
4452 | if (!(instance instanceof ChildComponent)) throw new TypeError("Cannot call a class as a function");
|
4453 | }(this);
|
4454 | src.a.try(function() {
|
4455 | if (window.xchild || window.xprops) throw _this.component.createError("Can not attach multiple components to the same window");
|
4456 | _this.component = component;
|
4457 | _this.onPropHandlers = [];
|
4458 | var _parseChildWindowName = parseChildWindowName(), parent = _parseChildWindowName.parent, domain = _parseChildWindowName.domain, exports = _parseChildWindowName.exports, context = _parseChildWindowName.context, props = _parseChildWindowName.props;
|
4459 | _this.context = context;
|
4460 | _this.parentComponentWindow = _this.getWindowByRef(parent);
|
4461 | _this.parentExports = deserializeMessage(_this.parentComponentWindow, domain, exports);
|
4462 | _this.checkParentDomain(domain);
|
4463 | window.xchild = _this.component.xchild = _this;
|
4464 | var initialProps = _this.getPropsByRef(_this.parentComponentWindow, domain, props);
|
4465 | _this.setProps(initialProps, domain);
|
4466 | Object(lib.e)(_this.parentComponentWindow);
|
4467 | _this.watchForClose();
|
4468 | return _this.parentExports.init(_this.buildExports());
|
4469 | }).then(function() {
|
4470 | return _this.watchForResize();
|
4471 | }).catch(function(err) {
|
4472 | _this.error(err);
|
4473 | });
|
4474 | }
|
4475 | ChildComponent.prototype.checkParentDomain = function(domain) {
|
4476 | if (!Object(cross_domain_utils_src.matchDomain)(this.component.allowedParentDomains, domain)) throw new Error("Can not be rendered by domain: " + domain);
|
4477 | };
|
4478 | ChildComponent.prototype.onProps = function(handler) {
|
4479 | this.onPropHandlers.push(handler);
|
4480 | };
|
4481 | ChildComponent.prototype.getPropsByRef = function(parentComponentWindow, domain, _ref) {
|
4482 | var type = _ref.type, value = _ref.value, uid = _ref.uid, props = void 0;
|
4483 | if (type === constants.INITIAL_PROPS.RAW) props = value; else if (type === constants.INITIAL_PROPS.UID) {
|
4484 | if (!Object(cross_domain_utils_src.isSameDomain)(parentComponentWindow)) {
|
4485 | if ("file:" === window.location.protocol) throw new Error("Can not get props from file:// domain");
|
4486 | throw new Error("Parent component window is on a different domain - expected " + Object(cross_domain_utils_src.getDomain)() + " - can not retrieve props");
|
4487 | }
|
4488 | var global = globalFor(parentComponentWindow);
|
4489 | if (!global) throw new Error("Can not find global for parent component - can not retrieve props");
|
4490 | props = global.props[uid];
|
4491 | }
|
4492 | if (!props) throw new Error("Initial props not found");
|
4493 | return deserializeMessage(parentComponentWindow, domain, props);
|
4494 | };
|
4495 | ChildComponent.prototype.getWindowByRef = function(ref) {
|
4496 | var type = ref.type, result = void 0;
|
4497 | if (type === constants.WINDOW_REFERENCES.OPENER) result = Object(cross_domain_utils_src.getOpener)(window); else if (type === constants.WINDOW_REFERENCES.TOP) result = Object(cross_domain_utils_src.getTop)(window); else if (type === constants.WINDOW_REFERENCES.PARENT) {
|
4498 | var distance = ref.distance;
|
4499 | result = distance ? Object(cross_domain_utils_src.getNthParentFromTop)(window, distance) : Object(cross_domain_utils_src.getParent)(window);
|
4500 | }
|
4501 | if (type === constants.WINDOW_REFERENCES.GLOBAL) {
|
4502 | var uid = ref.uid, ancestor = Object(cross_domain_utils_src.getAncestor)(window);
|
4503 | if (ancestor) for (var _i2 = 0, _getAllFramesInWindow2 = Object(cross_domain_utils_src.getAllFramesInWindow)(ancestor), _length2 = null == _getAllFramesInWindow2 ? 0 : _getAllFramesInWindow2.length; _i2 < _length2; _i2++) {
|
4504 | var global = globalFor(_getAllFramesInWindow2[_i2]);
|
4505 | if (global && global.windows && global.windows[uid]) {
|
4506 | result = global.windows[uid];
|
4507 | break;
|
4508 | }
|
4509 | }
|
4510 | }
|
4511 | if (!result) throw new Error("Unable to find " + type + " window");
|
4512 | return result;
|
4513 | };
|
4514 | ChildComponent.prototype.setProps = function(props, origin) {
|
4515 | var required = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2];
|
4516 | this.props = this.props || {};
|
4517 | var normalizedProps = function(parentComponentWindow, component, props, origin) {
|
4518 | for (var required = !(arguments.length > 4 && void 0 !== arguments[4]) || arguments[4], result = {}, _i2 = 0, _Object$keys2 = Object.keys(props), _length2 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i2 < _length2; _i2++) {
|
4519 | var key = _Object$keys2[_i2], prop = component.getProp(key);
|
4520 | if (!prop || !prop.sameDomain || origin === Object(cross_domain_utils_src.getDomain)(window) && Object(cross_domain_utils_src.isSameDomain)(parentComponentWindow)) {
|
4521 | var value = normalizeChildProp(component, 0, key, props[key]);
|
4522 | result[key] = value;
|
4523 | prop && prop.alias && !result[prop.alias] && (result[prop.alias] = value);
|
4524 | }
|
4525 | }
|
4526 | if (required) for (var _i4 = 0, _component$getPropNam2 = component.getPropNames(), _length4 = null == _component$getPropNam2 ? 0 : _component$getPropNam2.length; _i4 < _length4; _i4++) {
|
4527 | var _key = _component$getPropNam2[_i4];
|
4528 | props.hasOwnProperty(_key) || (result[_key] = normalizeChildProp(component, 0, _key, props[_key]));
|
4529 | }
|
4530 | return result;
|
4531 | }(this.parentComponentWindow, this.component, props, origin, required);
|
4532 | Object(belter_src.extend)(this.props, normalizedProps);
|
4533 | for (var _i4 = 0, _onPropHandlers2 = this.onPropHandlers, _length4 = null == _onPropHandlers2 ? 0 : _onPropHandlers2.length; _i4 < _length4; _i4++) _onPropHandlers2[_i4].call(this, this.props);
|
4534 | window.xprops = this.component.xprops = this.props;
|
4535 | };
|
4536 | ChildComponent.prototype.watchForClose = function() {
|
4537 | var _this2 = this;
|
4538 | window.addEventListener("unload", function() {
|
4539 | return _this2.parentExports.checkClose.fireAndForget();
|
4540 | });
|
4541 | };
|
4542 | ChildComponent.prototype.enableAutoResize = function() {
|
4543 | var _ref2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref2$width = _ref2.width, width = void 0 !== _ref2$width && _ref2$width, _ref2$height = _ref2.height, height = void 0 === _ref2$height || _ref2$height, _ref2$element = _ref2.element, element = void 0 === _ref2$element ? "body" : _ref2$element;
|
4544 | this.autoResize = {
|
4545 | width: width,
|
4546 | height: height,
|
4547 | element: element
|
4548 | };
|
4549 | this.watchForResize();
|
4550 | };
|
4551 | ChildComponent.prototype.getAutoResize = function() {
|
4552 | var _ref3 = this.autoResize || this.component.autoResize || {}, _ref3$width = _ref3.width, width = void 0 !== _ref3$width && _ref3$width, _ref3$height = _ref3.height, height = void 0 !== _ref3$height && _ref3$height, _ref3$element = _ref3.element, element = void 0 === _ref3$element ? "body" : _ref3$element;
|
4553 | return {
|
4554 | width: width,
|
4555 | height: height,
|
4556 | element: element = Object(belter_src.getElement)(element)
|
4557 | };
|
4558 | };
|
4559 | ChildComponent.prototype.watchForResize = function() {
|
4560 | var _this3 = this;
|
4561 | return Object(belter_src.waitForDocumentBody)().then(function() {
|
4562 | var _getAutoResize = _this3.getAutoResize(), width = _getAutoResize.width, height = _getAutoResize.height, element = _getAutoResize.element;
|
4563 | (width || height) && _this3.context !== constants.CONTEXT.POPUP && Object(belter_src.onResize)(element, function(_ref4) {
|
4564 | var newWidth = _ref4.width, newHeight = _ref4.height;
|
4565 | _this3.resize({
|
4566 | width: width ? newWidth : void 0,
|
4567 | height: height ? newHeight : void 0
|
4568 | });
|
4569 | }, {
|
4570 | width: width,
|
4571 | height: height
|
4572 | });
|
4573 | });
|
4574 | };
|
4575 | ChildComponent.prototype.buildExports = function() {
|
4576 | var self = this;
|
4577 | return {
|
4578 | updateProps: function(props) {
|
4579 | var _this4 = this;
|
4580 | return src.a.try(function() {
|
4581 | return self.setProps(props, _this4.origin, !1);
|
4582 | });
|
4583 | },
|
4584 | close: function() {
|
4585 | return src.a.try(function() {
|
4586 | return self.destroy();
|
4587 | });
|
4588 | }
|
4589 | };
|
4590 | };
|
4591 | ChildComponent.prototype.resize = function(_ref5) {
|
4592 | var width = _ref5.width, height = _ref5.height;
|
4593 | return this.parentExports.resize.fireAndForget({
|
4594 | width: width,
|
4595 | height: height
|
4596 | });
|
4597 | };
|
4598 | ChildComponent.prototype.hide = function() {
|
4599 | return this.parentExports.hide();
|
4600 | };
|
4601 | ChildComponent.prototype.show = function() {
|
4602 | return this.parentExports.show();
|
4603 | };
|
4604 | ChildComponent.prototype.userClose = function() {
|
4605 | return this.close(constants.CLOSE_REASONS.USER_CLOSED);
|
4606 | };
|
4607 | ChildComponent.prototype.close = function() {
|
4608 | var reason = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : constants.CLOSE_REASONS.CHILD_CALL;
|
4609 | return this.parentExports.close(reason);
|
4610 | };
|
4611 | ChildComponent.prototype.destroy = function() {
|
4612 | return src.a.try(function() {
|
4613 | window.close();
|
4614 | });
|
4615 | };
|
4616 | ChildComponent.prototype.focus = function() {
|
4617 | window.focus();
|
4618 | };
|
4619 | ChildComponent.prototype.error = function(err) {
|
4620 | var _this5 = this;
|
4621 | return src.a.try(function() {
|
4622 | if (_this5.parentExports.error) return _this5.parentExports.error(err);
|
4623 | }).catch(belter_src.noop).then(function() {
|
4624 | throw err;
|
4625 | });
|
4626 | };
|
4627 | return ChildComponent;
|
4628 | }()).prototype, 0, [ belter_src.memoized ], Object.getOwnPropertyDescriptor(_class.prototype, "watchForResize"), _class.prototype),
|
4629 | _class), drivers__extends = Object.assign || function(target) {
|
4630 | for (var i = 1; i < arguments.length; i++) {
|
4631 | var source = arguments[i];
|
4632 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
4633 | }
|
4634 | return target;
|
4635 | }, RENDER_DRIVERS = {};
|
4636 | RENDER_DRIVERS[constants.CONTEXT.IFRAME] = {
|
4637 | renderedIntoContainer: !0,
|
4638 | callChildToClose: !1,
|
4639 | open: function() {
|
4640 | var _this = this, attributes = this.component.attributes.iframe || {}, frame = Object(belter_src.iframe)({
|
4641 | attributes: drivers__extends({
|
4642 | title: this.component.name
|
4643 | }, attributes),
|
4644 | class: [ constants.CLASS_NAMES.COMPONENT_FRAME, constants.CLASS_NAMES.INVISIBLE ]
|
4645 | }, this.element);
|
4646 | this.clean.set("iframe", frame);
|
4647 | return Object(belter_src.awaitFrameWindow)(frame).then(function(win) {
|
4648 | var detectClose = function() {
|
4649 | return src.a.try(function() {
|
4650 | return _this.props.onClose(constants.CLOSE_REASONS.CLOSE_DETECTED);
|
4651 | }).finally(function() {
|
4652 | return _this.destroy();
|
4653 | });
|
4654 | }, iframeWatcher = Object(belter_src.watchElementForClose)(frame, detectClose), elementWatcher = Object(belter_src.watchElementForClose)(_this.element, detectClose);
|
4655 | _this.clean.register("destroyWindow", function() {
|
4656 | iframeWatcher.cancel();
|
4657 | elementWatcher.cancel();
|
4658 | cleanUpWindow(win);
|
4659 | Object(belter_src.destroyElement)(frame);
|
4660 | });
|
4661 | return window_ProxyWindow.toProxyWindow(win);
|
4662 | });
|
4663 | },
|
4664 | openPrerender: function() {
|
4665 | var _this2 = this, attributes = this.component.attributes.iframe || {}, prerenderIframe = Object(belter_src.iframe)({
|
4666 | attributes: drivers__extends({
|
4667 | name: "__zoid_prerender_frame__" + this.component.name + "_" + Object(belter_src.uniqueID)() + "__"
|
4668 | }, attributes),
|
4669 | class: [ constants.CLASS_NAMES.PRERENDER_FRAME, constants.CLASS_NAMES.VISIBLE ]
|
4670 | }, this.element);
|
4671 | this.clean.set("prerenderIframe", prerenderIframe);
|
4672 | return Object(belter_src.awaitFrameLoad)(prerenderIframe).then(function() {
|
4673 | var prerenderFrameWindow = prerenderIframe.contentWindow;
|
4674 | _this2.clean.register("destroyPrerender", function() {
|
4675 | Object(belter_src.destroyElement)(prerenderIframe);
|
4676 | });
|
4677 | return Object(cross_domain_utils_src.assertSameDomain)(prerenderFrameWindow);
|
4678 | });
|
4679 | },
|
4680 | switchPrerender: function() {
|
4681 | var _this3 = this;
|
4682 | Object(belter_src.addClass)(this.prerenderIframe, constants.CLASS_NAMES.INVISIBLE);
|
4683 | Object(belter_src.removeClass)(this.prerenderIframe, constants.CLASS_NAMES.VISIBLE);
|
4684 | Object(belter_src.addClass)(this.iframe, constants.CLASS_NAMES.VISIBLE);
|
4685 | Object(belter_src.removeClass)(this.iframe, constants.CLASS_NAMES.INVISIBLE);
|
4686 | setTimeout(function() {
|
4687 | _this3.prerenderIframe && Object(belter_src.destroyElement)(_this3.prerenderIframe);
|
4688 | }, 1e3);
|
4689 | },
|
4690 | delegateOverrides: {
|
4691 | openContainer: constants.DELEGATE.CALL_DELEGATE,
|
4692 | destroyComponent: constants.DELEGATE.CALL_DELEGATE,
|
4693 | destroyContainer: constants.DELEGATE.CALL_DELEGATE,
|
4694 | cancelContainerEvents: constants.DELEGATE.CALL_DELEGATE,
|
4695 | prerender: constants.DELEGATE.CALL_DELEGATE,
|
4696 | elementReady: constants.DELEGATE.CALL_DELEGATE,
|
4697 | showContainer: constants.DELEGATE.CALL_DELEGATE,
|
4698 | showComponent: constants.DELEGATE.CALL_DELEGATE,
|
4699 | hideContainer: constants.DELEGATE.CALL_DELEGATE,
|
4700 | hideComponent: constants.DELEGATE.CALL_DELEGATE,
|
4701 | hide: constants.DELEGATE.CALL_DELEGATE,
|
4702 | show: constants.DELEGATE.CALL_DELEGATE,
|
4703 | resize: constants.DELEGATE.CALL_DELEGATE,
|
4704 | loadUrl: constants.DELEGATE.CALL_DELEGATE,
|
4705 | openPrerender: constants.DELEGATE.CALL_DELEGATE,
|
4706 | switchPrerender: constants.DELEGATE.CALL_DELEGATE,
|
4707 | setWindowName: constants.DELEGATE.CALL_DELEGATE,
|
4708 | open: constants.DELEGATE.CALL_DELEGATE
|
4709 | },
|
4710 | resize: function(_ref) {
|
4711 | var width = _ref.width, height = _ref.height;
|
4712 | if (width) {
|
4713 | this.container.style.width = Object(belter_src.toCSS)(width);
|
4714 | this.element.style.width = Object(belter_src.toCSS)(width);
|
4715 | }
|
4716 | if (height) {
|
4717 | this.container.style.height = Object(belter_src.toCSS)(height);
|
4718 | this.element.style.height = Object(belter_src.toCSS)(height);
|
4719 | }
|
4720 | },
|
4721 | show: function() {
|
4722 | Object(belter_src.showElement)(this.element);
|
4723 | },
|
4724 | hide: function() {
|
4725 | Object(belter_src.hideElement)(this.element);
|
4726 | }
|
4727 | };
|
4728 | RENDER_DRIVERS[constants.CONTEXT.POPUP] = {
|
4729 | renderedIntoContainer: !1,
|
4730 | callChildToClose: !0,
|
4731 | open: function() {
|
4732 | var _this4 = this;
|
4733 | return src.a.try(function() {
|
4734 | var _component$dimensions = _this4.component.dimensions, width = _component$dimensions.width, height = _component$dimensions.height;
|
4735 | width = Object(belter_src.normalizeDimension)(width, window.outerWidth);
|
4736 | height = Object(belter_src.normalizeDimension)(height, window.outerWidth);
|
4737 | var attributes = _this4.component.attributes.popup || {}, win = Object(belter_src.popup)("", drivers__extends({
|
4738 | width: width,
|
4739 | height: height
|
4740 | }, attributes));
|
4741 | _this4.clean.register("destroyWindow", function() {
|
4742 | win.close();
|
4743 | cleanUpWindow(win);
|
4744 | });
|
4745 | return window_ProxyWindow.toProxyWindow(win);
|
4746 | });
|
4747 | },
|
4748 | openPrerender: function(win) {
|
4749 | return src.a.try(function() {
|
4750 | if (Object(cross_domain_utils_src.isSameDomain)(win)) return Object(cross_domain_utils_src.assertSameDomain)(win);
|
4751 | });
|
4752 | },
|
4753 | resize: function() {},
|
4754 | hide: function() {
|
4755 | throw new Error("Can not hide popup");
|
4756 | },
|
4757 | show: function() {
|
4758 | throw new Error("Can not show popup");
|
4759 | },
|
4760 | delegateOverrides: {
|
4761 | openContainer: constants.DELEGATE.CALL_DELEGATE,
|
4762 | destroyContainer: constants.DELEGATE.CALL_DELEGATE,
|
4763 | elementReady: constants.DELEGATE.CALL_DELEGATE,
|
4764 | showContainer: constants.DELEGATE.CALL_DELEGATE,
|
4765 | showComponent: constants.DELEGATE.CALL_DELEGATE,
|
4766 | hideContainer: constants.DELEGATE.CALL_DELEGATE,
|
4767 | hideComponent: constants.DELEGATE.CALL_DELEGATE,
|
4768 | hide: constants.DELEGATE.CALL_DELEGATE,
|
4769 | show: constants.DELEGATE.CALL_DELEGATE,
|
4770 | cancelContainerEvents: constants.DELEGATE.CALL_DELEGATE
|
4771 | }
|
4772 | };
|
4773 | var parent__class, props__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
4774 | return typeof obj;
|
4775 | } : function(obj) {
|
4776 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
4777 | }, parent__extends = Object.assign || function(target) {
|
4778 | for (var i = 1; i < arguments.length; i++) {
|
4779 | var source = arguments[i];
|
4780 | for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
4781 | }
|
4782 | return target;
|
4783 | }, parent__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
4784 | return typeof obj;
|
4785 | } : function(obj) {
|
4786 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
4787 | };
|
4788 | function parent__applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
|
4789 | var desc = {};
|
4790 | Object.keys(descriptor).forEach(function(key) {
|
4791 | desc[key] = descriptor[key];
|
4792 | });
|
4793 | desc.enumerable = !!desc.enumerable;
|
4794 | desc.configurable = !!desc.configurable;
|
4795 | ("value" in desc || desc.initializer) && (desc.writable = !0);
|
4796 | desc = decorators.slice().reverse().reduce(function(desc, decorator) {
|
4797 | return decorator(target, property, desc) || desc;
|
4798 | }, desc);
|
4799 | if (context && void 0 !== desc.initializer) {
|
4800 | desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
|
4801 | desc.initializer = void 0;
|
4802 | }
|
4803 | if (void 0 === desc.initializer) {
|
4804 | Object.defineProperty(target, property, desc);
|
4805 | desc = null;
|
4806 | }
|
4807 | return desc;
|
4808 | }
|
4809 | global_global.props = global_global.props || {};
|
4810 | global_global.windows = global_global.windows || {};
|
4811 | var parent_ParentComponent = (parent__applyDecoratedDescriptor((parent__class = function() {
|
4812 | function ParentComponent(component, context, _ref) {
|
4813 | var _this = this, props = _ref.props;
|
4814 | !function(instance, Constructor) {
|
4815 | if (!(instance instanceof ParentComponent)) throw new TypeError("Cannot call a class as a function");
|
4816 | }(this);
|
4817 | src.a.try(function() {
|
4818 | _this.onInit = new src.a();
|
4819 | _this.clean = cleanup(_this);
|
4820 | _this.event = Object(belter_src.eventEmitter)();
|
4821 | _this.component = component;
|
4822 | _this.driver = RENDER_DRIVERS[context];
|
4823 | _this.setProps(props);
|
4824 | _this.registerActiveComponent();
|
4825 | _this.watchForUnload();
|
4826 | return _this.onInit;
|
4827 | }).catch(function(err) {
|
4828 | return _this.error(err, props);
|
4829 | });
|
4830 | }
|
4831 | ParentComponent.prototype.render = function(context, element) {
|
4832 | var _this2 = this, target = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : window;
|
4833 | return this.tryInit(function() {
|
4834 | _this2.component.log("render");
|
4835 | var uid = Object(belter_src.uniqueID)(), tasks = {};
|
4836 | tasks.onRender = _this2.props.onRender();
|
4837 | var domain = _this2.getDomain(), initialDomain = _this2.getInitialDomain();
|
4838 | tasks.elementReady = src.a.try(function() {
|
4839 | if (element) return _this2.elementReady(element);
|
4840 | });
|
4841 | var focus = function() {
|
4842 | return tasks.open.then(function(proxyWin) {
|
4843 | return proxyWin.focus();
|
4844 | });
|
4845 | };
|
4846 | tasks.openContainer = tasks.elementReady.then(function() {
|
4847 | return _this2.openContainer(element, {
|
4848 | context: context,
|
4849 | uid: uid,
|
4850 | focus: focus
|
4851 | });
|
4852 | });
|
4853 | tasks.open = _this2.driver.renderedIntoContainer ? tasks.openContainer.then(function() {
|
4854 | return _this2.open();
|
4855 | }) : _this2.open();
|
4856 | tasks.awaitWindow = tasks.open.then(function(proxyWin) {
|
4857 | return proxyWin.awaitWindow();
|
4858 | });
|
4859 | tasks.showContainer = tasks.openContainer.then(function() {
|
4860 | return _this2.showContainer();
|
4861 | });
|
4862 | tasks.buildWindowName = tasks.open.then(function(proxyWin) {
|
4863 | return _this2.buildWindowName({
|
4864 | proxyWin: proxyWin,
|
4865 | initialDomain: initialDomain,
|
4866 | domain: domain,
|
4867 | target: target,
|
4868 | context: context,
|
4869 | uid: uid
|
4870 | });
|
4871 | });
|
4872 | tasks.setWindowName = src.a.all([ tasks.open, tasks.buildWindowName ]).then(function(_ref2) {
|
4873 | var proxyWin = _ref2[0], windowName = _ref2[1];
|
4874 | return _this2.setWindowName(proxyWin, windowName);
|
4875 | });
|
4876 | tasks.watchForClose = src.a.all([ tasks.awaitWindow, tasks.setWindowName ]).then(function(_ref3) {
|
4877 | var win = _ref3[0];
|
4878 | return _this2.watchForClose(win);
|
4879 | });
|
4880 | tasks.prerender = src.a.all([ tasks.awaitWindow, tasks.openContainer ]).then(function(_ref4) {
|
4881 | var win = _ref4[0];
|
4882 | return _this2.prerender(win, {
|
4883 | context: context,
|
4884 | uid: uid
|
4885 | });
|
4886 | });
|
4887 | tasks.showComponent = tasks.prerender.then(function() {
|
4888 | return _this2.showComponent();
|
4889 | });
|
4890 | tasks.buildUrl = _this2.buildUrl();
|
4891 | tasks.openBridge = src.a.all([ tasks.awaitWindow, tasks.buildUrl ]).then(function(_ref5) {
|
4892 | var win = _ref5[0], url = _ref5[1];
|
4893 | return _this2.openBridge(win, Object(cross_domain_utils_src.getDomainFromUrl)(url), context);
|
4894 | });
|
4895 | tasks.loadUrl = src.a.all([ tasks.open, tasks.buildUrl, tasks.setWindowName ]).then(function(_ref6) {
|
4896 | var proxyWin = _ref6[0], url = _ref6[1];
|
4897 | return _this2.loadUrl(proxyWin, url);
|
4898 | });
|
4899 | tasks.switchPrerender = src.a.all([ tasks.prerender, _this2.onInit ]).then(function() {
|
4900 | return _this2.switchPrerender();
|
4901 | });
|
4902 | tasks.runTimeout = tasks.loadUrl.then(function() {
|
4903 | return _this2.runTimeout();
|
4904 | });
|
4905 | return src.a.hash(tasks);
|
4906 | }).then(function() {
|
4907 | return _this2.props.onEnter();
|
4908 | }).then(function() {
|
4909 | return _this2;
|
4910 | });
|
4911 | };
|
4912 | ParentComponent.prototype.renderTo = function(context, target, element) {
|
4913 | var _this3 = this;
|
4914 | return this.tryInit(function() {
|
4915 | if (target === window) return _this3.render(context, element);
|
4916 | if (element && "string" != typeof element) throw new Error("Element passed to renderTo must be a string selector, got " + (void 0 === element ? "undefined" : parent__typeof(element)) + " " + element);
|
4917 | _this3.checkAllowRemoteRender(target);
|
4918 | _this3.component.log("render_" + context + "_to_win", {
|
4919 | element: Object(belter_src.stringify)(element),
|
4920 | context: context
|
4921 | });
|
4922 | _this3.delegate(context, target);
|
4923 | return _this3.render(context, element, target);
|
4924 | });
|
4925 | };
|
4926 | ParentComponent.prototype.on = function(eventName, handler) {
|
4927 | return this.event.on(eventName, handler);
|
4928 | };
|
4929 | ParentComponent.prototype.checkAllowRemoteRender = function(target) {
|
4930 | if (!target) throw this.component.createError("Must pass window to renderTo");
|
4931 | if (!Object(cross_domain_utils_src.isSameTopWindow)(window, target)) throw new Error("Can only renderTo an adjacent frame");
|
4932 | var origin = Object(cross_domain_utils_src.getDomain)(), domain = this.getDomain();
|
4933 | if (!Object(cross_domain_utils_src.matchDomain)(domain, origin) && !Object(cross_domain_utils_src.isSameDomain)(target)) throw new Error("Can not render remotely to " + domain.toString() + " - can only render to " + origin);
|
4934 | };
|
4935 | ParentComponent.prototype.registerActiveComponent = function() {
|
4936 | var _this4 = this;
|
4937 | ParentComponent.activeComponents.push(this);
|
4938 | this.clean.register(function() {
|
4939 | ParentComponent.activeComponents.splice(ParentComponent.activeComponents.indexOf(_this4), 1);
|
4940 | });
|
4941 | };
|
4942 | ParentComponent.prototype.getWindowRef = function(target, domain, uid, context) {
|
4943 | if (domain === Object(cross_domain_utils_src.getDomain)(window)) {
|
4944 | global_global.windows[uid] = window;
|
4945 | this.clean.register(function() {
|
4946 | delete global_global.windows[uid];
|
4947 | });
|
4948 | return {
|
4949 | type: constants.WINDOW_REFERENCES.GLOBAL,
|
4950 | uid: uid
|
4951 | };
|
4952 | }
|
4953 | if (target !== window) throw new Error("Can not currently create window reference for different target with a different domain");
|
4954 | return context === constants.CONTEXT.POPUP ? {
|
4955 | type: constants.WINDOW_REFERENCES.OPENER
|
4956 | } : Object(cross_domain_utils_src.isTop)(window) ? {
|
4957 | type: constants.WINDOW_REFERENCES.TOP
|
4958 | } : {
|
4959 | type: constants.WINDOW_REFERENCES.PARENT,
|
4960 | distance: Object(cross_domain_utils_src.getDistanceFromTop)(window)
|
4961 | };
|
4962 | };
|
4963 | ParentComponent.prototype.buildWindowName = function(_ref7) {
|
4964 | var name, childPayload, normalizedName, encodedPayload, proxyWin = _ref7.proxyWin, initialDomain = _ref7.initialDomain, domain = _ref7.domain, target = _ref7.target, uid = _ref7.uid, context = _ref7.context;
|
4965 | return name = this.component.name, childPayload = this.buildChildPayload({
|
4966 | proxyWin: proxyWin,
|
4967 | initialDomain: initialDomain,
|
4968 | domain: domain,
|
4969 | target: target,
|
4970 | context: context,
|
4971 | uid: uid
|
4972 | }), normalizedName = name.replace(/^[^a-z0-9A-Z]+|[^a-z0-9A-Z]+$/g, "").replace(/[^a-z0-9A-Z]+/g, "_"),
|
4973 | encodedPayload = Object(belter_src.base64encode)(JSON.stringify(childPayload)),
|
4974 | "__" + constants.ZOID + "__" + normalizedName + "__" + encodedPayload + "__";
|
4975 | };
|
4976 | ParentComponent.prototype.getPropsRef = function(proxyWin, target, domain, uid) {
|
4977 | var value = serializeMessage(proxyWin, domain, this.getPropsForChild(domain)), propRef = Object(cross_domain_utils_src.isSameDomain)(target) ? {
|
4978 | type: constants.INITIAL_PROPS.RAW,
|
4979 | value: value
|
4980 | } : {
|
4981 | type: constants.INITIAL_PROPS.UID,
|
4982 | uid: uid
|
4983 | };
|
4984 | if (propRef.type === constants.INITIAL_PROPS.UID) {
|
4985 | global_global.props[uid] = value;
|
4986 | this.clean.register(function() {
|
4987 | delete global_global.props[uid];
|
4988 | });
|
4989 | }
|
4990 | return propRef;
|
4991 | };
|
4992 | ParentComponent.prototype.buildChildPayload = function() {
|
4993 | var _ref8 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, proxyWin = _ref8.proxyWin, initialDomain = _ref8.initialDomain, domain = _ref8.domain, _ref8$target = _ref8.target, target = void 0 === _ref8$target ? window : _ref8$target, context = _ref8.context, uid = _ref8.uid;
|
4994 | return {
|
4995 | uid: uid,
|
4996 | context: context,
|
4997 | domain: Object(cross_domain_utils_src.getDomain)(window),
|
4998 | tag: this.component.tag,
|
4999 | parent: this.getWindowRef(target, initialDomain, uid, context),
|
5000 | props: this.getPropsRef(proxyWin, target, domain, uid),
|
5001 | exports: serializeMessage(proxyWin, domain, this.buildParentExports(proxyWin))
|
5002 | };
|
5003 | };
|
5004 | ParentComponent.prototype.setProps = function(props) {
|
5005 | var isUpdate = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
|
5006 | this.component.validate && this.component.validate(this.component, props);
|
5007 | this.props = this.props || {};
|
5008 | Object(belter_src.extend)(this.props, function(component, instance, props) {
|
5009 | var isUpdate = arguments.length > 3 && void 0 !== arguments[3] && arguments[3], result = {};
|
5010 | props = props || {};
|
5011 | for (var propNames = isUpdate ? [] : component.getPropNames(), _i2 = 0, _Object$keys2 = Object.keys(props), _length2 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i2 < _length2; _i2++) {
|
5012 | var key = _Object$keys2[_i2];
|
5013 | -1 === propNames.indexOf(key) && propNames.push(key);
|
5014 | }
|
5015 | for (var aliases = [], _i4 = 0, _length4 = null == propNames ? 0 : propNames.length; _i4 < _length4; _i4++) {
|
5016 | var _key = propNames[_i4], propDef = component.getProp(_key), value = props[_key];
|
5017 | if (propDef) {
|
5018 | var alias = propDef.alias;
|
5019 | if (alias) {
|
5020 | !Object(belter_src.isDefined)(value) && Object(belter_src.isDefined)(props[alias]) && (value = props[alias]);
|
5021 | aliases.push(alias);
|
5022 | }
|
5023 | propDef.value && (value = propDef.value());
|
5024 | !Object(belter_src.isDefined)(value) && propDef.def && (value = propDef.def(props, component));
|
5025 | if (Object(belter_src.isDefined)(value)) {
|
5026 | if ("array" === propDef.type ? !Array.isArray(value) : (void 0 === value ? "undefined" : props__typeof(value)) !== propDef.type) throw new TypeError("Prop is not of type " + propDef.type + ": " + _key);
|
5027 | } else if (!1 !== propDef.required) throw new Error("Expected prop " + _key + " to be passed");
|
5028 | result[_key] = value;
|
5029 | } else result[_key] = value;
|
5030 | }
|
5031 | for (var _i6 = 0, _length6 = null == aliases ? 0 : aliases.length; _i6 < _length6; _i6++) delete result[aliases[_i6]];
|
5032 | for (var _i8 = 0, _Object$keys4 = Object.keys(result), _length8 = null == _Object$keys4 ? 0 : _Object$keys4.length; _i8 < _length8; _i8++) {
|
5033 | var _key2 = _Object$keys4[_i8], _propDef = component.getProp(_key2), _value = result[_key2];
|
5034 | if (_propDef) {
|
5035 | Object(belter_src.isDefined)(_value) && _propDef.validate && _propDef.validate(_value, result);
|
5036 | _propDef.decorate && (result[_key2] = _propDef.decorate(_value, result));
|
5037 | result[_key2] && "function" === _propDef.type && (result[_key2] = result[_key2].bind(instance));
|
5038 | }
|
5039 | }
|
5040 | return result;
|
5041 | }(this.component, this, props, isUpdate));
|
5042 | };
|
5043 | ParentComponent.prototype.buildUrl = function() {
|
5044 | var propsDef, props, params, _this5 = this;
|
5045 | return (propsDef = parent__extends({}, this.component.props, this.component.builtinProps),
|
5046 | props = this.props, params = {}, src.a.all(Object.keys(props).map(function(key) {
|
5047 | var prop = propsDef[key];
|
5048 | if (prop) return src.a.resolve().then(function() {
|
5049 | var value = props[key];
|
5050 | if (value && prop.queryParam) return value;
|
5051 | }).then(function(value) {
|
5052 | if (null !== value && void 0 !== value) return src.a.all([ function(prop, key, value) {
|
5053 | return src.a.try(function() {
|
5054 | return "function" == typeof prop.queryParam ? prop.queryParam(value) : "string" == typeof prop.queryParam ? prop.queryParam : key;
|
5055 | });
|
5056 | }(prop, key, value), function(prop, key, value) {
|
5057 | return src.a.try(function() {
|
5058 | return "function" == typeof prop.queryValue ? prop.queryValue(value) : value;
|
5059 | });
|
5060 | }(prop, 0, value) ]).then(function(_ref) {
|
5061 | var queryParam = _ref[0], queryValue = _ref[1], result = void 0;
|
5062 | if ("boolean" == typeof queryValue) result = queryValue.toString(); else if ("string" == typeof queryValue) result = queryValue.toString(); else {
|
5063 | if ("function" == typeof queryValue) return;
|
5064 | if ("object" === (void 0 === queryValue ? "undefined" : props__typeof(queryValue)) && null !== queryValue) {
|
5065 | if (prop.serialization === constants.PROP_SERIALIZATION.JSON) result = JSON.stringify(queryValue); else if (prop.serialization === constants.PROP_SERIALIZATION.BASE64) result = btoa(JSON.stringify(queryValue)); else if (prop.serialization === constants.PROP_SERIALIZATION.DOTIFY || !prop.serialization) {
|
5066 | result = Object(belter_src.dotify)(queryValue, key);
|
5067 | for (var _i10 = 0, _Object$keys6 = Object.keys(result), _length10 = null == _Object$keys6 ? 0 : _Object$keys6.length; _i10 < _length10; _i10++) {
|
5068 | var dotkey = _Object$keys6[_i10];
|
5069 | params[dotkey] = result[dotkey];
|
5070 | }
|
5071 | return;
|
5072 | }
|
5073 | } else "number" == typeof queryValue && (result = queryValue.toString());
|
5074 | }
|
5075 | params[queryParam] = result;
|
5076 | });
|
5077 | });
|
5078 | })).then(function() {
|
5079 | return params;
|
5080 | })).then(function(query) {
|
5081 | var url = Object(cross_domain_utils_src.normalizeMockUrl)(_this5.component.getUrl(_this5.props));
|
5082 | return Object(belter_src.extendUrl)(url, {
|
5083 | query: parent__extends({}, query)
|
5084 | });
|
5085 | });
|
5086 | };
|
5087 | ParentComponent.prototype.getDomain = function() {
|
5088 | return this.component.getDomain(this.props);
|
5089 | };
|
5090 | ParentComponent.prototype.getInitialDomain = function() {
|
5091 | return this.component.getInitialDomain(this.props);
|
5092 | };
|
5093 | ParentComponent.prototype.getPropsForChild = function(domain) {
|
5094 | for (var result = {}, _i2 = 0, _Object$keys2 = Object.keys(this.props), _length2 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i2 < _length2; _i2++) {
|
5095 | var key = _Object$keys2[_i2], prop = this.component.getProp(key);
|
5096 | prop && !1 === prop.sendToChild || prop && prop.sameDomain && !Object(cross_domain_utils_src.matchDomain)(domain, Object(cross_domain_utils_src.getDomain)(window)) || (result[key] = this.props[key]);
|
5097 | }
|
5098 | return result;
|
5099 | };
|
5100 | ParentComponent.prototype.updateProps = function(props) {
|
5101 | var _this6 = this;
|
5102 | this.setProps(props, !0);
|
5103 | return this.onInit.then(function() {
|
5104 | if (_this6.childExports) return _this6.childExports.updateProps(_this6.getPropsForChild(_this6.getDomain()));
|
5105 | throw new Error("Child exports were not available");
|
5106 | });
|
5107 | };
|
5108 | ParentComponent.prototype.openBridge = function(win, domain, context) {
|
5109 | var _this7 = this;
|
5110 | return src.a.try(function() {
|
5111 | if (bridge && bridge.needsBridge({
|
5112 | win: win,
|
5113 | domain: domain
|
5114 | }) && !bridge.hasBridge(domain, domain)) {
|
5115 | var bridgeUrl = _this7.component.getBridgeUrl(_this7.props);
|
5116 | if (!bridgeUrl) throw new Error("Bridge url and domain needed to render " + context);
|
5117 | var bridgeDomain = Object(cross_domain_utils_src.getDomainFromUrl)(bridgeUrl);
|
5118 | bridge.linkUrl(win, domain);
|
5119 | return bridge.openBridge(bridgeUrl, bridgeDomain);
|
5120 | }
|
5121 | });
|
5122 | };
|
5123 | ParentComponent.prototype.open = function() {
|
5124 | var _this8 = this;
|
5125 | return src.a.try(function() {
|
5126 | _this8.component.log("open");
|
5127 | var windowProp = _this8.props.window;
|
5128 | if (windowProp) {
|
5129 | _this8.clean.register("destroyProxyWindow", function() {
|
5130 | return windowProp.close();
|
5131 | });
|
5132 | return windowProp;
|
5133 | }
|
5134 | return _this8.driver.open.call(_this8);
|
5135 | });
|
5136 | };
|
5137 | ParentComponent.prototype.setWindowName = function(proxyWin, name) {
|
5138 | return proxyWin.setName(name);
|
5139 | };
|
5140 | ParentComponent.prototype.switchPrerender = function() {
|
5141 | var _this9 = this;
|
5142 | return src.a.try(function() {
|
5143 | if (_this9.component.prerenderTemplate && _this9.driver.switchPrerender) return _this9.driver.switchPrerender.call(_this9);
|
5144 | });
|
5145 | };
|
5146 | ParentComponent.prototype.elementReady = function(element) {
|
5147 | return Object(belter_src.elementReady)(element).then(belter_src.noop);
|
5148 | };
|
5149 | ParentComponent.prototype.delegate = function(context, target) {
|
5150 | var _this10 = this;
|
5151 | this.component.log("delegate");
|
5152 | for (var props = {
|
5153 | window: this.props.window,
|
5154 | onClose: this.props.onClose,
|
5155 | onDisplay: this.props.onDisplay
|
5156 | }, _i4 = 0, _component$getPropNam2 = this.component.getPropNames(), _length4 = null == _component$getPropNam2 ? 0 : _component$getPropNam2.length; _i4 < _length4; _i4++) {
|
5157 | var propName = _component$getPropNam2[_i4];
|
5158 | this.component.getProp(propName).allowDelegate && (props[propName] = this.props[propName]);
|
5159 | }
|
5160 | for (var delegate = _send(target, constants.POST_MESSAGE.DELEGATE + "_" + this.component.name, {
|
5161 | context: context,
|
5162 | props: props,
|
5163 | overrides: {
|
5164 | userClose: function() {
|
5165 | return _this10.userClose();
|
5166 | },
|
5167 | error: function(err) {
|
5168 | return _this10.error(err);
|
5169 | },
|
5170 | on: function(eventName, handler) {
|
5171 | return _this10.on(eventName, handler);
|
5172 | }
|
5173 | }
|
5174 | }).then(function(_ref9) {
|
5175 | var data = _ref9.data;
|
5176 | _this10.clean.register(data.destroy);
|
5177 | return data;
|
5178 | }).catch(function(err) {
|
5179 | throw new Error("Unable to delegate rendering. Possibly the component is not loaded in the target window.\n\n" + Object(belter_src.stringifyError)(err));
|
5180 | }), overrides = this.driver.delegateOverrides, _loop = function(_i6, _Object$keys4, _length6) {
|
5181 | var key = _Object$keys4[_i6];
|
5182 | overrides[key] === constants.DELEGATE.CALL_DELEGATE && (_this10[key] = function() {
|
5183 | var _this11 = this, _arguments = arguments;
|
5184 | return delegate.then(function(data) {
|
5185 | return data.overrides[key].apply(_this11, _arguments);
|
5186 | });
|
5187 | });
|
5188 | }, _i6 = 0, _Object$keys4 = Object.keys(overrides), _length6 = null == _Object$keys4 ? 0 : _Object$keys4.length; _i6 < _length6; _i6++) _loop(_i6, _Object$keys4);
|
5189 | };
|
5190 | ParentComponent.prototype.watchForClose = function(win) {
|
5191 | var _this12 = this, closeWindowListener = Object(cross_domain_utils_src.onCloseWindow)(win, function() {
|
5192 | _this12.component.log("detect_close_child");
|
5193 | return src.a.try(function() {
|
5194 | return _this12.props.onClose(constants.CLOSE_REASONS.CLOSE_DETECTED);
|
5195 | }).finally(function() {
|
5196 | return _this12.destroy();
|
5197 | });
|
5198 | }, 3e3);
|
5199 | this.clean.register("destroyCloseWindowListener", closeWindowListener.cancel);
|
5200 | };
|
5201 | ParentComponent.prototype.watchForUnload = function() {
|
5202 | var _this13 = this, onunload = Object(belter_src.once)(function() {
|
5203 | _this13.component.log("navigate_away");
|
5204 | _this13.destroyComponent();
|
5205 | }), unloadWindowListener = Object(belter_src.addEventListener)(window, "unload", onunload);
|
5206 | this.clean.register("destroyUnloadWindowListener", unloadWindowListener.cancel);
|
5207 | };
|
5208 | ParentComponent.prototype.loadUrl = function(proxyWin, url) {
|
5209 | this.component.log("load_url");
|
5210 | return proxyWin.setLocation(url);
|
5211 | };
|
5212 | ParentComponent.prototype.runTimeout = function() {
|
5213 | var _this14 = this, timeout = this.props.timeout;
|
5214 | if (timeout) {
|
5215 | var _id = this.timeout = setTimeout(function() {
|
5216 | _this14.component.log("timed_out", {
|
5217 | timeout: timeout.toString()
|
5218 | });
|
5219 | _this14.error(_this14.component.createError("Loading component timed out after " + timeout + " milliseconds"));
|
5220 | }, timeout);
|
5221 | this.clean.register(function() {
|
5222 | clearTimeout(_id);
|
5223 | delete _this14.timeout;
|
5224 | });
|
5225 | }
|
5226 | };
|
5227 | ParentComponent.prototype.initChild = function(childExports) {
|
5228 | var _this15 = this;
|
5229 | return src.a.try(function() {
|
5230 | _this15.childExports = childExports;
|
5231 | _this15.onInit.resolve(_this15);
|
5232 | _this15.timeout && clearTimeout(_this15.timeout);
|
5233 | });
|
5234 | };
|
5235 | ParentComponent.prototype.buildParentExports = function(win) {
|
5236 | var _this16 = this;
|
5237 | return {
|
5238 | init: function(childExports) {
|
5239 | return _this16.initChild(childExports);
|
5240 | },
|
5241 | close: function(reason) {
|
5242 | return _this16.close(reason);
|
5243 | },
|
5244 | checkClose: function() {
|
5245 | return _this16.checkClose(win);
|
5246 | },
|
5247 | resize: function(_ref10) {
|
5248 | var width = _ref10.width, height = _ref10.height;
|
5249 | return _this16.resize({
|
5250 | width: width,
|
5251 | height: height
|
5252 | });
|
5253 | },
|
5254 | trigger: function(name) {
|
5255 | return src.a.try(function() {
|
5256 | return _this16.event.trigger(name);
|
5257 | });
|
5258 | },
|
5259 | hide: function() {
|
5260 | return src.a.try(function() {
|
5261 | return _this16.hide();
|
5262 | });
|
5263 | },
|
5264 | show: function() {
|
5265 | return src.a.try(function() {
|
5266 | return _this16.show();
|
5267 | });
|
5268 | },
|
5269 | error: function(err) {
|
5270 | return _this16.error(err);
|
5271 | }
|
5272 | };
|
5273 | };
|
5274 | ParentComponent.prototype.resize = function(_ref11) {
|
5275 | var _this17 = this, width = _ref11.width, height = _ref11.height;
|
5276 | return src.a.try(function() {
|
5277 | _this17.driver.resize.call(_this17, {
|
5278 | width: width,
|
5279 | height: height
|
5280 | });
|
5281 | });
|
5282 | };
|
5283 | ParentComponent.prototype.hide = function() {
|
5284 | this.container && Object(belter_src.hideElement)(this.container);
|
5285 | return this.driver.hide.call(this);
|
5286 | };
|
5287 | ParentComponent.prototype.show = function() {
|
5288 | this.container && Object(belter_src.showElement)(this.container);
|
5289 | return this.driver.show.call(this);
|
5290 | };
|
5291 | ParentComponent.prototype.checkClose = function(win) {
|
5292 | var _this18 = this;
|
5293 | return win.isClosed().then(function(closed) {
|
5294 | return closed ? _this18.userClose() : src.a.delay(200).then(function() {
|
5295 | return win.isClosed();
|
5296 | }).then(function(secondClosed) {
|
5297 | if (secondClosed) return _this18.userClose();
|
5298 | });
|
5299 | });
|
5300 | };
|
5301 | ParentComponent.prototype.userClose = function() {
|
5302 | return this.close(constants.CLOSE_REASONS.USER_CLOSED);
|
5303 | };
|
5304 | ParentComponent.prototype.close = function() {
|
5305 | var _this19 = this, reason = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : constants.CLOSE_REASONS.PARENT_CALL;
|
5306 | return src.a.try(function() {
|
5307 | _this19.component.log("close", {
|
5308 | reason: reason
|
5309 | });
|
5310 | _this19.event.triggerOnce(constants.EVENTS.CLOSE);
|
5311 | return _this19.props.onClose(reason);
|
5312 | }).then(function() {
|
5313 | return src.a.all([ _this19.closeComponent(), _this19.closeContainer() ]);
|
5314 | }).then(function() {
|
5315 | return _this19.destroy();
|
5316 | });
|
5317 | };
|
5318 | ParentComponent.prototype.closeContainer = function() {
|
5319 | var _this20 = this, reason = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : constants.CLOSE_REASONS.PARENT_CALL;
|
5320 | return src.a.try(function() {
|
5321 | _this20.event.triggerOnce(constants.EVENTS.CLOSE);
|
5322 | return _this20.props.onClose(reason);
|
5323 | }).then(function() {
|
5324 | return src.a.all([ _this20.closeComponent(reason), _this20.hideContainer() ]);
|
5325 | }).then(function() {
|
5326 | return _this20.destroyContainer();
|
5327 | });
|
5328 | };
|
5329 | ParentComponent.prototype.destroyContainer = function() {
|
5330 | var _this21 = this;
|
5331 | return src.a.try(function() {
|
5332 | _this21.clean.run("destroyContainerEvents");
|
5333 | _this21.clean.run("destroyContainerTemplate");
|
5334 | });
|
5335 | };
|
5336 | ParentComponent.prototype.closeComponent = function() {
|
5337 | var _this22 = this, reason = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : constants.CLOSE_REASONS.PARENT_CALL;
|
5338 | return src.a.try(function() {
|
5339 | return _this22.cancelContainerEvents();
|
5340 | }).then(function() {
|
5341 | _this22.event.triggerOnce(constants.EVENTS.CLOSE);
|
5342 | return _this22.props.onClose(reason);
|
5343 | }).then(function() {
|
5344 | return _this22.hideComponent();
|
5345 | }).then(function() {
|
5346 | return _this22.destroyComponent();
|
5347 | }).then(function() {
|
5348 | _this22.childExports && _this22.driver.callChildToClose && _this22.childExports.close().catch(belter_src.noop);
|
5349 | });
|
5350 | };
|
5351 | ParentComponent.prototype.destroyComponent = function() {
|
5352 | this.clean.run("destroyUnloadWindowListener");
|
5353 | this.clean.run("destroyCloseWindowListener");
|
5354 | this.clean.run("destroyContainerEvents");
|
5355 | this.clean.run("destroyWindow");
|
5356 | };
|
5357 | ParentComponent.prototype.showContainer = function() {
|
5358 | var _this23 = this;
|
5359 | return src.a.try(function() {
|
5360 | if (_this23.props.onDisplay) return _this23.props.onDisplay();
|
5361 | }).then(function() {
|
5362 | if (_this23.container) return Object(belter_src.showAndAnimate)(_this23.container, constants.ANIMATION_NAMES.SHOW_CONTAINER, _this23.clean.register);
|
5363 | });
|
5364 | };
|
5365 | ParentComponent.prototype.showComponent = function() {
|
5366 | var _this24 = this;
|
5367 | return src.a.try(function() {
|
5368 | if (_this24.props.onDisplay) return _this24.props.onDisplay();
|
5369 | }).then(function() {
|
5370 | if (_this24.element) return Object(belter_src.showAndAnimate)(_this24.element, constants.ANIMATION_NAMES.SHOW_COMPONENT, _this24.clean.register);
|
5371 | });
|
5372 | };
|
5373 | ParentComponent.prototype.hideContainer = function() {
|
5374 | var _this25 = this;
|
5375 | return src.a.try(function() {
|
5376 | if (_this25.container) return Object(belter_src.animateAndHide)(_this25.container, constants.ANIMATION_NAMES.HIDE_CONTAINER, _this25.clean.register);
|
5377 | });
|
5378 | };
|
5379 | ParentComponent.prototype.hideComponent = function() {
|
5380 | var _this26 = this;
|
5381 | return src.a.try(function() {
|
5382 | if (_this26.element) return Object(belter_src.animateAndHide)(_this26.element, constants.ANIMATION_NAMES.HIDE_COMPONENT, _this26.clean.register);
|
5383 | });
|
5384 | };
|
5385 | ParentComponent.prototype.prerender = function(win, _ref12) {
|
5386 | var _this27 = this, context = _ref12.context, uid = _ref12.uid;
|
5387 | return src.a.try(function() {
|
5388 | if (_this27.component.prerenderTemplate) return src.a.try(function() {
|
5389 | return _this27.driver.openPrerender.call(_this27, win);
|
5390 | }).then(function(prerenderWindow) {
|
5391 | if (prerenderWindow && Object(cross_domain_utils_src.isSameDomain)(prerenderWindow) && Object(cross_domain_utils_src.isBlankDomain)(prerenderWindow)) {
|
5392 | var doc = prerenderWindow.document, el = _this27.renderTemplate(_this27.component.prerenderTemplate, {
|
5393 | context: context,
|
5394 | uid: uid,
|
5395 | document: doc
|
5396 | });
|
5397 | el instanceof ElementNode && (el = el.render(dom_dom({
|
5398 | doc: doc
|
5399 | })));
|
5400 | try {
|
5401 | Object(belter_src.writeElementToWindow)(prerenderWindow, el);
|
5402 | } catch (err) {
|
5403 | return;
|
5404 | }
|
5405 | var _ref13 = _this27.component.autoResize || {}, _ref13$width = _ref13.width, width = void 0 !== _ref13$width && _ref13$width, _ref13$height = _ref13.height, height = void 0 !== _ref13$height && _ref13$height, _ref13$element = _ref13.element, element = void 0 === _ref13$element ? "body" : _ref13$element;
|
5406 | (width || height) && Object(belter_src.onResize)(Object(belter_src.getElement)(element, prerenderWindow.document), function(_ref14) {
|
5407 | var newWidth = _ref14.width, newHeight = _ref14.height;
|
5408 | _this27.resize({
|
5409 | width: width ? newWidth : void 0,
|
5410 | height: height ? newHeight : void 0
|
5411 | });
|
5412 | }, {
|
5413 | width: width,
|
5414 | height: height,
|
5415 | win: prerenderWindow
|
5416 | });
|
5417 | }
|
5418 | });
|
5419 | });
|
5420 | };
|
5421 | ParentComponent.prototype.renderTemplate = function(renderer, _ref15) {
|
5422 | var _this28 = this, context = _ref15.context, uid = _ref15.uid, focus = _ref15.focus, container = _ref15.container, document = _ref15.document, outlet = _ref15.outlet;
|
5423 | focus = focus || function() {
|
5424 | return src.a.resolve();
|
5425 | };
|
5426 | return renderer.call(this, {
|
5427 | context: context,
|
5428 | uid: uid,
|
5429 | id: constants.CLASS_NAMES.ZOID + "-" + this.component.tag + "-" + uid,
|
5430 | props: renderer.__xdomain__ ? null : this.props,
|
5431 | tag: this.component.tag,
|
5432 | CLASS: constants.CLASS_NAMES,
|
5433 | ANIMATION: constants.ANIMATION_NAMES,
|
5434 | CONTEXT: constants.CONTEXT,
|
5435 | EVENT: constants.EVENTS,
|
5436 | actions: {
|
5437 | focus: focus,
|
5438 | close: function() {
|
5439 | return _this28.userClose();
|
5440 | }
|
5441 | },
|
5442 | on: function(eventName, handler) {
|
5443 | return _this28.on(eventName, handler);
|
5444 | },
|
5445 | jsxDom: node,
|
5446 | document: document,
|
5447 | dimensions: this.component.dimensions,
|
5448 | container: container,
|
5449 | outlet: outlet
|
5450 | });
|
5451 | };
|
5452 | ParentComponent.prototype.openContainer = function(element, _ref16) {
|
5453 | var _this29 = this, context = _ref16.context, uid = _ref16.uid, focus = _ref16.focus;
|
5454 | return src.a.try(function() {
|
5455 | var el;
|
5456 | if (!(el = element ? Object(belter_src.getElement)(element) : document.body)) throw new Error("Could not find element to open container into");
|
5457 | if (_this29.component.containerTemplate) {
|
5458 | var outlet = document.createElement("div");
|
5459 | Object(belter_src.addClass)(outlet, constants.CLASS_NAMES.OUTLET);
|
5460 | var container = _this29.renderTemplate(_this29.component.containerTemplate, {
|
5461 | context: context,
|
5462 | uid: uid,
|
5463 | container: el,
|
5464 | focus: focus,
|
5465 | outlet: outlet
|
5466 | });
|
5467 | container instanceof ElementNode && (container = container.render(dom_dom({
|
5468 | doc: document
|
5469 | })));
|
5470 | _this29.container = container;
|
5471 | Object(belter_src.hideElement)(_this29.container);
|
5472 | Object(belter_src.appendChild)(el, _this29.container);
|
5473 | if (_this29.driver.renderedIntoContainer) {
|
5474 | _this29.element = outlet;
|
5475 | Object(belter_src.hideElement)(_this29.element);
|
5476 | if (!_this29.element) throw new Error("Could not find element to render component into");
|
5477 | Object(belter_src.hideElement)(_this29.element);
|
5478 | }
|
5479 | _this29.clean.register("destroyContainerTemplate", function() {
|
5480 | _this29.container && _this29.container.parentNode && _this29.container.parentNode.removeChild(_this29.container);
|
5481 | delete _this29.container;
|
5482 | });
|
5483 | } else if (_this29.driver.renderedIntoContainer) throw new Error("containerTemplate needed to render " + context);
|
5484 | });
|
5485 | };
|
5486 | ParentComponent.prototype.cancelContainerEvents = function() {
|
5487 | this.clean.run("destroyContainerEvents");
|
5488 | };
|
5489 | ParentComponent.prototype.destroy = function() {
|
5490 | var _this30 = this;
|
5491 | return src.a.try(function() {
|
5492 | if (_this30.clean.hasTasks()) {
|
5493 | _this30.component.log("destroy");
|
5494 | return _this30.clean.all();
|
5495 | }
|
5496 | });
|
5497 | };
|
5498 | ParentComponent.prototype.tryInit = function(method) {
|
5499 | var _this31 = this;
|
5500 | return src.a.try(method).catch(function(err) {
|
5501 | _this31.onInit.reject(err);
|
5502 | }).then(function() {
|
5503 | return _this31.onInit;
|
5504 | });
|
5505 | };
|
5506 | ParentComponent.prototype.error = function(err) {
|
5507 | var _this32 = this, props = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : this.props;
|
5508 | if (!this.errored) {
|
5509 | this.errored = !0;
|
5510 | return src.a.try(function() {
|
5511 | _this32.onInit = _this32.onInit || new src.a();
|
5512 | _this32.onInit.reject(err);
|
5513 | return _this32.destroy();
|
5514 | }).then(function() {
|
5515 | if (props.onError) return props.onError(err);
|
5516 | }).catch(function(errErr) {
|
5517 | throw new Error("An error was encountered while handling error:\n\n " + Object(belter_src.stringifyError)(err) + "\n\n" + Object(belter_src.stringifyError)(errErr));
|
5518 | }).then(function() {
|
5519 | if (!props.onError) throw err;
|
5520 | });
|
5521 | }
|
5522 | };
|
5523 | ParentComponent.destroyAll = function() {
|
5524 | for (var results = []; ParentComponent.activeComponents.length; ) results.push(ParentComponent.activeComponents[0].destroy());
|
5525 | return src.a.all(results).then(belter_src.noop);
|
5526 | };
|
5527 | return ParentComponent;
|
5528 | }()).prototype, "close", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "close"), parent__class.prototype),
|
5529 | parent__applyDecoratedDescriptor(parent__class.prototype, "closeContainer", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "closeContainer"), parent__class.prototype),
|
5530 | parent__applyDecoratedDescriptor(parent__class.prototype, "destroyContainer", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "destroyContainer"), parent__class.prototype),
|
5531 | parent__applyDecoratedDescriptor(parent__class.prototype, "closeComponent", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "closeComponent"), parent__class.prototype),
|
5532 | parent__applyDecoratedDescriptor(parent__class.prototype, "showContainer", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "showContainer"), parent__class.prototype),
|
5533 | parent__applyDecoratedDescriptor(parent__class.prototype, "showComponent", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "showComponent"), parent__class.prototype),
|
5534 | parent__applyDecoratedDescriptor(parent__class.prototype, "hideContainer", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "hideContainer"), parent__class.prototype),
|
5535 | parent__applyDecoratedDescriptor(parent__class.prototype, "hideComponent", [ belter_src.memoized ], Object.getOwnPropertyDescriptor(parent__class.prototype, "hideComponent"), parent__class.prototype),
|
5536 | parent__class);
|
5537 | parent_ParentComponent.activeComponents = [];
|
5538 | var _createClass = function() {
|
5539 | function defineProperties(target, props) {
|
5540 | for (var i = 0; i < props.length; i++) {
|
5541 | var descriptor = props[i];
|
5542 | descriptor.enumerable = descriptor.enumerable || !1;
|
5543 | descriptor.configurable = !0;
|
5544 | "value" in descriptor && (descriptor.writable = !0);
|
5545 | Object.defineProperty(target, descriptor.key, descriptor);
|
5546 | }
|
5547 | }
|
5548 | return function(Constructor, protoProps, staticProps) {
|
5549 | protoProps && defineProperties(Constructor.prototype, protoProps);
|
5550 | staticProps && defineProperties(Constructor, staticProps);
|
5551 | return Constructor;
|
5552 | };
|
5553 | }(), delegate_DelegateComponent = function() {
|
5554 | function DelegateComponent(component, source, options) {
|
5555 | !function(instance, Constructor) {
|
5556 | if (!(instance instanceof DelegateComponent)) throw new TypeError("Cannot call a class as a function");
|
5557 | }(this);
|
5558 | this.component = component;
|
5559 | this.context = options.context;
|
5560 | this.clean = cleanup(this);
|
5561 | this.event = Object(belter_src.eventEmitter)();
|
5562 | this.destroyComponent = parent_ParentComponent.prototype.destroyComponent;
|
5563 | this.resize = parent_ParentComponent.prototype.resize;
|
5564 | this.renderTemplate = parent_ParentComponent.prototype.renderTemplate;
|
5565 | this.registerActiveComponent = parent_ParentComponent.prototype.registerActiveComponent;
|
5566 | this.props = {
|
5567 | window: options.props.window,
|
5568 | onClose: options.props.onClose,
|
5569 | onDisplay: options.props.onDisplay
|
5570 | };
|
5571 | for (var _i2 = 0, _component$getPropNam2 = component.getPropNames(), _length2 = null == _component$getPropNam2 ? 0 : _component$getPropNam2.length; _i2 < _length2; _i2++) {
|
5572 | var propName = _component$getPropNam2[_i2];
|
5573 | this.component.getProp(propName).allowDelegate && (this.props[propName] = options.props[propName]);
|
5574 | }
|
5575 | this.userClose = options.overrides.userClose;
|
5576 | this.error = options.overrides.error;
|
5577 | this.on = options.overrides.on;
|
5578 | this.registerActiveComponent();
|
5579 | this.watchForClose(source);
|
5580 | }
|
5581 | DelegateComponent.prototype.getDelegate = function() {
|
5582 | var _this = this;
|
5583 | return {
|
5584 | overrides: this.getOverrides(),
|
5585 | destroy: function() {
|
5586 | return _this.destroy();
|
5587 | }
|
5588 | };
|
5589 | };
|
5590 | DelegateComponent.prototype.watchForClose = function(source) {
|
5591 | var _this2 = this, closeWindowListener = Object(cross_domain_utils_src.onCloseWindow)(source, function() {
|
5592 | return _this2.destroy();
|
5593 | }, 3e3);
|
5594 | this.clean.register("destroyCloseWindowListener", closeWindowListener.cancel);
|
5595 | };
|
5596 | DelegateComponent.prototype.getOverrides = function() {
|
5597 | for (var context = this.context, delegateOverrides = RENDER_DRIVERS[context].delegateOverrides, overrides = {}, self = this, _loop = function(_i4, _Object$keys2, _length4) {
|
5598 | var key = _Object$keys2[_i4];
|
5599 | overrides[key] = function() {
|
5600 | return parent_ParentComponent.prototype[key].apply(self, arguments);
|
5601 | };
|
5602 | }, _i4 = 0, _Object$keys2 = Object.keys(delegateOverrides), _length4 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i4 < _length4; _i4++) _loop(_i4, _Object$keys2);
|
5603 | return overrides;
|
5604 | };
|
5605 | DelegateComponent.prototype.destroy = function() {
|
5606 | return this.clean.all();
|
5607 | };
|
5608 | _createClass(DelegateComponent, [ {
|
5609 | key: "driver",
|
5610 | get: function() {
|
5611 | return RENDER_DRIVERS[this.context];
|
5612 | }
|
5613 | } ]);
|
5614 | return DelegateComponent;
|
5615 | }(), drivers = __webpack_require__("./src/drivers/index.js"), validate__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
5616 | return typeof obj;
|
5617 | } : function(obj) {
|
5618 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
5619 | };
|
5620 | function defaultContainerTemplate(_ref) {
|
5621 | var id = _ref.id, tag = _ref.tag, context = _ref.context, CLASS = _ref.CLASS, outlet = _ref.outlet, document = _ref.document, _ref$dimensions = _ref.dimensions, width = _ref$dimensions.width, height = _ref$dimensions.height;
|
5622 | return node("div", {
|
5623 | id: id,
|
5624 | class: CLASS.ZOID + " " + CLASS.ZOID + "-tag-" + tag + " " + CLASS.ZOID + "-context-" + context
|
5625 | }, node("style", null, "\n #" + id + ", #" + id + " > ." + CLASS.OUTLET + " {\n width: " + width + ";\n height: " + height + ";\n }\n\n #" + id + " > ." + CLASS.OUTLET + " {\n display: inline-block;\n position: relative;\n }\n\n #" + id + " > ." + CLASS.OUTLET + " > iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0;\n left: 0;\n transition: opacity .2s ease-in-out;\n }\n\n #" + id + " > ." + CLASS.OUTLET + " > iframe." + CLASS.VISIBLE + " {\n opacity: 1;\n }\n\n #" + id + " > ." + CLASS.OUTLET + " > iframe." + CLASS.INVISIBLE + " {\n opacity: 0;\n }\n "), node("node", {
|
5626 | el: outlet
|
5627 | })).render(dom_dom({
|
5628 | doc: document
|
5629 | }));
|
5630 | }
|
5631 | function defaultPrerenderTemplate(_ref) {
|
5632 | var document = _ref.document;
|
5633 | return node("html", null, node("head", null, node("style", null, "\n html, body {\n width: 100%;\n height: 100%;\n overflow: hidden;\n top: 0;\n left: 0;\n margin: 0;\n text-align: center;\n }\n\n .spinner {\n position: absolute;\n max-height: 60vmin;\n max-width: 60vmin;\n height: 40px;\n width: 40px;\n top: 50%;\n left: 50%;\n transform: translateX(-50%) translateY(-50%);\n z-index: 10;\n }\n\n .spinner .loader {\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n border: 3px solid rgba(0, 0, 0, .2);\n border-top-color: rgba(33, 128, 192, 0.8);\n border-radius: 100%;\n animation: rotation .7s infinite linear;\n\n }\n\n @keyframes rotation {\n from {\n transform: rotate(0deg)\n }\n to {\n transform: rotate(359deg)\n }\n }\n ")), node("body", null, node("div", {
|
5634 | class: "spinner"
|
5635 | }, node("div", {
|
5636 | id: "loader",
|
5637 | class: "loader"
|
5638 | })))).render(dom_dom({
|
5639 | doc: document
|
5640 | }));
|
5641 | }
|
5642 | __webpack_require__("./src/types.js");
|
5643 | var component__class, component__typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
5644 | return typeof obj;
|
5645 | } : function(obj) {
|
5646 | return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
5647 | }, component_drivers = {
|
5648 | angular: drivers.angular,
|
5649 | angular2: drivers.angular2,
|
5650 | glimmer: drivers.glimmer,
|
5651 | react: drivers.react,
|
5652 | vue: drivers.vue
|
5653 | }, component_Component = (function(target, property, decorators, descriptor, context) {
|
5654 | var desc = {};
|
5655 | Object.keys(descriptor).forEach(function(key) {
|
5656 | desc[key] = descriptor[key];
|
5657 | });
|
5658 | desc.enumerable = !!desc.enumerable;
|
5659 | desc.configurable = !!desc.configurable;
|
5660 | ("value" in desc || desc.initializer) && (desc.writable = !0);
|
5661 | desc = decorators.slice().reverse().reduce(function(desc, decorator) {
|
5662 | return decorator(target, "getPropNames", desc) || desc;
|
5663 | }, desc);
|
5664 | if (context && void 0 !== desc.initializer) {
|
5665 | desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
|
5666 | desc.initializer = void 0;
|
5667 | }
|
5668 | if (void 0 === desc.initializer) {
|
5669 | Object.defineProperty(target, "getPropNames", desc);
|
5670 | desc = null;
|
5671 | }
|
5672 | }((component__class = function() {
|
5673 | function Component(options) {
|
5674 | !function(instance, Constructor) {
|
5675 | if (!(instance instanceof Component)) throw new TypeError("Cannot call a class as a function");
|
5676 | }(this);
|
5677 | !function(options) {
|
5678 | if (!options) throw new Error("Expected options to be passed");
|
5679 | if (!options.tag || !options.tag.match(/^[a-z0-9-]+$/)) throw new Error("Invalid options.tag: " + options.tag);
|
5680 | !function(options) {
|
5681 | if (options.props && "object" !== validate__typeof(options.props)) throw new Error("Expected options.props to be an object");
|
5682 | if (options.props) for (var _i2 = 0, _Object$keys2 = Object.keys(options.props), _length2 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i2 < _length2; _i2++) {
|
5683 | var key = _Object$keys2[_i2], prop = options.props[key];
|
5684 | if (!prop || "object" !== (void 0 === prop ? "undefined" : validate__typeof(prop))) throw new Error("Expected options.props." + key + " to be an object");
|
5685 | if (!prop.type) throw new Error("Expected prop.type");
|
5686 | if (-1 === constants.PROP_TYPES_LIST.indexOf(prop.type)) throw new Error("Expected prop.type to be one of " + constants.PROP_TYPES_LIST.join(", "));
|
5687 | if (prop.required && prop.def) throw new Error("Required prop can not have a default value");
|
5688 | }
|
5689 | }(options);
|
5690 | if (options.dimensions) {
|
5691 | if (options.dimensions && !Object(belter_src.isPx)(options.dimensions.width) && !Object(belter_src.isPerc)(options.dimensions.width)) throw new Error("Expected options.dimensions.width to be a px or % string value");
|
5692 | if (options.dimensions && !Object(belter_src.isPx)(options.dimensions.height) && !Object(belter_src.isPerc)(options.dimensions.height)) throw new Error("Expected options.dimensions.height to be a px or % string value");
|
5693 | }
|
5694 | if (options.contexts) {
|
5695 | options.contexts.popup;
|
5696 | for (var anyEnabled = !1, _i4 = 0, _Object$keys4 = Object.keys(options.contexts), _length4 = null == _Object$keys4 ? 0 : _Object$keys4.length; _i4 < _length4; _i4++) {
|
5697 | var context = _Object$keys4[_i4];
|
5698 | if (-1 === constants.CONTEXT_LIST.indexOf(context)) throw new Error("Unsupported context type: " + context);
|
5699 | (options.contexts && options.contexts[context] || options.contexts && void 0 === options.contexts[context]) && (anyEnabled = !0);
|
5700 | }
|
5701 | if (!anyEnabled) throw new Error("No context type is enabled");
|
5702 | }
|
5703 | if (options.defaultContext) {
|
5704 | if (-1 === constants.CONTEXT_LIST.indexOf(options.defaultContext)) throw new Error("Unsupported context type: " + (options.defaultContext || "unknown"));
|
5705 | if (options.contexts && options.defaultContext && !options.contexts[options.defaultContext]) throw new Error("Disallowed default context type: " + (options.defaultContext || "unknown"));
|
5706 | }
|
5707 | if (options.defaultEnv) {
|
5708 | if ("string" != typeof options.defaultEnv) throw new TypeError("Expected options.defaultEnv to be a string");
|
5709 | if ("object" === validate__typeof(options.url) && !options.url[options.defaultEnv]) throw new Error("No url found for default env: " + options.defaultEnv);
|
5710 | }
|
5711 | if (!options.url && !options.buildUrl) throw new Error("Must pass url");
|
5712 | if ("object" === validate__typeof(options.url)) {
|
5713 | if (!options.defaultEnv) throw new Error("Must pass options.defaultEnv with env->url mapping");
|
5714 | for (var _i6 = 0, _Object$keys6 = Object.keys(options.url), _length6 = null == _Object$keys6 ? 0 : _Object$keys6.length; _i6 < _length6; _i6++) {
|
5715 | var env = _Object$keys6[_i6];
|
5716 | if (!options.url[env]) throw new Error("No url specified for env: " + env);
|
5717 | }
|
5718 | }
|
5719 | if (options.prerenderTemplate && "function" != typeof options.prerenderTemplate) throw new Error("Expected options.prerenderTemplate to be a function");
|
5720 | if (options.containerTemplate && "function" != typeof options.containerTemplate) throw new Error("Expected options.containerTemplate to be a function");
|
5721 | }(options);
|
5722 | this.tag = options.tag;
|
5723 | this.name = this.tag.replace(/-/g, "_");
|
5724 | this.allowedParentDomains = options.allowedParentDomains || constants.WILDCARD;
|
5725 | if (Component.components[this.tag]) throw new Error("Can not register multiple components with the same tag");
|
5726 | this.builtinProps = {
|
5727 | env: {
|
5728 | type: "string",
|
5729 | queryParam: !0,
|
5730 | required: !1,
|
5731 | def: function(props, component) {
|
5732 | return component.defaultEnv;
|
5733 | }
|
5734 | },
|
5735 | window: {
|
5736 | type: "object",
|
5737 | sendToChild: !1,
|
5738 | required: !1,
|
5739 | validate: function(val) {
|
5740 | if (!Object(cross_domain_utils_src.isWindow)(val) && !window_ProxyWindow.isProxyWindow(val)) throw new Error("Expected Window or ProxyWindow");
|
5741 | },
|
5742 | decorate: function(val) {
|
5743 | if (val) return window_ProxyWindow.toProxyWindow(val);
|
5744 | }
|
5745 | },
|
5746 | dimensions: {
|
5747 | type: "object",
|
5748 | required: !1
|
5749 | },
|
5750 | timeout: {
|
5751 | type: "number",
|
5752 | required: !1,
|
5753 | sendToChild: !1
|
5754 | },
|
5755 | onDisplay: {
|
5756 | type: "function",
|
5757 | required: !1,
|
5758 | sendToChild: !1,
|
5759 | def: function() {
|
5760 | return belter_src.noop;
|
5761 | },
|
5762 | decorate: function(onDisplay) {
|
5763 | return Object(belter_src.memoize)(Object(belter_src.promisify)(onDisplay));
|
5764 | }
|
5765 | },
|
5766 | onEnter: {
|
5767 | type: "function",
|
5768 | required: !1,
|
5769 | sendToChild: !1,
|
5770 | def: function() {
|
5771 | return belter_src.noop;
|
5772 | },
|
5773 | decorate: function(onEnter) {
|
5774 | return Object(belter_src.promisify)(onEnter);
|
5775 | }
|
5776 | },
|
5777 | onRender: {
|
5778 | type: "function",
|
5779 | required: !1,
|
5780 | sendToChild: !1,
|
5781 | def: function() {
|
5782 | return belter_src.noop;
|
5783 | },
|
5784 | decorate: function(onRender) {
|
5785 | return Object(belter_src.promisify)(onRender);
|
5786 | }
|
5787 | },
|
5788 | onClose: {
|
5789 | type: "function",
|
5790 | required: !1,
|
5791 | sendToChild: !1,
|
5792 | def: function() {
|
5793 | return belter_src.noop;
|
5794 | },
|
5795 | decorate: function(onClose) {
|
5796 | return Object(belter_src.once)(Object(belter_src.promisify)(onClose));
|
5797 | }
|
5798 | },
|
5799 | onError: {
|
5800 | type: "function",
|
5801 | required: !1,
|
5802 | sendToChild: !0,
|
5803 | def: function() {
|
5804 | return function(err) {
|
5805 | setTimeout(function() {
|
5806 | throw err;
|
5807 | });
|
5808 | };
|
5809 | },
|
5810 | decorate: function(onError) {
|
5811 | return Object(belter_src.once)(Object(belter_src.promisify)(onError));
|
5812 | }
|
5813 | }
|
5814 | };
|
5815 | this.props = options.props || {};
|
5816 | var _ref = options.dimensions || {}, _ref$width = _ref.width, width = void 0 === _ref$width ? constants.DEFAULT_DIMENSIONS.WIDTH : _ref$width, _ref$height = _ref.height, height = void 0 === _ref$height ? constants.DEFAULT_DIMENSIONS.HEIGHT : _ref$height;
|
5817 | this.dimensions = {
|
5818 | width: Object(belter_src.toCSS)(width),
|
5819 | height: Object(belter_src.toCSS)(height)
|
5820 | };
|
5821 | this.defaultEnv = options.defaultEnv;
|
5822 | this.url = options.url || options.buildUrl;
|
5823 | this.domain = options.domain;
|
5824 | this.bridgeUrl = options.bridgeUrl;
|
5825 | this.attributes = options.attributes || {};
|
5826 | this.contexts = options.contexts || {
|
5827 | iframe: !0,
|
5828 | popup: !1
|
5829 | };
|
5830 | this.defaultContext = options.defaultContext || constants.CONTEXT.IFRAME;
|
5831 | this.autoResize = "object" === component__typeof(options.autoResize) ? options.autoResize : {
|
5832 | width: Boolean(options.autoResize),
|
5833 | height: Boolean(options.autoResize),
|
5834 | element: "body"
|
5835 | };
|
5836 | this.containerTemplate = options.containerTemplate || defaultContainerTemplate;
|
5837 | this.prerenderTemplate = options.prerenderTemplate || defaultPrerenderTemplate;
|
5838 | this.validate = options.validate;
|
5839 | Component.components[this.tag] = this;
|
5840 | this.registerDrivers();
|
5841 | this.registerChild();
|
5842 | this.listenDelegate();
|
5843 | }
|
5844 | Component.prototype.getPropNames = function() {
|
5845 | for (var props = Object.keys(this.props), _i2 = 0, _Object$keys2 = Object.keys(this.builtinProps), _length2 = null == _Object$keys2 ? 0 : _Object$keys2.length; _i2 < _length2; _i2++) {
|
5846 | var key = _Object$keys2[_i2];
|
5847 | -1 === props.indexOf(key) && props.push(key);
|
5848 | }
|
5849 | return props;
|
5850 | };
|
5851 | Component.prototype.getProp = function(name) {
|
5852 | return this.props[name] || this.builtinProps[name];
|
5853 | };
|
5854 | Component.prototype.registerDrivers = function() {
|
5855 | this.driverCache = {};
|
5856 | for (var _i4 = 0, _Object$keys4 = Object.keys(component_drivers), _length4 = null == _Object$keys4 ? 0 : _Object$keys4.length; _i4 < _length4; _i4++) {
|
5857 | var driverName = _Object$keys4[_i4];
|
5858 | if (0 !== driverName.indexOf("_")) {
|
5859 | var glob = component_drivers[driverName].global();
|
5860 | glob && this.driver(driverName, glob);
|
5861 | }
|
5862 | }
|
5863 | };
|
5864 | Component.prototype.driver = function(name, dep) {
|
5865 | if (!component_drivers[name]) throw new Error("Could not find driver for framework: " + name);
|
5866 | this.driverCache[name] || (this.driverCache[name] = component_drivers[name].register(this, dep));
|
5867 | return this.driverCache[name];
|
5868 | };
|
5869 | Component.prototype.registerChild = function() {
|
5870 | var _this = this;
|
5871 | return src.a.try(function() {
|
5872 | if (_this.isChild()) return new child_ChildComponent(_this);
|
5873 | });
|
5874 | };
|
5875 | Component.prototype.listenDelegate = function() {
|
5876 | var _this2 = this;
|
5877 | _on(constants.POST_MESSAGE.ALLOW_DELEGATE + "_" + this.name, function() {
|
5878 | return !0;
|
5879 | });
|
5880 | _on(constants.POST_MESSAGE.DELEGATE + "_" + this.name, function(_ref2) {
|
5881 | var source = _ref2.source, _ref2$data = _ref2.data, context = _ref2$data.context, props = _ref2$data.props, overrides = _ref2$data.overrides;
|
5882 | return _this2.delegate(source, {
|
5883 | context: context,
|
5884 | props: props,
|
5885 | overrides: overrides
|
5886 | }).getDelegate();
|
5887 | });
|
5888 | };
|
5889 | Component.prototype.canRenderTo = function(win) {
|
5890 | return _send(win, constants.POST_MESSAGE.ALLOW_DELEGATE + "_" + this.name).then(function(_ref3) {
|
5891 | return _ref3.data;
|
5892 | }).catch(function() {
|
5893 | return !1;
|
5894 | });
|
5895 | };
|
5896 | Component.prototype.getUrl = function(props) {
|
5897 | if ("function" == typeof this.url) return this.url(props);
|
5898 | if ("string" == typeof this.url) return this.url;
|
5899 | var env = props.env || this.defaultEnv;
|
5900 | if (env && "object" === component__typeof(this.url) && this.url[env]) return this.url[env];
|
5901 | throw new Error("Can not find url");
|
5902 | };
|
5903 | Component.prototype.getInitialDomain = function(props) {
|
5904 | if ("string" == typeof this.domain) return this.domain;
|
5905 | var env = props.env || this.defaultEnv;
|
5906 | return env && "object" === component__typeof(this.domain) && !Object(belter_src.isRegex)(this.domain) && this.domain[env] ? this.domain[env] : Object(cross_domain_utils_src.getDomainFromUrl)(this.getUrl(props));
|
5907 | };
|
5908 | Component.prototype.getDomain = function(props) {
|
5909 | return Object(belter_src.isRegex)(this.domain) ? this.domain : this.getInitialDomain(props);
|
5910 | };
|
5911 | Component.prototype.getBridgeUrl = function(props) {
|
5912 | if (this.bridgeUrl) {
|
5913 | if ("string" == typeof this.bridgeUrl) return this.bridgeUrl;
|
5914 | var env = props.env || this.defaultEnv;
|
5915 | if (env && "object" === component__typeof(this.bridgeUrl) && this.bridgeUrl[env]) return this.bridgeUrl[env];
|
5916 | }
|
5917 | };
|
5918 | Component.prototype.isZoidComponent = function() {
|
5919 | return isZoidComponentWindow();
|
5920 | };
|
5921 | Component.prototype.isChild = function() {
|
5922 | return isZoidComponentWindow() && parseChildWindowName().tag === this.tag;
|
5923 | };
|
5924 | Component.prototype.createError = function(message, tag) {
|
5925 | return new Error("[" + (tag || this.tag) + "] " + message);
|
5926 | };
|
5927 | Component.prototype.init = function(props, context, element) {
|
5928 | return new parent_ParentComponent(this, this.getRenderContext(context, element), {
|
5929 | props: props
|
5930 | });
|
5931 | };
|
5932 | Component.prototype.delegate = function(source, options) {
|
5933 | return new delegate_DelegateComponent(this, source, options);
|
5934 | };
|
5935 | Component.prototype.validateRenderContext = function(context, element) {
|
5936 | if (context && !this.contexts[context]) throw new Error("[" + this.tag + "] Can not render to " + context);
|
5937 | if (!element && context === constants.CONTEXT.IFRAME) throw new Error("[" + this.tag + "] Context type " + constants.CONTEXT.IFRAME + " requires an element selector");
|
5938 | };
|
5939 | Component.prototype.getDefaultContext = function() {
|
5940 | if (this.defaultContext && this.contexts[this.defaultContext]) return this.defaultContext;
|
5941 | if (this.contexts[constants.CONTEXT.IFRAME]) return constants.CONTEXT.IFRAME;
|
5942 | if (this.contexts[constants.CONTEXT.POPUP]) return constants.CONTEXT.POPUP;
|
5943 | throw new Error("Can not determine default context");
|
5944 | };
|
5945 | Component.prototype.getRenderContext = function(context, element) {
|
5946 | context = context || this.getDefaultContext();
|
5947 | this.validateRenderContext(context, element);
|
5948 | return context;
|
5949 | };
|
5950 | Component.prototype.render = function(props, element) {
|
5951 | var _this3 = this;
|
5952 | return src.a.try(function() {
|
5953 | var context = _this3.getRenderContext(null, element);
|
5954 | return new parent_ParentComponent(_this3, context, {
|
5955 | props: props
|
5956 | }).render(context, element);
|
5957 | });
|
5958 | };
|
5959 | Component.prototype.renderIframe = function(props, element) {
|
5960 | var _this4 = this;
|
5961 | return src.a.try(function() {
|
5962 | var context = _this4.getRenderContext(constants.CONTEXT.IFRAME, element);
|
5963 | return new parent_ParentComponent(_this4, context, {
|
5964 | props: props
|
5965 | }).render(context, element);
|
5966 | });
|
5967 | };
|
5968 | Component.prototype.renderPopup = function(props) {
|
5969 | var _this5 = this;
|
5970 | return src.a.try(function() {
|
5971 | var context = _this5.getRenderContext(constants.CONTEXT.POPUP);
|
5972 | return new parent_ParentComponent(_this5, context, {
|
5973 | props: props
|
5974 | }).render(context);
|
5975 | });
|
5976 | };
|
5977 | Component.prototype.renderTo = function(win, props, element) {
|
5978 | var _this6 = this;
|
5979 | return src.a.try(function() {
|
5980 | var context = _this6.getRenderContext(null, element);
|
5981 | return new parent_ParentComponent(_this6, context, {
|
5982 | props: props
|
5983 | }).renderTo(context, win, element);
|
5984 | });
|
5985 | };
|
5986 | Component.prototype.renderIframeTo = function(win, props, element) {
|
5987 | var _this7 = this;
|
5988 | return src.a.try(function() {
|
5989 | var context = _this7.getRenderContext(constants.CONTEXT.IFRAME, element);
|
5990 | return new parent_ParentComponent(_this7, context, {
|
5991 | props: props
|
5992 | }).renderTo(context, win, element);
|
5993 | });
|
5994 | };
|
5995 | Component.prototype.renderPopupTo = function(win, props) {
|
5996 | var _this8 = this;
|
5997 | return src.a.try(function() {
|
5998 | var context = _this8.getRenderContext(constants.CONTEXT.POPUP);
|
5999 | return new parent_ParentComponent(_this8, context, {
|
6000 | props: props
|
6001 | }).renderTo(context, win);
|
6002 | });
|
6003 | };
|
6004 | Component.prototype.log = function(event) {
|
6005 | var payload = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
6006 | !function(name, event) {
|
6007 | var payload = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
6008 | logger && logger.info("xc_" + name + "_" + event, payload);
|
6009 | }(this.name, event, payload);
|
6010 | };
|
6011 | Component.prototype.logWarning = function(event, payload) {
|
6012 | !function(name, event) {
|
6013 | var payload = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
6014 | logger && logger.warn("xc_" + name + "_" + event, payload);
|
6015 | }(this.name, event, payload);
|
6016 | };
|
6017 | Component.prototype.logError = function(event, payload) {
|
6018 | !function(name, event) {
|
6019 | var payload = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
6020 | logger && logger.error("xc_" + name + "_" + event, payload);
|
6021 | }(this.name, event, payload);
|
6022 | };
|
6023 | Component.getByTag = function(tag) {
|
6024 | return Component.components[tag];
|
6025 | };
|
6026 | return Component;
|
6027 | }()).prototype, 0, [ belter_src.memoize ], Object.getOwnPropertyDescriptor(component__class.prototype, "getPropNames"), component__class.prototype),
|
6028 | component__class);
|
6029 | component_Component.components = {};
|
6030 | function create(options) {
|
6031 | return new component_Component(options);
|
6032 | }
|
6033 | function getByTag(tag) {
|
6034 | return component_Component.getByTag(tag);
|
6035 | }
|
6036 | function interface_destroyAll() {
|
6037 | return parent_ParentComponent.destroyAll();
|
6038 | }
|
6039 | var postRobot = post_robot_src_namespaceObject, CONSTANTS = constants;
|
6040 | __webpack_require__.d(__webpack_exports__, "PopupOpenError", function() {
|
6041 | return belter_src.PopupOpenError;
|
6042 | });
|
6043 | __webpack_require__.d(__webpack_exports__, "create", function() {
|
6044 | return create;
|
6045 | });
|
6046 | __webpack_require__.d(__webpack_exports__, "getByTag", function() {
|
6047 | return getByTag;
|
6048 | });
|
6049 | __webpack_require__.d(__webpack_exports__, "getCurrentScriptDir", function() {
|
6050 | return getCurrentScriptDir;
|
6051 | });
|
6052 | __webpack_require__.d(__webpack_exports__, "useLogger", function() {
|
6053 | return useLogger;
|
6054 | });
|
6055 | __webpack_require__.d(__webpack_exports__, "destroyAll", function() {
|
6056 | return interface_destroyAll;
|
6057 | });
|
6058 | __webpack_require__.d(__webpack_exports__, "postRobot", function() {
|
6059 | return postRobot;
|
6060 | });
|
6061 | __webpack_require__.d(__webpack_exports__, "CONSTANTS", function() {
|
6062 | return CONSTANTS;
|
6063 | });
|
6064 | __webpack_exports__.default = src_interface_namespaceObject;
|
6065 | },
|
6066 | "./src/types.js": function(module, exports) {}
|
6067 | });
|
6068 | });
|
6069 |
|
\ | No newline at end of file |