homura-runtime 0.3.23 → 0.3.25

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: 3a5659f0bfd92228407a2e0e15dd56ee5e0312289cb96f26a9960fedf5b6b157
4
- data.tar.gz: fefd3fbf629529ac2b959b77860917ecc14b384d28f5d6933b770c5af8c2cfa4
3
+ metadata.gz: 0b2d4ab2b10a143e1d6498e18df0a8b434fe68375824363ab529f866cecd6893
4
+ data.tar.gz: 6a9ec9a85df8450c752cee860de6acfc5cffe9c5285372e991da9372e07527aa
5
5
  SHA512:
6
- metadata.gz: fe4fa0f002fce65c874da54a276786953c35e480e681648e64dd1962206a01fbdecd404b533e716e2890ba7ad457363abfdf0c051512c2029d7b2a469bf0a21d
7
- data.tar.gz: 39881750bd31c90b61279569b9cfeaec2533b7c5045d99da288eff17becef3daf7c68b59a1b86aab20ebc5bd951f8e8e033c7a1f61a2a9200e5b729df88224c9
6
+ metadata.gz: '08f2e8a1c214545e38378c23de1d5204ad430ebe843326a3bd92b5998223aefdef20b6ab5be7ee5b3a29949b61aea5c3b2a12d6daa2fb7e76d8b6cbc322d2cca'
7
+ data.tar.gz: 938b603a2aefe6d4f343e3ecf87b1098ef6a19c9a6c0e68d162fdd32dfa5363255fcdab9a9b42d02076036af4ab555d0e471921b86f23b845a724d06468f491b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.25 (2026-06-25)
4
+
5
+ - Override Phlex element registration before loading HTML/SVG element modules.
6
+ The override uses `define_method` instead of string `class_eval`, avoiding
7
+ `opal-parser` in Worker bundles.
8
+
9
+ ## 0.3.24 (2026-06-25)
10
+
11
+ - Add a Phlex Opal compatibility shim for `String#name`. Phlex's element
12
+ registration receives method names as symbols on MRI, but Opal reports them
13
+ as strings in this path.
14
+
3
15
  ## 0.3.23 (2026-06-25)
4
16
 
5
17
  - Load Phlex SGML before SGML extension modules and bootstrap the HTML/SVG
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HomuraRuntime
4
- VERSION = "0.3.23"
4
+ VERSION = "0.3.25"
5
5
  end
@@ -3,6 +3,15 @@
3
3
  require "corelib/pattern_matching"
4
4
  require "zeitwerk/opal_compat"
5
5
  require "phlex" unless defined?(Phlex)
6
+
7
+ unless String.method_defined?(:name)
8
+ class String
9
+ def name
10
+ self
11
+ end
12
+ end
13
+ end
14
+
6
15
  require "phlex/error"
7
16
  require "phlex/errors/argument_error"
8
17
  require "phlex/errors/double_render_error"
@@ -26,6 +35,73 @@ unless defined?(Phlex::SVG)
26
35
  end
27
36
  end
28
37
 
