stimulus_reflex 3.5.0.pre9 → 3.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of stimulus_reflex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +122 -127
- data/README.md +13 -19
- data/app/assets/javascripts/stimulus_reflex.js +1017 -523
- data/app/assets/javascripts/stimulus_reflex.umd.js +940 -496
- data/app/channels/stimulus_reflex/channel.rb +9 -24
- data/bin/console +0 -2
- data/bin/standardize +2 -1
- data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +68 -9
- data/lib/generators/stimulus_reflex/templates/app/controllers/examples_controller.rb.tt +9 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/consumer.js.tt +6 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.esbuild.tt +4 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt +2 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.shakapacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.vite.tt +1 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.webpacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +4 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +2 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt +9 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +141 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +11 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +74 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.esbuild.tt +7 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.shakapacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.vite.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt +5 -0
- data/{test/tmp/app/reflexes/user_reflex.rb → lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt} +38 -9
- data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +27 -0
- data/lib/generators/stimulus_reflex/templates/app/views/examples/show.html.erb.tt +207 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +27 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +18 -13
- data/lib/generators/stimulus_reflex/templates/esbuild.config.mjs.tt +94 -0
- data/lib/install/action_cable.rb +155 -0
- data/lib/install/broadcaster.rb +90 -0
- data/lib/install/bundle.rb +56 -0
- data/lib/install/compression.rb +41 -0
- data/lib/install/config.rb +87 -0
- data/lib/install/development.rb +110 -0
- data/lib/install/esbuild.rb +114 -0
- data/lib/install/example.rb +22 -0
- data/lib/install/importmap.rb +133 -0
- data/lib/install/initializers.rb +25 -0
- data/lib/install/mrujs.rb +133 -0
- data/lib/install/npm_packages.rb +25 -0
- data/lib/install/reflexes.rb +25 -0
- data/lib/install/shakapacker.rb +64 -0
- data/lib/install/spring.rb +54 -0
- data/lib/install/updatable.rb +34 -0
- data/lib/install/vite.rb +64 -0
- data/lib/install/webpacker.rb +90 -0
- data/lib/install/yarn.rb +55 -0
- data/lib/stimulus_reflex/broadcasters/broadcaster.rb +15 -8
- data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +7 -8
- data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +10 -10
- data/lib/stimulus_reflex/broadcasters/update.rb +3 -0
- data/lib/stimulus_reflex/cable_readiness.rb +29 -0
- data/lib/stimulus_reflex/cable_ready_channels.rb +6 -5
- data/lib/stimulus_reflex/callbacks.rb +17 -1
- data/lib/stimulus_reflex/concern_enhancer.rb +6 -4
- data/lib/stimulus_reflex/configuration.rb +12 -2
- data/lib/stimulus_reflex/dataset.rb +11 -1
- data/lib/stimulus_reflex/engine.rb +16 -9
- data/lib/stimulus_reflex/html/document.rb +59 -0
- data/lib/stimulus_reflex/html/document_fragment.rb +13 -0
- data/lib/stimulus_reflex/importmap.rb +6 -3
- data/lib/stimulus_reflex/installer.rb +274 -0
- data/lib/stimulus_reflex/open_struct_fix.rb +2 -0
- data/lib/stimulus_reflex/reflex.rb +40 -31
- data/lib/stimulus_reflex/reflex_data.rb +19 -3
- data/lib/stimulus_reflex/reflex_factory.rb +6 -3
- data/lib/stimulus_reflex/request_parameters.rb +2 -0
- data/lib/stimulus_reflex/utils/logger.rb +10 -0
- data/lib/stimulus_reflex/utils/sanity_checker.rb +8 -48
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/stimulus_reflex/version_checker.rb +54 -0
- data/lib/stimulus_reflex.rb +2 -0
- data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +250 -0
- data/package.json +36 -28
- data/{rollup.config.js → rollup.config.mjs} +6 -24
- data/stimulus_reflex.gemspec +16 -19
- data/yarn.lock +1331 -748
- metadata +129 -79
- data/LATEST +0 -1
- data/app/assets/javascripts/stimulus_reflex.min.js +0 -2
- data/app/assets/javascripts/stimulus_reflex.min.js.map +0 -1
- data/app/assets/javascripts/stimulus_reflex.umd.min.js +0 -905
- data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +0 -1
- data/lib/generators/stimulus_reflex/initializer_generator.rb +0 -14
- data/test/broadcasters/broadcaster_test.rb +0 -11
- data/test/broadcasters/broadcaster_test_case.rb +0 -39
- data/test/broadcasters/nothing_broadcaster_test.rb +0 -31
- data/test/broadcasters/page_broadcaster_test.rb +0 -79
- data/test/broadcasters/selector_broadcaster_test.rb +0 -173
- data/test/callbacks_test.rb +0 -652
- data/test/concern_enhancer_test.rb +0 -54
- data/test/element_test.rb +0 -254
- data/test/generators/stimulus_reflex_generator_test.rb +0 -58
- data/test/reflex_test.rb +0 -43
- data/test/test_helper.rb +0 -71
- data/test/tmp/app/reflexes/application_reflex.rb +0 -12
- data/yarn-error.log +0 -4964
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.5.0.
|
4
|
+
version: 3.5.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actioncable
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '8'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '5.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '8'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: actionpack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +37,9 @@ dependencies:
|
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '5.2'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '8'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +47,9 @@ dependencies:
|
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '5.2'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '8'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: actionview
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +57,9 @@ dependencies:
|
|
45
57
|
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: '5.2'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '8'
|
48
63
|
type: :runtime
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,6 +67,9 @@ dependencies:
|
|
52
67
|
- - ">="
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: '5.2'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '8'
|
55
73
|
- !ruby/object:Gem::Dependency
|
56
74
|
name: activesupport
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +77,9 @@ dependencies:
|
|
59
77
|
- - ">="
|
60
78
|
- !ruby/object:Gem::Version
|
61
79
|
version: '5.2'
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '8'
|
62
83
|
type: :runtime
|
63
84
|
prerelease: false
|
64
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,6 +87,9 @@ dependencies:
|
|
66
87
|
- - ">="
|
67
88
|
- !ruby/object:Gem::Version
|
68
89
|
version: '5.2'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '8'
|
69
93
|
- !ruby/object:Gem::Dependency
|
70
94
|
name: railties
|
71
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +97,9 @@ dependencies:
|
|
73
97
|
- - ">="
|
74
98
|
- !ruby/object:Gem::Version
|
75
99
|
version: '5.2'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '8'
|
76
103
|
type: :runtime
|
77
104
|
prerelease: false
|
78
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,62 +107,77 @@ dependencies:
|
|
80
107
|
- - ">="
|
81
108
|
- !ruby/object:Gem::Version
|
82
109
|
version: '5.2'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '8'
|
83
113
|
- !ruby/object:Gem::Dependency
|
84
114
|
name: cable_ready
|
85
115
|
requirement: !ruby/object:Gem::Requirement
|
86
116
|
requirements:
|
87
117
|
- - ">="
|
88
118
|
- !ruby/object:Gem::Version
|
89
|
-
version: 5.0.0.
|
119
|
+
version: 5.0.0.rc1
|
90
120
|
type: :runtime
|
91
121
|
prerelease: false
|
92
122
|
version_requirements: !ruby/object:Gem::Requirement
|
93
123
|
requirements:
|
94
124
|
- - ">="
|
95
125
|
- !ruby/object:Gem::Version
|
96
|
-
version: 5.0.0.
|
126
|
+
version: 5.0.0.rc1
|
97
127
|
- !ruby/object:Gem::Dependency
|
98
128
|
name: nokogiri
|
99
129
|
requirement: !ruby/object:Gem::Requirement
|
100
130
|
requirements:
|
101
|
-
- - "
|
131
|
+
- - "~>"
|
102
132
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
133
|
+
version: '1.0'
|
104
134
|
type: :runtime
|
105
135
|
prerelease: false
|
106
136
|
version_requirements: !ruby/object:Gem::Requirement
|
107
137
|
requirements:
|
108
|
-
- - "
|
138
|
+
- - "~>"
|
109
139
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
140
|
+
version: '1.0'
|
111
141
|
- !ruby/object:Gem::Dependency
|
112
142
|
name: rack
|
113
143
|
requirement: !ruby/object:Gem::Requirement
|
114
144
|
requirements:
|
115
145
|
- - ">="
|
116
146
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
147
|
+
version: '2'
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '4'
|
118
151
|
type: :runtime
|
119
152
|
prerelease: false
|
120
153
|
version_requirements: !ruby/object:Gem::Requirement
|
121
154
|
requirements:
|
122
155
|
- - ">="
|
123
156
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
157
|
+
version: '2'
|
158
|
+
- - "<"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '4'
|
125
161
|
- !ruby/object:Gem::Dependency
|
126
162
|
name: redis
|
127
163
|
requirement: !ruby/object:Gem::Requirement
|
128
164
|
requirements:
|
129
165
|
- - ">="
|
130
166
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
167
|
+
version: '4.0'
|
168
|
+
- - "<"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '6.0'
|
132
171
|
type: :runtime
|
133
172
|
prerelease: false
|
134
173
|
version_requirements: !ruby/object:Gem::Requirement
|
135
174
|
requirements:
|
136
175
|
- - ">="
|
137
176
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
177
|
+
version: '4.0'
|
178
|
+
- - "<"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '6.0'
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: bundler
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,47 +193,33 @@ dependencies:
|
|
151
193
|
- !ruby/object:Gem::Version
|
152
194
|
version: '2.0'
|
153
195
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
196
|
+
name: magic_frozen_string_literal
|
155
197
|
requirement: !ruby/object:Gem::Requirement
|
156
198
|
requirements:
|
157
|
-
- - "
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: pry
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
199
|
+
- - "~>"
|
172
200
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
201
|
+
version: '1.2'
|
174
202
|
type: :development
|
175
203
|
prerelease: false
|
176
204
|
version_requirements: !ruby/object:Gem::Requirement
|
177
205
|
requirements:
|
178
|
-
- - "
|
206
|
+
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
208
|
+
version: '1.2'
|
181
209
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
210
|
+
name: mocha
|
183
211
|
requirement: !ruby/object:Gem::Requirement
|
184
212
|
requirements:
|
185
|
-
- - "
|
213
|
+
- - "~>"
|
186
214
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
215
|
+
version: '1.13'
|
188
216
|
type: :development
|
189
217
|
prerelease: false
|
190
218
|
version_requirements: !ruby/object:Gem::Requirement
|
191
219
|
requirements:
|
192
|
-
- - "
|
220
|
+
- - "~>"
|
193
221
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
222
|
+
version: '1.13'
|
195
223
|
- !ruby/object:Gem::Dependency
|
196
224
|
name: rails
|
197
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,6 +227,9 @@ dependencies:
|
|
199
227
|
- - ">="
|
200
228
|
- !ruby/object:Gem::Version
|
201
229
|
version: '5.2'
|
230
|
+
- - "<"
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: '8'
|
202
233
|
type: :development
|
203
234
|
prerelease: false
|
204
235
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -206,34 +237,37 @@ dependencies:
|
|
206
237
|
- - ">="
|
207
238
|
- !ruby/object:Gem::Version
|
208
239
|
version: '5.2'
|
240
|
+
- - "<"
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: '8'
|
209
243
|
- !ruby/object:Gem::Dependency
|
210
244
|
name: rake
|
211
245
|
requirement: !ruby/object:Gem::Requirement
|
212
246
|
requirements:
|
213
|
-
- - "
|
247
|
+
- - "~>"
|
214
248
|
- !ruby/object:Gem::Version
|
215
|
-
version: '0'
|
249
|
+
version: '13.0'
|
216
250
|
type: :development
|
217
251
|
prerelease: false
|
218
252
|
version_requirements: !ruby/object:Gem::Requirement
|
219
253
|
requirements:
|
220
|
-
- - "
|
254
|
+
- - "~>"
|
221
255
|
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
256
|
+
version: '13.0'
|
223
257
|
- !ruby/object:Gem::Dependency
|
224
|
-
name:
|
258
|
+
name: standard
|
225
259
|
requirement: !ruby/object:Gem::Requirement
|
226
260
|
requirements:
|
227
261
|
- - "~>"
|
228
262
|
- !ruby/object:Gem::Version
|
229
|
-
version: '1.
|
263
|
+
version: '1.24'
|
230
264
|
type: :development
|
231
265
|
prerelease: false
|
232
266
|
version_requirements: !ruby/object:Gem::Requirement
|
233
267
|
requirements:
|
234
268
|
- - "~>"
|
235
269
|
- !ruby/object:Gem::Version
|
236
|
-
version: '1.
|
270
|
+
version: '1.24'
|
237
271
|
description:
|
238
272
|
email:
|
239
273
|
- natehop@gmail.com
|
@@ -245,31 +279,69 @@ files:
|
|
245
279
|
- CODE_OF_CONDUCT.md
|
246
280
|
- Gemfile
|
247
281
|
- Gemfile.lock
|
248
|
-
- LATEST
|
249
282
|
- LICENSE.txt
|
250
283
|
- README.md
|
251
284
|
- Rakefile
|
252
285
|
- app/assets/javascripts/stimulus_reflex.js
|
253
|
-
- app/assets/javascripts/stimulus_reflex.min.js
|
254
|
-
- app/assets/javascripts/stimulus_reflex.min.js.map
|
255
286
|
- app/assets/javascripts/stimulus_reflex.umd.js
|
256
|
-
- app/assets/javascripts/stimulus_reflex.umd.min.js
|
257
|
-
- app/assets/javascripts/stimulus_reflex.umd.min.js.map
|
258
287
|
- app/channels/stimulus_reflex/channel.rb
|
259
288
|
- bin/console
|
260
289
|
- bin/loc
|
261
290
|
- bin/rake
|
262
291
|
- bin/setup
|
263
292
|
- bin/standardize
|
264
|
-
- lib/generators/stimulus_reflex/initializer_generator.rb
|
265
293
|
- lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
|
294
|
+
- lib/generators/stimulus_reflex/templates/app/controllers/examples_controller.rb.tt
|
295
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/channels/consumer.js.tt
|
296
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.esbuild.tt
|
297
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt
|
298
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.shakapacker.tt
|
299
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.vite.tt
|
300
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.webpacker.tt
|
301
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt
|
302
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt
|
303
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt
|
304
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt
|
305
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt
|
306
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt
|
307
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt
|
308
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.esbuild.tt
|
309
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt
|
310
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.shakapacker.tt
|
311
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.vite.tt
|
312
|
+
- lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt
|
313
|
+
- lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt
|
314
|
+
- lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt
|
315
|
+
- lib/generators/stimulus_reflex/templates/app/views/examples/show.html.erb.tt
|
316
|
+
- lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb
|
266
317
|
- lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb
|
318
|
+
- lib/generators/stimulus_reflex/templates/esbuild.config.mjs.tt
|
319
|
+
- lib/install/action_cable.rb
|
320
|
+
- lib/install/broadcaster.rb
|
321
|
+
- lib/install/bundle.rb
|
322
|
+
- lib/install/compression.rb
|
323
|
+
- lib/install/config.rb
|
324
|
+
- lib/install/development.rb
|
325
|
+
- lib/install/esbuild.rb
|
326
|
+
- lib/install/example.rb
|
327
|
+
- lib/install/importmap.rb
|
328
|
+
- lib/install/initializers.rb
|
329
|
+
- lib/install/mrujs.rb
|
330
|
+
- lib/install/npm_packages.rb
|
331
|
+
- lib/install/reflexes.rb
|
332
|
+
- lib/install/shakapacker.rb
|
333
|
+
- lib/install/spring.rb
|
334
|
+
- lib/install/updatable.rb
|
335
|
+
- lib/install/vite.rb
|
336
|
+
- lib/install/webpacker.rb
|
337
|
+
- lib/install/yarn.rb
|
267
338
|
- lib/stimulus_reflex.rb
|
268
339
|
- lib/stimulus_reflex/broadcasters/broadcaster.rb
|
269
340
|
- lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb
|
270
341
|
- lib/stimulus_reflex/broadcasters/page_broadcaster.rb
|
271
342
|
- lib/stimulus_reflex/broadcasters/selector_broadcaster.rb
|
272
343
|
- lib/stimulus_reflex/broadcasters/update.rb
|
344
|
+
- lib/stimulus_reflex/cable_readiness.rb
|
273
345
|
- lib/stimulus_reflex/cable_ready_channels.rb
|
274
346
|
- lib/stimulus_reflex/callbacks.rb
|
275
347
|
- lib/stimulus_reflex/concern_enhancer.rb
|
@@ -277,7 +349,10 @@ files:
|
|
277
349
|
- lib/stimulus_reflex/dataset.rb
|
278
350
|
- lib/stimulus_reflex/element.rb
|
279
351
|
- lib/stimulus_reflex/engine.rb
|
352
|
+
- lib/stimulus_reflex/html/document.rb
|
353
|
+
- lib/stimulus_reflex/html/document_fragment.rb
|
280
354
|
- lib/stimulus_reflex/importmap.rb
|
355
|
+
- lib/stimulus_reflex/installer.rb
|
281
356
|
- lib/stimulus_reflex/open_struct_fix.rb
|
282
357
|
- lib/stimulus_reflex/policies/reflex_invocation_policy.rb
|
283
358
|
- lib/stimulus_reflex/reflex.rb
|
@@ -289,24 +364,12 @@ files:
|
|
289
364
|
- lib/stimulus_reflex/utils/logger.rb
|
290
365
|
- lib/stimulus_reflex/utils/sanity_checker.rb
|
291
366
|
- lib/stimulus_reflex/version.rb
|
367
|
+
- lib/stimulus_reflex/version_checker.rb
|
368
|
+
- lib/tasks/stimulus_reflex/stimulus_reflex.rake
|
292
369
|
- package.json
|
293
|
-
- rollup.config.
|
370
|
+
- rollup.config.mjs
|
294
371
|
- stimulus_reflex.gemspec
|
295
|
-
- test/broadcasters/broadcaster_test.rb
|
296
|
-
- test/broadcasters/broadcaster_test_case.rb
|
297
|
-
- test/broadcasters/nothing_broadcaster_test.rb
|
298
|
-
- test/broadcasters/page_broadcaster_test.rb
|
299
|
-
- test/broadcasters/selector_broadcaster_test.rb
|
300
|
-
- test/callbacks_test.rb
|
301
|
-
- test/concern_enhancer_test.rb
|
302
|
-
- test/element_test.rb
|
303
|
-
- test/generators/stimulus_reflex_generator_test.rb
|
304
|
-
- test/reflex_test.rb
|
305
|
-
- test/test_helper.rb
|
306
|
-
- test/tmp/app/reflexes/application_reflex.rb
|
307
|
-
- test/tmp/app/reflexes/user_reflex.rb
|
308
372
|
- web-test-runner.config.mjs
|
309
|
-
- yarn-error.log
|
310
373
|
- yarn.lock
|
311
374
|
homepage: https://github.com/stimulusreflex/stimulus_reflex
|
312
375
|
licenses:
|
@@ -340,22 +403,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
340
403
|
- !ruby/object:Gem::Version
|
341
404
|
version: 1.3.1
|
342
405
|
requirements: []
|
343
|
-
rubygems_version: 3.
|
406
|
+
rubygems_version: 3.4.1
|
344
407
|
signing_key:
|
345
408
|
specification_version: 4
|
346
409
|
summary: Build reactive applications with the Rails tooling you already know and love.
|
347
|
-
test_files:
|
348
|
-
- test/broadcasters/broadcaster_test.rb
|
349
|
-
- test/broadcasters/broadcaster_test_case.rb
|
350
|
-
- test/broadcasters/nothing_broadcaster_test.rb
|
351
|
-
- test/broadcasters/page_broadcaster_test.rb
|
352
|
-
- test/broadcasters/selector_broadcaster_test.rb
|
353
|
-
- test/callbacks_test.rb
|
354
|
-
- test/concern_enhancer_test.rb
|
355
|
-
- test/element_test.rb
|
356
|
-
- test/generators/stimulus_reflex_generator_test.rb
|
357
|
-
- test/reflex_test.rb
|
358
|
-
- test/test_helper.rb
|
359
|
-
- test/tmp/app/reflexes/application_reflex.rb
|
360
|
-
- test/tmp/app/reflexes/user_reflex.rb
|
410
|
+
test_files: []
|
361
411
|
...
|
data/LATEST
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.4.1
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{Controller as e}from"@hotwired/stimulus";import t from"cable_ready";import{createConsumer as r}from"@rails/actioncable";const l={reflexAttribute:"data-reflex",reflexPermanentAttribute:"data-reflex-permanent",reflexRootAttribute:"data-reflex-root",reflexSuppressLoggingAttribute:"data-reflex-suppress-logging",reflexDatasetAttribute:"data-reflex-dataset",reflexDatasetAllAttribute:"data-reflex-dataset-all",reflexSerializeFormAttribute:"data-reflex-serialize-form",reflexFormSelectorAttribute:"data-reflex-form-selector",reflexIncludeInnerHtmlAttribute:"data-reflex-include-inner-html",reflexIncludeTextContentAttribute:"data-reflex-include-text-content"};let n={};var o={set(e){n={...l,...e.schema};for(const e in n)Object.defineProperty(this,e.slice(0,-9),{get:()=>n[e]})}};let a=!1;var s={get enabled(){return a},get disabled(){return!a},get value(){return a},set(e){a=!!e},set debug(e){a=!!e}};const i={};var d=(e,t,r,l,n,o)=>{const a=i[e];s.disabled||a.promise.data.suppressLogging||(a.timestamp=new Date,console.log(`↑ stimulus ↑ ${t}`,{reflexId:e,args:r,controller:l,element:n,controllerElement:o}))},c=(e,t)=>{const{detail:r}=e||{},{selector:l,payload:n}=r||{},{reflexId:o,target:a,morph:d}=r.stimulusReflex||{},c=i[o];if(s.disabled||c.promise.data.suppressLogging)return;const u=c.totalOperations>1?` ${c.completedOperations}/${c.totalOperations}`:"",f=c.timestamp?`in ${new Date-c.timestamp}ms`:"CLONED",m=e.type.split(":")[1].split("-").slice(1).join("_");console.log(`↓ reflex ↓ ${a} → ${l||"∞"}${u} ${f}`,{reflexId:o,morph:d,operation:m,halted:t,payload:n})},u=e=>{const{detail:t}=e||{},{reflexId:r,target:l,payload:n}=t.stimulusReflex||{},o=i[r];if(s.disabled||o.promise.data.suppressLogging)return;const a=o.timestamp?`in ${new Date-o.timestamp}ms`:"CLONED";console.log(`↓ reflex ↓ ${l} ${a} %cERROR: ${e.detail.body}`,"color: #f00;",{reflexId:r,payload:n})};let f=!0;var m={get enabled(){return f},get disabled(){return!f},get value(){return f},set(e){f=!!e},set deprecate(e){f=!!e}};const p=()=>{const e=window.crypto||window.msCrypto;return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(t=>(t^e.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))},x=(e,t=!0)=>"string"!=typeof e?"":(e=e.replace(/[\s_](.)/g,(e=>e.toUpperCase())).replace(/[\s_]/g,"").replace(/^(.)/,(e=>e.toLowerCase())),t&&(e=e.substr(0,1).toUpperCase()+e.substr(1)),e),h=(e,t)=>{document.dispatchEvent(new CustomEvent(e,{bubbles:!0,cancelable:!1,detail:t})),window.jQuery&&window.jQuery(document).trigger(e,t)},g=e=>{if(""!==e.id)return"//*[@id='"+e.id+"']";if(e===document.body)return"/html/body";let t=0;const r=e?.parentNode?e.parentNode.childNodes:[];for(var l=0;l<r.length;l++){const n=r[l];if(n===e){return`${g(e.parentNode)}/${e.tagName.toLowerCase()}[${t+1}]`}1===n.nodeType&&n.tagName===e.tagName&&t++}},b=e=>document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,y=(e,t=!1)=>{const r=document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),l=[];for(let e=0;e<r.snapshotLength;e++)l.push(r.snapshotItem(e));return t?l.reverse():l},v=(e=[])=>{const t=e.filter((e=>e&&String(e).length)).map((e=>e.trim())).join(" ").trim();return t.length?t:null},E=e=>e&&e.length?e.split(" ").filter((e=>e.trim().length)):[],w=e=>{let t=Array.from(e.attributes).reduce(((e,t)=>(e[t.name]=t.value,e)),{});if(t.checked=!!e.checked,t.selected=!!e.selected,t.tag_name=e.tagName,e.tagName.match(/select/i)||(e=>!!["checkbox","radio"].includes(e.type)&&document.querySelectorAll(`input[type="${e.type}"][name="${e.name}"]`).length>1)(e)){const r=(e=>Array.from(e.querySelectorAll("option:checked")).concat(Array.from(document.querySelectorAll(`input[type="${e.type}"][name="${e.name}"]`)).filter((e=>e.checked))).map((e=>e.value)))(e);t.values=r,t.value=r.join(",")}else t.value=e.value;return t},C=(e,t)=>{if(!t||0===t.length)return[];let r=[e];const l=g(e);return t.forEach((e=>{try{switch(e){case"combined":m.enabled&&console.warn("In the next version of StimulusReflex, the 'combined' option to data-reflex-dataset will become 'ancestors'."),r=[...r,...y(`${l}/ancestor::*`,!0)];break;case"ancestors":r=[...r,...y(`${l}/ancestor::*`,!0)];break;case"parent":r=[...r,...y(`${l}/parent::*`)];break;case"siblings":r=[...r,...y(`${l}/preceding-sibling::*|${l}/following-sibling::*`)];break;case"children":r=[...r,...y(`${l}/child::*`)];break;case"descendants":r=[...r,...y(`${l}/descendant::*`)];break;default:r=[...r,...document.querySelectorAll(e)]}}catch(e){s.enabled&&console.error(e)}})),r},I=e=>{let t={};return e&&e.attributes&&Array.from(e.attributes).forEach((e=>{e.name.startsWith("data-")&&(t[e.name]=e.value)})),t};let R=!1;var S={get disabled(){return!R},set(e){R=e}};const A=(e,t,r,l,n)=>{if(!r||!r.reflexData[l])return;const o=r.reflexController[l],a=r.reflexData[l].target,s=a.split("#")[1],d=o[["before","after","finalize"].includes(e)?`${e}${x(s)}`:`${x(s,!1)}${x(e)}`],c=o[["before","after","finalize"].includes(e)?`${e}Reflex`:`reflex${x(e)}`];"function"==typeof d&&d.call(o,t,a,r.reflexError[l],l,n),"function"==typeof c&&c.call(o,t,a,r.reflexError[l],l,n),i[l]&&e===i[l].finalStage&&(Reflect.deleteProperty(r.reflexController,l),Reflect.deleteProperty(r.reflexData,l),Reflect.deleteProperty(r.reflexError,l))};document.addEventListener("stimulus-reflex:before",(e=>A("before",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)),!0),document.addEventListener("stimulus-reflex:success",(e=>{A("success",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload),$("after",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)}),!0),document.addEventListener("stimulus-reflex:nothing",(e=>{$("success",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)}),!0),document.addEventListener("stimulus-reflex:error",(e=>{A("error",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload),$("after",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)}),!0),document.addEventListener("stimulus-reflex:halted",(e=>A("halted",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)),!0),document.addEventListener("stimulus-reflex:after",(e=>A("after",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)),!0),document.addEventListener("stimulus-reflex:finalize",(e=>A("finalize",e.detail.element,e.detail.controller.element,e.detail.reflexId,e.detail.payload)),!0);const $=(e,t,r,l,n)=>{if(!r)return void(s.enabled&&!i[l].warned&&(console.warn(`StimulusReflex was not able execute callbacks or emit events for "${e}" or later life-cycle stages for this Reflex. The StimulusReflex Controller Element is no longer present in the DOM. Could you move the StimulusReflex Controller to an element higher in your DOM?`),i[l].warned=!0));if(!r.reflexController||r.reflexController&&!r.reflexController[l])return void(s.enabled&&!i[l].warned&&(console.warn(`StimulusReflex detected that the StimulusReflex Controller responsible for this Reflex has been replaced with a new instance. Callbacks and events for "${e}" or later life-cycle stages cannot be executed.`),i[l].warned=!0));const{target:o}=r.reflexData[l]||{},a=r.reflexController[l]||{},d=`stimulus-reflex:${e}`,c=`${d}:${o.split("#")[1]}`,u={reflex:o,controller:a,reflexId:l,element:t,payload:n},f={bubbles:!0,cancelable:!1,detail:u};r.dispatchEvent(new CustomEvent(d,f)),r.dispatchEvent(new CustomEvent(c,f)),window.jQuery&&(window.jQuery(r).trigger(d,u),window.jQuery(r).trigger(c,u))},L=(e,t)=>E(t.getAttribute(o.controller)).reduce(((r,l)=>{const n=e.getControllerForElementAndIdentifier(t,l);return n&&n.StimulusReflex&&r.push(n),r}),[]),O=e=>{if(!e.cableReady)return;if(e.version.replace(".pre","-pre")!==t.version)return void(s.enabled&&console.error(`Reflex failed due to cable_ready gem/NPM package version mismatch. Package versions must match exactly.\nNote that if you are using pre-release builds, gems use the "x.y.z.preN" version format, while NPM packages use "x.y.z-preN".\n\ncable_ready gem: ${e.version}\ncable_ready NPM: ${t.version}`));let r,l=[];for(let t=e.operations.length-1;t>=0;t--)e.operations[t].stimulusReflex&&(l.push(e.operations[t]),e.operations.splice(t,1));if(!l.some((e=>e.stimulusReflex.url!==location.href)))if(l.length&&(r=l[0].stimulusReflex,r.payload=l[0].payload),r){const{reflexId:n,payload:o}=r;if(!i[n]&&S.disabled){const e=b(r.xpathController),t=b(r.xpathElement);e.reflexController=e.reflexController||{},e.reflexData=e.reflexData||{},e.reflexError=e.reflexError||{},e.reflexController[n]=i.app.getControllerForElementAndIdentifier(e,r.reflexController),e.reflexData[n]=r,$("before",t,e,n,o),_(r)}i[n]&&(i[n].totalOperations=l.length,i[n].pendingOperations=l.length,i[n].completedOperations=0,i[n].piggybackOperations=e.operations,t.perform(l))}else e.operations.length&&i[e.operations[0].reflexId]&&t.perform(e.operations)},_=e=>{const{reflexId:t}=e;i[t]={finalStage:"finalize"};const r=new Promise(((r,l)=>{i[t].promise={resolve:r,reject:l,data:e}}));return r.reflexId=t,s.enabled&&r.catch((()=>{})),r},D=((e,t=250)=>{let r;return(...l)=>{clearTimeout(r),r=setTimeout((()=>{r=null,e(...l)}),t)}})((()=>{document.querySelectorAll(`[${o.reflex}]`).forEach((e=>{const t=E(e.getAttribute(o.controller)),r=E(e.getAttribute(o.reflex)),l=E(e.getAttribute(o.action));r.forEach((r=>{const n=((e,t)=>t.find((t=>{if(t.identifier)return(e=>{const t=e.match(/(?:.*->)?(.*?)(?:Reflex)?#/);return t?t[1]:""})(e).replace(/([a-z0–9])([A-Z])/g,"$1-$2").replace(/(::)/g,"--").toLowerCase()===t.identifier}))||t[0])(r,((e,t)=>{let r=[];for(;t;)r=r.concat(L(e,t)),t=t.parentElement;return r})(i.app,e));let o;n?(o=`${r.split("->")[0]}->${n.identifier}#__perform`,l.includes(o)||l.push(o)):(o=`${r.split("->")[0]}->stimulus-reflex#__perform`,t.includes("stimulus-reflex")||t.push("stimulus-reflex"),l.includes(o)||l.push(o))}));const n=v(t),a=v(l);n&&e.getAttribute(o.controller)!=n&&e.setAttribute(o.controller,n),a&&e.getAttribute(o.action)!=a&&e.setAttribute(o.action,a)})),h("stimulus-reflex:ready")}),20);class T{constructor(e,t,r,l,n,o,a,s,i){this.options=e,this.reflexElement=t,this.controllerElement=r,this.reflexController=l,this.permanentAttributeName=n,this.target=o,this.args=a,this.url=s,this.tabId=i}get attrs(){return this._attrs=this._attrs||this.options.attrs||w(this.reflexElement),this._attrs}get reflexId(){return this._reflexId=this._reflexId||this.options.reflexId||p(),this._reflexId}get selectors(){return this._selectors=this._selectors||this.options.selectors||(e=>{let t=[];for(;0===t.length&&e;){let r=e.getAttribute(o.reflexRoot);if(r){0===r.length&&e.id&&(r=`#${e.id}`);const l=r.split(",").filter((e=>e.trim().length));s.enabled&&0===l.length&&console.error(`No value found for ${o.reflexRoot}. Add an #id to the element or provide a value for ${o.reflexRoot}.`,e),t=t.concat(l.filter((e=>document.querySelector(e))))}e=e.parentElement?e.parentElement.closest(`[${o.reflexRoot}]`):null}return t})(this.reflexElement),"string"==typeof this._selectors?[this._selectors]:this._selectors}get resolveLate(){return this.options.resolveLate||!1}get dataset(){return this._dataset=this._dataset||(e=>{const t=e.attributes[o.reflexDataset],r=e.attributes[o.reflexDatasetAll],l=t&&t.value.split(" ")||[],n=r&&r.value.split(" ")||[],a=C(e,l),s=C(e,n),i=a.reduce(((e,t)=>({...I(t),...e})),{}),d={dataset:{...I(e),...i},datasetAll:{}};return s.forEach((e=>{const t=I(e);Object.keys(t).forEach((e=>{const r=t[e];d.datasetAll[e]&&Array.isArray(d.datasetAll[e])?d.datasetAll[e].push(r):d.datasetAll[e]=[r]}))})),d})(this.reflexElement),this._dataset}get innerHTML(){return this.includeInnerHtml?this.reflexElement.innerHTML:""}get textContent(){return this.includeTextContent?this.reflexElement.textContent:""}get xpathController(){return g(this.controllerElement)}get xpathElement(){return g(this.reflexElement)}get formSelector(){const e=this.reflexElement.attributes[o.reflexFormSelector]?this.reflexElement.attributes[o.reflexFormSelector].value:void 0;return this.options.formSelector||e}get includeInnerHtml(){const e=this.reflexElement.attributes[o.reflexIncludeInnerHtml]||!1;return!(!this.options.includeInnerHTML&&!e)&&"false"!==e.value}get includeTextContent(){const e=this.reflexElement.attributes[o.reflexIncludeTextContent]||!1;return!(!this.options.includeTextContent&&!e)&&"false"!==e.value}get suppressLogging(){return this.options.suppressLogging||this.reflexElement.attributes[o.reflexSuppressLogging]||!1}valueOf(){return{attrs:this.attrs,dataset:this.dataset,selectors:this.selectors,reflexId:this.reflexId,resolveLate:this.resolveLate,suppressLogging:this.suppressLogging,xpathController:this.xpathController,xpathElement:this.xpathElement,inner_html:this.innerHTML,text_content:this.textContent,formSelector:this.formSelector,reflexController:this.reflexController,permanentAttributeName:this.permanentAttributeName,target:this.target,args:this.args,url:this.url,tabId:this.tabId,version:"3.5.0-pre9"}}}let N,j,k;const z=()=>{k=!0,document.body.classList.replace("stimulus-reflex-disconnected","stimulus-reflex-connected"),h("stimulus-reflex:connected"),h("stimulus-reflex:action-cable:connected")},P=()=>{k=!1,document.body.classList.replace("stimulus-reflex-connected","stimulus-reflex-disconnected"),h("stimulus-reflex:rejected"),h("stimulus-reflex:action-cable:rejected"),Debug.enabled&&console.warn("Channel subscription was rejected.")},F=e=>{k=!1,document.body.classList.replace("stimulus-reflex-connected","stimulus-reflex-disconnected"),h("stimulus-reflex:disconnected",e),h("stimulus-reflex:action-cable:disconnected",e)};var M={consumer:N,params:j,get subscriptionActive(){return k},createSubscription:e=>{N=N||e.application.consumer||r();const{channel:t}=e.StimulusReflex,l={channel:t,...j},n=JSON.stringify(l);e.StimulusReflex.subscription=N.subscriptions.findAll(n)[0]||N.subscriptions.create(l,{received:O,connected:z,rejected:P,disconnected:F})},connected:z,rejected:P,disconnected:F,set(e,t){N=e,j=t}};const H=e=>{const{stimulusReflex:t,payload:r}=e.detail||{};if(!t)return;const{reflexId:l,xpathElement:n,xpathController:o}=t,a=b(o),s=b(n),d=i[l],{promise:c}=d;d.pendingOperations--,d.pendingOperations>0||(t.resolveLate||setTimeout((()=>c.resolve({element:s,event:e,data:c.data,payload:r,reflexId:l,toString:()=>""}))),setTimeout((()=>$("success",s,a,l,r))))},U=e=>{const{stimulusReflex:r,payload:l}=e.detail||{};if(!r)return;const{reflexId:n,xpathElement:o,xpathController:a}=r,s=b(a),d=b(o),u=i[n],{promise:f}=u;u.completedOperations++,c(e,!1),u.completedOperations<u.totalOperations||(r.resolveLate&&setTimeout((()=>f.resolve({element:d,event:e,data:f.data,payload:l,reflexId:n,toString:()=>""}))),setTimeout((()=>$("finalize",d,s,n,l))),u.piggybackOperations.length&&t.perform(u.piggybackOperations))},q=(e,t,r,l,n)=>{l.finalStage="after",c(e,!1),setTimeout((()=>r.resolve({data:r.data,element:n,event:e,payload:t,reflexId:r.data.reflexId,toString:()=>""})))},Q=(e,t,r,l,n)=>{l.finalStage="halted",c(e,!0),setTimeout((()=>r.resolve({data:r.data,element:n,event:e,payload:t,reflexId:r.data.reflexId,toString:()=>""})))},V=(e,t,r,l,n)=>{l.finalStage="after",u(e),setTimeout((()=>r.reject({data:r.data,element:n,event:e,payload:t,reflexId:r.data.reflexId,error:e.detail.body,toString:()=>e.detail.body})))};class X extends e{constructor(...e){super(...e),J(this)}}const Y=(e,{controller:t,consumer:r,debug:l,params:n,isolate:a,deprecate:d}={})=>{M.set(r,n),document.addEventListener("DOMContentLoaded",(()=>{document.body.classList.remove("stimulus-reflex-connected"),document.body.classList.add("stimulus-reflex-disconnected"),m.enabled&&r&&console.warn("Deprecation warning: the next version of StimulusReflex will obtain a reference to consumer via the Stimulus application object.\nPlease add 'application.consumer = consumer' to your index.js after your Stimulus application has been established, and remove the consumer key from your StimulusReflex initialize() options object."),m.enabled&&S.disabled&&console.warn("Deprecation warning: the next version of StimulusReflex will standardize isolation mode, and the isolate option will be removed.\nPlease update your applications to assume that every tab will be isolated.")}),{once:!0}),S.set(!!a),i.app=e,o.set(e),i.app.register("stimulus-reflex",t||X),s.set(!!l),void 0!==d&&m.set(d);new MutationObserver(D).observe(document.documentElement,{attributeFilter:[o.reflex,o.action],childList:!0,subtree:!0})},J=(e,t={})=>{e.StimulusReflex={...t,channel:"StimulusReflex::Channel"},M.createSubscription(e),Object.assign(e,{isActionCableConnectionOpen(){return this.StimulusReflex.subscription.consumer.connection.isOpen()},stimulate(){const e=location.href,t=Array.from(arguments),r=t.shift()||"StimulusReflex::Reflex#default_reflex",l=this.element,n=t[0]&&t[0].nodeType===Node.ELEMENT_NODE?t.shift():l;if("number"===n.type&&n.validity&&n.validity.badInput)return void(s.enabled&&console.warn("Reflex aborted: invalid numeric input"));const a={};if(t[0]&&"object"==typeof t[0]&&Object.keys(t[0]).filter((e=>["attrs","selectors","reflexId","resolveLate","serializeForm","suppressLogging","includeInnerHTML","includeTextContent"].includes(e))).length){const e=t.shift();Object.keys(e).forEach((t=>a[t]=e[t]))}const i=new T(a,n,l,this.identifier,o.reflexPermanent,r,t,e,W),c=i.reflexId;if(!this.isActionCableConnectionOpen())throw"The ActionCable connection is not open! `this.isActionCableConnectionOpen()` must return true before calling `this.stimulate()`";if(!M.subscriptionActive)throw"The ActionCable channel subscription for StimulusReflex was rejected.";l.reflexController=l.reflexController||{},l.reflexData=l.reflexData||{},l.reflexError=l.reflexError||{},l.reflexController[c]=this,l.reflexData[c]=i.valueOf(),$("before",n,l,c),setTimeout((()=>{const{params:e}=l.reflexData[c]||{},t=n.attributes[o.reflexSerializeForm];t&&(a.serializeForm="false"!==t.value);const r=n.closest(i.formSelector)||document.querySelector(i.formSelector)||n.closest("form");m.enabled&&void 0===a.serializeForm&&r&&console.warn(`Deprecation warning: the next version of StimulusReflex will not serialize forms by default.\nPlease set ${o.reflexSerializeForm}="true" on your Reflex Controller Element or pass { serializeForm: true } as an option to stimulate.`);const s=!1===a.serializeForm?"":((e,t={})=>{if(!e)return"";const r=t.w||window,{element:l}=t,n=new r.FormData(e),o=Array.from(n,(e=>e.map(encodeURIComponent).join("="))),a=e.querySelector("input[type=submit]");return l&&l.name&&"INPUT"===l.nodeName&&"submit"===l.type?o.push(`${encodeURIComponent(l.name)}=${encodeURIComponent(l.value)}`):a&&a.name&&o.push(`${encodeURIComponent(a.name)}=${encodeURIComponent(a.value)}`),Array.from(o).join("&")})(r,{element:n});l.reflexData[c]={...i.valueOf(),params:e,formData:s},this.StimulusReflex.subscription.send(l.reflexData[c])}));const u=_(i.valueOf());return d(c,r,t,this.context.scope.identifier,n,l),u},__perform(e){let t,r=e.target;for(;r&&!t;)t=r.getAttribute(o.reflex),t&&t.trim().length||(r=r.parentElement);const l=E(t).find((t=>t.split("->")[0]===e.type));l&&(e.preventDefault(),e.stopPropagation(),this.stimulate(l.split("->")[1],r))}})},W=p(),Z=(e,t={})=>{J(e,t)};document.addEventListener("cable-ready:after-dispatch-event",(e=>{const{stimulusReflex:r,payload:l,name:n,body:o}=e.detail||{},a=n.split("-")[2];if(!r||!["nothing","halted","error"].includes(a))return;const{reflexId:s,xpathElement:d,xpathController:c}=r,u=b(d),f=b(c),m=i[s],{promise:p}=m;switch(f&&(f.reflexError=f.reflexError||{},"error"===a&&(f.reflexError[s]=o)),a){case"nothing":q(e,l,p,m,u);break;case"error":V(e,l,p,m,u);break;case"halted":Q(e,l,p,m,u)}setTimeout((()=>$(a,u,f,s,l))),m.piggybackOperations.length&&t.perform(m.piggybackOperations)})),document.addEventListener("cable-ready:before-inner-html",H),document.addEventListener("cable-ready:before-morph",H),document.addEventListener("cable-ready:after-inner-html",U),document.addEventListener("cable-ready:after-morph",U),window.addEventListener("load",D);const B={...Object.freeze({__proto__:null,initialize:Y,register:J,useReflex:Z}),get debug(){return s.value},set debug(e){s.set(!!e)},get deprecate(){return m.value},set deprecate(e){m.set(!!e)}};window.StimulusReflex=B;export{B as default,Y as initialize,J as register,Z as useReflex};
|
2
|
-
//# sourceMappingURL=stimulus_reflex.min.js.map
|