mini_racer 0.6.4 → 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: 2d643f2cd1fb220fc7ac49d502671334d2e9390cd6eac47b62cdecfc39f2dd82
4
- data.tar.gz: 2c1cbb7cb254dddefdeac0c7bd246d62e2f08dfb9df24c91680ef0e6016ea483
3
+ metadata.gz: 597511b18a2cdc00c0eaa3bb048930449564099b24ef6513fc3f6f0b5e233a29
4
+ data.tar.gz: af21176c1943dcb664b2f3266e92b73de02ce8c572073fcd22e0d61a14e7293f
5
5
  SHA512:
6
- metadata.gz: be7c745abba5a2bd5caf0e30f066601a58d00f847092bde4865d3faf7b79987af5bfe0c6cd9c2783f0ab7a7edc1e39b6a53afa489ce4e5dde0713981e26dfc51
7
- data.tar.gz: e6128f7619cdb105b04f5a7abb0ed2c0964a2b2b353c3a4eecc79dfa3d329d88695f9885c7250d2d6615ff9bc93c22cf111d24bca54d9e57fbaa02672998879c
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
@@ -23,7 +23,6 @@
23
23
  - Corrected re-raising of exceptions to support strings
24
24
  - During early termination of context under certain conditions MiniRacer could crash
25
25
 
26
-
27
26
  - 31-12-2021
28
27
 
29
28
  - 0.6.1
@@ -33,10 +32,10 @@
33
32
 
34
33
  - 0.6.0
35
34
 
36
- - Ruby 3.1 support
37
- - Fixes memory leak in heap snapshotting
38
- - Improved compilation ergonomics in clang
39
- - 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
40
39
 
41
40
  - 11-04-2021
42
41
 
@@ -87,7 +86,7 @@
87
86
 
88
87
  - 0.2.13
89
88
 
90
- - 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
91
90
 
92
91
  - 15-05-2020
93
92
 
@@ -137,7 +136,7 @@
137
136
 
138
137
  - 0.2.5
139
138
 
140
- - FIX: Compatiblity fixes for V8 7 and above @ignisf
139
+ - FIX: Compatibility fixes for V8 7 and above @ignisf
141
140
  - FIX: Memory leak in gc_callback @messense
142
141
  - IMPROVEMENT: Added example of sourcemap support @ianks
143
142
  - URGENT: you will need this release for latest version of libv8 to work
@@ -154,15 +153,15 @@
154
153
  - 0.2.3
155
154
 
156
155
  - Drop all conditional logic from Mini Racer compilation for clang, always
157
- rely on MacOS being High Sierra or up
156
+ rely on MacOS being High Sierra or up
158
157
 
159
158
  - 26-09-2018
160
159
 
161
160
  - 0.2.2
162
161
 
163
162
  - WORKAROUND: RUBY_PLATFORM is hardcoded on Ruby compile and can not be
164
- trusted for feature detection, use a different technique when checking for
165
- macOS Mojave
163
+ trusted for feature detection, use a different technique when checking for
164
+ macOS Mojave
166
165
 
167
166
  - 25-09-2018
168
167
 
@@ -190,7 +189,7 @@
190
189
 
191
190
  - 0.1.14
192
191
 
193
- - libv8 erronuously bumped to beta, reverted change
192
+ - libv8 erroneously bumped to beta, reverted change
194
193
 
195
194
  23-08-2017
196
195
 
@@ -203,7 +202,7 @@
203
202
  - 0.1.12
204
203
 
205
204
  - Feature: upgrade libv8 to 5.9
206
- - Fix: warning when runnin with ruby warnings enabled (missed @disposed initialize)
205
+ - Fix: warning when running with ruby warnings enabled (missed @disposed initialize)
207
206
 
208
207
  18-07-2017
209
208
 
@@ -215,16 +214,16 @@
215
214
 
216
215
  - 0.1.10
217
216
 
218
- - Fix leak: memory leak when disposing a context (20 bytes per context)
219
- - Feature: added #heap_stats so you can get visibility from context to actual memory usage of isolate
220
- - Feature: added #dispose so you reclaim all v8 memory right away as opposed to waiting for GC
221
- - 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')
222
221
 
