quickjs 0.17.0 → 0.19.0.pre1

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.
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # FormatJS Intl polyfill (`en` locale only — getCanonicalLocales, Locale,
4
+ # PluralRules, NumberFormat, DateTimeFormat). Compiled and cached on first
5
+ # VM that enables the feature; the file is not read until then.
6
+
7
+ Quickjs.register_polyfill(
8
+ Quickjs::POLYFILL_INTL,
9
+ source: -> { File.read(File.expand_path('intl-en.min.js', __dir__)) },
10
+ init: "Object.defineProperty(globalThis, 'Intl', { value:{} });"
11
+ )
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Quickjs
4
+ # Process-wide registry; entries are lazily compiled to bytecode on
5
+ # first use and the bytecode is reused across VMs.
6
+ @_polyfills = {}
7
+
8
+ # `source:` accepts either a `String` (eager) or a `Proc` returning one
9
+ # (lazy). The lazy form lets a companion gem call `register_polyfill`
10
+ # at require time without paying the file-read cost unless a VM
11
+ # actually opts into the feature.
12
+ def self.register_polyfill(name, source:, init: nil)
13
+ raise ::TypeError, "name must be a Symbol, got #{name.class}" unless name.is_a?(Symbol)
14
+ raise ::TypeError, "source: must be a String or Proc, got #{source.class}" unless source.is_a?(String) || source.is_a?(Proc)
15
+ raise ::TypeError, "init: must be a String or nil, got #{init.class}" unless init.nil? || init.is_a?(String)
16
+
17
+ @_polyfills[name] = {source: source, init: init&.freeze, bytecode: nil}
18
+ nil
19
+ end
20
+
21
+ def self._polyfill_for(name)
22
+ @_polyfills[name]
23
+ end
24
+
25
+ def self._unregister_polyfill(name)
26
+ @_polyfills.delete(name)
27
+ nil
28
+ end
29
+
30
+ def self._apply_registered_polyfills(vm, features)
31
+ features.each do |feature|
32
+ next unless (entry = @_polyfills[feature])
33
+ # `||=` isn't atomic — `_precompile_polyfill` releases the GVL inside
34
+ # `Quickjs.compile`, so two threads racing to construct VMs with the
35
+ # same polyfill can both see nil and both compile. The bytecode write
36
+ # is harmless because both threads produce identical bytes; the only
37
+ # observable cost is wasted compile work, and (for `source: Proc`) a
38
+ # second Proc invocation — so register Procs that are safe to call
39
+ # more than once.
40
+ entry[:bytecode] ||= _precompile_polyfill(entry, feature)
41
+ vm.send(:_load_polyfill_bytecode, entry[:bytecode])
42
+ end
43
+ end
44
+
45
+ # Compiled once per process per polyfill on a disposable VM whose
46
+ # generous timeout covers parsing multi-MB bundles (FormatJS Intl is
47
+ # ~2 MB). The user's per-VM `timeout_msec` is for their own JS — it
48
+ # would otherwise interrupt our infrastructure on tight defaults.
49
+ # `features: []` skips applying any registered polyfills to the temp
50
+ # VM (no recursion / no wasted polyfill loads).
51
+ def self._precompile_polyfill(entry, feature)
52
+ source = entry[:source]
53
+ source = source.call if source.is_a?(Proc)
54
+ combined = entry[:init] ? "#{entry[:init]}\n#{source}" : source
55
+ Quickjs.compile(combined, filename: feature.to_s, timeout_msec: 60_000, features: []).to_s
56
+ end
57
+
58
+ module PolyfillLoader
59
+ def initialize(features: [], **opts)
60
+ super
61
+ Quickjs._apply_registered_polyfills(self, features)
62
+ end
63
+ end
64
+
65
+ # Guard against double-prepend if this file is reloaded (e.g. Rails dev).
66
+ VM.prepend(PolyfillLoader) unless VM.ancestors.include?(PolyfillLoader)
67
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quickjs
4
- VERSION = "0.17.0"
4
+ VERSION = "0.19.0.pre1"
5
5
  end
data/lib/quickjs.rb CHANGED
@@ -8,6 +8,10 @@ require_relative "quickjs/crypto_key"
8
8
  require_relative "quickjs/function"
9
9
  require_relative "quickjs/quickjsrb"
10
10
  require_relative "quickjs/runnable"
11
+ # Polyfills.rb defines Quickjs.register_polyfill; polyfills/intl.rb calls
12
+ # it at load time, so the order matters.
13
+ require_relative "quickjs/polyfills"
14
+ require_relative "quickjs/polyfills/intl"
11
15
 
12
16
  module Quickjs
13
17
  class Blob
@@ -23,12 +27,22 @@ module Quickjs
23
27
  eval_opts[:filename] = overwrite_opts.delete(:filename) if overwrite_opts.key?(:filename)
