hyper-router 1.0.alpha1.1 → 1.0.alpha1.6

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: 9e1474712214609732ebf67e320728aa6240b255f0243569a8a8584f7d0a6b56
4
- data.tar.gz: d6524354f9b72060bcab4aea1c7b2c5db484c93415f4543c42b191d3ce88653d
3
+ metadata.gz: d4e0fbb3f6f7b605fd861a4ac3d3abd12723b6bf4a26fc6128143f23d9b2dc17
4
+ data.tar.gz: 9ed1b3db296fdaeacda7fbea185542b9750ea63f358a7c6b8491fec2973cc992
5
5
  SHA512:
6
- metadata.gz: 549180b133b0af03ce5dade7557ba47ad1dc9a095723a2836f4f05e8e0361e8247fb8c3d53b7b12236c409df312cb38ff5c0a9be90acbfa6f7d07e3402af66ff
7
- data.tar.gz: 54b739c2ed612d2f8d52bea12974df116f1b73259c0ca3285fc0b6c1deb8c136f68b27f589f8f54618bd745dc43308c116b356696daa2f37a69d072ba569ff63
6
+ metadata.gz: b6feda6f513d62676cd1714584f9241b3e5ff2882d14d1aa8701ac74cb1e917321910ae1b32a22125349f2450c378325665d30c46805acfdd34af78e5670f2ed
7
+ data.tar.gz: 9ce41cc41c148fa472b9d35d3424ae14114deebb572a90366c2f03f855857c1132ed35d2a0cc2ff3bf0eaac58f568c5b339d19dd98ee58954ef32931d8980fa5
@@ -14,29 +14,6 @@ module Hyperstack
14
14
  Hyperstack::Router::Location.new(`#{history.to_n}.location`)
15
15
  end
16
16
 
17
- def render(container = nil, params = {}, &block)
18
- if container
19
- container = container.type if container.is_a? Hyperstack::Component::Element
20
- select_router do
21
- Hyperstack::Internal::Component::RenderingContext.render(container, params) do
22
- instance_eval(&block) if block
23
- end
24
- end
25
- else
26
- select_router { instance_eval(&block) }
27
- end
28
- end
29
-
30
- def select_router(&block)
31
- if Hyperstack::Component::IsomorphicHelpers.on_opal_server?
32
- prerender_router(&block)
33
- else
34
- render_router(&block)
35
- end
36
- end
37
-
38
- alias route render
39
-
40
17
  private
41
18
 
42
19
  def browser_history
@@ -50,30 +27,6 @@ module Hyperstack
50
27
  def memory_history(*args)
51
28
  @__memory_history ||= React::Router::History.current.create_memory_history(*args)
52
29
  end
53
-
54
- def render_router(&block)
55
- define_method(:render) do
56
- self.class.history :browser unless history
57
-
58
- React::Router::Router(history: history.to_n) do
59
- instance_eval(&block)
60
- end
61
- end
62
- end
63
-
64
- def prerender_router(&block)
65
- define_method(:render) do
66
- location = {}.tap do |hash|
67
- pathname, search = IsomorphicMethods.request_fullpath.split('?', 2)
68
- hash[:pathname] = pathname
69
- hash[:search] = search ? "?#{search}" : ''
70
- end
71
-
72
- React::Router::StaticRouter(location: location.to_n, context: {}.to_n) do
73
- instance_eval(&block)
74
- end
75
- end
76
- end
77
30
  end
78
31
  end
79
32
  end
@@ -25,10 +25,13 @@ module Hyperstack
25
25
 
26
26
  def Redirect(to, opts = {})
27
27
  opts[:to] = to.to_n
28
+ status = opts.delete(:status)
29
+ status ||= 302
30
+ `#{IsomorphicMethods.ctx}.status = #{status}`
28
31
  React::Router::Redirect(opts)
29
32
  end
30
33
 
