stimulus_reflex 3.5.0.rc3 → 3.5.3

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +144 -101
  3. data/README.md +2 -2
  4. data/app/assets/javascripts/stimulus_reflex.js +15 -13
  5. data/app/assets/javascripts/stimulus_reflex.umd.js +15 -12
  6. data/app/channels/stimulus_reflex/channel.rb +49 -53
  7. data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +2 -2
  8. data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +1 -1
  9. data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +1 -1
  10. data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +1 -1
  11. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +1 -1
  12. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +1 -1
  13. data/lib/install/action_cable.rb +30 -30
  14. data/lib/install/broadcaster.rb +11 -11
  15. data/lib/install/bundle.rb +9 -9
  16. data/lib/install/compression.rb +5 -5
  17. data/lib/install/config.rb +22 -22
  18. data/lib/install/development.rb +19 -19
  19. data/lib/install/esbuild.rb +28 -28
  20. data/lib/install/example.rb +3 -3
  21. data/lib/install/importmap.rb +29 -29
  22. data/lib/install/initializers.rb +3 -3
  23. data/lib/install/mrujs.rb +25 -25
  24. data/lib/install/npm_packages.rb +7 -7
  25. data/lib/install/reflexes.rb +2 -2
  26. data/lib/install/shakapacker.rb +23 -23
  27. data/lib/install/spring.rb +7 -7
  28. data/lib/install/updatable.rb +7 -7
  29. data/lib/install/vite.rb +22 -22
  30. data/lib/install/webpacker.rb +27 -27
  31. data/lib/install/yarn.rb +9 -9
  32. data/lib/stimulus_reflex/html/document_fragment.rb +5 -3
  33. data/lib/stimulus_reflex/installer.rb +305 -277
  34. data/lib/stimulus_reflex/reflex.rb +14 -29
  35. data/lib/stimulus_reflex/reflex_data.rb +17 -17
  36. data/lib/stimulus_reflex/reflex_factory.rb +49 -26
  37. data/lib/stimulus_reflex/version.rb +1 -1
  38. data/lib/stimulus_reflex.rb +2 -0
  39. data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +8 -8
  40. data/package.json +10 -10
  41. data/stimulus_reflex.gemspec +10 -8
  42. data/web-test-runner.config.mjs +14 -0
  43. data/yarn.lock +1278 -830
  44. metadata +34 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cce31cfe35841f8e96b70fe52e22ee84cf6aa287562b3ab6d1d0ee318fa109ee
4
- data.tar.gz: 33e86551718a90441a3110e7daf72c110ecf42fcd73105d788ec508d92a30ca9
3
+ metadata.gz: f263910793deb40545ce21257891050bcea23bb612ccc3537b6655d17a9ab425
4
+ data.tar.gz: 0b3570e952a8f9646ed2fa0b9b090cc9518dc55ed17f215a1839e11b27411438
5
5
  SHA512:
6
- metadata.gz: a56cd9fcedd2859b3d9b828dbc0fc91c59e9b773ddb983a22ce23709bc443ab4cbd25270bfda366a4594767f08f9964af4fd30475307889eb6ab10ad187828f3
7
- data.tar.gz: a5f3a462fe156023852d2db3911040436034c3fe54e3716aeecad1fcf2aa0ef86484f04236f20fa75ae149a3530dad23d8935d71a8dd817da43084ce2d895c8a
6
+ metadata.gz: '049480ba71eaf824360cbf301d912282315d2615f0b979110841abf01f22380b1a7e4c37e667d25175b9e05ed9200ebd57b06b6af932854eaebecf9fee5e65a5'
7
+ data.tar.gz: dfd82208502ebf1f3a5dfefba059715a213c8b3158ea415a7fa09d2a95e62bd6caa3fe891ef325a6c1b5e1892de0bc1dcf89248b5490aa93b1aa0df38f259697
data/Gemfile.lock CHANGED
@@ -1,105 +1,128 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.5.0.rc3)
5
- actioncable (>= 5.2, < 8)
6
- actionpack (>= 5.2, < 8)
7
- actionview (>= 5.2, < 8)
8
- activesupport (>= 5.2, < 8)
4
+ stimulus_reflex (3.5.3)
5
+ actioncable (>= 5.2)
6
+ actionpack (>= 5.2)
7
+ actionview (>= 5.2)
8
+ activesupport (>= 5.2)
9
9
  cable_ready (~> 5.0)