24
28
  eval_opts[:async] = overwrite_opts.delete(:async) if overwrite_opts.key?(:async)
25
29
  vm = Quickjs::VM.new(**overwrite_opts)
26
- res = vm.eval_code(code, **eval_opts)
27
- vm = nil
28
- res
30
+ vm.eval_code(code, **eval_opts)
31
+ ensure
32
+ vm&.dispose!
29
33
  end
30
34
  module_function :eval_code
31
35
 
36
+ def compile(source, **opts)
37
+ compile_opts = {}
38
+ compile_opts[:filename] = opts.delete(:filename) if opts.key?(:filename)
39
+ vm = Quickjs::VM.new(**opts)
40
+ vm.compile(source, **compile_opts)
41
+ ensure
42
+ vm&.dispose!
43
+ end
44
+ module_function :compile
45
+
32
46
  def _with_timeout(msec, proc, args)
33
47
  Timeout.timeout(msec / 1_000.0) { proc.call(*args) }
34
48
  rescue Timeout::Error
@@ -43,12 +57,16 @@ module Quickjs
43
57
  when Quickjs::VM
44
58
  yield on
45
59
  when nil
46
- yield Quickjs::VM.new
60
+ vm = Quickjs::VM.new
61
+ yield vm
47
62
  when Hash
48
- yield Quickjs::VM.new(**on)
63
+ vm = Quickjs::VM.new(**on)
64
+ yield vm
49
65
  else
50
66
  raise ArgumentError, 'on: must be a Quickjs::VM, a Hash of VM options, or nil'
51
67
  end
68
+ ensure
69
+ vm&.dispose!
52
70
  end
53
71
  module_function :_with_vm
54
72
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "quickjs-rb-polyfills",
3
- "version": "0.17.0",
3
+ "version": "0.19.0.pre1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "quickjs-rb-polyfills",
9
- "version": "0.17.0",
9
+ "version": "0.19.0.pre1",
10
10
  "dependencies": {
11
11
  "@formatjs/intl-datetimeformat": "^7.3.1",
12
12
  "@formatjs/intl-getcanonicallocales": "^3.2.2",
@@ -53,79 +53,79 @@
53
53
  }
54
54
  },
55
55
  "node_modules/@formatjs/bigdecimal": {
56
- "version": "0.2.3",
57
- "resolved": "https://registry.npmjs.org/@formatjs/bigdecimal/-/bigdecimal-0.2.3.tgz",
58
- "integrity": "sha512-d7LpumdsbHueHdlVMos2yROIumyisUJNlFAk3PpN/5YcnXhWnkYmeiaQnOjqmmGx8BbaphoIyaF2CPus3cownw==",
56
+ "version": "0.2.5",
57
+ "resolved": "https://registry.npmjs.org/@formatjs/bigdecimal/-/bigdecimal-0.2.5.tgz",
58
+ "integrity": "sha512-2XTKNrZRaCUyXK2976wfutqxMBuPO/S/zbJnQdysLI2Zy5mWPVNVEkE6tsTcSVWSE7DgO88t8DtBy+uf3I8bxg==",
59
59
  "license": "MIT"
60
60
  },
61
61
  "node_modules/@formatjs/fast-memoize": {
62
- "version": "3.1.4",
63
- "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-3.1.4.tgz",
64
- "integrity": "sha512-Lbke1aOrsygKKR09Ux0NrZgbTqpDmiwXOgzyDOJ8Owr1zd5qOKTauf62hH+Seeku3ju77rHWH9I5SfX2CN0vuA==",
62
+ "version": "3.1.5",
63
+ "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-3.1.5.tgz",
64
+ "integrity": "sha512-KLi3fan6WnCHmigd9pmEEN8Hid0v4wiFBW576M/d07KMWYecf1CvyMI3n34vCmHT4AoVqG2n702kiHbXjzZX2A==",
65
65
  "license": "MIT"
66
66
  },
67
67
  "node_modules/@formatjs/intl-datetimeformat": {
68
- "version": "7.4.2",
69
- "resolved": "https://registry.npmjs.org/@formatjs/intl-datetimeformat/-/intl-datetimeformat-7.4.2.tgz",
70
- "integrity": "sha512-BwIDaewiY/vyQ2Vud5mQ1QxswZfgFuSm9jfAXSqAlLea1173HPbOR/IeCm63OaaHNogDNbNDQuiaN/3b38yAnw==",
68
+ "version": "7.4.6",
69
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-datetimeformat/-/intl-datetimeformat-7.4.6.tgz",
70
+ "integrity": "sha512-2g2NXRc1Q4DpG4lls2ImDCWpEJyMJLJBbt08w8Gk6ACr6Y00jvKwMS9MWVNOWNoy3UQp1oGANC5/RDCBqiWhfg==",
71
71
  "license": "MIT",
72
72
  "dependencies": {
73
- "@formatjs/bigdecimal": "0.2.3",
74
- "@formatjs/intl-localematcher": "0.8.6"
73
+ "@formatjs/bigdecimal": "0.2.5",
74
+ "@formatjs/intl-localematcher": "0.8.8"
75
75
  }
76
76
  },