223
222
  09-03-2017
224
223
 
225
224
  - 0.1.9
226
225
 
227
- - Perf: speed up ruby/node boundary performance when moving large objects
226
+ - Perf: speed up ruby/node boundary performance when moving large objects
228
227
 
229
228
  06-02-2017
230
229
 
@@ -264,7 +263,6 @@
264
263
  - Support more conversions from Ruby back to JS (Hash, Symbol, Array)
265
264
  - Support attaching nested objects
266
265
 
267
-
268
266
  17-05-2016
269
267
 
270
268
  - 0.1.2
@@ -282,4 +280,4 @@
282
280
 
283
281
  - 0.1.1.beta.1
284
282
 
285
- - 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,22 +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
- ### Supported Ruby Versions
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
18
 
19
- 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).
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
20
28
 
21
29
  ## Features
22
30
 
@@ -26,8 +34,8 @@ You can simply eval one or many JavaScript snippets in a shared context
26
34
 
27
35
  ```ruby
28
36
  context = MiniRacer::Context.new
29
- context.eval 'var adder = (a,b)=>a+b;'
30
- puts context.eval 'adder(20,22)'
37
+ context.eval("var adder = (a,b)=>a+b;")
38
+ puts context.eval("adder(20,22)")
31
39
  # => 42
32
40
  ```
33
41
 
@@ -38,20 +46,20 @@ You can attach one or many ruby proc that can be accessed via JavaScript
38
46
  ```ruby
39
47
  context = MiniRacer::Context.new
40
48
  context.attach("math.adder", proc{|a,b| a+b})
41
- puts context.eval 'math.adder(20,22)'
49
+ puts context.eval("math.adder(20,22)")
42
50
  # => 42
43
51
  ```
44
52
 
45
53
  ```ruby
46
54
  context = MiniRacer::Context.new
47
55
  context.attach("array_and_hash", proc{{a: 1, b: [1, {a: 1}]}})
48
- puts context.eval 'array_and_hash()'
56
+ puts context.eval("array_and_hash()")
49
57
  # => {"a" => 1, "b" => [1, {"a" => 1}]}
50
58
  ```
51
59
 
52
60
  ### GIL free JavaScript execution
53
61
 
54
- The Ruby Global interpreter lock is released when scripts are executing
62
+ The Ruby Global interpreter lock is released when scripts are executing:
55
63
 
56
64
  ```ruby
57
65
  context = MiniRacer::Context.new
@@ -59,35 +67,34 @@ Thread.new do
59
67
  sleep 1
60
68
  context.stop
61
69
  end
62
- context.eval 'while(true){}'
70
+ context.eval("while(true){}")
63
71
  # => exception is raised
64
72
  ```
65
73
 
66
74
  This allows you to execute multiple scripts in parallel.
67
75
 
68
- ### Timeout support
76
+ ### Timeout Support
69
77
 
70
78
  Contexts can specify a default timeout for scripts
71
79
 
72
80
  ```ruby
73
- # times out after 1 second (1000 ms)
74
81
  context = MiniRacer::Context.new(timeout: 1000)
75
- context.eval 'while(true){}'
76
- # => exception is raised
82
+ context.eval("while(true){}")
83
+ # => exception is raised after 1 second (1000 ms)
77
84
  ```
78
85
 
79
- ### Memory softlimit support
86
+ ### Memory softlimit Support
80
87
 
81
88
  Contexts can specify a memory softlimit for scripts
82
89
 
83
90
  ```ruby
84
91
  # terminates script if heap usage exceeds 200mb after V8 garbage collection has run
85
- context = MiniRacer::Context.new(max_memory: 200000000)
86
- 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)) }")
87
94
  # => V8OutOfMemoryError is raised
88
95
  ```
89
96
 
90
- ### Object marshal max stackdepth support
97
+ ### Object marshal max Stack Ddepth Support
91
98
 
92
99
  Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
93
100
 
@@ -100,23 +107,24 @@ context.eval("let arr = []; arr.push(arr); a(arr)")
100
107
  # => RuntimeError is raised