10
10
  nokogiri (~> 1.0)
11
+ nokogiri-html5-inference (~> 0.3)
11
12
  rack (>= 2, < 4)
12
- railties (>= 5.2, < 8)
13
+ railties (>= 5.2)
13
14
  redis (>= 4.0, < 6.0)
14
15
 
15
16
  GEM
16
17
  remote: https://rubygems.org/
17
18
  specs:
18
- actioncable (7.0.4.2)
19
- actionpack (= 7.0.4.2)
20
- activesupport (= 7.0.4.2)
19
+ actioncable (7.1.5.1)
20
+ actionpack (= 7.1.5.1)
21
+ activesupport (= 7.1.5.1)
21
22
  nio4r (~> 2.0)
22
23
  websocket-driver (>= 0.6.1)
23
- actionmailbox (7.0.4.2)
24
- actionpack (= 7.0.4.2)
25
- activejob (= 7.0.4.2)
26
- activerecord (= 7.0.4.2)
27
- activestorage (= 7.0.4.2)
28
- activesupport (= 7.0.4.2)
24
+ zeitwerk (~> 2.6)
25
+ actionmailbox (7.1.5.1)
26
+ actionpack (= 7.1.5.1)
27
+ activejob (= 7.1.5.1)
28
+ activerecord (= 7.1.5.1)
29
+ activestorage (= 7.1.5.1)
30
+ activesupport (= 7.1.5.1)
29
31
  mail (>= 2.7.1)
30
32
  net-imap
31
33
  net-pop
32
34
  net-smtp
33
- actionmailer (7.0.4.2)
34
- actionpack (= 7.0.4.2)
35
- actionview (= 7.0.4.2)
36
- activejob (= 7.0.4.2)
37
- activesupport (= 7.0.4.2)
35
+ actionmailer (7.1.5.1)
36
+ actionpack (= 7.1.5.1)
37
+ actionview (= 7.1.5.1)
38
+ activejob (= 7.1.5.1)
39
+ activesupport (= 7.1.5.1)
38
40
  mail (~> 2.5, >= 2.5.4)
39
41
  net-imap
40
42
  net-pop
41
43
  net-smtp
42
- rails-dom-testing (~> 2.0)
43
- actionpack (7.0.4.2)
44
- actionview (= 7.0.4.2)
45
- activesupport (= 7.0.4.2)
46
- rack (~> 2.0, >= 2.2.0)
44
+ rails-dom-testing (~> 2.2)
45
+ actionpack (7.1.5.1)
46
+ actionview (= 7.1.5.1)
47
+ activesupport (= 7.1.5.1)
48
+ nokogiri (>= 1.8.5)
49
+ racc
50
+ rack (>= 2.2.4)
51
+ rack-session (>= 1.0.1)
47
52
  rack-test (>= 0.6.3)
48
- rails-dom-testing (~> 2.0)
49
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
50
- actiontext (7.0.4.2)
51
- actionpack (= 7.0.4.2)
52
- activerecord (= 7.0.4.2)
53
- activestorage (= 7.0.4.2)
54
- activesupport (= 7.0.4.2)
53
+ rails-dom-testing (~> 2.2)
54
+ rails-html-sanitizer (~> 1.6)
55
+ actiontext (7.1.5.1)
56
+ actionpack (= 7.1.5.1)
57
+ activerecord (= 7.1.5.1)
58
+ activestorage (= 7.1.5.1)
59
+ activesupport (= 7.1.5.1)
55
60
  globalid (>= 0.6.0)
56
61
  nokogiri (>= 1.8.5)
57
- actionview (7.0.4.2)
58
- activesupport (= 7.0.4.2)
62
+ actionview (7.1.5.1)
63
+ activesupport (= 7.1.5.1)
59
64
  builder (~> 3.1)