77
77
  "node_modules/@formatjs/intl-getcanonicallocales": {
78
- "version": "3.2.6",
79
- "resolved": "https://registry.npmjs.org/@formatjs/intl-getcanonicallocales/-/intl-getcanonicallocales-3.2.6.tgz",
80
- "integrity": "sha512-vHJthiNaPxUnIvzXUGcea770v4Hg2UEDVglusg9l8O7R0k/nJgzbre/pJidohkB0dt1uRcDPD+WwrpAir3hLwQ==",
78
+ "version": "3.2.9",
79
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-getcanonicallocales/-/intl-getcanonicallocales-3.2.9.tgz",
80
+ "integrity": "sha512-b1dLzhFSeccG5X1PY2KodVFRGd0p6tBPc7pRBJaW6A7+fMeZnwHOAJLkMsGNDyvM9XailkkstE4jzmNa1GVh5w==",
81
81
  "license": "MIT"
82
82
  },
83
83
  "node_modules/@formatjs/intl-locale": {
84
- "version": "5.3.5",
85
- "resolved": "https://registry.npmjs.org/@formatjs/intl-locale/-/intl-locale-5.3.5.tgz",
86
- "integrity": "sha512-IeDGhU2nTNTmJbA9aIBKDLjSg4q57LYnb8+d0q7uYXmDBndo4oNufq2t9R7A9eeWngJAysvR3T8AHvPtudk2gQ==",
84
+ "version": "5.3.8",
85
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-locale/-/intl-locale-5.3.8.tgz",
86
+ "integrity": "sha512-pJgqQlg4zFoyCiVMXlKPBWpY7fAxvsUiShNmB/l8BW2ZwmFMefMWCrDzgocSH9WR+Z3pkihfjh1XbalCZhXc1Q==",
87
87
  "license": "MIT",
88
88
  "dependencies": {
89
- "@formatjs/intl-getcanonicallocales": "3.2.6",
90
- "@formatjs/intl-supportedvaluesof": "2.3.4"
89
+ "@formatjs/intl-getcanonicallocales": "3.2.9",
90
+ "@formatjs/intl-supportedvaluesof": "2.3.7"
91
91
  }
92
92
  },
93
93
  "node_modules/@formatjs/intl-localematcher": {
94
- "version": "0.8.6",
95
- "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.8.6.tgz",
96
- "integrity": "sha512-AZRgUxj0q93lyF7Z5lFS85bLINXuBLX4R3tCKicO6fSWo6cvh9GQfoR3B1WlsqQwefZ1QORTivhInx7gM6HUzQ==",
94
+ "version": "0.8.8",
95
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.8.8.tgz",
96
+ "integrity": "sha512-pBr2hVKWvkHVnfXegW+53NT9U2uaVQCc+EgzLPCCwXqBA3nvM5fPbK9IcJlNjV+NMKGyZ2F3ZSG78iGdxAAqbA==",
97
97
  "license": "MIT",
98
98
  "dependencies": {
99
- "@formatjs/fast-memoize": "3.1.4"
99
+ "@formatjs/fast-memoize": "3.1.5"
100
100
  }
101
101
  },
102
102
  "node_modules/@formatjs/intl-numberformat": {
103
- "version": "9.3.5",
104
- "resolved": "https://registry.npmjs.org/@formatjs/intl-numberformat/-/intl-numberformat-9.3.5.tgz",
105
- "integrity": "sha512-XAA/ds53WpPM6R4Ui644ICbmj9846PvioWkOzQvX44OCOPtoh4fiiab3qWSD5a1FK/Oc0NA5Mey+/xz1pfRv3Q==",
103
+ "version": "9.3.9",
104
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-numberformat/-/intl-numberformat-9.3.9.tgz",
105
+ "integrity": "sha512-VV0fPzmoA7j4NCdZ3M7xQY0iRDOtKvM2+Wi1/wLN41yhqjDV3BAIPbAIyAa4ZuyyQHWNDY3J+TciBQl66o1qhg==",
106
106
  "license": "MIT",
107
107
  "dependencies": {
108
- "@formatjs/bigdecimal": "0.2.3",
109
- "@formatjs/intl-localematcher": "0.8.6"
108
+ "@formatjs/bigdecimal": "0.2.5",
109
+ "@formatjs/intl-localematcher": "0.8.8"
110
110
  }
111
111
  },
