opal 1.3.2 → 1.4.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -0
- data/.github/workflows/build.yml +0 -3
- data/.rubocop.yml +5 -1
- data/UNRELEASED.md +66 -2
- data/benchmark-ips/bm_truthy.rb +30 -0
- data/bin/opal-mspec +1 -3
- data/bin/opal-repl +1 -2
- data/bin/remove-filters +1 -4
- data/docs/compiled_ruby.md +10 -6
- data/exe/opal-repl +1 -3
- data/lib/opal/ast/builder.rb +1 -1
- data/lib/opal/cli.rb +2 -2
- data/lib/opal/cli_runners/nodejs.rb +9 -2
- data/lib/opal/cli_runners/source-map-support-browser.js +80 -216
- data/lib/opal/cli_runners/source-map-support-node.js +80 -216
- data/lib/opal/cli_runners/source-map-support.js +5 -1
- data/lib/opal/cli_runners/system_runner.rb +10 -4
- data/lib/opal/compiler.rb +3 -5
- data/lib/opal/fragment.rb +5 -1
- data/lib/opal/nodes/args/extract_block_arg.rb +1 -8
- data/lib/opal/nodes/args/extract_kwoptarg.rb +1 -3
- data/lib/opal/nodes/args/extract_optarg.rb +1 -3
- data/lib/opal/nodes/args/extract_post_arg.rb +2 -5
- data/lib/opal/nodes/args/extract_post_optarg.rb +2 -7
- data/lib/opal/nodes/args/initialize_iterarg.rb +1 -3
- data/lib/opal/nodes/args/prepare_post_args.rb +5 -1
- data/lib/opal/nodes/base.rb +3 -2
- data/lib/opal/nodes/call.rb +20 -9
- data/lib/opal/nodes/call_special.rb +50 -0
- data/lib/opal/nodes/class.rb +24 -15
- data/lib/opal/nodes/constants.rb +23 -5
- data/lib/opal/nodes/def.rb +20 -23
- data/lib/opal/nodes/defined.rb +5 -5
- data/lib/opal/nodes/definitions.rb +2 -2
- data/lib/opal/nodes/defs.rb +2 -5
- data/lib/opal/nodes/helpers.rb +48 -18
- data/lib/opal/nodes/if.rb +109 -8
- data/lib/opal/nodes/iter.rb +23 -16
- data/lib/opal/nodes/literal.rb +18 -4
- data/lib/opal/nodes/logic.rb +2 -1
- data/lib/opal/nodes/masgn.rb +4 -9
- data/lib/opal/nodes/module.rb +29 -19
- data/lib/opal/nodes/node_with_args.rb +1 -7
- data/lib/opal/nodes/scope.rb +54 -15
- data/lib/opal/nodes/singleton_class.rb +5 -3
- data/lib/opal/nodes/super.rb +3 -3
- data/lib/opal/nodes/top.rb +34 -31
- data/lib/opal/nodes/variables.rb +2 -2
- data/lib/opal/nodes/x_string.rb +3 -0
- data/lib/opal/nodes.rb +0 -1
- data/lib/opal/parser/patch.rb +75 -0
- data/lib/opal/parser/with_ruby_lexer.rb +1 -1
- data/lib/opal/regexp_anchors.rb +7 -7
- data/lib/opal/requires.rb +19 -0
- data/lib/opal/rewriters/pattern_matching.rb +1 -1
- data/lib/opal/rewriters/returnable_logic.rb +102 -4
- data/lib/opal/util.rb +2 -2
- data/lib/opal/version.rb +1 -1
- data/lib/opal.rb +1 -17
- data/opal/corelib/array/pack.rb +11 -11
- data/opal/corelib/array.rb +193 -152
- data/opal/corelib/basic_object.rb +14 -14
- data/opal/corelib/binding.rb +7 -7
- data/opal/corelib/boolean.rb +12 -15
- data/opal/corelib/class.rb +23 -1
- data/opal/corelib/comparable.rb +8 -8
- data/opal/corelib/complex/base.rb +2 -2
- data/opal/corelib/complex.rb +79 -88
- data/opal/corelib/constants.rb +9 -9
- data/opal/corelib/dir.rb +4 -3
- data/opal/corelib/enumerable.rb +140 -127
- data/opal/corelib/enumerator/arithmetic_sequence.rb +177 -0
- data/opal/corelib/enumerator/chain.rb +42 -0
- data/opal/corelib/enumerator/generator.rb +35 -0
- data/opal/corelib/enumerator/lazy.rb +243 -0
- data/opal/corelib/enumerator/yielder.rb +36 -0
- data/opal/corelib/enumerator.rb +45 -300
- data/opal/corelib/error/errno.rb +47 -0
- data/opal/corelib/error.rb +62 -60
- data/opal/corelib/file.rb +26 -12
- data/opal/corelib/hash.rb +98 -107
- data/opal/corelib/helpers.rb +62 -13
- data/opal/corelib/io.rb +47 -34
- data/opal/corelib/kernel/format.rb +29 -29
- data/opal/corelib/kernel.rb +86 -83
- data/opal/corelib/main.rb +14 -12
- data/opal/corelib/marshal/read_buffer.rb +15 -15
- data/opal/corelib/marshal/write_buffer.rb +45 -44
- data/opal/corelib/marshal.rb +3 -3
- data/opal/corelib/math.rb +50 -50
- data/opal/corelib/method.rb +12 -8
- data/opal/corelib/module.rb +96 -79
- data/opal/corelib/nil.rb +9 -11
- data/opal/corelib/number.rb +113 -118
- data/opal/corelib/numeric.rb +37 -33
- data/opal/corelib/object_space.rb +11 -10
- data/opal/corelib/pack_unpack/format_string_parser.rb +3 -3
- data/opal/corelib/pattern_matching/base.rb +7 -7
- data/opal/corelib/pattern_matching.rb +1 -1
- data/opal/corelib/proc.rb +15 -16
- data/opal/corelib/process/base.rb +2 -2
- data/opal/corelib/process/status.rb +21 -0
- data/opal/corelib/process.rb +5 -5
- data/opal/corelib/random/formatter.rb +11 -11
- data/opal/corelib/random/math_random.js.rb +1 -1
- data/opal/corelib/random/mersenne_twister.rb +3 -3
- data/opal/corelib/random/seedrandom.js.rb +3 -3
- data/opal/corelib/random.rb +17 -17
- data/opal/corelib/range.rb +51 -35
- data/opal/corelib/rational/base.rb +4 -4
- data/opal/corelib/rational.rb +61 -62
- data/opal/corelib/regexp.rb +47 -38
- data/opal/corelib/runtime.js +245 -139
- data/opal/corelib/string/encoding.rb +21 -21
- data/opal/corelib/string/unpack.rb +19 -14
- data/opal/corelib/string.rb +135 -128
- data/opal/corelib/struct.rb +59 -46
- data/opal/corelib/time.rb +47 -57
- data/opal/corelib/trace_point.rb +2 -2
- data/opal/corelib/unsupported.rb +31 -120
- data/opal/corelib/variables.rb +3 -3
- data/opal/opal/base.rb +9 -8
- data/opal/opal/full.rb +8 -8
- data/opal/opal/mini.rb +17 -17
- data/opal/opal.rb +17 -18
- data/opal.gemspec +1 -1
- data/spec/filters/bugs/array.rb +4 -24
- data/spec/filters/bugs/bigdecimal.rb +0 -23
- data/spec/filters/bugs/binding.rb +0 -1
- data/spec/filters/bugs/boolean.rb +3 -0
- data/spec/filters/bugs/class.rb +2 -0
- data/spec/filters/bugs/date.rb +0 -5
- data/spec/filters/bugs/encoding.rb +8 -50
- data/spec/filters/bugs/enumerable.rb +4 -1
- data/spec/filters/bugs/enumerator.rb +3 -36
- data/spec/filters/bugs/exception.rb +0 -2
- data/spec/filters/bugs/file.rb +0 -2
- data/spec/filters/bugs/float.rb +0 -3
- data/spec/filters/bugs/hash.rb +5 -3
- data/spec/filters/bugs/integer.rb +2 -3
- data/spec/filters/bugs/kernel.rb +2 -31
- data/spec/filters/bugs/language.rb +29 -49
- data/spec/filters/bugs/main.rb +0 -2
- data/spec/filters/bugs/marshal.rb +2 -3
- data/spec/filters/bugs/matrix.rb +0 -36
- data/spec/filters/bugs/module.rb +7 -61
- data/spec/filters/bugs/numeric.rb +0 -7
- data/spec/filters/bugs/objectspace.rb +1 -1
- data/spec/filters/bugs/pack_unpack.rb +0 -4
- data/spec/filters/bugs/proc.rb +0 -9
- data/spec/filters/bugs/random.rb +0 -5
- data/spec/filters/bugs/range.rb +1 -6
- data/spec/filters/bugs/regexp.rb +0 -3
- data/spec/filters/bugs/set.rb +8 -1
- data/spec/filters/bugs/string.rb +9 -34
- data/spec/filters/bugs/stringscanner.rb +8 -7
- data/spec/filters/bugs/struct.rb +2 -3
- data/spec/filters/bugs/symbol.rb +0 -1
- data/spec/filters/bugs/time.rb +0 -8
- data/spec/filters/bugs/unboundmethod.rb +0 -8
- data/spec/filters/bugs/warnings.rb +1 -7
- data/spec/filters/unsupported/freeze.rb +24 -0
- data/spec/filters/unsupported/integer.rb +1 -0
- data/spec/filters/unsupported/kernel.rb +12 -0
- data/spec/filters/unsupported/privacy.rb +3 -0
- data/spec/filters/unsupported/string.rb +2 -0
- data/spec/lib/builder_spec.rb +2 -2
- data/spec/lib/cli_spec.rb +1 -1
- data/spec/lib/compiler_spec.rb +37 -37
- data/spec/lib/simple_server_spec.rb +2 -2
- data/spec/lib/source_map/file_spec.rb +1 -1
- data/spec/opal/compiler/irb_spec.rb +2 -2
- data/spec/opal/core/kernel/puts_spec.rb +90 -0
- data/spec/opal/core/language/super_spec.rb +24 -0
- data/spec/ruby_specs +4 -2
- data/spec/support/rewriters_helper.rb +1 -1
- data/stdlib/bigdecimal.rb +7 -11
- data/stdlib/buffer/view.rb +2 -2
- data/stdlib/buffer.rb +2 -2
- data/stdlib/date.rb +5 -6
- data/stdlib/erb.rb +1 -0
- data/stdlib/js.rb +2 -1
- data/stdlib/native.rb +7 -8
- data/stdlib/nodejs/argf.rb +4 -4
- data/stdlib/nodejs/base.rb +29 -0
- data/stdlib/nodejs/dir.rb +1 -1
- data/stdlib/nodejs/env.rb +6 -9
- data/stdlib/nodejs/file.rb +23 -17
- data/stdlib/nodejs/fileutils.rb +3 -3
- data/stdlib/nodejs/io.rb +2 -20
- data/stdlib/nodejs/irb.rb +0 -0
- data/stdlib/nodejs/kernel.rb +2 -37
- data/stdlib/nodejs.rb +1 -3
- data/stdlib/opal/miniracer.rb +2 -0
- data/stdlib/opal/platform.rb +6 -13
- data/stdlib/opal/replutils.rb +16 -5
- data/stdlib/opal-parser.rb +2 -2
- data/stdlib/optparse/ac.rb +54 -0
- data/stdlib/optparse/date.rb +14 -0
- data/stdlib/optparse/kwargs.rb +22 -0
- data/stdlib/optparse/shellwords.rb +7 -0
- data/stdlib/optparse/time.rb +15 -0
- data/stdlib/optparse/uri.rb +7 -0
- data/stdlib/optparse/version.rb +69 -0
- data/stdlib/optparse.rb +2279 -0
- data/stdlib/pathname.rb +5 -6
- data/stdlib/pp.rb +18 -2
- data/stdlib/promise/v2.rb +18 -22
- data/stdlib/promise.rb +15 -21
- data/stdlib/set.rb +32 -32
- data/stdlib/shellwords.rb +240 -0
- data/stdlib/stringio.rb +3 -6
- data/stdlib/strscan.rb +5 -8
- data/stdlib/template.rb +2 -2
- data/stdlib/thread.rb +7 -9
- data/tasks/performance.rake +5 -2
- data/tasks/testing/mspec_special_calls.rb +0 -12
- data/tasks/testing.rake +55 -37
- data/test/nodejs/test_file.rb +11 -0
- metadata +55 -10
- data/lib/opal/nodes/case.rb +0 -114
@@ -154,9 +154,12 @@ function fromByteArray (uint8) {
|
|
154
154
|
|
155
155
|
},{}],3:[function(require,module,exports){
|
156
156
|
(function (Buffer){(function (){
|
157
|
+
/* eslint-disable node/no-deprecated-api */
|
158
|
+
|
157
159
|
var toString = Object.prototype.toString
|
158
160
|
|
159
161
|
var isModern = (
|
162
|
+
typeof Buffer !== 'undefined' &&
|
160
163
|
typeof Buffer.alloc === 'function' &&
|
161
164
|
typeof Buffer.allocUnsafe === 'function' &&
|
162
165
|
typeof Buffer.from === 'function'
|
@@ -3470,19 +3473,19 @@ var ArraySet = require('./array-set').ArraySet;
|
|
3470
3473
|
var base64VLQ = require('./base64-vlq');
|
3471
3474
|
var quickSort = require('./quick-sort').quickSort;
|
3472
3475
|
|
3473
|
-
function SourceMapConsumer(aSourceMap
|
3476
|
+
function SourceMapConsumer(aSourceMap) {
|
3474
3477
|
var sourceMap = aSourceMap;
|
3475
3478
|
if (typeof aSourceMap === 'string') {
|
3476
|
-
sourceMap =
|
3479
|
+
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
3477
3480
|
}
|
3478
3481
|
|
3479
3482
|
return sourceMap.sections != null
|
3480
|
-
? new IndexedSourceMapConsumer(sourceMap
|
3481
|
-
: new BasicSourceMapConsumer(sourceMap
|
3483
|
+
? new IndexedSourceMapConsumer(sourceMap)
|
3484
|
+
: new BasicSourceMapConsumer(sourceMap);
|
3482
3485
|
}
|
3483
3486
|
|
3484
|
-
SourceMapConsumer.fromSourceMap = function(aSourceMap
|
3485
|
-
return BasicSourceMapConsumer.fromSourceMap(aSourceMap
|
3487
|
+
SourceMapConsumer.fromSourceMap = function(aSourceMap) {
|
3488
|
+
return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
|
3486
3489
|
}
|
3487
3490
|
|
3488
3491
|
/**
|
@@ -3522,8 +3525,6 @@ SourceMapConsumer.prototype._version = 3;
|
|
3522
3525
|
|
3523
3526
|
SourceMapConsumer.prototype.__generatedMappings = null;
|
3524
3527
|
Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
3525
|
-
configurable: true,
|
3526
|
-
enumerable: true,
|
3527
3528
|
get: function () {
|
3528
3529
|
if (!this.__generatedMappings) {
|
3529
3530
|
this._parseMappings(this._mappings, this.sourceRoot);
|
@@ -3535,8 +3536,6 @@ Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
|
3535
3536
|
|
3536
3537
|
SourceMapConsumer.prototype.__originalMappings = null;
|
3537
3538
|
Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
|
3538
|
-
configurable: true,
|
3539
|
-
enumerable: true,
|
3540
3539
|
get: function () {
|
3541
3540
|
if (!this.__originalMappings) {
|
3542
3541
|
this._parseMappings(this._mappings, this.sourceRoot);
|
@@ -3604,7 +3603,9 @@ SourceMapConsumer.prototype.eachMapping =
|
|
3604
3603
|
var sourceRoot = this.sourceRoot;
|
3605
3604
|
mappings.map(function (mapping) {
|
3606
3605
|
var source = mapping.source === null ? null : this._sources.at(mapping.source);
|
3607
|
-
source
|
3606
|
+
if (source != null && sourceRoot != null) {
|
3607
|
+
source = util.join(sourceRoot, source);
|
3608
|
+
}
|
3608
3609
|
return {
|
3609
3610
|
source: source,
|
3610
3611
|
generatedLine: mapping.generatedLine,
|
@@ -3627,16 +3628,13 @@ SourceMapConsumer.prototype.eachMapping =
|
|
3627
3628
|
* The only argument is an object with the following properties:
|
3628
3629
|
*
|
3629
3630
|
* - source: The filename of the original source.
|
3630
|
-
* - line: The line number in the original source.
|
3631
|
+
* - line: The line number in the original source.
|
3631
3632
|
* - column: Optional. the column number in the original source.
|
3632
|
-
* The column number is 0-based.
|
3633
3633
|
*
|
3634
3634
|
* and an array of objects is returned, each with the following properties:
|
3635
3635
|
*
|
3636
|
-
* - line: The line number in the generated source, or null.
|
3637
|
-
* line number is 1-based.
|
3636
|
+
* - line: The line number in the generated source, or null.
|
3638
3637
|
* - column: The column number in the generated source, or null.
|
3639
|
-
* The column number is 0-based.
|
3640
3638
|
*/
|
3641
3639
|
SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
3642
3640
|
function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
|
@@ -3652,10 +3650,13 @@ SourceMapConsumer.prototype.allGeneratedPositionsFor =
|
|
3652
3650
|
originalColumn: util.getArg(aArgs, 'column', 0)
|
3653
3651
|
};
|
3654
3652
|
|
3655
|
-
|
3656
|
-
|
3653
|
+
if (this.sourceRoot != null) {
|
3654
|
+
needle.source = util.relative(this.sourceRoot, needle.source);
|
3655
|
+
}
|
3656
|
+
if (!this._sources.has(needle.source)) {
|
3657
3657
|
return [];
|
3658
3658
|
}
|
3659
|
+
needle.source = this._sources.indexOf(needle.source);
|
3659
3660
|
|
3660
3661
|
var mappings = [];
|
3661
3662
|
|
@@ -3715,7 +3716,7 @@ exports.SourceMapConsumer = SourceMapConsumer;
|
|
3715
3716
|
* query for information about the original file positions by giving it a file
|
3716
3717
|
* position in the generated source.
|
3717
3718
|
*
|
3718
|
-
* The
|
3719
|
+
* The only parameter is the raw source map (either as a JSON string, or
|
3719
3720
|
* already parsed to an object). According to the spec, source maps have the
|
3720
3721
|
* following attributes:
|
3721
3722
|
*
|
@@ -3738,16 +3739,12 @@ exports.SourceMapConsumer = SourceMapConsumer;
|
|
3738
3739
|
* mappings: "AA,AB;;ABCDE;"
|
3739
3740
|
* }
|
3740
3741
|
*
|
3741
|
-
* The second parameter, if given, is a string whose value is the URL
|
3742
|
-
* at which the source map was found. This URL is used to compute the
|
3743
|
-
* sources array.
|
3744
|
-
*
|
3745
3742
|
* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
|
3746
3743
|
*/
|
3747
|
-
function BasicSourceMapConsumer(aSourceMap
|
3744
|
+
function BasicSourceMapConsumer(aSourceMap) {
|
3748
3745
|
var sourceMap = aSourceMap;
|
3749
3746
|
if (typeof aSourceMap === 'string') {
|
3750
|
-
sourceMap =
|
3747
|
+
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
3751
3748
|
}
|
3752
3749
|
|
3753
3750
|
var version = util.getArg(sourceMap, 'version');
|
@@ -3766,10 +3763,6 @@ function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
|
3766
3763
|
throw new Error('Unsupported version: ' + version);
|
3767
3764
|
}
|
3768
3765
|
|
3769
|
-
if (sourceRoot) {
|
3770
|
-
sourceRoot = util.normalize(sourceRoot);
|
3771
|
-
}
|
3772
|
-
|
3773
3766
|
sources = sources
|
3774
3767
|
.map(String)
|
3775
3768
|
// Some source maps produce relative source paths like "./foo.js" instead of
|
@@ -3793,57 +3786,24 @@ function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
|
3793
3786
|
this._names = ArraySet.fromArray(names.map(String), true);
|
3794
3787
|
this._sources = ArraySet.fromArray(sources, true);
|
3795
3788
|
|
3796
|
-
this._absoluteSources = this._sources.toArray().map(function (s) {
|
3797
|
-
return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
|
3798
|
-
});
|
3799
|
-
|
3800
3789
|
this.sourceRoot = sourceRoot;
|
3801
3790
|
this.sourcesContent = sourcesContent;
|
3802
3791
|
this._mappings = mappings;
|
3803
|
-
this._sourceMapURL = aSourceMapURL;
|
3804
3792
|
this.file = file;
|
3805
3793
|
}
|
3806
3794
|
|
3807
3795
|
BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
|
3808
3796
|
BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
|
3809
3797
|
|
3810
|
-
/**
|
3811
|
-
* Utility function to find the index of a source. Returns -1 if not
|
3812
|
-
* found.
|
3813
|
-
*/
|
3814
|
-
BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
|
3815
|
-
var relativeSource = aSource;
|
3816
|
-
if (this.sourceRoot != null) {
|
3817
|
-
relativeSource = util.relative(this.sourceRoot, relativeSource);
|
3818
|
-
}
|
3819
|
-
|
3820
|
-
if (this._sources.has(relativeSource)) {
|
3821
|
-
return this._sources.indexOf(relativeSource);
|
3822
|
-
}
|
3823
|
-
|
3824
|
-
// Maybe aSource is an absolute URL as returned by |sources|. In
|
3825
|
-
// this case we can't simply undo the transform.
|
3826
|
-
var i;
|
3827
|
-
for (i = 0; i < this._absoluteSources.length; ++i) {
|
3828
|
-
if (this._absoluteSources[i] == aSource) {
|
3829
|
-
return i;
|
3830
|
-
}
|
3831
|
-
}
|
3832
|
-
|
3833
|
-
return -1;
|
3834
|
-
};
|
3835
|
-
|
3836
3798
|
/**
|
3837
3799
|
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
3838
3800
|
*
|
3839
3801
|
* @param SourceMapGenerator aSourceMap
|
3840
3802
|
* The source map that will be consumed.
|
3841
|
-
* @param String aSourceMapURL
|
3842
|
-
* The URL at which the source map can be found (optional)
|
3843
3803
|
* @returns BasicSourceMapConsumer
|
3844
3804
|
*/
|
3845
3805
|
BasicSourceMapConsumer.fromSourceMap =
|
3846
|
-
function SourceMapConsumer_fromSourceMap(aSourceMap
|
3806
|
+
function SourceMapConsumer_fromSourceMap(aSourceMap) {
|
3847
3807
|
var smc = Object.create(BasicSourceMapConsumer.prototype);
|
3848
3808
|
|
3849
3809
|
var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
|
@@ -3852,10 +3812,6 @@ BasicSourceMapConsumer.fromSourceMap =
|
|
3852
3812
|
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
|
3853
3813
|
smc.sourceRoot);
|
3854
3814
|
smc.file = aSourceMap._file;
|
3855
|
-
smc._sourceMapURL = aSourceMapURL;
|
3856
|
-
smc._absoluteSources = smc._sources.toArray().map(function (s) {
|
3857
|
-
return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
|
3858
|
-
});
|
3859
3815
|
|
3860
3816
|
// Because we are modifying the entries (by converting string sources and
|
3861
3817
|
// names to indices into the sources and names ArraySets), we have to make
|
@@ -3902,7 +3858,9 @@ BasicSourceMapConsumer.prototype._version = 3;
|
|
3902
3858
|
*/
|
3903
3859
|
Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
|
3904
3860
|
get: function () {
|
3905
|
-
return this.
|
3861
|
+
return this._sources.toArray().map(function (s) {
|
3862
|
+
return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
|
3863
|
+
}, this);
|
3906
3864
|
}
|
3907
3865
|
});
|
3908
3866
|
|
@@ -4083,10 +4041,8 @@ BasicSourceMapConsumer.prototype.computeColumnSpans =
|
|
4083
4041
|
* source's line and column positions provided. The only argument is an object
|
4084
4042
|
* with the following properties:
|
4085
4043
|
*
|
4086
|
-
* - line: The line number in the generated source.
|
4087
|
-
*
|
4088
|
-
* - column: The column number in the generated source. The column
|
4089
|
-
* number is 0-based.
|
4044
|
+
* - line: The line number in the generated source.
|
4045
|
+
* - column: The column number in the generated source.
|
4090
4046
|
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
4091
4047
|
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
4092
4048
|
* closest element that is smaller than or greater than the one we are
|
@@ -4096,10 +4052,8 @@ BasicSourceMapConsumer.prototype.computeColumnSpans =
|
|
4096
4052
|
* and an object is returned with the following properties:
|
4097
4053
|
*
|
4098
4054
|
* - source: The original source file, or null.
|
4099
|
-
* - line: The line number in the original source, or null.
|
4100
|
-
*
|
4101
|
-
* - column: The column number in the original source, or null. The
|
4102
|
-
* column number is 0-based.
|
4055
|
+
* - line: The line number in the original source, or null.
|
4056
|
+
* - column: The column number in the original source, or null.
|
4103
4057
|
* - name: The original identifier, or null.
|
4104
4058
|
*/
|
4105
4059
|
BasicSourceMapConsumer.prototype.originalPositionFor =
|
@@ -4125,7 +4079,9 @@ BasicSourceMapConsumer.prototype.originalPositionFor =
|
|
4125
4079
|
var source = util.getArg(mapping, 'source', null);
|
4126
4080
|
if (source !== null) {
|
4127
4081
|
source = this._sources.at(source);
|
4128
|
-
|
4082
|
+
if (this.sourceRoot != null) {
|
4083
|
+
source = util.join(this.sourceRoot, source);
|
4084
|
+
}
|
4129
4085
|
}
|
4130
4086
|
var name = util.getArg(mapping, 'name', null);
|
4131
4087
|
if (name !== null) {
|
@@ -4172,14 +4128,12 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
|
4172
4128
|
return null;
|
4173
4129
|
}
|
4174
4130
|
|
4175
|
-
|
4176
|
-
|
4177
|
-
return this.sourcesContent[index];
|
4131
|
+
if (this.sourceRoot != null) {
|
4132
|
+
aSource = util.relative(this.sourceRoot, aSource);
|
4178
4133
|
}
|
4179
4134
|
|
4180
|
-
|
4181
|
-
|
4182
|
-
relativeSource = util.relative(this.sourceRoot, relativeSource);
|
4135
|
+
if (this._sources.has(aSource)) {
|
4136
|
+
return this.sourcesContent[this._sources.indexOf(aSource)];
|
4183
4137
|
}
|
4184
4138
|
|
4185
4139
|
var url;
|
@@ -4189,15 +4143,15 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
|
4189
4143
|
// many users. We can help them out when they expect file:// URIs to
|
4190
4144
|
// behave like it would if they were running a local HTTP server. See
|
4191
4145
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
|
4192
|
-
var fileUriAbsPath =
|
4146
|
+
var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
|
4193
4147
|
if (url.scheme == "file"
|
4194
4148
|
&& this._sources.has(fileUriAbsPath)) {
|
4195
4149
|
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
4196
4150
|
}
|
4197
4151
|
|
4198
4152
|
if ((!url.path || url.path == "/")
|
4199
|
-
&& this._sources.has("/" +
|
4200
|
-
return this.sourcesContent[this._sources.indexOf("/" +
|
4153
|
+
&& this._sources.has("/" + aSource)) {
|
4154
|
+
return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
4201
4155
|
}
|
4202
4156
|
}
|
4203
4157
|
|
@@ -4209,7 +4163,7 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
|
4209
4163
|
return null;
|
4210
4164
|
}
|
4211
4165
|
else {
|
4212
|
-
throw new Error('"' +
|
4166
|
+
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
4213
4167
|
}
|
4214
4168
|
};
|
4215
4169
|
|
@@ -4219,10 +4173,8 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
|
4219
4173
|
* the following properties:
|
4220
4174
|
*
|
4221
4175
|
* - source: The filename of the original source.
|
4222
|
-
* - line: The line number in the original source.
|
4223
|
-
*
|
4224
|
-
* - column: The column number in the original source. The column
|
4225
|
-
* number is 0-based.
|
4176
|
+
* - line: The line number in the original source.
|
4177
|
+
* - column: The column number in the original source.
|
4226
4178
|
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
4227
4179
|
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
4228
4180
|
* closest element that is smaller than or greater than the one we are
|
@@ -4231,22 +4183,23 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
|
|
4231
4183
|
*
|
4232
4184
|
* and an object is returned with the following properties:
|
4233
4185
|
*
|
4234
|
-
* - line: The line number in the generated source, or null.
|
4235
|
-
* line number is 1-based.
|
4186
|
+
* - line: The line number in the generated source, or null.
|
4236
4187
|
* - column: The column number in the generated source, or null.
|
4237
|
-
* The column number is 0-based.
|
4238
4188
|
*/
|
4239
4189
|
BasicSourceMapConsumer.prototype.generatedPositionFor =
|
4240
4190
|
function SourceMapConsumer_generatedPositionFor(aArgs) {
|
4241
4191
|
var source = util.getArg(aArgs, 'source');
|
4242
|
-
|
4243
|
-
|
4192
|
+
if (this.sourceRoot != null) {
|
4193
|
+
source = util.relative(this.sourceRoot, source);
|
4194
|
+
}
|
4195
|
+
if (!this._sources.has(source)) {
|
4244
4196
|
return {
|
4245
4197
|
line: null,
|
4246
4198
|
column: null,
|
4247
4199
|
lastColumn: null
|
4248
4200
|
};
|
4249
4201
|
}
|
4202
|
+
source = this._sources.indexOf(source);
|
4250
4203
|
|
4251
4204
|
var needle = {
|
4252
4205
|
source: source,
|
@@ -4290,7 +4243,7 @@ exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
|
|
4290
4243
|
* that it takes "indexed" source maps (i.e. ones with a "sections" field) as
|
4291
4244
|
* input.
|
4292
4245
|
*
|
4293
|
-
* The
|
4246
|
+
* The only parameter is a raw source map (either as a JSON string, or already
|
4294
4247
|
* parsed to an object). According to the spec for indexed source maps, they
|
4295
4248
|
* have the following attributes:
|
4296
4249
|
*
|
@@ -4327,16 +4280,12 @@ exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
|
|
4327
4280
|
* }],
|
4328
4281
|
* }
|
4329
4282
|
*
|
4330
|
-
* The second parameter, if given, is a string whose value is the URL
|
4331
|
-
* at which the source map was found. This URL is used to compute the
|
4332
|
-
* sources array.
|
4333
|
-
*
|
4334
4283
|
* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
|
4335
4284
|
*/
|
4336
|
-
function IndexedSourceMapConsumer(aSourceMap
|
4285
|
+
function IndexedSourceMapConsumer(aSourceMap) {
|
4337
4286
|
var sourceMap = aSourceMap;
|
4338
4287
|
if (typeof aSourceMap === 'string') {
|
4339
|
-
sourceMap =
|
4288
|
+
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
4340
4289
|
}
|
4341
4290
|
|
4342
4291
|
var version = util.getArg(sourceMap, 'version');
|
@@ -4376,7 +4325,7 @@ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
|
|
4376
4325
|
generatedLine: offsetLine + 1,
|
4377
4326
|
generatedColumn: offsetColumn + 1
|
4378
4327
|
},
|
4379
|
-
consumer: new SourceMapConsumer(util.getArg(s, 'map')
|
4328
|
+
consumer: new SourceMapConsumer(util.getArg(s, 'map'))
|
4380
4329
|
}
|
4381
4330
|
});
|
4382
4331
|
}
|
@@ -4409,18 +4358,14 @@ Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
|
|
4409
4358
|
* source's line and column positions provided. The only argument is an object
|
4410
4359
|
* with the following properties:
|
4411
4360
|
*
|
4412
|
-
* - line: The line number in the generated source.
|
4413
|
-
*
|
4414
|
-
* - column: The column number in the generated source. The column
|
4415
|
-
* number is 0-based.
|
4361
|
+
* - line: The line number in the generated source.
|
4362
|
+
* - column: The column number in the generated source.
|
4416
4363
|
*
|
4417
4364
|
* and an object is returned with the following properties:
|
4418
4365
|
*
|
4419
4366
|
* - source: The original source file, or null.
|
4420
|
-
* - line: The line number in the original source, or null.
|
4421
|
-
*
|
4422
|
-
* - column: The column number in the original source, or null. The
|
4423
|
-
* column number is 0-based.
|
4367
|
+
* - line: The line number in the original source, or null.
|
4368
|
+
* - column: The column number in the original source, or null.
|
4424
4369
|
* - name: The original identifier, or null.
|
4425
4370
|
*/
|
4426
4371
|
IndexedSourceMapConsumer.prototype.originalPositionFor =
|
@@ -4504,17 +4449,13 @@ IndexedSourceMapConsumer.prototype.sourceContentFor =
|
|
4504
4449
|
* the following properties:
|
4505
4450
|
*
|
4506
4451
|
* - source: The filename of the original source.
|
4507
|
-
* - line: The line number in the original source.
|
4508
|
-
*
|
4509
|
-
* - column: The column number in the original source. The column
|
4510
|
-
* number is 0-based.
|
4452
|
+
* - line: The line number in the original source.
|
4453
|
+
* - column: The column number in the original source.
|
4511
4454
|
*
|
4512
4455
|
* and an object is returned with the following properties:
|
4513
4456
|
*
|
4514
|
-
* - line: The line number in the generated source, or null.
|
4515
|
-
* line number is 1-based.
|
4457
|
+
* - line: The line number in the generated source, or null.
|
4516
4458
|
* - column: The column number in the generated source, or null.
|
4517
|
-
* The column number is 0-based.
|
4518
4459
|
*/
|
4519
4460
|
IndexedSourceMapConsumer.prototype.generatedPositionFor =
|
4520
4461
|
function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
|
@@ -4523,7 +4464,7 @@ IndexedSourceMapConsumer.prototype.generatedPositionFor =
|
|
4523
4464
|
|
4524
4465
|
// Only consider this section if the requested source is in the list of
|
4525
4466
|
// sources of the consumer.
|
4526
|
-
if (section.consumer.
|
4467
|
+
if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
|
4527
4468
|
continue;
|
4528
4469
|
}
|
4529
4470
|
var generatedPosition = section.consumer.generatedPositionFor(aArgs);
|
@@ -4562,16 +4503,15 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
|
4562
4503
|
var mapping = sectionMappings[j];
|
4563
4504
|
|
4564
4505
|
var source = section.consumer._sources.at(mapping.source);
|
4565
|
-
|
4506
|
+
if (section.consumer.sourceRoot !== null) {
|
4507
|
+
source = util.join(section.consumer.sourceRoot, source);
|
4508
|
+
}
|
4566
4509
|
this._sources.add(source);
|
4567
4510
|
source = this._sources.indexOf(source);
|
4568
4511
|
|
4569
|
-
var name =
|
4570
|
-
|
4571
|
-
|
4572
|
-
this._names.add(name);
|
4573
|
-
name = this._names.indexOf(name);
|
4574
|
-
}
|
4512
|
+
var name = section.consumer._names.at(mapping.name);
|
4513
|
+
this._names.add(name);
|
4514
|
+
name = this._names.indexOf(name);
|
4575
4515
|
|
4576
4516
|
// The mappings coming from the consumer for the section have
|
4577
4517
|
// generated positions relative to the start of the section, so we
|
@@ -4678,15 +4618,6 @@ SourceMapGenerator.fromSourceMap =
|
|
4678
4618
|
generator.addMapping(newMapping);
|
4679
4619
|
});
|
4680
4620
|
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
4681
|
-
var sourceRelative = sourceFile;
|
4682
|
-
if (sourceRoot !== null) {
|
4683
|
-
sourceRelative = util.relative(sourceRoot, sourceFile);
|
4684
|
-
}
|
4685
|
-
|
4686
|
-
if (!generator._sources.has(sourceRelative)) {
|
4687
|
-
generator._sources.add(sourceRelative);
|
4688
|
-
}
|
4689
|
-
|
4690
4621
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
4691
4622
|
if (content != null) {
|
4692
4623
|
generator.setSourceContent(sourceFile, content);
|
@@ -5130,7 +5061,7 @@ SourceNode.fromStringWithSourceMap =
|
|
5130
5061
|
// There is no new line in between.
|
5131
5062
|
// Associate the code between "lastGeneratedColumn" and
|
5132
5063
|
// "mapping.generatedColumn" with "lastMapping"
|
5133
|
-
var nextLine = remainingLines[remainingLinesIndex]
|
5064
|
+
var nextLine = remainingLines[remainingLinesIndex];
|
5134
5065
|
var code = nextLine.substr(0, mapping.generatedColumn -
|
5135
5066
|
lastGeneratedColumn);
|
5136
5067
|
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
|
@@ -5150,7 +5081,7 @@ SourceNode.fromStringWithSourceMap =
|
|
5150
5081
|
lastGeneratedLine++;
|
5151
5082
|
}
|
5152
5083
|
if (lastGeneratedColumn < mapping.generatedColumn) {
|
5153
|
-
var nextLine = remainingLines[remainingLinesIndex]
|
5084
|
+
var nextLine = remainingLines[remainingLinesIndex];
|
5154
5085
|
node.add(nextLine.substr(0, mapping.generatedColumn));
|
5155
5086
|
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
5156
5087
|
lastGeneratedColumn = mapping.generatedColumn;
|
@@ -5474,7 +5405,7 @@ function getArg(aArgs, aName, aDefaultValue) {
|
|
5474
5405
|
}
|
5475
5406
|
exports.getArg = getArg;
|
5476
5407
|
|
5477
|
-
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w
|
5408
|
+
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
|
5478
5409
|
var dataUrlRegexp = /^data:.+\,.+$/;
|
5479
5410
|
|
5480
5411
|
function urlParse(aUrl) {
|
@@ -5630,7 +5561,7 @@ function join(aRoot, aPath) {
|
|
5630
5561
|
exports.join = join;
|
5631
5562
|
|
5632
5563
|
exports.isAbsolute = function (aPath) {
|
5633
|
-
return aPath.charAt(0) === '/' ||
|
5564
|
+
return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
|
5634
5565
|
};
|
5635
5566
|
|
5636
5567
|
/**
|
@@ -5750,7 +5681,7 @@ function isProtoString(s) {
|
|
5750
5681
|
* stubbed out mapping.
|
5751
5682
|
*/
|
5752
5683
|
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
5753
|
-
var cmp =
|
5684
|
+
var cmp = mappingA.source - mappingB.source;
|
5754
5685
|
if (cmp !== 0) {
|
5755
5686
|
return cmp;
|
5756
5687
|
}
|
@@ -5775,7 +5706,7 @@ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
|
5775
5706
|
return cmp;
|
5776
5707
|
}
|
5777
5708
|
|
5778
|
-
return
|
5709
|
+
return mappingA.name - mappingB.name;
|
5779
5710
|
}
|
5780
5711
|
exports.compareByOriginalPositions = compareByOriginalPositions;
|
5781
5712
|
|
@@ -5799,7 +5730,7 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene
|
|
5799
5730
|
return cmp;
|
5800
5731
|
}
|
5801
5732
|
|
5802
|
-
cmp =
|
5733
|
+
cmp = mappingA.source - mappingB.source;
|
5803
5734
|
if (cmp !== 0) {
|
5804
5735
|
return cmp;
|
5805
5736
|
}
|
@@ -5814,7 +5745,7 @@ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGene
|
|
5814
5745
|
return cmp;
|
5815
5746
|
}
|
5816
5747
|
|
5817
|
-
return
|
5748
|
+
return mappingA.name - mappingB.name;
|
5818
5749
|
}
|
5819
5750
|
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
5820
5751
|
|
@@ -5823,14 +5754,6 @@ function strcmp(aStr1, aStr2) {
|
|
5823
5754
|
return 0;
|
5824
5755
|
}
|
5825
5756
|
|
5826
|
-
if (aStr1 === null) {
|
5827
|
-
return 1; // aStr2 !== null
|
5828
|
-
}
|
5829
|
-
|
5830
|
-
if (aStr2 === null) {
|
5831
|
-
return -1; // aStr1 !== null
|
5832
|
-
}
|
5833
|
-
|
5834
5757
|
if (aStr1 > aStr2) {
|
5835
5758
|
return 1;
|
5836
5759
|
}
|
@@ -5872,69 +5795,6 @@ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
|
5872
5795
|
}
|
5873
5796
|
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
5874
5797
|
|
5875
|
-
/**
|
5876
|
-
* Strip any JSON XSSI avoidance prefix from the string (as documented
|
5877
|
-
* in the source maps specification), and then parse the string as
|
5878
|
-
* JSON.
|
5879
|
-
*/
|
5880
|
-
function parseSourceMapInput(str) {
|
5881
|
-
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
|
5882
|
-
}
|
5883
|
-
exports.parseSourceMapInput = parseSourceMapInput;
|
5884
|
-
|
5885
|
-
/**
|
5886
|
-
* Compute the URL of a source given the the source root, the source's
|
5887
|
-
* URL, and the source map's URL.
|
5888
|
-
*/
|
5889
|
-
function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
|
5890
|
-
sourceURL = sourceURL || '';
|
5891
|
-
|
5892
|
-
if (sourceRoot) {
|
5893
|
-
// This follows what Chrome does.
|
5894
|
-
if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
|
5895
|
-
sourceRoot += '/';
|
5896
|
-
}
|
5897
|
-
// The spec says:
|
5898
|
-
// Line 4: An optional source root, useful for relocating source
|
5899
|
-
// files on a server or removing repeated values in the
|
5900
|
-
// “sources” entry. This value is prepended to the individual
|
5901
|
-
// entries in the “source” field.
|
5902
|
-
sourceURL = sourceRoot + sourceURL;
|
5903
|
-
}
|
5904
|
-
|
5905
|
-
// Historically, SourceMapConsumer did not take the sourceMapURL as
|
5906
|
-
// a parameter. This mode is still somewhat supported, which is why
|
5907
|
-
// this code block is conditional. However, it's preferable to pass
|
5908
|
-
// the source map URL to SourceMapConsumer, so that this function
|
5909
|
-
// can implement the source URL resolution algorithm as outlined in
|
5910
|
-
// the spec. This block is basically the equivalent of:
|
5911
|
-
// new URL(sourceURL, sourceMapURL).toString()
|
5912
|
-
// ... except it avoids using URL, which wasn't available in the
|
5913
|
-
// older releases of node still supported by this library.
|
5914
|
-
//
|
5915
|
-
// The spec says:
|
5916
|
-
// If the sources are not absolute URLs after prepending of the
|
5917
|
-
// “sourceRoot”, the sources are resolved relative to the
|
5918
|
-
// SourceMap (like resolving script src in a html document).
|
5919
|
-
if (sourceMapURL) {
|
5920
|
-
var parsed = urlParse(sourceMapURL);
|
5921
|
-
if (!parsed) {
|
5922
|
-
throw new Error("sourceMapURL could not be parsed");
|
5923
|
-
}
|
5924
|
-
if (parsed.path) {
|
5925
|
-
// Strip the last path component, but keep the "/".
|
5926
|
-
var index = parsed.path.lastIndexOf('/');
|
5927
|
-
if (index >= 0) {
|
5928
|
-
parsed.path = parsed.path.substring(0, index + 1);
|
5929
|
-
}
|
5930
|
-
}
|
5931
|
-
sourceURL = join(urlGenerate(parsed), sourceURL);
|
5932
|
-
}
|
5933
|
-
|
5934
|
-
return normalize(sourceURL);
|
5935
|
-
}
|
5936
|
-
exports.computeSourceURL = computeSourceURL;
|
5937
|
-
|
5938
5798
|
},{}],18:[function(require,module,exports){
|
5939
5799
|
/*
|
5940
5800
|
* Copyright 2009-2011 Mozilla Foundation and contributors
|
@@ -6465,7 +6325,11 @@ function printErrorAndExit (error) {
|
|
6465
6325
|
}
|
6466
6326
|
|
6467
6327
|
if (typeof error.$full_message === 'function') {
|
6468
|
-
|
6328
|
+
var full_message = error.$full_message();
|
6329
|
+
while (full_message[full_message.length - 1] == "\n") {
|
6330
|
+
full_message = full_message.slice(0, full_message.length - 1);
|
6331
|
+
}
|
6332
|
+
console.error(full_message);
|
6469
6333
|
}
|
6470
6334
|
else {
|
6471
6335
|
if (source) {
|