60
- erubi (~> 1.4)
61
- rails-dom-testing (~> 2.0)
62
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
63
- activejob (7.0.4.2)
64
- activesupport (= 7.0.4.2)
65
+ erubi (~> 1.11)
66
+ rails-dom-testing (~> 2.2)
67
+ rails-html-sanitizer (~> 1.6)
68
+ activejob (7.1.5.1)
69
+ activesupport (= 7.1.5.1)
65
70
  globalid (>= 0.3.6)
66
- activemodel (7.0.4.2)
67
- activesupport (= 7.0.4.2)
68
- activerecord (7.0.4.2)
69
- activemodel (= 7.0.4.2)
70
- activesupport (= 7.0.4.2)
71
- activestorage (7.0.4.2)
72
- actionpack (= 7.0.4.2)
73
- activejob (= 7.0.4.2)
74
- activerecord (= 7.0.4.2)
75
- activesupport (= 7.0.4.2)
71
+ activemodel (7.1.5.1)
72
+ activesupport (= 7.1.5.1)
73
+ activerecord (7.1.5.1)
74
+ activemodel (= 7.1.5.1)
75
+ activesupport (= 7.1.5.1)
76
+ timeout (>= 0.4.0)
77
+ activestorage (7.1.5.1)
78
+ actionpack (= 7.1.5.1)
79
+ activejob (= 7.1.5.1)
80
+ activerecord (= 7.1.5.1)
81
+ activesupport (= 7.1.5.1)
76
82
  marcel (~> 1.0)
77
- mini_mime (>= 1.1.0)
78
- activesupport (7.0.4.2)
83
+ activesupport (7.1.5.1)
84
+ base64
85
+ benchmark (>= 0.3)
86
+ bigdecimal
79
87
  concurrent-ruby (~> 1.0, >= 1.0.2)
88
+ connection_pool (>= 2.2.5)
89
+ drb
80
90
  i18n (>= 1.6, < 2)
91
+ logger (>= 1.4.2)
81
92
  minitest (>= 5.1)
93
+ mutex_m
94
+ securerandom (>= 0.3)
82
95
  tzinfo (~> 2.0)
83
96
  ast (2.4.2)
84
- builder (3.2.4)
85
- cable_ready (5.0.1)
97
+ base64 (0.2.0)
98
+ benchmark (0.4.0)
99
+ bigdecimal (3.1.8)
100
+ builder (3.3.0)
101
+ cable_ready (5.0.6)
86
102
  actionpack (>= 5.2)
87
103
  actionview (>= 5.2)
88
104
  activesupport (>= 5.2)
105
+ observer (~> 0.1)
89
106
  railties (>= 5.2)
90
107
  thread-local (>= 1.1.0)
91
- concurrent-ruby (1.2.2)
92
- connection_pool (2.4.0)
108
+ concurrent-ruby (1.3.4)
109
+ connection_pool (2.4.1)
93
110
  crass (1.0.6)
94
- date (3.3.3)
95
- erubi (1.12.0)
96
- globalid (1.1.0)
97
- activesupport (>= 5.0)
98
- i18n (1.14.1)
111
+ date (3.3.4)
112
+ drb (2.2.1)
113
+ erubi (1.13.0)
114
+ globalid (1.2.1)
115
+ activesupport (>= 6.1)
116
+ i18n (1.14.6)
99
117
  concurrent-ruby (~> 1.0)
118
+ io-console (0.7.2)
119
+ irb (1.14.0)
120
+ rdoc (>= 4.0.0)
121
+ reline (>= 0.4.2)
100
122
  json (2.6.3)
101
123
  language_server-protocol (3.17.0.3)
102
- loofah (2.21.3)
124
+ logger (1.6.2)
125
+ loofah (2.23.1)
103
126
  crass (~> 1.0.2)
104
127
  nokogiri (>= 1.12.0)
105
128
  magic_frozen_string_literal (1.2.0)
@@ -108,68 +131,83 @@ GEM
108
131
  net-imap
109
132
  net-pop
110
133
  net-smtp
111
- marcel (1.0.2)
112
- method_source (1.0.0)
113
- mini_mime (1.1.2)
134
+ marcel (1.0.4)
135
+ mini_mime (1.1.5)
114
136
  minitest (5.18.1)
115
137
  mocha (1.13.0)
116
- net-imap (0.3.4)
138
+ mutex_m (0.3.0)
139
+ net-imap (0.4.17)
117
140
  date