112
112
  "node_modules/@formatjs/intl-pluralrules": {
113
- "version": "6.3.5",
114
- "resolved": "https://registry.npmjs.org/@formatjs/intl-pluralrules/-/intl-pluralrules-6.3.5.tgz",
115
- "integrity": "sha512-E5Tv6pZL+OGhRqYo7QTzE0jj8Ym7O2HcIb0v7qQG/C70OQACZ5ha7cksI2ZqTouJ6blOAsmBauBFxkTFT7b55A==",
113
+ "version": "6.3.8",
114
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-pluralrules/-/intl-pluralrules-6.3.8.tgz",
115
+ "integrity": "sha512-v51wZCnKNoFkQH8WhjdY6MCzySk80ppZ/qExBCdm0eiM/xMoIE0VgiTKcv0NOnE7V8+yML68LLnjZmxiPq1aZw==",
116
116
  "license": "MIT",
117
117
  "dependencies": {
118
- "@formatjs/bigdecimal": "0.2.3",
119
- "@formatjs/intl-localematcher": "0.8.6"
118
+ "@formatjs/bigdecimal": "0.2.5",
119
+ "@formatjs/intl-localematcher": "0.8.8"
120
120
  }
121
121
  },
122
122
  "node_modules/@formatjs/intl-supportedvaluesof": {
123
- "version": "2.3.4",
124
- "resolved": "https://registry.npmjs.org/@formatjs/intl-supportedvaluesof/-/intl-supportedvaluesof-2.3.4.tgz",
125
- "integrity": "sha512-oexqyYumVuwk4Gxm5LNaDOcUV/iHgGNaMc7zzYZaZsegAUPNlTTjwM0swnYyczmzz4Vor43boG5SYt+MbvKWng==",
123
+ "version": "2.3.7",
124
+ "resolved": "https://registry.npmjs.org/@formatjs/intl-supportedvaluesof/-/intl-supportedvaluesof-2.3.7.tgz",
125
+ "integrity": "sha512-ZTXEKijV5H08z19odngZPsXlmGndfukHuVnjd9qyER77XSk/yJwDMiSjoJYY5C5WxFs2UN4s/EMtu75e6Tp3ug==",
126
126
  "license": "MIT",
127
127
  "dependencies": {
128
- "@formatjs/fast-memoize": "3.1.4"
128
+ "@formatjs/fast-memoize": "3.1.5"
129
129
  }
130
130
  },
131
131
  "node_modules/@napi-rs/wasm-runtime": {
@@ -148,9 +148,9 @@
148
148
  }
149
149
  },
150
150
  "node_modules/@oxc-project/types": {
151
- "version": "0.129.0",
152
- "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.129.0.tgz",
153
- "integrity": "sha512-3oz8m3FGdr2nDXVqmFUw7jolKliC4MoyXYIG2c7gpjBnzUWQpUGIYcXYKxTdTi+N2jusvt610ckTMkxdwHkYEg==",
151
+ "version": "0.132.0",
152
+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.132.0.tgz",
153
+ "integrity": "sha512-FESMOxil5Se014ui/Eq8fT5uHJo6nIRwH0PfJrZJXs6Gek3ZVFOrpUv3YIZT20m+extU98Hg1Ym72U58rlsxUQ==",
154
154
  "dev": true,
155
155
  "license": "MIT",
156
156
  "funding": {
@@ -158,9 +158,9 @@
158
158
  }
159
159
  },
160
160
  "node_modules/@rolldown/binding-android-arm64": {
161
- "version": "1.0.0",
162
- "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0.tgz",
163
- "integrity": "sha512-TWMZnRLMe63C2Lhyicviu7ZHaU4kxa6PS3rofvc9GmcvptzNN11BcfQ4Sl7MwTOsisQoa2keB/EBdNCAnUo8vA==",
161
+ "version": "1.0.2",
162
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.2.tgz",
163
+ "integrity": "sha512-ZS4D1JPGn/MYQN/SYDWftIE/nVsM8j/AFOYEzAoOE2O3NktQOZru+/vYXGbR/qtdLdIfGCP0lcoJiYVzsEz+iQ==",
164
164
  "cpu": [
165
165
  "arm64"
166
166
  ],
@@ -175,9 +175,9 @@
175
175
  }
176
176
  },
177
177
  "node_modules/@rolldown/binding-darwin-arm64": {
178
- "version": "1.0.0",
179
- "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0.tgz",
180
- "integrity": "sha512-6XcD+8k0gPVItNagEw78/qqcBDwKcwDYS8V2hRmVsfUSIrd8cWe/CBvRDI5toqFyPfj+FJr6t8U6Xj2P2prEew==",
178
+ "version": "1.0.2",
179
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.2.tgz",
180
+ "integrity": "sha512-vdFA9+C/rekyGce7WqHs/xoT0ioZEWaOFyZLIV1mEeNFaFDUQrPIo8Vs2GvJ6eetb3rzDUtUBgzto3ExpXJB3w==",
181
181
  "cpu": [
182
182
  "arm64"
183
183
  ],
@@ -192,9 +192,9 @@
192
192
  }
