ruby2js 4.1.4 → 4.1.5
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 +4 -4
- data/lib/ruby2js/converter/def.rb +3 -1
- data/lib/ruby2js/converter/logical.rb +1 -1
- data/lib/ruby2js/filter/active_functions.rb +9 -1
- data/lib/ruby2js/filter/camelCase.rb +2 -2
- data/lib/ruby2js/filter/functions.rb +11 -3
- data/lib/ruby2js/filter/lit-element.rb +1 -1
- data/lib/ruby2js/filter/react.rb +7 -1
- data/lib/ruby2js/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 412d541e9884847f722555edd11a71ead4c2358632976bf32f530ca270eb539b
|
4
|
+
data.tar.gz: f32b8d14177ee0f08466abfbb4a96017e6dc8a4e5a2226476c77f26affa7f81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4be8efc1eb9ec2f1de81f5c0236b6ea3c868522043e305cb0dfcac80e61b1e57e5639f77ad2a0a6aa44b7b5eb87842db5a7072f42ab25ad625474904d88e4b8
|
7
|
+
data.tar.gz: 6f8c9c91f1ca05f4363023ee588e356226dbafcf09235d5ab25c5ffaef564109a4c653673bbf8a6da1c0b3a231f84231f25089fdd0c0207e7ddd6c8d25dfd7d7
|
@@ -169,7 +169,9 @@ module Ruby2JS
|
|
169
169
|
put 'function'
|
170
170
|
end
|
171
171
|
|
172
|
-
put '('
|
172
|
+
put '('
|
173
|
+
parse s(:args, *args.children.select {|arg| arg.type != :shadowarg})
|
174
|
+
put ") {#{nl}"
|
173
175
|
|
174
176
|
next_token, @next_token = @next_token, :return
|
175
177
|
@block_depth += 1 if @block_depth
|
@@ -69,7 +69,7 @@ module Ruby2JS
|
|
69
69
|
left = rewrite(*left.children)
|
70
70
|
end
|
71
71
|
|
72
|
-
if right.type != :send
|
72
|
+
if right.type != :send or OPERATORS.flatten.include? right.children[1]
|
73
73
|
s(:and, left, right)
|
74
74
|
elsif conditionally_equals(left, right.children.first)
|
75
75
|
# a && a.b => a&.b
|
@@ -7,7 +7,6 @@ module Ruby2JS
|
|
7
7
|
|
8
8
|
def on_send(node)
|
9
9
|
target, method, *args = node.children
|
10
|
-
return super unless args.empty?
|
11
10
|
|
12
11
|
if es2015 and method == :blank?
|
13
12
|
create_or_update_import("blank$")
|
@@ -18,6 +17,15 @@ module Ruby2JS
|
|
18
17
|
elsif es2015 and method == :presence
|
19
18
|
create_or_update_import("presence$")
|
20
19
|
process node.updated :send, [nil, "presence$", target]
|
20
|
+
elsif es2015 and method == :chomp
|
21
|
+
create_or_update_import("chomp$")
|
22
|
+
process node.updated :send, [nil, "chomp$", target, *args]
|
23
|
+
elsif es2015 and method == :delete_prefix
|
24
|
+
create_or_update_import("deletePrefix$")
|
25
|
+
process node.updated :send, [nil, "deletePrefix$", target, *args]
|
26
|
+
elsif es2015 and method == :delete_suffix
|
27
|
+
create_or_update_import("deleteSuffix$")
|
28
|
+
process node.updated :send, [nil, "deleteSuffix$", target, *args]
|
21
29
|
else
|
22
30
|
super
|
23
31
|
end
|
@@ -69,7 +69,7 @@ module Ruby2JS
|
|
69
69
|
def handle_generic_node(node, node_type)
|
70
70
|
return node if node.type != node_type
|
71
71
|
|
72
|
-
if node.children[0] =~ /_
|
72
|
+
if node.children[0] =~ /_.*[?!\w]$/ and !ALLOWLIST.include?(node.children[0].to_s)
|
73
73
|
S(node_type , camelCase(node.children[0]), *node.children[1..-1])
|
74
74
|
else
|
75
75
|
node
|
@@ -136,7 +136,7 @@ module Ruby2JS
|
|
136
136
|
node = super
|
137
137
|
return node if node.type != :defs
|
138
138
|
|
139
|
-
if node.children[1] =~ /_
|
139
|
+
if node.children[1] =~ /_.*[?!\w]$/
|
140
140
|
S(:defs , node.children[0],
|
141
141
|
camelCase(node.children[1]), *node.children[2..-1])
|
142
142
|
else
|
@@ -341,7 +341,11 @@ module Ruby2JS
|
|
341
341
|
|
342
342
|
elsif method == :last
|
343
343
|
if node.children.length == 2
|
344
|
-
|
344
|
+
if es2022
|
345
|
+
process S(:send, target, :at, s(:int, -1))
|
346
|
+
else
|
347
|
+
process on_send S(:send, target, :[], s(:int, -1))
|
348
|
+
end
|
345
349
|
elsif node.children.length == 3
|
346
350
|
process S(:send, target, :slice,
|
347
351
|
s(:send, s(:attr, target, :length), :-, node.children[2]),
|
@@ -358,8 +362,12 @@ module Ruby2JS
|
|
358
362
|
# resolve negative literal indexes
|
359
363
|
i = proc do |index|
|
360
364
|
if index.type == :int and index.children.first < 0
|
361
|
-
|
362
|
-
|
365
|
+
if es2022
|
366
|
+
return process S(:send, target, :at, index)
|
367
|
+
else
|
368
|
+
process S(:send, S(:attr, target, :length), :-,
|
369
|
+
s(:int, -index.children.first))
|
370
|
+
end
|
363
371
|
else
|
364
372
|
index
|
365
373
|
end
|
data/lib/ruby2js/filter/react.rb
CHANGED
@@ -1492,7 +1492,13 @@ module Ruby2JS
|
|
1492
1492
|
source = Ruby2JS.jsx2_rb(source)
|
1493
1493
|
ast = Ruby2JS.parse(source).first
|
1494
1494
|
ast = s(:block, s(:send, nil, :_), s(:args), ast) if ast.type == :begin
|
1495
|
-
|
1495
|
+
|
1496
|
+
begin
|
1497
|
+
react, @react = @react, @react || :react
|
1498
|
+
process ast
|
1499
|
+
ensure
|
1500
|
+
@react = react
|
1501
|
+
end
|
1496
1502
|
end
|
1497
1503
|
end
|
1498
1504
|
|
data/lib/ruby2js/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby2js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parser
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: '0'
|
191
191
|
requirements: []
|
192
|
-
rubygems_version: 3.1.
|
192
|
+
rubygems_version: 3.1.2
|
193
193
|
signing_key:
|
194
194
|
specification_version: 4
|
195
195
|
summary: Minimal yet extensible Ruby to JavaScript conversion.
|