118
141
  net-protocol
119
142
  net-pop (0.1.2)
120
143
  net-protocol
121
- net-protocol (0.2.1)
144
+ net-protocol (0.2.2)
122
145
  timeout
123
- net-smtp (0.3.3)
146
+ net-smtp (0.5.0)
124
147
  net-protocol
125
- nio4r (2.5.8)
126
- nokogiri (1.15.3-x86_64-darwin)
148
+ nio4r (2.7.3)
149
+ nokogiri (1.17.2-x86_64-darwin)
127
150
  racc (~> 1.4)
128
- nokogiri (1.15.3-x86_64-linux)
151
+ nokogiri (1.17.2-x86_64-linux)
129
152
  racc (~> 1.4)
153
+ nokogiri-html5-inference (0.3.0)
154
+ nokogiri (~> 1.14)
155
+ observer (0.1.2)
130
156
  parallel (1.22.1)
131
157
  parser (3.2.1.0)
132
158
  ast (~> 2.4.1)
133
- racc (1.7.1)
134
- rack (2.2.7)
159
+ psych (5.1.2)
160
+ stringio
161
+ racc (1.8.1)
162
+ rack (3.1.8)
163
+ rack-session (2.0.0)
164
+ rack (>= 3.0.0)
135
165
  rack-test (2.1.0)
136
166
  rack (>= 1.3)
137
- rails (7.0.4.2)
138
- actioncable (= 7.0.4.2)
139
- actionmailbox (= 7.0.4.2)
140
- actionmailer (= 7.0.4.2)
141
- actionpack (= 7.0.4.2)
142
- actiontext (= 7.0.4.2)
143
- actionview (= 7.0.4.2)
144
- activejob (= 7.0.4.2)
145
- activemodel (= 7.0.4.2)
146
- activerecord (= 7.0.4.2)
147
- activestorage (= 7.0.4.2)
148
- activesupport (= 7.0.4.2)
167
+ rackup (2.1.0)
168
+ rack (>= 3)
169
+ webrick (~> 1.8)
170
+ rails (7.1.5.1)
171
+ actioncable (= 7.1.5.1)
172
+ actionmailbox (= 7.1.5.1)
173
+ actionmailer (= 7.1.5.1)
174
+ actionpack (= 7.1.5.1)
175
+ actiontext (= 7.1.5.1)
176
+ actionview (= 7.1.5.1)
177
+ activejob (= 7.1.5.1)
178
+ activemodel (= 7.1.5.1)
179
+ activerecord (= 7.1.5.1)
180
+ activestorage (= 7.1.5.1)
181
+ activesupport (= 7.1.5.1)
149
182
  bundler (>= 1.15.0)
150
- railties (= 7.0.4.2)
151
- rails-dom-testing (2.1.1)
183
+ railties (= 7.1.5.1)
184
+ rails-dom-testing (2.2.0)
152
185
  activesupport (>= 5.0.0)
153
186
  minitest
154
187
  nokogiri (>= 1.6)
155
- rails-html-sanitizer (1.6.0)
188
+ rails-html-sanitizer (1.6.2)
156
189
  loofah (~> 2.21)
157
- nokogiri (~> 1.14)
158
- railties (7.0.4.2)
159
- actionpack (= 7.0.4.2)
160
- activesupport (= 7.0.4.2)
161
- method_source
190
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
191
+ railties (7.1.5.1)
192
+ actionpack (= 7.1.5.1)
193
+ activesupport (= 7.1.5.1)
194
+ irb
195
+ rackup (>= 1.0.0)
162
196
  rake (>= 12.2)
163
- thor (~> 1.0)
164
- zeitwerk (~> 2.5)
197
+ thor (~> 1.0, >= 1.2.2)
198
+ zeitwerk (~> 2.6)
165
199
  rainbow (3.1.1)
166
- rake (13.0.6)
200
+ rake (13.2.1)
201
+ rdoc (6.7.0)
202
+ psych (>= 4.0.0)
167
203
  redis (5.0.6)
168
204
  redis-client (>= 0.9.0)
169
205
  redis-client (0.14.0)
170
206
  connection_pool
