isomorfeus-preact 22.9.0.rc6 → 22.9.0.rc8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ca8bdcd1a2bca5716034b22c785b72a1a5b41c7b62d54c625c445bbdadc8501
4
- data.tar.gz: 5ad31495ae9a95af445ff563fd1975d297bbc6bf20113cef70b00397100c56e7
3
+ metadata.gz: 33afa95cb2a08cd3e365b0fe5b602590f43ece313552f760047ed92ccef388b8
4
+ data.tar.gz: 6d23e97bc3af2352863e6b4fc0c8b8bab6ef471cddf1f5a63ce02bfeaf137e3b
5
5
  SHA512:
6
- metadata.gz: f98ff1c4cfc2799c2560870a71b395990459dae4e931c336bdda23ea29cc2f587d9f64cd0541326bbaa5c389ed40e26c5d1add1f198242d46e1e06b6b887e24a
7
- data.tar.gz: 813122cd579f3d5c68086559ac8c462b18e13039d6b4af99f7d6fa30f14e52be2bb25881e73f2d20e70713b5cc9005e85bc1f4f2c9800024a8b0fdf7b2c061ad
6
+ metadata.gz: 3b4cb524901cf8eaef3832d227874251db99c52ea643c1230903def189b565338e856abecd0a673cb4855fef82f63d955780040565a7f73901dc46175146afca
7
+ data.tar.gz: 66c58db0fa7a4717570b07552da43aa6b89f54e54ce8c461765b7d61014fe482070d8008713bb82ee10dafcb6170f8996903f6a6a2bfd55a7a6e2aae5bb87345
@@ -4,7 +4,6 @@ module Isomorfeus
4
4
  attr_accessor :browser_history
5
5
  attr_accessor :browser_location
6
6
  attr_accessor :current_user_sid_s
7
- attr_accessor :initial_state_fetched
8
7
  attr_accessor :ssr_response_status
9
8
  attr_accessor :top_component
10
9
  attr_reader :initialized
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Preact
3
- VERSION = '22.9.0.rc6'
3
+ VERSION = '22.9.0.rc8'
4
4
  end
5
5
  end
@@ -45,9 +45,22 @@ module Preact::Elements
45
45
  view vkern
46
46
  ]
47
47
 
48
- SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
49
- define_method(element.to_s.underscore.upcase.to_sym) do |props = nil, &block|
50
- Preact._render_element(element, props, &block)
48
+ if RUBY_ENGINE == 'opal'
49
+ SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
50
+ define_method(element.underscore.upcase) do |props = nil, &block|
51
+ %x{
52
+ const op = Opal.Preact;
53
+ const opr = op.render_buffer;
54
+ if (typeof block === 'function') op.$create_element.$$p = block.$to_proc();
55
+ opr[opr.length-1].push(op.$create_element(element, props, nil));
56
+ }
57
+ end
58
+ end
59
+ else
60
+ SUPPORTED_HTML_AND_SVG_ELEMENTS.each do |element|
61
+ define_method(element.to_s.underscore.upcase.to_sym) do |props = nil, &block|
62
+ Preact._render_element(element, props, &block)
63
+ end
51
64
  end
52
65
  end
53
66
 
data/lib/preact.rb CHANGED
@@ -770,7 +770,8 @@ module Preact
770
770
  if (newType.declared_props && newType.declared_props !== nil) {
771
771
  #{
772
772
  `newType.declared_props`.each do |prop, value|
773
- `newProps`[prop] = value[:default] if value.key?(:default) && !`newProps`.key?(prop)
773
+ `if (Object.hasOwnProperty.call(value.$$smap, "default") && !Object.hasOwnProperty.call(newProps.$$smap, prop)) { #{`newProps`[prop] = value[:default]} }`
774
+ nil
774
775
  end
775
776
  }
