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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 460654c8f6d8174bf3f7025c0ae6e37a0bed766f3a8bdf57da5b9f5fc4ef8e0b
4
- data.tar.gz: 100eb2a30022baada73c5d83eb79675c19ba1df439da494278638917c3df16a2
3
+ metadata.gz: dafb25d574a45620b440561078836c98c15d4bfbd262de5f18bf9f9eb8fc572e
4
+ data.tar.gz: 421c3d7ce93798a00a673d3cd15ee27c3fbdae62b4462d2b7100ad423d8d80e9
5
5
  SHA512:
6
- metadata.gz: 1527a557f744d35f9d79965d51c70f82cba82328351e1ec301ea66fd0293a7cd8bbe713766c470648774c6b589382d4e4357d89b01aa788a8c089e29f974f652
7
- data.tar.gz: d06c84aac9d3a440e885d769dfceb3849276c3b93c6d43e60788c8bc476416f61fef2898f1f94c90db44a4e0bc7e847c19c23366983555ee22138feeb9889a75
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
- # Expose `os.setTimouet` and `os.clearTimeout` from `os` module
62
- vm = Quickjs.eval_code(features: [::Quickjs::FEATURES_TIMEOUT])
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
- # Expose `os.setTimouet` and `os.clearTimeout` from `os` module
102
- vm = Quickjs::VM.new(features: [::Quickjs::FEATURES_TIMEOUT])
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])
@@ -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(featureOsTimeoutId))))
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",
@@ -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 *featureOsTimeoutId = "feature_os_timeout";
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, "FEATURES_TIMEOUT", QUICKJSRB_SYM(featureOsTimeoutId));
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);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quickjs
4
- VERSION = "0.7.1"
4
+ VERSION = "0.8.0"
5
5
  end
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.7.1
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-24 00:00:00.000000000 Z
11
+ date: 2025-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json