171
207
  regexp_parser (2.7.0)
172
- rexml (3.2.5)
208
+ reline (0.5.10)
209
+ io-console (~> 0.5)
210
+ rexml (3.3.9)
173
211
  rubocop (1.44.1)
174
212
  json (~> 2.3)
175
213
  parallel (~> 1.10)
@@ -186,31 +224,36 @@ GEM
186
224
  rubocop (>= 1.7.0, < 2.0)
187
225
  rubocop-ast (>= 0.4.0)
188
226
  ruby-progressbar (1.11.0)
227
+ securerandom (0.3.2)
189
228
  standard (1.24.3)
190
229
  language_server-protocol (~> 3.17.0.2)
191
230
  rubocop (= 1.44.1)
192
231
  rubocop-performance (= 1.15.2)
193
- thor (1.2.2)
232
+ stringio (3.1.1)
233
+ thor (1.3.2)
194
234
  thread-local (1.1.0)
195
- timeout (0.3.2)
235
+ timeout (0.4.1)
196
236
  tzinfo (2.0.6)
197
237
  concurrent-ruby (~> 1.0)
198
238
  unicode-display_width (2.4.2)
199
- websocket-driver (0.7.5)
239
+ webrick (1.8.2)
240
+ websocket-driver (0.7.6)
200
241
  websocket-extensions (>= 0.1.0)
201
242
  websocket-extensions (0.1.5)
202
- zeitwerk (2.6.8)
243
+ zeitwerk (2.6.18)
203
244
 
204
245
  PLATFORMS
205
246
  x86_64-darwin-19
206
247
  x86_64-darwin-22
248
+ x86_64-darwin-23
207
249
  x86_64-linux
208
250
 
209
251
  DEPENDENCIES
210
252
  bundler (~> 2.0)
211
253
  magic_frozen_string_literal (~> 1.2)
254
+ minitest (= 5.18.1)
212
255
  mocha (~> 1.13)
213
- rails (>= 5.2, < 8)
256
+ rails (>= 5.2)
214
257
  rake (~> 13.0)
215
258
  standard (~> 1.24)
216
259
  stimulus_reflex!
data/README.md CHANGED
@@ -141,10 +141,10 @@ View the [wiki](https://github.com/stimulusreflex/stimulus_reflex/wiki/Editor-Co
141
141
  1. Update the `cable_ready` dependency version in `stimulus_reflex.gemspec` and `package.json`
142
142
  1. Make sure that you run `yarn` and `bundle` to pick up the latest.
143
143
  1. Bump version number at `lib/stimulus_reflex/version.rb`. Pre-release versions use `.preN`
144
- 1. Run `rake build` and `yarn build`
144
+ 1. Run `bundle exec rake build` and `yarn build`
145
145
  1. Run `bin/standardize`
146
146
  1. Commit and push changes to GitHub
147
- 1. Run `rake release`
147
+ 1. Run `bundle exec rake release`
148
148
  1. Run `yarn publish --no-git-tag-version`
149
149
  1. Yarn will prompt you for the new version. Pre-release versions use `-preN`
150
150
  1. Commit and push changes to GitHub
@@ -945,7 +945,7 @@ const extractDataAttributes = element => {
945
945
 
946
946
  var name = "stimulus_reflex";
947
947
 
948
- var version = "3.5.0-rc3";
948
+ var version = "3.5.3";
949
949
 
950
950
  var description = "Build reactive applications with the Rails tooling you already know and love.";
951
951
 
@@ -995,19 +995,19 @@ var peerDependencies = {
995
995
  var dependencies = {
996
996
  "@hotwired/stimulus": "^3",
997
997
  "@rails/actioncable": "^6 || ^7",
998
- cable_ready: "^5.0.0"
998
+ cable_ready: "^5.0.6"
999
999
  };
1000
1000
 
1001
1001
  var devDependencies = {
1002
- "@open-wc/testing": "^3.1.7",
1003
- "@rollup/plugin-json": "^6.0.0",
1004
- "@rollup/plugin-node-resolve": "^15.0.1",
1005
- "@rollup/plugin-terser": "^0.4.0",
1006
- "@web/dev-server-esbuild": "^0.3.3",
1007
- "@web/dev-server-rollup": "^0.3.21",
1008
- "@web/test-runner": "^0.15.1",
1002
+ "@open-wc/testing": "^4.0.0",
1003
+ "@rollup/plugin-json": "^6.1.0",
1004
+ "@rollup/plugin-node-resolve": "^15.3.0",
1005
+ "@rollup/plugin-terser": "^0.4.4",
1006
+ "@web/dev-server-esbuild": "^1.0.2",
1007
+ "@web/dev-server-rollup": "^0.6.4",
1008
+ "@web/test-runner": "^0.19.0",
1009
1009
  "prettier-standard": "^16.4.1",
1010
- rollup: "^3.19.1",
1010
+ rollup: "^4.22.4",
1011
1011
  "toastify-js": "^1.12.0",
1012
1012
  vitepress: "^1.0.0-beta.1"
1013
1013
  };
@@ -1260,7 +1260,7 @@ const findControllerByReflexName = (reflexName, controllers) => {
1260
1260
  const identifier = reflexNameToControllerIdentifier(extractReflexName(reflexName));
1261
1261
  return identifier === controller.identifier;
1262
1262
  }));
1263
- return controller || controllers[0];
1263
+ return controller;
1264
1264
  };