101
108
  ```
102
109
 
103
- ### Rich debugging with "filename" support
110
+ ### Rich Debugging with File Name in Stack Trace Support
104
111
 
105
- ```ruby
112
+ You can provide `filename:` to `#eval` which will be used in stack traces produced by V8:
106
113
 
114
+ ```ruby
107
115
  context = MiniRacer::Context.new
108
- context.eval('var foo = function() {bar();}', filename: 'a/foo.js')
109
- context.eval('bar()', filename: 'a/bar.js')
110
-
111
- # 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")
112
118
 
119
+ # JavaScript at a/bar.js:1:1: ReferenceError: bar is not defined (MiniRacer::RuntimeError)
120
+ # …
113
121
  ```
114
122
 
115
- ### Fork safety
123
+ ### Fork Safety
116
124
 
117
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).
118
126
 
119
- 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:
120
128
 
121
129
  ```ruby
122
130
  MiniRacer::Platform.set_flags!(:single_threaded)
@@ -124,16 +132,13 @@ MiniRacer::Platform.set_flags!(:single_threaded)
124
132
 
125
133
  If you want to ensure your application does not leak memory after fork either:
126
134
 
127
- 1. Ensure no `MiniRacer::Context` objects are created in the master process
128
-
129
- Or
130
-
135
+ 1. Ensure no `MiniRacer::Context` objects are created in the master process; or
131
136
  2. Dispose manually of all `MiniRacer::Context` objects prior to forking
132
137
 
133
138
  ```ruby
134
139
  # before fork
135
140
 
136
- require 'objspace'
141
+ require "objspace"
137
142
  ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
138
143
 
139
144
  # fork here
@@ -144,9 +149,8 @@ ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
144
149
  Context usage is threadsafe
145
150
 
146
151
  ```ruby
147
-
148
152
  context = MiniRacer::Context.new
149
- context.eval('counter=0; plus=()=>counter++;')
153
+ context.eval("counter=0; plus=()=>counter++;")
150
154
 
151
155
  (1..10).map do
152
156
  Thread.new {
@@ -156,7 +160,6 @@ end.each(&:join)
156
160
 
157
161
  puts context.eval("counter")
158
162
  # => 10
159
-
160
163
  ```
161
164
 
162
165
  ### Snapshots
@@ -164,46 +167,40 @@ puts context.eval("counter")
164
167
  Contexts can be created with pre-loaded snapshots:
165
168
 
166
169
  ```ruby
167
-
168
- snapshot = MiniRacer::Snapshot.new('function hello() { return "world!"; }')
170
+ snapshot = MiniRacer::Snapshot.new("function hello() { return 'world!'; }")
169
171
 
170
172
  context = MiniRacer::Context.new(snapshot: snapshot)
171
173
 
172
174
  context.eval("hello()")
173
175
  # => "world!"
174
-
175
- ```
176
-
177
- 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:
178
-
179
176
  ```
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
177
 
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
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:
186
179
 
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.
190
- ```
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.
191
190
 
192
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:
193
192
 
194
193
  ```ruby
194
+ snapshot = MiniRacer::Snapshot.new("var counter = 0; function hello() { counter++; return 'world! '; }")
195
195
 
196
- snapshot = MiniRacer::Snapshot.new('var counter = 0; function hello() { counter++; return "world! "; }')
197
-
198
- snapshot.warmup!('hello()')
196
+ snapshot.warmup!("hello()")
199
197
 
200
198
  context = MiniRacer::Context.new(snapshot: snapshot)
201
199
 
202
- context.eval('hello()')
200
+ context.eval("hello()")
203
201
  # => "world! 1"
204
- context.eval('counter')
202
+ context.eval("counter")
205
203
  # => 1
206
-
207
204
  ```
208
205
 
209
206
  ### Shared isolates
@@ -211,7 +208,6 @@ context.eval('counter')
211
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:
212
209
 
213
210
  ```ruby
214
-
215
211
  isolate = MiniRacer::Isolate.new
216
212
 
217
213
  context1 = MiniRacer::Context.new(isolate: isolate)
@@ -228,7 +224,7 @@ The caveat with this is that a given isolate can only execute one context at a t
228
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:
229
225
 
230
226
  ```ruby
