terser 1.2.5 → 1.2.6
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/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/terser/version.rb +1 -1
- data/lib/terser.js +33369 -32962
- data/lib/terser.rb +12 -3
- metadata +2 -2
data/lib/terser.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "json"
|
5
|
-
require "base64"
|
6
5
|
require "execjs"
|
7
6
|
require "terser/railtie" if defined?(Rails::Railtie)
|
8
7
|
require "terser/version"
|
@@ -163,7 +162,7 @@ class Terser
|
|
163
162
|
def compile(source, source_map_options = @options)
|
164
163
|
if source_map_options[:source_map]
|
165
164
|
compiled, source_map = run_terserjs(source, true, source_map_options)
|
166
|
-
source_map_uri =
|
165
|
+
source_map_uri = [source_map].pack("m0")
|
167
166
|
source_map_mime = "application/json;charset=utf-8;base64"
|
168
167
|
compiled + "\n//# sourceMappingURL=data:#{source_map_mime},#{source_map_uri}"
|
169
168
|
else
|
@@ -506,9 +505,19 @@ class Terser
|
|
506
505
|
source_map_options = options[:source_map].is_a?(Hash) ? options[:source_map] : {}
|
507
506
|
sanitize_map_root(source_map_options.fetch(:input_source_map) do
|
508
507
|
url = extract_source_mapping_url(source)
|
509
|
-
|
508
|
+
base64_strict_decode64(url.split(",", 2)[-1]) if url && url.start_with?("data:")
|
510
509
|
end)
|
511
510
|
rescue ArgumentError, JSON::ParserError
|
512
511
|
nil
|
513
512
|
end
|
513
|
+
|
514
|
+
if "".respond_to?(:unpack1)
|
515
|
+
def base64_strict_decode64(str)
|
516
|
+
str.unpack1("m0")
|
517
|
+
end
|
518
|
+
else
|
519
|
+
def base64_strict_decode64(str)
|
520
|
+
str.unpack("m0")[0]
|
521
|
+
end
|
522
|
+
end
|
514
523
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Rosicky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|