38
+ module Phlex::SGML::Elements
39
+ def register_element(method_name, tag: method_name.name.tr("_", "-"))
40
+ define_method(method_name) do |**attributes, &content|
41
+ state = @_state
42
+ buffer = state.buffer
43
+ has_content = !content.nil?
44
+
45
+ unless state.should_render?
46
+ content.call(self) if has_content
47
+ return nil
48
+ end
49
+
50
+ if attributes.length > 0
51
+ buffer << "<#{tag}"
52
+ __homura_normalize_comma_separated_tokens__(method_name, attributes)
53
+ buffer << (Phlex::ATTRIBUTE_CACHE[attributes] ||= Phlex::SGML::Attributes.generate_attributes(attributes))
54
+ buffer << ">"
55
+
56
+ if has_content
57
+ original_length = buffer.bytesize
58
+ rendered_content = content.call(self)
59
+ __implicit_output__(rendered_content) if original_length == buffer.bytesize
60
+ buffer << "</#{tag}>"
61
+ else
62
+ buffer << "</#{tag}>"
63
+ end
64
+ elsif has_content
65
+ buffer << "<#{tag}>"
66
+ original_length = buffer.bytesize
67
+ rendered_content = content.call(self)
68
+ __implicit_output__(rendered_content) if original_length == buffer.bytesize
69
+ buffer << "</#{tag}>"
70
+ else
71
+ buffer << "<#{tag}></#{tag}>"
72
+ end
73
+
74
+ flush if tag == "head"
75
+ nil
76
+ end
77
+
78
+ __registered_elements__[method_name] = tag
79
+ method_name
80
+ end
81
+
82
+ def __register_void_element__(method_name, tag: method_name.name.tr("_", "-"))
83
+ define_method(method_name) do |**attributes|
84
+ state = @_state
85
+ return unless state.should_render?
86
+
87
+ buffer = state.buffer
88
+ if attributes.length > 0
89
+ buffer << "<#{tag}"
90
+ __homura_normalize_comma_separated_tokens__(method_name, attributes)
91
+ buffer << (Phlex::ATTRIBUTE_CACHE[attributes] ||= Phlex::SGML::Attributes.generate_attributes(attributes))
92
+ buffer << ">"
93
+ else
94
+ buffer << "<#{tag}>"
95
+ end
96
+
97
+ nil
98
+ end
99
+
100
+ __registered_elements__[method_name] = tag
101
+ method_name
102
+ end
103
+ end
104
+
29
105
  require "phlex/html/void_elements"
30
106
  require "phlex/html/standard_elements"
31
107
  require "phlex/html"
@@ -236,86 +312,6 @@ if defined?(Phlex::SGML)
236
312
  end
237
313
  end
238
314
 
239
- module Phlex::SGML::Elements
240
- def register_element(method_name, tag: method_name.name.tr("_", "-"))
241
- define_method(method_name) do |**attributes, &content|
242
- state = @_state
243
- buffer = state.buffer
244
- has_content = !content.nil?
245
-
246
- unless state.should_render?
247
- content.call(self) if has_content
248
- return nil
249
- end
250
-
251
- if attributes.length > 0
252
- buffer << "<#{tag}"
253
- begin
254
- __homura_normalize_comma_separated_tokens__(method_name, attributes)
255
- buffer << (Phlex::ATTRIBUTE_CACHE[attributes] ||= Phlex::SGML::Attributes.generate_attributes(attributes))
256
- ensure
257
- buffer << ">"
258
- end
259
-
260
- if has_content
261
- begin
262
- original_length = buffer.bytesize
263
- rendered_content = content.call(self)
264
- __implicit_output__(rendered_content) if original_length == buffer.bytesize
265
- ensure
266
- buffer << "</#{tag}>"
267
- end
268
- else
269
- buffer << "</#{tag}>"
270
- end
271
- elsif has_content
272
- buffer << "<#{tag}>"
273
- begin
274
- original_length = buffer.bytesize
275
- rendered_content = content.call(self)
276
- __implicit_output__(rendered_content) if original_length == buffer.bytesize
277
- ensure
278
- buffer << "</#{tag}>"
279
- end
280
- else
281
- buffer << "<#{tag}></#{tag}>"
282
- end
283
-
284
- flush if tag == "head"
285
- nil
286
- end
287
-
288
- __registered_elements__[method_name] = tag
289
- method_name
290
- end
291
-
292
- def __register_void_element__(method_name, tag: method_name.name.tr("_", "-"))
293
- define_method(method_name) do |**attributes|
294
- state = @_state
295
- return unless state.should_render?
296
-
297
- buffer = state.buffer
298
-
299
- if attributes.length > 0
300
- buffer << "<#{tag}"
301
- begin
302
- __homura_normalize_comma_separated_tokens__(method_name, attributes)
303
- buffer << (Phlex::ATTRIBUTE_CACHE[attributes] ||= Phlex::SGML::Attributes.generate_attributes(attributes))
304
- ensure
305
- buffer << ">"
306
- end
307
- else
308
- buffer << "<#{tag}>"
309
- end
310
-
311
- nil
312
- end
313
-
314
- __registered_elements__[method_name] = tag
315
- method_name
316
- end
317
- end
318
-
319
315
  module Phlex::SGML::Attributes
320
316
  class << self
321
317
  alias __homura_generate_attributes__ generate_attributes
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.3.23
4
+ version: 0.3.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuhiro Homma