esperanto-source 0.6.33 → 0.6.34

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65022f6e363f203e2251de1f51409bd63dfc4fb3
4
- data.tar.gz: ffd82a36c819f34d84bf4095eaf7201dceabaf45
3
+ metadata.gz: e0bd2e0fafcd3cd4249ae16bc134725936890f37
4
+ data.tar.gz: d9b4db58f14d64c6b06603592c905afc751cbdc2
5
5
  SHA512:
6
- metadata.gz: a0d92c351df440c0efe5ea6a3086927edddde74bcb2d9fdf044b53e2e5b8ad0879251351418ca11e14fa80bd83369171d88875f7040cf1109458fb1b7755af26
7
- data.tar.gz: 1bb2d6a9a92f30d4de761f8d7380f73794748f493bcbce11b895fdf8fde8b8a80d82d53ae08e83ab0ad02c05478a94b3d94c4494ae54bb778f5d4751443bde05
6
+ metadata.gz: 9aead4edb4ba8a2e3f16e72989328c88b1a4773085f56995a22da370602d6c31759f35c47446f1fdd99a2bcf5eb76ba8c64d3da6edb8f88e81d6c3eb4499bc81
7
+ data.tar.gz: fe1477afdfe8f6474739aeabec3d366f35d5844d774ada097c2b8af198d539979ab61c461090a8ffe7e27d888d58e3052e7502ab2a48901b7887ebf02eacf430
@@ -1,5 +1,5 @@
1
1
  module Esperanto
2
2
  module Source
3
- VERSION = '0.6.33'
3
+ VERSION = '0.6.34'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*
2
- esperanto.js v0.6.33 - 2015-05-07
2
+ esperanto.js v0.6.34 - 2015-05-12
3
3
  http://esperantojs.org
4
4
 
5
5
  Released under the MIT License.
@@ -930,12 +930,17 @@
930
930
 
931
931
  var magic_string = MagicString;
932
932
 
933
+ var ast_walk__shouldSkip;
934
+ var ast_walk__shouldAbort;
935
+
933
936
  function walk ( ast, leave) {var enter = leave.enter, leave = leave.leave;
937
+ ast_walk__shouldAbort = false;
934
938
  visit( ast, null, enter, leave );
935
939
  }
936
940
 
937
941
  var ast_walk__context = {
938
- skip: function() {return ast_walk__context.shouldSkip = true}
942
+ skip: function() {return ast_walk__shouldSkip = true},
943
+ abort: function() {return ast_walk__shouldAbort = true}
939
944
  };
940
945
 
941
946
  var ast_walk__childKeys = {};
@@ -947,12 +952,12 @@
947
952
  }
948
953
 
949
954
  function visit ( node, parent, enter, leave ) {
950
- if ( !node ) return;
955
+ if ( !node || ast_walk__shouldAbort ) return;
951
956
 
952
957
  if ( enter ) {
953
- ast_walk__context.shouldSkip = false;
958
+ ast_walk__shouldSkip = false;
954
959
  enter.call( ast_walk__context, node, parent );
955
- if ( ast_walk__context.shouldSkip ) return;
960
+ if ( ast_walk__shouldSkip || ast_walk__shouldAbort ) return;
956
961
  }
957
962
 
958
963
  var keys = ast_walk__childKeys[ node.type ] || (
@@ -978,7 +983,7 @@
978
983
  }
979
984
  }
980
985
 
981
- if ( leave ) {
986
+ if ( leave && !ast_walk__shouldAbort ) {
982
987
  leave( node, parent );
983
988
  }
984
989
  }
data/vendor/esperanto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- esperanto.js v0.6.33 - 2015-05-07
2
+ esperanto.js v0.6.34 - 2015-05-12
3
3
  http://esperantojs.org
4
4
 
5
5
  Released under the MIT License.
@@ -32,12 +32,17 @@ function hasNamedExports ( mod ) {
32
32
  }
33
33
  }
34
34
 
35
+ var ast_walk__shouldSkip = void 0;
36
+ var ast_walk__shouldAbort = void 0;
37
+
35
38
  function walk ( ast, leave) {var enter = leave.enter, leave = leave.leave;
39
+ ast_walk__shouldAbort = false;
36
40
  visit( ast, null, enter, leave );
37
41
  }
38
42
 
39
43
  var ast_walk__context = {
40
- skip: function() {return ast_walk__context.shouldSkip = true}
44
+ skip: function() {return ast_walk__shouldSkip = true},
45
+ abort: function() {return ast_walk__shouldAbort = true}
41
46
  };
42
47
 
43
48
  var ast_walk__childKeys = {};
@@ -49,12 +54,12 @@ function isArray ( thing ) {
49
54
  }
50
55
 
