requirejs-rails 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 571c2ca045ec5efe5b3a61e666f8c04d81edbd2d
4
- data.tar.gz: c7b95db0b61fd15d7be55c5faa63710e02e44a9d
3
+ metadata.gz: 0d36c8ac1ffc557f4d35301e35241af13ed319c5
4
+ data.tar.gz: 5aea76566e706e5cb1048b5f1f1b7bedcb18af6b
5
5
  SHA512:
6
- metadata.gz: ff9435da3a7e1298f277a354c28ea990616cda9e4bfba85e01f77a550f45a09701d468b4576ebc99bea6b2bebf132d13d4d47fcba012d4196de5f8c459ff413b
7
- data.tar.gz: 3b158d6d58f3a0c2195c6c956e5d4ccffaccb7fce07f5e17d40f6e9c60cbcdba5b3acb4bdc27cdd277208abf0ce46be3b1230a00ae938f867d48bbef93d2522d
6
+ metadata.gz: e395c2c0d2a70b487218b0e559578696e2f4d0eb1436b1d4fbbce5b15576c208d4283da25108f0694db9a9b2d0dfeeea8ab8f08a28670649b09e3a149a8236ba
7
+ data.tar.gz: ab3693d7d35349f42539a858fb687b7c9d9d5d932373c25903782c9caf711d5302caaf523d986a198b21592774fd18a81bd2eed310ae25b7647a40b29b92616a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  <!--
2
2
  Marked Style: GitHub
3
3
  -->
4
+ # v0.9.3
5
+
6
+ - Update `require.js` to `2.1.11` and `almond.js` to `0.2.9`.
7
+
4
8
  # v0.9.2
5
9
 
6
10
  - Update `require.js` to `2.1.10` and `almond.js` to `0.2.5`.
