stimulus_reflex 3.5.0.pre2 → 3.5.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.

Potentially problematic release.


This version of stimulus_reflex might be problematic. Click here for more details.

Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -11
  3. data/Gemfile.lock +71 -66
  4. data/README.md +4 -3
  5. data/app/channels/stimulus_reflex/channel.rb +11 -11
  6. data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +5 -4
  7. data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +5 -0
  8. data/lib/stimulus_reflex/broadcasters/broadcaster.rb +18 -17
  9. data/lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb +6 -1
  10. data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +1 -3
  11. data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +2 -6
  12. data/lib/stimulus_reflex/configuration.rb +2 -1
  13. data/lib/stimulus_reflex/dataset.rb +34 -0
  14. data/lib/stimulus_reflex/element.rb +12 -46
  15. data/lib/stimulus_reflex/reflex.rb +7 -2
  16. data/lib/stimulus_reflex/utils/attribute_builder.rb +17 -0
  17. data/lib/stimulus_reflex/utils/logger.rb +6 -2
  18. data/lib/stimulus_reflex/version.rb +1 -1
  19. data/lib/tasks/stimulus_reflex/install.rake +1 -1
  20. data/test/broadcasters/broadcaster_test.rb +0 -1
  21. data/test/broadcasters/broadcaster_test_case.rb +24 -0
  22. data/test/broadcasters/nothing_broadcaster_test.rb +14 -22
  23. data/test/broadcasters/page_broadcaster_test.rb +30 -32
  24. data/test/broadcasters/selector_broadcaster_test.rb +82 -88
  25. data/test/element_test.rb +73 -0
  26. data/test/generators/stimulus_reflex_generator_test.rb +8 -0
  27. data/test/reflex_test.rb +11 -0
  28. data/test/test_helper.rb +3 -1
  29. data/test/tmp/app/reflexes/demo_reflex.rb +0 -1
  30. metadata +36 -20
  31. data/package.json +0 -58
  32. data/stimulus_reflex.gemspec +0 -42
  33. data/yarn.lock +0 -4680
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83e2bc40ea2d2f8edb1e3b4aa6ca0a9ac72a1ef9aa16d55ef117ff90af37ee36
4
- data.tar.gz: 3b7d7f4bd6b4696420f4c581468cb0d62c6ac82fa5fa5762920182932d8dbeed
3
+ metadata.gz: d3eeb7e68a619fd080de2586195c301fb1964ca228386a1cf382746361ba8ba8
4
+ data.tar.gz: 941dd5eadad5a5b8a156875ec18b2a802c4beffdc8be89c066ab1ad0a49f9814
5
5
  SHA512:
6
- metadata.gz: fe9f56ae6a2423d27d244004d6098305434f40d8062c23024a650fc4796800491328dd954f69ba2f977f8c24208ab3d812b7c7144ae4d762c2bd4411a7df8f3a
7
- data.tar.gz: 90e5126b4caec44b433e54232ed0ea7e79341ed311e7d75a66cab57aa067920f682ff210a1a2600d27a0f9bedc22c9ae5447a2dc8e9dbc55990d5a24ea88b802
6
+ metadata.gz: e42c7c8d0af3239055643cab1fc501bc48ea6c8c09238b2a3f9ed874cbd36bfafaa79e3c359642e6535f50a2d6c71b6d4110a5da4b935412c5708a0d24c7c5db
7
+ data.tar.gz: 892930733782eab2fa08dd978a7bff83b2f31aea5f2b3b9f138b1aa2963cff249eca0c16e7929576e321c4fd17195539cc4bcc5b9de10f94ed7ccbb450c65f95
data/CHANGELOG.md CHANGED
@@ -2,7 +2,54 @@
2
2
 
3
3
  ## [Unreleased](https://github.com/stimulusreflex/stimulus_reflex/tree/HEAD)
4
4
 