1265
1265
 
1266
1266
  const scanForReflexes = debounce((() => {
@@ -1281,7 +1281,8 @@ const scanForReflexesOnElement = (element, controller = null) => {
1281
1281
  const controllerName = controller ? controller.identifier : "stimulus-reflex";
1282
1282
  actions.push(`${reflexName.split("->")[0]}->${controllerName}#__perform`);
1283
1283
  const parentControllerElement = element.closest(`[data-controller~=${controllerName}]`);
1284
- if (!parentControllerElement) {
1284
+ const elementPreviouslyHadStimulusReflexController = element === parentControllerElement && controllerName === "stimulus-reflex";
1285
+ if (!parentControllerElement || elementPreviouslyHadStimulusReflexController) {
1285
1286
  controllers.push(controllerName);
1286
1287
  }
1287
1288
  }));
@@ -1440,6 +1441,7 @@ document.addEventListener("readystatechange", (() => {
1440
1441
 
1441
1442
  var StimulusReflex = Object.freeze({
1442
1443
  __proto__: null,
1444
+ StimulusReflexController: StimulusReflexController,
1443
1445
  initialize: initialize,
1444
1446
  reflexes: reflexes,
1445
1447
  register: register,
@@ -1467,4 +1469,4 @@ const global = {
1467
1469
 
1468
1470
  window.StimulusReflex = global;
1469
1471
 
1470
- export { global as default, initialize, reflexes, register, scanForReflexes, scanForReflexesOnElement, useReflex };
1472
+ export { StimulusReflexController, global as default, initialize, reflexes, register, scanForReflexes, scanForReflexesOnElement, useReflex };
@@ -869,7 +869,7 @@
869
869
  return attrs;
870
870
  };
871
871
  var name = "stimulus_reflex";
872
- var version = "3.5.0-rc3";
872
+ var version = "3.5.3";
873
873
  var description = "Build reactive applications with the Rails tooling you already know and love.";
874
874
  var keywords = [ "ruby", "rails", "websockets", "actioncable", "turbolinks", "reactive", "cable", "ujs", "ssr", "stimulus", "reflex", "stimulus_reflex", "dom", "morphdom" ];
875
875
  var homepage = "https://docs.stimulusreflex.com";
@@ -902,18 +902,18 @@
902
902
  var dependencies = {
903
903
  "@hotwired/stimulus": "^3",
904
904
  "@rails/actioncable": "^6 || ^7",
905
- cable_ready: "^5.0.0"
905
+ cable_ready: "^5.0.6"
906
906
  };
907
907
  var devDependencies = {
908
- "@open-wc/testing": "^3.1.7",
909
- "@rollup/plugin-json": "^6.0.0",
910
- "@rollup/plugin-node-resolve": "^15.0.1",
911
- "@rollup/plugin-terser": "^0.4.0",
912
- "@web/dev-server-esbuild": "^0.3.3",
913
- "@web/dev-server-rollup": "^0.3.21",
914
- "@web/test-runner": "^0.15.1",
908
+ "@open-wc/testing": "^4.0.0",
909
+ "@rollup/plugin-json": "^6.1.0",
910
+ "@rollup/plugin-node-resolve": "^15.3.0",
911
+ "@rollup/plugin-terser": "^0.4.4",
912
+ "@web/dev-server-esbuild": "^1.0.2",
913
+ "@web/dev-server-rollup": "^0.6.4",
914
+ "@web/test-runner": "^0.19.0",
915
915
  "prettier-standard": "^16.4.1",
916
- rollup: "^3.19.1",
916
+ rollup: "^4.22.4",
917
917
  "toastify-js": "^1.12.0",
918
918
  vitepress: "^1.0.0-beta.1"
919
919
  };
@@ -1152,7 +1152,7 @@
1152
1152
  const identifier = reflexNameToControllerIdentifier(extractReflexName(reflexName));
1153
1153
  return identifier === controller.identifier;
1154
1154
  }));
1155
- return controller || controllers[0];
1155
+ return controller;
1156
1156
  };
1157
1157
  const scanForReflexes = debounce((() => {
1158
1158
  const reflexElements = document.querySelectorAll(`[${Schema.reflex}]`);
@@ -1171,7 +1171,8 @@
1171
1171
  const controllerName = controller ? controller.identifier : "stimulus-reflex";
1172
1172
  actions.push(`${reflexName.split("->")[0]}->${controllerName}#__perform`);
1173
1173
  const parentControllerElement = element.closest(`[data-controller~=${controllerName}]`);
1174
- if (!parentControllerElement) {
1174
+ const elementPreviouslyHadStimulusReflexController = element === parentControllerElement && controllerName === "stimulus-reflex";
1175
+ if (!parentControllerElement || elementPreviouslyHadStimulusReflexController) {
1175
1176
  controllers.push(controllerName);
1176
1177
  }
1177
1178
  }));
@@ -1318,6 +1319,7 @@
1318
1319
  }));
1319
1320
  var StimulusReflex = Object.freeze({
1320
1321
  __proto__: null,
1322
+ StimulusReflexController: StimulusReflexController,
1321
1323
  initialize: initialize,
1322
1324
  reflexes: reflexes,
1323
1325
  register: register,
@@ -1342,6 +1344,7 @@
1342
1344
  }
1343
1345
  };
1344
1346
  window.StimulusReflex = global;
1347
+ exports.StimulusReflexController = StimulusReflexController;
1345
1348
  exports.default = global;
1346
1349
  exports.initialize = initialize;
1347
1350
  exports.reflexes = reflexes;
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.constantize
4
- attr_reader :reflex_data
5
-
6
4
  def stream_name
7
5
  [params[:channel], connection.connection_identifier].reject(&:blank?).join(":")
8
6
  end
@@ -13,76 +11,74 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
13
11
  end
14
12
 
15
13
  def receive(data)
16
- @reflex_data = StimulusReflex::ReflexData.new(data)
17
14
  begin
18
- begin
19
- reflex = StimulusReflex::ReflexFactory.create_reflex_from_data(self, @reflex_data)
20
- delegate_call_to_reflex reflex
21
- rescue => exception
22
- error = exception_with_backtrace(exception)
23
- error_message = "\e[31mReflex #{reflex_data.target} failed: #{error[:message]} [#{reflex_data.url}]\e[0m\n#{error[:stack]}"
15
+ reflex = StimulusReflex::ReflexFactory.new(self, data).call
16
+ delegate_call_to_reflex reflex
17
+ rescue => exception
18
+ error = exception_with_backtrace(exception)
24
19
 
25
- if reflex
26
- reflex.rescue_with_handler(exception)
27
- reflex.logger&.error error_message
28
- reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
29
- else
30
- unless exception.is_a?(StimulusReflex::VersionMismatchError)
31
- StimulusReflex.config.logger.error error_message
32
- end
20
+ if reflex
21
+ error_message = "\e[31mReflex #{reflex.data.target} failed: #{error[:message]} [#{reflex.url}]\e[0m\n#{error[:stack]}"
22
+ reflex.rescue_with_handler(exception)
23
+ reflex.logger&.error error_message
24
+ reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
25
+ else
26
+ error_message = "\e[31mReflex failed: #{error[:message]} \e[0m\n#{error[:stack]}"
27
+ unless exception.is_a?(StimulusReflex::VersionMismatchError)
28
+ StimulusReflex.config.logger.error error_message
29
+ end
33
30
 
34
- if error_message.to_s.include? "No route matches"
35
- initializer_path = Rails.root.join("config", "initializers", "stimulus_reflex.rb")
31
+ if error_message.to_s.include? "No route matches"
32
+ initializer_path = Rails.root.join("config", "initializers", "stimulus_reflex.rb")
36
33
 
37
- StimulusReflex.config.logger.warn <<~NOTE
38
- \e[33mNOTE: StimulusReflex failed to locate a matching route and could not re-render the page.
34
+ StimulusReflex.config.logger.warn <<~NOTE
35
+ \e[33mNOTE: StimulusReflex failed to locate a matching route and could not re-render the page.
39
36
 
40
- If your app uses Rack middleware to rewrite part of the request path, you must enable those middleware modules in StimulusReflex.
41
- The StimulusReflex initializer should be located at #{initializer_path}, or you can generate it with:
37
+ If your app uses Rack middleware to rewrite part of the request path, you must enable those middleware modules in StimulusReflex.
38
+ The StimulusReflex initializer should be located at #{initializer_path}, or you can generate it with:
42
39
 
43
- $ bundle exec rails generate stimulus_reflex:config
40
+ $ bundle exec rails generate stimulus_reflex:config
44
41
 
45
- Configure any required middleware:
42
+ Configure any required middleware:
46
43
 
47
- StimulusReflex.configure do |config|
48
- config.middleware.use FirstRackMiddleware
49
- config.middleware.use SecondRackMiddleware
50
- end\e[0m
44
+ StimulusReflex.configure do |config|
45
+ config.middleware.use FirstRackMiddleware
46
+ config.middleware.use SecondRackMiddleware
47
+ end\e[0m
51
48
 
52
- NOTE
53
- end
49
+ NOTE
54
50
  end
55
- return
56
51
  end
52
+ return
53
+ end
57
54
 
58
- if reflex.halted?
59
- reflex.broadcast_halt data: data
60
- elsif reflex.forbidden?
61
- reflex.broadcast_forbid data: data
62
- else
63
- begin
64
- reflex.broadcast(reflex_data.selectors, data)
65
- rescue => exception
66
- reflex.rescue_with_handler(exception)
67
- error = exception_with_backtrace(exception)
68
- reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
69
- reflex.logger&.error "\e[31mReflex failed to re-render: #{error[:message]} [#{reflex_data.url}]\e[0m\n#{error[:stack]}"
70
- end
71
- end
72
- ensure
73
- if reflex
74
- commit_session(reflex)
75
- report_failed_basic_auth(reflex) if reflex.controller?
76
- reflex.logger&.log_all_operations
55
+ if reflex.halted?
56
+ reflex.broadcast_halt data: data
57
+ elsif reflex.forbidden?
58
+ reflex.broadcast_forbid data: data
59
+ else
60
+ begin
61
+ reflex.broadcast(reflex.selectors, data)
62
+ rescue => exception
63
+ reflex.rescue_with_handler(exception)
64
+ error = exception_with_backtrace(exception)
65
+ reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
66
+ reflex.logger&.error "\e[31mReflex failed to re-render: #{error[:message]} [#{reflex.url}]\e[0m\n#{error[:stack]}"
77
67
  end
78
68
  end
69
+ ensure
70
+ if reflex
71
+ commit_session(reflex)
72
+ report_failed_basic_auth(reflex) if reflex.controller?
73
+ reflex.logger&.log_all_operations
74
+ end
79
75
  end
80
76
 
81
77
  private
82
78
 
83
79
  def delegate_call_to_reflex(reflex)
84
- method_name = reflex_data.method_name
85
- arguments = reflex_data.arguments
80
+ method_name = reflex.method_name
81
+ arguments = reflex.data.arguments
86
82
  method = reflex.method(method_name)
87
83
 
88
84
  policy = StimulusReflex::ReflexMethodInvocationPolicy.new(method, arguments)