193
193
  },
194
194
  "node_modules/@rolldown/binding-darwin-x64": {
195
- "version": "1.0.0",
196
- "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0.tgz",
197
- "integrity": "sha512-iN/tWVXRQDWvmZlKdceP1Dwug9GDpEymhb9p4xnEe6zvCg5lFmzVljl+1qR1NVx3yfGpr2Na+CuLmv5IU8uzfQ==",
195
+ "version": "1.0.2",
196
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.2.tgz",
197
+ "integrity": "sha512-BewSOwTHazv77DTYiAZXSqqKZ4KP/KonFisDMVU7PImxoWfB2aepnPhd2E4SWz3zDzYgDNbs6jBmTdgNnF02GA==",
198
198
  "cpu": [
199
199
  "x64"
200
200
  ],
@@ -209,9 +209,9 @@
209
209
  }
210
210
  },
211
211
  "node_modules/@rolldown/binding-freebsd-x64": {
212
- "version": "1.0.0",
213
- "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0.tgz",
214
- "integrity": "sha512-jjQMDvvwSOuhOwMszD/klSOjyWMM3zI64hWTj9KT5x4MxRbZAf+7vLQ6qouRhtsLVFHr3f0ILaJAfgENPiQdAQ==",
212
+ "version": "1.0.2",
213
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.2.tgz",
214
+ "integrity": "sha512-m41o7M0YWtUdqk61Tb+jnKb2rN++iRdIASlExkUoKfIAH30DOHCB8fVLzSUpbWHHU8esmEioY62PxzexE8MBuA==",
215
215
  "cpu": [
216
216
  "x64"
217
217
  ],
@@ -226,9 +226,9 @@
226
226
  }
227
227
  },
228
228
  "node_modules/@rolldown/binding-linux-arm-gnueabihf": {
229
- "version": "1.0.0",
230
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0.tgz",
231
- "integrity": "sha512-d//Dtg2x6/m3mbV64yUGNnDGNZaDGRpDLLNGerHQUVObuNaIQaaDp25yUiqGXtHEXX+NP2d0wAlmKgpYgIAJ2A==",
229
+ "version": "1.0.2",
230
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.2.tgz",
231
+ "integrity": "sha512-jcojB9H7W/jS29pMKWAK1N+fU99vXodHDTatS3b3y/XSOCiHo0kkA74pL3jJmkoQtYpOCxDvaKs1fo2Ij/1X5w==",
232
232
  "cpu": [
233
233
  "arm"
234
234
  ],
@@ -243,9 +243,9 @@
243
243
  }
244
244
  },
245
245
  "node_modules/@rolldown/binding-linux-arm64-gnu": {
246
- "version": "1.0.0",
247
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0.tgz",
248
- "integrity": "sha512-n7Ofp0mx+aB2cC+Sdy5YtMnXtY9lchnHbY+3Yt0uq9JsWQExf4f5Whu0tK0R8Jdc9S6RchTHjIFY7uc92puOVQ==",
246
+ "version": "1.0.2",
247
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.2.tgz",
248
+ "integrity": "sha512-1jn6qDU5iiOgFgygDzKUuKP0maTi0/f1+sBLgvij/76C77Nm3ts6ufz9Bjg5q5dduxiUIxtq86JIoBvo1xQ4Ig==",
249
249
  "cpu": [
250
250
  "arm64"
251
251
  ],
@@ -260,9 +260,9 @@
260
260
  }
261
261
  },
262
262
  "node_modules/@rolldown/binding-linux-arm64-musl": {
263
- "version": "1.0.0",
264
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0.tgz",
265
- "integrity": "sha512-EIVjy2cgd7uuMMo94FVkBp7F6DhcZAUwNURkSG3RwUmvAXR6s0ISxM81U+IydcZByPG0pZIHsf1b6kTxoFDgJA==",
263
+ "version": "1.0.2",
264
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.2.tgz",
265
+ "integrity": "sha512-QVLO/czFMdoMFSqlX3bcswcJNm/23r+qoa/jgtmFc/qEp6/jXmIkDjF/XIo8dPfGaiwy1xfQn8o77L79GeXFgw==",
266
266
  "cpu": [
267
267
  "arm64"
268
268
  ],
@@ -277,9 +277,9 @@
277
277
  }
278
278
  },
