ruby2js 4.1.1 → 4.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 +4 -4
- data/lib/ruby2js/converter.rb +1 -0
- data/lib/ruby2js/converter/match.rb +7 -0
- data/lib/ruby2js/serializer.rb +41 -10
- data/lib/ruby2js/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696f01a3f2781f8821257f1d2d0ed832e45a9fbde25c2f6f9f200ced90b24dab
|
4
|
+
data.tar.gz: d4bc6d38fb7146b3615e621e7c86fc8e864895d377d10ecf69599fa60b7808d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82772a1dc3aefde7a5acb6b7ca3b05a083dbb3e4c9bbdcf585387ae950c6d410280dfe069d0be3d5fd5e28a5eb0524f2c35ccac83c3b9789109a45e2ceb29a9
|
7
|
+
data.tar.gz: dffb0cd058bc9cdf28b76e99d73cb4916792bd9160ff9516994b3de2bc1b46e22c5d5be9bb772ec0f62c5947f5d73218e9d5fbd69e5e8a28b450875b92940ed7
|
data/lib/ruby2js/converter.rb
CHANGED
@@ -359,6 +359,7 @@ require 'ruby2js/converter/kwbegin'
|
|
359
359
|
require 'ruby2js/converter/literal'
|
360
360
|
require 'ruby2js/converter/logical'
|
361
361
|
require 'ruby2js/converter/masgn'
|
362
|
+
require 'ruby2js/converter/match'
|
362
363
|
require 'ruby2js/converter/module'
|
363
364
|
require 'ruby2js/converter/next'
|
364
365
|
require 'ruby2js/converter/nil'
|
data/lib/ruby2js/serializer.rb
CHANGED
@@ -300,22 +300,29 @@ module Ruby2JS
|
|
300
300
|
BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
301
301
|
|
302
302
|
# https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
|
303
|
+
# http://sokra.github.io/source-map-visualization/
|
303
304
|
def vlq(*mark)
|
304
|
-
if
|
305
|
-
|
306
|
-
@
|
305
|
+
if !@mark
|
306
|
+
diffs = mark
|
307
|
+
@mark = [0, 0, 0, 0, 0, 0]
|
308
|
+
else
|
309
|
+
if @mark[0] == mark[0]
|
310
|
+
return if @mark[4] == mark[4] and @mark[3] == mark[3]
|
311
|
+
@mappings += ',' unless @mappings == ''
|
312
|
+
end
|
313
|
+
|
314
|
+
diffs = mark.zip(@mark).map {|a,b| a-b}
|
307
315
|
end
|
308
316
|
|
309
317
|
while @mark[0] < mark[0]
|
310
318
|
@mappings += ';'
|
311
319
|
@mark[0] += 1
|
312
|
-
|
320
|
+
diffs[1] = mark[1]
|
313
321
|
end
|
314
322
|
|
315
|
-
|
316
|
-
@mark = mark
|
323
|
+
@mark[0...mark.length] = mark
|
317
324
|
|
318
|
-
diffs[1
|
325
|
+
diffs[1..-1].each do |diff|
|
319
326
|
if diff < 0
|
320
327
|
data = (-diff << 1) + 1
|
321
328
|
else
|
@@ -345,7 +352,8 @@ module Ruby2JS
|
|
345
352
|
|
346
353
|
@mappings = ''
|
347
354
|
sources = []
|
348
|
-
|
355
|
+
names = []
|
356
|
+
@mark = nil
|
349
357
|
|
350
358
|
@lines.each_with_index do |line, row|
|
351
359
|
col = line.indent
|
@@ -361,8 +369,30 @@ module Ruby2JS
|
|
361
369
|
sources << buffer
|
362
370
|
end
|
363
371
|
|
364
|
-
|
365
|
-
|
372
|
+
line = buffer.line_for_position(pos) - 1
|
373
|
+
column = buffer.column_for_position(pos)
|
374
|
+
|
375
|
+
name = nil
|
376
|
+
if %i{lvasgn lvar}.include? token.ast.type
|
377
|
+
name = token.ast.children.first
|
378
|
+
elsif %i{casgn const}.include? token.ast.type
|
379
|
+
if token.ast.children.first == nil
|
380
|
+
name = token.ast.children[1]
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
if name
|
385
|
+
index = names.find_index(name)
|
386
|
+
|
387
|
+
unless index
|
388
|
+
index = names.length
|
389
|
+
names << name
|
390
|
+
end
|
391
|
+
|
392
|
+
vlq row, col, source_index, line, column, index
|
393
|
+
else
|
394
|
+
vlq row, col, source_index, line, column
|
395
|
+
end
|
366
396
|
end
|
367
397
|
col += token.length
|
368
398
|
end
|
@@ -372,6 +402,7 @@ module Ruby2JS
|
|
372
402
|
version: 3,
|
373
403
|
file: @file_name,
|
374
404
|
sources: sources.map(&:name),
|
405
|
+
names: names.map(&:to_s),
|
375
406
|
mappings: @mappings
|
376
407
|
}
|
377
408
|
end
|
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.2
|
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-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parser
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/ruby2js/converter/literal.rb
|
86
86
|
- lib/ruby2js/converter/logical.rb
|
87
87
|
- lib/ruby2js/converter/masgn.rb
|
88
|
+
- lib/ruby2js/converter/match.rb
|
88
89
|
- lib/ruby2js/converter/module.rb
|
89
90
|
- lib/ruby2js/converter/next.rb
|
90
91
|
- lib/ruby2js/converter/nil.rb
|