31
- def format_params(e)
34
+ def format_params(e, *)
32
35
  {
33
36
  match: Hyperstack::Router::Match.new(`#{e}.match`),
34
37
  location: Hyperstack::Router::Location.new(`#{e}.location`),
@@ -37,23 +40,25 @@ module Hyperstack
37
40
  end
38
41
 
39
42
  def Route(to, opts = {}, &block)
43
+ Hyperstack::Internal::State::Mapper.observed! Hyperstack::Router::Location
44
+
40
45
  opts[:path] = to.to_n
41
46
 
42
47
  if opts[:mounts]
43
48
  component = opts.delete(:mounts)
44
49
 
45
- opts[:component] = lambda do |e|
46
- route_params = format_params(e)
50
+ opts[:component] = lambda do |*e|
51
+ route_params = format_params(*e)
47
52
 
48
53
  Hyperstack::Component::ReactAPI.create_element(component, route_params).to_n
49
54
  end
50
55
  end
51
56
 
52
57
  if block
53
- opts[:render] = lambda do |e|
54
- route_params = format_params(e)
58
+ opts[:render] = lambda do |*e|
59
+ route_params = format_params(*e)
55
60
 
56
- yield(route_params.values).to_n
61
+ yield(*route_params.values).to_n
57
62
  end
58
63
  end
59
64
 
@@ -4,6 +4,17 @@ module Hyperstack
4
4
  class IsomorphicMethods
5
5
  include Hyperstack::Component::IsomorphicHelpers
6
6
 
7
+ def self.ctx
8
+ @ctx ||= `{}`
9
+ end
10
+
11
+ prerender_footer do |_controller|
12
+ next unless on_opal_server?
13
+ ctx_as_hash = Hash.new(@ctx)
14
+ @ctx = `{}`
15
+ raise "Hyperstack::Internal::Component::Redirect #{ctx_as_hash[:url]} status: #{ctx_as_hash[:status]}" if ctx_as_hash[:url]
16
+ end
17
+
7
18
  isomorphic_method(:request_fullpath) do |f|
8
19
  f.when_on_client { `window.location.pathname` }
9
20
  f.send_to_server
@@ -1,6 +1,50 @@
1
1
  module Hyperstack
2
2
  module Router
3
3
  class NoHistoryError < StandardError; end
4
+
5
+ def __hyperstack_router_wrapper(&block)
6
+ if Hyperstack::Component::IsomorphicHelpers.on_opal_server?
7
+ ->() { __hyperstack_prerender_router(&block) }
8
+ else
9
+ ->() { __hyperstack_render_router(&block) }
10
+ end
11
+ end
12
+
13
+ def __eval_block(block)
14
+ result = instance_eval(&block)
15
+ if result.is_a?(String) ||
16
+ (result.respond_to?(:acts_as_string?) && result.acts_as_string?)
17
+ # hyper-mesh DummyValues respond to acts_as_string, and must
18
+ # be converted to spans INSIDE the parent, otherwise the waiting_on_resources
19
+ # flag will get set in the wrong context
20
+ result = Hyperstack::Internal::Component::RenderingContext
21
+ .render(:span) { result.to_s }
22
+ end
23
+ result
24
+ end
25
+
26
+ def __hyperstack_render_router(&block)
27
+ instance_eval do
28
+ self.class.history :browser unless history
29
+ React::Router::Router(history: history.to_n) do
30
+ __eval_block(block)
31
+ end
32
+ end
33
+ end
34
+
35
+ def __hyperstack_prerender_router(&block)
36
+ instance_eval do
37
+ pathname, search = Hyperstack::Internal::Router::IsomorphicMethods.request_fullpath.split('?', 2)
38
+ location = { pathname: pathname, search: search ? "?#{search}" : '' }.to_n
39
+ React::Router::StaticRouter(
40
+ location: location,
41
+ context: Hyperstack::Internal::Router::IsomorphicMethods.ctx
42
+ ) do
43
+ __eval_block(block)
44
+ end
45
+ end
46
+ end
47
+
4
48
  def self.included(base)
5
49
  base.extend(Hyperstack::Internal::Router::ClassMethods)
6
50
 
@@ -2,36 +2,24 @@ module Hyperstack
2
2
  module Router
3
3
  module Helpers
4
4
  def match
5
- if @__hyperstack_component_params_wrapper.param_accessor_style != :hyperstack
6
- params.match
7
- else
8
- @Match
9
- end
5
+ @_match_param
10
6
  end
11
7
 
12
8
  def location
13
- if @__hyperstack_component_params_wrapper.param_accessor_style != :hyperstack
14
- params.location
15
- else
16
- @Location
17
- end
9
+ @_location_param
18
10
  end
19
11
 
20
12
  def history
21
- if @__hyperstack_component_params_wrapper.param_accessor_style != :hyperstack
22
- params.history
23
- else
24
- @History
25
- end
13
+ @_history_param
26
14
  end
27
15
 
28
16
  def self.included(base)
29
17
  base.include(Hyperstack::Internal::Router::Helpers)
30
18
 
31
19
  base.class_eval do
32
- param :match, default: nil
33
- param :location, default: nil
34
- param :history, default: nil
20
+ param :match, default: nil, alias: :_match_param
21
+ param :location, default: nil, alias: :_location_param
22
+ param :history, default: nil, alias: :_history_param
35
23
  end
36
24
  end
37
25
  end
@@ -1,7 +1,7 @@
1
1
  module Hyperstack
2
2
  module Router
3
3
  class History
4
- include Native
4
+ include Native::Wrapper
5
5
 
6
6
  def initialize(native)
7
7
  @native = native
@@ -1,7 +1,7 @@
1
1
  module Hyperstack
2
2
  module Router
3
3
  class Location
4
- include Native
4
+ include Native::Wrapper
5
5
 
6
6
  def initialize(native)
7
7
  @native = native
@@ -1,7 +1,7 @@
1
1
  module Hyperstack
2
2
  module Router
3
3
  class Match
4
- include Native
4
+ include Native::Wrapper
5
5
 
6
6
  def initialize(native)
7
7
  @native = native
@@ -1,3 +1,3 @@
1
1
  module HyperRouter
2
- VERSION = '1.0.alpha1.1'
2
+ VERSION = '1.0.alpha1.6'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module React
2
2
  class Router
3
3
  class History
4
- include Native
4
+ include Native::Wrapper
5
5
 
6
6
  def self.current
7
7
  new(`History`)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyper-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.alpha1.1
4
+ version: 1.0.alpha1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam George
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-14 00:00:00.000000000 Z
12
+ date: 2021-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hyper-component
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.alpha1.1
20
+ version: 1.0.alpha1.6
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.alpha1.1
27
+ version: 1.0.alpha1.6
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: hyper-state
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 1.0.alpha1.1
34
+ version: 1.0.alpha1.6
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 1.0.alpha1.1
41
+ version: 1.0.alpha1.6
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: opal-browser
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: capybara
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: chromedriver-helper
86
72
  requirement: !ruby/object:Gem::Requirement
@@ -95,48 +81,34 @@ dependencies:
95
81
  - - ">="
96
82
  - !ruby/object:Gem::Version
97
83
  version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: database_cleaner
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
84
  - !ruby/object:Gem::Dependency
113
85
  name: hyper-spec
114
86
  requirement: !ruby/object:Gem::Requirement
115
87
  requirements:
116
88
  - - '='
117
89
  - !ruby/object:Gem::Version
118
- version: 1.0.alpha1.1
90
+ version: 1.0.alpha1.6
119
91
  type: :development
120
92
  prerelease: false
121
93
  version_requirements: !ruby/object:Gem::Requirement
122
94
  requirements:
123
95
  - - '='
124
96
  - !ruby/object:Gem::Version
125
- version: 1.0.alpha1.1
97
+ version: 1.0.alpha1.6
126
98
  - !ruby/object:Gem::Dependency
127
99
  name: hyper-store
128
100
  requirement: !ruby/object:Gem::Requirement
129
101
  requirements:
130
102
  - - '='
131
103
  - !ruby/object:Gem::Version
132
- version: 1.0.alpha1.1
104
+ version: 1.0.alpha1.6
133
105
  type: :development
134
106
  prerelease: false
135
107
  version_requirements: !ruby/object:Gem::Requirement
136
108
  requirements:
137
109
  - - '='
138
110
  - !ruby/object:Gem::Version
139
- version: 1.0.alpha1.1
111
+ version: 1.0.alpha1.6
140
112
  - !ruby/object:Gem::Dependency
141
113
  name: listen
142
114
  requirement: !ruby/object:Gem::Requirement
@@ -155,32 +127,52 @@ dependencies:
155
127
  name: mini_racer
156
128
  requirement: !ruby/object:Gem::Requirement
157
129
  requirements:
158
- - - "~>"
130
+ - - ">="
159
131
  - !ruby/object:Gem::Version
160
- version: 0.1.15
132
+ version: '0'
161
133
  type: :development
162
134
  prerelease: false
163
135
  version_requirements: !ruby/object:Gem::Requirement
164
136
  requirements:
165
- - - "~>"
137
+ - - ">="
166
138
  - !ruby/object:Gem::Version
167
- version: 0.1.15
139
+ version: '0'
168
140
  - !ruby/object:Gem::Dependency
169
141
  name: opal-rails
170
142
  requirement: !ruby/object:Gem::Requirement
171
143
  requirements:
172
- - - "~>"
144
+ - - ">="
173
145
  - !ruby/object:Gem::Version
174
146
  version: 0.9.4
147
+ - - "<"
148
+ - !ruby/object:Gem::Version
149
+ version: 2.0.0
175
150
  type: :development
176
151
  prerelease: false
177
152
  version_requirements: !ruby/object:Gem::Requirement
178
153
  requirements:
179
- - - "~>"
154
+ - - ">="
180
155
  - !ruby/object:Gem::Version
181
156
  version: 0.9.4
157
+ - - "<"
158
+ - !ruby/object:Gem::Version
159
+ version: 2.0.0
182
160
  - !ruby/object:Gem::Dependency
183
- name: parser
161
+ name: pry-rescue
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: pry-stack_explorer
184
176
  requirement: !ruby/object:Gem::Requirement
185
177
  requirements:
186
178
  - - ">="
@@ -213,14 +205,20 @@ dependencies:
213
205
  requirements:
214
206
  - - ">="
215
207
  - !ruby/object:Gem::Version
216
- version: 4.0.0
208
+ version: 5.0.0
209
+ - - "<"
210
+ - !ruby/object:Gem::Version
211
+ version: '7.0'
217
212
  type: :development
218
213
  prerelease: false
219
214
  version_requirements: !ruby/object:Gem::Requirement
220
215
  requirements:
221
216
  - - ">="
222
217
  - !ruby/object:Gem::Version
223
- version: 4.0.0
218
+ version: 5.0.0
219
+ - - "<"
220
+ - !ruby/object:Gem::Version
221
+ version: '7.0'
224
222
  - !ruby/object:Gem::Dependency
225
223
  name: rake
226
224
  requirement: !ruby/object:Gem::Requirement
@@ -319,20 +317,6 @@ dependencies:
319
317
  - - "~>"
320
318
  - !ruby/object:Gem::Version
321
319
  version: 2.1.1
322
- - !ruby/object:Gem::Dependency
323
- name: selenium-webdriver
324
- requirement: !ruby/object:Gem::Requirement
325
- requirements:
326
- - - ">="
327
- - !ruby/object:Gem::Version
328
- version: '0'
329
- type: :development
330
- prerelease: false
331
- version_requirements: !ruby/object:Gem::Requirement
332
- requirements:
333
- - - ">="
334
- - !ruby/object:Gem::Version
335
- version: '0'
336
320
  - !ruby/object:Gem::Dependency
337
321
  name: shoulda
338
322
  requirement: !ruby/object:Gem::Requirement
@@ -361,48 +345,20 @@ dependencies:
361
345
  - - ">="
362
346
  - !ruby/object:Gem::Version
363
347
  version: '0'
364
- - !ruby/object:Gem::Dependency
365
- name: sinatra
366
- requirement: !ruby/object:Gem::Requirement
367
- requirements:
368
- - - ">="
369
- - !ruby/object:Gem::Version
370
- version: '0'
371
- type: :development
372
- prerelease: false
373
- version_requirements: !ruby/object:Gem::Requirement
374
- requirements:
375
- - - ">="
376
- - !ruby/object:Gem::Version
377
- version: '0'
378
- - !ruby/object:Gem::Dependency
379
- name: spring-commands-rspec
380
- requirement: !ruby/object:Gem::Requirement
381
- requirements:
382
- - - ">="
383
- - !ruby/object:Gem::Version
384
- version: '0'
385
- type: :development
386
- prerelease: false
387
- version_requirements: !ruby/object:Gem::Requirement
388
- requirements:
389
- - - ">="
390
- - !ruby/object:Gem::Version
391
- version: '0'
392
348
  - !ruby/object:Gem::Dependency
393
349
  name: sqlite3
394
350
  requirement: !ruby/object:Gem::Requirement
395
351
  requirements:
396
- - - ">="
352
+ - - "~>"
397
353
  - !ruby/object:Gem::Version
398
- version: '0'
354
+ version: 1.4.2
399
355
  type: :development
400
356
  prerelease: false
401
357
  version_requirements: !ruby/object:Gem::Requirement
402
358
  requirements:
403
- - - ">="
359
+ - - "~>"
404
360
  - !ruby/object:Gem::Version
405
- version: '0'
361
+ version: 1.4.2
406
362
  - !ruby/object:Gem::Dependency
407
363
  name: timecop
408
364
  requirement: !ruby/object:Gem::Requirement
@@ -417,34 +373,6 @@ dependencies:
417
373
  - - "~>"
418
374
  - !ruby/object:Gem::Version
419
375
  version: 0.8.1
420
- - !ruby/object:Gem::Dependency
421
- name: unparser
422
- requirement: !ruby/object:Gem::Requirement
423
- requirements:
424
- - - ">="
425
- - !ruby/object:Gem::Version
426
- version: '0'
427
- type: :development
428
- prerelease: false
429
- version_requirements: !ruby/object:Gem::Requirement
430
- requirements:
431
- - - ">="
432
- - !ruby/object:Gem::Version
433
- version: '0'
434
- - !ruby/object:Gem::Dependency
435
- name: webdrivers
436
- requirement: !ruby/object:Gem::Requirement
437
- requirements:
438
- - - ">="
439
- - !ruby/object:Gem::Version
440
- version: '0'
441
- type: :development
442
- prerelease: false
443
- version_requirements: !ruby/object:Gem::Requirement
444
- requirements:
445
- - - ">="
446
- - !ruby/object:Gem::Version
447
- version: '0'
448
376
  description: Adds the ability to write and use the react-router in Ruby through Opal
449
377
  email:
450
378
  - adamgeorge.31@gmail.com
@@ -491,8 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
491
419
  - !ruby/object:Gem::Version
492
420
  version: 1.3.1
493
421
  requirements: []
494
- rubyforge_project:
495
- rubygems_version: 2.7.8
422
+ rubygems_version: 3.0.8
496
423
  signing_key:
497
424
  specification_version: 4
498
425
  summary: hyper-router for Opal, part of the hyperstack framework