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