Version Description
Fixed
- Stuck on preparing to import
Download this release
Release Info
| Developer | yani.iliev |
| Plugin | |
| Version | 6.50 |
| Comparing to | |
| See all releases | |
Code changes from version 6.49 to 6.50
- all-in-one-wp-migration.php +1 -1
- constants.php +1 -1
- lib/view/assets/javascript/import.min.js +1579 -1095
- readme.txt +6 -1
all-in-one-wp-migration.php
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
* Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
|
| 6 |
* Author: ServMask
|
| 7 |
* Author URI: https://servmask.com/
|
| 8 |
-
* Version: 6.
|
| 9 |
* Text Domain: all-in-one-wp-migration
|
| 10 |
* Domain Path: /languages
|
| 11 |
* Network: True
|
| 5 |
* Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
|
| 6 |
* Author: ServMask
|
| 7 |
* Author URI: https://servmask.com/
|
| 8 |
+
* Version: 6.50
|
| 9 |
* Text Domain: all-in-one-wp-migration
|
| 10 |
* Domain Path: /languages
|
| 11 |
* Network: True
|
constants.php
CHANGED
|
@@ -31,7 +31,7 @@ define( 'AI1WM_DEBUG', false );
|
|
| 31 |
// ==================
|
| 32 |
// = Plugin Version =
|
| 33 |
// ==================
|
| 34 |
-
define( 'AI1WM_VERSION', '6.
|
| 35 |
|
| 36 |
// ===============
|
| 37 |
// = Plugin Name =
|
| 31 |
// ==================
|
| 32 |
// = Plugin Version =
|
| 33 |
// ==================
|
| 34 |
+
define( 'AI1WM_VERSION', '6.50' );
|
| 35 |
|
| 36 |
// ===============
|
| 37 |
// = Plugin Name =
|
lib/view/assets/javascript/import.min.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
| 47 |
'use strict';
|
| 48 |
|
| 49 |
/**
|
| 50 |
-
* Copyright (C) 2014-
|
| 51 |
*
|
| 52 |
* This program is free software: you can redistribute it and/or modify
|
| 53 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -71,7 +71,7 @@
|
|
| 71 |
*/
|
| 72 |
|
| 73 |
var Report = __webpack_require__(1),
|
| 74 |
-
Feedback = __webpack_require__(
|
| 75 |
Deprecated = __webpack_require__(8),
|
| 76 |
FileUploader = __webpack_require__(12);
|
| 77 |
|
|
@@ -89,12 +89,12 @@
|
|
| 89 |
|
| 90 |
/***/ },
|
| 91 |
/* 1 */
|
| 92 |
-
/***/ function(module, exports) {
|
| 93 |
|
| 94 |
'use strict';
|
| 95 |
|
| 96 |
/**
|
| 97 |
-
* Copyright (C) 2014-
|
| 98 |
*
|
| 99 |
* This program is free software: you can redistribute it and/or modify
|
| 100 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -117,6 +117,8 @@
|
|
| 117 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 118 |
*/
|
| 119 |
|
|
|
|
|
|
|
| 120 |
jQuery(document).ready(function ($) {
|
| 121 |
'use strict';
|
| 122 |
|
|
@@ -138,33 +140,35 @@
|
|
| 138 |
var terms = $('.ai1wm-report-terms').is(':checked');
|
| 139 |
|
| 140 |
$.ajax({
|
| 141 |
-
type: 'POST',
|
| 142 |
url: ai1wm_report.ajax.url,
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
success: function success(data) {
|
| 145 |
-
|
| 146 |
-
if (errors.length > 0) {
|
| 147 |
// Reset previous messages
|
| 148 |
$('.ai1wm-report-problem-dialog .ai1wm-message').remove();
|
| 149 |
|
| 150 |
-
var
|
| 151 |
-
$.each(errors, function (key, value) {
|
| 152 |
-
|
| 153 |
});
|
| 154 |
|
| 155 |
-
$('.ai1wm-report-problem-dialog').prepend(
|
| 156 |
} else {
|
| 157 |
-
var
|
| 158 |
-
$('.ai1wm-report-problem-dialog').html(
|
| 159 |
|
| 160 |
// Hide message
|
| 161 |
setTimeout(function () {
|
| 162 |
$('.ai1wm-report-problem-dialog').removeClass('ai1wm-report-active');
|
| 163 |
}, 2000);
|
| 164 |
}
|
| 165 |
-
}
|
| 166 |
-
dataType: 'json',
|
| 167 |
-
async: false
|
| 168 |
});
|
| 169 |
});
|
| 170 |
});
|
|
@@ -176,7 +180,87 @@
|
|
| 176 |
'use strict';
|
| 177 |
|
| 178 |
/**
|
| 179 |
-
* Copyright (C) 2014-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
*
|
| 181 |
* This program is free software: you can redistribute it and/or modify
|
| 182 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -199,6 +283,8 @@
|
|
| 199 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 200 |
*/
|
| 201 |
|
|
|
|
|
|
|
| 202 |
jQuery(document).ready(function ($) {
|
| 203 |
'use strict';
|
| 204 |
|
|
@@ -257,102 +343,34 @@
|
|
| 257 |
var terms = $('.ai1wm-feedback-terms').is(':checked');
|
| 258 |
|
| 259 |
$.ajax({
|
| 260 |
-
type: 'POST',
|
| 261 |
url: ai1wm_feedback.ajax.url,
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
success: function success(data) {
|
| 264 |
-
|
| 265 |
-
if (errors.length > 0) {
|
| 266 |
// Reset previous messages
|
| 267 |
$('.ai1wm-feedback .ai1wm-message').remove();
|
| 268 |
|
| 269 |
-
var
|
| 270 |
-
$.each(errors, function (key, value) {
|
| 271 |
-
|
| 272 |
});
|
| 273 |
|
| 274 |
-
$('.ai1wm-feedback').prepend(
|
| 275 |
} else {
|
| 276 |
-
var
|
| 277 |
-
$('.ai1wm-feedback').html(
|
| 278 |
}
|
| 279 |
-
}
|
| 280 |
-
dataType: 'json',
|
| 281 |
-
async: false
|
| 282 |
});
|
| 283 |
});
|
| 284 |
});
|
| 285 |
|
| 286 |
-
/***/ },
|
| 287 |
-
/* 3 */
|
| 288 |
-
/***/ function(module, exports) {
|
| 289 |
-
|
| 290 |
-
'use strict';
|
| 291 |
-
|
| 292 |
-
/**
|
| 293 |
-
* Copyright (C) 2014-2016 ServMask Inc.
|
| 294 |
-
*
|
| 295 |
-
* This program is free software: you can redistribute it and/or modify
|
| 296 |
-
* it under the terms of the GNU General Public License as published by
|
| 297 |
-
* the Free Software Foundation, either version 3 of the License, or
|
| 298 |
-
* (at your option) any later version.
|
| 299 |
-
*
|
| 300 |
-
* This program is distributed in the hope that it will be useful,
|
| 301 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 302 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 303 |
-
* GNU General Public License for more details.
|
| 304 |
-
*
|
| 305 |
-
* You should have received a copy of the GNU General Public License
|
| 306 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 307 |
-
*
|
| 308 |
-
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
| 309 |
-
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
| 310 |
-
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
| 311 |
-
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
| 312 |
-
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
| 313 |
-
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 314 |
-
*/
|
| 315 |
-
|
| 316 |
-
var $ = jQuery;
|
| 317 |
-
|
| 318 |
-
module.exports = {
|
| 319 |
-
random: function random(len) {
|
| 320 |
-
var text = '';
|
| 321 |
-
var possible = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
| 322 |
-
|
| 323 |
-
for (var i = 0; i < len; i++) {
|
| 324 |
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
| 325 |
-
}
|
| 326 |
-
|
| 327 |
-
return text;
|
| 328 |
-
},
|
| 329 |
-
form: function form(id) {
|
| 330 |
-
return $(id).serializeArray();
|
| 331 |
-
},
|
| 332 |
-
ucfirst: function ucfirst(text) {
|
| 333 |
-
return text.charAt(0).toUpperCase() + text.slice(1);
|
| 334 |
-
},
|
| 335 |
-
list: function list(input) {
|
| 336 |
-
// Convert object to list
|
| 337 |
-
if ($.isPlainObject(input)) {
|
| 338 |
-
var result = [];
|
| 339 |
-
var params = decodeURIComponent($.param(input)).split('&');
|
| 340 |
-
|
| 341 |
-
// Loop over params
|
| 342 |
-
$.each(params, function (index, item) {
|
| 343 |
-
var value = item.split('=');
|
| 344 |
-
|
| 345 |
-
// Add item
|
| 346 |
-
result.push({ name: value[0], value: value[1] });
|
| 347 |
-
});
|
| 348 |
-
|
| 349 |
-
return result;
|
| 350 |
-
}
|
| 351 |
-
|
| 352 |
-
return input;
|
| 353 |
-
}
|
| 354 |
-
};
|
| 355 |
-
|
| 356 |
/***/ },
|
| 357 |
/* 4 */
|
| 358 |
/***/ function(module, exports, __webpack_require__) {
|
|
@@ -360,7 +378,7 @@
|
|
| 360 |
'use strict';
|
| 361 |
|
| 362 |
/**
|
| 363 |
-
* Copyright (C) 2014-
|
| 364 |
*
|
| 365 |
* This program is free software: you can redistribute it and/or modify
|
| 366 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -383,7 +401,7 @@
|
|
| 383 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 384 |
*/
|
| 385 |
|
| 386 |
-
var Util = __webpack_require__(
|
| 387 |
Modal = __webpack_require__(5),
|
| 388 |
$ = jQuery;
|
| 389 |
|
|
@@ -393,6 +411,9 @@
|
|
| 393 |
// Set params
|
| 394 |
this.params = [];
|
| 395 |
|
|
|
|
|
|
|
|
|
|
| 396 |
// Set modal
|
| 397 |
this.modal = new Modal();
|
| 398 |
|
|
@@ -416,17 +437,25 @@
|
|
| 416 |
this.params = Util.list(params);
|
| 417 |
};
|
| 418 |
|
| 419 |
-
Import.prototype.start = function (options) {
|
| 420 |
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
|
| 422 |
// Initializing beforeunload event
|
| 423 |
$(window).bind('beforeunload', function () {
|
| 424 |
return 'You are about to stop importing your website, are you sure?';
|
| 425 |
});
|
| 426 |
|
| 427 |
-
// Set stop
|
| 428 |
-
this.stop = false;
|
| 429 |
-
|
| 430 |
// Set initial status
|
| 431 |
this.setStatus({ type: 'info', message: 'Preparing to import...' });
|
| 432 |
|
|
@@ -439,18 +468,74 @@
|
|
| 439 |
}
|
| 440 |
|
| 441 |
// Import
|
| 442 |
-
$.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
self.getStatus();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
}).fail(function () {
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
});
|
| 450 |
};
|
| 451 |
|
| 452 |
-
Import.prototype.confirm = function (options) {
|
| 453 |
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
|
| 455 |
// Set params
|
| 456 |
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 150 });
|
|
@@ -461,18 +546,43 @@
|
|
| 461 |
}
|
| 462 |
|
| 463 |
// Confirm
|
| 464 |
-
$.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
self.getStatus();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
}).fail(function () {
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
});
|
| 472 |
};
|
| 473 |
|
| 474 |
-
Import.prototype.blogs = function (options) {
|
| 475 |
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
|
| 477 |
// Set params
|
| 478 |
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 150 });
|
|
@@ -483,21 +593,44 @@
|
|
| 483 |
}
|
| 484 |
|
| 485 |
// Blogs
|
| 486 |
-
$.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
self.getStatus();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
}).fail(function () {
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
});
|
| 494 |
};
|
| 495 |
|
| 496 |
-
Import.prototype.clean = function (options) {
|
| 497 |
var self = this;
|
|
|
|
| 498 |
|
| 499 |
-
// Set stop
|
| 500 |
-
this.
|
|
|
|
|
|
|
|
|
|
| 501 |
|
| 502 |
// Set params
|
| 503 |
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 400 });
|
|
@@ -508,14 +641,32 @@
|
|
| 508 |
}
|
| 509 |
|
| 510 |
// Clean
|
| 511 |
-
$.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
// Unbinding the beforeunload event when we stop importing
|
| 513 |
$(window).unbind('beforeunload');
|
|
|
|
|
|
|
|
|
|
| 514 |
}).fail(function () {
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
});
|
| 520 |
};
|
| 521 |
|
|
@@ -523,14 +674,18 @@
|
|
| 523 |
var self = this;
|
| 524 |
|
| 525 |
// Stop getting status
|
| 526 |
-
if (this.
|
| 527 |
return;
|
| 528 |
}
|
| 529 |
|
| 530 |
$.ajax({
|
| 531 |
-
cache: false,
|
| 532 |
url: ai1wm_import.status.url,
|
| 533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
}).done(function (params) {
|
| 535 |
if (params) {
|
| 536 |
self.setStatus(params);
|
|
@@ -550,14 +705,10 @@
|
|
| 550 |
}
|
| 551 |
|
| 552 |
// Import is not done yet, let's check status in 3 seconds
|
| 553 |
-
setTimeout(
|
| 554 |
-
self.getStatus();
|
| 555 |
-
}, 3000);
|
| 556 |
}).fail(function () {
|
| 557 |
// Import is not done yet, let's check status in 3 seconds
|
| 558 |
-
setTimeout(
|
| 559 |
-
self.getStatus();
|
| 560 |
-
}, 3000);
|
| 561 |
});;
|
| 562 |
};
|
| 563 |
|
|
@@ -586,7 +737,7 @@
|
|
| 586 |
'use strict';
|
| 587 |
|
| 588 |
/**
|
| 589 |
-
* Copyright (C) 2014-
|
| 590 |
*
|
| 591 |
* This program is free software: you can redistribute it and/or modify
|
| 592 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -637,9 +788,8 @@
|
|
| 637 |
var title = $('<span></span>').addClass('ai1wm-title-red').text('Unable to import');
|
| 638 |
|
| 639 |
// Create close button
|
| 640 |
-
var closeButton = $('<button class="ai1wm-button-red">Close</button>').on('click', function () {
|
| 641 |
-
self.
|
| 642 |
-
self.overlay.hide();
|
| 643 |
});
|
| 644 |
|
| 645 |
// Append close button
|
|
@@ -662,6 +812,7 @@
|
|
| 662 |
// Progress Modal
|
| 663 |
this.progress = function (params) {
|
| 664 |
if (this.view === 'progress') {
|
|
|
|
| 665 |
// Update progressBarMeter
|
| 666 |
this.progress.progressBarMeter.width(params.percent + '%');
|
| 667 |
|
|
@@ -694,11 +845,9 @@
|
|
| 694 |
this.progress.progressBarPercent = $('<span class="ai1wm-progress-bar-percent">0%</span>').text(params.percent + '%');
|
| 695 |
|
| 696 |
// Create stop import
|
| 697 |
-
var stopButton = $('<button class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').on('click', function () {
|
| 698 |
$(this).attr('disabled', 'disabled');
|
| 699 |
self.onStop();
|
| 700 |
-
self.modal.hide();
|
| 701 |
-
self.overlay.hide();
|
| 702 |
});
|
| 703 |
|
| 704 |
// Append progress meter and progress percent
|
|
@@ -744,7 +893,7 @@
|
|
| 744 |
var warning = $('<span class="ai1wm-icon-notification"></span>');
|
| 745 |
|
| 746 |
// Create confirm button
|
| 747 |
-
var confirmButton = $('<button class="ai1wm-button-green">Continue</button>').on('click', function () {
|
| 748 |
$(this).attr('disabled', 'disabled');
|
| 749 |
self.onConfirm();
|
| 750 |
});
|
|
@@ -788,7 +937,7 @@
|
|
| 788 |
var title = $('<span></span>').addClass('ai1wm-title-grey').text(params.title);
|
| 789 |
|
| 790 |
// Create continue button
|
| 791 |
-
var continueButton = $('<button class="ai1wm-button-green">Continue</button>').on('click', function () {
|
| 792 |
$(this).attr('disabled', 'disabled');
|
| 793 |
self.onBlogs($(this).closest('form').serializeArray());
|
| 794 |
});
|
|
@@ -832,7 +981,7 @@
|
|
| 832 |
var loader = $('<span class="ai1wm-loader"></span>');
|
| 833 |
|
| 834 |
// Create stop import
|
| 835 |
-
var stopButton = $('<button class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').attr('disabled', 'disabled');
|
| 836 |
|
| 837 |
// Append stop button
|
| 838 |
action.append(stopButton);
|
|
@@ -873,9 +1022,8 @@
|
|
| 873 |
var title = $('<span></span>').addClass('ai1wm-title-green').text(params.title);
|
| 874 |
|
| 875 |
// Create close button
|
| 876 |
-
var closeButton = $('<button class="ai1wm-button-red">Close</button>').on('click', function () {
|
| 877 |
-
self.
|
| 878 |
-
self.overlay.hide();
|
| 879 |
});
|
| 880 |
|
| 881 |
// Append close button
|
|
@@ -937,6 +1085,11 @@
|
|
| 937 |
this.view = params.type;
|
| 938 |
};
|
| 939 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 940 |
module.exports = Modal;
|
| 941 |
|
| 942 |
/***/ },
|
|
@@ -948,7 +1101,7 @@
|
|
| 948 |
'use strict';
|
| 949 |
|
| 950 |
/**
|
| 951 |
-
* Copyright (C) 2014-
|
| 952 |
*
|
| 953 |
* This program is free software: you can redistribute it and/or modify
|
| 954 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -971,37 +1124,70 @@
|
|
| 971 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 972 |
*/
|
| 973 |
|
| 974 |
-
var Util = __webpack_require__(
|
| 975 |
Dialog = __webpack_require__(9);
|
| 976 |
|
| 977 |
var Extensions = {
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
};
|
| 984 |
|
| 985 |
window.Ai1wmExportController = function (provider) {
|
| 986 |
-
|
| 987 |
-
|
| 988 |
};
|
| 989 |
|
| 990 |
window.Ai1wmExportController.prototype.start = function () {
|
| 991 |
-
|
| 992 |
};
|
| 993 |
|
| 994 |
window.Ai1wmImportController = function (provider) {
|
| 995 |
-
|
| 996 |
-
|
| 997 |
};
|
| 998 |
|
| 999 |
window.Ai1wmImportController.prototype.init = function () {};
|
| 1000 |
|
| 1001 |
window.Ai1wmImportController.prototype.download = function () {
|
| 1002 |
-
|
| 1003 |
};
|
| 1004 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1005 |
/***/ },
|
| 1006 |
/* 9 */
|
| 1007 |
/***/ function(module, exports) {
|
|
@@ -1009,7 +1195,7 @@
|
|
| 1009 |
'use strict';
|
| 1010 |
|
| 1011 |
/**
|
| 1012 |
-
* Copyright (C) 2014-
|
| 1013 |
*
|
| 1014 |
* This program is free software: you can redistribute it and/or modify
|
| 1015 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -1056,7 +1242,7 @@
|
|
| 1056 |
this.action = $('<div></div>');
|
| 1057 |
|
| 1058 |
// Create close button
|
| 1059 |
-
this.closeButton = $('<button class="ai1wm-button-red">Close</button>').on('click', function () {
|
| 1060 |
self.modal.hide();
|
| 1061 |
self.overlay.hide();
|
| 1062 |
});
|
|
@@ -1088,7 +1274,7 @@
|
|
| 1088 |
/* WEBPACK VAR INJECTION */(function(fetch, global) {'use strict';
|
| 1089 |
|
| 1090 |
/**
|
| 1091 |
-
* Copyright (C) 2014-
|
| 1092 |
*
|
| 1093 |
* This program is free software: you can redistribute it and/or modify
|
| 1094 |
* it under the terms of the GNU General Public License as published by
|
|
@@ -1111,7 +1297,7 @@
|
|
| 1111 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 1112 |
*/
|
| 1113 |
|
| 1114 |
-
var Util = __webpack_require__(
|
| 1115 |
Import = __webpack_require__(4),
|
| 1116 |
$ = jQuery;
|
| 1117 |
|
|
@@ -1120,7 +1306,6 @@
|
|
| 1120 |
FileUploader.prototype.setDefaultValues = function () {
|
| 1121 |
this.model = new Import();
|
| 1122 |
this.stopUpload = false;
|
| 1123 |
-
this.retries = 0;
|
| 1124 |
};
|
| 1125 |
|
| 1126 |
FileUploader.prototype.init = function () {
|
|
@@ -1172,11 +1357,14 @@
|
|
| 1172 |
});
|
| 1173 |
};
|
| 1174 |
|
| 1175 |
-
FileUploader.prototype.upload = function (file) {
|
| 1176 |
var _this2 = this;
|
| 1177 |
|
|
|
|
|
|
|
| 1178 |
var chunkSize = file.size > ai1wm_uploader.chunk_size ? ai1wm_uploader.chunk_size : file.size;
|
| 1179 |
var formData = this.getFormData(file, chunkSize);
|
|
|
|
| 1180 |
fetch(ai1wm_uploader.url, {
|
| 1181 |
method: 'POST',
|
| 1182 |
credentials: 'include',
|
|
@@ -1191,22 +1379,33 @@
|
|
| 1191 |
ai1wm_uploader.chunk_size = chunkSize / 2;
|
| 1192 |
return _this2.upload(file);
|
| 1193 |
case 200:
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1200 |
default:
|
| 1201 |
throw new Error(response.status);
|
| 1202 |
}
|
| 1203 |
}).catch(function (error) {
|
| 1204 |
-
var timeout =
|
| 1205 |
-
if (
|
| 1206 |
return _this2.onError(new Error('We are sorry, there seems to be a problem while uploading your file. Follow <a href="https://www.youtube.com/watch?v=mRp7qTFYKgs" target="_blank">this guide</a> to resolve it.'));
|
| 1207 |
}
|
| 1208 |
-
|
| 1209 |
-
|
|
|
|
|
|
|
| 1210 |
});
|
| 1211 |
};
|
| 1212 |
|
|
@@ -1255,22 +1454,22 @@
|
|
| 1255 |
FileUploader.prototype.onBeforeUpload = function (file) {
|
| 1256 |
var self = this;
|
| 1257 |
|
| 1258 |
-
|
| 1259 |
-
|
| 1260 |
-
|
|
|
|
|
|
|
| 1261 |
|
| 1262 |
// Set multipart params
|
| 1263 |
$.extend(ai1wm_uploader.params, {
|
| 1264 |
-
storage:
|
| 1265 |
-
archive:
|
| 1266 |
});
|
| 1267 |
|
| 1268 |
-
// Set global params
|
| 1269 |
-
self.model.setParams([{ name: 'storage', value: this.storage }, { name: 'archive', value: this.archive }]);
|
| 1270 |
-
|
| 1271 |
// Set stop
|
| 1272 |
this.model.onStop = function () {
|
| 1273 |
self.stopUpload = true;
|
|
|
|
| 1274 |
// Clean storage
|
| 1275 |
self.model.clean();
|
| 1276 |
};
|
|
@@ -1325,6 +1524,28 @@
|
|
| 1325 |
arrayBuffer: 'ArrayBuffer' in self
|
| 1326 |
}
|
| 1327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1328 |
function normalizeName(name) {
|
| 1329 |
if (typeof name !== 'string') {
|
| 1330 |
name = String(name)
|
|
@@ -1457,14 +1678,36 @@
|
|
| 1457 |
|
| 1458 |
function readBlobAsArrayBuffer(blob) {
|
| 1459 |
var reader = new FileReader()
|
|
|
|
| 1460 |
reader.readAsArrayBuffer(blob)
|
| 1461 |
-
return
|
| 1462 |
}
|
| 1463 |
|
| 1464 |
function readBlobAsText(blob) {
|
| 1465 |
var reader = new FileReader()
|
|
|
|
| 1466 |
reader.readAsText(blob)
|
| 1467 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1468 |
}
|
| 1469 |
|
| 1470 |
function Body() {
|
|
@@ -1472,7 +1715,9 @@
|
|
| 1472 |
|
| 1473 |
this._initBody = function(body) {
|
| 1474 |
this._bodyInit = body
|
| 1475 |
-
if (
|
|
|
|
|
|
|
| 1476 |
this._bodyText = body
|
| 1477 |
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
| 1478 |
this._bodyBlob = body
|
|
@@ -1480,11 +1725,12 @@
|
|
| 1480 |
this._bodyFormData = body
|
| 1481 |
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
| 1482 |
this._bodyText = body.toString()
|
| 1483 |
-
} else if (
|
| 1484 |
-
this.
|
| 1485 |
-
|
| 1486 |
-
|
| 1487 |
-
|
|
|
|
| 1488 |
} else {
|
| 1489 |
throw new Error('unsupported BodyInit type')
|
| 1490 |
}
|
|
@@ -1509,6 +1755,8 @@
|
|
| 1509 |
|
| 1510 |
if (this._bodyBlob) {
|
| 1511 |
return Promise.resolve(this._bodyBlob)
|
|
|
|
|
|
|
| 1512 |
} else if (this._bodyFormData) {
|
| 1513 |
throw new Error('could not read FormData body as blob')
|
| 1514 |
} else {
|
|
@@ -1517,27 +1765,28 @@
|
|
| 1517 |
}
|
| 1518 |
|
| 1519 |
this.arrayBuffer = function() {
|
| 1520 |
-
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
this.text = function() {
|
| 1524 |
-
var rejected = consumed(this)
|
| 1525 |
-
if (rejected) {
|
| 1526 |
-
return rejected
|
| 1527 |
-
}
|
| 1528 |
-
|
| 1529 |
-
if (this._bodyBlob) {
|
| 1530 |
-
return readBlobAsText(this._bodyBlob)
|
| 1531 |
-
} else if (this._bodyFormData) {
|
| 1532 |
-
throw new Error('could not read FormData body as text')
|
| 1533 |
} else {
|
| 1534 |
-
return
|
| 1535 |
}
|
| 1536 |
}
|
| 1537 |
-
}
|
| 1538 |
-
|
| 1539 |
-
|
| 1540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1541 |
}
|
| 1542 |
}
|
| 1543 |
|
|
@@ -1565,7 +1814,10 @@
|
|
| 1565 |
function Request(input, options) {
|
| 1566 |
options = options || {}
|
| 1567 |
var body = options.body
|
| 1568 |
-
|
|
|
|
|
|
|
|
|
|
| 1569 |
if (input.bodyUsed) {
|
| 1570 |
throw new TypeError('Already read')
|
| 1571 |
}
|
|
@@ -1576,12 +1828,10 @@
|
|
| 1576 |
}
|
| 1577 |
this.method = input.method
|
| 1578 |
this.mode = input.mode
|
| 1579 |
-
if (!body) {
|
| 1580 |
body = input._bodyInit
|
| 1581 |
input.bodyUsed = true
|
| 1582 |
}
|
| 1583 |
-
} else {
|
| 1584 |
-
this.url = input
|
| 1585 |
}
|
| 1586 |
|
| 1587 |
this.credentials = options.credentials || this.credentials || 'omit'
|
|
@@ -1599,7 +1849,7 @@
|
|
| 1599 |
}
|
| 1600 |
|
| 1601 |
Request.prototype.clone = function() {
|
| 1602 |
-
return new Request(this)
|
| 1603 |
}
|
| 1604 |
|
| 1605 |
function decode(body) {
|
|
@@ -1615,16 +1865,17 @@
|
|
| 1615 |
return form
|
| 1616 |
}
|
| 1617 |
|
| 1618 |
-
function
|
| 1619 |
-
var
|
| 1620 |
-
|
| 1621 |
-
|
| 1622 |
-
var
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
|
|
|
|
| 1626 |
})
|
| 1627 |
-
return
|
| 1628 |
}
|
| 1629 |
|
| 1630 |
Body.call(Request.prototype)
|
|
@@ -1635,10 +1886,10 @@
|
|
| 1635 |
}
|
| 1636 |
|
| 1637 |
this.type = 'default'
|
| 1638 |
-
this.status = options.status
|
| 1639 |
this.ok = this.status >= 200 && this.status < 300
|
| 1640 |
-
this.statusText = options.statusText
|
| 1641 |
-
this.headers =
|
| 1642 |
this.url = options.url || ''
|
| 1643 |
this._initBody(bodyInit)
|
| 1644 |
}
|
|
@@ -1676,35 +1927,16 @@
|
|
| 1676 |
|
| 1677 |
self.fetch = function(input, init) {
|
| 1678 |
return new Promise(function(resolve, reject) {
|
| 1679 |
-
var request
|
| 1680 |
-
if (Request.prototype.isPrototypeOf(input) && !init) {
|
| 1681 |
-
request = input
|
| 1682 |
-
} else {
|
| 1683 |
-
request = new Request(input, init)
|
| 1684 |
-
}
|
| 1685 |
-
|
| 1686 |
var xhr = new XMLHttpRequest()
|
| 1687 |
|
| 1688 |
-
function responseURL() {
|
| 1689 |
-
if ('responseURL' in xhr) {
|
| 1690 |
-
return xhr.responseURL
|
| 1691 |
-
}
|
| 1692 |
-
|
| 1693 |
-
// Avoid security warnings on getResponseHeader when not allowed by CORS
|
| 1694 |
-
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
|
| 1695 |
-
return xhr.getResponseHeader('X-Request-URL')
|
| 1696 |
-
}
|
| 1697 |
-
|
| 1698 |
-
return
|
| 1699 |
-
}
|
| 1700 |
-
|
| 1701 |
xhr.onload = function() {
|
| 1702 |
var options = {
|
| 1703 |
status: xhr.status,
|
| 1704 |
statusText: xhr.statusText,
|
| 1705 |
-
headers:
|
| 1706 |
-
url: responseURL()
|
| 1707 |
}
|
|
|
|
| 1708 |
var body = 'response' in xhr ? xhr.response : xhr.responseText
|
| 1709 |
resolve(new Response(body, options))
|
| 1710 |
}
|
|
@@ -1747,987 +1979,1262 @@
|
|
| 1747 |
/* 14 */
|
| 1748 |
/***/ function(module, exports, __webpack_require__) {
|
| 1749 |
|
| 1750 |
-
var require
|
| 1751 |
(function() {
|
| 1752 |
|
| 1753 |
/*!
|
| 1754 |
* @overview es6-promise - a tiny implementation of Promises/A+.
|
| 1755 |
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
| 1756 |
* @license Licensed under MIT license
|
| 1757 |
-
* See https://raw.githubusercontent.com/
|
| 1758 |
-
* @version 3.
|
| 1759 |
*/
|
| 1760 |
|
| 1761 |
-
(function() {
|
| 1762 |
-
|
| 1763 |
-
function
|
| 1764 |
-
|
| 1765 |
-
|
| 1766 |
|
| 1767 |
-
|
| 1768 |
-
|
| 1769 |
-
|
| 1770 |
|
| 1771 |
-
|
| 1772 |
-
|
| 1773 |
-
|
| 1774 |
|
| 1775 |
-
|
| 1776 |
-
|
| 1777 |
-
|
| 1778 |
-
|
| 1779 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1780 |
} else {
|
| 1781 |
-
|
| 1782 |
}
|
|
|
|
|
|
|
| 1783 |
|
| 1784 |
-
|
| 1785 |
-
|
| 1786 |
-
|
| 1787 |
-
var lib$es6$promise$asap$$customSchedulerFn;
|
| 1788 |
-
|
| 1789 |
-
var lib$es6$promise$asap$$asap = function asap(callback, arg) {
|
| 1790 |
-
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
|
| 1791 |
-
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
|
| 1792 |
-
lib$es6$promise$asap$$len += 2;
|
| 1793 |
-
if (lib$es6$promise$asap$$len === 2) {
|
| 1794 |
-
// If len is 2, that means that we need to schedule an async flush.
|
| 1795 |
-
// If additional callbacks are queued before the queue is flushed, they
|
| 1796 |
-
// will be processed by this flush that we are scheduling.
|
| 1797 |
-
if (lib$es6$promise$asap$$customSchedulerFn) {
|
| 1798 |
-
lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
|
| 1799 |
-
} else {
|
| 1800 |
-
lib$es6$promise$asap$$scheduleFlush();
|
| 1801 |
-
}
|
| 1802 |
-
}
|
| 1803 |
-
}
|
| 1804 |
|
| 1805 |
-
|
| 1806 |
-
|
| 1807 |
-
|
| 1808 |
|
| 1809 |
-
|
| 1810 |
-
|
| 1811 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1812 |
|
| 1813 |
-
|
| 1814 |
-
|
| 1815 |
-
|
| 1816 |
-
|
| 1817 |
-
|
| 1818 |
-
|
| 1819 |
-
var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
|
| 1820 |
-
typeof importScripts !== 'undefined' &&
|
| 1821 |
-
typeof MessageChannel !== 'undefined';
|
| 1822 |
-
|
| 1823 |
-
// node
|
| 1824 |
-
function lib$es6$promise$asap$$useNextTick() {
|
| 1825 |
-
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
|
| 1826 |
-
// see https://github.com/cujojs/when/issues/410 for details
|
| 1827 |
-
return function() {
|
| 1828 |
-
process.nextTick(lib$es6$promise$asap$$flush);
|
| 1829 |
-
};
|
| 1830 |
-
}
|
| 1831 |
|
| 1832 |
-
|
| 1833 |
-
|
| 1834 |
-
|
| 1835 |
-
|
| 1836 |
-
|
| 1837 |
-
}
|
| 1838 |
|
| 1839 |
-
|
| 1840 |
-
|
| 1841 |
-
|
| 1842 |
-
|
| 1843 |
-
observer.observe(node, { characterData: true });
|
| 1844 |
|
| 1845 |
-
|
| 1846 |
-
|
| 1847 |
-
|
| 1848 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1849 |
|
| 1850 |
-
|
| 1851 |
-
|
| 1852 |
-
|
| 1853 |
-
|
| 1854 |
-
|
| 1855 |
-
|
| 1856 |
-
|
| 1857 |
-
|
| 1858 |
|
| 1859 |
-
|
| 1860 |
-
|
| 1861 |
-
|
| 1862 |
-
|
| 1863 |
-
|
| 1864 |
|
| 1865 |
-
|
| 1866 |
-
function lib$es6$promise$asap$$flush() {
|
| 1867 |
-
for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) {
|
| 1868 |
-
var callback = lib$es6$promise$asap$$queue[i];
|
| 1869 |
-
var arg = lib$es6$promise$asap$$queue[i+1];
|
| 1870 |
|
| 1871 |
-
|
|
|
|
|
|
|
| 1872 |
|
| 1873 |
-
|
| 1874 |
-
|
| 1875 |
-
}
|
| 1876 |
|
| 1877 |
-
|
| 1878 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1879 |
|
| 1880 |
-
|
| 1881 |
-
|
| 1882 |
-
|
| 1883 |
-
|
| 1884 |
-
|
| 1885 |
-
|
| 1886 |
-
|
| 1887 |
-
|
| 1888 |
-
|
| 1889 |
-
|
|
|
|
|
|
|
|
|
|
| 1890 |
|
| 1891 |
-
|
| 1892 |
-
|
| 1893 |
-
if (lib$es6$promise$asap$$isNode) {
|
| 1894 |
-
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
|
| 1895 |
-
} else if (lib$es6$promise$asap$$BrowserMutationObserver) {
|
| 1896 |
-
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
|
| 1897 |
-
} else if (lib$es6$promise$asap$$isWorker) {
|
| 1898 |
-
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
|
| 1899 |
-
} else if (lib$es6$promise$asap$$browserWindow === undefined && "function" === 'function') {
|
| 1900 |
-
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx();
|
| 1901 |
-
} else {
|
| 1902 |
-
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
|
| 1903 |
-
}
|
| 1904 |
-
function lib$es6$promise$then$$then(onFulfillment, onRejection) {
|
| 1905 |
-
var parent = this;
|
| 1906 |
|
| 1907 |
-
|
| 1908 |
|
| 1909 |
-
|
| 1910 |
-
lib$es6$promise$$internal$$makePromise(child);
|
| 1911 |
-
}
|
| 1912 |
|
| 1913 |
-
|
|
|
|
|
|
|
| 1914 |
|
| 1915 |
-
|
| 1916 |
-
var callback = arguments[state - 1];
|
| 1917 |
-
lib$es6$promise$asap$$asap(function(){
|
| 1918 |
-
lib$es6$promise$$internal$$invokeCallback(state, child, callback, parent._result);
|
| 1919 |
-
});
|
| 1920 |
-
} else {
|
| 1921 |
-
lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
|
| 1922 |
-
}
|
| 1923 |
|
| 1924 |
-
|
| 1925 |
-
|
| 1926 |
-
|
| 1927 |
-
|
| 1928 |
-
|
| 1929 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1930 |
|
| 1931 |
-
|
| 1932 |
-
|
| 1933 |
-
}
|
| 1934 |
|
| 1935 |
-
|
| 1936 |
-
|
| 1937 |
-
|
| 1938 |
-
}
|
| 1939 |
-
var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
|
| 1940 |
-
var lib$es6$promise$$internal$$PROMISE_ID = Math.random().toString(36).substring(16);
|
| 1941 |
|
| 1942 |
-
|
|
|
|
|
|
|
|
|
|
| 1943 |
|
| 1944 |
-
|
| 1945 |
-
|
| 1946 |
-
|
|
|
|
| 1947 |
|
| 1948 |
-
|
| 1949 |
|
| 1950 |
-
|
| 1951 |
-
|
| 1952 |
-
}
|
| 1953 |
|
| 1954 |
-
|
| 1955 |
-
|
| 1956 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1957 |
|
| 1958 |
-
|
| 1959 |
-
|
| 1960 |
-
|
| 1961 |
-
|
| 1962 |
-
lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
|
| 1963 |
-
return lib$es6$promise$$internal$$GET_THEN_ERROR;
|
| 1964 |
-
}
|
| 1965 |
-
}
|
| 1966 |
|
| 1967 |
-
|
| 1968 |
-
try {
|
| 1969 |
-
then.call(value, fulfillmentHandler, rejectionHandler);
|
| 1970 |
-
} catch(e) {
|
| 1971 |
-
return e;
|
| 1972 |
-
}
|
| 1973 |
-
}
|
| 1974 |
|
| 1975 |
-
|
| 1976 |
-
lib$es6$promise$asap$$asap(function(promise) {
|
| 1977 |
-
var sealed = false;
|
| 1978 |
-
var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
|
| 1979 |
-
if (sealed) { return; }
|
| 1980 |
-
sealed = true;
|
| 1981 |
-
if (thenable !== value) {
|
| 1982 |
-
lib$es6$promise$$internal$$resolve(promise, value);
|
| 1983 |
-
} else {
|
| 1984 |
-
lib$es6$promise$$internal$$fulfill(promise, value);
|
| 1985 |
-
}
|
| 1986 |
-
}, function(reason) {
|
| 1987 |
-
if (sealed) { return; }
|
| 1988 |
-
sealed = true;
|
| 1989 |
|
| 1990 |
-
|
| 1991 |
-
|
|
|
|
| 1992 |
|
| 1993 |
-
|
| 1994 |
-
sealed = true;
|
| 1995 |
-
lib$es6$promise$$internal$$reject(promise, error);
|
| 1996 |
-
}
|
| 1997 |
-
}, promise);
|
| 1998 |
-
}
|
| 1999 |
|
| 2000 |
-
|
| 2001 |
-
|
| 2002 |
-
|
| 2003 |
-
} else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
|
| 2004 |
-
lib$es6$promise$$internal$$reject(promise, thenable._result);
|
| 2005 |
-
} else {
|
| 2006 |
-
lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
|
| 2007 |
-
lib$es6$promise$$internal$$resolve(promise, value);
|
| 2008 |
-
}, function(reason) {
|
| 2009 |
-
lib$es6$promise$$internal$$reject(promise, reason);
|
| 2010 |
-
});
|
| 2011 |
-
}
|
| 2012 |
-
}
|
| 2013 |
|
| 2014 |
-
|
| 2015 |
-
|
| 2016 |
-
|
| 2017 |
-
|
| 2018 |
-
|
| 2019 |
-
|
| 2020 |
-
|
| 2021 |
-
|
| 2022 |
-
|
| 2023 |
-
|
| 2024 |
-
|
| 2025 |
-
|
| 2026 |
-
|
| 2027 |
-
|
| 2028 |
-
|
| 2029 |
-
|
| 2030 |
-
|
|
|
|
|
|
|
|
|
|
| 2031 |
|
| 2032 |
-
|
| 2033 |
-
|
| 2034 |
-
|
| 2035 |
-
|
| 2036 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2037 |
} else {
|
| 2038 |
-
|
| 2039 |
}
|
| 2040 |
-
}
|
| 2041 |
-
|
| 2042 |
-
|
| 2043 |
-
if (promise._onerror) {
|
| 2044 |
-
promise._onerror(promise._result);
|
| 2045 |
}
|
|
|
|
| 2046 |
|
| 2047 |
-
|
| 2048 |
-
}
|
| 2049 |
|
| 2050 |
-
|
| 2051 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2052 |
|
| 2053 |
-
|
| 2054 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2055 |
|
| 2056 |
-
|
| 2057 |
-
|
| 2058 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2059 |
}
|
|
|
|
|
|
|
| 2060 |
|
| 2061 |
-
|
| 2062 |
-
|
| 2063 |
-
|
| 2064 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2065 |
|
| 2066 |
-
|
| 2067 |
-
|
|
|
|
|
|
|
| 2068 |
|
| 2069 |
-
|
| 2070 |
-
|
| 2071 |
-
var length = subscribers.length;
|
| 2072 |
|
| 2073 |
-
|
|
|
|
|
|
|
|
|
|
| 2074 |
|
| 2075 |
-
|
| 2076 |
-
|
| 2077 |
-
subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
|
| 2078 |
|
| 2079 |
-
|
| 2080 |
-
|
| 2081 |
-
|
| 2082 |
-
|
| 2083 |
|
| 2084 |
-
|
| 2085 |
-
|
| 2086 |
-
|
|
|
|
|
|
|
|
|
|
| 2087 |
|
| 2088 |
-
|
|
|
|
| 2089 |
|
| 2090 |
-
|
|
|
|
|
|
|
| 2091 |
|
| 2092 |
-
|
| 2093 |
-
child = subscribers[i];
|
| 2094 |
-
callback = subscribers[i + settled];
|
| 2095 |
|
| 2096 |
-
|
| 2097 |
-
|
| 2098 |
-
|
| 2099 |
-
callback(detail);
|
| 2100 |
-
}
|
| 2101 |
-
}
|
| 2102 |
|
| 2103 |
-
|
| 2104 |
-
|
|
|
|
|
|
|
| 2105 |
|
| 2106 |
-
|
| 2107 |
-
|
| 2108 |
-
|
| 2109 |
|
| 2110 |
-
|
|
|
|
|
|
|
| 2111 |
|
| 2112 |
-
|
| 2113 |
-
|
| 2114 |
-
|
| 2115 |
-
|
| 2116 |
-
|
| 2117 |
-
|
| 2118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2119 |
}
|
|
|
|
| 2120 |
|
| 2121 |
-
|
| 2122 |
-
|
| 2123 |
-
value, error, succeeded, failed;
|
| 2124 |
|
| 2125 |
-
|
| 2126 |
-
|
|
|
|
| 2127 |
|
| 2128 |
-
|
| 2129 |
-
failed = true;
|
| 2130 |
-
error = value.error;
|
| 2131 |
-
value = null;
|
| 2132 |
-
} else {
|
| 2133 |
-
succeeded = true;
|
| 2134 |
-
}
|
| 2135 |
|
| 2136 |
-
|
| 2137 |
-
|
| 2138 |
-
|
| 2139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2140 |
|
| 2141 |
-
|
| 2142 |
-
|
| 2143 |
-
|
| 2144 |
-
|
|
|
|
|
|
|
| 2145 |
|
| 2146 |
-
|
| 2147 |
-
|
| 2148 |
-
} else if (hasCallback && succeeded) {
|
| 2149 |
-
lib$es6$promise$$internal$$resolve(promise, value);
|
| 2150 |
-
} else if (failed) {
|
| 2151 |
-
lib$es6$promise$$internal$$reject(promise, error);
|
| 2152 |
-
} else if (settled === lib$es6$promise$$internal$$FULFILLED) {
|
| 2153 |
-
lib$es6$promise$$internal$$fulfill(promise, value);
|
| 2154 |
-
} else if (settled === lib$es6$promise$$internal$$REJECTED) {
|
| 2155 |
-
lib$es6$promise$$internal$$reject(promise, value);
|
| 2156 |
-
}
|
| 2157 |
-
}
|
| 2158 |
|
| 2159 |
-
|
| 2160 |
-
|
| 2161 |
-
|
| 2162 |
-
|
| 2163 |
-
|
| 2164 |
-
|
| 2165 |
-
});
|
| 2166 |
-
} catch(e) {
|
| 2167 |
-
lib$es6$promise$$internal$$reject(promise, e);
|
| 2168 |
-
}
|
| 2169 |
}
|
| 2170 |
|
| 2171 |
-
|
| 2172 |
-
|
| 2173 |
-
return
|
| 2174 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2175 |
|
| 2176 |
-
|
| 2177 |
-
|
| 2178 |
-
|
| 2179 |
-
promise
|
| 2180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2181 |
}
|
|
|
|
| 2182 |
|
| 2183 |
-
|
| 2184 |
-
|
| 2185 |
-
|
| 2186 |
-
|
| 2187 |
-
function
|
| 2188 |
-
|
| 2189 |
-
|
| 2190 |
-
|
| 2191 |
-
|
| 2192 |
-
|
| 2193 |
-
|
| 2194 |
-
});
|
| 2195 |
-
} else {
|
| 2196 |
-
return new Constructor(function(resolve, reject) {
|
| 2197 |
-
var length = entries.length;
|
| 2198 |
-
for (var i = 0; i < length; i++) {
|
| 2199 |
-
Constructor.resolve(entries[i]).then(resolve, reject);
|
| 2200 |
-
}
|
| 2201 |
-
});
|
| 2202 |
-
}
|
| 2203 |
-
}
|
| 2204 |
-
var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
|
| 2205 |
-
function lib$es6$promise$promise$reject$$reject(reason) {
|
| 2206 |
-
/*jshint validthis:true */
|
| 2207 |
-
var Constructor = this;
|
| 2208 |
-
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
| 2209 |
-
lib$es6$promise$$internal$$reject(promise, reason);
|
| 2210 |
-
return promise;
|
| 2211 |
-
}
|
| 2212 |
-
var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
|
| 2213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2214 |
|
| 2215 |
-
|
| 2216 |
-
|
| 2217 |
-
|
|
|
|
|
|
|
|
|
|
| 2218 |
|
| 2219 |
-
|
| 2220 |
-
|
| 2221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2222 |
|
| 2223 |
-
|
| 2224 |
-
|
| 2225 |
-
|
| 2226 |
-
|
| 2227 |
-
registers callbacks to receive either a promise's eventual value or the reason
|
| 2228 |
-
why the promise cannot be fulfilled.
|
| 2229 |
|
| 2230 |
-
|
| 2231 |
-
-----------
|
| 2232 |
|
| 2233 |
-
|
| 2234 |
-
|
| 2235 |
-
|
| 2236 |
-
|
| 2237 |
-
|
| 2238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2239 |
|
| 2240 |
-
|
|
|
|
|
|
|
| 2241 |
|
| 2242 |
-
|
| 2243 |
-
|
| 2244 |
-
|
| 2245 |
|
| 2246 |
-
|
| 2247 |
-
|
| 2248 |
-
|
| 2249 |
-
|
| 2250 |
-
itself fulfill.
|
| 2251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2252 |
|
| 2253 |
-
|
| 2254 |
-
|
| 2255 |
|
| 2256 |
-
|
| 2257 |
-
|
| 2258 |
-
// on success
|
| 2259 |
-
resolve(value);
|
| 2260 |
|
| 2261 |
-
|
| 2262 |
-
|
| 2263 |
-
|
|
|
|
|
|
|
|
|
|
| 2264 |
|
| 2265 |
-
|
| 2266 |
-
|
| 2267 |
-
|
| 2268 |
-
|
| 2269 |
-
});
|
| 2270 |
-
```
|
| 2271 |
-
|
| 2272 |
-
Advanced Usage:
|
| 2273 |
-
---------------
|
| 2274 |
-
|
| 2275 |
-
Promises shine when abstracting away asynchronous interactions such as
|
| 2276 |
-
`XMLHttpRequest`s.
|
| 2277 |
-
|
| 2278 |
-
```js
|
| 2279 |
-
function getJSON(url) {
|
| 2280 |
-
return new Promise(function(resolve, reject){
|
| 2281 |
-
var xhr = new XMLHttpRequest();
|
| 2282 |
-
|
| 2283 |
-
xhr.open('GET', url);
|
| 2284 |
-
xhr.onreadystatechange = handler;
|
| 2285 |
-
xhr.responseType = 'json';
|
| 2286 |
-
xhr.setRequestHeader('Accept', 'application/json');
|
| 2287 |
-
xhr.send();
|
| 2288 |
-
|
| 2289 |
-
function handler() {
|
| 2290 |
-
if (this.readyState === this.DONE) {
|
| 2291 |
-
if (this.status === 200) {
|
| 2292 |
-
resolve(this.response);
|
| 2293 |
-
} else {
|
| 2294 |
-
reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
|
| 2295 |
-
}
|
| 2296 |
-
}
|
| 2297 |
-
};
|
| 2298 |
-
});
|
| 2299 |
-
}
|
| 2300 |
|
| 2301 |
-
|
| 2302 |
-
|
| 2303 |
-
}, function(reason) {
|
| 2304 |
-
// on rejection
|
| 2305 |
-
});
|
| 2306 |
-
```
|
| 2307 |
|
| 2308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2309 |
|
| 2310 |
-
|
| 2311 |
-
|
| 2312 |
-
|
| 2313 |
-
|
| 2314 |
-
|
| 2315 |
-
values[0] // => postsJSON
|
| 2316 |
-
values[1] // => commentsJSON
|
| 2317 |
|
| 2318 |
-
|
| 2319 |
-
});
|
| 2320 |
-
```
|
| 2321 |
-
|
| 2322 |
-
@class Promise
|
| 2323 |
-
@param {function} resolver
|
| 2324 |
-
Useful for tooling.
|
| 2325 |
-
@constructor
|
| 2326 |
-
*/
|
| 2327 |
-
function lib$es6$promise$promise$$Promise(resolver) {
|
| 2328 |
-
this[lib$es6$promise$$internal$$PROMISE_ID] = lib$es6$promise$$internal$$nextId();
|
| 2329 |
-
this._result = this._state = undefined;
|
| 2330 |
-
this._subscribers = [];
|
| 2331 |
-
|
| 2332 |
-
if (lib$es6$promise$$internal$$noop !== resolver) {
|
| 2333 |
-
typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver();
|
| 2334 |
-
this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew();
|
| 2335 |
-
}
|
| 2336 |
-
}
|
| 2337 |
|
| 2338 |
-
|
| 2339 |
-
|
| 2340 |
-
|
| 2341 |
-
|
| 2342 |
-
|
| 2343 |
-
lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
|
| 2344 |
-
lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
|
| 2345 |
-
|
| 2346 |
-
lib$es6$promise$promise$$Promise.prototype = {
|
| 2347 |
-
constructor: lib$es6$promise$promise$$Promise,
|
| 2348 |
-
|
| 2349 |
-
/**
|
| 2350 |
-
The primary way of interacting with a promise is through its `then` method,
|
| 2351 |
-
which registers callbacks to receive either a promise's eventual value or the
|
| 2352 |
-
reason why the promise cannot be fulfilled.
|
| 2353 |
-
|
| 2354 |
-
```js
|
| 2355 |
-
findUser().then(function(user){
|
| 2356 |
-
// user is available
|
| 2357 |
-
}, function(reason){
|
| 2358 |
-
// user is unavailable, and you are given the reason why
|
| 2359 |
-
});
|
| 2360 |
-
```
|
| 2361 |
-
|
| 2362 |
-
Chaining
|
| 2363 |
-
--------
|
| 2364 |
-
|
| 2365 |
-
The return value of `then` is itself a promise. This second, 'downstream'
|
| 2366 |
-
promise is resolved with the return value of the first promise's fulfillment
|
| 2367 |
-
or rejection handler, or rejected if the handler throws an exception.
|
| 2368 |
-
|
| 2369 |
-
```js
|
| 2370 |
-
findUser().then(function (user) {
|
| 2371 |
-
return user.name;
|
| 2372 |
-
}, function (reason) {
|
| 2373 |
-
return 'default name';
|
| 2374 |
-
}).then(function (userName) {
|
| 2375 |
-
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it
|
| 2376 |
-
// will be `'default name'`
|
| 2377 |
-
});
|
| 2378 |
|
| 2379 |
-
|
| 2380 |
-
|
| 2381 |
-
|
| 2382 |
-
|
| 2383 |
-
}).then(function (value) {
|
| 2384 |
-
// never reached
|
| 2385 |
-
}, function (reason) {
|
| 2386 |
-
// if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
|
| 2387 |
-
// If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
|
| 2388 |
-
});
|
| 2389 |
-
```
|
| 2390 |
-
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
|
| 2391 |
-
|
| 2392 |
-
```js
|
| 2393 |
-
findUser().then(function (user) {
|
| 2394 |
-
throw new PedagogicalException('Upstream error');
|
| 2395 |
-
}).then(function (value) {
|
| 2396 |
-
// never reached
|
| 2397 |
-
}).then(function (value) {
|
| 2398 |
-
// never reached
|
| 2399 |
-
}, function (reason) {
|
| 2400 |
-
// The `PedgagocialException` is propagated all the way down to here
|
| 2401 |
-
});
|
| 2402 |
-
```
|
| 2403 |
|
| 2404 |
-
|
| 2405 |
-
|
|
|
|
| 2406 |
|
| 2407 |
-
|
| 2408 |
-
retrieved asynchronously. This can be achieved by returning a promise in the
|
| 2409 |
-
fulfillment or rejection handler. The downstream promise will then be pending
|
| 2410 |
-
until the returned promise is settled. This is called *assimilation*.
|
| 2411 |
|
| 2412 |
-
|
| 2413 |
-
|
| 2414 |
-
|
| 2415 |
-
|
| 2416 |
-
|
| 2417 |
-
});
|
| 2418 |
-
```
|
| 2419 |
|
| 2420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2421 |
|
| 2422 |
-
|
| 2423 |
-
|
| 2424 |
-
|
| 2425 |
-
|
| 2426 |
-
|
| 2427 |
-
}, function (reason) {
|
| 2428 |
-
// If `findCommentsByAuthor` rejects, we'll have the reason here
|
| 2429 |
-
});
|
| 2430 |
-
```
|
| 2431 |
|
| 2432 |
-
|
| 2433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2434 |
|
| 2435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2436 |
|
| 2437 |
-
|
| 2438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2439 |
|
| 2440 |
-
|
| 2441 |
-
|
| 2442 |
-
|
| 2443 |
-
|
| 2444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2445 |
}
|
| 2446 |
-
|
|
|
|
|
|
|
| 2447 |
|
| 2448 |
-
|
|
|
|
|
|
|
| 2449 |
|
| 2450 |
-
|
| 2451 |
-
|
| 2452 |
-
|
| 2453 |
-
|
| 2454 |
-
} else {
|
| 2455 |
-
// success
|
| 2456 |
-
}
|
| 2457 |
-
});
|
| 2458 |
-
```
|
| 2459 |
|
| 2460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2461 |
|
| 2462 |
-
|
| 2463 |
-
findResult().then(function(result){
|
| 2464 |
-
// success
|
| 2465 |
-
}, function(reason){
|
| 2466 |
-
// failure
|
| 2467 |
-
});
|
| 2468 |
-
```
|
| 2469 |
|
| 2470 |
-
|
| 2471 |
-
|
| 2472 |
|
| 2473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2474 |
|
| 2475 |
-
|
| 2476 |
-
|
|
|
|
| 2477 |
|
| 2478 |
-
|
| 2479 |
-
|
| 2480 |
-
|
| 2481 |
-
// success
|
| 2482 |
-
} catch(reason) {
|
| 2483 |
-
// failure
|
| 2484 |
-
}
|
| 2485 |
-
```
|
| 2486 |
|
| 2487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2488 |
|
| 2489 |
-
|
|
|
|
| 2490 |
|
| 2491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2492 |
|
| 2493 |
-
|
| 2494 |
|
| 2495 |
-
|
|
|
|
|
|
|
| 2496 |
|
| 2497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2498 |
|
| 2499 |
-
findAuthor(function(author, err){
|
| 2500 |
-
if (err) {
|
| 2501 |
-
failure(err);
|
| 2502 |
-
// failure
|
| 2503 |
-
} else {
|
| 2504 |
-
try {
|
| 2505 |
-
findBoooksByAuthor(author, function(books, err) {
|
| 2506 |
-
if (err) {
|
| 2507 |
-
failure(err);
|
| 2508 |
-
} else {
|
| 2509 |
-
try {
|
| 2510 |
-
foundBooks(books);
|
| 2511 |
-
} catch(reason) {
|
| 2512 |
-
failure(reason);
|
| 2513 |
-
}
|
| 2514 |
-
}
|
| 2515 |
-
});
|
| 2516 |
-
} catch(error) {
|
| 2517 |
-
failure(err);
|
| 2518 |
-
}
|
| 2519 |
-
// success
|
| 2520 |
-
}
|
| 2521 |
-
});
|
| 2522 |
-
```
|
| 2523 |
|
| 2524 |
-
|
|
|
|
| 2525 |
|
| 2526 |
-
|
| 2527 |
-
|
| 2528 |
-
|
| 2529 |
-
|
| 2530 |
-
// found books
|
| 2531 |
-
}).catch(function(reason){
|
| 2532 |
-
// something went wrong
|
| 2533 |
-
});
|
| 2534 |
-
```
|
| 2535 |
-
|
| 2536 |
-
@method then
|
| 2537 |
-
@param {Function} onFulfilled
|
| 2538 |
-
@param {Function} onRejected
|
| 2539 |
-
Useful for tooling.
|
| 2540 |
-
@return {Promise}
|
| 2541 |
-
*/
|
| 2542 |
-
then: lib$es6$promise$then$$default,
|
| 2543 |
-
|
| 2544 |
-
/**
|
| 2545 |
-
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
|
| 2546 |
-
as the catch block of a try/catch statement.
|
| 2547 |
-
|
| 2548 |
-
```js
|
| 2549 |
-
function findAuthor(){
|
| 2550 |
-
throw new Error('couldn't find that author');
|
| 2551 |
-
}
|
| 2552 |
|
| 2553 |
-
|
| 2554 |
-
|
| 2555 |
-
|
| 2556 |
-
} catch(reason) {
|
| 2557 |
-
// something went wrong
|
| 2558 |
-
}
|
| 2559 |
|
| 2560 |
-
|
| 2561 |
-
|
| 2562 |
-
|
| 2563 |
-
|
| 2564 |
-
|
| 2565 |
-
|
| 2566 |
-
@method catch
|
| 2567 |
-
@param {Function} onRejection
|
| 2568 |
-
Useful for tooling.
|
| 2569 |
-
@return {Promise}
|
| 2570 |
-
*/
|
| 2571 |
-
'catch': function(onRejection) {
|
| 2572 |
-
return this.then(null, onRejection);
|
| 2573 |
-
}
|
| 2574 |
-
};
|
| 2575 |
-
var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
|
| 2576 |
-
function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
|
| 2577 |
-
this._instanceConstructor = Constructor;
|
| 2578 |
-
this.promise = new Constructor(lib$es6$promise$$internal$$noop);
|
| 2579 |
-
|
| 2580 |
-
if (!this.promise[lib$es6$promise$$internal$$PROMISE_ID]) {
|
| 2581 |
-
lib$es6$promise$$internal$$makePromise(this.promise);
|
| 2582 |
-
}
|
| 2583 |
|
| 2584 |
-
|
| 2585 |
-
|
| 2586 |
-
this.length = input.length;
|
| 2587 |
-
this._remaining = input.length;
|
| 2588 |
|
| 2589 |
-
|
|
|
|
| 2590 |
|
| 2591 |
-
|
| 2592 |
-
|
| 2593 |
-
|
| 2594 |
-
|
| 2595 |
-
|
| 2596 |
-
|
| 2597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2598 |
}
|
| 2599 |
}
|
| 2600 |
-
}
|
| 2601 |
-
|
| 2602 |
-
|
| 2603 |
-
}
|
| 2604 |
-
|
| 2605 |
-
function lib$es6$promise$enumerator$$validationError() {
|
| 2606 |
-
return new Error('Array Methods must be provided an Array');
|
| 2607 |
-
}
|
| 2608 |
|
| 2609 |
-
|
| 2610 |
-
|
| 2611 |
-
|
|
|
|
|
|
|
|
|
|
| 2612 |
|
| 2613 |
-
|
| 2614 |
-
this._eachEntry(input[i], i);
|
| 2615 |
-
}
|
| 2616 |
-
};
|
| 2617 |
-
|
| 2618 |
-
lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
|
| 2619 |
-
var c = this._instanceConstructor;
|
| 2620 |
-
var resolve = c.resolve;
|
| 2621 |
-
|
| 2622 |
-
if (resolve === lib$es6$promise$promise$resolve$$default) {
|
| 2623 |
-
var then = lib$es6$promise$$internal$$getThen(entry);
|
| 2624 |
-
|
| 2625 |
-
if (then === lib$es6$promise$then$$default &&
|
| 2626 |
-
entry._state !== lib$es6$promise$$internal$$PENDING) {
|
| 2627 |
-
this._settledAt(entry._state, i, entry._result);
|
| 2628 |
-
} else if (typeof then !== 'function') {
|
| 2629 |
-
this._remaining--;
|
| 2630 |
-
this._result[i] = entry;
|
| 2631 |
-
} else if (c === lib$es6$promise$promise$$default) {
|
| 2632 |
-
var promise = new c(lib$es6$promise$$internal$$noop);
|
| 2633 |
-
lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then);
|
| 2634 |
-
this._willSettleAt(promise, i);
|
| 2635 |
-
} else {
|
| 2636 |
-
this._willSettleAt(new c(function(resolve) { resolve(entry); }), i);
|
| 2637 |
-
}
|
| 2638 |
-
} else {
|
| 2639 |
-
this._willSettleAt(resolve(entry), i);
|
| 2640 |
-
}
|
| 2641 |
-
};
|
| 2642 |
|
| 2643 |
-
|
| 2644 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2645 |
|
| 2646 |
-
|
| 2647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2648 |
|
| 2649 |
-
|
| 2650 |
-
|
| 2651 |
-
|
| 2652 |
-
|
| 2653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2654 |
}
|
| 2655 |
-
|
| 2656 |
-
|
| 2657 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2658 |
}
|
| 2659 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2660 |
|
| 2661 |
-
|
| 2662 |
-
|
| 2663 |
|
| 2664 |
-
|
| 2665 |
-
|
| 2666 |
-
|
| 2667 |
-
|
| 2668 |
-
|
| 2669 |
-
|
| 2670 |
-
|
| 2671 |
-
|
| 2672 |
-
|
| 2673 |
-
|
| 2674 |
-
|
| 2675 |
-
} else if (typeof self !== 'undefined') {
|
| 2676 |
-
local = self;
|
| 2677 |
-
} else {
|
| 2678 |
-
try {
|
| 2679 |
-
local = Function('return this')();
|
| 2680 |
-
} catch (e) {
|
| 2681 |
-
throw new Error('polyfill failed because global object is unavailable in this environment');
|
| 2682 |
-
}
|
| 2683 |
-
}
|
| 2684 |
|
| 2685 |
-
|
| 2686 |
|
| 2687 |
-
|
| 2688 |
-
|
| 2689 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2690 |
|
| 2691 |
-
|
| 2692 |
-
|
| 2693 |
-
|
| 2694 |
-
|
| 2695 |
-
var lib$es6$promise$umd$$ES6Promise = {
|
| 2696 |
-
'Promise': lib$es6$promise$promise$$default,
|
| 2697 |
-
'polyfill': lib$es6$promise$polyfill$$default
|
| 2698 |
-
};
|
| 2699 |
-
|
| 2700 |
-
/* global define:true module:true window: true */
|
| 2701 |
-
if ("function" === 'function' && __webpack_require__(18)['amd']) {
|
| 2702 |
-
!(__WEBPACK_AMD_DEFINE_RESULT__ = function() { return lib$es6$promise$umd$$ES6Promise; }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
| 2703 |
-
} else if (typeof module !== 'undefined' && module['exports']) {
|
| 2704 |
-
module['exports'] = lib$es6$promise$umd$$ES6Promise;
|
| 2705 |
-
} else if (typeof this !== 'undefined') {
|
| 2706 |
-
this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
|
| 2707 |
}
|
| 2708 |
|
| 2709 |
-
|
| 2710 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2711 |
|
|
|
|
| 2712 |
|
|
|
|
|
|
|
| 2713 |
|
| 2714 |
/*** EXPORTS FROM exports-loader ***/
|
| 2715 |
module.exports = global.Promise;
|
| 2716 |
}.call(global));
|
| 2717 |
-
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15), (function() { return this; }())
|
| 2718 |
|
| 2719 |
/***/ },
|
| 2720 |
/* 15 */
|
| 2721 |
/***/ function(module, exports) {
|
| 2722 |
|
| 2723 |
// shim for using process in browser
|
| 2724 |
-
|
| 2725 |
var process = module.exports = {};
|
| 2726 |
|
| 2727 |
-
// cached from whatever global is present so that test runners that stub it
|
| 2728 |
-
|
| 2729 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2730 |
|
|
|
|
|
|
|
| 2731 |
var queue = [];
|
| 2732 |
var draining = false;
|
| 2733 |
var currentQueue;
|
|
@@ -2752,7 +3259,7 @@
|
|
| 2752 |
if (draining) {
|
| 2753 |
return;
|
| 2754 |
}
|
| 2755 |
-
var timeout =
|
| 2756 |
draining = true;
|
| 2757 |
|
| 2758 |
var len = queue.length;
|
|
@@ -2769,7 +3276,7 @@
|
|
| 2769 |
}
|
| 2770 |
currentQueue = null;
|
| 2771 |
draining = false;
|
| 2772 |
-
|
| 2773 |
}
|
| 2774 |
|
| 2775 |
process.nextTick = function (fun) {
|
|
@@ -2781,7 +3288,7 @@
|
|
| 2781 |
}
|
| 2782 |
queue.push(new Item(fun, args));
|
| 2783 |
if (queue.length === 1 && !draining) {
|
| 2784 |
-
|
| 2785 |
}
|
| 2786 |
};
|
| 2787 |
|
|
@@ -2823,32 +3330,9 @@
|
|
| 2823 |
|
| 2824 |
/***/ },
|
| 2825 |
/* 16 */
|
| 2826 |
-
/***/ function(module, exports) {
|
| 2827 |
-
|
| 2828 |
-
module.exports = function(module) {
|
| 2829 |
-
if(!module.webpackPolyfill) {
|
| 2830 |
-
module.deprecate = function() {};
|
| 2831 |
-
module.paths = [];
|
| 2832 |
-
// module.parent = undefined by default
|
| 2833 |
-
module.children = [];
|
| 2834 |
-
module.webpackPolyfill = 1;
|
| 2835 |
-
}
|
| 2836 |
-
return module;
|
| 2837 |
-
}
|
| 2838 |
-
|
| 2839 |
-
|
| 2840 |
-
/***/ },
|
| 2841 |
-
/* 17 */
|
| 2842 |
/***/ function(module, exports) {
|
| 2843 |
|
| 2844 |
/* (ignored) */
|
| 2845 |
|
| 2846 |
-
/***/ },
|
| 2847 |
-
/* 18 */
|
| 2848 |
-
/***/ function(module, exports) {
|
| 2849 |
-
|
| 2850 |
-
module.exports = function() { throw new Error("define cannot be used indirect"); };
|
| 2851 |
-
|
| 2852 |
-
|
| 2853 |
/***/ }
|
| 2854 |
/******/ ]);
|
| 47 |
'use strict';
|
| 48 |
|
| 49 |
/**
|
| 50 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 51 |
*
|
| 52 |
* This program is free software: you can redistribute it and/or modify
|
| 53 |
* it under the terms of the GNU General Public License as published by
|
| 71 |
*/
|
| 72 |
|
| 73 |
var Report = __webpack_require__(1),
|
| 74 |
+
Feedback = __webpack_require__(3),
|
| 75 |
Deprecated = __webpack_require__(8),
|
| 76 |
FileUploader = __webpack_require__(12);
|
| 77 |
|
| 89 |
|
| 90 |
/***/ },
|
| 91 |
/* 1 */
|
| 92 |
+
/***/ function(module, exports, __webpack_require__) {
|
| 93 |
|
| 94 |
'use strict';
|
| 95 |
|
| 96 |
/**
|
| 97 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 98 |
*
|
| 99 |
* This program is free software: you can redistribute it and/or modify
|
| 100 |
* it under the terms of the GNU General Public License as published by
|
| 117 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 118 |
*/
|
| 119 |
|
| 120 |
+
var Util = __webpack_require__(2);
|
| 121 |
+
|
| 122 |
jQuery(document).ready(function ($) {
|
| 123 |
'use strict';
|
| 124 |
|
| 140 |
var terms = $('.ai1wm-report-terms').is(':checked');
|
| 141 |
|
| 142 |
$.ajax({
|
|
|
|
| 143 |
url: ai1wm_report.ajax.url,
|
| 144 |
+
type: 'POST',
|
| 145 |
+
dataType: 'json',
|
| 146 |
+
async: false,
|
| 147 |
+
data: { 'ai1wm_email': email, 'ai1wm_message': message, 'ai1wm_terms': +terms },
|
| 148 |
+
dataFilter: function dataFilter(data, type) {
|
| 149 |
+
return Util.json(data);
|
| 150 |
+
},
|
| 151 |
success: function success(data) {
|
| 152 |
+
if (data.errors.length > 0) {
|
|
|
|
| 153 |
// Reset previous messages
|
| 154 |
$('.ai1wm-report-problem-dialog .ai1wm-message').remove();
|
| 155 |
|
| 156 |
+
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
|
| 157 |
+
$.each(data.errors, function (key, value) {
|
| 158 |
+
errorMessage.append('<p>' + value + '</p>');
|
| 159 |
});
|
| 160 |
|
| 161 |
+
$('.ai1wm-report-problem-dialog').prepend(errorMessage);
|
| 162 |
} else {
|
| 163 |
+
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message').append('<p>Thanks for submitting your request!</p>');
|
| 164 |
+
$('.ai1wm-report-problem-dialog').html(successMessage);
|
| 165 |
|
| 166 |
// Hide message
|
| 167 |
setTimeout(function () {
|
| 168 |
$('.ai1wm-report-problem-dialog').removeClass('ai1wm-report-active');
|
| 169 |
}, 2000);
|
| 170 |
}
|
| 171 |
+
}
|
|
|
|
|
|
|
| 172 |
});
|
| 173 |
});
|
| 174 |
});
|
| 180 |
'use strict';
|
| 181 |
|
| 182 |
/**
|
| 183 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 184 |
+
*
|
| 185 |
+
* This program is free software: you can redistribute it and/or modify
|
| 186 |
+
* it under the terms of the GNU General Public License as published by
|
| 187 |
+
* the Free Software Foundation, either version 3 of the License, or
|
| 188 |
+
* (at your option) any later version.
|
| 189 |
+
*
|
| 190 |
+
* This program is distributed in the hope that it will be useful,
|
| 191 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 192 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 193 |
+
* GNU General Public License for more details.
|
| 194 |
+
*
|
| 195 |
+
* You should have received a copy of the GNU General Public License
|
| 196 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 197 |
+
*
|
| 198 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
| 199 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
| 200 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
| 201 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
| 202 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
| 203 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 204 |
+
*/
|
| 205 |
+
|
| 206 |
+
var $ = jQuery;
|
| 207 |
+
|
| 208 |
+
module.exports = {
|
| 209 |
+
random: function random(len) {
|
| 210 |
+
var text = '';
|
| 211 |
+
var possible = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
| 212 |
+
|
| 213 |
+
for (var i = 0; i < len; i++) {
|
| 214 |
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
return text;
|
| 218 |
+
},
|
| 219 |
+
form: function form(id) {
|
| 220 |
+
return $(id).serializeArray();
|
| 221 |
+
},
|
| 222 |
+
ucfirst: function ucfirst(text) {
|
| 223 |
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
| 224 |
+
},
|
| 225 |
+
list: function list(input) {
|
| 226 |
+
// Convert object to list
|
| 227 |
+
if ($.isPlainObject(input)) {
|
| 228 |
+
var result = [];
|
| 229 |
+
var params = decodeURIComponent($.param(input)).split('&');
|
| 230 |
+
|
| 231 |
+
// Loop over params
|
| 232 |
+
$.each(params, function (index, item) {
|
| 233 |
+
var value = item.split('=');
|
| 234 |
+
|
| 235 |
+
// Add item
|
| 236 |
+
result.push({ name: value[0], value: value[1] });
|
| 237 |
+
});
|
| 238 |
+
|
| 239 |
+
return result;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
return input;
|
| 243 |
+
},
|
| 244 |
+
json: function json(input) {
|
| 245 |
+
if ($.type(input) === 'string') {
|
| 246 |
+
var result = input.match(/{[\s\S]+}/);
|
| 247 |
+
if (result !== null) {
|
| 248 |
+
return result[0];
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
return false;
|
| 253 |
+
}
|
| 254 |
+
};
|
| 255 |
+
|
| 256 |
+
/***/ },
|
| 257 |
+
/* 3 */
|
| 258 |
+
/***/ function(module, exports, __webpack_require__) {
|
| 259 |
+
|
| 260 |
+
'use strict';
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 264 |
*
|
| 265 |
* This program is free software: you can redistribute it and/or modify
|
| 266 |
* it under the terms of the GNU General Public License as published by
|
| 283 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 284 |
*/
|
| 285 |
|
| 286 |
+
var Util = __webpack_require__(2);
|
| 287 |
+
|
| 288 |
jQuery(document).ready(function ($) {
|
| 289 |
'use strict';
|
| 290 |
|
| 343 |
var terms = $('.ai1wm-feedback-terms').is(':checked');
|
| 344 |
|
| 345 |
$.ajax({
|
|
|
|
| 346 |
url: ai1wm_feedback.ajax.url,
|
| 347 |
+
type: 'POST',
|
| 348 |
+
dataType: 'json',
|
| 349 |
+
async: false,
|
| 350 |
+
data: { 'ai1wm_type': type, 'ai1wm_email': email, 'ai1wm_message': message, 'ai1wm_terms': +terms },
|
| 351 |
+
dataFilter: function dataFilter(data, type) {
|
| 352 |
+
return Util.json(data);
|
| 353 |
+
},
|
| 354 |
success: function success(data) {
|
| 355 |
+
if (data.errors.length > 0) {
|
|
|
|
| 356 |
// Reset previous messages
|
| 357 |
$('.ai1wm-feedback .ai1wm-message').remove();
|
| 358 |
|
| 359 |
+
var errorMessage = $('<div />').addClass('ai1wm-message ai1wm-error-message');
|
| 360 |
+
$.each(data.errors, function (key, value) {
|
| 361 |
+
errorMessage.append('<p>' + value + '</p>');
|
| 362 |
});
|
| 363 |
|
| 364 |
+
$('.ai1wm-feedback').prepend(errorMessage);
|
| 365 |
} else {
|
| 366 |
+
var successMessage = $('<div />').addClass('ai1wm-message ai1wm-success-message').append('<p>Thanks for submitting your feedback!</p>');
|
| 367 |
+
$('.ai1wm-feedback').html(successMessage);
|
| 368 |
}
|
| 369 |
+
}
|
|
|
|
|
|
|
| 370 |
});
|
| 371 |
});
|
| 372 |
});
|
| 373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
/***/ },
|
| 375 |
/* 4 */
|
| 376 |
/***/ function(module, exports, __webpack_require__) {
|
| 378 |
'use strict';
|
| 379 |
|
| 380 |
/**
|
| 381 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 382 |
*
|
| 383 |
* This program is free software: you can redistribute it and/or modify
|
| 384 |
* it under the terms of the GNU General Public License as published by
|
| 401 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 402 |
*/
|
| 403 |
|
| 404 |
+
var Util = __webpack_require__(2),
|
| 405 |
Modal = __webpack_require__(5),
|
| 406 |
$ = jQuery;
|
| 407 |
|
| 411 |
// Set params
|
| 412 |
this.params = [];
|
| 413 |
|
| 414 |
+
// Set stop flag
|
| 415 |
+
this.stopImport = false;
|
| 416 |
+
|
| 417 |
// Set modal
|
| 418 |
this.modal = new Modal();
|
| 419 |
|
| 437 |
this.params = Util.list(params);
|
| 438 |
};
|
| 439 |
|
| 440 |
+
Import.prototype.start = function (options, retries) {
|
| 441 |
var self = this;
|
| 442 |
+
var retries = retries || 0;
|
| 443 |
+
|
| 444 |
+
// Set stop flag
|
| 445 |
+
if (retries === 0) {
|
| 446 |
+
this.stopImport = false;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
// Stop running import
|
| 450 |
+
if (this.stopImport) {
|
| 451 |
+
return;
|
| 452 |
+
}
|
| 453 |
|
| 454 |
// Initializing beforeunload event
|
| 455 |
$(window).bind('beforeunload', function () {
|
| 456 |
return 'You are about to stop importing your website, are you sure?';
|
| 457 |
});
|
| 458 |
|
|
|
|
|
|
|
|
|
|
| 459 |
// Set initial status
|
| 460 |
this.setStatus({ type: 'info', message: 'Preparing to import...' });
|
| 461 |
|
| 468 |
}
|
| 469 |
|
| 470 |
// Import
|
| 471 |
+
$.ajax({
|
| 472 |
+
url: ai1wm_import.ajax.url,
|
| 473 |
+
type: 'POST',
|
| 474 |
+
dataType: 'json',
|
| 475 |
+
data: params,
|
| 476 |
+
dataFilter: function dataFilter(data, type) {
|
| 477 |
+
return Util.json(data);
|
| 478 |
+
}
|
| 479 |
+
}).done(function () {
|
| 480 |
self.getStatus();
|
| 481 |
+
}).done(function (params) {
|
| 482 |
+
if (params) {
|
| 483 |
+
self.run(params);
|
| 484 |
+
}
|
| 485 |
}).fail(function () {
|
| 486 |
+
var timeout = retries * 1000;
|
| 487 |
+
if (retries >= 5) {
|
| 488 |
+
return self.setStatus({
|
| 489 |
+
type: 'error',
|
| 490 |
+
message: 'Unable to start the import. Refresh the page and try again'
|
| 491 |
+
});
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
retries++;
|
| 495 |
+
|
| 496 |
+
setTimeout(self.start.bind(self, options, retries), timeout);
|
| 497 |
+
});
|
| 498 |
+
};
|
| 499 |
+
|
| 500 |
+
Import.prototype.run = function (params, retries) {
|
| 501 |
+
var self = this;
|
| 502 |
+
var retries = retries || 0;
|
| 503 |
+
|
| 504 |
+
// Stop running import
|
| 505 |
+
if (this.stopImport) {
|
| 506 |
+
return;
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
// Import
|
| 510 |
+
$.ajax({
|
| 511 |
+
url: ai1wm_import.ajax.url,
|
| 512 |
+
type: 'POST',
|
| 513 |
+
dataType: 'json',
|
| 514 |
+
data: params,
|
| 515 |
+
dataFilter: function dataFilter(data, type) {
|
| 516 |
+
return Util.json(data);
|
| 517 |
+
}
|
| 518 |
+
}).done(function (params) {
|
| 519 |
+
if (params) {
|
| 520 |
+
self.run(params);
|
| 521 |
+
}
|
| 522 |
+
}).fail(function () {
|
| 523 |
+
var timeout = retries * 1000;
|
| 524 |
+
|
| 525 |
+
retries++;
|
| 526 |
+
|
| 527 |
+
setTimeout(self.run.bind(self, params, retries), timeout);
|
| 528 |
});
|
| 529 |
};
|
| 530 |
|
| 531 |
+
Import.prototype.confirm = function (options, retries) {
|
| 532 |
var self = this;
|
| 533 |
+
var retries = retries || 0;
|
| 534 |
+
|
| 535 |
+
// Stop running import
|
| 536 |
+
if (this.stopImport) {
|
| 537 |
+
return;
|
| 538 |
+
}
|
| 539 |
|
| 540 |
// Set params
|
| 541 |
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 150 });
|
| 546 |
}
|
| 547 |
|
| 548 |
// Confirm
|
| 549 |
+
$.ajax({
|
| 550 |
+
url: ai1wm_import.ajax.url,
|
| 551 |
+
type: 'POST',
|
| 552 |
+
dataType: 'json',
|
| 553 |
+
data: params,
|
| 554 |
+
dataFilter: function dataFilter(data, type) {
|
| 555 |
+
return Util.json(data);
|
| 556 |
+
}
|
| 557 |
+
}).done(function () {
|
| 558 |
self.getStatus();
|
| 559 |
+
}).done(function (params) {
|
| 560 |
+
if (params) {
|
| 561 |
+
self.run(params);
|
| 562 |
+
}
|
| 563 |
}).fail(function () {
|
| 564 |
+
var timeout = retries * 1000;
|
| 565 |
+
if (retries >= 5) {
|
| 566 |
+
return self.setStatus({
|
| 567 |
+
type: 'error',
|
| 568 |
+
message: 'Unable to confirm the import. Refresh the page and try again'
|
| 569 |
+
});
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
retries++;
|
| 573 |
+
|
| 574 |
+
setTimeout(self.confirm.bind(self, options, retries), timeout);
|
| 575 |
});
|
| 576 |
};
|
| 577 |
|
| 578 |
+
Import.prototype.blogs = function (options, retries) {
|
| 579 |
var self = this;
|
| 580 |
+
var retries = retries || 0;
|
| 581 |
+
|
| 582 |
+
// Stop running import
|
| 583 |
+
if (this.stopImport) {
|
| 584 |
+
return;
|
| 585 |
+
}
|
| 586 |
|
| 587 |
// Set params
|
| 588 |
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 150 });
|
| 593 |
}
|
| 594 |
|
| 595 |
// Blogs
|
| 596 |
+
$.ajax({
|
| 597 |
+
url: ai1wm_import.ajax.url,
|
| 598 |
+
type: 'POST',
|
| 599 |
+
dataType: 'json',
|
| 600 |
+
data: params,
|
| 601 |
+
dataFilter: function dataFilter(data, type) {
|
| 602 |
+
return Util.json(data);
|
| 603 |
+
}
|
| 604 |
+
}).done(function () {
|
| 605 |
self.getStatus();
|
| 606 |
+
}).done(function (params) {
|
| 607 |
+
if (params) {
|
| 608 |
+
self.run(params);
|
| 609 |
+
}
|
| 610 |
}).fail(function () {
|
| 611 |
+
var timeout = retries * 1000;
|
| 612 |
+
if (retries >= 5) {
|
| 613 |
+
return self.setStatus({
|
| 614 |
+
type: 'error',
|
| 615 |
+
message: 'Unable to prepare blogs the import. Refresh the page and try again'
|
| 616 |
+
});
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
retries++;
|
| 620 |
+
|
| 621 |
+
setTimeout(self.blogs.bind(self, options, retries), timeout);
|
| 622 |
});
|
| 623 |
};
|
| 624 |
|
| 625 |
+
Import.prototype.clean = function (options, retries) {
|
| 626 |
var self = this;
|
| 627 |
+
var retries = retries || 0;
|
| 628 |
|
| 629 |
+
// Set stop flag
|
| 630 |
+
this.stopImport = true;
|
| 631 |
+
|
| 632 |
+
// Set initial status
|
| 633 |
+
this.setStatus({ type: 'info', message: 'Please wait, stopping the import...' });
|
| 634 |
|
| 635 |
// Set params
|
| 636 |
var params = this.params.concat({ name: 'secret_key', value: ai1wm_import.secret_key }).concat({ name: 'priority', value: 400 });
|
| 641 |
}
|
| 642 |
|
| 643 |
// Clean
|
| 644 |
+
$.ajax({
|
| 645 |
+
url: ai1wm_import.ajax.url,
|
| 646 |
+
type: 'POST',
|
| 647 |
+
dataType: 'json',
|
| 648 |
+
data: params,
|
| 649 |
+
dataFilter: function dataFilter(data, type) {
|
| 650 |
+
return Util.json(data);
|
| 651 |
+
}
|
| 652 |
+
}).done(function () {
|
| 653 |
// Unbinding the beforeunload event when we stop importing
|
| 654 |
$(window).unbind('beforeunload');
|
| 655 |
+
|
| 656 |
+
// Destroy modal
|
| 657 |
+
self.modal.destroy();
|
| 658 |
}).fail(function () {
|
| 659 |
+
var timeout = retries * 1000;
|
| 660 |
+
if (retries >= 5) {
|
| 661 |
+
return self.setStatus({
|
| 662 |
+
type: 'error',
|
| 663 |
+
message: 'Unable to stop the import. Refresh the page and try again'
|
| 664 |
+
});
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
retries++;
|
| 668 |
+
|
| 669 |
+
setTimeout(self.clean.bind(self, options, retries), timeout);
|
| 670 |
});
|
| 671 |
};
|
| 672 |
|
| 674 |
var self = this;
|
| 675 |
|
| 676 |
// Stop getting status
|
| 677 |
+
if (this.stopImport) {
|
| 678 |
return;
|
| 679 |
}
|
| 680 |
|
| 681 |
$.ajax({
|
|
|
|
| 682 |
url: ai1wm_import.status.url,
|
| 683 |
+
type: 'GET',
|
| 684 |
+
dataType: 'json',
|
| 685 |
+
cache: false,
|
| 686 |
+
dataFilter: function dataFilter(data, type) {
|
| 687 |
+
return Util.json(data);
|
| 688 |
+
}
|
| 689 |
}).done(function (params) {
|
| 690 |
if (params) {
|
| 691 |
self.setStatus(params);
|
| 705 |
}
|
| 706 |
|
| 707 |
// Import is not done yet, let's check status in 3 seconds
|
| 708 |
+
setTimeout(self.getStatus.bind(self), 3000);
|
|
|
|
|
|
|
| 709 |
}).fail(function () {
|
| 710 |
// Import is not done yet, let's check status in 3 seconds
|
| 711 |
+
setTimeout(self.getStatus.bind(self), 3000);
|
|
|
|
|
|
|
| 712 |
});;
|
| 713 |
};
|
| 714 |
|
| 737 |
'use strict';
|
| 738 |
|
| 739 |
/**
|
| 740 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 741 |
*
|
| 742 |
* This program is free software: you can redistribute it and/or modify
|
| 743 |
* it under the terms of the GNU General Public License as published by
|
| 788 |
var title = $('<span></span>').addClass('ai1wm-title-red').text('Unable to import');
|
| 789 |
|
| 790 |
// Create close button
|
| 791 |
+
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
|
| 792 |
+
self.destroy();
|
|
|
|
| 793 |
});
|
| 794 |
|
| 795 |
// Append close button
|
| 812 |
// Progress Modal
|
| 813 |
this.progress = function (params) {
|
| 814 |
if (this.view === 'progress') {
|
| 815 |
+
|
| 816 |
// Update progressBarMeter
|
| 817 |
this.progress.progressBarMeter.width(params.percent + '%');
|
| 818 |
|
| 845 |
this.progress.progressBarPercent = $('<span class="ai1wm-progress-bar-percent">0%</span>').text(params.percent + '%');
|
| 846 |
|
| 847 |
// Create stop import
|
| 848 |
+
var stopButton = $('<button type="button" class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').on('click', function () {
|
| 849 |
$(this).attr('disabled', 'disabled');
|
| 850 |
self.onStop();
|
|
|
|
|
|
|
| 851 |
});
|
| 852 |
|
| 853 |
// Append progress meter and progress percent
|
| 893 |
var warning = $('<span class="ai1wm-icon-notification"></span>');
|
| 894 |
|
| 895 |
// Create confirm button
|
| 896 |
+
var confirmButton = $('<button type="button" class="ai1wm-button-green">Continue</button>').on('click', function () {
|
| 897 |
$(this).attr('disabled', 'disabled');
|
| 898 |
self.onConfirm();
|
| 899 |
});
|
| 937 |
var title = $('<span></span>').addClass('ai1wm-title-grey').text(params.title);
|
| 938 |
|
| 939 |
// Create continue button
|
| 940 |
+
var continueButton = $('<button type="button" class="ai1wm-button-green">Continue</button>').on('click', function () {
|
| 941 |
$(this).attr('disabled', 'disabled');
|
| 942 |
self.onBlogs($(this).closest('form').serializeArray());
|
| 943 |
});
|
| 981 |
var loader = $('<span class="ai1wm-loader"></span>');
|
| 982 |
|
| 983 |
// Create stop import
|
| 984 |
+
var stopButton = $('<button type="button" class="ai1wm-button-red"><i class="ai1wm-icon-notification"></i> Stop import</button>').attr('disabled', 'disabled');
|
| 985 |
|
| 986 |
// Append stop button
|
| 987 |
action.append(stopButton);
|
| 1022 |
var title = $('<span></span>').addClass('ai1wm-title-green').text(params.title);
|
| 1023 |
|
| 1024 |
// Create close button
|
| 1025 |
+
var closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
|
| 1026 |
+
self.destroy();
|
|
|
|
| 1027 |
});
|
| 1028 |
|
| 1029 |
// Append close button
|
| 1085 |
this.view = params.type;
|
| 1086 |
};
|
| 1087 |
|
| 1088 |
+
Modal.prototype.destroy = function () {
|
| 1089 |
+
this.modal.hide();
|
| 1090 |
+
this.overlay.hide();
|
| 1091 |
+
};
|
| 1092 |
+
|
| 1093 |
module.exports = Modal;
|
| 1094 |
|
| 1095 |
/***/ },
|
| 1101 |
'use strict';
|
| 1102 |
|
| 1103 |
/**
|
| 1104 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 1105 |
*
|
| 1106 |
* This program is free software: you can redistribute it and/or modify
|
| 1107 |
* it under the terms of the GNU General Public License as published by
|
| 1124 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 1125 |
*/
|
| 1126 |
|
| 1127 |
+
var Util = __webpack_require__(2),
|
| 1128 |
Dialog = __webpack_require__(9);
|
| 1129 |
|
| 1130 |
var Extensions = {
|
| 1131 |
+
's3': 'Amazon S3 Extension',
|
| 1132 |
+
'url': 'URL Extension',
|
| 1133 |
+
'ftp': 'FTP Extension',
|
| 1134 |
+
'gdrive': 'Google Drive Extension',
|
| 1135 |
+
'dropbox': 'Dropbox Extension'
|
| 1136 |
};
|
| 1137 |
|
| 1138 |
window.Ai1wmExportController = function (provider) {
|
| 1139 |
+
this._export = {};
|
| 1140 |
+
this._provider = provider;
|
| 1141 |
};
|
| 1142 |
|
| 1143 |
window.Ai1wmExportController.prototype.start = function () {
|
| 1144 |
+
new Dialog('<strong>All in One WP Migration</strong> is not compatible with current version of ' + '<strong>' + Extensions[this._provider] + '</strong>. Please contact ' + '<a href="mailto:support@servmask.com">support@servmask.com</a> for more details.');
|
| 1145 |
};
|
| 1146 |
|
| 1147 |
window.Ai1wmImportController = function (provider) {
|
| 1148 |
+
this._import = {};
|
| 1149 |
+
this._provider = provider;
|
| 1150 |
};
|
| 1151 |
|
| 1152 |
window.Ai1wmImportController.prototype.init = function () {};
|
| 1153 |
|
| 1154 |
window.Ai1wmImportController.prototype.download = function () {
|
| 1155 |
+
new Dialog('<strong>All in One WP Migration</strong> is not compatible with current version of ' + '<strong>' + Extensions[this._provider] + '</strong>. Please contact ' + '<a href="mailto:support@servmask.com">support@servmask.com</a> for more details.');
|
| 1156 |
};
|
| 1157 |
|
| 1158 |
+
jQuery(document).ready(function ($) {
|
| 1159 |
+
'use strict';
|
| 1160 |
+
|
| 1161 |
+
// Box extension
|
| 1162 |
+
|
| 1163 |
+
$('#ai1wmbe-import-file-cancel').attr('type', 'button');
|
| 1164 |
+
$('#ai1wmbe-import-file').attr('type', 'button');
|
| 1165 |
+
|
| 1166 |
+
// Dropbox extension
|
| 1167 |
+
$('#ai1wmde-import-file-cancel').attr('type', 'button');
|
| 1168 |
+
$('#ai1wmde-import-file').attr('type', 'button');
|
| 1169 |
+
|
| 1170 |
+
// FTP extension
|
| 1171 |
+
$('#ai1wmfe-import-file-cancel').attr('type', 'button');
|
| 1172 |
+
$('#ai1wmfe-import-file').attr('type', 'button');
|
| 1173 |
+
|
| 1174 |
+
// Google Drive extension
|
| 1175 |
+
$('#ai1wmge-import-file-cancel').attr('type', 'button');
|
| 1176 |
+
$('#ai1wmge-import-file').attr('type', 'button');
|
| 1177 |
+
|
| 1178 |
+
// OneDrive extension
|
| 1179 |
+
$('#ai1wmoe-import-file-cancel').attr('type', 'button');
|
| 1180 |
+
$('#ai1wmoe-import-file').attr('type', 'button');
|
| 1181 |
+
|
| 1182 |
+
// Amazon S3 extension
|
| 1183 |
+
$('#ai1wmse-import-file-cancel').attr('type', 'button');
|
| 1184 |
+
$('#ai1wmse-import-file').attr('type', 'button');
|
| 1185 |
+
|
| 1186 |
+
// URL extension
|
| 1187 |
+
$('#ai1wmle-import-file-cancel').attr('type', 'button');
|
| 1188 |
+
$('#ai1wmle-import-file').attr('type', 'button');
|
| 1189 |
+
});
|
| 1190 |
+
|
| 1191 |
/***/ },
|
| 1192 |
/* 9 */
|
| 1193 |
/***/ function(module, exports) {
|
| 1195 |
'use strict';
|
| 1196 |
|
| 1197 |
/**
|
| 1198 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 1199 |
*
|
| 1200 |
* This program is free software: you can redistribute it and/or modify
|
| 1201 |
* it under the terms of the GNU General Public License as published by
|
| 1242 |
this.action = $('<div></div>');
|
| 1243 |
|
| 1244 |
// Create close button
|
| 1245 |
+
this.closeButton = $('<button type="button" class="ai1wm-button-red">Close</button>').on('click', function () {
|
| 1246 |
self.modal.hide();
|
| 1247 |
self.overlay.hide();
|
| 1248 |
});
|
| 1274 |
/* WEBPACK VAR INJECTION */(function(fetch, global) {'use strict';
|
| 1275 |
|
| 1276 |
/**
|
| 1277 |
+
* Copyright (C) 2014-2017 ServMask Inc.
|
| 1278 |
*
|
| 1279 |
* This program is free software: you can redistribute it and/or modify
|
| 1280 |
* it under the terms of the GNU General Public License as published by
|
| 1297 |
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
| 1298 |
*/
|
| 1299 |
|
| 1300 |
+
var Util = __webpack_require__(2),
|
| 1301 |
Import = __webpack_require__(4),
|
| 1302 |
$ = jQuery;
|
| 1303 |
|
| 1306 |
FileUploader.prototype.setDefaultValues = function () {
|
| 1307 |
this.model = new Import();
|
| 1308 |
this.stopUpload = false;
|
|
|
|
| 1309 |
};
|
| 1310 |
|
| 1311 |
FileUploader.prototype.init = function () {
|
| 1357 |
});
|
| 1358 |
};
|
| 1359 |
|
| 1360 |
+
FileUploader.prototype.upload = function (file, retries) {
|
| 1361 |
var _this2 = this;
|
| 1362 |
|
| 1363 |
+
var retries = retries || 0;
|
| 1364 |
+
|
| 1365 |
var chunkSize = file.size > ai1wm_uploader.chunk_size ? ai1wm_uploader.chunk_size : file.size;
|
| 1366 |
var formData = this.getFormData(file, chunkSize);
|
| 1367 |
+
|
| 1368 |
fetch(ai1wm_uploader.url, {
|
| 1369 |
method: 'POST',
|
| 1370 |
credentials: 'include',
|
| 1379 |
ai1wm_uploader.chunk_size = chunkSize / 2;
|
| 1380 |
return _this2.upload(file);
|
| 1381 |
case 200:
|
| 1382 |
+
return response.text().then(function (text) {
|
| 1383 |
+
var extractedJsonText = Util.json(text);
|
| 1384 |
+
if (extractedJsonText) {
|
| 1385 |
+
var json = JSON.parse(extractedJsonText);
|
| 1386 |
+
if (json.errors.length === 0) {
|
| 1387 |
+
file = file.slice(chunkSize, file.size, 'application/octet-binary');
|
| 1388 |
+
var uploadedBytes = _this2.fileSize - file.size;
|
| 1389 |
+
var progress = uploadedBytes / _this2.fileSize * 100;
|
| 1390 |
+
_this2.onUploadProgress(progress.toFixed(2));
|
| 1391 |
+
return progress === 100 ? _this2.onFileUploaded() : _this2.upload(file);
|
| 1392 |
+
}
|
| 1393 |
+
}
|
| 1394 |
+
|
| 1395 |
+
throw new Error(text);
|
| 1396 |
+
});
|
| 1397 |
default:
|
| 1398 |
throw new Error(response.status);
|
| 1399 |
}
|
| 1400 |
}).catch(function (error) {
|
| 1401 |
+
var timeout = retries * 1000;
|
| 1402 |
+
if (retries >= 30) {
|
| 1403 |
return _this2.onError(new Error('We are sorry, there seems to be a problem while uploading your file. Follow <a href="https://www.youtube.com/watch?v=mRp7qTFYKgs" target="_blank">this guide</a> to resolve it.'));
|
| 1404 |
}
|
| 1405 |
+
|
| 1406 |
+
retries++;
|
| 1407 |
+
|
| 1408 |
+
setTimeout(_this2.upload.bind(_this2, file, retries), timeout);
|
| 1409 |
});
|
| 1410 |
};
|
| 1411 |
|
| 1454 |
FileUploader.prototype.onBeforeUpload = function (file) {
|
| 1455 |
var self = this;
|
| 1456 |
|
| 1457 |
+
var storage = Util.random(12);
|
| 1458 |
+
var options = Util.form('#ai1wm-import-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: file.name });
|
| 1459 |
+
|
| 1460 |
+
// Set global params
|
| 1461 |
+
this.model.setParams(options);
|
| 1462 |
|
| 1463 |
// Set multipart params
|
| 1464 |
$.extend(ai1wm_uploader.params, {
|
| 1465 |
+
storage: storage,
|
| 1466 |
+
archive: file.name
|
| 1467 |
});
|
| 1468 |
|
|
|
|
|
|
|
|
|
|
| 1469 |
// Set stop
|
| 1470 |
this.model.onStop = function () {
|
| 1471 |
self.stopUpload = true;
|
| 1472 |
+
|
| 1473 |
// Clean storage
|
| 1474 |
self.model.clean();
|
| 1475 |
};
|
| 1524 |
arrayBuffer: 'ArrayBuffer' in self
|
| 1525 |
}
|
| 1526 |
|
| 1527 |
+
if (support.arrayBuffer) {
|
| 1528 |
+
var viewClasses = [
|
| 1529 |
+
'[object Int8Array]',
|
| 1530 |
+
'[object Uint8Array]',
|
| 1531 |
+
'[object Uint8ClampedArray]',
|
| 1532 |
+
'[object Int16Array]',
|
| 1533 |
+
'[object Uint16Array]',
|
| 1534 |
+
'[object Int32Array]',
|
| 1535 |
+
'[object Uint32Array]',
|
| 1536 |
+
'[object Float32Array]',
|
| 1537 |
+
'[object Float64Array]'
|
| 1538 |
+
]
|
| 1539 |
+
|
| 1540 |
+
var isDataView = function(obj) {
|
| 1541 |
+
return obj && DataView.prototype.isPrototypeOf(obj)
|
| 1542 |
+
}
|
| 1543 |
+
|
| 1544 |
+
var isArrayBufferView = ArrayBuffer.isView || function(obj) {
|
| 1545 |
+
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
| 1546 |
+
}
|
| 1547 |
+
}
|
| 1548 |
+
|
| 1549 |
function normalizeName(name) {
|
| 1550 |
if (typeof name !== 'string') {
|
| 1551 |
name = String(name)
|
| 1678 |
|
| 1679 |
function readBlobAsArrayBuffer(blob) {
|
| 1680 |
var reader = new FileReader()
|
| 1681 |
+
var promise = fileReaderReady(reader)
|
| 1682 |
reader.readAsArrayBuffer(blob)
|
| 1683 |
+
return promise
|
| 1684 |
}
|
| 1685 |
|
| 1686 |
function readBlobAsText(blob) {
|
| 1687 |
var reader = new FileReader()
|
| 1688 |
+
var promise = fileReaderReady(reader)
|
| 1689 |
reader.readAsText(blob)
|
| 1690 |
+
return promise
|
| 1691 |
+
}
|
| 1692 |
+
|
| 1693 |
+
function readArrayBufferAsText(buf) {
|
| 1694 |
+
var view = new Uint8Array(buf)
|
| 1695 |
+
var chars = new Array(view.length)
|
| 1696 |
+
|
| 1697 |
+
for (var i = 0; i < view.length; i++) {
|
| 1698 |
+
chars[i] = String.fromCharCode(view[i])
|
| 1699 |
+
}
|
| 1700 |
+
return chars.join('')
|
| 1701 |
+
}
|
| 1702 |
+
|
| 1703 |
+
function bufferClone(buf) {
|
| 1704 |
+
if (buf.slice) {
|
| 1705 |
+
return buf.slice(0)
|
| 1706 |
+
} else {
|
| 1707 |
+
var view = new Uint8Array(buf.byteLength)
|
| 1708 |
+
view.set(new Uint8Array(buf))
|
| 1709 |
+
return view.buffer
|
| 1710 |
+
}
|
| 1711 |
}
|
| 1712 |
|
| 1713 |
function Body() {
|
| 1715 |
|
| 1716 |
this._initBody = function(body) {
|
| 1717 |
this._bodyInit = body
|
| 1718 |
+
if (!body) {
|
| 1719 |
+
this._bodyText = ''
|
| 1720 |
+
} else if (typeof body === 'string') {
|
| 1721 |
this._bodyText = body
|
| 1722 |
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
| 1723 |
this._bodyBlob = body
|
| 1725 |
this._bodyFormData = body
|
| 1726 |
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
| 1727 |
this._bodyText = body.toString()
|
| 1728 |
+
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
| 1729 |
+
this._bodyArrayBuffer = bufferClone(body.buffer)
|
| 1730 |
+
// IE 10-11 can't handle a DataView body.
|
| 1731 |
+
this._bodyInit = new Blob([this._bodyArrayBuffer])
|
| 1732 |
+
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
| 1733 |
+
this._bodyArrayBuffer = bufferClone(body)
|
| 1734 |
} else {
|
| 1735 |
throw new Error('unsupported BodyInit type')
|
| 1736 |
}
|
| 1755 |
|
| 1756 |
if (this._bodyBlob) {
|
| 1757 |
return Promise.resolve(this._bodyBlob)
|
| 1758 |
+
} else if (this._bodyArrayBuffer) {
|
| 1759 |
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
| 1760 |
} else if (this._bodyFormData) {
|
| 1761 |
throw new Error('could not read FormData body as blob')
|
| 1762 |
} else {
|
| 1765 |
}
|
| 1766 |
|
| 1767 |
this.arrayBuffer = function() {
|
| 1768 |
+
if (this._bodyArrayBuffer) {
|
| 1769 |
+
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1770 |
} else {
|
| 1771 |
+
return this.blob().then(readBlobAsArrayBuffer)
|
| 1772 |
}
|
| 1773 |
}
|
| 1774 |
+
}
|
| 1775 |
+
|
| 1776 |
+
this.text = function() {
|
| 1777 |
+
var rejected = consumed(this)
|
| 1778 |
+
if (rejected) {
|
| 1779 |
+
return rejected
|
| 1780 |
+
}
|
| 1781 |
+
|
| 1782 |
+
if (this._bodyBlob) {
|
| 1783 |
+
return readBlobAsText(this._bodyBlob)
|
| 1784 |
+
} else if (this._bodyArrayBuffer) {
|
| 1785 |
+
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
| 1786 |
+
} else if (this._bodyFormData) {
|
| 1787 |
+
throw new Error('could not read FormData body as text')
|
| 1788 |
+
} else {
|
| 1789 |
+
return Promise.resolve(this._bodyText)
|
| 1790 |
}
|
| 1791 |
}
|
| 1792 |
|
| 1814 |
function Request(input, options) {
|
| 1815 |
options = options || {}
|
| 1816 |
var body = options.body
|
| 1817 |
+
|
| 1818 |
+
if (typeof input === 'string') {
|
| 1819 |
+
this.url = input
|
| 1820 |
+
} else {
|
| 1821 |
if (input.bodyUsed) {
|
| 1822 |
throw new TypeError('Already read')
|
| 1823 |
}
|
| 1828 |
}
|
| 1829 |
this.method = input.method
|
| 1830 |
this.mode = input.mode
|
| 1831 |
+
if (!body && input._bodyInit != null) {
|
| 1832 |
body = input._bodyInit
|
| 1833 |
input.bodyUsed = true
|
| 1834 |
}
|
|
|
|
|
|
|
| 1835 |
}
|
| 1836 |
|
| 1837 |
this.credentials = options.credentials || this.credentials || 'omit'
|
| 1849 |
}
|
| 1850 |
|
| 1851 |
Request.prototype.clone = function() {
|
| 1852 |
+
return new Request(this, { body: this._bodyInit })
|
| 1853 |
}
|
| 1854 |
|
| 1855 |
function decode(body) {
|
| 1865 |
return form
|
| 1866 |
}
|
| 1867 |
|
| 1868 |
+
function parseHeaders(rawHeaders) {
|
| 1869 |
+
var headers = new Headers()
|
| 1870 |
+
rawHeaders.split('\r\n').forEach(function(line) {
|
| 1871 |
+
var parts = line.split(':')
|
| 1872 |
+
var key = parts.shift().trim()
|
| 1873 |
+
if (key) {
|
| 1874 |
+
var value = parts.join(':').trim()
|
| 1875 |
+
headers.append(key, value)
|
| 1876 |
+
}
|
| 1877 |
})
|
| 1878 |
+
return headers
|
| 1879 |
}
|
| 1880 |
|
| 1881 |
Body.call(Request.prototype)
|
| 1886 |
}
|
| 1887 |
|
| 1888 |
this.type = 'default'
|
| 1889 |
+
this.status = 'status' in options ? options.status : 200
|
| 1890 |
this.ok = this.status >= 200 && this.status < 300
|
| 1891 |
+
this.statusText = 'statusText' in options ? options.statusText : 'OK'
|
| 1892 |
+
this.headers = new Headers(options.headers)
|
| 1893 |
this.url = options.url || ''
|
| 1894 |
this._initBody(bodyInit)
|
| 1895 |
}
|
| 1927 |
|
| 1928 |
self.fetch = function(input, init) {
|
| 1929 |
return new Promise(function(resolve, reject) {
|
| 1930 |
+
var request = new Request(input, init)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1931 |
var xhr = new XMLHttpRequest()
|
| 1932 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1933 |
xhr.onload = function() {
|
| 1934 |
var options = {
|
| 1935 |
status: xhr.status,
|
| 1936 |
statusText: xhr.statusText,
|
| 1937 |
+
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
|
|
| 1938 |
}
|
| 1939 |
+
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
|
| 1940 |
var body = 'response' in xhr ? xhr.response : xhr.responseText
|
| 1941 |
resolve(new Response(body, options))
|
| 1942 |
}
|
| 1979 |
/* 14 */
|
| 1980 |
/***/ function(module, exports, __webpack_require__) {
|
| 1981 |
|
| 1982 |
+
var require;/* WEBPACK VAR INJECTION */(function(process, Promise, global) {/*** IMPORTS FROM imports-loader ***/
|
| 1983 |
(function() {
|
| 1984 |
|
| 1985 |
/*!
|
| 1986 |
* @overview es6-promise - a tiny implementation of Promises/A+.
|
| 1987 |
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
| 1988 |
* @license Licensed under MIT license
|
| 1989 |
+
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
| 1990 |
+
* @version 3.3.1
|
| 1991 |
*/
|
| 1992 |
|
| 1993 |
+
(function (global, factory) {
|
| 1994 |
+
true ? module.exports = factory() :
|
| 1995 |
+
typeof define === 'function' && define.amd ? define(factory) :
|
| 1996 |
+
(global.ES6Promise = factory());
|
| 1997 |
+
}(this, (function () { 'use strict';
|
| 1998 |
|
| 1999 |
+
function objectOrFunction(x) {
|
| 2000 |
+
return typeof x === 'function' || typeof x === 'object' && x !== null;
|
| 2001 |
+
}
|
| 2002 |
|
| 2003 |
+
function isFunction(x) {
|
| 2004 |
+
return typeof x === 'function';
|
| 2005 |
+
}
|
| 2006 |
|
| 2007 |
+
var _isArray = undefined;
|
| 2008 |
+
if (!Array.isArray) {
|
| 2009 |
+
_isArray = function (x) {
|
| 2010 |
+
return Object.prototype.toString.call(x) === '[object Array]';
|
| 2011 |
+
};
|
| 2012 |
+
} else {
|
| 2013 |
+
_isArray = Array.isArray;
|
| 2014 |
+
}
|
| 2015 |
+
|
| 2016 |
+
var isArray = _isArray;
|
| 2017 |
+
|
| 2018 |
+
var len = 0;
|
| 2019 |
+
var vertxNext = undefined;
|
| 2020 |
+
var customSchedulerFn = undefined;
|
| 2021 |
+
|
| 2022 |
+
var asap = function asap(callback, arg) {
|
| 2023 |
+
queue[len] = callback;
|
| 2024 |
+
queue[len + 1] = arg;
|
| 2025 |
+
len += 2;
|
| 2026 |
+
if (len === 2) {
|
| 2027 |
+
// If len is 2, that means that we need to schedule an async flush.
|
| 2028 |
+
// If additional callbacks are queued before the queue is flushed, they
|
| 2029 |
+
// will be processed by this flush that we are scheduling.
|
| 2030 |
+
if (customSchedulerFn) {
|
| 2031 |
+
customSchedulerFn(flush);
|
| 2032 |
} else {
|
| 2033 |
+
scheduleFlush();
|
| 2034 |
}
|
| 2035 |
+
}
|
| 2036 |
+
};
|
| 2037 |
|
| 2038 |
+
function setScheduler(scheduleFn) {
|
| 2039 |
+
customSchedulerFn = scheduleFn;
|
| 2040 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2041 |
|
| 2042 |
+
function setAsap(asapFn) {
|
| 2043 |
+
asap = asapFn;
|
| 2044 |
+
}
|
| 2045 |
|
| 2046 |
+
var browserWindow = typeof window !== 'undefined' ? window : undefined;
|
| 2047 |
+
var browserGlobal = browserWindow || {};
|
| 2048 |
+
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
|
| 2049 |
+
var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
|
| 2050 |
+
|
| 2051 |
+
// test for web worker but not in IE10
|
| 2052 |
+
var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
|
| 2053 |
+
|
| 2054 |
+
// node
|
| 2055 |
+
function useNextTick() {
|
| 2056 |
+
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
|
| 2057 |
+
// see https://github.com/cujojs/when/issues/410 for details
|
| 2058 |
+
return function () {
|
| 2059 |
+
return process.nextTick(flush);
|
| 2060 |
+
};
|
| 2061 |
+
}
|
| 2062 |
|
| 2063 |
+
// vertx
|
| 2064 |
+
function useVertxTimer() {
|
| 2065 |
+
return function () {
|
| 2066 |
+
vertxNext(flush);
|
| 2067 |
+
};
|
| 2068 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2069 |
|
| 2070 |
+
function useMutationObserver() {
|
| 2071 |
+
var iterations = 0;
|
| 2072 |
+
var observer = new BrowserMutationObserver(flush);
|
| 2073 |
+
var node = document.createTextNode('');
|
| 2074 |
+
observer.observe(node, { characterData: true });
|
|
|
|
| 2075 |
|
| 2076 |
+
return function () {
|
| 2077 |
+
node.data = iterations = ++iterations % 2;
|
| 2078 |
+
};
|
| 2079 |
+
}
|
|
|
|
| 2080 |
|
| 2081 |
+
// web worker
|
| 2082 |
+
function useMessageChannel() {
|
| 2083 |
+
var channel = new MessageChannel();
|
| 2084 |
+
channel.port1.onmessage = flush;
|
| 2085 |
+
return function () {
|
| 2086 |
+
return channel.port2.postMessage(0);
|
| 2087 |
+
};
|
| 2088 |
+
}
|
| 2089 |
|
| 2090 |
+
function useSetTimeout() {
|
| 2091 |
+
// Store setTimeout reference so es6-promise will be unaffected by
|
| 2092 |
+
// other code modifying setTimeout (like sinon.useFakeTimers())
|
| 2093 |
+
var globalSetTimeout = setTimeout;
|
| 2094 |
+
return function () {
|
| 2095 |
+
return globalSetTimeout(flush, 1);
|
| 2096 |
+
};
|
| 2097 |
+
}
|
| 2098 |
|
| 2099 |
+
var queue = new Array(1000);
|
| 2100 |
+
function flush() {
|
| 2101 |
+
for (var i = 0; i < len; i += 2) {
|
| 2102 |
+
var callback = queue[i];
|
| 2103 |
+
var arg = queue[i + 1];
|
| 2104 |
|
| 2105 |
+
callback(arg);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2106 |
|
| 2107 |
+
queue[i] = undefined;
|
| 2108 |
+
queue[i + 1] = undefined;
|
| 2109 |
+
}
|
| 2110 |
|
| 2111 |
+
len = 0;
|
| 2112 |
+
}
|
|
|
|
| 2113 |
|
| 2114 |
+
function attemptVertx() {
|
| 2115 |
+
try {
|
| 2116 |
+
var r = require;
|
| 2117 |
+
var vertx = __webpack_require__(16);
|
| 2118 |
+
vertxNext = vertx.runOnLoop || vertx.runOnContext;
|
| 2119 |
+
return useVertxTimer();
|
| 2120 |
+
} catch (e) {
|
| 2121 |
+
return useSetTimeout();
|
| 2122 |
+
}
|
| 2123 |
+
}
|
| 2124 |
|
| 2125 |
+
var scheduleFlush = undefined;
|
| 2126 |
+
// Decide what async method to use to triggering processing of queued callbacks:
|
| 2127 |
+
if (isNode) {
|
| 2128 |
+
scheduleFlush = useNextTick();
|
| 2129 |
+
} else if (BrowserMutationObserver) {
|
| 2130 |
+
scheduleFlush = useMutationObserver();
|
| 2131 |
+
} else if (isWorker) {
|
| 2132 |
+
scheduleFlush = useMessageChannel();
|
| 2133 |
+
} else if (browserWindow === undefined && "function" === 'function') {
|
| 2134 |
+
scheduleFlush = attemptVertx();
|
| 2135 |
+
} else {
|
| 2136 |
+
scheduleFlush = useSetTimeout();
|
| 2137 |
+
}
|
| 2138 |
|
| 2139 |
+
function then(onFulfillment, onRejection) {
|
| 2140 |
+
var _arguments = arguments;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2141 |
|
| 2142 |
+
var parent = this;
|
| 2143 |
|
| 2144 |
+
var child = new this.constructor(noop);
|
|
|
|
|
|
|
| 2145 |
|
| 2146 |
+
if (child[PROMISE_ID] === undefined) {
|
| 2147 |
+
makePromise(child);
|
| 2148 |
+
}
|
| 2149 |
|
| 2150 |
+
var _state = parent._state;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2151 |
|
| 2152 |
+
if (_state) {
|
| 2153 |
+
(function () {
|
| 2154 |
+
var callback = _arguments[_state - 1];
|
| 2155 |
+
asap(function () {
|
| 2156 |
+
return invokeCallback(_state, child, callback, parent._result);
|
| 2157 |
+
});
|
| 2158 |
+
})();
|
| 2159 |
+
} else {
|
| 2160 |
+
subscribe(parent, child, onFulfillment, onRejection);
|
| 2161 |
+
}
|
| 2162 |
|
| 2163 |
+
return child;
|
| 2164 |
+
}
|
|
|
|
| 2165 |
|
| 2166 |
+
/**
|
| 2167 |
+
`Promise.resolve` returns a promise that will become resolved with the
|
| 2168 |
+
passed `value`. It is shorthand for the following:
|
|
|
|
|
|
|
|
|
|
| 2169 |
|
| 2170 |
+
```javascript
|
| 2171 |
+
let promise = new Promise(function(resolve, reject){
|
| 2172 |
+
resolve(1);
|
| 2173 |
+
});
|
| 2174 |
|
| 2175 |
+
promise.then(function(value){
|
| 2176 |
+
// value === 1
|
| 2177 |
+
});
|
| 2178 |
+
```
|
| 2179 |
|
| 2180 |
+
Instead of writing the above, your code now simply becomes the following:
|
| 2181 |
|
| 2182 |
+
```javascript
|
| 2183 |
+
let promise = Promise.resolve(1);
|
|
|
|
| 2184 |
|
| 2185 |
+
promise.then(function(value){
|
| 2186 |
+
// value === 1
|
| 2187 |
+
});
|
| 2188 |
+
```
|
| 2189 |
+
|
| 2190 |
+
@method resolve
|
| 2191 |
+
@static
|
| 2192 |
+
@param {Any} value value that the returned promise will be resolved with
|
| 2193 |
+
Useful for tooling.
|
| 2194 |
+
@return {Promise} a promise that will become fulfilled with the given
|
| 2195 |
+
`value`
|
| 2196 |
+
*/
|
| 2197 |
+
function resolve(object) {
|
| 2198 |
+
/*jshint validthis:true */
|
| 2199 |
+
var Constructor = this;
|
| 2200 |
+
|
| 2201 |
+
if (object && typeof object === 'object' && object.constructor === Constructor) {
|
| 2202 |
+
return object;
|
| 2203 |
+
}
|
| 2204 |
|
| 2205 |
+
var promise = new Constructor(noop);
|
| 2206 |
+
_resolve(promise, object);
|
| 2207 |
+
return promise;
|
| 2208 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2209 |
|
| 2210 |
+
var PROMISE_ID = Math.random().toString(36).substring(16);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2211 |
|
| 2212 |
+
function noop() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2213 |
|
| 2214 |
+
var PENDING = void 0;
|
| 2215 |
+
var FULFILLED = 1;
|
| 2216 |
+
var REJECTED = 2;
|
| 2217 |
|
| 2218 |
+
var GET_THEN_ERROR = new ErrorObject();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2219 |
|
| 2220 |
+
function selfFulfillment() {
|
| 2221 |
+
return new TypeError("You cannot resolve a promise with itself");
|
| 2222 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2223 |
|
| 2224 |
+
function cannotReturnOwn() {
|
| 2225 |
+
return new TypeError('A promises callback cannot return that same promise.');
|
| 2226 |
+
}
|
| 2227 |
+
|
| 2228 |
+
function getThen(promise) {
|
| 2229 |
+
try {
|
| 2230 |
+
return promise.then;
|
| 2231 |
+
} catch (error) {
|
| 2232 |
+
GET_THEN_ERROR.error = error;
|
| 2233 |
+
return GET_THEN_ERROR;
|
| 2234 |
+
}
|
| 2235 |
+
}
|
| 2236 |
+
|
| 2237 |
+
function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
|
| 2238 |
+
try {
|
| 2239 |
+
then.call(value, fulfillmentHandler, rejectionHandler);
|
| 2240 |
+
} catch (e) {
|
| 2241 |
+
return e;
|
| 2242 |
+
}
|
| 2243 |
+
}
|
| 2244 |
|
| 2245 |
+
function handleForeignThenable(promise, thenable, then) {
|
| 2246 |
+
asap(function (promise) {
|
| 2247 |
+
var sealed = false;
|
| 2248 |
+
var error = tryThen(then, thenable, function (value) {
|
| 2249 |
+
if (sealed) {
|
| 2250 |
+
return;
|
| 2251 |
+
}
|
| 2252 |
+
sealed = true;
|
| 2253 |
+
if (thenable !== value) {
|
| 2254 |
+
_resolve(promise, value);
|
| 2255 |
} else {
|
| 2256 |
+
fulfill(promise, value);
|
| 2257 |
}
|
| 2258 |
+
}, function (reason) {
|
| 2259 |
+
if (sealed) {
|
| 2260 |
+
return;
|
|
|
|
|
|
|
| 2261 |
}
|
| 2262 |
+
sealed = true;
|
| 2263 |
|
| 2264 |
+
_reject(promise, reason);
|
| 2265 |
+
}, 'Settle: ' + (promise._label || ' unknown promise'));
|
| 2266 |
|
| 2267 |
+
if (!sealed && error) {
|
| 2268 |
+
sealed = true;
|
| 2269 |
+
_reject(promise, error);
|
| 2270 |
+
}
|
| 2271 |
+
}, promise);
|
| 2272 |
+
}
|
| 2273 |
|
| 2274 |
+
function handleOwnThenable(promise, thenable) {
|
| 2275 |
+
if (thenable._state === FULFILLED) {
|
| 2276 |
+
fulfill(promise, thenable._result);
|
| 2277 |
+
} else if (thenable._state === REJECTED) {
|
| 2278 |
+
_reject(promise, thenable._result);
|
| 2279 |
+
} else {
|
| 2280 |
+
subscribe(thenable, undefined, function (value) {
|
| 2281 |
+
return _resolve(promise, value);
|
| 2282 |
+
}, function (reason) {
|
| 2283 |
+
return _reject(promise, reason);
|
| 2284 |
+
});
|
| 2285 |
+
}
|
| 2286 |
+
}
|
| 2287 |
|
| 2288 |
+
function handleMaybeThenable(promise, maybeThenable, then$$) {
|
| 2289 |
+
if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) {
|
| 2290 |
+
handleOwnThenable(promise, maybeThenable);
|
| 2291 |
+
} else {
|
| 2292 |
+
if (then$$ === GET_THEN_ERROR) {
|
| 2293 |
+
_reject(promise, GET_THEN_ERROR.error);
|
| 2294 |
+
} else if (then$$ === undefined) {
|
| 2295 |
+
fulfill(promise, maybeThenable);
|
| 2296 |
+
} else if (isFunction(then$$)) {
|
| 2297 |
+
handleForeignThenable(promise, maybeThenable, then$$);
|
| 2298 |
+
} else {
|
| 2299 |
+
fulfill(promise, maybeThenable);
|
| 2300 |
}
|
| 2301 |
+
}
|
| 2302 |
+
}
|
| 2303 |
|
| 2304 |
+
function _resolve(promise, value) {
|
| 2305 |
+
if (promise === value) {
|
| 2306 |
+
_reject(promise, selfFulfillment());
|
| 2307 |
+
} else if (objectOrFunction(value)) {
|
| 2308 |
+
handleMaybeThenable(promise, value, getThen(value));
|
| 2309 |
+
} else {
|
| 2310 |
+
fulfill(promise, value);
|
| 2311 |
+
}
|
| 2312 |
+
}
|
| 2313 |
|
| 2314 |
+
function publishRejection(promise) {
|
| 2315 |
+
if (promise._onerror) {
|
| 2316 |
+
promise._onerror(promise._result);
|
| 2317 |
+
}
|
| 2318 |
|
| 2319 |
+
publish(promise);
|
| 2320 |
+
}
|
|
|
|
| 2321 |
|
| 2322 |
+
function fulfill(promise, value) {
|
| 2323 |
+
if (promise._state !== PENDING) {
|
| 2324 |
+
return;
|
| 2325 |
+
}
|
| 2326 |
|
| 2327 |
+
promise._result = value;
|
| 2328 |
+
promise._state = FULFILLED;
|
|
|
|
| 2329 |
|
| 2330 |
+
if (promise._subscribers.length !== 0) {
|
| 2331 |
+
asap(publish, promise);
|
| 2332 |
+
}
|
| 2333 |
+
}
|
| 2334 |
|
| 2335 |
+
function _reject(promise, reason) {
|
| 2336 |
+
if (promise._state !== PENDING) {
|
| 2337 |
+
return;
|
| 2338 |
+
}
|
| 2339 |
+
promise._state = REJECTED;
|
| 2340 |
+
promise._result = reason;
|
| 2341 |
|
| 2342 |
+
asap(publishRejection, promise);
|
| 2343 |
+
}
|
| 2344 |
|
| 2345 |
+
function subscribe(parent, child, onFulfillment, onRejection) {
|
| 2346 |
+
var _subscribers = parent._subscribers;
|
| 2347 |
+
var length = _subscribers.length;
|
| 2348 |
|
| 2349 |
+
parent._onerror = null;
|
|
|
|
|
|
|
| 2350 |
|
| 2351 |
+
_subscribers[length] = child;
|
| 2352 |
+
_subscribers[length + FULFILLED] = onFulfillment;
|
| 2353 |
+
_subscribers[length + REJECTED] = onRejection;
|
|
|
|
|
|
|
|
|
|
| 2354 |
|
| 2355 |
+
if (length === 0 && parent._state) {
|
| 2356 |
+
asap(publish, parent);
|
| 2357 |
+
}
|
| 2358 |
+
}
|
| 2359 |
|
| 2360 |
+
function publish(promise) {
|
| 2361 |
+
var subscribers = promise._subscribers;
|
| 2362 |
+
var settled = promise._state;
|
| 2363 |
|
| 2364 |
+
if (subscribers.length === 0) {
|
| 2365 |
+
return;
|
| 2366 |
+
}
|
| 2367 |
|
| 2368 |
+
var child = undefined,
|
| 2369 |
+
callback = undefined,
|
| 2370 |
+
detail = promise._result;
|
| 2371 |
+
|
| 2372 |
+
for (var i = 0; i < subscribers.length; i += 3) {
|
| 2373 |
+
child = subscribers[i];
|
| 2374 |
+
callback = subscribers[i + settled];
|
| 2375 |
+
|
| 2376 |
+
if (child) {
|
| 2377 |
+
invokeCallback(settled, child, callback, detail);
|
| 2378 |
+
} else {
|
| 2379 |
+
callback(detail);
|
| 2380 |
}
|
| 2381 |
+
}
|
| 2382 |
|
| 2383 |
+
promise._subscribers.length = 0;
|
| 2384 |
+
}
|
|
|
|
| 2385 |
|
| 2386 |
+
function ErrorObject() {
|
| 2387 |
+
this.error = null;
|
| 2388 |
+
}
|
| 2389 |
|
| 2390 |
+
var TRY_CATCH_ERROR = new ErrorObject();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2391 |
|
| 2392 |
+
function tryCatch(callback, detail) {
|
| 2393 |
+
try {
|
| 2394 |
+
return callback(detail);
|
| 2395 |
+
} catch (e) {
|
| 2396 |
+
TRY_CATCH_ERROR.error = e;
|
| 2397 |
+
return TRY_CATCH_ERROR;
|
| 2398 |
+
}
|
| 2399 |
+
}
|
| 2400 |
|
| 2401 |
+
function invokeCallback(settled, promise, callback, detail) {
|
| 2402 |
+
var hasCallback = isFunction(callback),
|
| 2403 |
+
value = undefined,
|
| 2404 |
+
error = undefined,
|
| 2405 |
+
succeeded = undefined,
|
| 2406 |
+
failed = undefined;
|
| 2407 |
|
| 2408 |
+
if (hasCallback) {
|
| 2409 |
+
value = tryCatch(callback, detail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2410 |
|
| 2411 |
+
if (value === TRY_CATCH_ERROR) {
|
| 2412 |
+
failed = true;
|
| 2413 |
+
error = value.error;
|
| 2414 |
+
value = null;
|
| 2415 |
+
} else {
|
| 2416 |
+
succeeded = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2417 |
}
|
| 2418 |
|
| 2419 |
+
if (promise === value) {
|
| 2420 |
+
_reject(promise, cannotReturnOwn());
|
| 2421 |
+
return;
|
| 2422 |
}
|
| 2423 |
+
} else {
|
| 2424 |
+
value = detail;
|
| 2425 |
+
succeeded = true;
|
| 2426 |
+
}
|
| 2427 |
|
| 2428 |
+
if (promise._state !== PENDING) {
|
| 2429 |
+
// noop
|
| 2430 |
+
} else if (hasCallback && succeeded) {
|
| 2431 |
+
_resolve(promise, value);
|
| 2432 |
+
} else if (failed) {
|
| 2433 |
+
_reject(promise, error);
|
| 2434 |
+
} else if (settled === FULFILLED) {
|
| 2435 |
+
fulfill(promise, value);
|
| 2436 |
+
} else if (settled === REJECTED) {
|
| 2437 |
+
_reject(promise, value);
|
| 2438 |
}
|
| 2439 |
+
}
|
| 2440 |
|
| 2441 |
+
function initializePromise(promise, resolver) {
|
| 2442 |
+
try {
|
| 2443 |
+
resolver(function resolvePromise(value) {
|
| 2444 |
+
_resolve(promise, value);
|
| 2445 |
+
}, function rejectPromise(reason) {
|
| 2446 |
+
_reject(promise, reason);
|
| 2447 |
+
});
|
| 2448 |
+
} catch (e) {
|
| 2449 |
+
_reject(promise, e);
|
| 2450 |
+
}
|
| 2451 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2452 |
|
| 2453 |
+
var id = 0;
|
| 2454 |
+
function nextId() {
|
| 2455 |
+
return id++;
|
| 2456 |
+
}
|
| 2457 |
|
| 2458 |
+
function makePromise(promise) {
|
| 2459 |
+
promise[PROMISE_ID] = id++;
|
| 2460 |
+
promise._state = undefined;
|
| 2461 |
+
promise._result = undefined;
|
| 2462 |
+
promise._subscribers = [];
|
| 2463 |
+
}
|
| 2464 |
|
| 2465 |
+
function Enumerator(Constructor, input) {
|
| 2466 |
+
this._instanceConstructor = Constructor;
|
| 2467 |
+
this.promise = new Constructor(noop);
|
| 2468 |
+
|
| 2469 |
+
if (!this.promise[PROMISE_ID]) {
|
| 2470 |
+
makePromise(this.promise);
|
| 2471 |
+
}
|
| 2472 |
|
| 2473 |
+
if (isArray(input)) {
|
| 2474 |
+
this._input = input;
|
| 2475 |
+
this.length = input.length;
|
| 2476 |
+
this._remaining = input.length;
|
|
|
|
|
|
|
| 2477 |
|
| 2478 |
+
this._result = new Array(this.length);
|
|
|
|
| 2479 |
|
| 2480 |
+
if (this.length === 0) {
|
| 2481 |
+
fulfill(this.promise, this._result);
|
| 2482 |
+
} else {
|
| 2483 |
+
this.length = this.length || 0;
|
| 2484 |
+
this._enumerate();
|
| 2485 |
+
if (this._remaining === 0) {
|
| 2486 |
+
fulfill(this.promise, this._result);
|
| 2487 |
+
}
|
| 2488 |
+
}
|
| 2489 |
+
} else {
|
| 2490 |
+
_reject(this.promise, validationError());
|
| 2491 |
+
}
|
| 2492 |
+
}
|
| 2493 |
|
| 2494 |
+
function validationError() {
|
| 2495 |
+
return new Error('Array Methods must be provided an Array');
|
| 2496 |
+
};
|
| 2497 |
|
| 2498 |
+
Enumerator.prototype._enumerate = function () {
|
| 2499 |
+
var length = this.length;
|
| 2500 |
+
var _input = this._input;
|
| 2501 |
|
| 2502 |
+
for (var i = 0; this._state === PENDING && i < length; i++) {
|
| 2503 |
+
this._eachEntry(_input[i], i);
|
| 2504 |
+
}
|
| 2505 |
+
};
|
|
|
|
| 2506 |
|
| 2507 |
+
Enumerator.prototype._eachEntry = function (entry, i) {
|
| 2508 |
+
var c = this._instanceConstructor;
|
| 2509 |
+
var resolve$$ = c.resolve;
|
| 2510 |
+
|
| 2511 |
+
if (resolve$$ === resolve) {
|
| 2512 |
+
var _then = getThen(entry);
|
| 2513 |
+
|
| 2514 |
+
if (_then === then && entry._state !== PENDING) {
|
| 2515 |
+
this._settledAt(entry._state, i, entry._result);
|
| 2516 |
+
} else if (typeof _then !== 'function') {
|
| 2517 |
+
this._remaining--;
|
| 2518 |
+
this._result[i] = entry;
|
| 2519 |
+
} else if (c === Promise) {
|
| 2520 |
+
var promise = new c(noop);
|
| 2521 |
+
handleMaybeThenable(promise, entry, _then);
|
| 2522 |
+
this._willSettleAt(promise, i);
|
| 2523 |
+
} else {
|
| 2524 |
+
this._willSettleAt(new c(function (resolve$$) {
|
| 2525 |
+
return resolve$$(entry);
|
| 2526 |
+
}), i);
|
| 2527 |
+
}
|
| 2528 |
+
} else {
|
| 2529 |
+
this._willSettleAt(resolve$$(entry), i);
|
| 2530 |
+
}
|
| 2531 |
+
};
|
| 2532 |
|
| 2533 |
+
Enumerator.prototype._settledAt = function (state, i, value) {
|
| 2534 |
+
var promise = this.promise;
|
| 2535 |
|
| 2536 |
+
if (promise._state === PENDING) {
|
| 2537 |
+
this._remaining--;
|
|
|
|
|
|
|
| 2538 |
|
| 2539 |
+
if (state === REJECTED) {
|
| 2540 |
+
_reject(promise, value);
|
| 2541 |
+
} else {
|
| 2542 |
+
this._result[i] = value;
|
| 2543 |
+
}
|
| 2544 |
+
}
|
| 2545 |
|
| 2546 |
+
if (this._remaining === 0) {
|
| 2547 |
+
fulfill(promise, this._result);
|
| 2548 |
+
}
|
| 2549 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2550 |
|
| 2551 |
+
Enumerator.prototype._willSettleAt = function (promise, i) {
|
| 2552 |
+
var enumerator = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2553 |
|
| 2554 |
+
subscribe(promise, undefined, function (value) {
|
| 2555 |
+
return enumerator._settledAt(FULFILLED, i, value);
|
| 2556 |
+
}, function (reason) {
|
| 2557 |
+
return enumerator._settledAt(REJECTED, i, reason);
|
| 2558 |
+
});
|
| 2559 |
+
};
|
| 2560 |
|
| 2561 |
+
/**
|
| 2562 |
+
`Promise.all` accepts an array of promises, and returns a new promise which
|
| 2563 |
+
is fulfilled with an array of fulfillment values for the passed promises, or
|
| 2564 |
+
rejected with the reason of the first passed promise to be rejected. It casts all
|
| 2565 |
+
elements of the passed iterable to promises as it runs this algorithm.
|
|
|
|
|
|
|
| 2566 |
|
| 2567 |
+
Example:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2568 |
|
| 2569 |
+
```javascript
|
| 2570 |
+
let promise1 = resolve(1);
|
| 2571 |
+
let promise2 = resolve(2);
|
| 2572 |
+
let promise3 = resolve(3);
|
| 2573 |
+
let promises = [ promise1, promise2, promise3 ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2574 |
|
| 2575 |
+
Promise.all(promises).then(function(array){
|
| 2576 |
+
// The array here would be [ 1, 2, 3 ];
|
| 2577 |
+
});
|
| 2578 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2579 |
|
| 2580 |
+
If any of the `promises` given to `all` are rejected, the first promise
|
| 2581 |
+
that is rejected will be given as an argument to the returned promises's
|
| 2582 |
+
rejection handler. For example:
|
| 2583 |
|
| 2584 |
+
Example:
|
|
|
|
|
|
|
|
|
|
| 2585 |
|
| 2586 |
+
```javascript
|
| 2587 |
+
let promise1 = resolve(1);
|
| 2588 |
+
let promise2 = reject(new Error("2"));
|
| 2589 |
+
let promise3 = reject(new Error("3"));
|
| 2590 |
+
let promises = [ promise1, promise2, promise3 ];
|
|
|
|
|
|
|
| 2591 |
|
| 2592 |
+
Promise.all(promises).then(function(array){
|
| 2593 |
+
// Code here never runs because there are rejected promises!
|
| 2594 |
+
}, function(error) {
|
| 2595 |
+
// error.message === "2"
|
| 2596 |
+
});
|
| 2597 |
+
```
|
| 2598 |
+
|
| 2599 |
+
@method all
|
| 2600 |
+
@static
|
| 2601 |
+
@param {Array} entries array of promises
|
| 2602 |
+
@param {String} label optional string for labeling the promise.
|
| 2603 |
+
Useful for tooling.
|
| 2604 |
+
@return {Promise} promise that is fulfilled when all `promises` have been
|
| 2605 |
+
fulfilled, or rejected if any of them become rejected.
|
| 2606 |
+
@static
|
| 2607 |
+
*/
|
| 2608 |
+
function all(entries) {
|
| 2609 |
+
return new Enumerator(this, entries).promise;
|
| 2610 |
+
}
|
| 2611 |
|
| 2612 |
+
/**
|
| 2613 |
+
`Promise.race` returns a new promise which is settled in the same way as the
|
| 2614 |
+
first passed promise to settle.
|
| 2615 |
+
|
| 2616 |
+
Example:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2617 |
|
| 2618 |
+
```javascript
|
| 2619 |
+
let promise1 = new Promise(function(resolve, reject){
|
| 2620 |
+
setTimeout(function(){
|
| 2621 |
+
resolve('promise 1');
|
| 2622 |
+
}, 200);
|
| 2623 |
+
});
|
| 2624 |
|
| 2625 |
+
let promise2 = new Promise(function(resolve, reject){
|
| 2626 |
+
setTimeout(function(){
|
| 2627 |
+
resolve('promise 2');
|
| 2628 |
+
}, 100);
|
| 2629 |
+
});
|
| 2630 |
|
| 2631 |
+
Promise.race([promise1, promise2]).then(function(result){
|
| 2632 |
+
// result === 'promise 2' because it was resolved before promise1
|
| 2633 |
+
// was resolved.
|
| 2634 |
+
});
|
| 2635 |
+
```
|
| 2636 |
+
|
| 2637 |
+
`Promise.race` is deterministic in that only the state of the first
|
| 2638 |
+
settled promise matters. For example, even if other promises given to the
|
| 2639 |
+
`promises` array argument are resolved, but the first settled promise has
|
| 2640 |
+
become rejected before the other promises became fulfilled, the returned
|
| 2641 |
+
promise will become rejected:
|
| 2642 |
+
|
| 2643 |
+
```javascript
|
| 2644 |
+
let promise1 = new Promise(function(resolve, reject){
|
| 2645 |
+
setTimeout(function(){
|
| 2646 |
+
resolve('promise 1');
|
| 2647 |
+
}, 200);
|
| 2648 |
+
});
|
| 2649 |
|
| 2650 |
+
let promise2 = new Promise(function(resolve, reject){
|
| 2651 |
+
setTimeout(function(){
|
| 2652 |
+
reject(new Error('promise 2'));
|
| 2653 |
+
}, 100);
|
| 2654 |
+
});
|
| 2655 |
+
|
| 2656 |
+
Promise.race([promise1, promise2]).then(function(result){
|
| 2657 |
+
// Code here never runs
|
| 2658 |
+
}, function(reason){
|
| 2659 |
+
// reason.message === 'promise 2' because promise 2 became rejected before
|
| 2660 |
+
// promise 1 became fulfilled
|
| 2661 |
+
});
|
| 2662 |
+
```
|
| 2663 |
+
|
| 2664 |
+
An example real-world use case is implementing timeouts:
|
| 2665 |
+
|
| 2666 |
+
```javascript
|
| 2667 |
+
Promise.race([ajax('foo.json'), timeout(5000)])
|
| 2668 |
+
```
|
| 2669 |
+
|
| 2670 |
+
@method race
|
| 2671 |
+
@static
|
| 2672 |
+
@param {Array} promises array of promises to observe
|
| 2673 |
+
Useful for tooling.
|
| 2674 |
+
@return {Promise} a promise which settles in the same way as the first passed
|
| 2675 |
+
promise to settle.
|
| 2676 |
+
*/
|
| 2677 |
+
function race(entries) {
|
| 2678 |
+
/*jshint validthis:true */
|
| 2679 |
+
var Constructor = this;
|
| 2680 |
+
|
| 2681 |
+
if (!isArray(entries)) {
|
| 2682 |
+
return new Constructor(function (_, reject) {
|
| 2683 |
+
return reject(new TypeError('You must pass an array to race.'));
|
| 2684 |
+
});
|
| 2685 |
+
} else {
|
| 2686 |
+
return new Constructor(function (resolve, reject) {
|
| 2687 |
+
var length = entries.length;
|
| 2688 |
+
for (var i = 0; i < length; i++) {
|
| 2689 |
+
Constructor.resolve(entries[i]).then(resolve, reject);
|
| 2690 |
}
|
| 2691 |
+
});
|
| 2692 |
+
}
|
| 2693 |
+
}
|
| 2694 |
|
| 2695 |
+
/**
|
| 2696 |
+
`Promise.reject` returns a promise rejected with the passed `reason`.
|
| 2697 |
+
It is shorthand for the following:
|
| 2698 |
|
| 2699 |
+
```javascript
|
| 2700 |
+
let promise = new Promise(function(resolve, reject){
|
| 2701 |
+
reject(new Error('WHOOPS'));
|
| 2702 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2703 |
|
| 2704 |
+
promise.then(function(value){
|
| 2705 |
+
// Code here doesn't run because the promise is rejected!
|
| 2706 |
+
}, function(reason){
|
| 2707 |
+
// reason.message === 'WHOOPS'
|
| 2708 |
+
});
|
| 2709 |
+
```
|
| 2710 |
|
| 2711 |
+
Instead of writing the above, your code now simply becomes the following:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2712 |
|
| 2713 |
+
```javascript
|
| 2714 |
+
let promise = Promise.reject(new Error('WHOOPS'));
|
| 2715 |
|
| 2716 |
+
promise.then(function(value){
|
| 2717 |
+
// Code here doesn't run because the promise is rejected!
|
| 2718 |
+
}, function(reason){
|
| 2719 |
+
// reason.message === 'WHOOPS'
|
| 2720 |
+
});
|
| 2721 |
+
```
|
| 2722 |
+
|
| 2723 |
+
@method reject
|
| 2724 |
+
@static
|
| 2725 |
+
@param {Any} reason value that the returned promise will be rejected with.
|
| 2726 |
+
Useful for tooling.
|
| 2727 |
+
@return {Promise} a promise rejected with the given `reason`.
|
| 2728 |
+
*/
|
| 2729 |
+
function reject(reason) {
|
| 2730 |
+
/*jshint validthis:true */
|
| 2731 |
+
var Constructor = this;
|
| 2732 |
+
var promise = new Constructor(noop);
|
| 2733 |
+
_reject(promise, reason);
|
| 2734 |
+
return promise;
|
| 2735 |
+
}
|
| 2736 |
|
| 2737 |
+
function needsResolver() {
|
| 2738 |
+
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
|
| 2739 |
+
}
|
| 2740 |
|
| 2741 |
+
function needsNew() {
|
| 2742 |
+
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
|
| 2743 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2744 |
|
| 2745 |
+
/**
|
| 2746 |
+
Promise objects represent the eventual result of an asynchronous operation. The
|
| 2747 |
+
primary way of interacting with a promise is through its `then` method, which
|
| 2748 |
+
registers callbacks to receive either a promise's eventual value or the reason
|
| 2749 |
+
why the promise cannot be fulfilled.
|
| 2750 |
|
| 2751 |
+
Terminology
|
| 2752 |
+
-----------
|
| 2753 |
|
| 2754 |
+
- `promise` is an object or function with a `then` method whose behavior conforms to this specification.
|
| 2755 |
+
- `thenable` is an object or function that defines a `then` method.
|
| 2756 |
+
- `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
|
| 2757 |
+
- `exception` is a value that is thrown using the throw statement.
|
| 2758 |
+
- `reason` is a value that indicates why a promise was rejected.
|
| 2759 |
+
- `settled` the final resting state of a promise, fulfilled or rejected.
|
| 2760 |
|
| 2761 |
+
A promise can be in one of three states: pending, fulfilled, or rejected.
|
| 2762 |
|
| 2763 |
+
Promises that are fulfilled have a fulfillment value and are in the fulfilled
|
| 2764 |
+
state. Promises that are rejected have a rejection reason and are in the
|
| 2765 |
+
rejected state. A fulfillment value is never a thenable.
|
| 2766 |
|
| 2767 |
+
Promises can also be said to *resolve* a value. If this value is also a
|
| 2768 |
+
promise, then the original promise's settled state will match the value's
|
| 2769 |
+
settled state. So a promise that *resolves* a promise that rejects will
|
| 2770 |
+
itself reject, and a promise that *resolves* a promise that fulfills will
|
| 2771 |
+
itself fulfill.
|
| 2772 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2773 |
|
| 2774 |
+
Basic Usage:
|
| 2775 |
+
------------
|
| 2776 |
|
| 2777 |
+
```js
|
| 2778 |
+
let promise = new Promise(function(resolve, reject) {
|
| 2779 |
+
// on success
|
| 2780 |
+
resolve(value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2781 |
|
| 2782 |
+
// on failure
|
| 2783 |
+
reject(reason);
|
| 2784 |
+
});
|
|
|
|
|
|
|
|
|
|
| 2785 |
|
| 2786 |
+
promise.then(function(value) {
|
| 2787 |
+
// on fulfillment
|
| 2788 |
+
}, function(reason) {
|
| 2789 |
+
// on rejection
|
| 2790 |
+
});
|
| 2791 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2792 |
|
| 2793 |
+
Advanced Usage:
|
| 2794 |
+
---------------
|
|
|
|
|
|
|
| 2795 |
|
| 2796 |
+
Promises shine when abstracting away asynchronous interactions such as
|
| 2797 |
+
`XMLHttpRequest`s.
|
| 2798 |
|
| 2799 |
+
```js
|
| 2800 |
+
function getJSON(url) {
|
| 2801 |
+
return new Promise(function(resolve, reject){
|
| 2802 |
+
let xhr = new XMLHttpRequest();
|
| 2803 |
+
|
| 2804 |
+
xhr.open('GET', url);
|
| 2805 |
+
xhr.onreadystatechange = handler;
|
| 2806 |
+
xhr.responseType = 'json';
|
| 2807 |
+
xhr.setRequestHeader('Accept', 'application/json');
|
| 2808 |
+
xhr.send();
|
| 2809 |
+
|
| 2810 |
+
function handler() {
|
| 2811 |
+
if (this.readyState === this.DONE) {
|
| 2812 |
+
if (this.status === 200) {
|
| 2813 |
+
resolve(this.response);
|
| 2814 |
+
} else {
|
| 2815 |
+
reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
|
| 2816 |
}
|
| 2817 |
}
|
| 2818 |
+
};
|
| 2819 |
+
});
|
| 2820 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2821 |
|
| 2822 |
+
getJSON('/posts.json').then(function(json) {
|
| 2823 |
+
// on fulfillment
|
| 2824 |
+
}, function(reason) {
|
| 2825 |
+
// on rejection
|
| 2826 |
+
});
|
| 2827 |
+
```
|
| 2828 |
|
| 2829 |
+
Unlike callbacks, promises are great composable primitives.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2830 |
|
| 2831 |
+
```js
|
| 2832 |
+
Promise.all([
|
| 2833 |
+
getJSON('/posts'),
|
| 2834 |
+
getJSON('/comments')
|
| 2835 |
+
]).then(function(values){
|
| 2836 |
+
values[0] // => postsJSON
|
| 2837 |
+
values[1] // => commentsJSON
|
| 2838 |
|
| 2839 |
+
return values;
|
| 2840 |
+
});
|
| 2841 |
+
```
|
| 2842 |
+
|
| 2843 |
+
@class Promise
|
| 2844 |
+
@param {function} resolver
|
| 2845 |
+
Useful for tooling.
|
| 2846 |
+
@constructor
|
| 2847 |
+
*/
|
| 2848 |
+
function Promise(resolver) {
|
| 2849 |
+
this[PROMISE_ID] = nextId();
|
| 2850 |
+
this._result = this._state = undefined;
|
| 2851 |
+
this._subscribers = [];
|
| 2852 |
+
|
| 2853 |
+
if (noop !== resolver) {
|
| 2854 |
+
typeof resolver !== 'function' && needsResolver();
|
| 2855 |
+
this instanceof Promise ? initializePromise(this, resolver) : needsNew();
|
| 2856 |
+
}
|
| 2857 |
+
}
|
| 2858 |
|
| 2859 |
+
Promise.all = all;
|
| 2860 |
+
Promise.race = race;
|
| 2861 |
+
Promise.resolve = resolve;
|
| 2862 |
+
Promise.reject = reject;
|
| 2863 |
+
Promise._setScheduler = setScheduler;
|
| 2864 |
+
Promise._setAsap = setAsap;
|
| 2865 |
+
Promise._asap = asap;
|
| 2866 |
+
|
| 2867 |
+
Promise.prototype = {
|
| 2868 |
+
constructor: Promise,
|
| 2869 |
+
|
| 2870 |
+
/**
|
| 2871 |
+
The primary way of interacting with a promise is through its `then` method,
|
| 2872 |
+
which registers callbacks to receive either a promise's eventual value or the
|
| 2873 |
+
reason why the promise cannot be fulfilled.
|
| 2874 |
+
|
| 2875 |
+
```js
|
| 2876 |
+
findUser().then(function(user){
|
| 2877 |
+
// user is available
|
| 2878 |
+
}, function(reason){
|
| 2879 |
+
// user is unavailable, and you are given the reason why
|
| 2880 |
+
});
|
| 2881 |
+
```
|
| 2882 |
+
|
| 2883 |
+
Chaining
|
| 2884 |
+
--------
|
| 2885 |
+
|
| 2886 |
+
The return value of `then` is itself a promise. This second, 'downstream'
|
| 2887 |
+
promise is resolved with the return value of the first promise's fulfillment
|
| 2888 |
+
or rejection handler, or rejected if the handler throws an exception.
|
| 2889 |
+
|
| 2890 |
+
```js
|
| 2891 |
+
findUser().then(function (user) {
|
| 2892 |
+
return user.name;
|
| 2893 |
+
}, function (reason) {
|
| 2894 |
+
return 'default name';
|
| 2895 |
+
}).then(function (userName) {
|
| 2896 |
+
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it
|
| 2897 |
+
// will be `'default name'`
|
| 2898 |
+
});
|
| 2899 |
+
|
| 2900 |
+
findUser().then(function (user) {
|
| 2901 |
+
throw new Error('Found user, but still unhappy');
|
| 2902 |
+
}, function (reason) {
|
| 2903 |
+
throw new Error('`findUser` rejected and we're unhappy');
|
| 2904 |
+
}).then(function (value) {
|
| 2905 |
+
// never reached
|
| 2906 |
+
}, function (reason) {
|
| 2907 |
+
// if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
|
| 2908 |
+
// If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
|
| 2909 |
+
});
|
| 2910 |
+
```
|
| 2911 |
+
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
|
| 2912 |
+
|
| 2913 |
+
```js
|
| 2914 |
+
findUser().then(function (user) {
|
| 2915 |
+
throw new PedagogicalException('Upstream error');
|
| 2916 |
+
}).then(function (value) {
|
| 2917 |
+
// never reached
|
| 2918 |
+
}).then(function (value) {
|
| 2919 |
+
// never reached
|
| 2920 |
+
}, function (reason) {
|
| 2921 |
+
// The `PedgagocialException` is propagated all the way down to here
|
| 2922 |
+
});
|
| 2923 |
+
```
|
| 2924 |
+
|
| 2925 |
+
Assimilation
|
| 2926 |
+
------------
|
| 2927 |
+
|
| 2928 |
+
Sometimes the value you want to propagate to a downstream promise can only be
|
| 2929 |
+
retrieved asynchronously. This can be achieved by returning a promise in the
|
| 2930 |
+
fulfillment or rejection handler. The downstream promise will then be pending
|
| 2931 |
+
until the returned promise is settled. This is called *assimilation*.
|
| 2932 |
+
|
| 2933 |
+
```js
|
| 2934 |
+
findUser().then(function (user) {
|
| 2935 |
+
return findCommentsByAuthor(user);
|
| 2936 |
+
}).then(function (comments) {
|
| 2937 |
+
// The user's comments are now available
|
| 2938 |
+
});
|
| 2939 |
+
```
|
| 2940 |
+
|
| 2941 |
+
If the assimliated promise rejects, then the downstream promise will also reject.
|
| 2942 |
+
|
| 2943 |
+
```js
|
| 2944 |
+
findUser().then(function (user) {
|
| 2945 |
+
return findCommentsByAuthor(user);
|
| 2946 |
+
}).then(function (comments) {
|
| 2947 |
+
// If `findCommentsByAuthor` fulfills, we'll have the value here
|
| 2948 |
+
}, function (reason) {
|
| 2949 |
+
// If `findCommentsByAuthor` rejects, we'll have the reason here
|
| 2950 |
+
});
|
| 2951 |
+
```
|
| 2952 |
+
|
| 2953 |
+
Simple Example
|
| 2954 |
+
--------------
|
| 2955 |
+
|
| 2956 |
+
Synchronous Example
|
| 2957 |
+
|
| 2958 |
+
```javascript
|
| 2959 |
+
let result;
|
| 2960 |
+
|
| 2961 |
+
try {
|
| 2962 |
+
result = findResult();
|
| 2963 |
+
// success
|
| 2964 |
+
} catch(reason) {
|
| 2965 |
+
// failure
|
| 2966 |
+
}
|
| 2967 |
+
```
|
| 2968 |
+
|
| 2969 |
+
Errback Example
|
| 2970 |
+
|
| 2971 |
+
```js
|
| 2972 |
+
findResult(function(result, err){
|
| 2973 |
+
if (err) {
|
| 2974 |
+
// failure
|
| 2975 |
+
} else {
|
| 2976 |
+
// success
|
| 2977 |
}
|
| 2978 |
+
});
|
| 2979 |
+
```
|
| 2980 |
+
|
| 2981 |
+
Promise Example;
|
| 2982 |
+
|
| 2983 |
+
```javascript
|
| 2984 |
+
findResult().then(function(result){
|
| 2985 |
+
// success
|
| 2986 |
+
}, function(reason){
|
| 2987 |
+
// failure
|
| 2988 |
+
});
|
| 2989 |
+
```
|
| 2990 |
+
|
| 2991 |
+
Advanced Example
|
| 2992 |
+
--------------
|
| 2993 |
+
|
| 2994 |
+
Synchronous Example
|
| 2995 |
+
|
| 2996 |
+
```javascript
|
| 2997 |
+
let author, books;
|
| 2998 |
+
|
| 2999 |
+
try {
|
| 3000 |
+
author = findAuthor();
|
| 3001 |
+
books = findBooksByAuthor(author);
|
| 3002 |
+
// success
|
| 3003 |
+
} catch(reason) {
|
| 3004 |
+
// failure
|
| 3005 |
+
}
|
| 3006 |
+
```
|
| 3007 |
+
|
| 3008 |
+
Errback Example
|
| 3009 |
+
|
| 3010 |
+
```js
|
| 3011 |
+
|
| 3012 |
+
function foundBooks(books) {
|
| 3013 |
+
|
| 3014 |
+
}
|
| 3015 |
+
|
| 3016 |
+
function failure(reason) {
|
| 3017 |
+
|
| 3018 |
+
}
|
| 3019 |
+
|
| 3020 |
+
findAuthor(function(author, err){
|
| 3021 |
+
if (err) {
|
| 3022 |
+
failure(err);
|
| 3023 |
+
// failure
|
| 3024 |
+
} else {
|
| 3025 |
+
try {
|
| 3026 |
+
findBoooksByAuthor(author, function(books, err) {
|
| 3027 |
+
if (err) {
|
| 3028 |
+
failure(err);
|
| 3029 |
+
} else {
|
| 3030 |
+
try {
|
| 3031 |
+
foundBooks(books);
|
| 3032 |
+
} catch(reason) {
|
| 3033 |
+
failure(reason);
|
| 3034 |
+
}
|
| 3035 |
+
}
|
| 3036 |
+
});
|
| 3037 |
+
} catch(error) {
|
| 3038 |
+
failure(err);
|
| 3039 |
+
}
|
| 3040 |
+
// success
|
| 3041 |
}
|
| 3042 |
+
});
|
| 3043 |
+
```
|
| 3044 |
+
|
| 3045 |
+
Promise Example;
|
| 3046 |
+
|
| 3047 |
+
```javascript
|
| 3048 |
+
findAuthor().
|
| 3049 |
+
then(findBooksByAuthor).
|
| 3050 |
+
then(function(books){
|
| 3051 |
+
// found books
|
| 3052 |
+
}).catch(function(reason){
|
| 3053 |
+
// something went wrong
|
| 3054 |
+
});
|
| 3055 |
+
```
|
| 3056 |
+
|
| 3057 |
+
@method then
|
| 3058 |
+
@param {Function} onFulfilled
|
| 3059 |
+
@param {Function} onRejected
|
| 3060 |
+
Useful for tooling.
|
| 3061 |
+
@return {Promise}
|
| 3062 |
+
*/
|
| 3063 |
+
then: then,
|
| 3064 |
+
|
| 3065 |
+
/**
|
| 3066 |
+
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
|
| 3067 |
+
as the catch block of a try/catch statement.
|
| 3068 |
+
|
| 3069 |
+
```js
|
| 3070 |
+
function findAuthor(){
|
| 3071 |
+
throw new Error('couldn't find that author');
|
| 3072 |
+
}
|
| 3073 |
+
|
| 3074 |
+
// synchronous
|
| 3075 |
+
try {
|
| 3076 |
+
findAuthor();
|
| 3077 |
+
} catch(reason) {
|
| 3078 |
+
// something went wrong
|
| 3079 |
+
}
|
| 3080 |
+
|
| 3081 |
+
// async with promises
|
| 3082 |
+
findAuthor().catch(function(reason){
|
| 3083 |
+
// something went wrong
|
| 3084 |
+
});
|
| 3085 |
+
```
|
| 3086 |
+
|
| 3087 |
+
@method catch
|
| 3088 |
+
@param {Function} onRejection
|
| 3089 |
+
Useful for tooling.
|
| 3090 |
+
@return {Promise}
|
| 3091 |
+
*/
|
| 3092 |
+
'catch': function _catch(onRejection) {
|
| 3093 |
+
return this.then(null, onRejection);
|
| 3094 |
+
}
|
| 3095 |
+
};
|
| 3096 |
|
| 3097 |
+
function polyfill() {
|
| 3098 |
+
var local = undefined;
|
| 3099 |
|
| 3100 |
+
if (typeof global !== 'undefined') {
|
| 3101 |
+
local = global;
|
| 3102 |
+
} else if (typeof self !== 'undefined') {
|
| 3103 |
+
local = self;
|
| 3104 |
+
} else {
|
| 3105 |
+
try {
|
| 3106 |
+
local = Function('return this')();
|
| 3107 |
+
} catch (e) {
|
| 3108 |
+
throw new Error('polyfill failed because global object is unavailable in this environment');
|
| 3109 |
+
}
|
| 3110 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3111 |
|
| 3112 |
+
var P = local.Promise;
|
| 3113 |
|
| 3114 |
+
if (P) {
|
| 3115 |
+
var promiseToString = null;
|
| 3116 |
+
try {
|
| 3117 |
+
promiseToString = Object.prototype.toString.call(P.resolve());
|
| 3118 |
+
} catch (e) {
|
| 3119 |
+
// silently ignored
|
| 3120 |
+
}
|
| 3121 |
|
| 3122 |
+
if (promiseToString === '[object Promise]' && !P.cast) {
|
| 3123 |
+
return;
|
| 3124 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3125 |
}
|
| 3126 |
|
| 3127 |
+
local.Promise = Promise;
|
| 3128 |
+
}
|
| 3129 |
+
|
| 3130 |
+
polyfill();
|
| 3131 |
+
// Strange compat..
|
| 3132 |
+
Promise.polyfill = polyfill;
|
| 3133 |
+
Promise.Promise = Promise;
|
| 3134 |
|
| 3135 |
+
return Promise;
|
| 3136 |
|
| 3137 |
+
})));
|
| 3138 |
+
//# sourceMappingURL=es6-promise.map
|
| 3139 |
|
| 3140 |
/*** EXPORTS FROM exports-loader ***/
|
| 3141 |
module.exports = global.Promise;
|
| 3142 |
}.call(global));
|
| 3143 |
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15), __webpack_require__(14), (function() { return this; }())))
|
| 3144 |
|
| 3145 |
/***/ },
|
| 3146 |
/* 15 */
|
| 3147 |
/***/ function(module, exports) {
|
| 3148 |
|
| 3149 |
// shim for using process in browser
|
|
|
|
| 3150 |
var process = module.exports = {};
|
| 3151 |
|
| 3152 |
+
// cached from whatever global is present so that test runners that stub it
|
| 3153 |
+
// don't break things. But we need to wrap it in a try catch in case it is
|
| 3154 |
+
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
| 3155 |
+
// function because try/catches deoptimize in certain engines.
|
| 3156 |
+
|
| 3157 |
+
var cachedSetTimeout;
|
| 3158 |
+
var cachedClearTimeout;
|
| 3159 |
+
|
| 3160 |
+
function defaultSetTimout() {
|
| 3161 |
+
throw new Error('setTimeout has not been defined');
|
| 3162 |
+
}
|
| 3163 |
+
function defaultClearTimeout () {
|
| 3164 |
+
throw new Error('clearTimeout has not been defined');
|
| 3165 |
+
}
|
| 3166 |
+
(function () {
|
| 3167 |
+
try {
|
| 3168 |
+
if (typeof setTimeout === 'function') {
|
| 3169 |
+
cachedSetTimeout = setTimeout;
|
| 3170 |
+
} else {
|
| 3171 |
+
cachedSetTimeout = defaultSetTimout;
|
| 3172 |
+
}
|
| 3173 |
+
} catch (e) {
|
| 3174 |
+
cachedSetTimeout = defaultSetTimout;
|
| 3175 |
+
}
|
| 3176 |
+
try {
|
| 3177 |
+
if (typeof clearTimeout === 'function') {
|
| 3178 |
+
cachedClearTimeout = clearTimeout;
|
| 3179 |
+
} else {
|
| 3180 |
+
cachedClearTimeout = defaultClearTimeout;
|
| 3181 |
+
}
|
| 3182 |
+
} catch (e) {
|
| 3183 |
+
cachedClearTimeout = defaultClearTimeout;
|
| 3184 |
+
}
|
| 3185 |
+
} ())
|
| 3186 |
+
function runTimeout(fun) {
|
| 3187 |
+
if (cachedSetTimeout === setTimeout) {
|
| 3188 |
+
//normal enviroments in sane situations
|
| 3189 |
+
return setTimeout(fun, 0);
|
| 3190 |
+
}
|
| 3191 |
+
// if setTimeout wasn't available but was latter defined
|
| 3192 |
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
| 3193 |
+
cachedSetTimeout = setTimeout;
|
| 3194 |
+
return setTimeout(fun, 0);
|
| 3195 |
+
}
|
| 3196 |
+
try {
|
| 3197 |
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
| 3198 |
+
return cachedSetTimeout(fun, 0);
|
| 3199 |
+
} catch(e){
|
| 3200 |
+
try {
|
| 3201 |
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
| 3202 |
+
return cachedSetTimeout.call(null, fun, 0);
|
| 3203 |
+
} catch(e){
|
| 3204 |
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
| 3205 |
+
return cachedSetTimeout.call(this, fun, 0);
|
| 3206 |
+
}
|
| 3207 |
+
}
|
| 3208 |
+
|
| 3209 |
+
|
| 3210 |
+
}
|
| 3211 |
+
function runClearTimeout(marker) {
|
| 3212 |
+
if (cachedClearTimeout === clearTimeout) {
|
| 3213 |
+
//normal enviroments in sane situations
|
| 3214 |
+
return clearTimeout(marker);
|
| 3215 |
+
}
|
| 3216 |
+
// if clearTimeout wasn't available but was latter defined
|
| 3217 |
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
| 3218 |
+
cachedClearTimeout = clearTimeout;
|
| 3219 |
+
return clearTimeout(marker);
|
| 3220 |
+
}
|
| 3221 |
+
try {
|
| 3222 |
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
| 3223 |
+
return cachedClearTimeout(marker);
|
| 3224 |
+
} catch (e){
|
| 3225 |
+
try {
|
| 3226 |
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
| 3227 |
+
return cachedClearTimeout.call(null, marker);
|
| 3228 |
+
} catch (e){
|
| 3229 |
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
| 3230 |
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
| 3231 |
+
return cachedClearTimeout.call(this, marker);
|
| 3232 |
+
}
|
| 3233 |
+
}
|
| 3234 |
+
|
| 3235 |
|
| 3236 |
+
|
| 3237 |
+
}
|
| 3238 |
var queue = [];
|
| 3239 |
var draining = false;
|
| 3240 |
var currentQueue;
|
| 3259 |
if (draining) {
|
| 3260 |
return;
|
| 3261 |
}
|
| 3262 |
+
var timeout = runTimeout(cleanUpNextTick);
|
| 3263 |
draining = true;
|
| 3264 |
|
| 3265 |
var len = queue.length;
|
| 3276 |
}
|
| 3277 |
currentQueue = null;
|
| 3278 |
draining = false;
|
| 3279 |
+
runClearTimeout(timeout);
|
| 3280 |
}
|
| 3281 |
|
| 3282 |
process.nextTick = function (fun) {
|
| 3288 |
}
|
| 3289 |
queue.push(new Item(fun, args));
|
| 3290 |
if (queue.length === 1 && !draining) {
|
| 3291 |
+
runTimeout(drainQueue);
|
| 3292 |
}
|
| 3293 |
};
|
| 3294 |
|
| 3330 |
|
| 3331 |
/***/ },
|
| 3332 |
/* 16 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3333 |
/***/ function(module, exports) {
|
| 3334 |
|
| 3335 |
/* (ignored) */
|
| 3336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3337 |
/***/ }
|
| 3338 |
/******/ ]);
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: yani.iliev, bangelov, pimjitsawang
|
|
| 3 |
Tags: move, transfer, copy, migrate, backup, clone, restore, db migration, wordpress migration, website migration, database export, database import, apoyo, sauvegarde, di riserva, バックアップ
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 4.8
|
| 6 |
-
Stable tag: 6.
|
| 7 |
License: GPLv2 or later
|
| 8 |
|
| 9 |
Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable.
|
|
@@ -90,6 +90,11 @@ Alternatively you can download the plugin using the download button on this page
|
|
| 90 |
3. Plugin Menu
|
| 91 |
|
| 92 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
= 6.49 =
|
| 94 |
**Changed**
|
| 95 |
|
| 3 |
Tags: move, transfer, copy, migrate, backup, clone, restore, db migration, wordpress migration, website migration, database export, database import, apoyo, sauvegarde, di riserva, バックアップ
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 4.8
|
| 6 |
+
Stable tag: 6.50
|
| 7 |
License: GPLv2 or later
|
| 8 |
|
| 9 |
Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable.
|
| 90 |
3. Plugin Menu
|
| 91 |
|
| 92 |
== Changelog ==
|
| 93 |
+
= 6.50 =
|
| 94 |
+
**Fixed**
|
| 95 |
+
|
| 96 |
+
* Stuck on preparing to import
|
| 97 |
+
|
| 98 |
= 6.49 =
|
| 99 |
**Changed**
|
| 100 |
|
