mini_racer 0.19.2 → 0.20.0
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/CHANGELOG +3 -0
- data/README.md +19 -0
- data/ext/mini_racer_extension/mini_racer_extension.c +15 -0
- data/lib/mini_racer/version.rb +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5aa16bf587a6e12df562d7a946ce3a965a8444debd9769b376075cafd10a3b5c
|
|
4
|
+
data.tar.gz: 5aaf6a08ae90f05bc554bae0a06e93efce5318d00aacdfe959f36513533caac4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b2641ceb0fd1770efd32cfb9e37aee92ca857ad6acbe2129157a58be9ed6bbef4a355c5af133f5749f229d578e10a452ef77a62eadbe436993f005146d242cd
|
|
7
|
+
data.tar.gz: 3264e95d4951aa52ba080a94b847c5080705e1de0e3dd5fefae0786342ccece850b00db4f151220e65068e9e5d62fb0eebae0fda65e79647196903fae70d8012
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
|
@@ -193,6 +193,25 @@ context.eval("counter")
|
|
|
193
193
|
# => 1
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
+
Snapshots can also be persisted to disk for faster startup:
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
# Save a snapshot to disk
|
|
200
|
+
snapshot = MiniRacer::Snapshot.new('var foo = "bar";')
|
|
201
|
+
File.binwrite("snapshot.bin", snapshot.dump)
|
|
202
|
+
|
|
203
|
+
# Load it back in a later process
|
|
204
|
+
blob = File.binread("snapshot.bin")
|
|
205
|
+
snapshot = MiniRacer::Snapshot.load(blob)
|
|
206
|
+
context = MiniRacer::Context.new(snapshot: snapshot)
|
|
207
|
+
context.eval("foo")
|
|
208
|
+
# => "bar"
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Note that snapshots are architecture and V8-version specific. A snapshot created on one platform (e.g., ARM64 macOS) cannot be loaded on a different platform (e.g., x86_64 Linux). Snapshots are best used for same-machine caching or homogeneous deployment environments.
|
|
212
|
+
|
|
213
|
+
**Security note:** Only load snapshots from trusted sources. V8 snapshots are not designed to be safely loaded from untrusted input—malformed or malicious snapshot data may cause crashes or memory corruption.
|
|
214
|
+
|
|
196
215
|
### Garbage collection
|
|
197
216
|
|
|
198
217
|
You can make the garbage collector more aggressive by defining the context with `MiniRacer::Context.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.low_memory_notification` 1 second after the last eval on the context. Low memory notifications ensure long living contexts use minimal amounts of memory.
|
|
@@ -1690,6 +1690,20 @@ static VALUE snapshot_dump(VALUE self)
|
|
|
1690
1690
|
return ss->blob;
|
|
1691
1691
|
}
|
|
1692
1692
|
|
|
1693
|
+
static VALUE snapshot_load(VALUE klass, VALUE blob)
|
|
1694
|
+
{
|
|
1695
|
+
Snapshot *ss;
|
|
1696
|
+
VALUE self;
|
|
1697
|
+
|
|
1698
|
+
Check_Type(blob, T_STRING);
|
|
1699
|
+
self = snapshot_alloc(klass);
|
|
1700
|
+
TypedData_Get_Struct(self, Snapshot, &snapshot_type, ss);
|
|
1701
|
+
ss->blob = rb_str_dup(blob);
|
|
1702
|
+
rb_enc_associate(ss->blob, rb_ascii8bit_encoding());
|
|
1703
|
+
ENC_CODERANGE_SET(ss->blob, ENC_CODERANGE_VALID);
|
|
1704
|
+
return self;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1693
1707
|
static VALUE snapshot_size0(VALUE self)
|
|
1694
1708
|
{
|
|
1695
1709
|
Snapshot *ss;
|
|
@@ -1742,6 +1756,7 @@ void Init_mini_racer_extension(void)
|
|
|
1742
1756
|
rb_define_method(c, "warmup!", snapshot_warmup, 1);
|
|
1743
1757
|
rb_define_method(c, "dump", snapshot_dump, 0);
|
|
1744
1758
|
rb_define_method(c, "size", snapshot_size0, 0);
|
|
1759
|
+
rb_define_singleton_method(c, "load", snapshot_load, 1);
|
|
1745
1760
|
rb_define_alloc_func(c, snapshot_alloc);
|
|
1746
1761
|
|
|
1747
1762
|
c = rb_define_class_under(m, "Platform", rb_cObject);
|
data/lib/mini_racer/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mini_racer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Saffron
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-02-24 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: bundler
|
|
@@ -112,8 +113,8 @@ email:
|
|
|
112
113
|
- sam.saffron@gmail.com
|
|
113
114
|
executables: []
|
|
114
115
|
extensions:
|
|
115
|
-
- ext/mini_racer_extension/extconf.rb
|
|
116
116
|
- ext/mini_racer_loader/extconf.rb
|
|
117
|
+
- ext/mini_racer_extension/extconf.rb
|
|
117
118
|
extra_rdoc_files: []
|
|
118
119
|
files:
|
|
119
120
|
- CHANGELOG
|
|
@@ -136,9 +137,10 @@ licenses:
|
|
|
136
137
|
- MIT
|
|
137
138
|
metadata:
|
|
138
139
|
bug_tracker_uri: https://github.com/discourse/mini_racer/issues
|
|
139
|
-
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.
|
|
140
|
-
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.
|
|
141
|
-
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.
|
|
140
|
+
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.20.0/CHANGELOG
|
|
141
|
+
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.20.0
|
|
142
|
+
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.20.0
|
|
143
|
+
post_install_message:
|
|
142
144
|
rdoc_options: []
|
|
143
145
|
require_paths:
|
|
144
146
|
- lib
|
|
@@ -154,7 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
154
156
|
- !ruby/object:Gem::Version
|
|
155
157
|
version: '0'
|
|
156
158
|
requirements: []
|
|
157
|
-
rubygems_version: 3.
|
|
159
|
+
rubygems_version: 3.5.22
|
|
160
|
+
signing_key:
|
|
158
161
|
specification_version: 4
|
|
159
162
|
summary: Minimal embedded v8 for Ruby
|
|
160
163
|
test_files: []
|