279
279
  "node_modules/@rolldown/binding-linux-ppc64-gnu": {
280
- "version": "1.0.0",
281
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0.tgz",
282
- "integrity": "sha512-JEwwOPcwTLAcpDQlqSmjEmfs63xJnSiUNIGvLcDLUHCWK4XowpS/7c7tUsUH6uT/ct6bMUTdXKfI8967FYj6mg==",
280
+ "version": "1.0.2",
281
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.2.tgz",
282
+ "integrity": "sha512-hgO5Abm0w5UL6FEa2iFnZqo2KlK7TQ5QhV5x09hujBf7t5KzHQ1VmfPuTpqRy/rNlSxua3eWH374xxiVrP+lcA==",
283
283
  "cpu": [
284
284
  "ppc64"
285
285
  ],
@@ -294,9 +294,9 @@
294
294
  }
295
295
  },
296
296
  "node_modules/@rolldown/binding-linux-s390x-gnu": {
297
- "version": "1.0.0",
298
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0.tgz",
299
- "integrity": "sha512-0wjCFhLrihtAubnT9iA0N++0pSV0z5Hg7tNGdNJ4RFaINceHadoF+kiFGyY1qSSNVIAZtLotG8Ju1bgDPkjnFA==",
297
+ "version": "1.0.2",
298
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.2.tgz",
299
+ "integrity": "sha512-fy8rXxuYEu602abC8MUNaPjYLIFzReOaEIEMKMUa0rFEUxNpVXhs15KSSQ4qlqSaM7B6rcj9rDZgADh/IGDzLQ==",
300
300
  "cpu": [
301
301
  "s390x"
302
302
  ],
@@ -311,9 +311,9 @@
311
311
  }
312
312
  },
313
313
  "node_modules/@rolldown/binding-linux-x64-gnu": {
314
- "version": "1.0.0",
315
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0.tgz",
316
- "integrity": "sha512-Dfn7iak9BcMMePxcoJfpSbWqnEyrp/dRF63/8qW/eHBdOZov6x5aShLLEYGYdIeSJ6vMLK/XCVB+lGIxm41bQA==",
314
+ "version": "1.0.2",
315
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.2.tgz",
316
+ "integrity": "sha512-0+bOkiQ779+r1WpoHOWHqncvyySci0vKph+myNDYb+im6meJAzHQXay6oEgnkHuUGouM1LKTZwqKpBow6Kj7CQ==",
317
317
  "cpu": [
318
318
  "x64"
319
319
  ],
@@ -328,9 +328,9 @@
328
328
  }
329
329
  },
330
330
  "node_modules/@rolldown/binding-linux-x64-musl": {
331
- "version": "1.0.0",
332
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0.tgz",
333
- "integrity": "sha512-5/utzzDmD/pD/bmuaUcbTf/sZYy0aztwIVlfpoW1fTjCZ0BaPOMVWGZL1zvgxyi7ZIVYWlxKONHmSbHuiOh8Jw==",
331
+ "version": "1.0.2",
332
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.2.tgz",
333
+ "integrity": "sha512-mjSkrzZK5Qsl0a9d1JgILOiuZOSDTVdKENcSXBoqbzSrspLR/4/IRVDo5wd2GgZjNss/viBFJdeq+j7qH2nypw==",
334
334
  "cpu": [
335
335
  "x64"
336
336
  ],
@@ -345,9 +345,9 @@
345
345
  }
346
346
  },
347
347
  "node_modules/@rolldown/binding-openharmony-arm64": {
348
- "version": "1.0.0",
349
- "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0.tgz",
350
- "integrity": "sha512-ouJs8VcUomfLfpbUECqFMRqdV4x6aeAK3MA4m6vTrJJjKyWTV5KnxZx7Jd9G+GlDaQQxubcba00x16OyJ1meig==",
348
+ "version": "1.0.2",
349
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.2.tgz",
350
+ "integrity": "sha512-1v5vHasdfQAZoEHakBV72LIFAC9JjnymsiKxp+GEr/ma3+NJCPSaYK+qavInOovJkgwFrs7GccX2d6IgDA3Z5w==",
351
351
  "cpu": [
352
352
  "arm64"
353
353
  ],
@@ -362,9 +362,9 @@
362
362
  }
363
363
  },
364
364
  "node_modules/@rolldown/binding-wasm32-wasi": {
365
- "version": "1.0.0",
366
- "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0.tgz",
367
- "integrity": "sha512-E+oHKGiDA+lsKMmFtffDDw91EryDT7uJocrIuCHqhm6bCTM6xFK+3gaCkYOHfPwQr0cCNarSM2xaELoQDz9jJg==",
365
+ "version": "1.0.2",
366
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.2.tgz",
367
+ "integrity": "sha512-mb1VobWn6NheziTk5/WEaR6AKVbrwT5sOi6C7zk3gy/pD1qtJfU1j4PgTo2NJnOtbL9Dl3Aeei8w9jJ7qC2jZQ==",
368
368
  "cpu": [
369
369
  "wasm32"
370
370
  ],
@@ -381,9 +381,9 @@
381
381
  }
382
382
  },