5
- [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v3.5.0.pre1...HEAD)
5
+ [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v3.5.0.pre3...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Rails 7 Alpha Incompatibility [\#552](https://github.com/stimulusreflex/stimulus_reflex/issues/552)
10
+
11
+ ## [v3.5.0.pre3](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.5.0.pre3) (2021-10-01)
12
+
13
+ [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v3.5.0.pre2...v3.5.0.pre3)
14
+
15
+ **Implemented enhancements:**
16
+
17
+ - Allow to skip stages in the generator [\#541](https://github.com/stimulusreflex/stimulus_reflex/issues/541)
18
+ - document body connection status classes [\#547](https://github.com/stimulusreflex/stimulus_reflex/pull/547) ([leastbad](https://github.com/leastbad))
19
+ - overhaul Reflex logging [\#546](https://github.com/stimulusreflex/stimulus_reflex/pull/546) ([leastbad](https://github.com/leastbad))
20
+ - reverse merge params into locals [\#542](https://github.com/stimulusreflex/stimulus_reflex/pull/542) ([leastbad](https://github.com/leastbad))
21
+ - specify env headers for page morph controller [\#538](https://github.com/stimulusreflex/stimulus_reflex/pull/538) ([leastbad](https://github.com/leastbad))
22
+ - New CR wire format + reworked server message events [\#536](https://github.com/stimulusreflex/stimulus_reflex/pull/536) ([leastbad](https://github.com/leastbad))
23
+ - reflex render layout defaults to false [\#534](https://github.com/stimulusreflex/stimulus_reflex/pull/534) ([leastbad](https://github.com/leastbad))
24
+
25
+ **Closed issues:**
26
+
27
+ - Controller action being re-run is different from expected. [\#540](https://github.com/stimulusreflex/stimulus_reflex/issues/540)
28
+ - The ActionCable channel subscription for StimulusReflex gets rejected when interacting too fast [\#539](https://github.com/stimulusreflex/stimulus_reflex/issues/539)
29
+ - Stimulus reflex not working making server to stop on ruby on rails [\#533](https://github.com/stimulusreflex/stimulus_reflex/issues/533)
30
+
31
+ **Merged pull requests:**
32
+
33
+ - Bump nokogiri from 1.12.3 to 1.12.5 [\#548](https://github.com/stimulusreflex/stimulus_reflex/pull/548) ([dependabot[bot]](https://github.com/apps/dependabot))
34
+ - Add test for param behavior [\#545](https://github.com/stimulusreflex/stimulus_reflex/pull/545) ([julianrubisch](https://github.com/julianrubisch))
35
+ - Add generator options to skip reflex and stimulus [\#543](https://github.com/stimulusreflex/stimulus_reflex/pull/543) ([nachiket87](https://github.com/nachiket87))
36
+ - Fix comment [\#537](https://github.com/stimulusreflex/stimulus_reflex/pull/537) ([julianrubisch](https://github.com/julianrubisch))
37
+ - add first line of stacktrace to console.log error in dev environment [\#532](https://github.com/stimulusreflex/stimulus_reflex/pull/532) ([RolandStuder](https://github.com/RolandStuder))
38
+ - Add test for `data-reflex-dataset="descendants"` [\#531](https://github.com/stimulusreflex/stimulus_reflex/pull/531) ([assuntaw](https://github.com/assuntaw))
39
+ - Provide proxy methods boolean and numeric on Element [\#528](https://github.com/stimulusreflex/stimulus_reflex/pull/528) ([julianrubisch](https://github.com/julianrubisch))
40
+
41
+ ## [v3.5.0.pre2](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.5.0.pre2) (2021-07-21)
42
+
43
+ [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v3.5.0.pre1...v3.5.0.pre2)
44
+
45
+ **Implemented enhancements:**
46
+
47
+ - Optionally provide innerHtml and textContent on StimulusReflex::Element [\#517](https://github.com/stimulusreflex/stimulus_reflex/pull/517) ([julianrubisch](https://github.com/julianrubisch))
48
+
49
+ **Fixed bugs:**
50
+
51
+ - Sanity checker should not abort stimulus\_reflex install task [\#508](https://github.com/stimulusreflex/stimulus_reflex/issues/508)
52
+ - Improve install experience [\#510](https://github.com/stimulusreflex/stimulus_reflex/pull/510) ([leastbad](https://github.com/leastbad))
6
53
 
7
54
  **Closed issues:**
8
55
 
@@ -12,10 +59,13 @@
12
59
 
13
60
  **Merged pull requests:**
14
61
 
62
+ - Specify form selector [\#527](https://github.com/stimulusreflex/stimulus_reflex/pull/527) ([julianrubisch](https://github.com/julianrubisch))
15
63
  - Fix two minor typos [\#526](https://github.com/stimulusreflex/stimulus_reflex/pull/526) ([julianrubisch](https://github.com/julianrubisch))
16
64
  - chore: add sideEffects false to make Webpack happy [\#523](https://github.com/stimulusreflex/stimulus_reflex/pull/523) ([ParamagicDev](https://github.com/ParamagicDev))
65
+ - Morph stimulus reflex element AKA "single element page morph" [\#522](https://github.com/stimulusreflex/stimulus_reflex/pull/522) ([julianrubisch](https://github.com/julianrubisch))
17
66
  - Add localization example to ApplicationReflex template [\#521](https://github.com/stimulusreflex/stimulus_reflex/pull/521) ([erlingur](https://github.com/erlingur))
18
67
  - refactor stream\_name [\#519](https://github.com/stimulusreflex/stimulus_reflex/pull/519) ([leastbad](https://github.com/leastbad))
68
+ - Schema object with getters [\#505](https://github.com/stimulusreflex/stimulus_reflex/pull/505) ([leastbad](https://github.com/leastbad))
19
69
 
20
70
  ## [v3.5.0.pre1](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.5.0.pre1) (2021-06-02)
21
71
 
@@ -125,6 +175,7 @@
125
175
  - Extract RequestParameters class [\#451](https://github.com/stimulusreflex/stimulus_reflex/pull/451) ([julianrubisch](https://github.com/julianrubisch))
126
176
  - run changelog action not on every single push to master [\#450](https://github.com/stimulusreflex/stimulus_reflex/pull/450) ([marcoroth](https://github.com/marcoroth))
127
177
  - Extract method invocation policy [\#448](https://github.com/stimulusreflex/stimulus_reflex/pull/448) ([julianrubisch](https://github.com/julianrubisch))
178
+ - remove unnecessary gate [\#439](https://github.com/stimulusreflex/stimulus_reflex/pull/439) ([leastbad](https://github.com/leastbad))
128
179
 
129
180
  ## [v3.4.1](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.4.1) (2021-01-26)
130
181
 
@@ -137,6 +188,7 @@
137
188
  **Fixed bugs:**
138
189
 
139
190
  - life-cycle callbacks return correct element reference [\#431](https://github.com/stimulusreflex/stimulus_reflex/pull/431) ([leastbad](https://github.com/leastbad))
191
+ - encode form data for chars like '&' and '=' [\#418](https://github.com/stimulusreflex/stimulus_reflex/pull/418) ([RolandStuder](https://github.com/RolandStuder))
140
192
  - Bug fix: Updating changelog generator to push to master, not main [\#416](https://github.com/stimulusreflex/stimulus_reflex/pull/416) ([MikeRogers0](https://github.com/MikeRogers0))
141
193
  - Prefix dom\_id with hash/pound [\#410](https://github.com/stimulusreflex/stimulus_reflex/pull/410) ([hopsoft](https://github.com/hopsoft))
142
194
 
@@ -150,7 +202,6 @@
150
202
 
151
203
  **Merged pull requests:**
152
204
 
153
- - remove unnecessary gate [\#439](https://github.com/stimulusreflex/stimulus_reflex/pull/439) ([leastbad](https://github.com/leastbad))
154
205
  - Extract callbacks to module [\#427](https://github.com/stimulusreflex/stimulus_reflex/pull/427) ([julianrubisch](https://github.com/julianrubisch))
155
206
  - Fixes bug where multiple inputs with the same name lost element value [\#426](https://github.com/stimulusreflex/stimulus_reflex/pull/426) ([jonsgreen](https://github.com/jonsgreen))
156
207
  - Add general policy for CoC enforcement [\#424](https://github.com/stimulusreflex/stimulus_reflex/pull/424) ([hopsoft](https://github.com/hopsoft))
@@ -179,7 +230,6 @@
179
230
 
180
231
  **Fixed bugs:**
181
232
 
182
- - encode form data for chars like '&' and '=' [\#418](https://github.com/stimulusreflex/stimulus_reflex/pull/418) ([RolandStuder](https://github.com/RolandStuder))
183
233
  - fix up install task [\#401](https://github.com/stimulusreflex/stimulus_reflex/pull/401) ([leastbad](https://github.com/leastbad))
184
234
  - Fix multiple broadcasts from within the same reflex [\#400](https://github.com/stimulusreflex/stimulus_reflex/pull/400) ([hopsoft](https://github.com/hopsoft))
185
235
 
@@ -376,6 +426,7 @@
376
426
 
377
427
  **Merged pull requests:**
378
428
 
429
+ - fixes and tweaks to client logging subsystem [\#313](https://github.com/stimulusreflex/stimulus_reflex/pull/313) ([leastbad](https://github.com/leastbad))
379
430
  - add ready event after setupDeclarativeReflexes [\#312](https://github.com/stimulusreflex/stimulus_reflex/pull/312) ([leastbad](https://github.com/leastbad))
380
431
  - Refactor sanity checks on boot [\#311](https://github.com/stimulusreflex/stimulus_reflex/pull/311) ([excid3](https://github.com/excid3))
381
432
 
@@ -395,7 +446,6 @@
395
446
 
396
447
  **Merged pull requests:**
397
448
 
398
- - fixes and tweaks to client logging subsystem [\#313](https://github.com/stimulusreflex/stimulus_reflex/pull/313) ([leastbad](https://github.com/leastbad))
399
449
  - Support IE11 msCrypto \(\#308\) [\#310](https://github.com/stimulusreflex/stimulus_reflex/pull/310) ([chooselife22](https://github.com/chooselife22))
400
450
  - Print warning and exit if caching is disabled or npm/gem versions are mismatched [\#309](https://github.com/stimulusreflex/stimulus_reflex/pull/309) ([excid3](https://github.com/excid3))
401
451
  - ActionCable connectivity events [\#307](https://github.com/stimulusreflex/stimulus_reflex/pull/307) ([leastbad](https://github.com/leastbad))
@@ -496,14 +546,12 @@
496
546
  **Fixed bugs:**
497
547
 
498
548
  - Limit MutationObserver mutations [\#256](https://github.com/stimulusreflex/stimulus_reflex/pull/256) ([jasoncharnes](https://github.com/jasoncharnes))
499
- - Add more smarts to \_\_perform [\#235](https://github.com/stimulusreflex/stimulus_reflex/pull/235) ([hopsoft](https://github.com/hopsoft))
500
549
 
501
550
  **Closed issues:**
502
551
 
503
552
  - beforeUpdate/updateSuccess/updateError functions deprecated? [\#255](https://github.com/stimulusreflex/stimulus_reflex/issues/255)
504
553
  - Error handling will fail if reflex is not defined [\#253](https://github.com/stimulusreflex/stimulus_reflex/issues/253)
505
554
  - Select with data-reflex in Firefox flickers [\#251](https://github.com/stimulusreflex/stimulus_reflex/issues/251)
506
- - data-reflex-attributes vs data-reflex-dataset [\#237](https://github.com/stimulusreflex/stimulus_reflex/issues/237)
507
555
  - Shorthand action notations corresponding to stimulus [\#233](https://github.com/stimulusreflex/stimulus_reflex/issues/233)
508
556
  - Lifecycle methods only called for one reflex [\#225](https://github.com/stimulusreflex/stimulus_reflex/issues/225)
509
557
  - Tweak the generator so we can specify reflex actions [\#219](https://github.com/stimulusreflex/stimulus_reflex/issues/219)
@@ -525,6 +573,7 @@
525
573
  - Revert "Add instructions for pulling the user id out of session storage" [\#239](https://github.com/stimulusreflex/stimulus_reflex/pull/239) ([leastbad](https://github.com/leastbad))
526
574
  - Add instructions for pulling the user id out of session storage [\#238](https://github.com/stimulusreflex/stimulus_reflex/pull/238) ([mtomov](https://github.com/mtomov))
527
575
  - adds params documentation [\#230](https://github.com/stimulusreflex/stimulus_reflex/pull/230) ([RolandStuder](https://github.com/RolandStuder))
576
+ - Fix calling wrong controller lifecycle methods [\#226](https://github.com/stimulusreflex/stimulus_reflex/pull/226) ([davidalejandroaguilar](https://github.com/davidalejandroaguilar))
528
577
  - Allow to pass reflex action names to reflex generator [\#224](https://github.com/stimulusreflex/stimulus_reflex/pull/224) ([marcoroth](https://github.com/marcoroth))
529
578
 
530
579
  ## [v3.2.3](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.2.3) (2020-06-15)
@@ -533,6 +582,7 @@
533
582
 
534
583
  **Fixed bugs:**
535
584
 
585
+ - Add more smarts to \_\_perform [\#235](https://github.com/stimulusreflex/stimulus_reflex/pull/235) ([hopsoft](https://github.com/hopsoft))
536
586
  - \_\_perform had a bug where it was only ever calling the first event [\#234](https://github.com/stimulusreflex/stimulus_reflex/pull/234) ([leastbad](https://github.com/leastbad))
537
587
  - merges insteads of overwrites params for reflex actions with form data [\#231](https://github.com/stimulusreflex/stimulus_reflex/pull/231) ([RolandStuder](https://github.com/RolandStuder))
538
588
 
@@ -543,7 +593,6 @@
543
593
  **Merged pull requests:**
544
594
 
545
595
  - Fix typos in the documentation [\#228](https://github.com/stimulusreflex/stimulus_reflex/pull/228) ([dlt](https://github.com/dlt))
546
- - Always commit session [\#222](https://github.com/stimulusreflex/stimulus_reflex/pull/222) ([hopsoft](https://github.com/hopsoft))
547
596
 
548
597
  ## [v3.2.2](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.2.2) (2020-06-06)
549
598
 
@@ -564,7 +613,6 @@
564
613
 
565
614
  **Merged pull requests:**
566
615
 
567
- - Fix calling wrong controller lifecycle methods [\#226](https://github.com/stimulusreflex/stimulus_reflex/pull/226) ([davidalejandroaguilar](https://github.com/davidalejandroaguilar))
568
616
  - Always commit session [\#222](https://github.com/stimulusreflex/stimulus_reflex/pull/222) ([hopsoft](https://github.com/hopsoft))
569
617
 
570
618
  ## [v3.2.2.pre0](https://github.com/stimulusreflex/stimulus_reflex/tree/v3.2.2.pre0) (2020-05-27)
@@ -671,7 +719,6 @@
671
719
  - Possible bug when about to perform cableready operations [\#166](https://github.com/stimulusreflex/stimulus_reflex/issues/166)
672
720
  - Reflex not binding to ajax loaded content [\#161](https://github.com/stimulusreflex/stimulus_reflex/issues/161)
673
721
  - Input field values sometimes remain [\#159](https://github.com/stimulusreflex/stimulus_reflex/issues/159)
674
- - remove changelog rake task [\#150](https://github.com/stimulusreflex/stimulus_reflex/pull/150) ([andrewmcodes](https://github.com/andrewmcodes))
675
722
 
676
723
  **Closed issues:**
677
724
 
@@ -721,6 +768,7 @@
721
768
  **Fixed bugs:**
722
769
 
723
770
  - Cannot read property 'removeEventListener' of undefined after updating to 3.1.0 [\#151](https://github.com/stimulusreflex/stimulus_reflex/issues/151)
771
+ - remove changelog rake task [\#150](https://github.com/stimulusreflex/stimulus_reflex/pull/150) ([andrewmcodes](https://github.com/andrewmcodes))
724
772
 
725
773
  **Closed issues:**
726
774
 
@@ -802,6 +850,10 @@
802
850
 
803
851
  [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v2.2.0...v2.2.1)
804
852
 
853
+ **Fixed bugs:**
854
+
855
+ - Cleanup and fixes around lifecycle dispatch [\#121](https://github.com/stimulusreflex/stimulus_reflex/pull/121) ([hopsoft](https://github.com/hopsoft))
856
+
805
857
  ## [v2.2.0](https://github.com/stimulusreflex/stimulus_reflex/tree/v2.2.0) (2020-02-28)
806
858
 
807
859
  [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v2.1.9...v2.2.0)
@@ -823,6 +875,10 @@
823
875
 
824
876
  [Full Changelog](https://github.com/stimulusreflex/stimulus_reflex/compare/v2.1.7...v2.1.8)
825
877
 
878
+ **Implemented enhancements:**
879
+
880
+ - More defense in the received handler [\#107](https://github.com/stimulusreflex/stimulus_reflex/pull/107) ([hopsoft](https://github.com/hopsoft))
881
+
826
882
  **Fixed bugs:**
827
883
 
828
884
  - Fix bug related to trailing slash in URL path [\#111](https://github.com/stimulusreflex/stimulus_reflex/pull/111) ([hopsoft](https://github.com/hopsoft))
@@ -865,7 +921,6 @@
865
921
 
866
922
  **Fixed bugs:**
867
923
 
868
- - Cleanup and fixes around lifecycle dispatch [\#121](https://github.com/stimulusreflex/stimulus_reflex/pull/121) ([hopsoft](https://github.com/hopsoft))
869
924
  - Use application.js as fallback file path [\#82](https://github.com/stimulusreflex/stimulus_reflex/pull/82) ([julianrubisch](https://github.com/julianrubisch))
870
925
 
871
926
  **Closed issues:**
@@ -881,7 +936,6 @@
881
936
 
882
937
  **Implemented enhancements:**
883
938
 
884
- - More defense in the received handler [\#107](https://github.com/stimulusreflex/stimulus_reflex/pull/107) ([hopsoft](https://github.com/hopsoft))
885
939
  - Add CodeFund sponsorship [\#75](https://github.com/stimulusreflex/stimulus_reflex/pull/75) ([coderberry](https://github.com/coderberry))
886
940
 
887
941
  **Fixed bugs:**
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.5.0.pre2)
5
- cable_ready (= 5.0.0.pre2)
4
+ stimulus_reflex (3.5.0.pre6)
5
+ cable_ready (= 5.0.0.pre6)
6
6
  nokogiri
7
7
  rack
8
8
  rails (>= 5.2)
@@ -11,60 +11,60 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (6.1.4)
15
- actionpack (= 6.1.4)
16
- activesupport (= 6.1.4)
14
+ actioncable (6.1.4.1)
15
+ actionpack (= 6.1.4.1)
16
+ activesupport (= 6.1.4.1)
17
17
  nio4r (~> 2.0)
18
18
  websocket-driver (>= 0.6.1)
19
- actionmailbox (6.1.4)
20
- actionpack (= 6.1.4)
21
- activejob (= 6.1.4)
22
- activerecord (= 6.1.4)
23
- activestorage (= 6.1.4)
24
- activesupport (= 6.1.4)
19
+ actionmailbox (6.1.4.1)
20
+ actionpack (= 6.1.4.1)
21
+ activejob (= 6.1.4.1)
22
+ activerecord (= 6.1.4.1)
23
+ activestorage (= 6.1.4.1)
24
+ activesupport (= 6.1.4.1)
25
25
  mail (>= 2.7.1)
26
- actionmailer (6.1.4)
27
- actionpack (= 6.1.4)
28
- actionview (= 6.1.4)
29
- activejob (= 6.1.4)
30
- activesupport (= 6.1.4)
26
+ actionmailer (6.1.4.1)
27
+ actionpack (= 6.1.4.1)
28
+ actionview (= 6.1.4.1)
29
+ activejob (= 6.1.4.1)
30
+ activesupport (= 6.1.4.1)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  rails-dom-testing (~> 2.0)
33
- actionpack (6.1.4)
34
- actionview (= 6.1.4)
35
- activesupport (= 6.1.4)
33
+ actionpack (6.1.4.1)
34
+ actionview (= 6.1.4.1)
35
+ activesupport (= 6.1.4.1)
36
36
  rack (~> 2.0, >= 2.0.9)
37
37
  rack-test (>= 0.6.3)
38
38
  rails-dom-testing (~> 2.0)
39
39
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
40
- actiontext (6.1.4)
41
- actionpack (= 6.1.4)
42
- activerecord (= 6.1.4)
43
- activestorage (= 6.1.4)
44
- activesupport (= 6.1.4)
40
+ actiontext (6.1.4.1)
41
+ actionpack (= 6.1.4.1)
42
+ activerecord (= 6.1.4.1)
43
+ activestorage (= 6.1.4.1)
44
+ activesupport (= 6.1.4.1)
45
45
  nokogiri (>= 1.8.5)
46
- actionview (6.1.4)
47
- activesupport (= 6.1.4)
46
+ actionview (6.1.4.1)
47
+ activesupport (= 6.1.4.1)
48
48
  builder (~> 3.1)
49
49
  erubi (~> 1.4)
50
50
  rails-dom-testing (~> 2.0)
51
51
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
52
- activejob (6.1.4)
53
- activesupport (= 6.1.4)
52
+ activejob (6.1.4.1)
53
+ activesupport (= 6.1.4.1)
54
54
  globalid (>= 0.3.6)
55
- activemodel (6.1.4)
56
- activesupport (= 6.1.4)
57
- activerecord (6.1.4)
58
- activemodel (= 6.1.4)
59
- activesupport (= 6.1.4)
60
- activestorage (6.1.4)
61
- actionpack (= 6.1.4)
62
- activejob (= 6.1.4)
63
- activerecord (= 6.1.4)
64
- activesupport (= 6.1.4)
55
+ activemodel (6.1.4.1)
56
+ activesupport (= 6.1.4.1)
57
+ activerecord (6.1.4.1)
58
+ activemodel (= 6.1.4.1)
59
+ activesupport (= 6.1.4.1)
60
+ activestorage (6.1.4.1)
61
+ actionpack (= 6.1.4.1)
62
+ activejob (= 6.1.4.1)
63
+ activerecord (= 6.1.4.1)
64
+ activesupport (= 6.1.4.1)
65
65
  marcel (~> 1.0.0)
66
66
  mini_mime (>= 1.1.0)
67
- activesupport (6.1.4)
67
+ activesupport (6.1.4.1)
68
68
  concurrent-ruby (~> 1.0, >= 1.0.2)
69
69
  i18n (>= 1.6, < 2)
70
70
  minitest (>= 5.1)
@@ -72,30 +72,33 @@ GEM
72
72
  zeitwerk (~> 2.3)
73
73
  ast (2.4.2)
74
74
  builder (3.2.4)
75
- cable_ready (5.0.0.pre2)
75
+ cable_ready (5.0.0.pre6)
76
76
  rails (>= 5.2)
77
77
  thread-local (>= 1.1.0)
78
78
  coderay (1.1.3)
79
79
  concurrent-ruby (1.1.9)
80
80
  crass (1.0.6)
81
81
  erubi (1.10.0)
82
- globalid (0.4.2)
83
- activesupport (>= 4.2.0)
82
+ globalid (0.5.2)
83
+ activesupport (>= 5.0)
84
84
  i18n (1.8.10)
85
85
  concurrent-ruby (~> 1.0)
86
- loofah (2.10.0)
86
+ loofah (2.12.0)
87
87
  crass (~> 1.0.2)
88
88
  nokogiri (>= 1.5.9)
89
89
  mail (2.7.1)
90
90
  mini_mime (>= 0.1.1)
91
- marcel (1.0.1)
91
+ marcel (1.0.2)
92
92
  method_source (0.9.2)
93
- mini_mime (1.1.0)
93
+ mini_mime (1.1.2)
94
94
  minitest (5.14.4)
95
- nio4r (2.5.7)
96
- nokogiri (1.11.7-arm64-darwin)
95
+ mocha (1.13.0)
96
+ nio4r (2.5.8)
97
+ nokogiri (1.12.5-arm64-darwin)
98
+ racc (~> 1.4)
99
+ nokogiri (1.12.5-x86_64-darwin)
97
100
  racc (~> 1.4)
98
- nokogiri (1.11.7-x86_64-linux)
101
+ nokogiri (1.12.5-x86_64-linux)
99
102
  racc (~> 1.4)
100
103
  parallel (1.20.1)
101
104
  parser (3.0.2.0)
@@ -109,35 +112,35 @@ GEM
109
112
  rack (2.2.3)
110
113
  rack-test (1.1.0)
111
114
  rack (>= 1.0, < 3)
112
- rails (6.1.4)
113
- actioncable (= 6.1.4)
114
- actionmailbox (= 6.1.4)
115
- actionmailer (= 6.1.4)
116
- actionpack (= 6.1.4)
117
- actiontext (= 6.1.4)
118
- actionview (= 6.1.4)
119
- activejob (= 6.1.4)
120
- activemodel (= 6.1.4)
121
- activerecord (= 6.1.4)
122
- activestorage (= 6.1.4)
123
- activesupport (= 6.1.4)
115
+ rails (6.1.4.1)
116
+ actioncable (= 6.1.4.1)
117
+ actionmailbox (= 6.1.4.1)
118
+ actionmailer (= 6.1.4.1)
119
+ actionpack (= 6.1.4.1)
120
+ actiontext (= 6.1.4.1)
121
+ actionview (= 6.1.4.1)
122
+ activejob (= 6.1.4.1)
123
+ activemodel (= 6.1.4.1)
124
+ activerecord (= 6.1.4.1)
125
+ activestorage (= 6.1.4.1)
126
+ activesupport (= 6.1.4.1)
124
127
  bundler (>= 1.15.0)
125
- railties (= 6.1.4)
128
+ railties (= 6.1.4.1)
126
129
  sprockets-rails (>= 2.0.0)
127
130
  rails-dom-testing (2.0.3)
128
131
  activesupport (>= 4.2.0)
129
132
  nokogiri (>= 1.6)
130
- rails-html-sanitizer (1.3.0)
133
+ rails-html-sanitizer (1.4.2)
131
134
  loofah (~> 2.3)
132
- railties (6.1.4)
133
- actionpack (= 6.1.4)
134
- activesupport (= 6.1.4)
135
+ railties (6.1.4.1)
136
+ actionpack (= 6.1.4.1)
137
+ activesupport (= 6.1.4.1)
135
138
  method_source
136
139
  rake (>= 0.13)
137
140
  thor (~> 1.0)
138
141
  rainbow (3.0.0)
139
142
  rake (13.0.6)
140
- redis (4.3.1)
143
+ redis (4.4.0)
141
144
  regexp_parser (2.1.1)
142
145
  rexml (3.2.5)
143
146
  rubocop (1.18.3)
@@ -179,10 +182,12 @@ GEM
179
182
 
180
183
  PLATFORMS
181
184
  arm64-darwin-20
185
+ x86_64-darwin-19
182
186
  x86_64-linux
183
187
 
184
188
  DEPENDENCIES
185
189
  bundler (~> 2.0)
190
+ mocha
186
191
  pry
187
192
  pry-nav
188
193
  rake
data/README.md CHANGED
@@ -69,13 +69,14 @@ This project strives to live up to the vision outlined in [The Rails Doctrine](h
69
69
 
70
70
  ## ✨ Demos
71
71
 
72
- - [StimulusReflex Expo](http://expo.stimulusreflex.com) - part showcase, part learning tool
73
72
  - [Build a Twitter Clone in 10 Minutes](https://youtu.be/F5hA79vKE_E) (video)
73
+ - [BeastMode](https://beastmode.leastbad.com/) - faceted search, with filtering, sorting and pagination
74
+ - [StimulusReflex Patterns](https://www.stimulusreflexpatterns.com/patterns/) - single-file SR apps hosted on Glitch
74
75
  - [BoxDrop](https://dropbox-clone-rails.herokuapp.com/) - a Dropbox-inspired [concept demo](https://github.com/marcoroth/boxdrop/)
75
76
 
76
77
  ## 👩‍👩‍👧 Discord Community
77
78
 
78
- Please join over 1300 of us on [Discord](https://discord.gg/stimulus-reflex) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
79
+ Please join over 1500 of us on [Discord](https://discord.gg/stimulus-reflex) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
79
80
 
80
81
  ![](https://img.shields.io/discord/629472241427415060)
81
82
 
@@ -89,7 +90,7 @@ Please note that we are not actively providing support on Stack Overflow. If you
89
90
 
90
91
  ## 🚀 Installation and upgrading
91
92
 
92
- CLI and manual setup procedures are fully detailed in the [official docs](https://docs.stimulusreflex.com/setup). For information on upgrading existing projects to v3.4, read [this](https://docs.stimulusreflex.com/setup#upgrading-to-v-3-4-0).
93
+ CLI and manual setup procedures are fully detailed in the [official docs](https://docs.stimulusreflex.com/setup). For information on upgrading existing projects to v3.4, read [this](https://docs.stimulusreflex.com/hello-world/setup#upgrading-to-v-3-4-0).
93
94
 
94
95
  ## 🙏 Contributing
95
96
 
@@ -24,15 +24,15 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
24
24
 
25
25
  if reflex
26
26
  reflex.rescue_with_handler(exception)
27
- puts error_message
28
- reflex.broadcast_message subject: "error", data: data, error: exception
27
+ reflex.logger&.error error_message
28
+ reflex.error data: data, body: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
29
29
  else
30
- puts error_message
30
+ reflex.logger&.error error_message
31
31
 
32
32
  if body.to_s.include? "No route matches"
33
33
  initializer_path = Rails.root.join("config", "initializers", "stimulus_reflex.rb")
34
34
 
35
- puts <<~NOTE
35
+ reflex.logger&.warn <<~NOTE
36
36
  \e[33mNOTE: StimulusReflex failed to locate a matching route and could not re-render the page.
37
37
 
38
38
  If your app uses Rack middleware to rewrite part of the request path, you must enable those middleware modules in StimulusReflex.
@@ -54,22 +54,22 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
54
54
  end
55
55
 
56
56
  if reflex.halted?
57
- reflex.broadcast_message subject: "halted", data: data
57
+ reflex.halted data: data
58
58
  else
59
59
  begin
60
60
  reflex.broadcast(reflex_data.selectors, data)
61
61
  rescue => exception
62
62
  reflex.rescue_with_handler(exception)
63
63
  error = exception_with_backtrace(exception)
64
- reflex.broadcast_message subject: "error", data: data, error: exception
65
- puts "\e[31mReflex failed to re-render: #{error[:message]} [#{reflex_data.url}]\e[0m\n#{error[:stack]}"
64
+ reflex.error data: data, body: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
65
+ reflex.logger&.error "\e[31mReflex failed to re-render: #{error[:message]} [#{reflex_data.url}]\e[0m\n#{error[:stack]}"
66
66
  end
67
67
  end
68
68
  ensure
69
69
  if reflex
70
70
  commit_session(reflex)
71
71
  report_failed_basic_auth(reflex) if reflex.controller?
72
- reflex.logger&.print
72
+ reflex.logger&.log_all_operations
73
73
  end
74
74
  end
75
75
  end
@@ -97,19 +97,19 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
97
97
  store.commit_session reflex.request, reflex.controller.response
98
98
  rescue => exception
99
99
  error = exception_with_backtrace(exception)
100
- puts "\e[31mFailed to commit session! #{error[:message]}\e[0m\n#{error[:backtrace]}"
100
+ reflex.logger&.error "\e[31mFailed to commit session! #{error[:message]}\e[0m\n#{error[:backtrace]}"
101
101
  end
102
102
 
103
103
  def report_failed_basic_auth(reflex)
104
104
  if reflex.controller.response.status == 401
105
- puts "\e[31mReflex failed to process controller action \"#{reflex.controller.class}##{reflex.controller.action_name}\" due to HTTP basic auth. Consider adding \"unless: -> { @stimulus_reflex }\" to the before_action or method responible for authentication.\e[0m"
105
+ reflex.logger&.error "\e[31mReflex failed to process controller action \"#{reflex.controller.class}##{reflex.controller.action_name}\" due to HTTP basic auth. Consider adding \"unless: -> { @stimulus_reflex }\" to the before_action or method responible for authentication.\e[0m"
106
106
  end
107
107
  end
108
108
 
109
109
  def exception_with_backtrace(exception)
110
110
  {
111
111
  message: exception.to_s,
112
- backtrace: exception.backtrace.first,
112
+ backtrace: exception.backtrace.first.split(":in ")[0],
113
113
  stack: exception.backtrace.join("\n")
114
114
  }
115
115
  end
@@ -7,20 +7,21 @@ class StimulusReflexGenerator < Rails::Generators::NamedBase
7
7
 
8
8
  argument :name, type: :string, required: true, banner: "NAME"
9
9
  argument :actions, type: :array, default: [], banner: "action action"
10
+ class_options skip_stimulus: false, skip_app_reflex: false, skip_reflex: false, skip_app_controller: false
10
11
 
11
12
  def execute
12
13
  actions.map!(&:underscore)
13
14
 
14
15
  copy_application_files if behavior == :invoke
15
16
 
16
- template "app/reflexes/%file_name%_reflex.rb"
17
- template "app/javascript/controllers/%file_name%_controller.js"
17
+ template "app/reflexes/%file_name%_reflex.rb" unless options[:skip_reflex]
18
+ template "app/javascript/controllers/%file_name%_controller.js" unless options[:skip_stimulus]
18
19
  end
19
20
 
20
21
  private
21
22
 
22
23
  def copy_application_files
23
- template "app/reflexes/application_reflex.rb"
24
- template "app/javascript/controllers/application_controller.js"
24
+ template "app/reflexes/application_reflex.rb" unless options[:skip_app_reflex]
25
+ template "app/javascript/controllers/application_controller.js" unless options[:skip_app_controller]
25
26
  end
26
27
  end
@@ -25,6 +25,11 @@ StimulusReflex.configure do |config|
25
25
 
26
26
  # config.parent_channel = "ApplicationCable::Channel"
27
27
 
28
+ # Override the logger that the StimulusReflex uses; default is Rails' logger
29
+ # eg. Logger.new(RAILS_ROOT + "/log/reflex.log")
30
+
31
+ # config.logger = Rails.logger
32
+
28
33
  # Customize server-side Reflex logging format, with optional colorization:
29
34
  # Available tokens: session_id, session_id_full, reflex_info, operation, reflex_id, reflex_id_full, mode, selector, operation_counter, connection_id, connection_id_full, timestamp
30
35
  # Available colors: red, green, yellow, blue, magenta, cyan, white
@@ -26,33 +26,34 @@ module StimulusReflex
26
26
  false
27
27
  end
28
28
 
29
- def broadcast_message(subject:, data: {}, error: nil)
29
+ def halted(data: {})
30
30
  operations << ["document", :dispatch_event]
31
31
  cable_ready.dispatch_event(
32
- name: "stimulus-reflex:server-message",
33
- detail: {
34
- reflexId: data.delete("reflexId"),
35
- payload: payload,
36
- stimulus_reflex: data.merge(
37
- morph: to_sym,
38
- server_message: {subject: subject, body: error&.to_s}
39
- )
40
- }
41
- )
42
- cable_ready.broadcast
43
- end
44
-
45
- # abstract method to be implemented by subclasses
32
+ name: "stimulus-reflex:morph-halted",
33
+ payload: payload,
34
+ stimulus_reflex: data.merge(morph: to_sym)
35
+ ).broadcast
36
+ end
37
+
38
+ def error(data: {}, body: nil)
39
+ operations << ["document", :dispatch_event]
40
+ cable_ready.dispatch_event(
41
+ name: "stimulus-reflex:morph-error",
42
+ payload: payload,
43
+ stimulus_reflex: data.merge(morph: to_sym),
44
+ body: body&.to_s
45
+ ).broadcast
46
+ end
47
+
48
+ # abstract methods to be implemented by subclasses
46
49
  def broadcast(*args)
47
50
  raise NotImplementedError
48
51
  end
49
52
 
50
- # abstract method to be implemented by subclasses
51
53
  def to_sym
52
54
  raise NotImplementedError
53
55
  end
54
56
 
55
- # abstract method to be implemented by subclasses
56
57
  def to_s
57
58
  raise NotImplementedError
58
59
  end
@@ -3,7 +3,12 @@
3
3
  module StimulusReflex
4
4
  class NothingBroadcaster < Broadcaster
5
5
  def broadcast(_, data)
6
- broadcast_message subject: "nothing", data: data
6
+ operations << ["document", :dispatch_event]
7
+ cable_ready.dispatch_event(
8
+ name: "stimulus-reflex:morph-nothing",
9
+ payload: payload,
10
+ stimulus_reflex: data.merge(morph: to_sym)
11
+ ).broadcast
7
12
  end
8
13
 
9
14
  def nothing?