opal-optimizer 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: bac974d0150297fd084bdc1a40e9eb41d859f2231545d543294de2e3de0ac073
4
- data.tar.gz: 0cda5d5d3ac92adef47a98e7c82b9c1233e7ff18d218e23bd4838cc812b82ae6
3
+ metadata.gz: d76a6684777438ef696216358695d66b0e2ddd212f5b9d28d482843c912a2ac4
4
+ data.tar.gz: 536b978277f2af33f5ac47ad8661629e151d54adf11d88f8e0a63487327956d2
5
5
  SHA512:
6
- metadata.gz: cce52551506f12e9bdf5c0f05ee80df69b6c9c1d3887c57a316a019b108abe0441fb5b9f0a70bf02ef2fe2fe5fff637ec06563639b8e295ad4371b4567b8b2a1
7
- data.tar.gz: 11460f5faf89d08dc4965d5c788b216b0ef55c16125e0a1ea9a617ac7ce0111d3eb99f8b60334ff0cfc7cedd5f0883573d7583f408087b0f98b35a8e27973d86
6
+ metadata.gz: 3e87db8dbc1976b663dfc0fcbbc25b3317058e06c72f759b131e16caeaf589355f85e029e2307392ba386f8c7787128a70a39743570a2d854f327f8b054187fb
7
+ data.tar.gz: f29200eb79910e28c08acf486e3881468ec0b5cdc8718787a0e719193e6a2ac1b96c9b43acfc5fbcfe2158e710ce19371d67795521119fbd448db216f87512f4
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ gem "opal", path: "../opal"
10
10
  gem "opal-sprockets", path: "../opal-sprockets"
11
11
  gem "opal-browser", path: "../opal-browser"
12
12
 
13
- gem "rkelly-remix"
13
+ gem "rkelly-turbo", path: "../rkelly-turbo"
14
14
 
15
+ gem "ruby-prof"
15
16
  gem "pry"
data/Gemfile.lock CHANGED
@@ -8,42 +8,46 @@ PATH
8
8
  PATH
9
9
  remote: ../opal-sprockets
10
10
  specs:
11
- opal-sprockets (0.5.0.1.0.4.0)
12
- opal (~> 1.0.0)
11
+ opal-sprockets (1.0.0)
12
+ opal (>= 1.0, < 1.2)
13
13
  sprockets (~> 4.0)
14
14
  tilt (>= 1.4)
15
15
 
16
16
  PATH
17
17
  remote: ../opal
18
18
  specs:
19
- opal (1.0.0)
19
+ opal (1.1.1)
20
20
  ast (>= 2.3.0)
21
- parser (~> 2.6)
21
+ parser (~> 3.0)
22
+
23
+ PATH
24
+ remote: ../rkelly-turbo
25
+ specs:
26
+ rkelly-turbo (0.1.1.20210526224136)
22
27
 
23
28
  PATH
24
29
  remote: .
25
30
  specs:
26
- opal-optimizer (0.1.0)
31
+ opal-optimizer (0.1.2)
27
32
  opal (>= 1.0.0)
28
- rkelly-remix
33
+ rkelly-turbo
29
34
 
30
35
  GEM
31
36
  remote: https://rubygems.org/
32
37
  specs:
33
- ast (2.4.1)
38
+ ast (2.4.2)
34
39
  coderay (1.1.3)
35
- concurrent-ruby (1.1.7)
40
+ concurrent-ruby (1.1.8)
36
41
  diff-lcs (1.4.4)
37
42
  method_source (1.0.0)
38
43
  paggio (0.2.6)
39
- parser (2.7.1.4)
44
+ parser (3.0.1.1)
40
45
  ast (~> 2.4.1)
41
46
  pry (0.13.1)
42
47
  coderay (~> 1.1)
43
48
  method_source (~> 1.0)
44
49
  rack (2.2.3)
45
50
  rake (12.3.3)
46
- rkelly-remix (0.0.7)
47
51
  rspec (3.9.0)
48
52
  rspec-core (~> 3.9.0)
