homura-runtime 0.3.8 → 0.3.9
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/CHANGELOG.md +8 -0
- data/exe/auto-await +23 -23
- data/exe/compile-assets +68 -61
- data/exe/compile-erb +263 -255
- data/exe/homura-build +74 -21
- data/lib/homura/runtime/ai.rb +104 -85
- data/lib/homura/runtime/async_registry.rb +124 -109
- data/lib/homura/runtime/auto_await/analyzer.rb +28 -15
- data/lib/homura/runtime/auto_await/transformer.rb +1 -0
- data/lib/homura/runtime/build_support.rb +90 -11
- data/lib/homura/runtime/cache.rb +21 -18
- data/lib/homura/runtime/durable_object.rb +27 -17
- data/lib/homura/runtime/email.rb +14 -14
- data/lib/homura/runtime/http.rb +4 -3
- data/lib/homura/runtime/multipart.rb +11 -4
- data/lib/homura/runtime/queue.rb +53 -23
- data/lib/homura/runtime/scheduled.rb +12 -14
- data/lib/homura/runtime/stream.rb +18 -14
- data/lib/homura/runtime/version.rb +1 -1
- data/lib/homura/runtime.rb +129 -93
- data/lib/homura_vendor_tempfile.rb +4 -2
- data/lib/homura_vendor_tilt.rb +5 -3
- data/lib/homura_vendor_zlib.rb +3 -0
- data/lib/opal_patches.rb +83 -66
- metadata +1 -1
data/lib/opal_patches.rb
CHANGED
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
# from, and a warning-only behaviour does not affect program output).
|
|
26
26
|
class Module
|
|
27
27
|
unless private_method_defined?(:deprecate_constant) ||
|
|
28
|
-
|
|
28
|
+
method_defined?(:deprecate_constant)
|
|
29
29
|
def deprecate_constant(*_names)
|
|
30
30
|
self
|
|
31
31
|
end
|
|
32
|
+
|
|
32
33
|
private :deprecate_constant
|
|
33
34
|
end
|
|
34
35
|
end
|
|
@@ -72,13 +73,15 @@ class Module
|
|
|
72
73
|
name_str = name.to_s
|
|
73
74
|
if name_str.include?("::")
|
|
74
75
|
parts = name_str.split("::")
|
|
75
|
-
|
|
76
|
+
# leading "::Foo::Bar"
|
|
77
|
+
parts.shift if parts.first.empty?
|
|
76
78
|
current = self
|
|
77
79
|
parts.each do |part|
|
|
78
80
|
return false unless current.__homura_const_defined_simple(part, inherit)
|
|
79
81
|
current = current.const_get(part, inherit)
|
|
80
82
|
return false unless current.is_a?(Module)
|
|
81
83
|
end
|
|
84
|
+
|
|
82
85
|
true
|
|
83
86
|
else
|
|
84
87
|
__homura_const_defined_simple(name, inherit)
|
|
@@ -156,15 +159,15 @@ module ForwardableAccessor
|
|
|
156
159
|
expr
|
|
157
160
|
.split(".")
|
|
158
161
|
.each do |part|
|
|
159
|
-
current =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
end
|
|
162
|
+
current = if part == "self"
|
|
163
|
+
instance
|
|
164
|
+
elsif part.start_with?("@")
|
|
165
|
+
instance.instance_variable_get(part)
|
|
166
|
+
else
|
|
167
|
+
current.__send__(part)
|
|
168
|
+
end
|
|
167
169
|
end
|
|
170
|
+
|
|
168
171
|
current
|
|
169
172
|
end
|
|
170
173
|
end
|
|
@@ -177,17 +180,17 @@ module Forwardable
|
|
|
177
180
|
def def_instance_delegator(accessor, method, ali = method)
|
|
178
181
|
accessor_str = accessor.to_s
|
|
179
182
|
if accessor_str.start_with?("@") && !accessor_str.include?(".")
|
|
180
|
-
define_method
|
|
183
|
+
define_method(ali) do |*args, &block|
|
|
181
184
|
instance_variable_get(accessor_str).__send__(method, *args, &block)
|
|
182
185
|
end
|
|
183
186
|
elsif accessor_str =~ /\A[A-Za-z_]\w*\z/
|
|
184
187
|
# Plain identifier (method name) — call via __send__ as before.
|
|
185
|
-
define_method
|
|
188
|
+
define_method(ali) do |*args, &block|
|
|
186
189
|
__send__(accessor_str).__send__(method, *args, &block)
|
|
187
190
|
end
|
|
188
191
|
else
|
|
189
192
|
# Dot-path expression like 'self.class'. Resolve without eval.
|
|
190
|
-
define_method
|
|
193
|
+
define_method(ali) do |*args, &block|
|
|
191
194
|
ForwardableAccessor.resolve(self, accessor_str).__send__(
|
|
192
195
|
method,
|
|
193
196
|
*args,
|
|
@@ -204,15 +207,15 @@ module SingleForwardable
|
|
|
204
207
|
def def_single_delegator(accessor, method, ali = method)
|
|
205
208
|
accessor_str = accessor.to_s
|
|
206
209
|
if accessor_str.start_with?("@") && !accessor_str.include?(".")
|
|
207
|
-
define_singleton_method
|
|
210
|
+
define_singleton_method(ali) do |*args, &block|
|
|
208
211
|
instance_variable_get(accessor_str).__send__(method, *args, &block)
|
|
209
212
|
end
|
|
210
213
|
elsif accessor_str =~ /\A[A-Za-z_]\w*\z/
|
|
211
|
-
define_singleton_method
|
|
214
|
+
define_singleton_method(ali) do |*args, &block|
|
|
212
215
|
__send__(accessor_str).__send__(method, *args, &block)
|
|
213
216
|
end
|
|
214
217
|
else
|
|
215
|
-
define_singleton_method
|
|
218
|
+
define_singleton_method(ali) do |*args, &block|
|
|
216
219
|
ForwardableAccessor.resolve(self, accessor_str).__send__(
|
|
217
220
|
method,
|
|
218
221
|
*args,
|
|
@@ -239,29 +242,30 @@ end
|
|
|
239
242
|
# continue to work.
|
|
240
243
|
begin
|
|
241
244
|
require "uri"
|
|
245
|
+
|
|
242
246
|
rescue StandardError
|
|
243
247
|
nil
|
|
244
248
|
end
|
|
249
|
+
|
|
245
250
|
require "cgi"
|
|
246
251
|
|
|
247
252
|
module ::URI
|
|
248
253
|
unless const_defined?(:DEFAULT_PARSER)
|
|
249
|
-
DEFAULT_PARSER =
|
|
250
|
-
|
|
251
|
-
UNSAFE = Regexp.compile('[^\-_.!~*\'()a-zA-Z0-9;/?:@&=+$,\[\]]').freeze
|
|
254
|
+
DEFAULT_PARSER = Module.new do
|
|
255
|
+
UNSAFE = Regexp.compile("[^\\-_.!~*'()a-zA-Z0-9;/?:@&=+$,\\[\\]]").freeze
|
|
252
256
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
257
|
+
def self.regexp
|
|
258
|
+
{UNSAFE: UNSAFE}
|
|
259
|
+
end
|
|
256
260
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
def self.escape(s, unsafe = UNSAFE)
|
|
262
|
+
CGI.escape(s.to_s)
|
|
263
|
+
end
|
|
260
264
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
end
|
|
265
|
+
def self.unescape(s)
|
|
266
|
+
CGI.unescape(s.to_s)
|
|
264
267
|
end
|
|
268
|
+
end
|
|
265
269
|
end
|
|
266
270
|
|
|
267
271
|
# CRuby's URI.decode_www_form_component / encode_www_form_component are used
|
|
@@ -330,20 +334,17 @@ module ::URI
|
|
|
330
334
|
def self.parse(str)
|
|
331
335
|
s = str.to_s
|
|
332
336
|
if s.empty?
|
|
333
|
-
return(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
)
|
|
342
|
-
)
|
|
337
|
+
return (Generic.new(
|
|
338
|
+
host: nil,
|
|
339
|
+
scheme: nil,
|
|
340
|
+
port: nil,
|
|
341
|
+
path: "",
|
|
342
|
+
query: nil,
|
|
343
|
+
fragment: nil
|
|
344
|
+
))
|
|
343
345
|
end
|
|
344
346
|
|
|
345
|
-
js_url =
|
|
346
|
-
`
|
|
347
|
+
js_url = `
|
|
347
348
|
(function() {
|
|
348
349
|
try { return new URL(#{s}); }
|
|
349
350
|
catch (e) {
|
|
@@ -398,6 +399,7 @@ module ::Kernel
|
|
|
398
399
|
return arg if arg.is_a?(::URI::Generic)
|
|
399
400
|
::URI.parse(arg.to_s)
|
|
400
401
|
end
|
|
402
|
+
|
|
401
403
|
module_function :URI
|
|
402
404
|
end
|
|
403
405
|
|
|
@@ -471,9 +473,12 @@ module ::SecureRandom
|
|
|
471
473
|
n = 16 if n <= 0
|
|
472
474
|
hex_string = secure_hex_bytes(n)
|
|
473
475
|
if hex_string.nil?
|
|
474
|
-
raise
|
|
475
|
-
|
|
476
|
+
raise(
|
|
477
|
+
EntropyError,
|
|
478
|
+
"no source of cryptographic entropy available (node:crypto AND Web Crypto both unreachable)"
|
|
479
|
+
)
|
|
476
480
|
end
|
|
481
|
+
|
|
477
482
|
[hex_string].pack("H*")
|
|
478
483
|
end
|
|
479
484
|
|
|
@@ -482,9 +487,12 @@ module ::SecureRandom
|
|
|
482
487
|
n = 16 if n <= 0
|
|
483
488
|
out = secure_hex_bytes(n)
|
|
484
489
|
if out.nil?
|
|
485
|
-
raise
|
|
486
|
-
|
|
490
|
+
raise(
|
|
491
|
+
EntropyError,
|
|
492
|
+
"no source of cryptographic entropy available (node:crypto AND Web Crypto both unreachable)"
|
|
493
|
+
)
|
|
487
494
|
end
|
|
495
|
+
|
|
488
496
|
out
|
|
489
497
|
end
|
|
490
498
|
|
|
@@ -495,6 +503,7 @@ module ::SecureRandom
|
|
|
495
503
|
|
|
496
504
|
def self.base64(n = 16)
|
|
497
505
|
require "base64"
|
|
506
|
+
|
|
498
507
|
Base64.strict_encode64(random_bytes(n))
|
|
499
508
|
end
|
|
500
509
|
|
|
@@ -518,8 +527,7 @@ module ::SecureRandom
|
|
|
518
527
|
def self.secure_hex_bytes(n)
|
|
519
528
|
# Opal does not always auto-return backtick IIFEs; assign first
|
|
520
529
|
# so the method's last expression is a normal Ruby reference.
|
|
521
|
-
result =
|
|
522
|
-
`(function(n) {
|
|
530
|
+
result = `(function(n) {
|
|
523
531
|
try {
|
|
524
532
|
if (typeof globalThis.__nodeCrypto__ !== 'undefined' && globalThis.__nodeCrypto__) {
|
|
525
533
|
return globalThis.__nodeCrypto__.randomBytes(n).toString('hex');
|
|
@@ -569,19 +577,20 @@ class ::Array
|
|
|
569
577
|
end
|
|
570
578
|
|
|
571
579
|
hex = self.first.to_s
|
|
572
|
-
nibble_count =
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
nibble_count -= 1 if nibble_count.odd?
|
|
580
|
+
nibble_count = if fmt == "H*"
|
|
581
|
+
hex.length
|
|
582
|
+
else
|
|
583
|
+
[fmt[1..-1].to_i, hex.length].min
|
|
584
|
+
end
|
|
585
|
+
# round down to whole bytes
|
|
586
|
+
nibble_count -= 1 if nibble_count.odd?
|
|
579
587
|
out = ""
|
|
580
588
|
i = 0
|
|
581
589
|
while i < nibble_count
|
|
582
590
|
out = out + hex[i, 2].to_i(16).chr
|
|
583
591
|
i += 2
|
|
584
592
|
end
|
|
593
|
+
|
|
585
594
|
out
|
|
586
595
|
end
|
|
587
596
|
end
|
|
@@ -608,12 +617,12 @@ class ::String
|
|
|
608
617
|
return unpack1_without_homura_hex(format)
|
|
609
618
|
end
|
|
610
619
|
|
|
611
|
-
requested_nibbles =
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
620
|
+
requested_nibbles = if fmt == "H*"
|
|
621
|
+
self.length * 2
|
|
622
|
+
else
|
|
623
|
+
fmt[1..-1].to_i
|
|
624
|
+
end
|
|
625
|
+
|
|
617
626
|
out = ""
|
|
618
627
|
i = 0
|
|
619
628
|
n = self.length
|
|
@@ -624,6 +633,7 @@ class ::String
|
|
|
624
633
|
out = out + h
|
|
625
634
|
i += 1
|
|
626
635
|
end
|
|
636
|
+
|
|
627
637
|
out[0, requested_nibbles]
|
|
628
638
|
end
|
|
629
639
|
end
|
|
@@ -643,19 +653,21 @@ end
|
|
|
643
653
|
begin
|
|
644
654
|
file_class = ::File
|
|
645
655
|
unless file_class.respond_to?(:read) &&
|
|
646
|
-
|
|
656
|
+
!file_class.method(:read).source_location.nil?
|
|
647
657
|
def file_class.read(*args)
|
|
648
658
|
raise ::Errno::ENOENT, args.first.to_s
|
|
649
659
|
end
|
|
660
|
+
|
|
650
661
|
def file_class.binread(*args)
|
|
651
662
|
raise ::Errno::ENOENT, args.first.to_s
|
|
652
663
|
end
|
|
653
664
|
end
|
|
665
|
+
|
|
654
666
|
unless file_class.respond_to?(:fnmatch)
|
|
655
667
|
def file_class.fnmatch(pattern, path, *)
|
|
656
668
|
# Very small fnmatch: supports `*` and `?` only, good enough for
|
|
657
669
|
# Sinatra's template extension matching.
|
|
658
|
-
regex =
|
|
670
|
+
regex = "\\A"
|
|
659
671
|
i = 0
|
|
660
672
|
p = pattern.to_s
|
|
661
673
|
while i < p.length
|
|
@@ -670,15 +682,19 @@ begin
|
|
|
670
682
|
else
|
|
671
683
|
regex += c
|
|
672
684
|
end
|
|
685
|
+
|
|
673
686
|
i += 1
|
|
674
687
|
end
|
|
675
|
-
|
|
688
|
+
|
|
689
|
+
regex += "\\z"
|
|
676
690
|
!!(path.to_s =~ Regexp.new(regex))
|
|
677
691
|
end
|
|
692
|
+
|
|
678
693
|
def file_class.fnmatch?(pattern, path, *)
|
|
679
694
|
fnmatch(pattern, path)
|
|
680
695
|
end
|
|
681
696
|
end
|
|
697
|
+
|
|
682
698
|
rescue NameError
|
|
683
699
|
# File not available at this load point — ignore.
|
|
684
700
|
end
|
|
@@ -736,8 +752,9 @@ require "rubygems/version"
|
|
|
736
752
|
ISO_8859_15
|
|
737
753
|
ISO_8859_16
|
|
738
754
|
MACROMAN
|
|
739
|
-
]
|
|
740
|
-
|
|
741
|
-
Encoding.
|
|
755
|
+
]
|
|
756
|
+
.each do |name|
|
|
757
|
+
unless Encoding.const_defined?(name)
|
|
758
|
+
Encoding.const_set(name, Encoding::ASCII_8BIT)
|
|
759
|
+
end
|
|
742
760
|
end
|
|
743
|
-
end
|