quickjs 0.7.1 → 0.8.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 +4 -4
- data/ext/quickjsrb/quickjsrb.c +1 -16
- data/ext/quickjsrb/quickjsrb.h +2 -4
- data/lib/quickjs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dafb25d574a45620b440561078836c98c15d4bfbd262de5f18bf9f9eb8fc572e
|
4
|
+
data.tar.gz: 421c3d7ce93798a00a673d3cd15ee27c3fbdae62b4462d2b7100ad423d8d80e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0512949cf01227a5f924b9e04f199e8fc24bb486d854c6e72d08ba8cae4f52ba5490a3b205e9c02a39ed0b90d599f18c3e2e90f7aca9d59a755e4501a358cba2'
|
7
|
+
data.tar.gz: 95777d46e97ce2783593dd28f59beda26454f040741363a3f8190d65ce72ffe1874142f1983b7dd87dbbca99c0e37dfc5f01feb2e501a8b82bc538d3b7706371
|
data/README.md
CHANGED
@@ -58,8 +58,8 @@ vm = Quickjs.eval_code(features: [::Quickjs::MODULE_STD])
|
|
58
58
|
# Enable `os` module by quickjs: https://bellard.org/quickjs/quickjs.html#os-module
|
59
59
|
vm = Quickjs.eval_code(features: [::Quickjs::MODULE_OS])
|
60
60
|
|
61
|
-
#
|
62
|
-
vm = Quickjs.eval_code(features: [::Quickjs::
|
61
|
+
# Provide `setTimeout` managed by CRuby
|
62
|
+
vm = Quickjs.eval_code(features: [::Quickjs::FEATURE_TIMEOUT])
|
63
63
|
|
64
64
|
# Inject the polyfill of Intl
|
65
65
|
vm = Quickjs.eval_code(features: [::Quickjs::POLYFILL_INTL])
|
@@ -98,8 +98,8 @@ vm = Quickjs::VM.new(features: [::Quickjs::MODULE_STD])
|
|
98
98
|
# Enable `os` module by quickjs: https://bellard.org/quickjs/quickjs.html#os-module
|
99
99
|
vm = Quickjs::VM.new(features: [::Quickjs::MODULE_OS])
|
100
100
|
|
101
|
-
#
|
102
|
-
vm = Quickjs::VM.new(features: [::Quickjs::
|
101
|
+
# Provide `setTimeout` managed by CRuby
|
102
|
+
vm = Quickjs::VM.new(features: [::Quickjs::FEATURE_TIMEOUT])
|
103
103
|
|
104
104
|
# Inject the polyfill of Intl
|
105
105
|
vm = Quickjs::VM.new(features: [::Quickjs::POLYFILL_INTL])
|
data/ext/quickjsrb/quickjsrb.c
CHANGED
@@ -542,22 +542,7 @@ static VALUE vm_m_initialize(int argc, VALUE *argv, VALUE r_self)
|
|
542
542
|
JSValue j_osEval = JS_Eval(data->context, enableOs, strlen(enableOs), "<vm>", JS_EVAL_TYPE_MODULE);
|
543
543
|
JS_FreeValue(data->context, j_osEval);
|
544
544
|
}
|
545
|
-
else if (RTEST(rb_funcall(r_features, rb_intern("include?"), 1, QUICKJSRB_SYM(
|
546
|
-
{
|
547
|
-
char *filename = random_string();
|
548
|
-
js_init_module_os(data->context, filename); // Better if this is limited just only for setTimeout and clearTimeout
|
549
|
-
const char *enableTimeoutTemplate = "import * as _os from '%s';\n"
|
550
|
-
"globalThis.setTimeout = _os.setTimeout;\n"
|
551
|
-
"globalThis.clearTimeout = _os.clearTimeout;\n";
|
552
|
-
int length = snprintf(NULL, 0, enableTimeoutTemplate, filename);
|
553
|
-
char *enableTimeout = (char *)malloc(length + 1);
|
554
|
-
snprintf(enableTimeout, length + 1, enableTimeoutTemplate, filename);
|
555
|
-
|
556
|
-
JSValue j_timeoutEval = JS_Eval(data->context, enableTimeout, strlen(enableTimeout), "<vm>", JS_EVAL_TYPE_MODULE);
|
557
|
-
free(enableTimeout);
|
558
|
-
JS_FreeValue(data->context, j_timeoutEval);
|
559
|
-
}
|
560
|
-
else if (RTEST(rb_funcall(r_features, rb_intern("include?"), 1, QUICKJSRB_SYM(featureOsTimeoutBetaId))))
|
545
|
+
else if (RTEST(rb_funcall(r_features, rb_intern("include?"), 1, QUICKJSRB_SYM(featureTimeoutId))))
|
561
546
|
{
|
562
547
|
JS_SetPropertyStr(
|
563
548
|
data->context, j_global, "setTimeout",
|
data/ext/quickjsrb/quickjsrb.h
CHANGED
@@ -17,8 +17,7 @@ extern const uint8_t qjsc_polyfill_intl_en_min;
|
|
17
17
|
|
18
18
|
const char *featureStdId = "feature_std";
|
19
19
|
const char *featureOsId = "feature_os";
|
20
|
-
const char *
|
21
|
-
const char *featureOsTimeoutBetaId = "feature_os_timeout_beta";
|
20
|
+
const char *featureTimeoutId = "feature_timeout";
|
22
21
|
const char *featurePolyfillIntlId = "feature_polyfill_intl";
|
23
22
|
|
24
23
|
const char *undefinedId = "undefined";
|
@@ -137,8 +136,7 @@ static void r_define_constants(VALUE r_parent_class)
|
|
137
136
|
{
|
138
137
|
rb_define_const(r_parent_class, "MODULE_STD", QUICKJSRB_SYM(featureStdId));
|
139
138
|
rb_define_const(r_parent_class, "MODULE_OS", QUICKJSRB_SYM(featureOsId));
|
140
|
-
rb_define_const(r_parent_class, "
|
141
|
-
rb_define_const(r_parent_class, "FEATURES_TIMEOUT_BETA", QUICKJSRB_SYM(featureOsTimeoutBetaId));
|
139
|
+
rb_define_const(r_parent_class, "FEATURE_TIMEOUT", QUICKJSRB_SYM(featureTimeoutId));
|
142
140
|
rb_define_const(r_parent_class, "POLYFILL_INTL", QUICKJSRB_SYM(featurePolyfillIntlId));
|
143
141
|
|
144
142
|
VALUE rb_cQuickjsValue = rb_define_class_under(r_parent_class, "Value", rb_cObject);
|
data/lib/quickjs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hmsk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|