quickjs 0.13.0 → 0.15.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/README.md +32 -2
- data/Rakefile +7 -0
- data/ext/quickjsrb/extconf.rb +8 -2
- data/ext/quickjsrb/quickjsrb.c +389 -65
- data/ext/quickjsrb/quickjsrb.h +6 -4
- data/ext/quickjsrb/quickjsrb_crypto.c +71 -0
- data/ext/quickjsrb/quickjsrb_crypto.h +6 -0
- data/ext/quickjsrb/quickjsrb_crypto_subtle.c +1001 -0
- data/ext/quickjsrb/quickjsrb_crypto_subtle.h +6 -0
- data/ext/quickjsrb/vendor/polyfill-intl-en.min.js +3 -11
- data/ext/quickjsrb/vendor/polyfill-url.min.js +1 -0
- data/lib/quickjs/crypto_key.rb +15 -0
- data/lib/quickjs/function.rb +36 -0
- data/lib/quickjs/subtle_crypto.rb +493 -0
- data/lib/quickjs/version.rb +1 -1
- data/lib/quickjs.rb +4 -0
- data/polyfills/check-licenses.mjs +72 -0
- data/polyfills/package-lock.json +183 -154
- data/polyfills/package.json +9 -8
- data/polyfills/rolldown.config.mjs +8 -0
- data/polyfills/src/url.js +1089 -0
- data/sig/quickjs.rbs +15 -1
- metadata +12 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e13c4664328e497bb8c2179807e8c110c4709b6df84a9a60f888e5a822075de2
|
|
4
|
+
data.tar.gz: c43d43f3c0b928798545ecf57bf9956df1912e3867220915dd5b13c8aeb0031f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 581463e6df8d5559f9aa1f91e4512b68f745942d771b2246202d3137a378876c6662db800381abd4dc065b4a6a8acb03f247feda4b78aa9ce1fc31cdd6ed6836
|
|
7
|
+
data.tar.gz: cd4f64a7d98a75c5e388b99e1cdbd44c6ad4cfc4cd96f8e23259f12aa8cbe18f8c580ad41633cb65c9f77a6f9732fbb6e042b6805cc034a0c4c060f4ecdb3635
|
data/README.md
CHANGED
|
@@ -61,6 +61,8 @@ Quickjs.eval_code(code, features: [::Quickjs::MODULE_STD, ::Quickjs::POLYFILL_FI
|
|
|
61
61
|
| `POLYFILL_INTL` | Intl API (DateTimeFormat, NumberFormat, PluralRules, Locale) |
|
|
62
62
|
| `POLYFILL_FILE` | W3C File API (Blob and File) |
|
|
63
63
|
| `POLYFILL_ENCODING` | Encoding API (TextEncoder and TextDecoder) |
|
|
64
|
+
| `POLYFILL_URL` | URL API (URL and URLSearchParams) |
|
|
65
|
+
| `POLYFILL_CRYPTO` | Web Crypto API (`crypto.getRandomValues`, `crypto.randomUUID`, `crypto.subtle`); combine with `POLYFILL_ENCODING` for string↔buffer conversion |
|
|
64
66
|
|
|
65
67
|
</details>
|
|
66
68
|
|
|
@@ -76,6 +78,29 @@ vm.eval_code('a.b = "d";')
|
|
|
76
78
|
vm.eval_code('a.b;') #=> "d"
|
|
77
79
|
```
|
|
78
80
|
|
|
81
|
+
#### `Quickjs::VM#call`: ⚡ Call a JS function directly with Ruby arguments
|
|
82
|
+
|
|
83
|
+
```rb
|
|
84
|
+
vm = Quickjs::VM.new
|
|
85
|
+
vm.eval_code('function add(a, b) { return a + b; }')
|
|
86
|
+
|
|
87
|
+
vm.call('add', 1, 2) #=> 3
|
|
88
|
+
vm.call(:add, 1, 2) #=> 3 (Symbol also works)
|
|
89
|
+
|
|
90
|
+
# Nested functions — preserves `this` binding
|
|
91
|
+
vm.eval_code('const counter = { n: 0, inc() { return ++this.n; } }')
|
|
92
|
+
vm.call('counter.inc') #=> 1
|
|
93
|
+
vm.call('counter.inc') #=> 2
|
|
94
|
+
|
|
95
|
+
# Keys with special characters via bracket notation
|
|
96
|
+
vm.eval_code("const obj = {}; obj['my-fn'] = x => x * 2;")
|
|
97
|
+
vm.call('obj["my-fn"]', 21) #=> 42
|
|
98
|
+
|
|
99
|
+
# Async functions are automatically awaited
|
|
100
|
+
vm.eval_code('async function fetchVal() { return 42; }')
|
|
101
|
+
vm.call('fetchVal') #=> 42
|
|
102
|
+
```
|
|
103
|
+
|
|
79
104
|
#### `Quickjs::VM#import`: 🔌 Import ESM from a source code
|
|
80
105
|
|
|
81
106
|
```rb
|
|
@@ -165,13 +190,18 @@ vm.eval_code('console.log("hello", 42)')
|
|
|
165
190
|
- `ext/quickjsrb/quickjs`
|
|
166
191
|
- [MIT License Copyright (c) 2017-2021 by Fabrice Bellard and Charlie Gordon](https://github.com/bellard/quickjs/blob/6e2e68fd0896957f92eb6c242a2e048c1ef3cae0/LICENSE).
|
|
167
192
|
- `ext/quickjsrb/vendor/polyfill-intl-en.min.js` ([bundled and minified from `polyfills/`](https://github.com/hmsk/quickjs.rb/tree/main/polyfills))
|
|
193
|
+
- MIT License Copyright (c) 2022 FormatJS
|
|
194
|
+
- [@formatjs/intl-supportedvaluesof](https://github.com/formatjs/formatjs/blob/main/packages/intl-supportedvaluesof/LICENSE.md)
|
|
168
195
|
- MIT License Copyright (c) 2023 FormatJS
|
|
169
196
|
- [@formatjs/intl-getcanonicallocales](https://github.com/formatjs/formatjs/blob/main/packages/intl-getcanonicallocales/LICENSE.md)
|
|
170
197
|
- [@formatjs/intl-locale](https://github.com/formatjs/formatjs/blob/main/packages/intl-locale/LICENSE.md)
|
|
171
198
|
- [@formatjs/intl-pluralrules](https://github.com/formatjs/formatjs/blob/main/packages/intl-pluralrules/LICENSE.md)
|
|
172
199
|
- [@formatjs/intl-numberformat](https://github.com/formatjs/formatjs/blob/main/packages/intl-numberformat/LICENSE.md)
|
|
173
200
|
- [@formatjs/intl-datetimeformat](https://github.com/formatjs/formatjs/blob/main/packages/intl-datetimeformat/LICENSE.md)
|
|
174
|
-
|
|
175
|
-
- [
|
|
201
|
+
- [@formatjs/ecma402-abstract](https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/LICENSE.md)
|
|
202
|
+
- [@formatjs/fast-memoize](https://github.com/formatjs/formatjs/blob/main/packages/fast-memoize/LICENSE.md)
|
|
203
|
+
- [@formatjs/intl-localematcher](https://github.com/formatjs/formatjs/blob/main/packages/intl-localematcher/LICENSE.md)
|
|
204
|
+
- MIT License Copyright (c) 2026 FormatJS
|
|
205
|
+
- [@formatjs/bigdecimal](https://github.com/formatjs/formatjs/blob/main/packages/bigdecimal/LICENSE.md)
|
|
176
206
|
|
|
177
207
|
Otherwise, [the MIT License, Copyright 2024 by Kengo Hamasaki](/LICENSE).
|
data/Rakefile
CHANGED
|
@@ -54,6 +54,13 @@ namespace :polyfills do
|
|
|
54
54
|
Rake::Task[:compile].invoke
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
desc 'Check licenses of bundled polyfill dependencies'
|
|
58
|
+
task :check_licenses do
|
|
59
|
+
Dir.chdir(File.expand_path('polyfills', __dir__)) do
|
|
60
|
+
sh 'npm run check-licenses'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
57
64
|
namespace :version do
|
|
58
65
|
task :check do
|
|
59
66
|
check_polyfill_version! do |pkg_v, gem_v|
|
data/ext/quickjsrb/extconf.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'mkmf'
|
|
4
4
|
|
|
5
5
|
$VPATH << "$(srcdir)/quickjs"
|
|
6
|
+
$INCFLAGS << " -I$(srcdir)/quickjs"
|
|
6
7
|
|
|
7
8
|
$srcs = [
|
|
8
9
|
'dtoa.c',
|
|
@@ -14,12 +15,13 @@ $srcs = [
|
|
|
14
15
|
'polyfill-intl-en.min.c',
|
|
15
16
|
'polyfill-file.min.c',
|
|
16
17
|
'polyfill-encoding.min.c',
|
|
18
|
+
'polyfill-url.min.c',
|
|
17
19
|
'quickjsrb.c',
|
|
18
20
|
'quickjsrb_file.c',
|
|
21
|
+
'quickjsrb_crypto.c',
|
|
22
|
+
'quickjsrb_crypto_subtle.c',
|
|
19
23
|
]
|
|
20
24
|
|
|
21
|
-
append_cflags('-I$(srcdir)/quickjs')
|
|
22
|
-
|
|
23
25
|
append_cflags('-g')
|
|
24
26
|
append_cflags('-O2')
|
|
25
27
|
append_cflags('-Wall')
|
|
@@ -72,6 +74,10 @@ polyfill-encoding.min.js:
|
|
|
72
74
|
$(COPY) $(srcdir)/vendor/$@ $@
|
|
73
75
|
polyfill-encoding.min.c: ./qjsc polyfill-encoding.min.js
|
|
74
76
|
./qjsc -fno-string-normalize -fno-eval -fno-proxy -fno-module-loader -c -M polyfill/encoding.so,encoding -m -o $@ polyfill-encoding.min.js
|
|
77
|
+
polyfill-url.min.js:
|
|
78
|
+
$(COPY) $(srcdir)/vendor/$@ $@
|
|
79
|
+
polyfill-url.min.c: ./qjsc polyfill-url.min.js
|
|
80
|
+
./qjsc -fno-string-normalize -fno-eval -fno-proxy -fno-module-loader -c -M polyfill/url.so,url -m -o $@ polyfill-url.min.js
|
|
75
81
|
COMPILE_POLYFILL
|
|
76
82
|
conf
|
|
77
83
|
end
|