383
383
  "node_modules/@rolldown/binding-win32-arm64-msvc": {
384
- "version": "1.0.0",
385
- "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0.tgz",
386
- "integrity": "sha512-yYK02n8Rngo+gbm1y6G0+7jk1sJ/2Wt7K0me0Y7k/ErBpyf+LJ2gFpqWVTcRV1rUepBlQRmpgWkTQCiiwrK0Ow==",
384
+ "version": "1.0.2",
385
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.2.tgz",
386
+ "integrity": "sha512-SqKonF56vA/L2yHwHYcEp2P34URpOZ7d1fS635cTkpDnUtEGdUbhI6NzsPdqeSWvAAeGDrxjWjNmibDIdFf9/A==",
387
387
  "cpu": [
388
388
  "arm64"
389
389
  ],
@@ -398,9 +398,9 @@
398
398
  }
399
399
  },
400
400
  "node_modules/@rolldown/binding-win32-x64-msvc": {
401
- "version": "1.0.0",
402
- "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0.tgz",
403
- "integrity": "sha512-14bpChMahXRRXiTwahSl+zzHPW6qQTXtkMuJBFlbo+pqSAews2d4BdCSHfrJ/MBsCZtpmTafsY+1QhBzitcmdg==",
401
+ "version": "1.0.2",
402
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.2.tgz",
403
+ "integrity": "sha512-v7qRI7gXLRINcOGXt+7YmAZ6iFuyZVMIoXAxhd8oP+DR9dLfL9GfNIx7PLMxmhZdvq8waUJBQiWN9EKNy+TRBQ==",
404
404
  "cpu": [
405
405
  "x64"
406
406
  ],
@@ -415,9 +415,9 @@
415
415
  }
416
416
  },
417
417
  "node_modules/@rolldown/pluginutils": {
418
- "version": "1.0.0",
419
- "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0.tgz",
420
- "integrity": "sha512-aKs/3GSWyV0mrhNmt/96/Z3yczC3yvrzYATCiCXQebBsGyYzjNdUphRVLeJQ67ySKVXRfMxt2lm12pmXvbPFQQ==",
418
+ "version": "1.0.1",
419
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
420
+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
421
421
  "dev": true,
422
422
  "license": "MIT"
423
423
  },
@@ -433,14 +433,14 @@
433
433
  }
434
434
  },
435
435
  "node_modules/rolldown": {
436
- "version": "1.0.0",
437
- "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0.tgz",
438
- "integrity": "sha512-yD986aXDESFGS95spT1LAv0jssywP4npMEjmMHyN2/5+eE8qQJUype2AaKkRiLgBgyD0LFlubwAht7VmY8rGoA==",
436
+ "version": "1.0.2",
437
+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.2.tgz",
438
+ "integrity": "sha512-oZx5zVDtVB44AW3eaifgDml1gWRDZGvjcfdxonE4swNPG98PrrXjaO/KrnUjzlMnztCCRVlUueA1kCXhARGk6g==",
439
439
  "dev": true,
440
440
  "license": "MIT",
441
441
  "dependencies": {
442
- "@oxc-project/types": "=0.129.0",
443
- "@rolldown/pluginutils": "1.0.0"
442
+ "@oxc-project/types": "=0.132.0",
443
+ "@rolldown/pluginutils": "^1.0.0"
444
444
  },
445
445
  "bin": {
446
446
  "rolldown": "bin/cli.mjs"
@@ -449,21 +449,21 @@
449
449
  "node": "^20.19.0 || >=22.12.0"
450
450
  },
451
451
  "optionalDependencies": {
452
- "@rolldown/binding-android-arm64": "1.0.0",
453
- "@rolldown/binding-darwin-arm64": "1.0.0",
454
- "@rolldown/binding-darwin-x64": "1.0.0",
455
- "@rolldown/binding-freebsd-x64": "1.0.0",
456
- "@rolldown/binding-linux-arm-gnueabihf": "1.0.0",
457
- "@rolldown/binding-linux-arm64-gnu": "1.0.0",
458
- "@rolldown/binding-linux-arm64-musl": "1.0.0",
459
- "@rolldown/binding-linux-ppc64-gnu": "1.0.0",
460
- "@rolldown/binding-linux-s390x-gnu": "1.0.0",
461
- "@rolldown/binding-linux-x64-gnu": "1.0.0",
462
- "@rolldown/binding-linux-x64-musl": "1.0.0",
463
- "@rolldown/binding-openharmony-arm64": "1.0.0",
464
- "@rolldown/binding-wasm32-wasi": "1.0.0",
465
- "@rolldown/binding-win32-arm64-msvc": "1.0.0",
466
- "@rolldown/binding-win32-x64-msvc": "1.0.0"
452
+ "@rolldown/binding-android-arm64": "1.0.2",
453
+ "@rolldown/binding-darwin-arm64": "1.0.2",
454
+ "@rolldown/binding-darwin-x64": "1.0.2",
455
+ "@rolldown/binding-freebsd-x64": "1.0.2",
456
+ "@rolldown/binding-linux-arm-gnueabihf": "1.0.2",
457
+ "@rolldown/binding-linux-arm64-gnu": "1.0.2",
458
+ "@rolldown/binding-linux-arm64-musl": "1.0.2",
459
+ "@rolldown/binding-linux-ppc64-gnu": "1.0.2",
460
+ "@rolldown/binding-linux-s390x-gnu": "1.0.2",
461
+ "@rolldown/binding-linux-x64-gnu": "1.0.2",
462
+ "@rolldown/binding-linux-x64-musl": "1.0.2",
463
+ "@rolldown/binding-openharmony-arm64": "1.0.2",
464
+ "@rolldown/binding-wasm32-wasi": "1.0.2",
465
+ "@rolldown/binding-win32-arm64-msvc": "1.0.2",
466
+ "@rolldown/binding-win32-x64-msvc": "1.0.2"
467
467
  }
468
468
  },