51
56
  function visit ( node, parent, enter, leave ) {
52
- if ( !node ) return;
57
+ if ( !node || ast_walk__shouldAbort ) return;
53
58
 
54
59
  if ( enter ) {
55
- ast_walk__context.shouldSkip = false;
60
+ ast_walk__shouldSkip = false;
56
61
  enter.call( ast_walk__context, node, parent );
57
- if ( ast_walk__context.shouldSkip ) return;
62
+ if ( ast_walk__shouldSkip || ast_walk__shouldAbort ) return;
58
63
  }
59
64
 
60
65
  var keys = ast_walk__childKeys[ node.type ] || (
@@ -80,7 +85,7 @@ function visit ( node, parent, enter, leave ) {
80
85
  }
81
86
  }
82
87
 
83
- if ( leave ) {
88
+ if ( leave && !ast_walk__shouldAbort ) {
84
89
  leave( node, parent );
85
90
  }
86
91
  }
@@ -755,61 +760,87 @@ function resolveAgainst ( importerPath ) {
755
760
  function sortModules ( entry ) {
756
761
  var seen = {};
757
762
  var ordered = [];
758
- var swapPairs = [];
763
+ var hasCycles;
764
+
765
+ var strongDeps = {};
766
+ var stronglyDependsOn = {};
759
767
 
760
768
  function visit ( mod ) {
761
- seen[ mod.id ] = true;
769
+ var id = mod.id;
770
+
771
+ seen[ id ] = true;
772
+
773
+ strongDeps[ id ] = [];
774
+ stronglyDependsOn[ id ] = {};
762
775
 
763
776
  mod.imports.forEach( function(x ) {
764
777
  var imported = x.module;
765
778
 
766
779
  if ( imported.isExternal || imported.isSkipped ) return;
767
780
 
768
- // ignore modules we've already included
769
- if ( utils_hasOwnProp.call( seen, imported.id ) ) {
770
- if ( shouldSwap( imported, mod ) ) {
771
- swapPairs.push([ imported, mod ]);
772
- }
781
+ // if `mod` references a binding from `imported` at the top
782
+ // level (i.e. outside function bodies), we say that `mod`
783
+ // strongly depends on `imported. If two modules depend on
784
+ // each other, this helps us order them such that if a
785
+ // strongly depends on b, and b weakly depends on a, b
786
+ // goes first
787
+ if ( referencesAtTopLevel( mod, imported ) ) {
788
+ strongDeps[ id ].push( imported );
789
+ }
773
790
 
791
+ if ( utils_hasOwnProp.call( seen, imported.id ) ) {
792
+ // we need to prevent an infinite loop, and note that
793
+ // we need to check for strong/weak dependency relationships
794
+ hasCycles = true;
774
795
  return;
775
796
  }
776
797
 
777
798
  visit( imported );
778
799
  });
779
800
 
801
+ // add second (and third...) order dependencies
802
+ function addStrongDependencies ( dependency ) {
803
+ if ( utils_hasOwnProp.call( stronglyDependsOn[ id ], dependency.id ) ) return;
804
+
805
+ stronglyDependsOn[ id ][ dependency.id ] = true;
806
+ strongDeps[ dependency.id ].forEach( addStrongDependencies );
807
+ }
808
+
809
+ strongDeps[ id ].forEach( addStrongDependencies );
810
+
780
811
  ordered.push( mod );
781
812
  }
782
813
 
783
814
  visit( entry );
784
815
 
785
- swapPairs.forEach( function(b) {var a = b[0], b = b[1];
786
- var aIndex = ordered.indexOf( a );
787
- var bIndex = ordered.indexOf( b );
816
+ var unordered;
788
817
 
789
- ordered[ aIndex ] = b;
790
- ordered[ bIndex ] = a;
791
- });
792
-
793
- return ordered;
794
- }
818
+ if ( hasCycles ) {
819
+ unordered = ordered;
820
+ ordered = [];
795
821
 
796
- function shouldSwap ( a, b ) {
797
- // if these modules don't import each other, abort
798
- if ( !( utils_sortModules__imports( a, b ) && utils_sortModules__imports( b, a ) ) ) return;
822
+ // unordered is actually semi-ordered, as [ fewer dependencies ... more dependencies ]
823
+ unordered.forEach( function(x ) {
824
+ // ensure strong dependencies of x that don't strongly depend on x go first
825
+ strongDeps[ x.id ].forEach( place );
799
826
 
800
- return usesAtTopLevel( b, a ) && !usesAtTopLevel( a, b );
801
- }
827
+ function place ( dep ) {
828
+ if ( !stronglyDependsOn[ dep.id ][ x.id ] && !~ordered.indexOf( dep ) ) {
829
+ strongDeps[ dep.id ].forEach( place );
830
+ ordered.push( dep );
831
+ }
832
+ }
802
833
 
803
- function utils_sortModules__imports ( a, b ) {
804
- var i = a.imports.length;
805
- while ( i-- ) {
806
- if ( a.imports[i].module === b ) {
807
- return true;
808
- }
834
+ if ( !~ordered.indexOf( x ) ) {
835
+ ordered.push( x );
836
+ }
837
+ });
809
838
  }
839
+
840
+ return ordered;
810
841
  }
811
842
 
812
- function usesAtTopLevel ( a, b ) {
843
+ function referencesAtTopLevel ( a, b ) {
813
844
  var bindings = [];
814
845
 
815
846
  // find out which bindings a imports from b
@@ -825,16 +856,13 @@ function usesAtTopLevel ( a, b ) {
825
856
 
826
857
  walk( a.ast, {
827
858
  enter: function ( node ) {
828
- if ( referencedAtTopLevel ) {
829
- return this.skip();
830
- }
831
-
832
859
  if ( /^Import/.test( node.type ) || ( node._scope && node._scope.parent ) ) {
833
860
  return this.skip();
834
861
  }
835
862
 
836
863
  if ( node.type === 'Identifier' && ~bindings.indexOf( node.name ) ) {
837
864
  referencedAtTopLevel = true;
865
+ this.abort();
838
866
  }
839
867
  }
840
868
  });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esperanto-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.33
4
+ version: 0.6.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryunosuke SATO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler