mini_racer 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4290b52d3d19c196567892c0d3eda0b47f07047afe059e63d4ac976258cb52a0
4
- data.tar.gz: 55e41b4e8ab93cdfe45446ff08a5b3c42323356e36b79d91f2e564c43a7715fe
3
+ metadata.gz: 597511b18a2cdc00c0eaa3bb048930449564099b24ef6513fc3f6f0b5e233a29
4
+ data.tar.gz: af21176c1943dcb664b2f3266e92b73de02ce8c572073fcd22e0d61a14e7293f
5
5
  SHA512:
6
- metadata.gz: c0e0cca11803ffa6ba38998810ccb82413257145947a637f3800252f4a0d47bd47fde425786c09f1eedf6c28b1bb584d34914b111effffef908ff182e79c5329
7
- data.tar.gz: 05dbfe34c140fedf6fbd33f5eee62f6cc6880579d238039f2e351a0279fa9267575b46ae7890f9c7d19ebd43bf1020e9bb57d445ad4e6ac8f89440ac3e2744d3
6
+ metadata.gz: 6622188fe90e54bdb4df479aec3a3c1b7d86b1c19cecc2c4bb877fce90c9529e28e4c73ac9c197a18db88d3c8efc56b6f9aa6e0438dfcaebf7a2d3b4bc7b9bf3
7
+ data.tar.gz: e1e4a96e70e0200e389567890fc6aedfb235ea65a104717fd1a2308ea4f20a37d844aa989b5f65bcdd35c26a8cdff24c455c83d917026f20184863087b7d2e0e
@@ -45,10 +45,9 @@ jobs:
45
45
  - "macos-11"
46
46
  - "macos-12"
47
47
  ruby:
48
- - "ruby-2.6"
49
- - "ruby-2.7"
50
48
  - "ruby-3.0"
51
49
  - "ruby-3.1"
50
+ - "ruby-3.2"
52
51
 
53
52
  name: ${{ matrix.os }} - ${{ matrix.ruby }}
54
53
  runs-on: ${{ matrix.os }}
@@ -69,20 +68,15 @@ jobs:
69
68
  fail-fast: false
70
69
  matrix:
71
70
  ruby:
72
- - "2.6"
73
- - "2.7"
74
71
  - "3.0"
75
72
  - "3.1"
73
+ - "3.2"
76
74
  platform:
77
75
  - "amd64"
78
76
  - "arm64"
79
77
  libc:
80
78
  - "gnu"
81
79
  - "musl"
82
- exclude:
83
- # there's no libv8-node (v16) for aarch64-linux-musl at the moment
84
- - platform: "arm64"
85
- libc: "musl"
86
80
 
87
81
  name: linux-${{ matrix.platform }} - ruby-${{ matrix.ruby }} - ${{ matrix.libc }}
88
82
  runs-on: ubuntu-20.04
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ - 25-05-2022
2
+
3
+ - 0.6.4
4
+
5
+ - Target Node 16.19.0.0
6
+
1
7
  - 16-08-2022
2
8
 
3
9
  - 0.6.3
@@ -17,7 +23,6 @@
17
23
  - Corrected re-raising of exceptions to support strings
18
24
  - During early termination of context under certain conditions MiniRacer could crash
19
25
 
20
-
21
26
  - 31-12-2021
22
27
 
23
28
  - 0.6.1
@@ -27,10 +32,10 @@
27
32
 
28
33
  - 0.6.0
29
34
 
30
- - Ruby 3.1 support
31
- - Fixes memory leak in heap snapshotting
32
- - Improved compilation ergonomics in clang
33
- - Migrated internal storage in c extension to TypedData
35
+ - Ruby 3.1 support
36
+ - Fixes memory leak in heap snapshotting
37
+ - Improved compilation ergonomics in clang
38
+ - Migrated internal storage in c extension to TypedData
34
39
 
35
40
  - 11-04-2021
36
41
 
@@ -81,7 +86,7 @@
81
86
 
82
87
  - 0.2.13
83
88
 
84
- - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
89
+ - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
85
90
 
86
91
  - 15-05-2020
87
92
 
@@ -131,7 +136,7 @@
131
136
 
132
137
  - 0.2.5
133
138
 
134
- - FIX: Compatiblity fixes for V8 7 and above @ignisf
139
+ - FIX: Compatibility fixes for V8 7 and above @ignisf
135
140
  - FIX: Memory leak in gc_callback @messense
136
141
  - IMPROVEMENT: Added example of sourcemap support @ianks
137
142
  - URGENT: you will need this release for latest version of libv8 to work
@@ -148,15 +153,15 @@
148
153
  - 0.2.3
149
154
 
150
155
  - Drop all conditional logic from Mini Racer compilation for clang, always
151
- rely on MacOS being High Sierra or up
156
+ rely on MacOS being High Sierra or up
152
157
 
153
158
  - 26-09-2018
154
159
 
155
160
  - 0.2.2
156
161
 
157
162
  - WORKAROUND: RUBY_PLATFORM is hardcoded on Ruby compile and can not be
158
- trusted for feature detection, use a different technique when checking for
159
- macOS Mojave
163
+ trusted for feature detection, use a different technique when checking for
164
+ macOS Mojave
160
165
 
161
166
  - 25-09-2018
162
167
 
@@ -184,7 +189,7 @@
184
189
 
185
190
  - 0.1.14
186
191
 
187
- - libv8 erronuously bumped to beta, reverted change
192
+ - libv8 erroneously bumped to beta, reverted change
188
193
 
189
194
  23-08-2017
190
195
 
@@ -197,7 +202,7 @@
197
202
  - 0.1.12
198
203
 
199
204
  - Feature: upgrade libv8 to 5.9
200
- - Fix: warning when runnin with ruby warnings enabled (missed @disposed initialize)
205
+ - Fix: warning when running with ruby warnings enabled (missed @disposed initialize)
201
206
 
202
207
  18-07-2017
203
208
 
@@ -209,16 +214,16 @@
209
214
 
210
215
  - 0.1.10
211
216
 
212
- - Fix leak: memory leak when disposing a context (20 bytes per context)
213
- - Feature: added #heap_stats so you can get visibility from context to actual memory usage of isolate
214
- - Feature: added #dispose so you reclaim all v8 memory right away as opposed to waiting for GC
215
- - Feature: you can now specify filename in an eval eg: eval('a = 1', filename: 'my_awesome.js')
217
+ - Fix leak: memory leak when disposing a context (20 bytes per context)
218
+ - Feature: added #heap_stats so you can get visibility from context to actual memory usage of isolate
219
+ - Feature: added #dispose so you reclaim all v8 memory right away as opposed to waiting for GC
220
+ - Feature: you can now specify filename in an eval eg: eval('a = 1', filename: 'my_awesome.js')
216
221
 
217
222
  09-03-2017
218
223
 
219
224
  - 0.1.9
220
225
 
221
- - Perf: speed up ruby/node boundary performance when moving large objects
226
+ - Perf: speed up ruby/node boundary performance when moving large objects
222
227
 
223
228
  06-02-2017
224
229
 
@@ -258,7 +263,6 @@
258
263
  - Support more conversions from Ruby back to JS (Hash, Symbol, Array)
259
264
  - Support attaching nested objects
260
265
 
261
-
262
266
  17-05-2016
263
267
 
264
268
  - 0.1.2
@@ -276,4 +280,4 @@
276
280
 
277
281
  - 0.1.1.beta.1
278
282
 
279
- - First release
283
+ - First release
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- ARG RUBY_VERSION=2.7
1
+ ARG RUBY_VERSION=3.2
2
2
  FROM ruby:${RUBY_VERSION}
3
3
 
4
4
  RUN test ! -f /etc/alpine-release || apk add --no-cache build-base git
data/README.md CHANGED
@@ -1,20 +1,30 @@
1
1
  # MiniRacer
2
2
 
3
- [![Test](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml)
3
+ [![Test](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml) ![Gem](https://img.shields.io/gem/v/mini_racer)
4
4
 
5
5
  Minimal, modern embedded V8 for Ruby.
6
6
 
7
7
  MiniRacer provides a minimal two way bridge between the V8 JavaScript engine and Ruby.
8
8
 
9
- It was created as an alternative to the excellent [therubyracer](https://github.com/cowboyd/therubyracer). Unlike therubyracer, mini_racer only implements a minimal bridge. This reduces the surface area making upgrading v8 much simpler and exhaustive testing simpler.
9
+ It was created as an alternative to the excellent [therubyracer](https://github.com/cowboyd/therubyracer), which is [no longer maintained](https://github.com/rubyjs/therubyracer/issues/462). Unlike therubyracer, mini_racer only implements a minimal bridge. This reduces the surface area making upgrading v8 much simpler and exhaustive testing simpler.
10
10
 
11
11
  MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can be used directly with Rails projects to minify assets, run babel or compile CoffeeScript.
12
12
 
13
- ### A note about Ruby version Support
13
+ ## Supported Ruby Versions & Troubleshooting
14
14
 
15
- MiniRacer only supports non-EOL versions of Ruby. See [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) for the list of non-EOL Rubies.
15
+ MiniRacer only supports non-EOL versions of Ruby. See [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) for the list of non-EOL Rubies. If you require support for older versions of Ruby install an older version of the gem.
16
16
 
17
- If you require support for older versions of Ruby install an older version of the gem.
17
+ MiniRacer **does not support** [Ruby built on MinGW](https://github.com/rubyjs/mini_racer/issues/252#issuecomment-1201172236), "pure windows" no Cygwin, no WSL2 (see https://github.com/rubyjs/libv8-node/issues/9).
18
+
19
+ If you have a problem installing MiniRacer, please consider the following steps:
20
+
21
+ * make sure you try the latest released version of `mini_racer`
22
+ * make sure you have Rubygems >= 3.2.13 and bundler >= 2.2.13 installed: `gem update --system`
23
+ * if you are using bundler
24
+ * make sure it is actually using the latest bundler version: [`bundle update --bundler`](https://bundler.io/v2.4/man/bundle-update.1.html)
25
+ * make sure to have `PLATFORMS` set correctly in `Gemfile.lock` via [`bundle lock --add-platform`](https://bundler.io/v2.4/man/bundle-lock.1.html#SUPPORTING-OTHER-PLATFORMS)
26
+ * make sure to recompile/reinstall `mini_racer` and `libv8-node` after OS upgrades (for example via `gem uninstall --all mini_racer libv8-node`)
27
+ * make sure you are on the latest patch/teeny version of a supported Ruby branch
18
28
 
19
29
  ## Features
20
30
 
@@ -24,8 +34,8 @@ You can simply eval one or many JavaScript snippets in a shared context
24
34
 
25
35
  ```ruby
26
36
  context = MiniRacer::Context.new
27
- context.eval 'var adder = (a,b)=>a+b;'
28
- puts context.eval 'adder(20,22)'
37
+ context.eval("var adder = (a,b)=>a+b;")
38
+ puts context.eval("adder(20,22)")
29
39
  # => 42
30
40
  ```
31
41
 
@@ -36,20 +46,20 @@ You can attach one or many ruby proc that can be accessed via JavaScript
36
46
  ```ruby
37
47
  context = MiniRacer::Context.new
38
48
  context.attach("math.adder", proc{|a,b| a+b})
39
- puts context.eval 'math.adder(20,22)'
49
+ puts context.eval("math.adder(20,22)")
40
50
  # => 42
41
51
  ```
42
52
 
43
53
  ```ruby
44
54
  context = MiniRacer::Context.new
45
55
  context.attach("array_and_hash", proc{{a: 1, b: [1, {a: 1}]}})
46
- puts context.eval 'array_and_hash()'
56
+ puts context.eval("array_and_hash()")
47
57
  # => {"a" => 1, "b" => [1, {"a" => 1}]}
48
58
  ```
49
59
 
50
60
  ### GIL free JavaScript execution
51
61
 
52
- The Ruby Global interpreter lock is released when scripts are executing
62
+ The Ruby Global interpreter lock is released when scripts are executing:
53
63
 
54
64
  ```ruby
55
65
  context = MiniRacer::Context.new
@@ -57,35 +67,34 @@ Thread.new do
57
67
  sleep 1
58
68
  context.stop
59
69
  end
60
- context.eval 'while(true){}'
70
+ context.eval("while(true){}")
61
71
  # => exception is raised
62
72
  ```
63
73
 
64
74
  This allows you to execute multiple scripts in parallel.
65
75
 
66
- ### Timeout support
76
+ ### Timeout Support
67
77
 
68
78
  Contexts can specify a default timeout for scripts
69
79
 
70
80
  ```ruby
71
- # times out after 1 second (1000 ms)
72
81
  context = MiniRacer::Context.new(timeout: 1000)
73
- context.eval 'while(true){}'
74
- # => exception is raised
82
+ context.eval("while(true){}")
83
+ # => exception is raised after 1 second (1000 ms)
75
84
  ```
76
85
 
77
- ### Memory softlimit support
86
+ ### Memory softlimit Support
78
87
 
79
88
  Contexts can specify a memory softlimit for scripts
80
89
 
81
90
  ```ruby
82
91
  # terminates script if heap usage exceeds 200mb after V8 garbage collection has run
83
- context = MiniRacer::Context.new(max_memory: 200000000)
84
- context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(10000)); print("loop " + a.length);}'
92
+ context = MiniRacer::Context.new(max_memory: 200_000_000)
93
+ context.eval("var a = new Array(10000); while(true) {a = a.concat(new Array(10000)) }")
85
94
  # => V8OutOfMemoryError is raised
86
95
  ```
87
96
 
88
- ### Object marshal max stackdepth support
97
+ ### Object marshal max Stack Ddepth Support
89
98
 
90
99
  Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
91
100
 
@@ -98,23 +107,24 @@ context.eval("let arr = []; arr.push(arr); a(arr)")
98
107
  # => RuntimeError is raised
99
108
  ```
100
109
 
101
- ### Rich debugging with "filename" support
110
+ ### Rich Debugging with File Name in Stack Trace Support
102
111
 
103
- ```ruby
112
+ You can provide `filename:` to `#eval` which will be used in stack traces produced by V8:
104
113
 
114
+ ```ruby
105
115
  context = MiniRacer::Context.new
106
- context.eval('var foo = function() {bar();}', filename: 'a/foo.js')
107
- context.eval('bar()', filename: 'a/bar.js')
108
-
109
- # MiniRacer::RuntimeError is raised containing the filenames you specified for evals in backtrace
116
+ context.eval("var foo = function() {bar();}", filename: "a/foo.js")
117
+ context.eval("bar()", filename: "a/bar.js")
110
118
 
119
+ # JavaScript at a/bar.js:1:1: ReferenceError: bar is not defined (MiniRacer::RuntimeError)
120
+ # …
111
121
  ```
112
122
 
113
- ### Fork safety
123
+ ### Fork Safety
114
124
 
115
125
  Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe by default and sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
116
126
 
117
- Since 0.6.1 mini_racer does support V8 single threaded platform mode which should remove most forking related issues. To enable run this before using `MiniRacer::Context`:
127
+ Since 0.6.1 mini_racer does support V8 single threaded platform mode which should remove most forking related issues. To enable run this before using `MiniRacer::Context`, for example in a Rails initializer:
118
128
 
119
129
  ```ruby
120
130
  MiniRacer::Platform.set_flags!(:single_threaded)
@@ -122,16 +132,13 @@ MiniRacer::Platform.set_flags!(:single_threaded)
122
132
 
123
133
  If you want to ensure your application does not leak memory after fork either:
124
134
 
125
- 1. Ensure no `MiniRacer::Context` objects are created in the master process
126
-
127
- Or
128
-
135
+ 1. Ensure no `MiniRacer::Context` objects are created in the master process; or
129
136
  2. Dispose manually of all `MiniRacer::Context` objects prior to forking
130
137
 
131
138
  ```ruby
132
139
  # before fork
133
140
 
134
- require 'objspace'
141
+ require "objspace"
135
142
  ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
136
143
 
137
144
  # fork here
@@ -142,9 +149,8 @@ ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
142
149
  Context usage is threadsafe
143
150
 
144
151
  ```ruby
145
-
146
152
  context = MiniRacer::Context.new
147
- context.eval('counter=0; plus=()=>counter++;')
153
+ context.eval("counter=0; plus=()=>counter++;")
148
154
 
149
155
  (1..10).map do
150
156
  Thread.new {
@@ -154,7 +160,6 @@ end.each(&:join)
154
160
 
155
161
  puts context.eval("counter")
156
162
  # => 10
157
-
158
163
  ```
159
164
 
160
165
  ### Snapshots
@@ -162,46 +167,40 @@ puts context.eval("counter")
162
167
  Contexts can be created with pre-loaded snapshots:
163
168
 
164
169
  ```ruby
165
-
166
- snapshot = MiniRacer::Snapshot.new('function hello() { return "world!"; }')
170
+ snapshot = MiniRacer::Snapshot.new("function hello() { return 'world!'; }")
167
171
 
168
172
  context = MiniRacer::Context.new(snapshot: snapshot)
169
173
 
170
174
  context.eval("hello()")
171
175
  # => "world!"
172
-
173
- ```
174
-
175
- Snapshots can come in handy for example if you want your contexts to be pre-loaded for effiency. It uses [V8 snapshots](http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html) under the hood; see [this link](http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html) for caveats using these, in particular:
176
-
177
176
  ```
178
- There is an important limitation to snapshots: they can only capture V8’s
179
- heap. Any interaction from V8 with the outside is off-limits when creating the
180
- snapshot. Such interactions include:
181
177
 
182
- * defining and calling API callbacks (i.e. functions created via v8::FunctionTemplate)
183
- * creating typed arrays, since the backing store may be allocated outside of V8
178
+ Snapshots can come in handy for example if you want your contexts to be pre-loaded for efficiency. It uses [V8 snapshots](http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html) under the hood; see [this link](http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html) for caveats using these, in particular:
184
179
 
185
- And of course, values derived from sources such as `Math.random` or `Date.now`
186
- are fixed once the snapshot has been captured. They are no longer really random
187
- nor reflect the current time.
188
- ```
180
+ > There is an important limitation to snapshots: they can only capture V8’s
181
+ > heap. Any interaction from V8 with the outside is off-limits when creating the
182
+ > snapshot. Such interactions include:
183
+ >
184
+ > * defining and calling API callbacks (i.e. functions created via v8::FunctionTemplate)
185
+ > * creating typed arrays, since the backing store may be allocated outside of V8
186
+ >
187
+ > And of course, values derived from sources such as `Math.random` or `Date.now`
188
+ > are fixed once the snapshot has been captured. They are no longer really random
189
+ > nor reflect the current time.
189
190
 
190
191
  Also note that snapshots can be warmed up, using the `warmup!` method, which allows you to call functions which are otherwise lazily compiled to get them to compile right away; any side effect of your warm up code being then dismissed. [More details on warming up here](https://github.com/electron/electron/issues/169#issuecomment-76783481), and a small example:
191
192
 
192
193
  ```ruby
194
+ snapshot = MiniRacer::Snapshot.new("var counter = 0; function hello() { counter++; return 'world! '; }")
193
195
 
194
- snapshot = MiniRacer::Snapshot.new('var counter = 0; function hello() { counter++; return "world! "; }')
195
-
196
- snapshot.warmup!('hello()')
196
+ snapshot.warmup!("hello()")
197
197
 
198
198
  context = MiniRacer::Context.new(snapshot: snapshot)
199
199
 
200
- context.eval('hello()')
200
+ context.eval("hello()")
201
201
  # => "world! 1"
202
- context.eval('counter')
202
+ context.eval("counter")
203
203
  # => 1
204
-
205
204
  ```
206
205
 
207
206
  ### Shared isolates
@@ -209,7 +208,6 @@ context.eval('counter')
209
208
  By default, MiniRacer's contexts each have their own isolate (V8 runtime). For efficiency, it is possible to re-use an isolate across contexts:
210
209
 
211
210
  ```ruby
212
-
213
211
  isolate = MiniRacer::Isolate.new
214
212
 
215
213
  context1 = MiniRacer::Context.new(isolate: isolate)
@@ -226,7 +224,7 @@ The caveat with this is that a given isolate can only execute one context at a t
226
224
  Also, note that if you want to use shared isolates together with snapshots, you need to first create an isolate with that snapshot, and then create contexts from that isolate:
227
225
 
228
226
  ```ruby
229
- snapshot = MiniRacer::Snapshot.new('function hello() { return "world!"; }')
227
+ snapshot = MiniRacer::Snapshot.new("function hello() { return 'world!'; }")
230
228
 
231
229
  isolate = MiniRacer::Isolate.new(snapshot)
232
230
 
@@ -250,7 +248,6 @@ isolate.idle_notification(100)
250
248
 
251
249
  # force V8 to perform a full GC
252
250
  isolate.low_memory_notification
253
-
254
251
  ```
255
252
 
256
253
  This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
@@ -268,11 +265,13 @@ MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels:
268
265
  ```
269
266
 
270
267
  This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to always appreciate V8's liberal use of threading:
268
+
271
269
  ```ruby
272
270
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
273
271
  ```
274
272
 
275
273
  Or else to unlock experimental features in V8, for example tail recursion optimization:
274
+
276
275
  ```ruby
277
276
  MiniRacer::Platform.set_flags! :harmony
278
277
 
@@ -293,6 +292,7 @@ context = MiniRacer::Context.new
293
292
  context.eval js
294
293
  # => "foo"
295
294
  ```
295
+
296
296
  The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
297
297
  Please refer to http://node.green/ as a reference on other harmony features.
298
298
 
@@ -302,17 +302,18 @@ Note that runtime flags must be set before any other operation (e.g. creating a
302
302
 
303
303
  Flags:
304
304
 
305
- - :expose_gc : Will expose `gc()` which you can run in JavaScript to issue a gc
306
- - :max_old_space_size : defaults to 1400 (megs) on 64 bit, you can restric memory usage by limiting this.
307
- - **NOTE TO READER** our documentation could be awesome we could be properly documenting all the flags, they are hugely useful, if you feel like documenting a few more, PLEASE DO, PRs are welcome.
305
+ * `:expose_gc`: Will expose `gc()` which you can run in JavaScript to issue a GC run.
306
+ * `:max_old_space_size`: defaults to 1400 (megs) on 64 bit, you can restrict memory usage by limiting this.
307
+
308
+ **NOTE TO READER** our documentation could be awesome we could be properly documenting all the flags, they are hugely useful, if you feel like documenting a few more, PLEASE DO, PRs are welcome.
308
309
 
309
310
  ## Controlling memory
310
311
 
311
- When hosting v8 you may want to keep track of memory usage, use #heap_stats to get memory usage:
312
+ When hosting v8 you may want to keep track of memory usage, use `#heap_stats` to get memory usage:
312
313
 
313
314
  ```ruby
314
- context = MiniRacer::Context.new(timeout: 5)
315
- context.eval("let a='testing';")
315
+ context = MiniRacer::Context.new
316
+ # use context
316
317
  p context.heap_stats
317
318
  # {:total_physical_size=>1280640,
318
319
  # :total_heap_size_executable=>4194304,
@@ -321,27 +322,27 @@ p context.heap_stats
321
322
  # :heap_size_limit=>1501560832}
322
323
  ```
323
324
 
324
- If you wish to dispose of a context before waiting on the GC use
325
+ If you wish to dispose of a context before waiting on the GC use `#dispose`:
325
326
 
326
327
  ```ruby
327
- context = MiniRacer::Context.new(timeout: 5)
328
+ context = MiniRacer::Context.new
328
329
  context.eval("let a='testing';")
329
330
  context.dispose
330
331
  context.eval("a = 2")
331
332
  # MiniRacer::ContextDisposedError
332
333
 
333
- # nothing works on the context from now on, its a shell waiting to be disposed
334
+ # nothing works on the context from now on, it's a shell waiting to be disposed
334
335
  ```
335
336
 
336
337
  A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
337
338
 
338
339
  ```ruby
339
- context = MiniRacer::Context.new(timeout: 5)
340
- context.eval("let a='testing';")
340
+ context = MiniRacer::Context.new
341
+ # use context
341
342
  context.write_heap_snapshot("test.heapsnapshot")
342
343
  ```
343
344
 
344
- This file can then be loaded in the memory tab of the chrome dev console.
345
+ This file can then be loaded in the "memory" tab of the [Chrome DevTools](https://developer.chrome.com/docs/devtools/memory-problems/heap-snapshots/#view_snapshots).
345
346
 
346
347
  ### Function call
347
348
 
@@ -349,30 +350,29 @@ This calls the function passed as first argument:
349
350
 
350
351
  ```ruby
351
352
  context = MiniRacer::Context.new
352
- context.eval('function hello(name) { return "Hello, " + name + "!" }')
353
- context.call('hello', 'George')
353
+ context.eval("function hello(name) { return `Hello, ${name}!` }")
354
+ context.call("hello", "George")
354
355
  # "Hello, George!"
355
356
  ```
356
357
 
357
- Performance is slightly better than running `eval('hello("George")')` since:
358
+ Performance is slightly better than running `context.eval("hello('George')")` since:
358
359
 
359
- - compilation of eval'd string is avoided
360
- - function arguments don't need to be converted to JSON
360
+ * compilation of eval'd string is avoided
361
+ * function arguments don't need to be converted to JSON
361
362
 
362
363
  ## Performance
363
364
 
364
365
  The `bench` folder contains benchmark.
365
366
 
366
- ### Benchmark minification of Discourse application.js (both minified and unminified)
367
+ ### Benchmark minification of Discourse application.js (both minified and non-minified)
367
368
 
368
369
  MiniRacer outperforms node when minifying assets via execjs.
369
370
 
370
- - MiniRacer version 0.1.9
371
- - node version 6.10
372
- - therubyracer version 0.12.2
373
-
374
- ```
371
+ * MiniRacer version 0.1.9
372
+ * node version 6.10
373
+ * therubyracer version 0.12.2
375
374
 
375
+ ```terminal
376
376
  $ bundle exec ruby bench.rb mini_racer
377
377
  Benching with mini_racer
378
378
  mini_racer minify discourse_app.js 9292.72063ms
@@ -409,78 +409,64 @@ MiniRacer can fully support source maps but must be configured correctly to do s
409
409
  Add this line to your application's Gemfile:
410
410
 
411
411
  ```ruby
412
- gem 'mini_racer'
412
+ gem "mini_racer"
413
413
  ```
414
414
 
415
415
  And then execute:
416
416
 
417
- $ bundle
417
+ ```terminal
418
+ $ bundle
418
419
 
419
420
  Or install it yourself as:
420
421
 
421
- $ gem install mini_racer
422
-
422
+ ```terminal
423
+ $ gem install mini_racer
424
+ ```
423
425
 
424
426
  **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or GCC 6.3 (or later).
425
427
 
426
-
427
- ### Troubleshooting
428
-
429
- If you have a problem installing mini_racer, please consider the following steps:
430
-
431
- * make sure you try the latest released version of mini_racer
432
- * make sure you have Rubygems >= 3.2.13 and bundler >= 2.2.13 installed via `gem update --system`
433
- * if you are using bundler, make sure to have `PLATFORMS` set correctly in `Gemfile.lock` via `bundle lock --add-platform`
434
- * make sure to recompile/reinstall `mini_racer` and `libv8-node` after system upgrades (for example via `gem uninstall --all mini_racer libv8-node`)
435
- * make sure you are on the latest patch/teeny version of a supported Ruby branch
436
-
437
428
  ## Similar Projects
438
429
 
439
430
  ### therubyracer
440
431
 
441
- - https://github.com/cowboyd/therubyracer
442
- - Most comprehensive bridge available
443
- - Provides the ability to "eval" JavaScript
444
- - Provides the ability to invoke Ruby code from JavaScript
445
- - Hold references to JavaScript objects and methods in your Ruby code
446
- - Hold references to Ruby objects and methods in JavaScript code
447
- - Uses libv8, so installation is fast
448
- - Supports timeouts for JavaScript execution
449
- - Does not release global interpreter lock, so performance is constrained to a single thread
450
- - Currently (May 2016) only supports v8 version 3.16.14 (Released approx November 2013), plans to upgrade by July 2016
451
- - Supports execjs
452
-
432
+ * https://github.com/cowboyd/therubyracer
433
+ * Most comprehensive bridge available
434
+ * Provides the ability to "eval" JavaScript
435
+ * Provides the ability to invoke Ruby code from JavaScript
436
+ * Hold references to JavaScript objects and methods in your Ruby code
437
+ * Hold references to Ruby objects and methods in JavaScript code
438
+ * Uses libv8, so installation is fast
439
+ * Supports timeouts for JavaScript execution
440
+ * Does not release global interpreter lock, so performance is constrained to a single thread
441
+ * Currently (May 2016) only supports v8 version 3.16.14 (Released approx November 2013), plans to upgrade by July 2016
442
+ * Supports execjs
453
443
 
454
444
  ### v8eval
455
445
 
456
- - https://github.com/sony/v8eval
457
- - Provides the ability to "eval" JavaScript using the latest V8 engine
458
- - Does not depend on the [libv8](https://github.com/cowboyd/libv8) gem, installation can take 10-20 mins as V8 needs to be downloaded and compiled.
459
- - Does not release global interpreter lock when executing JavaScript
460
- - Does not allow you to invoke Ruby code from JavaScript
461
- - Multi runtime support due to SWIG based bindings
462
- - Supports a JavaScript debugger
463
- - Does not support timeouts for JavaScript execution
464
- - No support for execjs (can not be used with Rails uglifier and coffeescript gems)
465
-
446
+ * https://github.com/sony/v8eval
447
+ * Provides the ability to "eval" JavaScript using the latest V8 engine
448
+ * Does not depend on the [libv8](https://github.com/cowboyd/libv8) gem, installation can take 10-20 mins as V8 needs to be downloaded and compiled.
449
+ * Does not release global interpreter lock when executing JavaScript
450
+ * Does not allow you to invoke Ruby code from JavaScript
451
+ * Multi runtime support due to SWIG based bindings
452
+ * Supports a JavaScript debugger
453
+ * Does not support timeouts for JavaScript execution
454
+ * No support for execjs (can not be used with Rails uglifier and coffeescript gems)
466
455
 
467
456
  ### therubyrhino
468
457
 
469
- - https://github.com/cowboyd/therubyrhino
470
- - API compatible with therubyracer
471
- - Uses Mozilla's Rhino engine https://github.com/mozilla/rhino
472
- - Requires JRuby
473
- - Support for timeouts for JavaScript execution
474
- - Concurrent cause .... JRuby
475
- - Supports execjs
476
-
458
+ * https://github.com/cowboyd/therubyrhino
459
+ * API compatible with therubyracer
460
+ * Uses Mozilla's Rhino engine https://github.com/mozilla/rhino
461
+ * Requires JRuby
462
+ * Support for timeouts for JavaScript execution
463
+ * Concurrent cause .... JRuby
464
+ * Supports execjs
477
465
 
478
466
  ## Contributing
479
467
 
480
468
  Bug reports and pull requests are welcome on GitHub at https://github.com/rubyjs/mini_racer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
481
469
 
482
-
483
470
  ## License
484
471
 
485
472
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
486
-
@@ -658,7 +658,7 @@ static VALUE convert_v8_to_ruby(Isolate* isolate, Local<Context> context,
658
658
 
659
659
  if (value->IsSymbol()) {
660
660
  v8::String::Utf8Value symbol_name(isolate,
661
- Local<Symbol>::Cast(value)->Name());
661
+ Local<Symbol>::Cast(value)->Description(isolate));
662
662
 
663
663
  VALUE str_symbol = rb_utf8_str_new(*symbol_name, symbol_name.length());
664
664
 
@@ -71,7 +71,9 @@ module MiniRacer
71
71
  end
72
72
 
73
73
  unless Polyglot.languages.include? "js"
74
- warn "You also need to install the 'js' component with 'gu install js' on GraalVM 22.2+", uplevel: 0 if $VERBOSE
74
+ raise "The language 'js' is not available, you likely need to `export TRUFFLERUBYOPT='--jvm --polyglot'`\n" \
75
+ "You also need to install the 'js' component with 'gu install js' on GraalVM 22.2+\n" \
76
+ "Note that you need TruffleRuby+GraalVM and not just the TruffleRuby standalone to use MiniRacer"
75
77
  end
76
78
 
77
79
  @context = Polyglot::InnerContext.new(on_cancelled: -> {
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniRacer
4
- VERSION = "0.6.3"
5
- LIBV8_NODE_VERSION = "~> 16.10.0.0"
4
+ VERSION = "0.7.0"
5
+ LIBV8_NODE_VERSION = "~> 17.9.1.0"
6
6
  end
data/mini_racer.gemspec CHANGED
@@ -35,5 +35,5 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.extensions = ["ext/mini_racer_loader/extconf.rb", "ext/mini_racer_extension/extconf.rb"]
37
37
 
38
- spec.required_ruby_version = '>= 2.6'
38
+ spec.required_ruby_version = '>= 3.0'
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_racer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2023-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 16.10.0.0
89
+ version: 17.9.1.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 16.10.0.0
96
+ version: 17.9.1.0
97
97
  description: Minimal embedded v8 engine for Ruby
98
98
  email:
99
99
  - sam.saffron@gmail.com
@@ -128,9 +128,9 @@ licenses:
128
128
  - MIT
129
129
  metadata:
130
130
  bug_tracker_uri: https://github.com/discourse/mini_racer/issues
131
- changelog_uri: https://github.com/discourse/mini_racer/blob/v0.6.3/CHANGELOG
132
- documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.6.3
133
- source_code_uri: https://github.com/discourse/mini_racer/tree/v0.6.3
131
+ changelog_uri: https://github.com/discourse/mini_racer/blob/v0.7.0/CHANGELOG
132
+ documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.7.0
133
+ source_code_uri: https://github.com/discourse/mini_racer/tree/v0.7.0
134
134
  post_install_message:
135
135
  rdoc_options: []
136
136
  require_paths:
@@ -140,14 +140,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: '2.6'
143
+ version: '3.0'
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.3.20
150
+ rubygems_version: 3.4.6
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Minimal embedded v8 for Ruby