less 2.6.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +3 -2
- package/CHANGELOG.md +26 -1
- package/Gruntfile.js +2 -3
- package/README.md +1 -1
- package/appveyor.yml +1 -0
- package/bin/lessc +47 -23
- package/dist/less.js +678 -374
- package/dist/less.min.js +9 -13
- package/lib/less/environment/abstract-file-manager.js +2 -2
- package/lib/less/functions/color.js +1 -1
- package/lib/less/index.js +1 -1
- package/lib/less/parser/parser-input.js +2 -2
- package/lib/less/parser/parser.js +45 -13
- package/lib/less/tree/anonymous.js +1 -1
- package/lib/less/tree/call.js +7 -4
- package/lib/less/tree/comment.js +2 -0
- package/lib/less/tree/directive.js +1 -0
- package/lib/less/tree/extend.js +1 -0
- package/lib/less/tree/import.js +1 -0
- package/lib/less/tree/media.js +1 -0
- package/lib/less/tree/mixin-call.js +1 -0
- package/lib/less/tree/mixin-definition.js +1 -0
- package/lib/less/tree/rule.js +1 -0
- package/lib/less/tree/ruleset-call.js +1 -0
- package/lib/less/tree/ruleset.js +1 -0
- package/lib/less/visitors/extend-visitor.js +5 -5
- package/lib/less/visitors/to-css-visitor.js +20 -10
- package/lib/less-browser/index.js +48 -25
- package/lib/less-node/file-manager.js +1 -1
- package/lib/less-node/lessc-helper.js +2 -2
- package/lib/source-map/source-map-0.1.31.js +1 -1
- package/package.json +25 -18
- package/test/browser/common.js +29 -8
- package/test/browser/less/console-errors/test-error.txt +1 -1
- package/test/browser/less.js +13 -17
- package/test/browser/runner-production-options.js +1 -1
- package/test/css/no-strict-math/no-sm-operations.css +3 -0
- package/test/css/operations.css +1 -1
- package/test/css/plugin.css +5 -0
- package/test/less/comments.less +1 -1
- package/test/less/errors/detached-ruleset-3.txt +1 -1
- package/test/less/errors/functions-1.less +2 -0
- package/test/less/errors/functions-1.txt +3 -0
- package/test/less/errors/functions-10-keyword.less +2 -0
- package/test/less/errors/functions-10-keyword.txt +3 -0
- package/test/less/errors/functions-11-operation.less +2 -0
- package/test/less/errors/functions-11-operation.txt +3 -0
- package/test/less/errors/functions-12-quoted.less +2 -0
- package/test/less/errors/functions-12-quoted.txt +3 -0
- package/test/less/errors/functions-13-selector.less +2 -0
- package/test/less/errors/functions-13-selector.txt +3 -0
- package/test/less/errors/functions-14-url.less +2 -0
- package/test/less/errors/functions-14-url.txt +3 -0
- package/test/less/errors/functions-15-value.less +2 -0
- package/test/less/errors/functions-15-value.txt +3 -0
- package/test/less/errors/functions-2-alpha.less +2 -0
- package/test/less/errors/functions-2-alpha.txt +3 -0
- package/test/less/errors/functions-3-assignment.less +2 -0
- package/test/less/errors/functions-3-assignment.txt +3 -0
- package/test/less/errors/functions-4-call.less +2 -0
- package/test/less/errors/functions-4-call.txt +3 -0
- package/test/less/errors/functions-5-color-2.less +1 -0
- package/test/less/errors/functions-5-color-2.txt +2 -0
- package/test/less/errors/functions-5-color.less +2 -0
- package/test/less/errors/functions-5-color.txt +3 -0
- package/test/less/errors/functions-6-condition.less +2 -0
- package/test/less/errors/functions-6-condition.txt +3 -0
- package/test/less/errors/functions-7-dimension.less +2 -0
- package/test/less/errors/functions-7-dimension.txt +3 -0
- package/test/less/errors/functions-8-element.less +2 -0
- package/test/less/errors/functions-8-element.txt +3 -0
- package/test/less/errors/functions-9-expression.less +2 -0
- package/test/less/errors/functions-9-expression.txt +3 -0
- package/test/less/errors/property-in-root.txt +1 -1
- package/test/less/errors/property-in-root2.txt +1 -1
- package/test/less/errors/property-in-root3.txt +1 -1
- package/test/less/errors/root-func-undefined-1.less +1 -0
- package/test/less/errors/root-func-undefined-1.txt +2 -0
- package/test/less/errors/root-func-undefined-2.less +2 -0
- package/test/less/errors/root-func-undefined-2.txt +3 -0
- package/test/less/extend-chaining.less +1 -1
- package/test/less/merge.less +4 -4
- package/test/less/mixins-guards.less +1 -1
- package/test/less/no-strict-math/no-sm-operations.less +4 -1
- package/test/less/operations.less +1 -1
- package/test/less/plugin/plugin-tree-nodes.js +80 -0
- package/test/less/plugin.less +8 -0
- package/test/less-bom/comments.less +1 -1
- package/test/less-bom/errors/detached-ruleset-3.txt +1 -1
- package/test/less-bom/errors/functions-1.less +2 -0
- package/test/less-bom/errors/functions-1.txt +3 -0
- package/test/less-bom/errors/functions-10-keyword.less +2 -0
- package/test/less-bom/errors/functions-10-keyword.txt +3 -0
- package/test/less-bom/errors/functions-11-operation.less +2 -0
- package/test/less-bom/errors/functions-11-operation.txt +3 -0
- package/test/less-bom/errors/functions-12-quoted.less +2 -0
- package/test/less-bom/errors/functions-12-quoted.txt +3 -0
- package/test/less-bom/errors/functions-13-selector.less +2 -0
- package/test/less-bom/errors/functions-13-selector.txt +3 -0
- package/test/less-bom/errors/functions-14-url.less +2 -0
- package/test/less-bom/errors/functions-14-url.txt +3 -0
- package/test/less-bom/errors/functions-15-value.less +2 -0
- package/test/less-bom/errors/functions-15-value.txt +3 -0
- package/test/less-bom/errors/functions-2-alpha.less +2 -0
- package/test/less-bom/errors/functions-2-alpha.txt +3 -0
- package/test/less-bom/errors/functions-3-assignment.less +2 -0
- package/test/less-bom/errors/functions-3-assignment.txt +3 -0
- package/test/less-bom/errors/functions-4-call.less +2 -0
- package/test/less-bom/errors/functions-4-call.txt +3 -0
- package/test/less-bom/errors/functions-5-color-2.less +1 -0
- package/test/less-bom/errors/functions-5-color-2.txt +2 -0
- package/test/less-bom/errors/functions-5-color.less +2 -0
- package/test/less-bom/errors/functions-5-color.txt +3 -0
- package/test/less-bom/errors/functions-6-condition.less +2 -0
- package/test/less-bom/errors/functions-6-condition.txt +3 -0
- package/test/less-bom/errors/functions-7-dimension.less +2 -0
- package/test/less-bom/errors/functions-7-dimension.txt +3 -0
- package/test/less-bom/errors/functions-8-element.less +2 -0
- package/test/less-bom/errors/functions-8-element.txt +3 -0
- package/test/less-bom/errors/functions-9-expression.less +2 -0
- package/test/less-bom/errors/functions-9-expression.txt +3 -0
- package/test/less-bom/errors/property-in-root.txt +1 -1
- package/test/less-bom/errors/property-in-root2.txt +1 -1
- package/test/less-bom/errors/property-in-root3.txt +1 -1
- package/test/less-bom/errors/root-func-undefined-1.less +1 -0
- package/test/less-bom/errors/root-func-undefined-1.txt +2 -0
- package/test/less-bom/errors/root-func-undefined-2.less +2 -0
- package/test/less-bom/errors/root-func-undefined-2.txt +3 -0
- package/test/less-bom/extend-chaining.less +1 -1
- package/test/less-bom/merge.less +4 -4
- package/test/less-bom/mixins-guards.less +1 -1
- package/test/less-bom/no-strict-math/no-sm-operations.less +4 -1
- package/test/less-bom/operations.less +1 -1
- package/test/less-bom/plugin/plugin-tree-nodes.js +80 -0
- package/test/less-bom/plugin.less +8 -0
package/dist/less.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Less - Leaner CSS v2.
|
|
2
|
+
* Less - Leaner CSS v2.7.3
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2009-
|
|
6
|
-
* Licensed under the
|
|
5
|
+
* Copyright (c) 2009-2017, Alexis Sellier <self@cloudhead.net>
|
|
6
|
+
* Licensed under the Apache-2.0 License.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
/** * @license
|
|
10
|
+
/** * @license Apache-2.0
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.less = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
@@ -772,34 +772,57 @@ module.exports = function(window, options) {
|
|
|
772
772
|
fileManager.clearFileCache();
|
|
773
773
|
}
|
|
774
774
|
return new Promise(function (resolve, reject) {
|
|
775
|
-
var startTime, endTime, totalMilliseconds;
|
|
775
|
+
var startTime, endTime, totalMilliseconds, remainingSheets;
|
|
776
776
|
startTime = endTime = new Date();
|
|
777
777
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}
|
|
784
|
-
if (webInfo.local) {
|
|
785
|
-
less.logger.info("loading " + sheet.href + " from cache.");
|
|
786
|
-
} else {
|
|
787
|
-
less.logger.info("rendered " + sheet.href + " successfully.");
|
|
788
|
-
}
|
|
789
|
-
browser.createCSS(window.document, css, sheet);
|
|
790
|
-
less.logger.info("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
|
|
791
|
-
if (webInfo.remaining === 0) {
|
|
792
|
-
totalMilliseconds = new Date() - startTime;
|
|
793
|
-
less.logger.info("less has finished. css generated in " + totalMilliseconds + 'ms');
|
|
794
|
-
resolve({
|
|
795
|
-
startTime: startTime,
|
|
796
|
-
endTime: endTime,
|
|
797
|
-
totalMilliseconds: totalMilliseconds,
|
|
798
|
-
sheets: less.sheets.length
|
|
799
|
-
});
|
|
800
|
-
}
|
|
778
|
+
// Set counter for remaining unprocessed sheets
|
|
779
|
+
remainingSheets = less.sheets.length;
|
|
780
|
+
|
|
781
|
+
if (remainingSheets === 0) {
|
|
782
|
+
|
|
801
783
|
endTime = new Date();
|
|
802
|
-
|
|
784
|
+
totalMilliseconds = endTime - startTime;
|
|
785
|
+
less.logger.info("Less has finished and no sheets were loaded.");
|
|
786
|
+
resolve({
|
|
787
|
+
startTime: startTime,
|
|
788
|
+
endTime: endTime,
|
|
789
|
+
totalMilliseconds: totalMilliseconds,
|
|
790
|
+
sheets: less.sheets.length
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
} else {
|
|
794
|
+
// Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array
|
|
795
|
+
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
|
796
|
+
if (e) {
|
|
797
|
+
errors.add(e, e.href || sheet.href);
|
|
798
|
+
reject(e);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (webInfo.local) {
|
|
802
|
+
less.logger.info("Loading " + sheet.href + " from cache.");
|
|
803
|
+
} else {
|
|
804
|
+
less.logger.info("Rendered " + sheet.href + " successfully.");
|
|
805
|
+
}
|
|
806
|
+
browser.createCSS(window.document, css, sheet);
|
|
807
|
+
less.logger.info("CSS for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms');
|
|
808
|
+
|
|
809
|
+
// Count completed sheet
|
|
810
|
+
remainingSheets--;
|
|
811
|
+
|
|
812
|
+
// Check if the last remaining sheet was processed and then call the promise
|
|
813
|
+
if (remainingSheets === 0) {
|
|
814
|
+
totalMilliseconds = new Date() - startTime;
|
|
815
|
+
less.logger.info("Less has finished. CSS generated in " + totalMilliseconds + 'ms');
|
|
816
|
+
resolve({
|
|
817
|
+
startTime: startTime,
|
|
818
|
+
endTime: endTime,
|
|
819
|
+
totalMilliseconds: totalMilliseconds,
|
|
820
|
+
sheets: less.sheets.length
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
endTime = new Date();
|
|
824
|
+
}, reload, modifyVars);
|
|
825
|
+
}
|
|
803
826
|
|
|
804
827
|
loadStyles(modifyVars);
|
|
805
828
|
});
|
|
@@ -1242,13 +1265,13 @@ abstractFileManager.prototype.pathDiff = function pathDiff(url, baseUrl) {
|
|
|
1242
1265
|
};
|
|
1243
1266
|
// helper function, not part of API
|
|
1244
1267
|
abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, baseUrl) {
|
|
1245
|
-
// urlParts[1] = protocol
|
|
1268
|
+
// urlParts[1] = protocol://hostname/ OR /
|
|
1246
1269
|
// urlParts[2] = / if path relative to host base
|
|
1247
1270
|
// urlParts[3] = directories
|
|
1248
1271
|
// urlParts[4] = filename
|
|
1249
1272
|
// urlParts[5] = parameters
|
|
1250
1273
|
|
|
1251
|
-
var urlPartsRegex = /^((?:[a-z-]+:)
|
|
1274
|
+
var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i,
|
|
1252
1275
|
urlParts = url.match(urlPartsRegex),
|
|
1253
1276
|
returner = {}, directories = [], i, baseUrlParts;
|
|
1254
1277
|
|
|
@@ -1666,7 +1689,7 @@ colorFunctions = {
|
|
|
1666
1689
|
return hsla(hsl);
|
|
1667
1690
|
},
|
|
1668
1691
|
//
|
|
1669
|
-
// Copyright (c) 2006-2009 Hampton Catlin,
|
|
1692
|
+
// Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
|
|
1670
1693
|
// http://sass-lang.com
|
|
1671
1694
|
//
|
|
1672
1695
|
mix: function (color1, color2, weight) {
|
|
@@ -2454,7 +2477,7 @@ module.exports = function(environment, fileManagers) {
|
|
|
2454
2477
|
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
|
|
2455
2478
|
|
|
2456
2479
|
var less = {
|
|
2457
|
-
version: [2,
|
|
2480
|
+
version: [2, 7, 3],
|
|
2458
2481
|
data: require('./data'),
|
|
2459
2482
|
tree: require('./tree'),
|
|
2460
2483
|
Environment: (Environment = require("./environment/environment")),
|
|
@@ -2849,7 +2872,7 @@ module.exports = function() {
|
|
|
2849
2872
|
nextNewLine = endIndex;
|
|
2850
2873
|
}
|
|
2851
2874
|
parserInput.i = nextNewLine;
|
|
2852
|
-
comment.text = inp.substr(comment.
|
|
2875
|
+
comment.text = inp.substr(comment.index, parserInput.i - comment.index);
|
|
2853
2876
|
parserInput.commentStore.push(comment);
|
|
2854
2877
|
continue;
|
|
2855
2878
|
} else if (nextChar === '*') {
|
|
@@ -3026,7 +3049,7 @@ module.exports = function() {
|
|
|
3026
3049
|
input = str;
|
|
3027
3050
|
parserInput.i = j = currentPos = furthest = 0;
|
|
3028
3051
|
|
|
3029
|
-
// chunking
|
|
3052
|
+
// chunking apparently makes things quicker (but my tests indicate
|
|
3030
3053
|
// it might actually make things slower in node at least)
|
|
3031
3054
|
// and it is a non-perfect parse - it can't recognise
|
|
3032
3055
|
// unquoted urls, meaning it can't distinguish comments
|
|
@@ -3331,7 +3354,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3331
3354
|
}
|
|
3332
3355
|
|
|
3333
3356
|
node = mixin.definition() || this.rule() || this.ruleset() ||
|
|
3334
|
-
mixin.call() || this.rulesetCall() || this.directive();
|
|
3357
|
+
mixin.call() || this.rulesetCall() || this.entities.call() || this.directive();
|
|
3335
3358
|
if (node) {
|
|
3336
3359
|
root.push(node);
|
|
3337
3360
|
} else {
|
|
@@ -3440,19 +3463,51 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3440
3463
|
return new(tree.Call)(name, args, index, fileInfo);
|
|
3441
3464
|
},
|
|
3442
3465
|
arguments: function () {
|
|
3443
|
-
var
|
|
3466
|
+
var argsSemiColon = [], argsComma = [],
|
|
3467
|
+
expressions = [],
|
|
3468
|
+
isSemiColonSeparated, value, arg;
|
|
3469
|
+
|
|
3470
|
+
parserInput.save();
|
|
3444
3471
|
|
|
3445
3472
|
while (true) {
|
|
3446
|
-
|
|
3473
|
+
|
|
3474
|
+
arg = parsers.detachedRuleset() || this.assignment() || parsers.expression();
|
|
3475
|
+
|
|
3447
3476
|
if (!arg) {
|
|
3448
3477
|
break;
|
|
3449
3478
|
}
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3479
|
+
|
|
3480
|
+
value = arg;
|
|
3481
|
+
|
|
3482
|
+
if (arg.value && arg.value.length == 1) {
|
|
3483
|
+
value = arg.value[0];
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
if (value) {
|
|
3487
|
+
expressions.push(value);
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
argsComma.push(value);
|
|
3491
|
+
|
|
3492
|
+
if (parserInput.$char(',')) {
|
|
3493
|
+
continue;
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
if (parserInput.$char(';') || isSemiColonSeparated) {
|
|
3497
|
+
|
|
3498
|
+
isSemiColonSeparated = true;
|
|
3499
|
+
|
|
3500
|
+
if (expressions.length > 1) {
|
|
3501
|
+
value = new(tree.Value)(expressions);
|
|
3502
|
+
}
|
|
3503
|
+
argsSemiColon.push(value);
|
|
3504
|
+
|
|
3505
|
+
expressions = [];
|
|
3453
3506
|
}
|
|
3454
3507
|
}
|
|
3455
|
-
|
|
3508
|
+
|
|
3509
|
+
parserInput.forget();
|
|
3510
|
+
return isSemiColonSeparated ? argsSemiColon : argsComma;
|
|
3456
3511
|
},
|
|
3457
3512
|
literal: function () {
|
|
3458
3513
|
return this.dimension() ||
|
|
@@ -3532,7 +3587,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3532
3587
|
}
|
|
3533
3588
|
},
|
|
3534
3589
|
|
|
3535
|
-
// A variable entity
|
|
3590
|
+
// A variable entity using the protective {} e.g. @{var}
|
|
3536
3591
|
variableCurly: function () {
|
|
3537
3592
|
var curly, index = parserInput.i;
|
|
3538
3593
|
|
|
@@ -3567,7 +3622,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3567
3622
|
parserInput.save();
|
|
3568
3623
|
var autoCommentAbsorb = parserInput.autoCommentAbsorb;
|
|
3569
3624
|
parserInput.autoCommentAbsorb = false;
|
|
3570
|
-
var k = parserInput.$re(/^[
|
|
3625
|
+
var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/);
|
|
3571
3626
|
parserInput.autoCommentAbsorb = autoCommentAbsorb;
|
|
3572
3627
|
if (!k) {
|
|
3573
3628
|
parserInput.forget();
|
|
@@ -3969,7 +4024,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
3969
4024
|
//
|
|
3970
4025
|
// A Rule terminator. Note that we use `peek()` to check for '}',
|
|
3971
4026
|
// because the `block` rule will be expecting it, but we still need to make sure
|
|
3972
|
-
// it's there, if ';' was
|
|
4027
|
+
// it's there, if ';' was omitted.
|
|
3973
4028
|
//
|
|
3974
4029
|
end: function () {
|
|
3975
4030
|
return parserInput.$char(';') || parserInput.peek('}');
|
|
@@ -4391,10 +4446,10 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
4391
4446
|
},
|
|
4392
4447
|
|
|
4393
4448
|
media: function () {
|
|
4394
|
-
var features, rules, media, debugInfo;
|
|
4449
|
+
var features, rules, media, debugInfo, index = parserInput.i;
|
|
4395
4450
|
|
|
4396
4451
|
if (context.dumpLineNumbers) {
|
|
4397
|
-
debugInfo = getDebugInfo(
|
|
4452
|
+
debugInfo = getDebugInfo(index);
|
|
4398
4453
|
}
|
|
4399
4454
|
|
|
4400
4455
|
parserInput.save();
|
|
@@ -4410,7 +4465,7 @@ var Parser = function Parser(context, imports, fileInfo) {
|
|
|
4410
4465
|
|
|
4411
4466
|
parserInput.forget();
|
|
4412
4467
|
|
|
4413
|
-
media = new(tree.Media)(rules, features,
|
|
4468
|
+
media = new(tree.Media)(rules, features, index, fileInfo);
|
|
4414
4469
|
if (context.dumpLineNumbers) {
|
|
4415
4470
|
media.debugInfo = debugInfo;
|
|
4416
4471
|
}
|
|
@@ -5442,7 +5497,7 @@ var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike,
|
|
|
5442
5497
|
this.mapLines = mapLines;
|
|
5443
5498
|
this.currentFileInfo = currentFileInfo;
|
|
5444
5499
|
this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
|
|
5445
|
-
|
|
5500
|
+
this.allowRoot = true;
|
|
5446
5501
|
this.copyVisibilityInfo(visibilityInfo);
|
|
5447
5502
|
};
|
|
5448
5503
|
Anonymous.prototype = new Node();
|
|
@@ -5553,18 +5608,21 @@ Call.prototype.eval = function (context) {
|
|
|
5553
5608
|
var args = this.args.map(function (a) { return a.eval(context); }),
|
|
5554
5609
|
result, funcCaller = new FunctionCaller(this.name, context, this.index, this.currentFileInfo);
|
|
5555
5610
|
|
|
5556
|
-
if (funcCaller.isValid()) {
|
|
5611
|
+
if (funcCaller.isValid()) {
|
|
5557
5612
|
try {
|
|
5558
5613
|
result = funcCaller.call(args);
|
|
5559
|
-
if (result != null) {
|
|
5560
|
-
return result;
|
|
5561
|
-
}
|
|
5562
5614
|
} catch (e) {
|
|
5563
5615
|
throw { type: e.type || "Runtime",
|
|
5564
5616
|
message: "error evaluating function `" + this.name + "`" +
|
|
5565
5617
|
(e.message ? ': ' + e.message : ''),
|
|
5566
5618
|
index: this.index, filename: this.currentFileInfo.filename };
|
|
5567
5619
|
}
|
|
5620
|
+
|
|
5621
|
+
if (result != null) {
|
|
5622
|
+
result.index = this.index;
|
|
5623
|
+
result.currentFileInfo = this.currentFileInfo;
|
|
5624
|
+
return result;
|
|
5625
|
+
}
|
|
5568
5626
|
}
|
|
5569
5627
|
|
|
5570
5628
|
return new Call(this.name, args, this.index, this.currentFileInfo);
|
|
@@ -5806,7 +5864,9 @@ var Node = require("./node"),
|
|
|
5806
5864
|
var Comment = function (value, isLineComment, index, currentFileInfo) {
|
|
5807
5865
|
this.value = value;
|
|
5808
5866
|
this.isLineComment = isLineComment;
|
|
5867
|
+
this.index = index;
|
|
5809
5868
|
this.currentFileInfo = currentFileInfo;
|
|
5869
|
+
this.allowRoot = true;
|
|
5810
5870
|
};
|
|
5811
5871
|
Comment.prototype = new Node();
|
|
5812
5872
|
Comment.prototype.type = "Comment";
|
|
@@ -6109,6 +6169,7 @@ var Directive = function (name, value, rules, index, currentFileInfo, debugInfo,
|
|
|
6109
6169
|
this.debugInfo = debugInfo;
|
|
6110
6170
|
this.isRooted = isRooted || false;
|
|
6111
6171
|
this.copyVisibilityInfo(visibilityInfo);
|
|
6172
|
+
this.allowRoot = true;
|
|
6112
6173
|
};
|
|
6113
6174
|
|
|
6114
6175
|
Directive.prototype = new Node();
|
|
@@ -6350,6 +6411,7 @@ var Extend = function Extend(selector, option, index, currentFileInfo, visibilit
|
|
|
6350
6411
|
this.parent_ids = [this.object_id];
|
|
6351
6412
|
this.currentFileInfo = currentFileInfo || {};
|
|
6352
6413
|
this.copyVisibilityInfo(visibilityInfo);
|
|
6414
|
+
this.allowRoot = true;
|
|
6353
6415
|
|
|
6354
6416
|
switch(option) {
|
|
6355
6417
|
case "all":
|
|
@@ -6422,6 +6484,7 @@ var Import = function (path, features, options, index, currentFileInfo, visibili
|
|
|
6422
6484
|
this.path = path;
|
|
6423
6485
|
this.features = features;
|
|
6424
6486
|
this.currentFileInfo = currentFileInfo;
|
|
6487
|
+
this.allowRoot = true;
|
|
6425
6488
|
|
|
6426
6489
|
if (this.options.less !== undefined || this.options.inline) {
|
|
6427
6490
|
this.css = !this.options.less || this.options.inline;
|
|
@@ -6733,6 +6796,7 @@ var Media = function (value, features, index, currentFileInfo, visibilityInfo) {
|
|
|
6733
6796
|
this.rules = [new Ruleset(selectors, value)];
|
|
6734
6797
|
this.rules[0].allowImports = true;
|
|
6735
6798
|
this.copyVisibilityInfo(visibilityInfo);
|
|
6799
|
+
this.allowRoot = true;
|
|
6736
6800
|
};
|
|
6737
6801
|
Media.prototype = new Directive();
|
|
6738
6802
|
Media.prototype.type = "Media";
|
|
@@ -6873,6 +6937,7 @@ var MixinCall = function (elements, args, index, currentFileInfo, important) {
|
|
|
6873
6937
|
this.index = index;
|
|
6874
6938
|
this.currentFileInfo = currentFileInfo;
|
|
6875
6939
|
this.important = important;
|
|
6940
|
+
this.allowRoot = true;
|
|
6876
6941
|
};
|
|
6877
6942
|
MixinCall.prototype = new Node();
|
|
6878
6943
|
MixinCall.prototype.type = "MixinCall";
|
|
@@ -7075,6 +7140,7 @@ var Definition = function (name, params, rules, condition, variadic, frames, vis
|
|
|
7075
7140
|
this.optionalParameters = optionalParameters;
|
|
7076
7141
|
this.frames = frames;
|
|
7077
7142
|
this.copyVisibilityInfo(visibilityInfo);
|
|
7143
|
+
this.allowRoot = true;
|
|
7078
7144
|
};
|
|
7079
7145
|
Definition.prototype = new Ruleset();
|
|
7080
7146
|
Definition.prototype.type = "MixinDefinition";
|
|
@@ -7534,6 +7600,7 @@ var Rule = function (name, value, important, merge, index, currentFileInfo, inli
|
|
|
7534
7600
|
this.inline = inline || false;
|
|
7535
7601
|
this.variable = (variable !== undefined) ? variable
|
|
7536
7602
|
: (name.charAt && (name.charAt(0) === '@'));
|
|
7603
|
+
this.allowRoot = true;
|
|
7537
7604
|
};
|
|
7538
7605
|
|
|
7539
7606
|
function evalName(context, name) {
|
|
@@ -7621,6 +7688,7 @@ var Node = require("./node"),
|
|
|
7621
7688
|
|
|
7622
7689
|
var RulesetCall = function (variable) {
|
|
7623
7690
|
this.variable = variable;
|
|
7691
|
+
this.allowRoot = true;
|
|
7624
7692
|
};
|
|
7625
7693
|
RulesetCall.prototype = new Node();
|
|
7626
7694
|
RulesetCall.prototype.type = "RulesetCall";
|
|
@@ -7647,6 +7715,7 @@ var Ruleset = function (selectors, rules, strictImports, visibilityInfo) {
|
|
|
7647
7715
|
this._lookups = {};
|
|
7648
7716
|
this.strictImports = strictImports;
|
|
7649
7717
|
this.copyVisibilityInfo(visibilityInfo);
|
|
7718
|
+
this.allowRoot = true;
|
|
7650
7719
|
};
|
|
7651
7720
|
Ruleset.prototype = new Node();
|
|
7652
7721
|
Ruleset.prototype.type = "Ruleset";
|
|
@@ -8854,7 +8923,7 @@ var ProcessExtendsVisitor = function() {
|
|
|
8854
8923
|
ProcessExtendsVisitor.prototype = {
|
|
8855
8924
|
run: function(root) {
|
|
8856
8925
|
var extendFinder = new ExtendFinderVisitor();
|
|
8857
|
-
this.
|
|
8926
|
+
this.extendIndices = {};
|
|
8858
8927
|
extendFinder.run(root);
|
|
8859
8928
|
if (!extendFinder.foundExtends) { return root; }
|
|
8860
8929
|
root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));
|
|
@@ -8864,7 +8933,7 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8864
8933
|
return newRoot;
|
|
8865
8934
|
},
|
|
8866
8935
|
checkExtendsForNonMatched: function(extendList) {
|
|
8867
|
-
var
|
|
8936
|
+
var indices = this.extendIndices;
|
|
8868
8937
|
extendList.filter(function(extend) {
|
|
8869
8938
|
return !extend.hasFoundMatches && extend.parent_ids.length == 1;
|
|
8870
8939
|
}).forEach(function(extend) {
|
|
@@ -8874,8 +8943,8 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8874
8943
|
}
|
|
8875
8944
|
catch(_) {}
|
|
8876
8945
|
|
|
8877
|
-
if (!
|
|
8878
|
-
|
|
8946
|
+
if (!indices[extend.index + ' ' + selector]) {
|
|
8947
|
+
indices[extend.index + ' ' + selector] = true;
|
|
8879
8948
|
logger.warn("extend '" + selector + "' has no matches");
|
|
8880
8949
|
}
|
|
8881
8950
|
});
|
|
@@ -8899,7 +8968,7 @@ ProcessExtendsVisitor.prototype = {
|
|
|
8899
8968
|
// a target extend is the one on the ruleset we are looking at copy/edit/pasting in place
|
|
8900
8969
|
// e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one
|
|
8901
8970
|
// and the second is the target.
|
|
8902
|
-
// the
|
|
8971
|
+
// the separation into two lists allows us to process a subset of chains with a bigger set, as is the
|
|
8903
8972
|
// case when processing media queries
|
|
8904
8973
|
for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {
|
|
8905
8974
|
for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) {
|
|
@@ -9716,7 +9785,6 @@ ToCSSVisitor.prototype = {
|
|
|
9716
9785
|
} else {
|
|
9717
9786
|
return this.visitDirectiveWithoutBody(directiveNode, visitArgs);
|
|
9718
9787
|
}
|
|
9719
|
-
return directiveNode;
|
|
9720
9788
|
},
|
|
9721
9789
|
|
|
9722
9790
|
visitDirectiveWithBody: function(directiveNode, visitArgs) {
|
|
@@ -9771,13 +9839,24 @@ ToCSSVisitor.prototype = {
|
|
|
9771
9839
|
return directiveNode;
|
|
9772
9840
|
},
|
|
9773
9841
|
|
|
9774
|
-
|
|
9775
|
-
|
|
9842
|
+
checkValidNodes: function(rules, isRoot) {
|
|
9843
|
+
if (!rules) {
|
|
9844
|
+
return;
|
|
9845
|
+
}
|
|
9846
|
+
|
|
9776
9847
|
for (var i = 0; i < rules.length; i++) {
|
|
9777
|
-
ruleNode = rules[i];
|
|
9778
|
-
if (ruleNode instanceof tree.Rule && !ruleNode.variable) {
|
|
9779
|
-
throw { message: "
|
|
9780
|
-
index: ruleNode.index, filename: ruleNode.currentFileInfo
|
|
9848
|
+
var ruleNode = rules[i];
|
|
9849
|
+
if (isRoot && ruleNode instanceof tree.Rule && !ruleNode.variable) {
|
|
9850
|
+
throw { message: "Properties must be inside selector blocks. They cannot be in the root",
|
|
9851
|
+
index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.filename};
|
|
9852
|
+
}
|
|
9853
|
+
if (ruleNode instanceof tree.Call) {
|
|
9854
|
+
throw { message: "Function '" + ruleNode.name + "' is undefined",
|
|
9855
|
+
index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.filename};
|
|
9856
|
+
}
|
|
9857
|
+
if (ruleNode.type && !ruleNode.allowRoot) {
|
|
9858
|
+
throw { message: ruleNode.type + " node returned by a function is not valid here",
|
|
9859
|
+
index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.filename};
|
|
9781
9860
|
}
|
|
9782
9861
|
}
|
|
9783
9862
|
},
|
|
@@ -9785,9 +9864,9 @@ ToCSSVisitor.prototype = {
|
|
|
9785
9864
|
visitRuleset: function (rulesetNode, visitArgs) {
|
|
9786
9865
|
//at this point rulesets are nested into each other
|
|
9787
9866
|
var rule, rulesets = [];
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9867
|
+
|
|
9868
|
+
this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot);
|
|
9869
|
+
|
|
9791
9870
|
if (! rulesetNode.root) {
|
|
9792
9871
|
//remove invisible paths
|
|
9793
9872
|
this._compileRulesetPaths(rulesetNode);
|
|
@@ -10109,145 +10188,490 @@ Visitor.prototype = {
|
|
|
10109
10188
|
module.exports = Visitor;
|
|
10110
10189
|
|
|
10111
10190
|
},{"../tree":62}],92:[function(require,module,exports){
|
|
10112
|
-
|
|
10191
|
+
"use strict";
|
|
10113
10192
|
|
|
10114
|
-
|
|
10115
|
-
var
|
|
10116
|
-
|
|
10193
|
+
// rawAsap provides everything we need except exception management.
|
|
10194
|
+
var rawAsap = require("./raw");
|
|
10195
|
+
// RawTasks are recycled to reduce GC churn.
|
|
10196
|
+
var freeTasks = [];
|
|
10197
|
+
// We queue errors to ensure they are thrown in right order (FIFO).
|
|
10198
|
+
// Array-as-queue is good enough here, since we are just dealing with exceptions.
|
|
10199
|
+
var pendingErrors = [];
|
|
10200
|
+
var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);
|
|
10117
10201
|
|
|
10118
|
-
function
|
|
10119
|
-
if (
|
|
10120
|
-
|
|
10202
|
+
function throwFirstError() {
|
|
10203
|
+
if (pendingErrors.length) {
|
|
10204
|
+
throw pendingErrors.shift();
|
|
10121
10205
|
}
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10206
|
+
}
|
|
10207
|
+
|
|
10208
|
+
/**
|
|
10209
|
+
* Calls a task as soon as possible after returning, in its own event, with priority
|
|
10210
|
+
* over other events like animation, reflow, and repaint. An error thrown from an
|
|
10211
|
+
* event will not interrupt, nor even substantially slow down the processing of
|
|
10212
|
+
* other events, but will be rather postponed to a lower priority event.
|
|
10213
|
+
* @param {{call}} task A callable object, typically a function that takes no
|
|
10214
|
+
* arguments.
|
|
10215
|
+
*/
|
|
10216
|
+
module.exports = asap;
|
|
10217
|
+
function asap(task) {
|
|
10218
|
+
var rawTask;
|
|
10219
|
+
if (freeTasks.length) {
|
|
10220
|
+
rawTask = freeTasks.pop();
|
|
10221
|
+
} else {
|
|
10222
|
+
rawTask = new RawTask();
|
|
10133
10223
|
}
|
|
10134
|
-
|
|
10224
|
+
rawTask.task = task;
|
|
10225
|
+
rawAsap(rawTask);
|
|
10226
|
+
}
|
|
10227
|
+
|
|
10228
|
+
// We wrap tasks with recyclable task objects. A task object implements
|
|
10229
|
+
// `call`, just like a function.
|
|
10230
|
+
function RawTask() {
|
|
10231
|
+
this.task = null;
|
|
10135
10232
|
}
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10233
|
+
|
|
10234
|
+
// The sole purpose of wrapping the task is to catch the exception and recycle
|
|
10235
|
+
// the task object after its single use.
|
|
10236
|
+
RawTask.prototype.call = function () {
|
|
10237
|
+
try {
|
|
10238
|
+
this.task.call();
|
|
10239
|
+
} catch (error) {
|
|
10240
|
+
if (asap.onerror) {
|
|
10241
|
+
// This hook exists purely for testing purposes.
|
|
10242
|
+
// Its name will be periodically randomized to break any code that
|
|
10243
|
+
// depends on its existence.
|
|
10244
|
+
asap.onerror(error);
|
|
10245
|
+
} else {
|
|
10246
|
+
// In a web browser, exceptions are not fatal. However, to avoid
|
|
10247
|
+
// slowing down the queue of pending tasks, we rethrow the error in a
|
|
10248
|
+
// lower priority turn.
|
|
10249
|
+
pendingErrors.push(error);
|
|
10250
|
+
requestErrorThrow();
|
|
10251
|
+
}
|
|
10252
|
+
} finally {
|
|
10253
|
+
this.task = null;
|
|
10254
|
+
freeTasks[freeTasks.length] = this;
|
|
10140
10255
|
}
|
|
10141
10256
|
};
|
|
10142
10257
|
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
process.argv = [];
|
|
10147
|
-
process.version = ''; // empty string to avoid regexp issues
|
|
10148
|
-
process.versions = {};
|
|
10258
|
+
},{"./raw":93}],93:[function(require,module,exports){
|
|
10259
|
+
(function (global){
|
|
10260
|
+
"use strict";
|
|
10149
10261
|
|
|
10150
|
-
|
|
10262
|
+
// Use the fastest means possible to execute a task in its own turn, with
|
|
10263
|
+
// priority over other events including IO, animation, reflow, and redraw
|
|
10264
|
+
// events in browsers.
|
|
10265
|
+
//
|
|
10266
|
+
// An exception thrown by a task will permanently interrupt the processing of
|
|
10267
|
+
// subsequent tasks. The higher level `asap` function ensures that if an
|
|
10268
|
+
// exception is thrown by a task, that the task queue will continue flushing as
|
|
10269
|
+
// soon as possible, but if you use `rawAsap` directly, you are responsible to
|
|
10270
|
+
// either ensure that no exceptions are thrown from your task, or to manually
|
|
10271
|
+
// call `rawAsap.requestFlush` if an exception is thrown.
|
|
10272
|
+
module.exports = rawAsap;
|
|
10273
|
+
function rawAsap(task) {
|
|
10274
|
+
if (!queue.length) {
|
|
10275
|
+
requestFlush();
|
|
10276
|
+
flushing = true;
|
|
10277
|
+
}
|
|
10278
|
+
// Equivalent to push, but avoids a function call.
|
|
10279
|
+
queue[queue.length] = task;
|
|
10280
|
+
}
|
|
10151
10281
|
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10282
|
+
var queue = [];
|
|
10283
|
+
// Once a flush has been requested, no further calls to `requestFlush` are
|
|
10284
|
+
// necessary until the next `flush` completes.
|
|
10285
|
+
var flushing = false;
|
|
10286
|
+
// `requestFlush` is an implementation-specific method that attempts to kick
|
|
10287
|
+
// off a `flush` event as quickly as possible. `flush` will attempt to exhaust
|
|
10288
|
+
// the event queue before yielding to the browser's own event loop.
|
|
10289
|
+
var requestFlush;
|
|
10290
|
+
// The position of the next task to execute in the task queue. This is
|
|
10291
|
+
// preserved between calls to `flush` so that it can be resumed if
|
|
10292
|
+
// a task throws an exception.
|
|
10293
|
+
var index = 0;
|
|
10294
|
+
// If a task schedules additional tasks recursively, the task queue can grow
|
|
10295
|
+
// unbounded. To prevent memory exhaustion, the task queue will periodically
|
|
10296
|
+
// truncate already-completed tasks.
|
|
10297
|
+
var capacity = 1024;
|
|
10298
|
+
|
|
10299
|
+
// The flush function processes all tasks that have been scheduled with
|
|
10300
|
+
// `rawAsap` unless and until one of those tasks throws an exception.
|
|
10301
|
+
// If a task throws an exception, `flush` ensures that its state will remain
|
|
10302
|
+
// consistent and will resume where it left off when called again.
|
|
10303
|
+
// However, `flush` does not make any arrangements to be called again if an
|
|
10304
|
+
// exception is thrown.
|
|
10305
|
+
function flush() {
|
|
10306
|
+
while (index < queue.length) {
|
|
10307
|
+
var currentIndex = index;
|
|
10308
|
+
// Advance the index before calling the task. This ensures that we will
|
|
10309
|
+
// begin flushing on the next task the task throws an error.
|
|
10310
|
+
index = index + 1;
|
|
10311
|
+
queue[currentIndex].call();
|
|
10312
|
+
// Prevent leaking memory for long chains of recursive calls to `asap`.
|
|
10313
|
+
// If we call `asap` within tasks scheduled by `asap`, the queue will
|
|
10314
|
+
// grow, but to avoid an O(n) walk for every task we execute, we don't
|
|
10315
|
+
// shift tasks off the queue after they have been executed.
|
|
10316
|
+
// Instead, we periodically shift 1024 tasks off the queue.
|
|
10317
|
+
if (index > capacity) {
|
|
10318
|
+
// Manually shift all values starting at the index back to the
|
|
10319
|
+
// beginning of the queue.
|
|
10320
|
+
for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {
|
|
10321
|
+
queue[scan] = queue[scan + index];
|
|
10322
|
+
}
|
|
10323
|
+
queue.length -= index;
|
|
10324
|
+
index = 0;
|
|
10325
|
+
}
|
|
10326
|
+
}
|
|
10327
|
+
queue.length = 0;
|
|
10328
|
+
index = 0;
|
|
10329
|
+
flushing = false;
|
|
10330
|
+
}
|
|
10159
10331
|
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10332
|
+
// `requestFlush` is implemented using a strategy based on data collected from
|
|
10333
|
+
// every available SauceLabs Selenium web driver worker at time of writing.
|
|
10334
|
+
// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
|
|
10163
10335
|
|
|
10164
|
-
//
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10336
|
+
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
|
|
10337
|
+
// have WebKitMutationObserver but not un-prefixed MutationObserver.
|
|
10338
|
+
// Must use `global` or `self` instead of `window` to work in both frames and web
|
|
10339
|
+
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
|
|
10340
|
+
|
|
10341
|
+
/* globals self */
|
|
10342
|
+
var scope = typeof global !== "undefined" ? global : self;
|
|
10343
|
+
var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
|
|
10344
|
+
|
|
10345
|
+
// MutationObservers are desirable because they have high priority and work
|
|
10346
|
+
// reliably everywhere they are implemented.
|
|
10347
|
+
// They are implemented in all modern browsers.
|
|
10348
|
+
//
|
|
10349
|
+
// - Android 4-4.3
|
|
10350
|
+
// - Chrome 26-34
|
|
10351
|
+
// - Firefox 14-29
|
|
10352
|
+
// - Internet Explorer 11
|
|
10353
|
+
// - iPad Safari 6-7.1
|
|
10354
|
+
// - iPhone Safari 7-7.1
|
|
10355
|
+
// - Safari 6-7
|
|
10356
|
+
if (typeof BrowserMutationObserver === "function") {
|
|
10357
|
+
requestFlush = makeRequestCallFromMutationObserver(flush);
|
|
10358
|
+
|
|
10359
|
+
// MessageChannels are desirable because they give direct access to the HTML
|
|
10360
|
+
// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
|
|
10361
|
+
// 11-12, and in web workers in many engines.
|
|
10362
|
+
// Although message channels yield to any queued rendering and IO tasks, they
|
|
10363
|
+
// would be better than imposing the 4ms delay of timers.
|
|
10364
|
+
// However, they do not work reliably in Internet Explorer or Safari.
|
|
10365
|
+
|
|
10366
|
+
// Internet Explorer 10 is the only browser that has setImmediate but does
|
|
10367
|
+
// not have MutationObservers.
|
|
10368
|
+
// Although setImmediate yields to the browser's renderer, it would be
|
|
10369
|
+
// preferrable to falling back to setTimeout since it does not have
|
|
10370
|
+
// the minimum 4ms penalty.
|
|
10371
|
+
// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
|
|
10372
|
+
// Desktop to a lesser extent) that renders both setImmediate and
|
|
10373
|
+
// MessageChannel useless for the purposes of ASAP.
|
|
10374
|
+
// https://github.com/kriskowal/q/issues/396
|
|
10375
|
+
|
|
10376
|
+
// Timers are implemented universally.
|
|
10377
|
+
// We fall back to timers in workers in most engines, and in foreground
|
|
10378
|
+
// contexts in the following browsers.
|
|
10379
|
+
// However, note that even this simple case requires nuances to operate in a
|
|
10380
|
+
// broad spectrum of browsers.
|
|
10381
|
+
//
|
|
10382
|
+
// - Firefox 3-13
|
|
10383
|
+
// - Internet Explorer 6-9
|
|
10384
|
+
// - iPad Safari 4.3
|
|
10385
|
+
// - Lynx 2.8.7
|
|
10386
|
+
} else {
|
|
10387
|
+
requestFlush = makeRequestCallFromTimer(flush);
|
|
10388
|
+
}
|
|
10389
|
+
|
|
10390
|
+
// `requestFlush` requests that the high priority event queue be flushed as
|
|
10391
|
+
// soon as possible.
|
|
10392
|
+
// This is useful to prevent an error thrown in a task from stalling the event
|
|
10393
|
+
// queue if the exception handled by Node.js’s
|
|
10394
|
+
// `process.on("uncaughtException")` or by a domain.
|
|
10395
|
+
rawAsap.requestFlush = requestFlush;
|
|
10396
|
+
|
|
10397
|
+
// To request a high priority event, we induce a mutation observer by toggling
|
|
10398
|
+
// the text of a text node between "1" and "-1".
|
|
10399
|
+
function makeRequestCallFromMutationObserver(callback) {
|
|
10400
|
+
var toggle = 1;
|
|
10401
|
+
var observer = new BrowserMutationObserver(callback);
|
|
10402
|
+
var node = document.createTextNode("");
|
|
10403
|
+
observer.observe(node, {characterData: true});
|
|
10404
|
+
return function requestCall() {
|
|
10405
|
+
toggle = -toggle;
|
|
10406
|
+
node.data = toggle;
|
|
10407
|
+
};
|
|
10408
|
+
}
|
|
10409
|
+
|
|
10410
|
+
// The message channel technique was discovered by Malte Ubl and was the
|
|
10411
|
+
// original foundation for this library.
|
|
10412
|
+
// http://www.nonblocking.io/2011/06/windownexttick.html
|
|
10413
|
+
|
|
10414
|
+
// Safari 6.0.5 (at least) intermittently fails to create message ports on a
|
|
10415
|
+
// page's first load. Thankfully, this version of Safari supports
|
|
10416
|
+
// MutationObservers, so we don't need to fall back in that case.
|
|
10417
|
+
|
|
10418
|
+
// function makeRequestCallFromMessageChannel(callback) {
|
|
10419
|
+
// var channel = new MessageChannel();
|
|
10420
|
+
// channel.port1.onmessage = callback;
|
|
10421
|
+
// return function requestCall() {
|
|
10422
|
+
// channel.port2.postMessage(0);
|
|
10423
|
+
// };
|
|
10424
|
+
// }
|
|
10425
|
+
|
|
10426
|
+
// For reasons explained above, we are also unable to use `setImmediate`
|
|
10427
|
+
// under any circumstances.
|
|
10428
|
+
// Even if we were, there is another bug in Internet Explorer 10.
|
|
10429
|
+
// It is not sufficient to assign `setImmediate` to `requestFlush` because
|
|
10430
|
+
// `setImmediate` must be called *by name* and therefore must be wrapped in a
|
|
10431
|
+
// closure.
|
|
10432
|
+
// Never forget.
|
|
10433
|
+
|
|
10434
|
+
// function makeRequestCallFromSetImmediate(callback) {
|
|
10435
|
+
// return function requestCall() {
|
|
10436
|
+
// setImmediate(callback);
|
|
10437
|
+
// };
|
|
10438
|
+
// }
|
|
10439
|
+
|
|
10440
|
+
// Safari 6.0 has a problem where timers will get lost while the user is
|
|
10441
|
+
// scrolling. This problem does not impact ASAP because Safari 6.0 supports
|
|
10442
|
+
// mutation observers, so that implementation is used instead.
|
|
10443
|
+
// However, if we ever elect to use timers in Safari, the prevalent work-around
|
|
10444
|
+
// is to add a scroll event listener that calls for a flush.
|
|
10445
|
+
|
|
10446
|
+
// `setTimeout` does not call the passed callback if the delay is less than
|
|
10447
|
+
// approximately 7 in web workers in Firefox 8 through 18, and sometimes not
|
|
10448
|
+
// even then.
|
|
10449
|
+
|
|
10450
|
+
function makeRequestCallFromTimer(callback) {
|
|
10451
|
+
return function requestCall() {
|
|
10452
|
+
// We dispatch a timeout with a specified delay of 0 for engines that
|
|
10453
|
+
// can reliably accommodate that request. This will usually be snapped
|
|
10454
|
+
// to a 4 milisecond delay, but once we're flushing, there's no delay
|
|
10455
|
+
// between events.
|
|
10456
|
+
var timeoutHandle = setTimeout(handleTimer, 0);
|
|
10457
|
+
// However, since this timer gets frequently dropped in Firefox
|
|
10458
|
+
// workers, we enlist an interval handle that will try to fire
|
|
10459
|
+
// an event 20 times per second until it succeeds.
|
|
10460
|
+
var intervalHandle = setInterval(handleTimer, 50);
|
|
10461
|
+
|
|
10462
|
+
function handleTimer() {
|
|
10463
|
+
// Whichever timer succeeds will cancel both timers and
|
|
10464
|
+
// execute the callback.
|
|
10465
|
+
clearTimeout(timeoutHandle);
|
|
10466
|
+
clearInterval(intervalHandle);
|
|
10467
|
+
callback();
|
|
10468
|
+
}
|
|
10469
|
+
};
|
|
10470
|
+
}
|
|
10471
|
+
|
|
10472
|
+
// This is for `asap.js` only.
|
|
10473
|
+
// Its name will be periodically randomized to break any code that depends on
|
|
10474
|
+
// its existence.
|
|
10475
|
+
rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
|
|
10170
10476
|
|
|
10171
|
-
|
|
10477
|
+
// ASAP was originally a nextTick shim included in Q. This was factored out
|
|
10478
|
+
// into this ASAP package. It was later adapted to RSVP which made further
|
|
10479
|
+
// amendments. These decisions, particularly to marginalize MessageChannel and
|
|
10480
|
+
// to capture the MutationObserver implementation in a closure, were integrated
|
|
10481
|
+
// back into ASAP proper.
|
|
10482
|
+
// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
|
|
10483
|
+
|
|
10484
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
10485
|
+
},{}],94:[function(require,module,exports){
|
|
10172
10486
|
'use strict';
|
|
10173
10487
|
|
|
10174
|
-
var asap = require('asap')
|
|
10488
|
+
var asap = require('asap/raw');
|
|
10175
10489
|
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10490
|
+
function noop() {}
|
|
10491
|
+
|
|
10492
|
+
// States:
|
|
10493
|
+
//
|
|
10494
|
+
// 0 - pending
|
|
10495
|
+
// 1 - fulfilled with _value
|
|
10496
|
+
// 2 - rejected with _value
|
|
10497
|
+
// 3 - adopted the state of another promise, _value
|
|
10498
|
+
//
|
|
10499
|
+
// once the state is no longer pending (0) it is immutable
|
|
10500
|
+
|
|
10501
|
+
// All `_` prefixed properties will be reduced to `_{random number}`
|
|
10502
|
+
// at build time to obfuscate them and discourage their use.
|
|
10503
|
+
// We don't use symbols or Object.defineProperty to fully hide them
|
|
10504
|
+
// because the performance isn't good enough.
|
|
10505
|
+
|
|
10506
|
+
|
|
10507
|
+
// to avoid using try/catch inside critical functions, we
|
|
10508
|
+
// extract them to here.
|
|
10509
|
+
var LAST_ERROR = null;
|
|
10510
|
+
var IS_ERROR = {};
|
|
10511
|
+
function getThen(obj) {
|
|
10512
|
+
try {
|
|
10513
|
+
return obj.then;
|
|
10514
|
+
} catch (ex) {
|
|
10515
|
+
LAST_ERROR = ex;
|
|
10516
|
+
return IS_ERROR;
|
|
10189
10517
|
}
|
|
10518
|
+
}
|
|
10190
10519
|
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
var cb = state ? deferred.onFulfilled : deferred.onRejected
|
|
10198
|
-
if (cb === null) {
|
|
10199
|
-
(state ? deferred.resolve : deferred.reject)(value)
|
|
10200
|
-
return
|
|
10201
|
-
}
|
|
10202
|
-
var ret
|
|
10203
|
-
try {
|
|
10204
|
-
ret = cb(value)
|
|
10205
|
-
}
|
|
10206
|
-
catch (e) {
|
|
10207
|
-
deferred.reject(e)
|
|
10208
|
-
return
|
|
10209
|
-
}
|
|
10210
|
-
deferred.resolve(ret)
|
|
10211
|
-
})
|
|
10520
|
+
function tryCallOne(fn, a) {
|
|
10521
|
+
try {
|
|
10522
|
+
return fn(a);
|
|
10523
|
+
} catch (ex) {
|
|
10524
|
+
LAST_ERROR = ex;
|
|
10525
|
+
return IS_ERROR;
|
|
10212
10526
|
}
|
|
10527
|
+
}
|
|
10528
|
+
function tryCallTwo(fn, a, b) {
|
|
10529
|
+
try {
|
|
10530
|
+
fn(a, b);
|
|
10531
|
+
} catch (ex) {
|
|
10532
|
+
LAST_ERROR = ex;
|
|
10533
|
+
return IS_ERROR;
|
|
10534
|
+
}
|
|
10535
|
+
}
|
|
10213
10536
|
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
if (typeof then === 'function') {
|
|
10220
|
-
doResolve(then.bind(newValue), resolve, reject)
|
|
10221
|
-
return
|
|
10222
|
-
}
|
|
10223
|
-
}
|
|
10224
|
-
state = true
|
|
10225
|
-
value = newValue
|
|
10226
|
-
finale()
|
|
10227
|
-
} catch (e) { reject(e) }
|
|
10537
|
+
module.exports = Promise;
|
|
10538
|
+
|
|
10539
|
+
function Promise(fn) {
|
|
10540
|
+
if (typeof this !== 'object') {
|
|
10541
|
+
throw new TypeError('Promises must be constructed via new');
|
|
10228
10542
|
}
|
|
10543
|
+
if (typeof fn !== 'function') {
|
|
10544
|
+
throw new TypeError('Promise constructor\'s argument is not a function');
|
|
10545
|
+
}
|
|
10546
|
+
this._40 = 0;
|
|
10547
|
+
this._65 = 0;
|
|
10548
|
+
this._55 = null;
|
|
10549
|
+
this._72 = null;
|
|
10550
|
+
if (fn === noop) return;
|
|
10551
|
+
doResolve(fn, this);
|
|
10552
|
+
}
|
|
10553
|
+
Promise._37 = null;
|
|
10554
|
+
Promise._87 = null;
|
|
10555
|
+
Promise._61 = noop;
|
|
10229
10556
|
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
finale()
|
|
10557
|
+
Promise.prototype.then = function(onFulfilled, onRejected) {
|
|
10558
|
+
if (this.constructor !== Promise) {
|
|
10559
|
+
return safeThen(this, onFulfilled, onRejected);
|
|
10234
10560
|
}
|
|
10561
|
+
var res = new Promise(noop);
|
|
10562
|
+
handle(this, new Handler(onFulfilled, onRejected, res));
|
|
10563
|
+
return res;
|
|
10564
|
+
};
|
|
10235
10565
|
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10566
|
+
function safeThen(self, onFulfilled, onRejected) {
|
|
10567
|
+
return new self.constructor(function (resolve, reject) {
|
|
10568
|
+
var res = new Promise(noop);
|
|
10569
|
+
res.then(resolve, reject);
|
|
10570
|
+
handle(self, new Handler(onFulfilled, onRejected, res));
|
|
10571
|
+
});
|
|
10572
|
+
}
|
|
10573
|
+
function handle(self, deferred) {
|
|
10574
|
+
while (self._65 === 3) {
|
|
10575
|
+
self = self._55;
|
|
10576
|
+
}
|
|
10577
|
+
if (Promise._37) {
|
|
10578
|
+
Promise._37(self);
|
|
10240
10579
|
}
|
|
10580
|
+
if (self._65 === 0) {
|
|
10581
|
+
if (self._40 === 0) {
|
|
10582
|
+
self._40 = 1;
|
|
10583
|
+
self._72 = deferred;
|
|
10584
|
+
return;
|
|
10585
|
+
}
|
|
10586
|
+
if (self._40 === 1) {
|
|
10587
|
+
self._40 = 2;
|
|
10588
|
+
self._72 = [self._72, deferred];
|
|
10589
|
+
return;
|
|
10590
|
+
}
|
|
10591
|
+
self._72.push(deferred);
|
|
10592
|
+
return;
|
|
10593
|
+
}
|
|
10594
|
+
handleResolved(self, deferred);
|
|
10595
|
+
}
|
|
10241
10596
|
|
|
10242
|
-
|
|
10597
|
+
function handleResolved(self, deferred) {
|
|
10598
|
+
asap(function() {
|
|
10599
|
+
var cb = self._65 === 1 ? deferred.onFulfilled : deferred.onRejected;
|
|
10600
|
+
if (cb === null) {
|
|
10601
|
+
if (self._65 === 1) {
|
|
10602
|
+
resolve(deferred.promise, self._55);
|
|
10603
|
+
} else {
|
|
10604
|
+
reject(deferred.promise, self._55);
|
|
10605
|
+
}
|
|
10606
|
+
return;
|
|
10607
|
+
}
|
|
10608
|
+
var ret = tryCallOne(cb, self._55);
|
|
10609
|
+
if (ret === IS_ERROR) {
|
|
10610
|
+
reject(deferred.promise, LAST_ERROR);
|
|
10611
|
+
} else {
|
|
10612
|
+
resolve(deferred.promise, ret);
|
|
10613
|
+
}
|
|
10614
|
+
});
|
|
10615
|
+
}
|
|
10616
|
+
function resolve(self, newValue) {
|
|
10617
|
+
// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
|
|
10618
|
+
if (newValue === self) {
|
|
10619
|
+
return reject(
|
|
10620
|
+
self,
|
|
10621
|
+
new TypeError('A promise cannot be resolved with itself.')
|
|
10622
|
+
);
|
|
10623
|
+
}
|
|
10624
|
+
if (
|
|
10625
|
+
newValue &&
|
|
10626
|
+
(typeof newValue === 'object' || typeof newValue === 'function')
|
|
10627
|
+
) {
|
|
10628
|
+
var then = getThen(newValue);
|
|
10629
|
+
if (then === IS_ERROR) {
|
|
10630
|
+
return reject(self, LAST_ERROR);
|
|
10631
|
+
}
|
|
10632
|
+
if (
|
|
10633
|
+
then === self.then &&
|
|
10634
|
+
newValue instanceof Promise
|
|
10635
|
+
) {
|
|
10636
|
+
self._65 = 3;
|
|
10637
|
+
self._55 = newValue;
|
|
10638
|
+
finale(self);
|
|
10639
|
+
return;
|
|
10640
|
+
} else if (typeof then === 'function') {
|
|
10641
|
+
doResolve(then.bind(newValue), self);
|
|
10642
|
+
return;
|
|
10643
|
+
}
|
|
10644
|
+
}
|
|
10645
|
+
self._65 = 1;
|
|
10646
|
+
self._55 = newValue;
|
|
10647
|
+
finale(self);
|
|
10243
10648
|
}
|
|
10244
10649
|
|
|
10650
|
+
function reject(self, newValue) {
|
|
10651
|
+
self._65 = 2;
|
|
10652
|
+
self._55 = newValue;
|
|
10653
|
+
if (Promise._87) {
|
|
10654
|
+
Promise._87(self, newValue);
|
|
10655
|
+
}
|
|
10656
|
+
finale(self);
|
|
10657
|
+
}
|
|
10658
|
+
function finale(self) {
|
|
10659
|
+
if (self._40 === 1) {
|
|
10660
|
+
handle(self, self._72);
|
|
10661
|
+
self._72 = null;
|
|
10662
|
+
}
|
|
10663
|
+
if (self._40 === 2) {
|
|
10664
|
+
for (var i = 0; i < self._72.length; i++) {
|
|
10665
|
+
handle(self, self._72[i]);
|
|
10666
|
+
}
|
|
10667
|
+
self._72 = null;
|
|
10668
|
+
}
|
|
10669
|
+
}
|
|
10245
10670
|
|
|
10246
|
-
function Handler(onFulfilled, onRejected,
|
|
10247
|
-
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null
|
|
10248
|
-
this.onRejected = typeof onRejected === 'function' ? onRejected : null
|
|
10249
|
-
this.
|
|
10250
|
-
this.reject = reject
|
|
10671
|
+
function Handler(onFulfilled, onRejected, promise){
|
|
10672
|
+
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
|
10673
|
+
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
|
10674
|
+
this.promise = promise;
|
|
10251
10675
|
}
|
|
10252
10676
|
|
|
10253
10677
|
/**
|
|
@@ -10256,253 +10680,133 @@ function Handler(onFulfilled, onRejected, resolve, reject){
|
|
|
10256
10680
|
*
|
|
10257
10681
|
* Makes no guarantees about asynchrony.
|
|
10258
10682
|
*/
|
|
10259
|
-
function doResolve(fn,
|
|
10683
|
+
function doResolve(fn, promise) {
|
|
10260
10684
|
var done = false;
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
done = true
|
|
10274
|
-
onRejected(ex)
|
|
10685
|
+
var res = tryCallTwo(fn, function (value) {
|
|
10686
|
+
if (done) return;
|
|
10687
|
+
done = true;
|
|
10688
|
+
resolve(promise, value);
|
|
10689
|
+
}, function (reason) {
|
|
10690
|
+
if (done) return;
|
|
10691
|
+
done = true;
|
|
10692
|
+
reject(promise, reason);
|
|
10693
|
+
});
|
|
10694
|
+
if (!done && res === IS_ERROR) {
|
|
10695
|
+
done = true;
|
|
10696
|
+
reject(promise, LAST_ERROR);
|
|
10275
10697
|
}
|
|
10276
10698
|
}
|
|
10277
10699
|
|
|
10278
|
-
},{"asap":
|
|
10700
|
+
},{"asap/raw":93}],95:[function(require,module,exports){
|
|
10279
10701
|
'use strict';
|
|
10280
10702
|
|
|
10281
10703
|
//This file contains the ES6 extensions to the core Promises/A+ API
|
|
10282
10704
|
|
|
10283
|
-
var Promise = require('./core.js')
|
|
10284
|
-
var asap = require('asap')
|
|
10705
|
+
var Promise = require('./core.js');
|
|
10285
10706
|
|
|
10286
|
-
module.exports = Promise
|
|
10707
|
+
module.exports = Promise;
|
|
10287
10708
|
|
|
10288
10709
|
/* Static Functions */
|
|
10289
10710
|
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
}
|
|
10711
|
+
var TRUE = valuePromise(true);
|
|
10712
|
+
var FALSE = valuePromise(false);
|
|
10713
|
+
var NULL = valuePromise(null);
|
|
10714
|
+
var UNDEFINED = valuePromise(undefined);
|
|
10715
|
+
var ZERO = valuePromise(0);
|
|
10716
|
+
var EMPTYSTRING = valuePromise('');
|
|
10717
|
+
|
|
10718
|
+
function valuePromise(value) {
|
|
10719
|
+
var p = new Promise(Promise._61);
|
|
10720
|
+
p._65 = 1;
|
|
10721
|
+
p._55 = value;
|
|
10722
|
+
return p;
|
|
10303
10723
|
}
|
|
10304
|
-
ValuePromise.prototype = Promise.prototype
|
|
10305
|
-
|
|
10306
|
-
var TRUE = new ValuePromise(true)
|
|
10307
|
-
var FALSE = new ValuePromise(false)
|
|
10308
|
-
var NULL = new ValuePromise(null)
|
|
10309
|
-
var UNDEFINED = new ValuePromise(undefined)
|
|
10310
|
-
var ZERO = new ValuePromise(0)
|
|
10311
|
-
var EMPTYSTRING = new ValuePromise('')
|
|
10312
|
-
|
|
10313
10724
|
Promise.resolve = function (value) {
|
|
10314
|
-
if (value instanceof Promise) return value
|
|
10725
|
+
if (value instanceof Promise) return value;
|
|
10315
10726
|
|
|
10316
|
-
if (value === null) return NULL
|
|
10317
|
-
if (value === undefined) return UNDEFINED
|
|
10318
|
-
if (value === true) return TRUE
|
|
10319
|
-
if (value === false) return FALSE
|
|
10320
|
-
if (value === 0) return ZERO
|
|
10321
|
-
if (value === '') return EMPTYSTRING
|
|
10727
|
+
if (value === null) return NULL;
|
|
10728
|
+
if (value === undefined) return UNDEFINED;
|
|
10729
|
+
if (value === true) return TRUE;
|
|
10730
|
+
if (value === false) return FALSE;
|
|
10731
|
+
if (value === 0) return ZERO;
|
|
10732
|
+
if (value === '') return EMPTYSTRING;
|
|
10322
10733
|
|
|
10323
10734
|
if (typeof value === 'object' || typeof value === 'function') {
|
|
10324
10735
|
try {
|
|
10325
|
-
var then = value.then
|
|
10736
|
+
var then = value.then;
|
|
10326
10737
|
if (typeof then === 'function') {
|
|
10327
|
-
return new Promise(then.bind(value))
|
|
10738
|
+
return new Promise(then.bind(value));
|
|
10328
10739
|
}
|
|
10329
10740
|
} catch (ex) {
|
|
10330
10741
|
return new Promise(function (resolve, reject) {
|
|
10331
|
-
reject(ex)
|
|
10332
|
-
})
|
|
10742
|
+
reject(ex);
|
|
10743
|
+
});
|
|
10333
10744
|
}
|
|
10334
10745
|
}
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
}
|
|
10746
|
+
return valuePromise(value);
|
|
10747
|
+
};
|
|
10338
10748
|
|
|
10339
10749
|
Promise.all = function (arr) {
|
|
10340
|
-
var args = Array.prototype.slice.call(arr)
|
|
10750
|
+
var args = Array.prototype.slice.call(arr);
|
|
10341
10751
|
|
|
10342
10752
|
return new Promise(function (resolve, reject) {
|
|
10343
|
-
if (args.length === 0) return resolve([])
|
|
10344
|
-
var remaining = args.length
|
|
10753
|
+
if (args.length === 0) return resolve([]);
|
|
10754
|
+
var remaining = args.length;
|
|
10345
10755
|
function res(i, val) {
|
|
10346
|
-
|
|
10347
|
-
if (val
|
|
10348
|
-
|
|
10756
|
+
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
10757
|
+
if (val instanceof Promise && val.then === Promise.prototype.then) {
|
|
10758
|
+
while (val._65 === 3) {
|
|
10759
|
+
val = val._55;
|
|
10760
|
+
}
|
|
10761
|
+
if (val._65 === 1) return res(i, val._55);
|
|
10762
|
+
if (val._65 === 2) reject(val._55);
|
|
10763
|
+
val.then(function (val) {
|
|
10764
|
+
res(i, val);
|
|
10765
|
+
}, reject);
|
|
10766
|
+
return;
|
|
10767
|
+
} else {
|
|
10768
|
+
var then = val.then;
|
|
10349
10769
|
if (typeof then === 'function') {
|
|
10350
|
-
|
|
10351
|
-
|
|
10770
|
+
var p = new Promise(then.bind(val));
|
|
10771
|
+
p.then(function (val) {
|
|
10772
|
+
res(i, val);
|
|
10773
|
+
}, reject);
|
|
10774
|
+
return;
|
|
10352
10775
|
}
|
|
10353
10776
|
}
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
} catch (ex) {
|
|
10359
|
-
reject(ex)
|
|
10777
|
+
}
|
|
10778
|
+
args[i] = val;
|
|
10779
|
+
if (--remaining === 0) {
|
|
10780
|
+
resolve(args);
|
|
10360
10781
|
}
|
|
10361
10782
|
}
|
|
10362
10783
|
for (var i = 0; i < args.length; i++) {
|
|
10363
|
-
res(i, args[i])
|
|
10784
|
+
res(i, args[i]);
|
|
10364
10785
|
}
|
|
10365
|
-
})
|
|
10366
|
-
}
|
|
10786
|
+
});
|
|
10787
|
+
};
|
|
10367
10788
|
|
|
10368
10789
|
Promise.reject = function (value) {
|
|
10369
|
-
return new Promise(function (resolve, reject) {
|
|
10790
|
+
return new Promise(function (resolve, reject) {
|
|
10370
10791
|
reject(value);
|
|
10371
10792
|
});
|
|
10372
|
-
}
|
|
10793
|
+
};
|
|
10373
10794
|
|
|
10374
10795
|
Promise.race = function (values) {
|
|
10375
|
-
return new Promise(function (resolve, reject) {
|
|
10796
|
+
return new Promise(function (resolve, reject) {
|
|
10376
10797
|
values.forEach(function(value){
|
|
10377
10798
|
Promise.resolve(value).then(resolve, reject);
|
|
10378
|
-
})
|
|
10799
|
+
});
|
|
10379
10800
|
});
|
|
10380
|
-
}
|
|
10801
|
+
};
|
|
10381
10802
|
|
|
10382
10803
|
/* Prototype Methods */
|
|
10383
10804
|
|
|
10384
10805
|
Promise.prototype['catch'] = function (onRejected) {
|
|
10385
10806
|
return this.then(null, onRejected);
|
|
10386
|
-
}
|
|
10387
|
-
|
|
10388
|
-
},{"./core.js":93,"asap":95}],95:[function(require,module,exports){
|
|
10389
|
-
(function (process){
|
|
10390
|
-
|
|
10391
|
-
// Use the fastest possible means to execute a task in a future turn
|
|
10392
|
-
// of the event loop.
|
|
10393
|
-
|
|
10394
|
-
// linked list of tasks (single, with head node)
|
|
10395
|
-
var head = {task: void 0, next: null};
|
|
10396
|
-
var tail = head;
|
|
10397
|
-
var flushing = false;
|
|
10398
|
-
var requestFlush = void 0;
|
|
10399
|
-
var isNodeJS = false;
|
|
10400
|
-
|
|
10401
|
-
function flush() {
|
|
10402
|
-
/* jshint loopfunc: true */
|
|
10403
|
-
|
|
10404
|
-
while (head.next) {
|
|
10405
|
-
head = head.next;
|
|
10406
|
-
var task = head.task;
|
|
10407
|
-
head.task = void 0;
|
|
10408
|
-
var domain = head.domain;
|
|
10409
|
-
|
|
10410
|
-
if (domain) {
|
|
10411
|
-
head.domain = void 0;
|
|
10412
|
-
domain.enter();
|
|
10413
|
-
}
|
|
10414
|
-
|
|
10415
|
-
try {
|
|
10416
|
-
task();
|
|
10417
|
-
|
|
10418
|
-
} catch (e) {
|
|
10419
|
-
if (isNodeJS) {
|
|
10420
|
-
// In node, uncaught exceptions are considered fatal errors.
|
|
10421
|
-
// Re-throw them synchronously to interrupt flushing!
|
|
10422
|
-
|
|
10423
|
-
// Ensure continuation if the uncaught exception is suppressed
|
|
10424
|
-
// listening "uncaughtException" events (as domains does).
|
|
10425
|
-
// Continue in next event to avoid tick recursion.
|
|
10426
|
-
if (domain) {
|
|
10427
|
-
domain.exit();
|
|
10428
|
-
}
|
|
10429
|
-
setTimeout(flush, 0);
|
|
10430
|
-
if (domain) {
|
|
10431
|
-
domain.enter();
|
|
10432
|
-
}
|
|
10433
|
-
|
|
10434
|
-
throw e;
|
|
10435
|
-
|
|
10436
|
-
} else {
|
|
10437
|
-
// In browsers, uncaught exceptions are not fatal.
|
|
10438
|
-
// Re-throw them asynchronously to avoid slow-downs.
|
|
10439
|
-
setTimeout(function() {
|
|
10440
|
-
throw e;
|
|
10441
|
-
}, 0);
|
|
10442
|
-
}
|
|
10443
|
-
}
|
|
10444
|
-
|
|
10445
|
-
if (domain) {
|
|
10446
|
-
domain.exit();
|
|
10447
|
-
}
|
|
10448
|
-
}
|
|
10449
|
-
|
|
10450
|
-
flushing = false;
|
|
10451
|
-
}
|
|
10452
|
-
|
|
10453
|
-
if (typeof process !== "undefined" && process.nextTick) {
|
|
10454
|
-
// Node.js before 0.9. Note that some fake-Node environments, like the
|
|
10455
|
-
// Mocha test runner, introduce a `process` global without a `nextTick`.
|
|
10456
|
-
isNodeJS = true;
|
|
10457
|
-
|
|
10458
|
-
requestFlush = function () {
|
|
10459
|
-
process.nextTick(flush);
|
|
10460
|
-
};
|
|
10461
|
-
|
|
10462
|
-
} else if (typeof setImmediate === "function") {
|
|
10463
|
-
// In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate
|
|
10464
|
-
if (typeof window !== "undefined") {
|
|
10465
|
-
requestFlush = setImmediate.bind(window, flush);
|
|
10466
|
-
} else {
|
|
10467
|
-
requestFlush = function () {
|
|
10468
|
-
setImmediate(flush);
|
|
10469
|
-
};
|
|
10470
|
-
}
|
|
10471
|
-
|
|
10472
|
-
} else if (typeof MessageChannel !== "undefined") {
|
|
10473
|
-
// modern browsers
|
|
10474
|
-
// http://www.nonblocking.io/2011/06/windownexttick.html
|
|
10475
|
-
var channel = new MessageChannel();
|
|
10476
|
-
channel.port1.onmessage = flush;
|
|
10477
|
-
requestFlush = function () {
|
|
10478
|
-
channel.port2.postMessage(0);
|
|
10479
|
-
};
|
|
10480
|
-
|
|
10481
|
-
} else {
|
|
10482
|
-
// old browsers
|
|
10483
|
-
requestFlush = function () {
|
|
10484
|
-
setTimeout(flush, 0);
|
|
10485
|
-
};
|
|
10486
|
-
}
|
|
10487
|
-
|
|
10488
|
-
function asap(task) {
|
|
10489
|
-
tail = tail.next = {
|
|
10490
|
-
task: task,
|
|
10491
|
-
domain: isNodeJS && process.domain,
|
|
10492
|
-
next: null
|
|
10493
|
-
};
|
|
10494
|
-
|
|
10495
|
-
if (!flushing) {
|
|
10496
|
-
flushing = true;
|
|
10497
|
-
requestFlush();
|
|
10498
|
-
}
|
|
10499
10807
|
};
|
|
10500
10808
|
|
|
10501
|
-
module
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
}).call(this,require('_process'))
|
|
10505
|
-
},{"_process":92}],96:[function(require,module,exports){
|
|
10809
|
+
},{"./core.js":94}],96:[function(require,module,exports){
|
|
10506
10810
|
// should work in any browser without browserify
|
|
10507
10811
|
|
|
10508
10812
|
if (typeof Promise.prototype.done !== 'function') {
|
|
@@ -10527,5 +10831,5 @@ if (typeof Promise === 'undefined') {
|
|
|
10527
10831
|
|
|
10528
10832
|
require('./polyfill-done.js');
|
|
10529
10833
|
|
|
10530
|
-
},{"./lib/core.js":
|
|
10834
|
+
},{"./lib/core.js":94,"./lib/es6-extensions.js":95,"./polyfill-done.js":96,"asap":92}]},{},[2])(2)
|
|
10531
10835
|
});
|