stimulus_reflex 3.3.0 → 3.4.0.pre4

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +113 -8
  3. data/Gemfile.lock +70 -69
  4. data/README.md +6 -3
  5. data/{lib → app/channels}/stimulus_reflex/channel.rb +36 -21
  6. data/lib/generators/stimulus_reflex/config_generator.rb +14 -0
  7. data/lib/generators/{stimulus_reflex_generator.rb → stimulus_reflex/stimulus_reflex_generator.rb} +0 -0
  8. data/lib/generators/{templates → stimulus_reflex/templates}/app/javascript/controllers/%file_name%_controller.js.tt +0 -0
  9. data/lib/generators/{templates → stimulus_reflex/templates}/app/javascript/controllers/application_controller.js.tt +0 -0
  10. data/lib/generators/{templates → stimulus_reflex/templates}/app/reflexes/%file_name%_reflex.rb.tt +0 -0
  11. data/lib/generators/{templates → stimulus_reflex/templates}/app/reflexes/application_reflex.rb.tt +0 -0
  12. data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +20 -0
  13. data/lib/stimulus_reflex.rb +3 -2
  14. data/lib/stimulus_reflex/broadcasters/broadcaster.rb +12 -9
  15. data/lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb +4 -0
  16. data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +8 -3
  17. data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +12 -2
  18. data/lib/stimulus_reflex/configuration.rb +27 -0
  19. data/lib/stimulus_reflex/element.rb +8 -0
  20. data/lib/stimulus_reflex/logger.rb +106 -0
  21. data/lib/stimulus_reflex/reflex.rb +29 -22
  22. data/lib/stimulus_reflex/sanity_checker.rb +82 -22
  23. data/lib/stimulus_reflex/utils/colorize.rb +23 -0
  24. data/lib/stimulus_reflex/version.rb +1 -1
  25. data/lib/tasks/stimulus_reflex/install.rake +12 -8
  26. data/package.json +57 -0
  27. data/stimulus_reflex.gemspec +40 -0
  28. data/tags +98 -0
  29. data/test/broadcasters/broadcaster_test.rb +15 -0
  30. data/test/broadcasters/nothing_broadcaster_test.rb +34 -0
  31. data/test/broadcasters/page_broadcaster_test.rb +69 -0
  32. data/test/broadcasters/selector_broadcaster_test.rb +83 -0
  33. data/test/generators/stimulus_reflex_generator_test.rb +1 -0
  34. data/test/test_helper.rb +2 -0
  35. data/test/tmp/app/reflexes/application_reflex.rb +12 -0
  36. data/test/tmp/app/reflexes/posts_reflex.rb +24 -0
  37. data/yarn.lock +4685 -0
  38. metadata +42 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8b04fb348bbf5ebfb86274f76f84bd70877490d96adb0b435d9108288e414ea
4
- data.tar.gz: '082d8a0bf06b806c5bf717455a3698c59a3f75b40e16a062f1361e7931ea5692'
3
+ metadata.gz: 1d3b9110da6cd9d446b19c1bd8ac2978b1d8b0c5ca88d1a1cf9fb849400a1757
4
+ data.tar.gz: 5512ece82357de04c62f9c4fcff9bba59bf6dec9f9234effeb06772084e96d38
5
5
  SHA512:
