homura-runtime 0.2.14 → 0.2.16

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: 6f9563f8e7aae9b3faa946423aa2f7dc13c48767572c744546397ada20dd1015
4
- data.tar.gz: 946de6742c7518ced26da901ce064d894d52607e3139c8365914d21fe5a2b539
3
+ metadata.gz: 411bf1884ba07170427e2f1a905b2848c81e8de9d53caea247006c7d41377f3e
4
+ data.tar.gz: 83b2fc17572d59b4c93625553d2e46477e9df01161feaa76be41a8cb8e7acf5d
5
5
  SHA512:
6
- metadata.gz: 185534dd8a467b7b04fe44456c856d84f0124bdd6d487f9a756676d71479228e081b4fdaa72d7635d1428d6cf2b0868db3b2103668b9f696ec9487f0f8c9b2a7
7
- data.tar.gz: 91fce4ded7da7402431a993225969618fa88f538d77a6e5791a4c5acc72391941a706f446ab59a74996528f7575b5a186a852b483e276bb5a312fdb009b78311
6
+ metadata.gz: 1d8fb86ad2a4aee75cc5c1864b954d04ac8bbda9fd4c10a1151076eeb0996db4eca85f59fcd25ae6721e060f409097a8a83856c30b57bc063e9145156973380e
7
+ data.tar.gz: 0a451bc7da52d28fd1d253bfe7b6885caa463b2f5790d53bbd2de0bc49f9ea7efe282c690a8131a0cc4fafa4dd720bc7f3571744280631acf5e423800343f3d5
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudflareWorkers
4
- VERSION = '0.2.14'
4
+ VERSION = '0.2.16'
5
5
  end
@@ -685,7 +685,19 @@ module Cloudflare
685
685
  # Flatten common keys from `result['meta']` to the top of the hash so
686
686
  # callers can write `meta['last_row_id']` without descending into the
687
687
  # nested D1 metadata object. Preserves the original shape unchanged.
688
+ #
689
+ # The gem's own Ruby sources are NOT processed by the build's
690
+ # auto-await pass — only user app code is. So when `execute_insert`
691
+ # passes the result of `stmt.run` here, `result` may still be a JS
692
+ # Promise. Await it explicitly so the flatten branch actually runs;
693
+ # otherwise the early `unless result.is_a?(Hash)` would short-circuit
694
+ # and `meta['last_row_id']` would come back as nil at the call site
695
+ # (the caller's auto-await resolves the Promise *after* this method
696
+ # returns).
688
697
  def self.flatten_meta(result)
698
+ if defined?(::Cloudflare) && ::Cloudflare.js_promise?(result)
699
+ result = result.__await__
700
+ end
689
701
  return result unless result.is_a?(Hash)
690
702
  nested = result['meta']
691
703
  return result unless nested.is_a?(Hash)
data/lib/opal_patches.rb CHANGED
@@ -456,10 +456,12 @@ module ::SecureRandom
456
456
  padding ? s : s.delete('=')
457
457
  end
458
458
 
459
- def self.random_number(n = 0)
460
- # Not used at class-init time; real implementations welcome.
461
- 0
462
- end
459
+ # NOTE: `SecureRandom.random_number` is provided by `Random::Formatter`
460
+ # (extended into `SecureRandom` by stdlib/securerandom.rb). Defining a
461
+ # `self.random_number` stub here used to shadow that real implementation
462
+ # and pin the result to `0`, which silently broke any caller that did
463
+ # the canonical `format('%06d', SecureRandom.random_number(1_000_000))`.
464
+ # Leave the formatter implementation alone; do NOT redefine here.
463
465
 
464
466
  # Returns a hex string of `n` random bytes, or nil when no entropy
465
467
  # source is available. Tries node:crypto.randomBytes first (works
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homura-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuhiro Homma