data/Gemfile.lock CHANGED
@@ -2,7 +2,7 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  requirejs-rails (0.9.2)
5
- railties (>= 3.1.1, < 4.1)
5
+ railties (>= 3.1.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -90,6 +90,6 @@ PLATFORMS
90
90
  DEPENDENCIES
91
91
  execjs
92
92
  jquery-rails
93
- rails (>= 3.1.1, < 4.1)
93
+ rails (>= 3.1.1)
94
94
  requirejs-rails!
95
95
  sqlite3
@@ -13,7 +13,7 @@ module RequirejsHelper
13
13
  name += ".js" unless name =~ /\.js$/
14
14
  data['main'] = _javascript_path(name).
15
15
  sub(/\.js$/,'').
16
- sub(baseUrl(name), '').
16
+ sub(base_url(name), '').
17
17
  sub(/\A\//, '')
18
18
  end
19
19
 
@@ -58,7 +58,7 @@ module RequirejsHelper
58
58
  run_config['paths'] = paths
59
59
  end
60
60
 
61
- run_config['baseUrl'] = baseUrl(name)
61
+ run_config['baseUrl'] = base_url(name)
62
62
  html.concat <<-HTML
63
63
  <script>var require = #{run_config.to_json};</script>
64
64
  HTML
@@ -95,10 +95,10 @@ module RequirejsHelper
95
95
  end
96
96
  end
97
97
 
98
- def baseUrl(js_asset)
98
+ def base_url(js_asset)
99
99
  js_asset_path = javascript_path(js_asset)
100
100
  uri = URI.parse(js_asset_path)
101
101
  asset_host = uri.host && js_asset_path.sub(uri.request_uri, '')
102
- [asset_host, Rails.application.config.assets.prefix].join
102
+ [asset_host, Rails.application.config.relative_url_root, Rails.application.config.assets.prefix].join
103
103
  end
104
104
  end
data/bin/r.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license r.js 2.1.10 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
3
3
  * Available via the MIT or new BSD license.
4
4
  * see: http://github.com/jrburke/requirejs for details
5
5
  */
@@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
20
20
  (function (console, args, readFileFunc) {
21
21
  var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
22
22
  nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
23
- version = '2.1.10',
23
+ version = '2.1.11',
24
24
  jsSuffixRegExp = /\.js$/,
25
25
  commandOption = '',
26
26
  useLibLoaded = {},
@@ -238,7 +238,7 @@ var requirejs, require, define, xpcUtil;
238
238
  }
239
239
 
240
240
  /** vim: et:ts=4:sw=4:sts=4
241
- * @license RequireJS 2.1.10 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
241
+ * @license RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
242
242
  * Available via the MIT or new BSD license.
243
243
  * see: http://github.com/jrburke/requirejs for details
244
244
  */
@@ -251,7 +251,7 @@ var requirejs, require, define, xpcUtil;
251
251
  (function (global) {
252
252
  var req, s, head, baseElement, dataMain, src,
253
253
  interactiveScript, currentlyAddingScript, mainScript, subPath,
254
- version = '2.1.10',
254
+ version = '2.1.11',
255
255
  commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
256
256
  cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
257
257
  jsSuffixRegExp = /\.js$/,
@@ -380,7 +380,7 @@ var requirejs, require, define, xpcUtil;
380
380
  throw err;
381
381
  }
382
382
 
383
- //Allow getting a global that expressed in
383
+ //Allow getting a global that is expressed in
384
384
  //dot notation, like 'a.b.c'.
385
385
  function getGlobal(value) {
386
386
  if (!value) {
@@ -806,7 +806,7 @@ var requirejs, require, define, xpcUtil;
806
806
  mod.usingExports = true;
807
807
  if (mod.map.isDefine) {
808
808
  if (mod.exports) {
809
- return mod.exports;
809
+ return (defined[mod.map.id] = mod.exports);
810
810
  } else {
811
811
  return (mod.exports = defined[mod.map.id] = {});
812
812
  }
@@ -822,7 +822,7 @@ var requirejs, require, define, xpcUtil;
822
822
  config: function () {
823
823
  return getOwn(config.config, mod.map.id) || {};
824
824
  },
825
- exports: handlers.exports(mod)
825
+ exports: mod.exports || (mod.exports = {})
826
826
  });
827
827
  }
828
828
  }
@@ -1741,7 +1741,7 @@ var requirejs, require, define, xpcUtil;
1741
1741
  /**
1742
1742
  * Called to enable a module if it is still in the registry
1743
1743
  * awaiting enablement. A second arg, parent, the parent module,
1744
- * is passed in for context, when this method is overriden by
1744
+ * is passed in for context, when this method is overridden by
1745
1745
  * the optimizer. Not shown here to keep code compact.
1746
1746
  */
1747
1747
  enable: function (depMap) {
@@ -9683,7 +9683,7 @@ define('uglifyjs/parse-js', ["exports"], function(exports) {
9683
9683
  disclaimer in the documentation and/or other materials
9684
9684
  provided with the distribution.
9685
9685
 
9686
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
9686
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
9687
9687
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9688
9688
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
9689
9689
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -11134,7 +11134,7 @@ define('uglifyjs/process', ["require", "exports", "module", "./parse-js", "./squ
11134
11134
  disclaimer in the documentation and/or other materials
11135
11135
  provided with the distribution.
11136
11136
 
11137
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
11137
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
11138
11138
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
11139
11139
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
11140
11140
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -13839,6 +13839,7 @@ define('source-map/source-map-consumer', function (require, exports, module) {
13839
13839
  }
13840
13840
  }
13841
13841
 
13842
+ this.__generatedMappings.sort(util.compareByGeneratedPositions);
13842
13843
  this.__originalMappings.sort(util.compareByOriginalPositions);
13843
13844
  };
13844
13845
 
@@ -14309,7 +14310,7 @@ define('source-map/source-map-generator', function (require, exports, module) {
14309
14310
  throw new Error('Invalid mapping: ' + JSON.stringify({
14310
14311
  generated: aGenerated,
14311
14312
  source: aSource,
14312
- orginal: aOriginal,
14313
+ original: aOriginal,
14313
14314
  name: aName
14314
14315
  }));
14315
14316
  }
@@ -15052,7 +15053,7 @@ define('uglifyjs2', ['exports', 'source-map', 'logger', 'env!env/file'], functio
15052
15053
  disclaimer in the documentation and/or other materials
15053
15054
  provided with the distribution.
15054
15055
 
15055
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
15056
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
15056
15057
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15057
15058
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15058
15059
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -15355,7 +15356,7 @@ Dictionary.prototype = {
15355
15356
  disclaimer in the documentation and/or other materials
15356
15357
  provided with the distribution.
15357
15358
 
15358
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
15359
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
15359
15360
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15360
15361
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15361
15362
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -15714,11 +15715,11 @@ var AST_Defun = DEFNODE("Defun", null, {
15714
15715
  /* -----[ JUMPS ]----- */
15715
15716
 
15716
15717
  var AST_Jump = DEFNODE("Jump", null, {
15717
- $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
15718
+ $documentation: "Base class for jumps (for now that's `return`, `throw`, `break` and `continue`)"
15718
15719
  }, AST_Statement);
15719
15720
 
15720
15721
  var AST_Exit = DEFNODE("Exit", "value", {
15721
- $documentation: "Base class for “exits” (`return` and `throw`)",
15722
+ $documentation: "Base class for exits (`return` and `throw`)",
15722
15723
  $propdoc: {
15723
15724
  value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
15724
15725
  },
@@ -15779,7 +15780,7 @@ var AST_If = DEFNODE("If", "condition alternative", {
15779
15780
  var AST_Switch = DEFNODE("Switch", "expression", {
15780
15781
  $documentation: "A `switch` statement",
15781
15782
  $propdoc: {
15782
- expression: "[AST_Node] the `switch` “discriminant”"
15783
+ expression: "[AST_Node] the `switch` discriminant"
15783
15784
  },
15784
15785
  _walk: function(visitor) {
15785
15786
  return visitor._visit(this, function(){
@@ -15966,7 +15967,7 @@ var AST_Seq = DEFNODE("Seq", "car cdr", {
15966
15967
  var AST_PropAccess = DEFNODE("PropAccess", "expression property", {
15967
15968
  $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
15968
15969
  $propdoc: {
15969
- expression: "[AST_Node] the “container” expression",
15970
+ expression: "[AST_Node] the container expression",
15970
15971
  property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node"
15971
15972
  }
15972
15973
  });
@@ -16043,7 +16044,7 @@ var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative",
16043
16044
  });
16044
16045
 
16045
16046
  var AST_Assign = DEFNODE("Assign", null, {
16046
- $documentation: "An assignment expression — `a = b + 5`",
16047
+ $documentation: "An assignment expression `a = b + 5`",
16047
16048
  }, AST_Binary);
16048
16049
 
16049
16050
  /* -----[ LITERALS ]----- */
@@ -16341,7 +16342,7 @@ TreeWalker.prototype = {
16341
16342
  disclaimer in the documentation and/or other materials
16342
16343
  provided with the distribution.
16343
16344
 
16344
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
16345
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
16345
16346
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16346
16347
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16347
16348
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -16360,7 +16361,7 @@ TreeWalker.prototype = {
16360
16361
 
16361
16362
  var KEYWORDS = 'break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with';
16362
16363
  var KEYWORDS_ATOM = 'false null true';
16363
- var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile'
16364
+ var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield'
16364
16365
  + " " + KEYWORDS_ATOM + " " + KEYWORDS;
16365
16366
  var KEYWORDS_BEFORE_EXPRESSION = 'return new delete throw else case';
16366
16367
 
@@ -16995,7 +16996,7 @@ function parse($TEXT, options) {
16995
16996
  if (is(type, val)) {
16996
16997
  return next();
16997
16998
  }
16998
- token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
16999
+ token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
16999
17000
  };
17000
17001
 
17001
17002
  function expect(punc) { return expect_token("punc", punc); };
@@ -17695,7 +17696,7 @@ function parse($TEXT, options) {
17695
17696
  condition : expr,
17696
17697
  consequent : yes,
17697
17698
  alternative : expression(false, no_in),
17698
- end : peek()
17699
+ end : prev()
17699
17700
  });
17700
17701
  }
17701
17702
  return expr;
@@ -17798,7 +17799,7 @@ function parse($TEXT, options) {
17798
17799
  disclaimer in the documentation and/or other materials
17799
17800
  provided with the distribution.
17800
17801
 
17801
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
17802
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
17802
17803
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17803
17804
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17804
17805
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -18017,7 +18018,7 @@ TreeTransformer.prototype = new TreeWalker;
18017
18018
  disclaimer in the documentation and/or other materials
18018
18019
  provided with the distribution.
18019
18020
 
18020
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
18021
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
18021
18022
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18022
18023
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18023
18024
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -18581,7 +18582,7 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
18581
18582
  disclaimer in the documentation and/or other materials
18582
18583
  provided with the distribution.
18583
18584
 
18584
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
18585
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
18585
18586
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18586
18587
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18587
18588
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -18601,22 +18602,23 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
18601
18602
  function OutputStream(options) {
18602
18603
 
18603
18604
  options = defaults(options, {
18604
- indent_start : 0,
18605
- indent_level : 4,
18606
- quote_keys : false,
18607
- space_colon : true,
18608
- ascii_only : false,
18609
- inline_script : false,
18610
- width : 80,
18611
- max_line_len : 32000,
18612
- beautify : false,
18613
- source_map : null,
18614
- bracketize : false,
18615
- semicolons : true,
18616
- comments : false,
18617
- preserve_line : false,
18618
- screw_ie8 : false,
18619
- preamble : null,
18605
+ indent_start : 0,
18606
+ indent_level : 4,
18607
+ quote_keys : false,
18608
+ space_colon : true,
18609
+ ascii_only : false,
18610
+ unescape_regexps : false,
18611
+ inline_script : false,
18612
+ width : 80,
18613
+ max_line_len : 32000,
18614
+ beautify : false,
18615
+ source_map : null,
18616
+ bracketize : false,
18617
+ semicolons : true,
18618
+ comments : false,
18619
+ preserve_line : false,
18620
+ screw_ie8 : false,
18621
+ preamble : null,
18620
18622
  }, true);
18621
18623
 
18622
18624
  var indentation = 0;
@@ -18840,7 +18842,7 @@ function OutputStream(options) {
18840
18842
  (!name && token.type == "name") ? token.value : name
18841
18843
  );
18842
18844
  } catch(ex) {
18843
- AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", {
18845
+ AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} {cline},{ccol} [{name}]", {
18844
18846
  file: token.file,
18845
18847
  line: token.line,
18846
18848
  col: token.col,
@@ -18941,13 +18943,20 @@ function OutputStream(options) {
18941
18943
  var comments = start.comments_before || [];
18942
18944
 
18943
18945
  // XXX: ugly fix for https://github.com/mishoo/UglifyJS2/issues/112
18944
- // if this node is `return` or `throw`, we cannot allow comments before
18945
- // the returned or thrown value.
18946
- if (self instanceof AST_Exit && self.value
18947
- && self.value.start.comments_before
18948
- && self.value.start.comments_before.length > 0) {
18949
- comments = comments.concat(self.value.start.comments_before);
18950
- self.value.start.comments_before = [];
18946
+ // and https://github.com/mishoo/UglifyJS2/issues/372
18947
+ if (self instanceof AST_Exit && self.value) {
18948
+ self.value.walk(new TreeWalker(function(node){
18949
+ if (node.start && node.start.comments_before) {
18950
+ comments = comments.concat(node.start.comments_before);
18951
+ node.start.comments_before = [];
18952
+ }
18953
+ if (node instanceof AST_Function ||
18954
+ node instanceof AST_Array ||
18955
+ node instanceof AST_Object)
18956
+ {
18957
+ return true; // don't go inside.
18958
+ }
18959
+ }));
18951
18960
  }
18952
18961
 
18953
18962
  if (c.test) {
@@ -19011,7 +19020,7 @@ function OutputStream(options) {
19011
19020
  || p instanceof AST_Unary // !(foo, bar, baz)
19012
19021
  || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
19013
19022
  || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
19014
- || p instanceof AST_Dot // (1, {foo:2}).foo ==> 2
19023
+ || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
19015
19024
  || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
19016
19025
  || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
19017
19026
  || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
@@ -19098,19 +19107,19 @@ function OutputStream(options) {
19098
19107
 
19099
19108
  function assign_and_conditional_paren_rules(output) {
19100
19109
  var p = output.parent();
19101
- // !(a = false) → true
19110
+ // !(a = false) true
19102
19111
  if (p instanceof AST_Unary)
19103
19112
  return true;
19104
- // 1 + (a = 2) + 3 → 6, side effect setting a = 2
19113
+ // 1 + (a = 2) + 3 6, side effect setting a = 2
19105
19114
  if (p instanceof AST_Binary && !(p instanceof AST_Assign))
19106
19115
  return true;
19107
- // (a = func)() —or— new (a = Object)()
19116
+ // (a = func)() or new (a = Object)()
19108
19117
  if (p instanceof AST_Call && p.expression === this)
19109
19118
  return true;
19110
19119
  // (a = foo) ? bar : baz
19111
19120
  if (p instanceof AST_Conditional && p.condition === this)
19112
19121
  return true;
19113
- // (a = foo)["prop"] —or— (a = foo).prop
19122
+ // (a = foo)["prop"] or (a = foo).prop
19114
19123
  if (p instanceof AST_PropAccess && p.expression === this)
19115
19124
  return true;
19116
19125
  };
@@ -19666,10 +19675,47 @@ function OutputStream(options) {
19666
19675
  DEFPRINT(AST_Number, function(self, output){
19667
19676
  output.print(make_num(self.getValue()));
19668
19677
  });
19678
+
19679
+ function regexp_safe_literal(code) {
19680
+ return [
19681
+ 0x5c , // \
19682
+ 0x2f , // /
19683
+ 0x2e , // .
19684
+ 0x2b , // +
19685
+ 0x2a , // *
19686
+ 0x3f , // ?
19687
+ 0x28 , // (
19688
+ 0x29 , // )
19689
+ 0x5b , // [
19690
+ 0x5d , // ]
19691
+ 0x7b , // {
19692
+ 0x7d , // }
19693
+ 0x24 , // $
19694
+ 0x5e , // ^
19695
+ 0x3a , // :
19696
+ 0x7c , // |
19697
+ 0x21 , // !
19698
+ 0x0a , // \n
19699
+ 0x0d , // \r
19700
+ 0x00 , // \0
19701
+ 0xfeff , // Unicode BOM
19702
+ 0x2028 , // unicode "line separator"
19703
+ 0x2029 , // unicode "paragraph separator"
19704
+ ].indexOf(code) < 0;
19705
+ };
19706
+
19669
19707
  DEFPRINT(AST_RegExp, function(self, output){
19670
19708
  var str = self.getValue().toString();
19671
- if (output.option("ascii_only"))
19709
+ if (output.option("ascii_only")) {
19672
19710
  str = output.to_ascii(str);
19711
+ } else if (output.option("unescape_regexps")) {
19712
+ str = str.split("\\\\").map(function(str){
19713
+ return str.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g, function(s){
19714
+ var code = parseInt(s.substr(2), 16);
19715
+ return regexp_safe_literal(code) ? String.fromCharCode(code) : s;
19716
+ });
19717
+ }).join("\\\\");
19718
+ }
19673
19719
  output.print(str);
19674
19720
  var p = output.parent();
19675
19721
  if (p instanceof AST_Binary && /^in/.test(p.operator) && p.left === self)
@@ -19837,7 +19883,7 @@ function OutputStream(options) {
19837
19883
  disclaimer in the documentation and/or other materials
19838
19884
  provided with the distribution.
19839
19885
 
19840
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
19886
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
19841
19887
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19842
19888
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19843
19889
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -19882,6 +19928,7 @@ function Compressor(options, false_by_default) {
19882
19928
  negate_iife : !false_by_default,
19883
19929
  screw_ie8 : false,
19884
19930
  drop_console : false,
19931
+ angular : false,
19885
19932
 
19886
19933
  warnings : true,
19887
19934
  global_defs : {}
@@ -20009,6 +20056,9 @@ merge(Compressor.prototype, {
20009
20056
  var CHANGED;
20010
20057
  do {
20011
20058
  CHANGED = false;
20059
+ if (compressor.option("angular")) {
20060
+ statements = process_for_angular(statements);
20061
+ }
20012
20062
  statements = eliminate_spurious_blocks(statements);
20013
20063
  if (compressor.option("dead_code")) {
20014
20064
  statements = eliminate_dead_code(statements, compressor);
@@ -20030,6 +20080,50 @@ merge(Compressor.prototype, {
20030
20080
 
20031
20081
  return statements;
20032
20082
 
20083
+ function process_for_angular(statements) {
20084
+ function make_injector(func, name) {
20085
+ return make_node(AST_SimpleStatement, func, {
20086
+ body: make_node(AST_Assign, func, {
20087
+ operator: "=",
20088
+ left: make_node(AST_Dot, name, {
20089
+ expression: make_node(AST_SymbolRef, name, name),
20090
+ property: "$inject"
20091
+ }),
20092
+ right: make_node(AST_Array, func, {
20093
+ elements: func.argnames.map(function(sym){
20094
+ return make_node(AST_String, sym, { value: sym.name });
20095
+ })
20096
+ })
20097
+ })
20098
+ });
20099
+ }
20100
+ return statements.reduce(function(a, stat){
20101
+ a.push(stat);
20102
+ var token = stat.start;
20103
+ var comments = token.comments_before;
20104
+ if (comments && comments.length > 0) {
20105
+ var last = comments.pop();
20106
+ if (/@ngInject/.test(last.value)) {
20107
+ // case 1: defun
20108
+ if (stat instanceof AST_Defun) {
20109
+ a.push(make_injector(stat, stat.name));
20110
+ }
20111
+ else if (stat instanceof AST_Definitions) {
20112
+ stat.definitions.forEach(function(def){
20113
+ if (def.value && def.value instanceof AST_Lambda) {
20114
+ a.push(make_injector(def.value, def.name));
20115
+ }
20116
+ });
20117
+ }
20118
+ else {
20119
+ compressor.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]", token);
20120
+ }
20121
+ }
20122
+ }
20123
+ return a;
20124
+ }, []);
20125
+ }
20126
+
20033
20127
  function eliminate_spurious_blocks(statements) {
20034
20128
  var seen_dirs = [];
20035
20129
  return statements.reduce(function(a, stat){
@@ -21164,7 +21258,7 @@ merge(Compressor.prototype, {
21164
21258
  if (!compressor.option("conditionals")) return self;
21165
21259
  // if condition can be statically determined, warn and drop
21166
21260
  // one of the blocks. note, statically determined implies
21167
- // “has no side effects”; also it doesn't work for cases like
21261
+ // has no side effects”; also it doesn't work for cases like
21168
21262
  // `x && true`, though it probably should.
21169
21263
  var cond = self.condition.evaluate(compressor);
21170
21264
  self.condition = cond[0];
@@ -21647,6 +21741,18 @@ merge(Compressor.prototype, {
21647
21741
  return self.car;
21648
21742
  }
21649
21743
  }
21744
+ if (self.cdr instanceof AST_UnaryPrefix
21745
+ && self.cdr.operator == "void"
21746
+ && !self.cdr.expression.has_side_effects(compressor)) {
21747
+ self.cdr.operator = self.car;
21748
+ return self.cdr;
21749
+ }
21750
+ if (self.cdr instanceof AST_Undefined) {
21751
+ return make_node(AST_UnaryPrefix, self, {
21752
+ operator : "void",
21753
+ expression : self.car
21754
+ });
21755
+ }
21650
21756
  return self;
21651
21757
  });
21652
21758
 
@@ -22018,7 +22124,7 @@ merge(Compressor.prototype, {
22018
22124
  * ==>
22019
22125
  * exp = foo ? something : something_else;
22020
22126
  */
22021
- self = make_node(AST_Assign, self, {
22127
+ return make_node(AST_Assign, self, {
22022
22128
  operator: consequent.operator,
22023
22129
  left: consequent.left,
22024
22130
  right: make_node(AST_Conditional, self, {
@@ -22028,6 +22134,25 @@ merge(Compressor.prototype, {
22028
22134
  })
22029
22135
  });
22030
22136
  }
22137
+ if (consequent instanceof AST_Call
22138
+ && alternative.TYPE === consequent.TYPE
22139
+ && consequent.args.length == alternative.args.length
22140
+ && consequent.expression.equivalent_to(alternative.expression)) {
22141
+ if (consequent.args.length == 0) {
22142
+ return make_node(AST_Seq, self, {
22143
+ car: self.condition,
22144
+ cdr: consequent
22145
+ });
22146
+ }
22147
+ if (consequent.args.length == 1) {
22148
+ consequent.args[0] = make_node(AST_Conditional, self, {
22149
+ condition: self.condition,
22150
+ consequent: consequent.args[0],
22151
+ alternative: alternative.args[0]
22152
+ });
22153
+ return consequent;
22154
+ }
22155
+ }
22031
22156
  return self;
22032
22157
  });
22033
22158
 
@@ -22067,6 +22192,12 @@ merge(Compressor.prototype, {
22067
22192
  property : prop
22068
22193
  });
22069
22194
  }
22195
+ var v = parseFloat(prop);
22196
+ if (!isNaN(v) && v.toString() == prop) {
22197
+ self.property = make_node(AST_Number, self.property, {
22198
+ value: v
22199
+ });
22200
+ }
22070
22201
  }
22071
22202
  return self;
22072
22203
  });
@@ -22111,7 +22242,7 @@ merge(Compressor.prototype, {
22111
22242
  disclaimer in the documentation and/or other materials
22112
22243
  provided with the distribution.
22113
22244
 
22114
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
22245
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
22115
22246
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22116
22247
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22117
22248
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -22196,7 +22327,7 @@ function SourceMap(options) {
22196
22327
  disclaimer in the documentation and/or other materials
22197
22328
  provided with the distribution.
22198
22329
 
22199
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
22330
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AS IS AND ANY
22200
22331
  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22201
22332
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22202
22333
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -22439,6 +22570,7 @@ function SourceMap(options) {
22439
22570
  AST_Node.warn_function = function(txt) { logger.error("uglifyjs2 WARN: " + txt); };
22440
22571
  exports.minify = function(files, options, name) {
22441
22572
  options = defaults(options, {
22573
+ spidermonkey : false,
22442
22574
  outSourceMap : null,
22443
22575
  sourceRoot : null,
22444
22576
  inSourceMap : null,
@@ -22448,22 +22580,26 @@ exports.minify = function(files, options, name) {
22448
22580
  output : null,
22449
22581
  compress : {}
22450
22582
  });
22451
- if (typeof files == "string")
22452
- files = [ files ];
22453
-
22454
22583
  base54.reset();
22455
22584
 
22456
22585
  // 1. parse
22457
22586
  var toplevel = null;
22458
- files.forEach(function(file){
22459
- var code = options.fromString
22460
- ? file
22461
- : rjsFile.readFile(file, "utf8");
22462
- toplevel = parse(code, {
22463
- filename: options.fromString ? name : file,
22464
- toplevel: toplevel
22587
+
22588
+ if (options.spidermonkey) {
22589
+ toplevel = AST_Node.from_mozilla_ast(files);
22590
+ } else {
22591
+ if (typeof files == "string")
22592
+ files = [ files ];
22593
+ files.forEach(function(file){
22594
+ var code = options.fromString
22595
+ ? file
22596
+ : rjsFile.readFile(file, "utf8");
22597
+ toplevel = parse(code, {
22598
+ filename: options.fromString ? name : file,
22599
+ toplevel: toplevel
22600
+ });
22465
22601
  });
22466
- });
22602
+ }
22467
22603
 
22468
22604
  // 2. compress
22469
22605
  if (options.compress) {
@@ -22624,7 +22760,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22624
22760
  if (object.hasOwnProperty(key)) {
22625
22761
  child = object[key];
22626
22762
  if (typeof child === 'object' && child !== null) {
22627
- traverse(child, visitor);
22763
+ traverseBroad(child, visitor);
22628
22764
  }
22629
22765
  }
22630
22766
  }
@@ -23515,7 +23651,16 @@ function (esprima, parse, logger, lang) {
23515
23651
  foundAnon,
23516
23652
  scanCount = 0,
23517
23653
  scanReset = false,
23518
- defineInfos = [];
23654
+ defineInfos = [],
23655
+ applySourceUrl = function (contents) {
23656
+ if (options.useSourceUrl) {
23657
+ contents = 'eval("' + lang.jsEscape(contents) +
23658
+ '\\n//# sourceURL=' + (path.indexOf('/') === 0 ? '' : '/') +
23659
+ path +
23660
+ '");\n';
23661
+ }
23662
+ return contents;
23663
+ };
23519
23664
 
23520
23665
  try {
23521
23666
  astRoot = esprima.parse(contents, {
@@ -23528,7 +23673,7 @@ function (esprima, parse, logger, lang) {
23528
23673
  }
23529
23674
 
23530
23675
  //Find the define calls and their position in the files.
23531
- parse.traverseBroad(astRoot, function (node) {
23676
+ parse.traverse(astRoot, function (node) {
23532
23677
  var args, firstArg, firstArgLoc, factoryNode,
23533
23678
  needsId, depAction, foundId, init,
23534
23679
  sourceUrlData, range,
@@ -23681,8 +23826,9 @@ function (esprima, parse, logger, lang) {
23681
23826
  }
23682
23827
  });
23683
23828
 
23829
+
23684
23830
  if (!defineInfos.length) {
23685
- return contents;
23831
+ return applySourceUrl(contents);
23686
23832
  }
23687
23833
 
23688
23834
  //Reverse the matches, need to start from the bottom of
@@ -23754,14 +23900,7 @@ function (esprima, parse, logger, lang) {
23754
23900
 
23755
23901
  contents = contentLines.join('\n');
23756
23902
 
23757
- if (options.useSourceUrl) {
23758
- contents = 'eval("' + lang.jsEscape(contents) +
23759
- '\\n//# sourceURL=' + (path.indexOf('/') === 0 ? '' : '/') +
23760
- path +
23761
- '");\n';
23762
- }
23763
-
23764
- return contents;
23903
+ return applySourceUrl(contents);
23765
23904
  },
23766
23905
 
23767
23906
  /**
@@ -25022,18 +25161,45 @@ define('requirePatch', [ 'env!env/file', 'pragma', 'parse', 'lang', 'logger', 'c
25022
25161
  //spit out strings that can be used in the stringified
25023
25162
  //build output.
25024
25163
  context.makeShimExports = function (value) {
25025
- function fn() {
25026
- return '(function (global) {\n' +
25027
- ' return function () {\n' +
25028
- ' var ret, fn;\n' +
25029
- (value.init ?
25030
- (' fn = ' + value.init.toString() + ';\n' +
25031
- ' ret = fn.apply(global, arguments);\n') : '') +
25032
- (value.exports ?
25033
- ' return ret || global.' + value.exports + ';\n' :
25034
- ' return ret;\n') +
25035
- ' };\n' +
25036
- '}(this))';
25164
+ var fn;
25165
+ if (context.config.wrapShim) {
25166
+ fn = function () {
25167
+ var str = 'return ';
25168
+ // If specifies an export that is just a global
25169
+ // name, no dot for a `this.` and such, then also
25170
+ // attach to the global, for `var a = {}` files
25171
+ // where the function closure would hide that from
25172
+ // the global object.
25173
+ if (value.exports && value.exports.indexOf('.') === -1) {
25174
+ str += 'root.' + value.exports + ' = ';
25175
+ }
25176
+
25177
+ if (value.init) {
25178
+ str += '(' + value.init.toString() + '.apply(this, arguments))';
25179
+ }
25180
+ if (value.init && value.exports) {
25181
+ str += ' || ';
25182
+ }
25183
+ if (value.exports) {
25184
+ str += value.exports;
25185
+ }
25186
+ str += ';';
25187
+ return str;
25188
+ };
25189
+ } else {
25190
+ fn = function () {
25191
+ return '(function (global) {\n' +
25192
+ ' return function () {\n' +
25193
+ ' var ret, fn;\n' +
25194
+ (value.init ?
25195
+ (' fn = ' + value.init.toString() + ';\n' +
25196
+ ' ret = fn.apply(global, arguments);\n') : '') +
25197
+ (value.exports ?
25198
+ ' return ret || global.' + value.exports + ';\n' :
25199
+ ' return ret;\n') +
25200
+ ' };\n' +
25201
+ '}(this))';
25202
+ };
25037
25203
  }
25038
25204
 
25039
25205
  return fn;
@@ -26611,6 +26777,9 @@ define('build', function (require) {
26611
26777
  //Set final output dir
26612
26778
  if (hasProp(config, "baseUrl")) {
26613
26779
  if (config.appDir) {
26780
+ if (!config.originalBaseUrl) {
26781
+ throw new Error('Please set a baseUrl in the build config');
26782
+ }
26614
26783
  config.dirBaseUrl = build.makeAbsPath(config.originalBaseUrl, config.dir);
26615
26784
  } else {
26616
26785
  config.dirBaseUrl = config.dir || config.baseUrl;
@@ -26666,15 +26835,20 @@ define('build', function (require) {
26666
26835
  // Make sure the output dir is not set to a parent of the
26667
26836
  // source dir or the same dir, as it will result in source
26668
26837
  // code deletion.
26669
- if (config.dir === config.baseUrl ||
26838
+ if (!config.allowSourceOverwrites && (config.dir === config.baseUrl ||
26670
26839
  config.dir === config.appDir ||
26671
26840
  (config.baseUrl && build.makeRelativeFilePath(config.dir,
26672
26841
  config.baseUrl).indexOf('..') !== 0) ||
26673
26842
  (config.appDir &&
26674
- build.makeRelativeFilePath(config.dir, config.appDir).indexOf('..') !== 0)) {
26843
+ build.makeRelativeFilePath(config.dir, config.appDir).indexOf('..') !== 0))) {
26675
26844
  throw new Error('"dir" is set to a parent or same directory as' +
26676
26845
  ' "appDir" or "baseUrl". This can result in' +
26677
- ' the deletion of source code. Stopping.');
26846
+ ' the deletion of source code. Stopping. If' +
26847
+ ' you want to allow possible overwriting of' +
26848
+ ' source code, set "allowSourceOverwrites"' +
26849
+ ' to true in the build config, but do so at' +
26850
+ ' your own risk. In that case, you may want' +
26851
+ ' to also set "keepBuildDir" to true.');
26678
26852
  }
26679
26853
  }
26680
26854
 
@@ -27255,7 +27429,7 @@ define('build', function (require) {
27255
27429
 
27256
27430
  //Semicolon is for files that are not well formed when
27257
27431
  //concatenated with other content.
27258
- singleContents += "\n" + addSemiColon(currContents, config);
27432
+ singleContents += addSemiColon(currContents, config);
27259
27433
  });
27260
27434
  }
27261
27435
  }).then(function () {
@@ -27273,16 +27447,36 @@ define('build', function (require) {
27273
27447
  if (moduleName && falseProp(layer.modulesWithNames, moduleName) && !config.skipModuleInsertion) {
27274
27448
  shim = config.shim && (getOwn(config.shim, moduleName) || (packageMain && getOwn(config.shim, moduleName) || getOwn(config.shim, packageName)));
27275
27449
  if (shim) {
27276
- singleContents += '\n' + namespaceWithDot + 'define("' + moduleName + '", ' +
27277
- (shim.deps && shim.deps.length ?
27278
- build.makeJsArrayString(shim.deps) + ', ' : '') +
27279
- (shim.exportsFn ? shim.exportsFn() : 'function(){}') +
27280
- ');\n';
27450
+ if (config.wrapShim) {
27451
+ singleContents = '(function(root) {' +
27452
+ '\n' + namespaceWithDot + 'define("' + moduleName + '", ' +
27453
+ (shim.deps && shim.deps.length ?
27454
+ build.makeJsArrayString(shim.deps) + ', ' : '[], ') +
27455
+ 'function() {\n' +
27456
+ ' return (function() {\n' +
27457
+ singleContents +
27458
+ (shim.exportsFn ? shim.exportsFn() : '') +
27459
+ ' }).apply(root, arguments);\n' +
27460
+ ' });\n' +
27461
+ '}(this));\n';
27462
+ } else {
27463
+ singleContents += '\n' + namespaceWithDot + 'define("' + moduleName + '", ' +
27464
+ (shim.deps && shim.deps.length ?
27465
+ build.makeJsArrayString(shim.deps) + ', ' : '') +
27466
+ (shim.exportsFn ? shim.exportsFn() : 'function(){}') +
27467
+ ');\n';
27468
+ }
27281
27469
  } else {
27282
27470
  singleContents += '\n' + namespaceWithDot + 'define("' + moduleName + '", function(){});\n';
27283
27471
  }
27284
27472
  }
27285
27473
 
27474
+ //Add line break at end of file, instead of at beginning,
27475
+ //so source map line numbers stay correct, but still allow
27476
+ //for some space separation between files in case ASI issues
27477
+ //for concatenation would cause an error otherwise.
27478
+ singleContents += '\n';
27479
+
27286
27480
  //Add to the source map
27287
27481
  if (sourceMapGenerator) {
27288
27482
  refPath = config.out ? config.baseUrl : module._buildPath;
@@ -27575,7 +27769,7 @@ function (args, quit, logger, build) {
27575
27769
  } else if (commandOption === 'v') {
27576
27770
  console.log('r.js: ' + version +
27577
27771
  ', RequireJS: ' + this.requirejsVars.require.version +
27578
- ', UglifyJS2: 2.4.8, UglifyJS: 1.3.4');
27772
+ ', UglifyJS2: 2.4.12, UglifyJS: 1.3.4');
27579
27773
  } else if (commandOption === 'convert') {
27580
27774
  loadLib();
27581
27775
 
@@ -27614,4 +27808,4 @@ function (args, quit, logger, build) {
27614
27808
  (typeof Packages !== 'undefined' || (typeof window === 'undefined' &&
27615
27809
  typeof Components !== 'undefined' && Components.interfaces) ?
27616
27810
  Array.prototype.slice.call(arguments, 0) : []),
27617
- (typeof readFile !== 'undefined' ? readFile : undefined)));
27811
+ (typeof readFile !== 'undefined' ? readFile : undefined)));