469
469
  "node_modules/tslib": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickjs-rb-polyfills",
3
- "version": "0.17.0",
3
+ "version": "0.19.0.pre1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "build": "rolldown -c rolldown.config.mjs",
@@ -4,7 +4,10 @@ export default [
4
4
  defineConfig({
5
5
  input: "src/intl-en.js",
6
6
  output: {
7
- file: "../ext/quickjsrb/vendor/polyfill-intl-en.min.js",
7
+ // Loaded at runtime by lib/quickjs/polyfills/intl.rb via
8
+ // Quickjs.register_polyfill; other entries are still embedded as
9
+ // pre-compiled bytecode in the .so until they go the same way.
10
+ file: "../lib/quickjs/polyfills/intl-en.min.js",
8
11
  format: "iife",
9
12
  minify: true,
10
13
  },
data/sig/quickjs.rbs CHANGED
@@ -12,6 +12,9 @@ module Quickjs
12
12
  POLYFILL_CRYPTO: Symbol
13
13
 
14
14
  def self.eval_code: (String code, ?Hash[Symbol, untyped] overwrite_opts) -> untyped
15
+ def self.compile: (String source, ?filename: String, **untyped) -> Quickjs::Runnable
16
+
17
+ def self.register_polyfill: (Symbol name, source: String | ^() -> String, ?init: String?) -> nil
15
18
 
16
19
  class Value
17
20
  UNDEFINED: Symbol
@@ -33,9 +36,14 @@ module Quickjs
33
36
  def import: (String | Array[String] | Hash[Symbol, String] imported, from: String, ?code_to_expose: String?) -> true
34
37
  | (String | Array[String] | Hash[Symbol, String] imported, filename: String, ?code_to_expose: String?) -> true
35
38
 
36
- def module_loader: () -> (^(String) -> String? | nil)
39
+ type module_loader_return = String | Hash[Symbol, String] | nil
40
+ type module_loader_proc = ^(String, String) -> module_loader_return | ^(String) -> module_loader_return
41
+
42
+ def module_loader: () -> (module_loader_proc | nil)
43
+
44
+ def module_loader=: (module_loader_proc | nil) -> (module_loader_proc | nil)
37
45
 
38
- def module_loader=: (^(String) -> String? | nil) -> (^(String) -> String? | nil)
46
+ def on_unhandled_rejection: () { (Quickjs::RuntimeError) -> void } -> nil
39
47
 
40
48
  def on_log: () { (Log) -> void } -> nil
41
49
 
@@ -45,6 +53,12 @@ module Quickjs
45
53
 
46
54
  def memory_poisoned?: () -> bool
47
55
 
56
+ def dispose!: () -> nil
57
+
58
+ def disposed?: () -> bool
59
+
60
+ def drain_jobs!: () -> Integer
61
+
48
62
  class Log
49
63
  attr_reader severity: Symbol
50
64
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.19.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hmsk
@@ -86,11 +86,13 @@ files:
86
86
  - ext/quickjsrb/quickjsrb_file.h
87
87
  - ext/quickjsrb/vendor/polyfill-encoding.min.js
88
88
  - ext/quickjsrb/vendor/polyfill-file.min.js
89
- - ext/quickjsrb/vendor/polyfill-intl-en.min.js
90
89
  - ext/quickjsrb/vendor/polyfill-url.min.js
91
90
  - lib/quickjs.rb
92
91
  - lib/quickjs/crypto_key.rb
93
92
  - lib/quickjs/function.rb
93
+ - lib/quickjs/polyfills.rb
94
+ - lib/quickjs/polyfills/intl-en.min.js
95
+ - lib/quickjs/polyfills/intl.rb
94
96
  - lib/quickjs/runnable.rb
95
97
  - lib/quickjs/subtle_crypto.rb
96
98
  - lib/quickjs/version.rb