stimulus_reflex 3.3.0.pre5 → 3.3.0.pre6
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 +24 -4
- data/Gemfile.lock +1 -1
- data/lib/stimulus_reflex.rb +3 -62
- data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +1 -1
- data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +2 -2
- data/lib/stimulus_reflex/channel.rb +12 -1
- data/lib/stimulus_reflex/sanity_checker.rb +80 -0
- data/lib/stimulus_reflex/version.rb +1 -1
- data/test/generators/stimulus_reflex_generator_test.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c8542f86c6a95d6528f7c9838c8ca9084c7ebb938e0d1271837e3dfd1d34219
|
|
4
|
+
data.tar.gz: 2881c8a442b7854dda4c6ac1625d9b8466997c5175bcc4ee319aa0bfb5a95153
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9efb56d48030a6b2264f9db47330baee93d47407b90e021c49a77ff6339d382a767089ec02b6c2adad40ce965332fe1457e8e30dadfdf8f38e9a9c15d8f16d58
|
|
7
|
+
data.tar.gz: 52d7ee2200946cfec45758f224acbb354e2aee5eab4ad4a7cddcdcbc3d4ba34afba461876c63bfe8dffaabde2f9527f5093ad9560b789158510b8acf74b7242a
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased](https://github.com/hopsoft/stimulus_reflex/tree/HEAD)
|
|
4
4
|
|
|
5
|
-
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.
|
|
5
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.pre5...HEAD)
|
|
6
|
+
|
|
7
|
+
**Implemented enhancements:**
|
|
8
|
+
|
|
9
|
+
- Support for token-based authentication [\#243](https://github.com/hopsoft/stimulus_reflex/pull/243) ([leastbad](https://github.com/leastbad))
|
|
10
|
+
|
|
11
|
+
**Closed issues:**
|
|
12
|
+
|
|
13
|
+
- Authorization [\#292](https://github.com/hopsoft/stimulus_reflex/issues/292)
|
|
14
|
+
- Params incorrect for form submitted for nested resource [\#290](https://github.com/hopsoft/stimulus_reflex/issues/290)
|
|
15
|
+
- Use set I18n.locale in Reflexes with Selector Morphs [\#280](https://github.com/hopsoft/stimulus_reflex/issues/280)
|
|
16
|
+
|
|
17
|
+
**Merged pull requests:**
|
|
18
|
+
|
|
19
|
+
- fixes and tweaks to client logging subsystem [\#313](https://github.com/hopsoft/stimulus_reflex/pull/313) ([leastbad](https://github.com/leastbad))
|
|
20
|
+
- add ready event after setupDeclarativeReflexes [\#312](https://github.com/hopsoft/stimulus_reflex/pull/312) ([leastbad](https://github.com/leastbad))
|
|
21
|
+
- Refactor sanity checks on boot [\#311](https://github.com/hopsoft/stimulus_reflex/pull/311) ([excid3](https://github.com/excid3))
|
|
22
|
+
|
|
23
|
+
## [v3.3.0.pre5](https://github.com/hopsoft/stimulus_reflex/tree/v3.3.0.pre5) (2020-09-18)
|
|
24
|
+
|
|
25
|
+
[Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.pre4...v3.3.0.pre5)
|
|
6
26
|
|
|
7
27
|
**Implemented enhancements:**
|
|
8
28
|
|
|
@@ -486,7 +506,9 @@
|
|
|
486
506
|
**Implemented enhancements:**
|
|
487
507
|
|
|
488
508
|
- Custom Stimulus schema breaks Reflex [\#91](https://github.com/hopsoft/stimulus_reflex/issues/91)
|
|
509
|
+
- Add schema support [\#94](https://github.com/hopsoft/stimulus_reflex/pull/94) ([hopsoft](https://github.com/hopsoft))
|
|
489
510
|
- inherit stimulus schema [\#92](https://github.com/hopsoft/stimulus_reflex/pull/92) ([nickyvanurk](https://github.com/nickyvanurk))
|
|
511
|
+
- Single source of truth [\#76](https://github.com/hopsoft/stimulus_reflex/pull/76) ([leastbad](https://github.com/leastbad))
|
|
490
512
|
|
|
491
513
|
**Fixed bugs:**
|
|
492
514
|
|
|
@@ -505,7 +527,6 @@
|
|
|
505
527
|
|
|
506
528
|
**Implemented enhancements:**
|
|
507
529
|
|
|
508
|
-
- Single source of truth [\#76](https://github.com/hopsoft/stimulus_reflex/pull/76) ([leastbad](https://github.com/leastbad))
|
|
509
530
|
- Add CodeFund sponsorship [\#75](https://github.com/hopsoft/stimulus_reflex/pull/75) ([coderberry](https://github.com/coderberry))
|
|
510
531
|
|
|
511
532
|
**Fixed bugs:**
|
|
@@ -519,11 +540,9 @@
|
|
|
519
540
|
**Implemented enhancements:**
|
|
520
541
|
|
|
521
542
|
- Create Rails generators [\#3](https://github.com/hopsoft/stimulus_reflex/issues/3)
|
|
522
|
-
- Add schema support [\#94](https://github.com/hopsoft/stimulus_reflex/pull/94) ([hopsoft](https://github.com/hopsoft))
|
|
523
543
|
- Update installer [\#71](https://github.com/hopsoft/stimulus_reflex/pull/71) ([hopsoft](https://github.com/hopsoft))
|
|
524
544
|
- Tweak generators [\#69](https://github.com/hopsoft/stimulus_reflex/pull/69) ([hopsoft](https://github.com/hopsoft))
|
|
525
545
|
- add generators [\#67](https://github.com/hopsoft/stimulus_reflex/pull/67) ([andrewmcodes](https://github.com/andrewmcodes))
|
|
526
|
-
- Add reflex name to the lifecycle args [\#62](https://github.com/hopsoft/stimulus_reflex/pull/62) ([hopsoft](https://github.com/hopsoft))
|
|
527
546
|
|
|
528
547
|
**Fixed bugs:**
|
|
529
548
|
|
|
@@ -552,6 +571,7 @@
|
|
|
552
571
|
- Client side call-backs? [\#34](https://github.com/hopsoft/stimulus_reflex/issues/34)
|
|
553
572
|
- Scoped register\(\)? [\#26](https://github.com/hopsoft/stimulus_reflex/issues/26)
|
|
554
573
|
- Add guard to verify same URL prior to morph [\#63](https://github.com/hopsoft/stimulus_reflex/pull/63) ([hopsoft](https://github.com/hopsoft))
|
|
574
|
+
- Add reflex name to the lifecycle args [\#62](https://github.com/hopsoft/stimulus_reflex/pull/62) ([hopsoft](https://github.com/hopsoft))
|
|
555
575
|
- Refactor some helper methods out of main file [\#61](https://github.com/hopsoft/stimulus_reflex/pull/61) ([hopsoft](https://github.com/hopsoft))
|
|
556
576
|
- Documentation update [\#58](https://github.com/hopsoft/stimulus_reflex/pull/58) ([leastbad](https://github.com/leastbad))
|
|
557
577
|
- \# Support for data-reflex-permanent [\#57](https://github.com/hopsoft/stimulus_reflex/pull/57) ([hopsoft](https://github.com/hopsoft))
|
data/Gemfile.lock
CHANGED
data/lib/stimulus_reflex.rb
CHANGED
|
@@ -12,6 +12,7 @@ require "stimulus_reflex/version"
|
|
|
12
12
|
require "stimulus_reflex/reflex"
|
|
13
13
|
require "stimulus_reflex/element"
|
|
14
14
|
require "stimulus_reflex/channel"
|
|
15
|
+
require "stimulus_reflex/sanity_checker"
|
|
15
16
|
require "stimulus_reflex/broadcasters/broadcaster"
|
|
16
17
|
require "stimulus_reflex/broadcasters/nothing_broadcaster"
|
|
17
18
|
require "stimulus_reflex/broadcasters/page_broadcaster"
|
|
@@ -20,68 +21,8 @@ require "generators/stimulus_reflex_generator"
|
|
|
20
21
|
|
|
21
22
|
module StimulusReflex
|
|
22
23
|
class Engine < Rails::Engine
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
initializer "stimulus_reflex.verify_caching_enabled" do
|
|
27
|
-
unless caching_enabled?
|
|
28
|
-
puts <<~WARN
|
|
29
|
-
Stimulus Reflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.
|
|
30
|
-
To enable caching in development, run:
|
|
31
|
-
|
|
32
|
-
rails dev:cache
|
|
33
|
-
WARN
|
|
34
|
-
exit
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
initializer "stimulus_reflex.verify_npm_package_version" do
|
|
39
|
-
unless node_version_matches?
|
|
40
|
-
puts <<~WARN
|
|
41
|
-
The Stimulus Reflex javascript package version (#{node_package_version}) does not match the Rubygem version (#{gem_version}).
|
|
42
|
-
To update the Stimulus Reflex node module:
|
|
43
|
-
|
|
44
|
-
yarn upgrade stimulus_reflex@#{gem_version}
|
|
45
|
-
WARN
|
|
46
|
-
exit
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def caching_enabled?
|
|
53
|
-
Rails.application.config.action_controller.perform_caching &&
|
|
54
|
-
Rails.application.config.cache_store != :null_store
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def node_version_matches?
|
|
58
|
-
node_package_version == gem_version
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def gem_version
|
|
62
|
-
StimulusReflex::VERSION.gsub(".pre", "-pre")
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def node_package_version
|
|
66
|
-
match = File.foreach(yarn_lock_path).grep(/^stimulus_reflex/)
|
|
67
|
-
return match.first[NODE_VERSION_FORMAT, 1] if match.present?
|
|
68
|
-
|
|
69
|
-
match = File.foreach(yarn_link_path).grep(/version/)
|
|
70
|
-
return match.first[JSON_VERSION_FORMAT, 1] if match.present?
|
|
71
|
-
|
|
72
|
-
puts <<~WARN
|
|
73
|
-
Can't locate the stimulus_reflex NPM package.
|
|
74
|
-
Either add it to your package.json as a dependency or use "yarn link stimulus_reflex" if you are doing development.
|
|
75
|
-
WARN
|
|
76
|
-
exit
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def yarn_lock_path
|
|
80
|
-
Rails.root.join("yarn.lock")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def yarn_link_path
|
|
84
|
-
Rails.root.join("node_modules", "stimulus_reflex", "package.json")
|
|
24
|
+
initializer "stimulus_reflex.sanity_check" do
|
|
25
|
+
SanityChecker.check!
|
|
85
26
|
end
|
|
86
27
|
end
|
|
87
28
|
end
|
|
@@ -17,7 +17,7 @@ module StimulusReflex
|
|
|
17
17
|
children_only: true,
|
|
18
18
|
permanent_attribute_name: permanent_attribute_name,
|
|
19
19
|
stimulus_reflex: data.merge({
|
|
20
|
-
|
|
20
|
+
broadcaster: to_sym
|
|
21
21
|
})
|
|
22
22
|
)
|
|
23
23
|
else
|
|
@@ -25,7 +25,7 @@ module StimulusReflex
|
|
|
25
25
|
selector: selector,
|
|
26
26
|
html: fragment.to_html,
|
|
27
27
|
stimulus_reflex: data.merge({
|
|
28
|
-
|
|
28
|
+
broadcaster: to_sym
|
|
29
29
|
})
|
|
30
30
|
)
|
|
31
31
|
end
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module ApplicationCable
|
|
4
|
+
class Channel < ActionCable::Channel::Base
|
|
5
|
+
def initialize(connection, identifier, params = {})
|
|
6
|
+
super
|
|
7
|
+
application_channel = Rails.root.join("app", "channels", "application_cable", "channel.rb")
|
|
8
|
+
require application_channel if File.exist?(application_channel)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class StimulusReflex::Channel < ApplicationCable::Channel
|
|
4
14
|
def stream_name
|
|
5
15
|
ids = connection.identifiers.map { |identifier| send(identifier).try(:id) || send(identifier) }
|
|
6
16
|
[
|
|
@@ -10,6 +20,7 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
|
|
|
10
20
|
end
|
|
11
21
|
|
|
12
22
|
def subscribed
|
|
23
|
+
super
|
|
13
24
|
stream_from stream_name
|
|
14
25
|
end
|
|
15
26
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class StimulusReflex::SanityChecker
|
|
4
|
+
NODE_VERSION_FORMAT = /(\d+\.\d+\.\d+.*):/
|
|
5
|
+
JSON_VERSION_FORMAT = /(\d+\.\d+\.\d+.*)"/
|
|
6
|
+
|
|
7
|
+
def self.check!
|
|
8
|
+
instance = new
|
|
9
|
+
instance.check_caching_enabled
|
|
10
|
+
instance.check_javascript_package_version
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def check_caching_enabled
|
|
14
|
+
unless caching_enabled?
|
|
15
|
+
puts <<~WARN
|
|
16
|
+
WARNING: Stimulus Reflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.
|
|
17
|
+
To enable caching in development, run:
|
|
18
|
+
rails dev:cache
|
|
19
|
+
WARN
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def check_javascript_package_version
|
|
24
|
+
if javascript_package_version.nil?
|
|
25
|
+
puts <<~WARN
|
|
26
|
+
WARNING: Can't locate the stimulus_reflex NPM package.
|
|
27
|
+
Either add it to your package.json as a dependency or use "yarn link stimulus_reflex" if you are doing development.
|
|
28
|
+
WARN
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
unless javascript_version_matches?
|
|
32
|
+
puts <<~WARN
|
|
33
|
+
WARNING: The Stimulus Reflex javascript package version (#{javascript_package_version}) does not match the Rubygem version (#{gem_version}).
|
|
34
|
+
To update the Stimulus Reflex npm package:
|
|
35
|
+
yarn upgrade stimulus_reflex@#{gem_version}
|
|
36
|
+
WARN
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def caching_enabled?
|
|
43
|
+
Rails.application.config.action_controller.perform_caching &&
|
|
44
|
+
Rails.application.config.cache_store != :null_store
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def javascript_version_matches?
|
|
48
|
+
javascript_package_version == gem_version
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def gem_version
|
|
52
|
+
@_gem_version ||= StimulusReflex::VERSION.gsub(".pre", "-pre")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def javascript_package_version
|
|
56
|
+
return @_js_version if defined?(@_js_version)
|
|
57
|
+
@_js_version = find_javascript_package_version
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def find_javascript_package_version
|
|
61
|
+
if (match = search_file(yarn_lock_path, regex: /^stimulus_reflex/))
|
|
62
|
+
match[NODE_VERSION_FORMAT, 1]
|
|
63
|
+
elsif (match = search_file(yarn_link_path, regex: /version/))
|
|
64
|
+
match[JSON_VERSION_FORMAT, 1]
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def search_file(path, regex:)
|
|
69
|
+
return unless File.exist?(path)
|
|
70
|
+
File.foreach(path).grep(regex).first
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def yarn_lock_path
|
|
74
|
+
Rails.root.join("yarn.lock")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def yarn_link_path
|
|
78
|
+
Rails.root.join("node_modules", "stimulus_reflex", "package.json")
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -11,7 +11,7 @@ class StimulusReflexGeneratorTest < Rails::Generators::TestCase
|
|
|
11
11
|
test "creates singular named controller and reflex files" do
|
|
12
12
|
run_generator %w[demo]
|
|
13
13
|
assert_file "app/javascript/controllers/application_controller.js"
|
|
14
|
-
assert_file "app/javascript/controllers/demo_controller.js", /
|
|
14
|
+
assert_file "app/javascript/controllers/demo_controller.js", /Demo/
|
|
15
15
|
assert_file "app/reflexes/application_reflex.rb"
|
|
16
16
|
assert_file "app/reflexes/demo_reflex.rb", /DemoReflex/
|
|
17
17
|
end
|
|
@@ -19,7 +19,7 @@ class StimulusReflexGeneratorTest < Rails::Generators::TestCase
|
|
|
19
19
|
test "creates plural named controller and reflex files" do
|
|
20
20
|
run_generator %w[posts]
|
|
21
21
|
assert_file "app/javascript/controllers/application_controller.js"
|
|
22
|
-
assert_file "app/javascript/controllers/posts_controller.js", /
|
|
22
|
+
assert_file "app/javascript/controllers/posts_controller.js", /Posts/
|
|
23
23
|
assert_file "app/reflexes/application_reflex.rb"
|
|
24
24
|
assert_file "app/reflexes/posts_reflex.rb", /PostsReflex/
|
|
25
25
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stimulus_reflex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.3.0.
|
|
4
|
+
version: 3.3.0.pre6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Hopkins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-09-
|
|
11
|
+
date: 2020-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -183,6 +183,7 @@ files:
|
|
|
183
183
|
- lib/stimulus_reflex/channel.rb
|
|
184
184
|
- lib/stimulus_reflex/element.rb
|
|
185
185
|
- lib/stimulus_reflex/reflex.rb
|
|
186
|
+
- lib/stimulus_reflex/sanity_checker.rb
|
|
186
187
|
- lib/stimulus_reflex/version.rb
|
|
187
188
|
- lib/tasks/stimulus_reflex/install.rake
|
|
188
189
|
- test/generators/stimulus_reflex_generator_test.rb
|