js 2.5.0 → 2.5.1
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/ext/js/js-core.c +11 -0
- data/ext/witapi/depend +1 -1
- data/lib/js/version.rb +1 -1
- data/lib/js.rb +19 -3
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a1548392e9fe8a5aafc049bf997785e93d3545d77e0cc08db636bc36c14243d6
         | 
| 4 | 
            +
              data.tar.gz: '028d3bcf94f19c167b244c388f61d964b54d18da67bf631e30cd1bfe2d511ec1'
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 370c149ec326bcf0f9fbbfb6dfbb8d92b27ecfc99933a1c58af35669923aeb439ad2f5719b2da12b1ae5bf016b9bfaf8f0fba73ddd9ea73d9101dc7df2f5a9b8
         | 
| 7 | 
            +
              data.tar.gz: a702e7859689f537d4bed57fd85b537556cdf30336cf1155031aae13c057dcf6e2826f9b616fae21a4ab1ceca58d7b07386a2431334eef4e833a39a821f6ac92
         | 
    
        data/ext/js/js-core.c
    CHANGED
    
    | @@ -200,6 +200,11 @@ static VALUE _rb_js_obj_aref(VALUE obj, VALUE key) { | |
| 200 200 | 
             
            static VALUE _rb_js_obj_aset(VALUE obj, VALUE key, VALUE val) {
         | 
| 201 201 | 
             
              struct jsvalue *p = check_jsvalue(obj);
         | 
| 202 202 | 
             
              VALUE rv = _rb_js_try_convert(rb_mJS, val);
         | 
| 203 | 
            +
              if (rv == Qnil) {
         | 
| 204 | 
            +
                rb_raise(rb_eTypeError,
         | 
| 205 | 
            +
                         "wrong argument type %s (expected JS::Object like object)",
         | 
| 206 | 
            +
                         rb_class2name(rb_obj_class(val)));
         | 
| 207 | 
            +
              }
         | 
| 203 208 | 
             
              struct jsvalue *v = check_jsvalue(rv);
         | 
| 204 209 | 
             
              rb_js_abi_host_string_t key_abi_str;
         | 
| 205 210 | 
             
              key = rb_obj_as_string(key);
         | 
| @@ -235,8 +240,14 @@ static VALUE _rb_js_obj_strictly_eql(VALUE obj, VALUE other) { | |
| 235 240 | 
             
             * Performs "==" comparison, a.k.a the "Abstract Equality Comparison"
         | 
| 236 241 | 
             
             * algorithm defined in the ECMAScript.
         | 
| 237 242 | 
             
             * https://262.ecma-international.org/11.0/#sec-abstract-equality-comparison
         | 
| 243 | 
            +
             * If the given other object is not a JS::Object, try to convert it to a
         | 
| 244 | 
            +
             * JS::Object using JS.try_convert. If the conversion fails, returns false.
         | 
| 238 245 | 
             
             */
         | 
| 239 246 | 
             
            static VALUE _rb_js_obj_eql(VALUE obj, VALUE other) {
         | 
| 247 | 
            +
              other = _rb_js_try_convert(rb_mJS, other);
         | 
| 248 | 
            +
              if (other == Qnil) {
         | 
| 249 | 
            +
                return Qfalse;
         | 
| 250 | 
            +
              }
         | 
| 240 251 | 
             
              struct jsvalue *lhs = check_jsvalue(obj);
         | 
| 241 252 | 
             
              struct jsvalue *rhs = check_jsvalue(other);
         | 
| 242 253 | 
             
              bool result = rb_js_abi_host_js_value_equal(lhs->abi, rhs->abi);
         | 
    
        data/ext/witapi/depend
    CHANGED
    
    
    
        data/lib/js/version.rb
    CHANGED
    
    
    
        data/lib/js.rb
    CHANGED
    
    | @@ -79,8 +79,8 @@ module JS | |
| 79 79 | 
             
                  current = Fiber.current
         | 
| 80 80 | 
             
                  promise.call(
         | 
| 81 81 | 
             
                    :then,
         | 
| 82 | 
            -
                    ->(value) { current.transfer(value, :success) },
         | 
| 83 | 
            -
                    ->(value) { current.transfer(value, :failure) }
         | 
| 82 | 
            +
                    ->(value) { current.transfer(value, :success); nil },
         | 
| 83 | 
            +
                    ->(value) { current.transfer(value, :failure); nil }
         | 
| 84 84 | 
             
                  )
         | 
| 85 85 | 
             
                  if @loop == current
         | 
| 86 86 | 
             
                    raise (
         | 
| @@ -137,8 +137,10 @@ class JS::Object | |
| 137 137 | 
             
              #   JS.global[:Date].new(2020, 1, 1)
         | 
| 138 138 | 
             
              #   JS.global[:Error].new("error message")
         | 
| 139 139 | 
             
              #   JS.global[:URLSearchParams].new(JS.global[:location][:search])
         | 
| 140 | 
            +
              #   JS.global[:Promise].new ->(resolve, reject) { resolve.call(42) }
         | 
| 140 141 | 
             
              #
         | 
| 141 | 
            -
              def new(*args)
         | 
| 142 | 
            +
              def new(*args, &block)
         | 
| 143 | 
            +
                args = args + [block] if block
         | 
| 142 144 | 
             
                JS.global[:Reflect].construct(self, args.to_js)
         | 
| 143 145 | 
             
              end
         | 
| 144 146 |  | 
| @@ -189,6 +191,20 @@ class JS::Object | |
| 189 191 | 
             
                self[sym].typeof == "function"
         | 
| 190 192 | 
             
              end
         | 
| 191 193 |  | 
| 194 | 
            +
              # Call the receiver (a JavaScript function) with `undefined` as its receiver context. 
         | 
| 195 | 
            +
              # This method is similar to JS::Object#call, but it is used to call a function that is not
         | 
| 196 | 
            +
              # a method of an object.
         | 
| 197 | 
            +
              #   
         | 
| 198 | 
            +
              #   floor = JS.global[:Math][:floor]
         | 
| 199 | 
            +
              #   floor.apply(3.14) # => 3
         | 
| 200 | 
            +
              #   JS.global[:Promise].new do |resolve, reject|
         | 
| 201 | 
            +
              #     resolve.apply(42)
         | 
| 202 | 
            +
              #   end.await # => 42
         | 
| 203 | 
            +
              def apply(*args, &block)
         | 
| 204 | 
            +
                args = args + [block] if block
         | 
| 205 | 
            +
                JS.global[:Reflect].call(:apply, self, JS::Undefined, args.to_js)
         | 
| 206 | 
            +
              end
         | 
| 207 | 
            +
             | 
| 192 208 | 
             
              # Await a JavaScript Promise like `await` in JavaScript.
         | 
| 193 209 | 
             
              # This method looks like a synchronous method, but it actually runs asynchronously using fibers.
         | 
| 194 210 | 
             
              # In other words, the next line to the `await` call at Ruby source will be executed after the
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: js
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.5. | 
| 4 | 
            +
              version: 2.5.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yuta Saito
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-04-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: JavaScript bindings for ruby.wasm. This gem provides a way to use JavaScript
         | 
| 14 14 | 
             
              functionalities from Ruby through WebAssembly.
         | 
| @@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 63 63 | 
             
                - !ruby/object:Gem::Version
         | 
| 64 64 | 
             
                  version: '0'
         | 
| 65 65 | 
             
            requirements: []
         | 
| 66 | 
            -
            rubygems_version: 3. | 
| 66 | 
            +
            rubygems_version: 3.4.19
         | 
| 67 67 | 
             
            signing_key: 
         | 
| 68 68 | 
             
            specification_version: 4
         | 
| 69 69 | 
             
            summary: JavaScript bindings for ruby.wasm
         |