776
777
  if (Opal.Isomorfeus.development) { #{`newType`.validate_props(`newProps`)} }
@@ -1187,43 +1188,6 @@ module Preact
1187
1188
  end
1188
1189
  end
1189
1190
 
1190
- def create_element(type, props = nil, children = nil, &block)
1191
- if props
1192
- if props.is_a?(Hash)
1193
- normalized_props = props.dup
1194
- key = normalized_props.delete(:key)
1195
- ref = normalized_props.delete(:ref)
1196
- else
1197
- children = props
1198
- normalized_props = {}
1199
- key = nil
1200
- ref = nil
1201
- end
1202
- else
1203
- normalized_props = {}
1204
- key = nil
1205
- ref = nil
1206
- end
1207
-
1208
- if block_given?
1209
- pr = render_buffer
1210
- pr.push([])
1211
- block_result = block.call
1212
- children = pr.pop
1213
- if Preact.is_renderable?(block_result)
1214
- children.push(block_result)
1215
- end
1216
- end
1217
-
1218
- normalized_props[:children] = children unless children.nil?
1219
-
1220
- if RUBY_ENGINE == 'opal'
1221
- `self.createVNode(type, normalized_props, key, ref, null)`
1222
- else
1223
- _create_vnode(type, normalized_props, key, ref, nil)
1224
- end
1225
- end
1226
-
1227
1191
  def create_context(const_name, default_value = nil)
1228
1192
  context = Preact::Context.new(default_value)
1229
1193
  Object.const_set(const_name, context)
@@ -1246,6 +1210,40 @@ module Preact
1246
1210
  attr_accessor :render_buffer
1247
1211
  attr_accessor :rerender_queue
1248
1212
 
1213
+ def create_element(type, props = nil, children = nil, &block)
1214
+ if props
1215
+ if props.is_a?(Hash)
1216
+ normalized_props = props.dup
1217
+ key = normalized_props.delete(:key)
1218
+ ref = normalized_props.delete(:ref)
1219
+ else
1220
+ children = props
1221
+ normalized_props = {}
1222
+ key = nil
1223
+ ref = nil
1224
+ end
1225
+ else
1226
+ normalized_props = {}
1227
+ key = nil
1228
+ ref = nil
1229
+ end
1230
+
1231
+ if block_given?
1232
+ pr = render_buffer
1233
+ pr.JS.push([])
1234
+ block_result = block.call
1235
+ children = pr.JS.pop()
1236
+ if Preact.is_renderable?(block_result)
1237
+ children.JS.push(block_result)
1238
+ end
1239
+ end
1240
+
1241
+ %x{
1242
+ if (children !== nil && children !== null) { #{normalized_props[:children] = children} }
1243
+ return self.createVNode(type, normalized_props, key, ref, null);
1244
+ }
1245
+ end
1246
+
1249
1247
  def _enqueue_render(c)
1250
1248
  if ((`!c._dirty` && (`c._dirty = true`) && rerender_queue.push(c) && `!self.process._rerenderCount++`))
1251
1249
  `setTimeout(self.process)`
@@ -1320,6 +1318,38 @@ module Preact
1320
1318
  VNode.new(type, props, key, ref, original)
1321
1319
  end
1322
1320
 
1321
+ def create_element(type, props = nil, children = nil, &block)
1322
+ if props
1323
+ if props.is_a?(Hash)
1324
+ normalized_props = props.dup
1325
+ key = normalized_props.delete(:key)
1326
+ ref = normalized_props.delete(:ref)
1327
+ else
1328
+ children = props
1329
+ normalized_props = {}
1330
+ key = nil
1331
+ ref = nil
1332
+ end
1333
+ else
1334
+ normalized_props = {}
1335
+ key = nil
1336
+ ref = nil
1337
+ end
1338
+
1339
+ if block_given?
1340
+ pr = render_buffer
1341
+ pr.push([])
1342
+ block_result = block.call
1343
+ children = pr.pop
1344
+ if Preact.is_renderable?(block_result)
1345
+ children.push(block_result)
1346
+ end
1347
+ end
1348
+
1349
+ normalized_props[:children] = children unless children.nil?
1350
+ _create_vnode(type, normalized_props, key, ref, nil)
1351
+ end
1352
+
1323
1353
  def _encode_entities(input)
1324
1354
  s = input.to_s
1325
1355
  return s unless ENCODED_ENTITIES.match?(s)
@@ -1426,7 +1456,7 @@ module Preact
1426
1456
  declared_props = node_name.instance_variable_get(:@declared_props)
1427
1457
  if declared_props
1428
1458
  declared_props.each do |prop, value|
1429
- props[prop] = value[:default] if !props.key?(prop) && value.key?(:default)
1459
+ props[prop] = value[:default] if value.key?(:default) && !props.key?(prop)
1430
1460
  end
1431
1461
  node_name.validate_props(props) if Isomorfeus.development?
1432
1462
  end
data/lib/route.rb CHANGED
@@ -2,14 +2,15 @@ class Route < Preact::Component
2
2
  render do
3
3
  route_match = @context[:router][:matcher].call(props[:path], @context[:location])
4
4
  matches, params = props[:match] || route_match
5
- return unless matches
6
- component = props[:component]
7
- component_props = props[:component_props] || {}
8
- if component
9
- component = component.constantize if component.is_a?(String)
10
- Preact.create_element(component, component_props.merge!({ params: params }))
11
- else
12
- props[:children]
5
+ if matches
6
+ component = props[:component]
7
+ component_props = props[:component_props] || {}
8
+ if component
9
+ component = component.constantize if component.is_a?(String)
10
+ Preact.create_element(component, component_props.merge!({ params: params }))
11
+ else
12
+ props[:children]
13
+ end
13
14
  end
14
15
  end
15
16
  end
data/lib/switch.rb CHANGED
@@ -8,11 +8,11 @@ class Switch < Preact::Component
8
8
  end
9
9
  end
10
10
 
11
- def flatten(children)
12
- if children.is_a?(Array)
13
- children.compact!
14
- children.map! do |child|
15
- if RUBY_ENGINE == 'opal'
11
+ if RUBY_ENGINE == 'opal'
12
+ def flatten(children)
13
+ if children.is_a?(Array)
14
+ children.compact!
15
+ children.map! do |child|
16
16
  if child.is_a?(Array)
17
17
  flatten(child)
18
18
  elsif `child.type === Opal.Fragment`
@@ -20,18 +20,27 @@ class Switch < Preact::Component
20
20
  else
21
21
  child
22
22
  end
23
- else
23
+ end
24
+ else
25
+ [children]
26
+ end
27
+ end
28
+ else
29
+ def flatten(children)
30
+ if children.is_a?(Array)
31
+ children.compact!
32
+ children.map! do |child|
24
33
  if child.is_a?(Array)
25
34
  flatten(child)
26
35
  elsif child.type == ::Fragment
27
- flatten(child.JS[:props][:children])
36
+ flatten(child[:props][:children])
28
37
  else
29
38
  child
30
39
  end
31
40
  end
41
+ else
42
+ [children]
32
43
  end
33
- else
34
- [children]
35
44
  end
36
45
  end
37
46
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-preact
3
3
  version: !ruby/object:Gem::Version
4
- version: 22.9.0.rc6
4
+ version: 22.9.0.rc8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 22.9.0.rc6
61
+ version: 22.9.0.rc8
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 22.9.0.rc6
68
+ version: 22.9.0.rc8
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: isomorfeus-redux
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 22.9.0.rc6
75
+ version: 22.9.0.rc8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 22.9.0.rc6
82
+ version: 22.9.0.rc8
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: isomorfeus-puppetmaster
85
85
  requirement: !ruby/object:Gem::Requirement