49
53
  rspec-expectations (~> 3.9.0)
@@ -57,6 +61,7 @@ GEM
57
61
  diff-lcs (>= 1.2.0, < 2.0)
58
62
  rspec-support (~> 3.9.0)
59
63
  rspec-support (3.9.3)
64
+ ruby-prof (1.4.3)
60
65
  sprockets (4.0.2)
61
66
  concurrent-ruby (~> 1.0)
62
67
  rack (> 1, < 3)
@@ -72,8 +77,9 @@ DEPENDENCIES
72
77
  opal-sprockets!
73
78
  pry
74
79
  rake (~> 12.0)
75
- rkelly-remix
80
+ rkelly-turbo!
76
81
  rspec (~> 3.0)
82
+ ruby-prof
77
83
 
78
84
  BUNDLED WITH
79
85
  2.1.4
@@ -14,22 +14,24 @@ module Opal
14
14
 
15
15
  attr_accessor :exports
16
16
 
17
- def initialize(code, exports: "")
17
+ def initialize(code, exports: "", force_corelib: true)
18
18
  @ast = parse_js(code)
19
19
 
20
20
  @corelib = @ast.value.find do |i|
21
- es = i.to_ecma
22
- if es.start_with?("(function(undefined) {\n var global_object") &&
23
- es.end_with?(").call(this);")
21
+ es = code[i.range.from.index..i.range.to.index]
22
+ if es.start_with?("(function(undefined) {\n // @note\n"\
23
+ " // A few conventions for the documentation of this file:") &&
24
+ es.end_with?("TypeError.$$super = Error;\n}).call(this);")
24
25
  @opal_version = 1.0
25
- elsif es.start_with?("(function(global_object) {\n \"use strict\";\n"+
26
- " var console;\n if(typeof (globalThis) !== "+
27
- "'undefined') {\n") &&
28
- es.end_with?(").call(this);")
26
+ elsif es.start_with?("(function(global_object) {\n \"use strict\";\n\n // @note\n "\
27
+ "// A few conventions for the documentation of this file:") &&
28
+ es.end_with?("TypeError.$$super = Error;\n}).call(this);")
29
29
  @opal_version = 1.1
30
30
  end
31
31
  end
32
32
 
33
+ raise ArgumentError, "Couldn't deduce Opal version based on this content" if force_corelib && !@corelib
34
+
33
35
  @corelib_source = @corelib.value.value.value.value.function_body.value if @corelib
34
36
 
35
37
  reload
@@ -38,7 +40,7 @@ module Opal
38
40
  unless [nil, ""].include?(exports) || exports.start_with?("(function(")
39
41
  exports = Opal::Compiler.new(exports).compile
40
42
  end
41
- @exports = Opal::Optimizer.new(exports, exports: nil) unless exports == nil
43
+ @exports = Opal::Optimizer.new(exports, exports: nil, force_corelib: false) unless exports == nil
42
44
  end
43
45
 
44
46
  def reload
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  class Optimizer
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_dependency "rkelly-remix"
28
+ spec.add_dependency "rkelly-turbo"
29
29
  spec.add_dependency "opal", ">= 1.0.0"
30
30
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hmdne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rkelly-remix
14
+ name: rkelly-turbo
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.0
41
- description:
41
+ description:
42
42
  email: []
43
43
  executables: []
44
44
  extensions: []
@@ -70,7 +70,7 @@ metadata:
70
70
  homepage_uri: https://github.com/hmdne/opal-optimizer
71
71
  source_code_uri: https://github.com/hmdne/opal-optimizer
72
72
  changelog_uri: https://github.com/hmdne/opal-optimizer/commits/master
73
- post_install_message:
73
+ post_install_message:
74
74
  rdoc_options: []
75
75
  require_paths:
76
76
  - lib
@@ -85,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubygems_version: 3.1.4
89
- signing_key:
88
+ rubygems_version: 3.2.15
89
+ signing_key:
90
90
  specification_version: 4
91
91
  summary: Optimize Opal's resulting javascript code
92
92
  test_files: []