6
- metadata.gz: d5e9b636b0869a338da5be3fb5dc5a35f582a94d28c76896c6e58964097af8670367ae66c691ac4a379492be362c445ec46fe9ddaaf5cc148c73bb0becb473aa
7
- data.tar.gz: 3008e7ba71def33ae0b0774f9bd8cd716574a1877f62732c417e25bf20d4f9e29680f94ba587f051606a9bc2480fc7a7bc9879096e5029686b87ecd3c0b01960
6
+ metadata.gz: 928a0b20cc704cb30a1a9c7ccfe7672cc44c2e8cce2f9387b87ddc531981b2521e926992271233fb18e7787121bcda84e4f90c64823d32f5c2824ad302ba24e4
7
+ data.tar.gz: da166747c83c5dfee363e6a9475826cb32d3ba850f997481539cfdd475e390614e7726083bdf7e18762f410d4b74ff8b031922a66647498937d065479e939002
@@ -2,7 +2,115 @@
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.pre5...HEAD)
5
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre3...HEAD)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fix fatal error in `stimulus\_reflex:install` task with Rails 5.2 [\#371](https://github.com/hopsoft/stimulus_reflex/pull/371) ([Matt-Yorkley](https://github.com/Matt-Yorkley))
10
+ - fix nothing morphs and error messages [\#368](https://github.com/hopsoft/stimulus_reflex/pull/368) ([leastbad](https://github.com/leastbad))
11
+
12
+ **Closed issues:**
13
+
14
+ - `stimulus\_reflex:install` fails to complete in Rails 5.2 [\#367](https://github.com/hopsoft/stimulus_reflex/issues/367)
15
+ - Form data still not captured [\#366](https://github.com/hopsoft/stimulus_reflex/issues/366)
16
+ - Console exception when reflex does not update a page that didn't trigger the reflex [\#363](https://github.com/hopsoft/stimulus_reflex/issues/363)
17
+ - Improve server-side logging options [\#264](https://github.com/hopsoft/stimulus_reflex/issues/264)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - use puts instead of ActionCable.logger to sidestep silenced AC logs [\#373](https://github.com/hopsoft/stimulus_reflex/pull/373) ([leastbad](https://github.com/leastbad))
22
+ - Improve logged post\_install.js message [\#372](https://github.com/hopsoft/stimulus_reflex/pull/372) ([forsbergplustwo](https://github.com/forsbergplustwo))
23
+ - Pass additional reflex-related data to reflex from data [\#370](https://github.com/hopsoft/stimulus_reflex/pull/370) ([joshleblanc](https://github.com/joshleblanc))
24
+ - fix: rip out microbundle [\#369](https://github.com/hopsoft/stimulus_reflex/pull/369) ([ParamagicDev](https://github.com/ParamagicDev))
25
+ - Add tests for broadcasters [\#364](https://github.com/hopsoft/stimulus_reflex/pull/364) ([julianrubisch](https://github.com/julianrubisch))
26
+ - Do not run sanity check on `rails generate stimulus\_reflex:config` [\#362](https://github.com/hopsoft/stimulus_reflex/pull/362) ([RolandStuder](https://github.com/RolandStuder))
27
+ - fix: revert CR and @rails/actioncable to dependencies [\#361](https://github.com/hopsoft/stimulus_reflex/pull/361) ([ParamagicDev](https://github.com/ParamagicDev))
28
+ - xpath fix [\#360](https://github.com/hopsoft/stimulus_reflex/pull/360) ([leastbad](https://github.com/leastbad))
29
+
30
+ ## [v3.4.0.pre3](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre3) (2020-11-11)
31
+
32
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre2...v3.4.0.pre3)
33
+
34
+ **Merged pull requests:**
35
+
36
+ - Allow to supress warnings for sanity checks [\#359](https://github.com/hopsoft/stimulus_reflex/pull/359) ([RolandStuder](https://github.com/RolandStuder))
37
+ - serializeForm: only append given input if element is submit button [\#357](https://github.com/hopsoft/stimulus_reflex/pull/357) ([marcoroth](https://github.com/marcoroth))
38
+ - Update package.json to 3.4.0-pre2 [\#356](https://github.com/hopsoft/stimulus_reflex/pull/356) ([marcoroth](https://github.com/marcoroth))
39
+ - Fix elementToXPath import [\#355](https://github.com/hopsoft/stimulus_reflex/pull/355) ([julianrubisch](https://github.com/julianrubisch))
40
+ - Add guard clause to return valid empty form data [\#354](https://github.com/hopsoft/stimulus_reflex/pull/354) ([julianrubisch](https://github.com/julianrubisch))
41
+ - simplify xpath functions [\#353](https://github.com/hopsoft/stimulus_reflex/pull/353) ([leastbad](https://github.com/leastbad))
42
+ - pass reflex id to reflex [\#352](https://github.com/hopsoft/stimulus_reflex/pull/352) ([joshleblanc](https://github.com/joshleblanc))
43
+
44
+ ## [v3.4.0.pre2](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre2) (2020-11-06)
45
+
46
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre1...v3.4.0.pre2)
47
+
48
+ **Closed issues:**
49
+
50
+ - Regression in version 3.4.0-pre1: Cannot find module `cable\_ready` [\#350](https://github.com/hopsoft/stimulus_reflex/issues/350)
51
+
52
+ **Merged pull requests:**
53
+
54
+ - move `cable\_ready` to development dependencies [\#351](https://github.com/hopsoft/stimulus_reflex/pull/351) ([marcoroth](https://github.com/marcoroth))
55
+ - Fix serializeForm initialization [\#349](https://github.com/hopsoft/stimulus_reflex/pull/349) ([marcoroth](https://github.com/marcoroth))
56
+
57
+ ## [v3.4.0.pre1](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre1) (2020-11-03)
58
+
59
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre0...v3.4.0.pre1)
60
+
61
+ ## [v3.4.0.pre0](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre0) (2020-11-02)
62
+
63
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0...v3.4.0.pre0)
64
+
65
+ **Implemented enhancements:**
66
+
67
+ - Move StimulusReflex::Channel to app/ and allow for a configurable parent channel [\#346](https://github.com/hopsoft/stimulus_reflex/pull/346) ([leastbad](https://github.com/leastbad))
68
+ - tab isolation mode v2 [\#335](https://github.com/hopsoft/stimulus_reflex/pull/335) ([leastbad](https://github.com/leastbad))
69
+ - Delegate flash to the request [\#334](https://github.com/hopsoft/stimulus_reflex/pull/334) ([hopsoft](https://github.com/hopsoft))
70
+ - Opt-in form serialization & params overriding [\#325](https://github.com/hopsoft/stimulus_reflex/pull/325) ([s-s](https://github.com/s-s))
71
+ - Exit on failed sanity check, provide config to skip exit [\#318](https://github.com/hopsoft/stimulus_reflex/pull/318) ([RolandStuder](https://github.com/RolandStuder))
72
+
73
+ **Fixed bugs:**
74
+
75
+ - Console exception when reflex updates a page that didn't trigger the update [\#336](https://github.com/hopsoft/stimulus_reflex/issues/336)
76
+ - AlpineJS components not reinitalised after reflex [\#329](https://github.com/hopsoft/stimulus_reflex/issues/329)
77
+ - Encoding changes from UTF-8 to ASCII-8BIT [\#202](https://github.com/hopsoft/stimulus_reflex/issues/202)
78
+
79
+ **Closed issues:**
80
+
81
+ - ActionController::RoutingError with Rails 6 Engines [\#342](https://github.com/hopsoft/stimulus_reflex/issues/342)
82
+ - Wrong input name parsing [\#321](https://github.com/hopsoft/stimulus_reflex/issues/321)
83
+ - Stimulus' controllers are not reconnecting after reflex, why? [\#314](https://github.com/hopsoft/stimulus_reflex/issues/314)
84
+ - Rendering issue [\#289](https://github.com/hopsoft/stimulus_reflex/issues/289)
85
+ - Documentation Request for a Rails 6.x app with 5.2 defaults [\#265](https://github.com/hopsoft/stimulus_reflex/issues/265)
86
+
87
+ **Merged pull requests:**
88
+
89
+ - \[docs\] StimulusReflex.debug= on left hand side [\#348](https://github.com/hopsoft/stimulus_reflex/pull/348) ([drnic](https://github.com/drnic))
90
+ - Fix page morphs inside Rails engines [\#344](https://github.com/hopsoft/stimulus_reflex/pull/344) ([leastbad](https://github.com/leastbad))
91
+ - Use Webpacker folder if available [\#343](https://github.com/hopsoft/stimulus_reflex/pull/343) ([coorasse](https://github.com/coorasse))
92
+ - feat: create a more robust package.json [\#340](https://github.com/hopsoft/stimulus_reflex/pull/340) ([ParamagicDev](https://github.com/ParamagicDev))
93
+ - Make StimulusReflex configurable and add an initializer [\#339](https://github.com/hopsoft/stimulus_reflex/pull/339) ([RolandStuder](https://github.com/RolandStuder))
94
+ - Aliases method\_name to action\_name [\#338](https://github.com/hopsoft/stimulus_reflex/pull/338) ([obie](https://github.com/obie))
95
+ - remove isolate concept and make behavior default [\#332](https://github.com/hopsoft/stimulus_reflex/pull/332) ([leastbad](https://github.com/leastbad))
96
+ - add signed/unsigned accessors to element [\#330](https://github.com/hopsoft/stimulus_reflex/pull/330) ([joshleblanc](https://github.com/joshleblanc))
97
+ - merge environment into ApplicationController and descendants [\#328](https://github.com/hopsoft/stimulus_reflex/pull/328) ([leastbad](https://github.com/leastbad))
98
+ - Move form-data merge logic to the server-side [\#327](https://github.com/hopsoft/stimulus_reflex/pull/327) ([marcoroth](https://github.com/marcoroth))
99
+ - fix for PR\#317 which was preventing server messages [\#326](https://github.com/hopsoft/stimulus_reflex/pull/326) ([leastbad](https://github.com/leastbad))
100
+ - introduce tab isolation mode [\#324](https://github.com/hopsoft/stimulus_reflex/pull/324) ([leastbad](https://github.com/leastbad))
101
+ - Force request encodings to be UTF-8 instead of ASCII-8BIT after a reflex [\#320](https://github.com/hopsoft/stimulus_reflex/pull/320) ([marcoroth](https://github.com/marcoroth))
102
+ - Append short section about resetting a form [\#319](https://github.com/hopsoft/stimulus_reflex/pull/319) ([julianrubisch](https://github.com/julianrubisch))
103
+ - lifecycle refactor: introduce new finalize stage, global reflexes dictionary [\#317](https://github.com/hopsoft/stimulus_reflex/pull/317) ([leastbad](https://github.com/leastbad))
104
+ - Update events.md [\#316](https://github.com/hopsoft/stimulus_reflex/pull/316) ([gahia](https://github.com/gahia))
105
+ - Proposal: Reduce bundle size and add a bundler for Stimulus Reflex javascript [\#315](https://github.com/hopsoft/stimulus_reflex/pull/315) ([ParamagicDev](https://github.com/ParamagicDev))
106
+
107
+ ## [v3.3.0](https://github.com/hopsoft/stimulus_reflex/tree/v3.3.0) (2020-09-22)
108
+
109
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.pre6...v3.3.0)
110
+
111
+ ## [v3.3.0.pre6](https://github.com/hopsoft/stimulus_reflex/tree/v3.3.0.pre6) (2020-09-20)
112
+
113
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0.pre5...v3.3.0.pre6)
6
114
 
7
115
  **Implemented enhancements:**
8
116
 
@@ -197,10 +305,6 @@
197
305
 
198
306
  [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.2.pre0...v3.2.2.pre1)
199
307
 
200
- **Implemented enhancements:**
201
-
202
- - Make element even more user friendly [\#210](https://github.com/hopsoft/stimulus_reflex/pull/210) ([hopsoft](https://github.com/hopsoft))
203
-
204
308
  **Fixed bugs:**
205
309
 
206
310
  - Session lost after throw :abort [\#221](https://github.com/hopsoft/stimulus_reflex/issues/221)
@@ -219,6 +323,7 @@
219
323
  - Add a halted lifecycle event [\#190](https://github.com/hopsoft/stimulus_reflex/issues/190)
220
324
  - Allow extractElementAttributes to use a checkbox list [\#147](https://github.com/hopsoft/stimulus_reflex/issues/147)
221
325
  - reflex\_name restriction loosening [\#212](https://github.com/hopsoft/stimulus_reflex/pull/212) ([leastbad](https://github.com/leastbad))
326
+ - Make element even more user friendly [\#210](https://github.com/hopsoft/stimulus_reflex/pull/210) ([hopsoft](https://github.com/hopsoft))
222
327
  - Form parameters [\#204](https://github.com/hopsoft/stimulus_reflex/pull/204) ([jasoncharnes](https://github.com/jasoncharnes))
223
328
  - Map hashes in incoming arguments using with\_indifferent\_access [\#203](https://github.com/hopsoft/stimulus_reflex/pull/203) ([jaredcwhite](https://github.com/jaredcwhite))
224
329
  - Combine dataset with data-attributes from parent elements on reflex call [\#200](https://github.com/hopsoft/stimulus_reflex/pull/200) ([marcoroth](https://github.com/marcoroth))
@@ -244,7 +349,7 @@
244
349
  - Loosen Rails requirement to 5.2 with instructions [\#205](https://github.com/hopsoft/stimulus_reflex/pull/205) ([jasoncharnes](https://github.com/jasoncharnes))
245
350
  - Fix undefined is not an object for Object.keys in log.js [\#201](https://github.com/hopsoft/stimulus_reflex/pull/201) ([marcoroth](https://github.com/marcoroth))
246
351
  - Small typo/grammar fix in quickstart doc. [\#198](https://github.com/hopsoft/stimulus_reflex/pull/198) ([acoffman](https://github.com/acoffman))
247
- - Add halted lifecycle event [\#193](https://github.com/hopsoft/stimulus_reflex/pull/193) ([seb1441](https://github.com/seb1441))
352
+ - Add halted lifecycle event [\#193](https://github.com/hopsoft/stimulus_reflex/pull/193) ([websebdev](https://github.com/websebdev))
248
353
  - 147 extract multiple checkbox values [\#175](https://github.com/hopsoft/stimulus_reflex/pull/175) ([julianrubisch](https://github.com/julianrubisch))
249
354
 
250
355
  ## [v3.2.1](https://github.com/hopsoft/stimulus_reflex/tree/v3.2.1) (2020-05-09)
@@ -283,11 +388,11 @@
283
388
  - Replace uuid4 dependency with function in repo [\#181](https://github.com/hopsoft/stimulus_reflex/pull/181) ([jonathan-s](https://github.com/jonathan-s))
284
389
  - Allow channel exceptions to be rescuable [\#180](https://github.com/hopsoft/stimulus_reflex/pull/180) ([dark-panda](https://github.com/dark-panda))
285
390
  - add console log messages for every reflex call [\#163](https://github.com/hopsoft/stimulus_reflex/pull/163) ([marcoroth](https://github.com/marcoroth))
286
- - add reflex callbacks [\#160](https://github.com/hopsoft/stimulus_reflex/pull/160) ([seb1441](https://github.com/seb1441))
391
+ - add reflex callbacks [\#160](https://github.com/hopsoft/stimulus_reflex/pull/160) ([websebdev](https://github.com/websebdev))
287
392
 
288
393
  **Fixed bugs:**
289
394
 
290
- - Pluralize the generated class name, so that will match with the file name [\#178](https://github.com/hopsoft/stimulus_reflex/pull/178) ([darkrubyist](https://github.com/darkrubyist))
395
+ - Pluralize the generated class name, so that will match with the file name [\#178](https://github.com/hopsoft/stimulus_reflex/pull/178) ([dark88888](https://github.com/dark88888))
291
396
 
292
397
  **Closed issues:**
293
398
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.3.0)
4
+ stimulus_reflex (3.4.0.pre4)
5
5
  cable_ready (>= 4.3.0)
6
6
  nokogiri
7
7
  rack
@@ -11,56 +11,56 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (6.0.3.3)
15
- actionpack (= 6.0.3.3)
14
+ actioncable (6.0.3.4)
15
+ actionpack (= 6.0.3.4)
16
16
  nio4r (~> 2.0)
17
17
  websocket-driver (>= 0.6.1)
18
- actionmailbox (6.0.3.3)
19
- actionpack (= 6.0.3.3)
20
- activejob (= 6.0.3.3)
21
- activerecord (= 6.0.3.3)
22
- activestorage (= 6.0.3.3)
23
- activesupport (= 6.0.3.3)
18
+ actionmailbox (6.0.3.4)
19
+ actionpack (= 6.0.3.4)
20
+ activejob (= 6.0.3.4)
21
+ activerecord (= 6.0.3.4)
22
+ activestorage (= 6.0.3.4)
23
+ activesupport (= 6.0.3.4)
24
24
  mail (>= 2.7.1)
25
- actionmailer (6.0.3.3)
26
- actionpack (= 6.0.3.3)
27
- actionview (= 6.0.3.3)
28
- activejob (= 6.0.3.3)
25
+ actionmailer (6.0.3.4)
26
+ actionpack (= 6.0.3.4)
27
+ actionview (= 6.0.3.4)
28
+ activejob (= 6.0.3.4)
29
29
  mail (~> 2.5, >= 2.5.4)
30
30
  rails-dom-testing (~> 2.0)
31
- actionpack (6.0.3.3)
32
- actionview (= 6.0.3.3)
33
- activesupport (= 6.0.3.3)
31
+ actionpack (6.0.3.4)
32
+ actionview (= 6.0.3.4)
33
+ activesupport (= 6.0.3.4)
34
34
  rack (~> 2.0, >= 2.0.8)
35
35
  rack-test (>= 0.6.3)
36
36
  rails-dom-testing (~> 2.0)
37
37
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
38
- actiontext (6.0.3.3)
39
- actionpack (= 6.0.3.3)
40
- activerecord (= 6.0.3.3)
41
- activestorage (= 6.0.3.3)
42
- activesupport (= 6.0.3.3)
38
+ actiontext (6.0.3.4)
39
+ actionpack (= 6.0.3.4)
40
+ activerecord (= 6.0.3.4)
41
+ activestorage (= 6.0.3.4)
42
+ activesupport (= 6.0.3.4)
43
43
  nokogiri (>= 1.8.5)
44
- actionview (6.0.3.3)
45
- activesupport (= 6.0.3.3)
44
+ actionview (6.0.3.4)
45
+ activesupport (= 6.0.3.4)
46
46
  builder (~> 3.1)
47
47
  erubi (~> 1.4)
48
48
  rails-dom-testing (~> 2.0)
49
49
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
50
- activejob (6.0.3.3)
51
- activesupport (= 6.0.3.3)
50
+ activejob (6.0.3.4)
51
+ activesupport (= 6.0.3.4)
52
52
  globalid (>= 0.3.6)
53
- activemodel (6.0.3.3)
54
- activesupport (= 6.0.3.3)
55
- activerecord (6.0.3.3)
56
- activemodel (= 6.0.3.3)
57
- activesupport (= 6.0.3.3)
58
- activestorage (6.0.3.3)
59
- actionpack (= 6.0.3.3)
60
- activejob (= 6.0.3.3)
61
- activerecord (= 6.0.3.3)
53
+ activemodel (6.0.3.4)
54
+ activesupport (= 6.0.3.4)
55
+ activerecord (6.0.3.4)
56
+ activemodel (= 6.0.3.4)
57
+ activesupport (= 6.0.3.4)
58
+ activestorage (6.0.3.4)
59
+ actionpack (= 6.0.3.4)
60
+ activejob (= 6.0.3.4)
61
+ activerecord (= 6.0.3.4)
62
62
  marcel (~> 0.3.1)
63
- activesupport (6.0.3.3)
63
+ activesupport (6.0.3.4)
64
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
65
65
  i18n (>= 0.7, < 2)
66
66
  minitest (~> 5.1)
@@ -73,7 +73,7 @@ GEM
73
73
  coderay (1.1.3)
74
74
  concurrent-ruby (1.1.7)
75
75
  crass (1.0.6)
76
- erubi (1.9.0)
76
+ erubi (1.10.0)
77
77
  globalid (0.4.2)
78
78
  activesupport (>= 4.2.0)
79
79
  i18n (1.8.5)
@@ -93,8 +93,8 @@ GEM
93
93
  nio4r (2.5.4)
94
94
  nokogiri (1.10.10)
95
95
  mini_portile2 (~> 2.4.0)
96
- parallel (1.19.2)
97
- parser (2.7.1.4)
96
+ parallel (1.20.0)
97
+ parser (2.7.2.0)
98
98
  ast (~> 2.4.1)
99
99
  pry (0.12.2)
100
100
  coderay (~> 1.1.0)
@@ -104,50 +104,51 @@ GEM
104
104
  rack (2.2.3)
105
105
  rack-test (1.1.0)
106
106
  rack (>= 1.0, < 3)
107
- rails (6.0.3.3)
108
- actioncable (= 6.0.3.3)
109
- actionmailbox (= 6.0.3.3)
110
- actionmailer (= 6.0.3.3)
111
- actionpack (= 6.0.3.3)
112
- actiontext (= 6.0.3.3)
113
- actionview (= 6.0.3.3)
114
- activejob (= 6.0.3.3)
115
- activemodel (= 6.0.3.3)
116
- activerecord (= 6.0.3.3)
117
- activestorage (= 6.0.3.3)
118
- activesupport (= 6.0.3.3)
107
+ rails (6.0.3.4)
108
+ actioncable (= 6.0.3.4)
109
+ actionmailbox (= 6.0.3.4)
110
+ actionmailer (= 6.0.3.4)
111
+ actionpack (= 6.0.3.4)
112
+ actiontext (= 6.0.3.4)
113
+ actionview (= 6.0.3.4)
114
+ activejob (= 6.0.3.4)
115
+ activemodel (= 6.0.3.4)
116
+ activerecord (= 6.0.3.4)
117
+ activestorage (= 6.0.3.4)
118
+ activesupport (= 6.0.3.4)
119
119
  bundler (>= 1.3.0)
120
- railties (= 6.0.3.3)
120
+ railties (= 6.0.3.4)
121
121
  sprockets-rails (>= 2.0.0)
122
122
  rails-dom-testing (2.0.3)
123
123
  activesupport (>= 4.2.0)
124
124
  nokogiri (>= 1.6)
125
125
  rails-html-sanitizer (1.3.0)
126
126
  loofah (~> 2.3)
127
- railties (6.0.3.3)
128
- actionpack (= 6.0.3.3)
129
- activesupport (= 6.0.3.3)
127
+ railties (6.0.3.4)
128
+ actionpack (= 6.0.3.4)
129
+ activesupport (= 6.0.3.4)
130
130
  method_source
131
131
  rake (>= 0.8.7)
132
132
  thor (>= 0.20.3, < 2.0)
133
133
  rainbow (3.0.0)
134
134
  rake (13.0.1)
135
- redis (4.2.2)
136
- regexp_parser (1.7.1)
135
+ redis (4.2.4)
136
+ regexp_parser (1.8.2)
137
137
  rexml (3.2.4)
138
- rubocop (0.89.1)
138
+ rubocop (1.2.0)
139
139
  parallel (~> 1.10)
140
- parser (>= 2.7.1.1)
140
+ parser (>= 2.7.1.5)
141
141
  rainbow (>= 2.2.2, < 4.0)
142
- regexp_parser (>= 1.7)
142
+ regexp_parser (>= 1.8)
143
143
  rexml
144
- rubocop-ast (>= 0.3.0, < 1.0)
144
+ rubocop-ast (>= 1.0.1)
145
145
  ruby-progressbar (~> 1.7)
146
146
  unicode-display_width (>= 1.4.0, < 2.0)
147
- rubocop-ast (0.3.0)
148
- parser (>= 2.7.1.4)
149
- rubocop-performance (1.7.1)
150
- rubocop (>= 0.82.0)
147
+ rubocop-ast (1.1.1)
148
+ parser (>= 2.7.1.5)
149
+ rubocop-performance (1.8.1)
150
+ rubocop (>= 0.87.0)
151
+ rubocop-ast (>= 0.4.0)
151
152
  ruby-progressbar (1.10.1)
152
153
  sprockets (4.0.2)
153
154
  concurrent-ruby (~> 1.0)
@@ -156,20 +157,20 @@ GEM
156
157
  actionpack (>= 4.0)
157
158
  activesupport (>= 4.0)
158
159
  sprockets (>= 3.0.0)
159
- standard (0.5.2)
160
- rubocop (~> 0.89.1)
161
- rubocop-performance (~> 1.7.1)
160
+ standard (0.9.0)
161
+ rubocop (= 1.2.0)
162
+ rubocop-performance (= 1.8.1)
162
163
  standardrb (1.0.0)
163
164
  standard
164
165
  thor (1.0.1)
165
166
  thread_safe (0.3.6)
166
- tzinfo (1.2.7)
167
+ tzinfo (1.2.8)
167
168
  thread_safe (~> 0.1)
168
169
  unicode-display_width (1.7.0)
169
170
  websocket-driver (0.7.3)
170
171
  websocket-extensions (>= 0.1.0)
171
172
  websocket-extensions (0.1.5)
172
- zeitwerk (2.4.0)
173
+ zeitwerk (2.4.1)
173
174
 
174
175
  PLATFORMS
175
176
  ruby
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-brightgreen.svg" target="_blank" />
12
12
  </a>
13
13
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/" target="_blank">
14
- <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1098-brightgreen.svg?style=flat" />
14
+ <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1322-brightgreen.svg?style=flat" />
15
15
  </a>
16
16
  <a href="https://docs.stimulusreflex.com/" target="_blank">
17
17
  <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
@@ -27,6 +27,9 @@
27
27
  <img alt="JavaScript Code Style" src="https://img.shields.io/badge/JavaScript_Code_Style-prettier_standard-ff69b4.svg" />
28
28
  </a>
29
29
  <br />
30
+ <a href="https://www.codacy.com/manual/hopsoft/stimulus_reflex/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=hopsoft/stimulus_reflex&amp;utm_campaign=Badge_Grade" target="_blank">
31
+ <img alt="Code Quality" src="https://app.codacy.com/project/badge/Grade/d1d72a7060f5467b8696884351cf477f"/>
32
+ </a>
30
33
  <a href="https://codeclimate.com/github/hopsoft/stimulus_reflex/maintainability" target="_blank">
31
34
  <img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/2b24fdbd1ae37a24bedb/maintainability" />
32
35
  </a>
@@ -51,7 +54,7 @@ And, it's fast.
51
54
 
52
55
  It works seamlessly with the Rails tooling you already know and love.
53
56
 
54
- - Server-rendered HTML, delivered in miliseconds over the wire via Websockets
57
+ - Server-rendered HTML, delivered in milliseconds over the wire via Websockets
55
58
  - ERB templates and partials, with first-class [ViewComponent](https://github.com/github/view_component) support
56
59
  - [Russian doll caching](https://edgeguides.rubyonrails.org/caching_with_rails.html#russian-doll-caching) and [ActiveJob](https://guides.rubyonrails.org/active_job_basics.html)
57
60
  - [StimulusJS](https://stimulusjs.org/) and [Turbolinks](https://www.youtube.com/watch?v=SWEts0rlezA)
@@ -74,7 +77,7 @@ This project strives to live up to the vision outlined in [The Rails Doctrine](h
74
77
 
75
78
  ## 👩‍👩‍👧 Discord Community
76
79
 
77
- Please join over 500 of us on [Discord](https://discord.gg/XveN625) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
80
+ Please join over 700 of us on [Discord](https://discord.gg/XveN625) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
78
81
 
79
82
  ![](https://img.shields.io/discord/629472241427415060)
80
83
 
@@ -1,16 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
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
3
+ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.constantize
14
4
  def stream_name
15
5
  ids = connection.identifiers.map { |identifier| send(identifier).try(:id) || send(identifier) }
16
6
  [
@@ -21,6 +11,7 @@ class StimulusReflex::Channel < ApplicationCable::Channel
21
11
 
22
12
  def subscribed
23
13
  super
14
+ fix_environment!
24
15
  stream_from stream_name
25
16
  end
26
17
 
@@ -34,22 +25,35 @@ class StimulusReflex::Channel < ApplicationCable::Channel
34
25
  reflex_name = reflex_name.end_with?("Reflex") ? reflex_name : "#{reflex_name}Reflex"
35
26
  arguments = (data["args"] || []).map { |arg| object_with_indifferent_access arg }
36
27
  element = StimulusReflex::Element.new(data)
37
- permanent_attribute_name = data["permanent_attribute_name"]
38
- params = data["params"] || {}
28
+ permanent_attribute_name = data["permanentAttributeName"]
29
+ form_data = Rack::Utils.parse_nested_query(data["formData"])
30
+ params = form_data.deep_merge(data["params"] || {})
39
31
 
40
32
  begin
41
33
  begin
42
34
  reflex_class = reflex_name.constantize.tap { |klass| raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex") unless is_reflex?(klass) }
43
- reflex = reflex_class.new(self, url: url, element: element, selectors: selectors, method_name: method_name, permanent_attribute_name: permanent_attribute_name, params: params)
35
+ reflex = reflex_class.new(self,
36
+ url: url,
37
+ element: element,
38
+ selectors: selectors,
39
+ method_name: method_name,
40
+ params: params,
41
+ client_attributes: {
42
+ reflex_id: data["reflexId"],
43
+ xpath: data["xpath"],
44
+ c_xpath: data["cXpath"],
45
+ reflex_controller: data["reflexController"],
46
+ permanent_attribute_name: permanent_attribute_name
47
+ })
44
48
  delegate_call_to_reflex reflex, method_name, arguments
45
49
  rescue => invoke_error
46
50
  message = exception_message_with_backtrace(invoke_error)
47
- body = "StimulusReflex::Channel Failed to invoke #{target}! #{url} #{message}"
51
+ body = "Reflex #{target} failed: #{message} [#{url}]"
48
52
  if reflex
49
53
  reflex.rescue_with_handler(invoke_error)
50
- reflex.broadcast_message subject: "error", body: body, data: data
54
+ reflex.broadcast_message subject: "error", body: body, data: data, error: invoke_error
51
55
  else
52
- logger.error "\e[31m#{body}\e[0m"
56
+ puts "\e[31m#{body}\e[0m"
53
57
  end
54
58
  return
55
59
  end
@@ -62,11 +66,16 @@ class StimulusReflex::Channel < ApplicationCable::Channel
62
66
  rescue => render_error
63
67
  reflex.rescue_with_handler(render_error)
64
68
  message = exception_message_with_backtrace(render_error)
65
- reflex.broadcast_message subject: "error", body: "StimulusReflex::Channel Failed to re-render #{url} #{message}", data: data
69
+ body = "Reflex failed to re-render: #{message} [#{url}]"
70
+ reflex.broadcast_message subject: "error", body: body, data: data, error: render_error
71
+ puts "\e[31m#{body}\e[0m"
66
72
  end
67
73
  end
68
74
  ensure
69
- commit_session reflex if reflex
75
+ if reflex
76
+ commit_session(reflex)
77
+ reflex.logger.print
78
+ end
70
79
  end
71
80
  end
72
81
 
@@ -101,10 +110,16 @@ class StimulusReflex::Channel < ApplicationCable::Channel
101
110
  store.commit_session reflex.request, reflex.controller.response
102
111
  rescue => e
103
112
  message = "Failed to commit session! #{exception_message_with_backtrace(e)}"
104
- logger.error "\e[31m#{message}\e[0m"
113
+ puts "\e[31m#{message}\e[0m"
105
114
  end
106
115
 
107
116
  def exception_message_with_backtrace(exception)
108
- "#{exception} #{exception.backtrace.first}"
117
+ "#{exception}\n#{exception.backtrace.first}"
118
+ end
119
+
120
+ def fix_environment!
121
+ ([ApplicationController] + ApplicationController.descendants).each do |controller|
122
+ controller.renderer.instance_variable_set(:@env, connection.env.merge(controller.renderer.instance_variable_get(:@env)))
123
+ end
109
124
  end
110
125
  end