231
- snapshot = MiniRacer::Snapshot.new('function hello() { return "world!"; }')
227
+ snapshot = MiniRacer::Snapshot.new("function hello() { return 'world!'; }")
232
228
 
233
229
  isolate = MiniRacer::Isolate.new(snapshot)
234
230
 
@@ -252,7 +248,6 @@ isolate.idle_notification(100)
252
248
 
253
249
  # force V8 to perform a full GC
254
250
  isolate.low_memory_notification
255
-
256
251
  ```
257
252
 
258
253
  This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
@@ -270,11 +265,13 @@ MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels:
270
265
  ```
271
266
 
272
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
+
273
269
  ```ruby
274
270
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
275
271
  ```
276
272
 
277
273
  Or else to unlock experimental features in V8, for example tail recursion optimization:
274
+
278
275
  ```ruby
279
276
  MiniRacer::Platform.set_flags! :harmony
280
277
 
@@ -295,6 +292,7 @@ context = MiniRacer::Context.new
295
292
  context.eval js
296
293
  # => "foo"
297
294
  ```
295
+
298
296
  The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
299
297
  Please refer to http://node.green/ as a reference on other harmony features.
300
298
 
@@ -304,17 +302,18 @@ Note that runtime flags must be set before any other operation (e.g. creating a
304
302
 
305
303
  Flags:
306
304
 
307
- - :expose_gc : Will expose `gc()` which you can run in JavaScript to issue a gc
308
- - :max_old_space_size : defaults to 1400 (megs) on 64 bit, you can restric memory usage by limiting this.
309
- - **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.
310
309
 
311
310
  ## Controlling memory
312
311
 
313
- 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:
314
313
 
315
314
  ```ruby
316
- context = MiniRacer::Context.new(timeout: 5)
317
- context.eval("let a='testing';")
315
+ context = MiniRacer::Context.new
316
+ # use context
318
317
  p context.heap_stats
319
318
  # {:total_physical_size=>1280640,
320
319
  # :total_heap_size_executable=>4194304,
@@ -323,27 +322,27 @@ p context.heap_stats
323
322
  # :heap_size_limit=>1501560832}
324
323
  ```
325
324
 
326
- 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`:
327
326
 
328
327
  ```ruby
329
- context = MiniRacer::Context.new(timeout: 5)
328
+ context = MiniRacer::Context.new
330
329
  context.eval("let a='testing';")
331
330
  context.dispose
332
331
  context.eval("a = 2")
333
332
  # MiniRacer::ContextDisposedError
334
333
 
335
- # 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
336
335
  ```
337
336
 
338
337
  A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
339
338
 
340
339
  ```ruby
341
- context = MiniRacer::Context.new(timeout: 5)
342
- context.eval("let a='testing';")
340
+ context = MiniRacer::Context.new
341
+ # use context
343
342
  context.write_heap_snapshot("test.heapsnapshot")
344
343
  ```
345
344
 
346
- 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).
347
346
 
348
347
  ### Function call
349
348
 
@@ -351,30 +350,29 @@ This calls the function passed as first argument:
351
350
 
352
351
  ```ruby
353
352
  context = MiniRacer::Context.new
354
- context.eval('function hello(name) { return "Hello, " + name + "!" }')
355
- context.call('hello', 'George')
353
+ context.eval("function hello(name) { return `Hello, ${name}!` }")
354
+ context.call("hello", "George")
356
355
  # "Hello, George!"
357
356
  ```
358
357
 
359
- Performance is slightly better than running `eval('hello("George")')` since:
358
+ Performance is slightly better than running `context.eval("hello('George')")` since:
360
359
 
361
- - compilation of eval'd string is avoided
362
- - 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
363
362
 
364
363
  ## Performance
365
364
 
366
365
  The `bench` folder contains benchmark.
367
366
 
368
- ### Benchmark minification of Discourse application.js (both minified and unminified)
367
+ ### Benchmark minification of Discourse application.js (both minified and non-minified)
369
368
 
370
369
  MiniRacer outperforms node when minifying assets via execjs.
371
370
 
372
- - MiniRacer version 0.1.9
373
- - node version 6.10
374
- - therubyracer version 0.12.2
375
-
376
- ```
371
+ * MiniRacer version 0.1.9
372
+ * node version 6.10
373
+ * therubyracer version 0.12.2
377
374
 
375
+ ```terminal
378
376
  $ bundle exec ruby bench.rb mini_racer
379
377
  Benching with mini_racer
380
378
  mini_racer minify discourse_app.js 9292.72063ms
@@ -411,78 +409,64 @@ MiniRacer can fully support source maps but must be configured correctly to do s
411
409
  Add this line to your application's Gemfile:
412
410
 
413
411
  ```ruby
414
- gem 'mini_racer'
412
+ gem "mini_racer"
415
413
  ```
416
414
 
417
415
  And then execute:
418
416
 
419
- $ bundle
417
+ ```terminal
418
+ $ bundle
420
419
 
421
420
  Or install it yourself as:
422
421
 
423
- $ gem install mini_racer
424
-
422
+ ```terminal
423
+ $ gem install mini_racer
424
+ ```
425
425
 
426
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).
427
427
 
