quickjs 0.17.0.pre → 0.17.0.rc1
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 +16 -0
- data/lib/quickjs/version.rb +1 -1
- data/polyfills/package-lock.json +2 -2
- data/polyfills/package.json +1 -1
- data/sig/quickjs.rbs +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bbf290b6ef28018eef7425f01ea25228bce86c9b7271bf2519d063ea1c6282c7
|
|
4
|
+
data.tar.gz: bc45a3945be7ac771d853611b1ee1ddc1d1c0f3316dd58646c89405d54006350
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98dd776d1e9a044e2fed7ebc88f22181cd77aacbb5751057ce468687c4afe5dea5b618943db6713d970cc64beb60cf4f4bde0119d43456cf95d074e8f75eef7b
|
|
7
|
+
data.tar.gz: 17539d15924130c531eb77694ae69a7db921495d675c6e6445045305187e6bef2122f22cd900c727de355ef96d5c0b03966c0ab7629aa0a09bf25b42d5382dc0
|
data/README.md
CHANGED
|
@@ -144,6 +144,22 @@ vm.import('DefaultExport', from: File.read('exports.esm.js'))
|
|
|
144
144
|
vm.import('* as all', from: File.read('exports.esm.js'))
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
+
By default each imported binding is attached to `globalThis` under its own name so later `eval_code` / `call` can see it. Pass `code_to_expose:` to replace that step with your own JS — useful for renaming, attaching the import somewhere other than `globalThis`, or skipping the global assignment entirely for side-effect-only imports.
|
|
148
|
+
|
|
149
|
+
```rb
|
|
150
|
+
# Rename on the way in
|
|
151
|
+
vm.import('Imported', from: File.read('exports.esm.js'),
|
|
152
|
+
code_to_expose: 'globalThis.RenamedImported = Imported;')
|
|
153
|
+
|
|
154
|
+
vm.eval_code('RenamedImported()') #=> calls the default export
|
|
155
|
+
vm.eval_code('!!globalThis.Imported') #=> false — the original name was never assigned
|
|
156
|
+
|
|
157
|
+
# Side-effect-only import: run the module body but don't expose anything
|
|
158
|
+
vm.import('initSomething', from: File.read('setup.esm.js'), code_to_expose: '')
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`code_to_expose` is just a JavaScript fragment that runs after the `import` statement, with the imported binding(s) in scope under the name(s) you requested. It works with both `from:` and `filename:`.
|
|
162
|
+
|
|
147
163
|
#### `Quickjs::VM#module_loader=`: 🧩 Resolve `import` specifiers from Ruby
|
|
148
164
|
|
|
149
165
|
By default, `import` specifiers that aren't already loaded fall through to QuickJS's filesystem loader. Set a `module_loader` Proc to resolve specifiers in-memory instead — useful when the source code lives in a database, an importmap, or a virtual filesystem.
|
data/lib/quickjs/version.rb
CHANGED
data/polyfills/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickjs-rb-polyfills",
|
|
3
|
-
"version": "0.17.0.
|
|
3
|
+
"version": "0.17.0.rc1",
|
|
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.17.0.rc1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@formatjs/intl-datetimeformat": "^7.3.1",
|
|
12
12
|
"@formatjs/intl-getcanonicallocales": "^3.2.2",
|
data/polyfills/package.json
CHANGED
data/sig/quickjs.rbs
CHANGED
|
@@ -31,7 +31,7 @@ module Quickjs
|
|
|
31
31
|
| (Array[String | Symbol] path, *Symbol flags) { (*untyped) -> untyped } -> Array[Symbol]
|
|
32
32
|
|
|
33
33
|
def import: (String | Array[String] | Hash[Symbol, String] imported, from: String, ?code_to_expose: String?) -> true
|
|
34
|
-
| (String | Array[String] | Hash[Symbol, String] imported, filename: String) -> true
|
|
34
|
+
| (String | Array[String] | Hash[Symbol, String] imported, filename: String, ?code_to_expose: String?) -> true
|
|
35
35
|
|
|
36
36
|
def module_loader: () -> (^(String) -> String? | nil)
|
|
37
37
|
|