428
-
429
- ### Troubleshooting
430
-
431
- If you have a problem installing mini_racer, please consider the following steps:
432
-
433
- * make sure you try the latest released version of mini_racer
434
- * make sure you have Rubygems >= 3.2.13 and bundler >= 2.2.13 installed via `gem update --system`
435
- * if you are using bundler, make sure to have `PLATFORMS` set correctly in `Gemfile.lock` via `bundle lock --add-platform`
436
- * make sure to recompile/reinstall `mini_racer` and `libv8-node` after system upgrades (for example via `gem uninstall --all mini_racer libv8-node`)
437
- * make sure you are on the latest patch/teeny version of a supported Ruby branch
438
-
439
428
  ## Similar Projects
440
429
 
441
430
  ### therubyracer
442
431
 
443
- - https://github.com/cowboyd/therubyracer
444
- - Most comprehensive bridge available
445
- - Provides the ability to "eval" JavaScript
446
- - Provides the ability to invoke Ruby code from JavaScript
447
- - Hold references to JavaScript objects and methods in your Ruby code
448
- - Hold references to Ruby objects and methods in JavaScript code
449
- - Uses libv8, so installation is fast
450
- - Supports timeouts for JavaScript execution
451
- - Does not release global interpreter lock, so performance is constrained to a single thread
452
- - Currently (May 2016) only supports v8 version 3.16.14 (Released approx November 2013), plans to upgrade by July 2016
453
- - Supports execjs
454
-
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
455
443
 
456
444
  ### v8eval
457
445
 
458
- - https://github.com/sony/v8eval
459
- - Provides the ability to "eval" JavaScript using the latest V8 engine
460
- - 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.
461
- - Does not release global interpreter lock when executing JavaScript
462
- - Does not allow you to invoke Ruby code from JavaScript
463
- - Multi runtime support due to SWIG based bindings
464
- - Supports a JavaScript debugger
465
- - Does not support timeouts for JavaScript execution
466
- - No support for execjs (can not be used with Rails uglifier and coffeescript gems)
467
-
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)
468
455
 
469
456
  ### therubyrhino
470
457
 
471
- - https://github.com/cowboyd/therubyrhino
472
- - API compatible with therubyracer
473
- - Uses Mozilla's Rhino engine https://github.com/mozilla/rhino
474
- - Requires JRuby
475
- - Support for timeouts for JavaScript execution
476
- - Concurrent cause .... JRuby
477
- - Supports execjs
478
-
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
479
465
 
480
466
  ## Contributing
481
467
 
482
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.
483
469
 
484
-
485
470
  ## License
486
471
 
487
472
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
488
-
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniRacer
4
- VERSION = "0.6.4"
5
- LIBV8_NODE_VERSION = "~> 16.19.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.4
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: 2023-05-26 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.19.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.19.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.4/CHANGELOG
132
- documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.6.4
133
- source_code_uri: https://github.com/discourse/mini_racer/tree/v0.6.4
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,7 +140,7 @@ 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
  - - ">="