cable_ready 5.0.0.pre9 → 5.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -1
- data/Gemfile.lock +119 -100
- data/README.md +12 -15
- data/app/assets/javascripts/cable_ready.js +465 -155
- data/app/assets/javascripts/cable_ready.umd.js +449 -169
- data/app/channels/cable_ready/stream.rb +7 -5
- data/app/helpers/cable_ready/view_helper.rb +58 -0
- data/app/jobs/cable_ready/broadcast_job.rb +15 -0
- data/app/models/concerns/cable_ready/updatable/collection_updatable_callbacks.rb +2 -0
- data/app/models/concerns/cable_ready/updatable/collections_registry.rb +31 -5
- data/app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb +9 -4
- data/app/models/concerns/cable_ready/updatable.rb +107 -39
- data/app/models/concerns/extend_has_many.rb +2 -0
- data/cable_ready.gemspec +4 -6
- data/lib/cable_ready/broadcaster.rb +2 -0
- data/lib/cable_ready/cable_car.rb +2 -0
- data/lib/cable_ready/channel.rb +12 -4
- data/lib/cable_ready/channels.rb +3 -1
- data/lib/cable_ready/config.rb +17 -2
- data/lib/cable_ready/engine.rb +33 -14
- data/lib/cable_ready/identifiable.rb +23 -5
- data/lib/cable_ready/importmap.rb +3 -1
- data/lib/cable_ready/installer.rb +224 -0
- data/lib/cable_ready/operation_builder.rb +1 -1
- data/lib/cable_ready/sanity_checker.rb +1 -31
- data/lib/cable_ready/updatable/memory_cache_debounce_adapter.rb +22 -0
- data/lib/cable_ready/version.rb +1 -1
- data/lib/cable_ready.rb +5 -8
- data/lib/cable_ready_helper.rb +13 -0
- data/lib/generators/cable_ready/channel_generator.rb +51 -12
- data/lib/generators/cable_ready/templates/config/initializers/cable_ready.rb +15 -6
- data/lib/install/action_cable.rb +144 -0
- data/lib/install/broadcaster.rb +109 -0
- data/lib/install/bundle.rb +54 -0
- data/lib/install/compression.rb +51 -0
- data/lib/install/config.rb +39 -0
- data/lib/install/development.rb +34 -0
- data/lib/install/esbuild.rb +101 -0
- data/lib/install/importmap.rb +96 -0
- data/lib/install/initializers.rb +15 -0
- data/lib/install/mrujs.rb +121 -0
- data/lib/install/npm_packages.rb +13 -0
- data/lib/install/shakapacker.rb +65 -0
- data/lib/install/spring.rb +54 -0
- data/lib/install/updatable.rb +34 -0
- data/lib/install/vite.rb +66 -0
- data/lib/install/webpacker.rb +93 -0
- data/lib/install/yarn.rb +56 -0
- data/lib/tasks/cable_ready/cable_ready.rake +247 -0
- data/package.json +36 -22
- data/{rollup.config.js → rollup.config.mjs} +7 -25
- data/web-test-runner.config.mjs +12 -0
- data/yarn.lock +3058 -398
- metadata +39 -167
- data/IMPLEMENTATION.md +0 -93
- data/LATEST +0 -1
- data/app/assets/javascripts/cable_ready.min.js +0 -2
- data/app/assets/javascripts/cable_ready.min.js.map +0 -1
- data/app/assets/javascripts/cable_ready.umd.min.js +0 -2
- data/app/assets/javascripts/cable_ready.umd.min.js.map +0 -1
- data/app/helpers/cable_ready_helper.rb +0 -26
- data/app/jobs/cable_ready_broadcast_job.rb +0 -14
- data/lib/generators/cable_ready/helpers_generator.rb +0 -43
- data/lib/generators/cable_ready/initializer_generator.rb +0 -14
- data/test/dummy/app/channels/application_cable/channel.rb +0 -4
- data/test/dummy/app/channels/application_cable/connection.rb +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -2
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/jobs/application_job.rb +0 -7
- data/test/dummy/app/mailers/application_mailer.rb +0 -4
- data/test/dummy/app/models/application_record.rb +0 -3
- data/test/dummy/app/models/dugong.rb +0 -4
- data/test/dummy/app/models/global_idable_entity.rb +0 -16
- data/test/dummy/app/models/post.rb +0 -4
- data/test/dummy/app/models/section.rb +0 -6
- data/test/dummy/app/models/team.rb +0 -6
- data/test/dummy/app/models/topic.rb +0 -4
- data/test/dummy/app/models/user.rb +0 -7
- data/test/dummy/config/application.rb +0 -22
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -76
- data/test/dummy/config/environments/production.rb +0 -120
- data/test/dummy/config/environments/test.rb +0 -59
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/test/dummy/config/initializers/assets.rb +0 -12
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
- data/test/dummy/config/initializers/cable_ready.rb +0 -18
- data/test/dummy/config/initializers/content_security_policy.rb +0 -28
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/permissions_policy.rb +0 -11
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/puma.rb +0 -43
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/db/migrate/20210902154139_create_users.rb +0 -9
- data/test/dummy/db/migrate/20210902154153_create_posts.rb +0 -10
- data/test/dummy/db/migrate/20210904081930_create_topics.rb +0 -9
- data/test/dummy/db/migrate/20210904093607_create_sections.rb +0 -9
- data/test/dummy/db/migrate/20210913191735_create_teams.rb +0 -8
- data/test/dummy/db/migrate/20210913191759_add_team_reference_to_users.rb +0 -5
- data/test/dummy/db/migrate/20220329222959_create_dugongs.rb +0 -8
- data/test/dummy/db/migrate/20220329230221_create_active_storage_tables.active_storage.rb +0 -36
- data/test/dummy/db/schema.rb +0 -84
- data/test/dummy/test/models/dugong_test.rb +0 -7
- data/test/dummy/test/models/post_test.rb +0 -7
- data/test/dummy/test/models/section_test.rb +0 -7
- data/test/dummy/test/models/team_test.rb +0 -7
- data/test/dummy/test/models/topic_test.rb +0 -7
- data/test/dummy/test/models/user_test.rb +0 -7
- data/test/lib/cable_ready/cable_car_test.rb +0 -50
- data/test/lib/cable_ready/compoundable_test.rb +0 -26
- data/test/lib/cable_ready/helper_test.rb +0 -25
- data/test/lib/cable_ready/identifiable_test.rb +0 -69
- data/test/lib/cable_ready/operation_builder_test.rb +0 -189
- data/test/lib/cable_ready/updatable_test.rb +0 -135
- data/test/lib/generators/cable_ready/channel_generator_test.rb +0 -157
- data/test/support/generator_test_helpers.rb +0 -28
- data/test/test_helper.rb +0 -18
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cable_ready
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.
|
4
|
+
version: 5.0.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
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: actioncable
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '5.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: actionpack
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +38,6 @@ dependencies:
|
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '5.2'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: activerecord
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.2'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.2'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: activesupport
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,21 +137,21 @@ dependencies:
|
|
165
137
|
- !ruby/object:Gem::Version
|
166
138
|
version: '0'
|
167
139
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
140
|
+
name: rake
|
169
141
|
requirement: !ruby/object:Gem::Requirement
|
170
142
|
requirements:
|
171
143
|
- - ">="
|
172
144
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
145
|
+
version: '0'
|
174
146
|
type: :development
|
175
147
|
prerelease: false
|
176
148
|
version_requirements: !ruby/object:Gem::Requirement
|
177
149
|
requirements:
|
178
150
|
- - ">="
|
179
151
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
152
|
+
version: '0'
|
181
153
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
154
|
+
name: sqlite3
|
183
155
|
requirement: !ruby/object:Gem::Requirement
|
184
156
|
requirements:
|
185
157
|
- - ">="
|
@@ -193,19 +165,19 @@ dependencies:
|
|
193
165
|
- !ruby/object:Gem::Version
|
194
166
|
version: '0'
|
195
167
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
168
|
+
name: standard
|
197
169
|
requirement: !ruby/object:Gem::Requirement
|
198
170
|
requirements:
|
199
|
-
- -
|
171
|
+
- - '='
|
200
172
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
173
|
+
version: 1.19.1
|
202
174
|
type: :development
|
203
175
|
prerelease: false
|
204
176
|
version_requirements: !ruby/object:Gem::Requirement
|
205
177
|
requirements:
|
206
|
-
- -
|
178
|
+
- - '='
|
207
179
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
180
|
+
version: 1.19.1
|
209
181
|
- !ruby/object:Gem::Dependency
|
210
182
|
name: standardrb
|
211
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,20 +203,14 @@ files:
|
|
231
203
|
- CODE_OF_CONDUCT.md
|
232
204
|
- Gemfile
|
233
205
|
- Gemfile.lock
|
234
|
-
- IMPLEMENTATION.md
|
235
|
-
- LATEST
|
236
206
|
- LICENSE.txt
|
237
207
|
- README.md
|
238
208
|
- Rakefile
|
239
209
|
- app/assets/javascripts/cable_ready.js
|
240
|
-
- app/assets/javascripts/cable_ready.min.js
|
241
|
-
- app/assets/javascripts/cable_ready.min.js.map
|
242
210
|
- app/assets/javascripts/cable_ready.umd.js
|
243
|
-
- app/assets/javascripts/cable_ready.umd.min.js
|
244
|
-
- app/assets/javascripts/cable_ready.umd.min.js.map
|
245
211
|
- app/channels/cable_ready/stream.rb
|
246
|
-
- app/helpers/
|
247
|
-
- app/jobs/
|
212
|
+
- app/helpers/cable_ready/view_helper.rb
|
213
|
+
- app/jobs/cable_ready/broadcast_job.rb
|
248
214
|
- app/models/concerns/cable_ready/updatable.rb
|
249
215
|
- app/models/concerns/cable_ready/updatable/collection_updatable_callbacks.rb
|
250
216
|
- app/models/concerns/cable_ready/updatable/collections_registry.rb
|
@@ -265,73 +231,36 @@ files:
|
|
265
231
|
- lib/cable_ready/engine.rb
|
266
232
|
- lib/cable_ready/identifiable.rb
|
267
233
|
- lib/cable_ready/importmap.rb
|
234
|
+
- lib/cable_ready/installer.rb
|
268
235
|
- lib/cable_ready/operation_builder.rb
|
269
236
|
- lib/cable_ready/sanity_checker.rb
|
270
237
|
- lib/cable_ready/stream_identifier.rb
|
238
|
+
- lib/cable_ready/updatable/memory_cache_debounce_adapter.rb
|
271
239
|
- lib/cable_ready/version.rb
|
240
|
+
- lib/cable_ready_helper.rb
|
272
241
|
- lib/generators/cable_ready/channel_generator.rb
|
273
|
-
- lib/generators/cable_ready/helpers_generator.rb
|
274
|
-
- lib/generators/cable_ready/initializer_generator.rb
|
275
242
|
- lib/generators/cable_ready/templates/config/initializers/cable_ready.rb
|
243
|
+
- lib/install/action_cable.rb
|
244
|
+
- lib/install/broadcaster.rb
|
245
|
+
- lib/install/bundle.rb
|
246
|
+
- lib/install/compression.rb
|
247
|
+
- lib/install/config.rb
|
248
|
+
- lib/install/development.rb
|
249
|
+
- lib/install/esbuild.rb
|
250
|
+
- lib/install/importmap.rb
|
251
|
+
- lib/install/initializers.rb
|
252
|
+
- lib/install/mrujs.rb
|
253
|
+
- lib/install/npm_packages.rb
|
254
|
+
- lib/install/shakapacker.rb
|
255
|
+
- lib/install/spring.rb
|
256
|
+
- lib/install/updatable.rb
|
257
|
+
- lib/install/vite.rb
|
258
|
+
- lib/install/webpacker.rb
|
259
|
+
- lib/install/yarn.rb
|
260
|
+
- lib/tasks/cable_ready/cable_ready.rake
|
276
261
|
- package.json
|
277
|
-
- rollup.config.
|
278
|
-
- test
|
279
|
-
- test/dummy/app/channels/application_cable/connection.rb
|
280
|
-
- test/dummy/app/controllers/application_controller.rb
|
281
|
-
- test/dummy/app/helpers/application_helper.rb
|
282
|
-
- test/dummy/app/jobs/application_job.rb
|
283
|
-
- test/dummy/app/mailers/application_mailer.rb
|
284
|
-
- test/dummy/app/models/application_record.rb
|
285
|
-
- test/dummy/app/models/dugong.rb
|
286
|
-
- test/dummy/app/models/global_idable_entity.rb
|
287
|
-
- test/dummy/app/models/post.rb
|
288
|
-
- test/dummy/app/models/section.rb
|
289
|
-
- test/dummy/app/models/team.rb
|
290
|
-
- test/dummy/app/models/topic.rb
|
291
|
-
- test/dummy/app/models/user.rb
|
292
|
-
- test/dummy/config/application.rb
|
293
|
-
- test/dummy/config/boot.rb
|
294
|
-
- test/dummy/config/environment.rb
|
295
|
-
- test/dummy/config/environments/development.rb
|
296
|
-
- test/dummy/config/environments/production.rb
|
297
|
-
- test/dummy/config/environments/test.rb
|
298
|
-
- test/dummy/config/initializers/application_controller_renderer.rb
|
299
|
-
- test/dummy/config/initializers/assets.rb
|
300
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
301
|
-
- test/dummy/config/initializers/cable_ready.rb
|
302
|
-
- test/dummy/config/initializers/content_security_policy.rb
|
303
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
304
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
305
|
-
- test/dummy/config/initializers/inflections.rb
|
306
|
-
- test/dummy/config/initializers/mime_types.rb
|
307
|
-
- test/dummy/config/initializers/permissions_policy.rb
|
308
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
309
|
-
- test/dummy/config/puma.rb
|
310
|
-
- test/dummy/config/routes.rb
|
311
|
-
- test/dummy/db/migrate/20210902154139_create_users.rb
|
312
|
-
- test/dummy/db/migrate/20210902154153_create_posts.rb
|
313
|
-
- test/dummy/db/migrate/20210904081930_create_topics.rb
|
314
|
-
- test/dummy/db/migrate/20210904093607_create_sections.rb
|
315
|
-
- test/dummy/db/migrate/20210913191735_create_teams.rb
|
316
|
-
- test/dummy/db/migrate/20210913191759_add_team_reference_to_users.rb
|
317
|
-
- test/dummy/db/migrate/20220329222959_create_dugongs.rb
|
318
|
-
- test/dummy/db/migrate/20220329230221_create_active_storage_tables.active_storage.rb
|
319
|
-
- test/dummy/db/schema.rb
|
320
|
-
- test/dummy/test/models/dugong_test.rb
|
321
|
-
- test/dummy/test/models/post_test.rb
|
322
|
-
- test/dummy/test/models/section_test.rb
|
323
|
-
- test/dummy/test/models/team_test.rb
|
324
|
-
- test/dummy/test/models/topic_test.rb
|
325
|
-
- test/dummy/test/models/user_test.rb
|
326
|
-
- test/lib/cable_ready/cable_car_test.rb
|
327
|
-
- test/lib/cable_ready/compoundable_test.rb
|
328
|
-
- test/lib/cable_ready/helper_test.rb
|
329
|
-
- test/lib/cable_ready/identifiable_test.rb
|
330
|
-
- test/lib/cable_ready/operation_builder_test.rb
|
331
|
-
- test/lib/cable_ready/updatable_test.rb
|
332
|
-
- test/lib/generators/cable_ready/channel_generator_test.rb
|
333
|
-
- test/support/generator_test_helpers.rb
|
334
|
-
- test/test_helper.rb
|
262
|
+
- rollup.config.mjs
|
263
|
+
- web-test-runner.config.mjs
|
335
264
|
- yarn.lock
|
336
265
|
homepage: https://github.com/stimulusreflex/cable_ready
|
337
266
|
licenses:
|
@@ -345,72 +274,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
345
274
|
requirements:
|
346
275
|
- - ">="
|
347
276
|
- !ruby/object:Gem::Version
|
348
|
-
version:
|
277
|
+
version: 2.7.0
|
349
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
350
279
|
requirements:
|
351
280
|
- - ">"
|
352
281
|
- !ruby/object:Gem::Version
|
353
282
|
version: 1.3.1
|
354
283
|
requirements: []
|
355
|
-
rubygems_version: 3.
|
284
|
+
rubygems_version: 3.4.1
|
356
285
|
signing_key:
|
357
286
|
specification_version: 4
|
358
287
|
summary: Out-of-Band Server Triggered DOM Operations
|
359
|
-
test_files:
|
360
|
-
- test/dummy/app/channels/application_cable/channel.rb
|
361
|
-
- test/dummy/app/channels/application_cable/connection.rb
|
362
|
-
- test/dummy/app/controllers/application_controller.rb
|
363
|
-
- test/dummy/app/helpers/application_helper.rb
|
364
|
-
- test/dummy/app/jobs/application_job.rb
|
365
|
-
- test/dummy/app/mailers/application_mailer.rb
|
366
|
-
- test/dummy/app/models/application_record.rb
|
367
|
-
- test/dummy/app/models/dugong.rb
|
368
|
-
- test/dummy/app/models/global_idable_entity.rb
|
369
|
-
- test/dummy/app/models/post.rb
|
370
|
-
- test/dummy/app/models/section.rb
|
371
|
-
- test/dummy/app/models/team.rb
|
372
|
-
- test/dummy/app/models/topic.rb
|
373
|
-
- test/dummy/app/models/user.rb
|
374
|
-
- test/dummy/config/application.rb
|
375
|
-
- test/dummy/config/boot.rb
|
376
|
-
- test/dummy/config/environment.rb
|
377
|
-
- test/dummy/config/environments/development.rb
|
378
|
-
- test/dummy/config/environments/production.rb
|
379
|
-
- test/dummy/config/environments/test.rb
|
380
|
-
- test/dummy/config/initializers/application_controller_renderer.rb
|
381
|
-
- test/dummy/config/initializers/assets.rb
|
382
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
383
|
-
- test/dummy/config/initializers/cable_ready.rb
|
384
|
-
- test/dummy/config/initializers/content_security_policy.rb
|
385
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
386
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
387
|
-
- test/dummy/config/initializers/inflections.rb
|
388
|
-
- test/dummy/config/initializers/mime_types.rb
|
389
|
-
- test/dummy/config/initializers/permissions_policy.rb
|
390
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
391
|
-
- test/dummy/config/puma.rb
|
392
|
-
- test/dummy/config/routes.rb
|
393
|
-
- test/dummy/db/migrate/20210902154139_create_users.rb
|
394
|
-
- test/dummy/db/migrate/20210902154153_create_posts.rb
|
395
|
-
- test/dummy/db/migrate/20210904081930_create_topics.rb
|
396
|
-
- test/dummy/db/migrate/20210904093607_create_sections.rb
|
397
|
-
- test/dummy/db/migrate/20210913191735_create_teams.rb
|
398
|
-
- test/dummy/db/migrate/20210913191759_add_team_reference_to_users.rb
|
399
|
-
- test/dummy/db/migrate/20220329222959_create_dugongs.rb
|
400
|
-
- test/dummy/db/migrate/20220329230221_create_active_storage_tables.active_storage.rb
|
401
|
-
- test/dummy/db/schema.rb
|
402
|
-
- test/dummy/test/models/dugong_test.rb
|
403
|
-
- test/dummy/test/models/post_test.rb
|
404
|
-
- test/dummy/test/models/section_test.rb
|
405
|
-
- test/dummy/test/models/team_test.rb
|
406
|
-
- test/dummy/test/models/topic_test.rb
|
407
|
-
- test/dummy/test/models/user_test.rb
|
408
|
-
- test/lib/cable_ready/cable_car_test.rb
|
409
|
-
- test/lib/cable_ready/compoundable_test.rb
|
410
|
-
- test/lib/cable_ready/helper_test.rb
|
411
|
-
- test/lib/cable_ready/identifiable_test.rb
|
412
|
-
- test/lib/cable_ready/operation_builder_test.rb
|
413
|
-
- test/lib/cable_ready/updatable_test.rb
|
414
|
-
- test/lib/generators/cable_ready/channel_generator_test.rb
|
415
|
-
- test/support/generator_test_helpers.rb
|
416
|
-
- test/test_helper.rb
|
288
|
+
test_files: []
|
data/IMPLEMENTATION.md
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
# CableReady Language Implementation Project
|
2
|
-
|
3
|
-
We believe that CableReady can become the universal standard tool for developers to dynamically control client browsers from the server. While the project has roots in the Ruby on Rails community, the JS client is unopinionated about how the simple JSON structure that it consumes was created.
|
4
|
-
|
5
|
-
We would like to announce support for Python, Go, C#, Java, PHP and NodeJS server libraries in early 2022. While there's a broad set of features a server library could implement, there's a baseline that we'd like to make sure all implementations can offer.
|
6
|
-
|
7
|
-
## Background
|
8
|
-
|
9
|
-
CableReady was started in 2017 by Nate Hopkins. It predates LiveView and the HTML-on-the-wire trend by 18 months. It sees roughly 15,000 downloads per week and offers 36 different [operations](https://cableready.stimulusreflex.com/v/v5/reference/operations).
|
10
|
-
|
11
|
-
CableReady is currently a client-side JS module and a server-side Ruby module.
|
12
|
-
|
13
|
-
## Key concepts
|
14
|
-
|
15
|
-
- available everywhere
|
16
|
-
- multiple operations per payload
|
17
|
-
- schemaless
|
18
|
-
- simple JSON wire format
|
19
|
-
- method chaining
|
20
|
-
- transport agnostic
|
21
|
-
- extensible via custom operations
|
22
|
-
|
23
|
-
### Available everywhere
|
24
|
-
|
25
|
-
Rails developers can access a `cable_ready` singleton from just about anywhere in their application, and we believe it's a big part of the secret sauce. While every language and framework has their own idioms, we encourage implementors to remove barriers and make it easy to call CableReady anywhere it could be useful.
|
26
|
-
|
27
|
-
https://cableready.stimulusreflex.com/v/v5/cableready-everywhere
|
28
|
-
|
29
|
-
### Operations and their options
|
30
|
-
|
31
|
-
Operations are the basic atomic unit of activity in CableReady. Each operation typically has a very specific focus and often mimics the DOM JS spec for the activity in question. Operations have options passed to them which specify their exact behavior.
|
32
|
-
|
33
|
-
Multiple operations can be prepared together. They will be executed in the order that they were created. Different operation types can be mixed together in one payload.
|
34
|
-
|
35
|
-
The Ruby implementation offers two interfaces; the (original) primary mechanism delivers the operations to a WebSocket channel in what we refer to as a "broadcast". The other - known as "cable car" - returns a JSON string that can be sent, persisted or displayed for any purpose.
|
36
|
-
|
37
|
-
### Schemaless
|
38
|
-
|
39
|
-
CableReady operations each have their own mandatory and optional options, along with options that are provided to every operation by the library. However, arbitrary additional options can be passed to an operation and they will be passed to the client. This makes it easy for CableReady to form the basis of much larger projects, such as StimulusReflex.
|
40
|
-
|
41
|
-
### JSON wire format
|
42
|
-
|
43
|
-
As of v5.0, the CableReady JSON wire format is an array of objects, where each object represents one operation. It's intentionally very simple.
|
44
|
-
|
45
|
-
```json
|
46
|
-
[{\"message\":\"Hello!\",\"operation\":\"consoleLog\"}]
|
47
|
-
```
|
48
|
-
|
49
|
-
Each operation has **camelCased** key/value pairs that convey options. Every operation must have an `operation` value, or the client will raise an exception.
|
50
|
-
|
51
|
-
### Method chaining
|
52
|
-
|
53
|
-
Developer experience is a high priority. We take pride in the readability and expressiveness offered by our server API. The basic pseudocode structure we provide looks like:
|
54
|
-
|
55
|
-
```rb
|
56
|
-
cable_ready[:foo].operation(options).broadcast
|
57
|
-
```
|
58
|
-
|
59
|
-
In other words, the first method `cable_ready` starts a method chain by returning `self`, and then each operation is a method that also returns the chain started by the initial method. In this way, you can chain together as many operations as you like. Finally, we have a `broadcast` method which takes the current chain and broadcasts it via WebSockets to the `:foo` channel.
|
60
|
-
|
61
|
-
We also have our "cable car" interface which emits JSON when `to_json` is called. This makes it perfect for responding to Ajax fetch requests:
|
62
|
-
|
63
|
-
```rb
|
64
|
-
cable_car.operation(options).to_json
|
65
|
-
```
|
66
|
-
|
67
|
-
The `cable_car` might be assembled in steps, perhaps via a control loop:
|
68
|
-
|
69
|
-
```rb
|
70
|
-
inspiration = cable_car.console_log(message: "Hello there!").dispatch_event(name: "fred", detail: {inspiring: true})
|
71
|
-
3.times do |i|
|
72
|
-
inspiration.console_log(message: "Still here: #{i}")
|
73
|
-
end
|
74
|
-
inspiration.to_json
|
75
|
-
```
|
76
|
-
|
77
|
-
The main expectation that should hold between languages is that you will start the chain with a command, add one or many operation methods, and then execute the chain.
|
78
|
-
|
79
|
-
### Transport agnostic
|
80
|
-
|
81
|
-
CableReady started its life as a WebSocket library, but the neutral JSON format has potential far beyond just WebSocket usage. We now frequently return CableReady JSON payloads via Ajax as well. There's nothing stopping you from embedding payloads into a DOM element attribute, for example.
|
82
|
-
|
83
|
-
We believe that a minimally viable CableReady server library must be able to produce compatible JSON. There's no hard requirement that it interface with WebSockets, although we do find this to be a major sweet spot and will do our best to provide support.
|
84
|
-
|
85
|
-
### Custom operations
|
86
|
-
|
87
|
-
While CableReady ships with an impressive number of operations out of the box, users should be able to add their own operations. Admittedly, the method used to dynamically create all of the methods for each operation is the [most sophisticated](https://github.com/stimulusreflex/cable_ready/blob/master/lib/cable_ready/operation_builder.rb) one in our framework, but again, we're here to help.
|
88
|
-
|
89
|
-
https://cableready.stimulusreflex.com/v/v5/customization#custom-operations
|
90
|
-
|
91
|
-
# Get involved!
|
92
|
-
|
93
|
-
We have a wonderful community with over 1600 folks on our Discord server, helping people get started. Come join https://discord.gg/stimulus-reflex and drop by the #cable_ready channel with any questions.
|
data/LATEST
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
4.5.0
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import e from"morphdom";var t="5.0.0-pre9";const n={INPUT:!0,TEXTAREA:!0,SELECT:!0},o={INPUT:!0,TEXTAREA:!0,OPTION:!0},r={"datetime-local":!0,"select-multiple":!0,"select-one":!0,color:!0,date:!0,datetime:!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,textarea:!0,time:!0,url:!0,week:!0};let s;var a={get element(){return s},set(e){s=e}};const i=e=>n[e.tagName]&&r[e.type],l=e=>{const t=(e&&e.nodeType===Node.ELEMENT_NODE?e:document.querySelector(e))||a.element;t&&t.focus&&t.focus()},c=(e,t,n={})=>{const o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e.dispatchEvent(o),window.jQuery&&window.jQuery(e).trigger(t,n)},u=e=>document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,d=e=>Array(e).flat(),m=(e,t)=>{Array.from(e.selectAll?e.element:[e.element]).forEach(t)},h=e=>e.split("").map(((e,t)=>e.toUpperCase()===e?`${0!==t?"-":""}${e.toLowerCase()}`:e)).join(""),p=(e,t)=>!e.cancel&&(e.delay?setTimeout(t,e.delay):t(),!0),f=(e,t)=>c(e,`cable-ready:before-${h(t.operation)}`,t),b=(e,t)=>c(e,`cable-ready:after-${h(t.operation)}`,t);function y(e,t){let n;return(...o)=>{clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}}function g(e){if(!e.ok)throw Error(e.statusText);return e}async function w(e,t){try{const n=await fetch(e,{headers:{"X-REQUESTED-WITH":"XmlHttpRequest",...t}});if(null==n)return;return g(n),n}catch(t){console.error(`Could not fetch ${e}`)}}var E=Object.freeze({__proto__:null,isTextInput:i,assignFocus:l,dispatch:c,xpathToElement:u,getClassNames:d,processElements:m,operate:p,before:f,after:b,debounce:y,handleErrors:g,graciouslyFetch:w,kebabize:h});const v=e=>(t,n)=>!x.map((o=>"function"!=typeof o||o(e,t,n))).includes(!1),T=e=>t=>{M.forEach((n=>{"function"==typeof n&&n(e,t)}))},A=(e,t,n)=>!(!o[t.tagName]&&t.isEqualNode(n)),S=(e,t,n)=>t!==a.element||!t.isContentEditable,C=(e,t,n)=>{const{permanentAttributeName:o}=e;if(!o)return!0;const r=t.closest(`[${o}]`);if(!r&&t===a.element&&i(t)){const e={value:!0};return Array.from(n.attributes).forEach((n=>{e[n.name]||t.setAttribute(n.name,n.value)})),!1}return!r},x=[A,C,S],M=[];var O=Object.freeze({__proto__:null,shouldMorphCallbacks:x,didMorphCallbacks:M,shouldMorph:v,didMorph:T,verifyNotMutable:A,verifyNotContentEditable:S,verifyNotPermanent:C}),k={append:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{html:n,focusSelector:o}=e;t.insertAdjacentHTML("beforeend",n||""),l(o)})),b(t,e)}))},graft:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{parent:n,focusSelector:o}=e,r=document.querySelector(n);r&&(r.appendChild(t),l(o))})),b(t,e)}))},innerHtml:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{html:n,focusSelector:o}=e;t.innerHTML=n||"",l(o)})),b(t,e)}))},insertAdjacentHtml:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{html:n,position:o,focusSelector:r}=e;t.insertAdjacentHTML(o||"beforeend",n||""),l(r)})),b(t,e)}))},insertAdjacentText:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{text:n,position:o,focusSelector:r}=e;t.insertAdjacentText(o||"beforeend",n||""),l(r)})),b(t,e)}))},morph:t=>{m(t,(n=>{const{html:o}=t,r=document.createElement("template");r.innerHTML=String(o).trim(),t.content=r.content;const s=n.parentElement,a=Array.from(s.children).indexOf(n);f(n,t),p(t,(()=>{const{childrenOnly:o,focusSelector:s}=t;e(n,o?r.content:r.innerHTML,{childrenOnly:!!o,onBeforeElUpdated:v(t),onElUpdated:T(t)}),l(s)})),b(s.children[a],t)}))},outerHtml:e=>{m(e,(t=>{const n=t.parentElement,o=Array.from(n.children).indexOf(t);f(t,e),p(e,(()=>{const{html:n,focusSelector:o}=e;t.outerHTML=n||"",l(o)})),b(n.children[o],e)}))},prepend:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{html:n,focusSelector:o}=e;t.insertAdjacentHTML("afterbegin",n||""),l(o)})),b(t,e)}))},remove:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{focusSelector:n}=e;t.remove(),l(n)})),b(document,e)}))},replace:e=>{m(e,(t=>{const n=t.parentElement,o=Array.from(n.children).indexOf(t);f(t,e),p(e,(()=>{const{html:n,focusSelector:o}=e;t.outerHTML=n||"",l(o)})),b(n.children[o],e)}))},textContent:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{text:n,focusSelector:o}=e;t.textContent=null!=n?n:"",l(o)})),b(t,e)}))},addCssClass:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n}=e;t.classList.add(...d(n||""))})),b(t,e)}))},removeAttribute:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n}=e;t.removeAttribute(n)})),b(t,e)}))},removeCssClass:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n}=e;t.classList.remove(...d(n))})),b(t,e)}))},setAttribute:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n,value:o}=e;t.setAttribute(n,o||"")})),b(t,e)}))},setDatasetProperty:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n,value:o}=e;t.dataset[n]=o||""})),b(t,e)}))},setProperty:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n,value:o}=e;n in t&&(t[n]=o||"")})),b(t,e)}))},setStyle:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n,value:o}=e;t.style[n]=o||""})),b(t,e)}))},setStyles:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{styles:n}=e;for(let[e,o]of Object.entries(n))t.style[e]=o||""})),b(t,e)}))},setValue:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{value:n}=e;t.value=n||""})),b(t,e)}))},dispatchEvent:e=>{m(e,(t=>{f(t,e),p(e,(()=>{const{name:n,detail:o}=e;c(t,n,o)})),b(t,e)}))},setMeta:e=>{f(document,e),p(e,(()=>{const{name:t,content:n}=e;let o=document.head.querySelector(`meta[name='${t}']`);o||(o=document.createElement("meta"),o.name=t,document.head.appendChild(o)),o.content=n})),b(document,e)},clearStorage:e=>{f(document,e),p(e,(()=>{const{type:t}=e;("session"===t?sessionStorage:localStorage).clear()})),b(document,e)},go:e=>{f(window,e),p(e,(()=>{const{delta:t}=e;history.go(t)})),b(window,e)},pushState:e=>{f(window,e),p(e,(()=>{const{state:t,title:n,url:o}=e;history.pushState(t||{},n||"",o)})),b(window,e)},redirectTo:e=>{f(window,e),p(e,(()=>{let{url:t,action:n}=e;n=n||"advance",window.Turbo&&window.Turbo.visit(t,{action:n}),window.Turbolinks&&window.Turbolinks.visit(t,{action:n}),window.Turbo||window.Turbolinks||(window.location.href=t)})),b(window,e)},reload:e=>{f(window,e),p(e,(()=>{window.location.reload()})),b(window,e)},removeStorageItem:e=>{f(document,e),p(e,(()=>{const{key:t,type:n}=e;("session"===n?sessionStorage:localStorage).removeItem(t)})),b(document,e)},replaceState:e=>{f(window,e),p(e,(()=>{const{state:t,title:n,url:o}=e;history.replaceState(t||{},n||"",o)})),b(window,e)},scrollIntoView:e=>{const{element:t}=e;f(t,e),p(e,(()=>{t.scrollIntoView(e)})),b(t,e)},setCookie:e=>{f(document,e),p(e,(()=>{const{cookie:t}=e;document.cookie=t||""})),b(document,e)},setFocus:e=>{const{element:t}=e;f(t,e),p(e,(()=>{l(t)})),b(t,e)},setStorageItem:e=>{f(document,e),p(e,(()=>{const{key:t,value:n,type:o}=e;("session"===o?sessionStorage:localStorage).setItem(t,n||"")})),b(document,e)},consoleLog:e=>{f(document,e),p(e,(()=>{const{message:t,level:n}=e;n&&["warn","info","error"].includes(n)?console[n](t||""):console.log(t||"")})),b(document,e)},consoleTable:e=>{f(document,e),p(e,(()=>{const{data:t,columns:n}=e;console.table(t,n||[])})),b(document,e)},notification:e=>{f(document,e),p(e,(()=>{const{title:t,options:n}=e;Notification.requestPermission().then((o=>{e.permission=o,"granted"===o&&new Notification(t||"",n)}))})),b(document,e)}};let L=k;const R=e=>{L={...L,...e}};var P={get all(){return L}};const q=(e,t={emitMissingElementWarnings:!0})=>{const n={};e.forEach((e=>{e.batch&&(n[e.batch]=n[e.batch]?++n[e.batch]:1)})),e.forEach((e=>{const o=e.operation;try{if(e.selector?e.element=e.xpath?u(e.selector):document[e.selectAll?"querySelectorAll":"querySelector"](e.selector):e.element=document,e.element||t.emitMissingElementWarnings){a.set(document.activeElement);const t=P.all[o];t?(t(e),e.batch&&0==--n[e.batch]&&c(document,"cable-ready:batch-complete",{batch:e.batch})):console.error(`CableReady couldn't find the "${o}" operation. Make sure you use the camelized form when calling an operation method.`)}}catch(t){e.element?(console.error(`CableReady detected an error in ${o||"operation"}: ${t.message}. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`),console.error(t)):console.warn(`CableReady ${o||"operation"} failed due to missing DOM element for selector: '${e.selector}'`)}}))};let H;const N=[25,50,75,100,200,250,500,800,1e3,2e3],I=async(e=0)=>{if(H)return H;if(e>=N.length)throw new Error("Couldn't obtain a Action Cable consumer within 5s");var t;return await(t=N[e],new Promise((e=>setTimeout(e,t)))),await I(e+1)};var U={setConsumer(e){H=e},get consumer(){return H},getConsumer:async()=>await I()};class $ extends HTMLElement{disconnectedCallback(){this.channel&&this.channel.unsubscribe()}createSubscription(e,t,n){this.channel=e.subscriptions.create({channel:t,identifier:this.identifier},{received:n})}get preview(){return document.documentElement.hasAttribute("data-turbolinks-preview")||document.documentElement.hasAttribute("data-turbo-preview")}get identifier(){return this.getAttribute("identifier")}}class _ extends ${async connectedCallback(){if(this.preview)return;const e=await U.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.performOperations):console.error("The `stream_from` helper cannot connect without an ActionCable consumer.\nPlease run `rails generate cable_ready:helpers` to fix this.")}performOperations(e){e.cableReady&&q(e.operations)}}class j extends ${constructor(){super();this.attachShadow({mode:"open"}).innerHTML="\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n"}async connectedCallback(){if(this.preview)return;this.update=y(this.update.bind(this),this.debounce);const e=await U.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.update):console.error("The `updates-for` helper cannot connect without an ActionCable consumer.\nPlease run `rails generate cable_ready:helpers` to fix this.")}async update(e){const t=Array.from(document.querySelectorAll(this.query),(e=>new D(e)));if(t[0].element!==this)return;a.set(document.activeElement),this.html={};const n=[...new Set(t.map((e=>e.url)))];await Promise.all(n.map((async e=>{if(!this.html.hasOwnProperty(e)){const t=await w(e,{"X-Cable-Ready":"update"});this.html[e]=await t.text()}}))),this.index={},t.forEach((t=>{this.index.hasOwnProperty(t.url)?this.index[t.url]++:this.index[t.url]=0,t.process(e,this.html,this.index)}))}get query(){return`updates-for[identifier="${this.identifier}"]`}get identifier(){return this.getAttribute("identifier")}get debounce(){return this.hasAttribute("debounce")?parseInt(this.getAttribute("debounce")):20}}class D{constructor(e){this.element=e}async process(t,n,o){if(!this.shouldUpdate(t))return;const r=o[this.url],s=document.createElement("template");this.element.setAttribute("updating","updating"),s.innerHTML=String(n[this.url]).trim(),await this.resolveTurboFrames(s.content);const a=s.content.querySelectorAll(this.query);if(a.length<=r)return void console.warn(`Update aborted due to insufficient number of elements. The offending url is ${this.url}.`);const i={element:this.element,html:a[r],permanentAttributeName:"data-ignore-updates"};c(this.element,"cable-ready:before-update",i),e(this.element,a[r],{childrenOnly:!0,onBeforeElUpdated:v(i),onElUpdated:e=>{this.element.removeAttribute("updating"),c(this.element,"cable-ready:after-update",i),l(i.focusSelector)}})}async resolveTurboFrames(e){const t=[...e.querySelectorAll('turbo-frame[src]:not([loading="lazy"])')];return Promise.all(t.map((t=>new Promise((async n=>{const o=await w(t.getAttribute("src"),{"Turbo-Frame":t.id,"X-Cable-Ready":"update"}),r=document.createElement("template");r.innerHTML=await o.text(),await this.resolveTurboFrames(r.content),e.querySelector(`turbo-frame#${t.id}`).innerHTML=String(r.content.querySelector(`turbo-frame#${t.id}`).innerHTML).trim(),n()})))))}shouldUpdate(e){return!this.ignoresInnerUpdates&&this.hasChangesSelectedForUpdate(e)}hasChangesSelectedForUpdate(e){const t=this.element.getAttribute("only");return!(t&&e.changed&&!t.split(" ").some((t=>e.changed.includes(t))))}get ignoresInnerUpdates(){return this.element.hasAttribute("ignore-inner-updates")&&this.element.hasAttribute("performing-inner-update")}get url(){return this.element.hasAttribute("url")?this.element.getAttribute("url"):location.href}get identifier(){return this.element.identifier}get query(){return this.element.query}}const F=e=>{const t=e&&e.parentElement.closest("updates-for");t&&(t.setAttribute("performing-inner-update",""),F(t))},z=e=>{const t=e&&e.parentElement.closest("updates-for");t&&(t.removeAttribute("performing-inner-update"),z(t))},X={perform:q,performAsync:(e,t={emitMissingElementWarnings:!0})=>new Promise(((n,o)=>{try{n(q(e,t))}catch(e){o(e)}})),shouldMorphCallbacks:x,didMorphCallbacks:M,initialize:(e={})=>{const{consumer:t}=e;document.addEventListener("stimulus-reflex:before",(e=>{F(e.detail.element)})),document.addEventListener("stimulus-reflex:after",(e=>{setTimeout((()=>{z(e.detail.element)}))})),document.addEventListener("turbo:submit-start",(e=>{F(e.target)})),document.addEventListener("turbo:submit-end",(e=>{setTimeout((()=>{z(e.target)}))})),t?U.setConsumer(t):console.error("CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`."),customElements.get("stream-from")||customElements.define("stream-from",_),customElements.get("updates-for")||customElements.define("updates-for",j)},addOperation:(e,t)=>{const n={};n[e]=t,R(n)},addOperations:e=>{R(e)},version:t,cable:U,get DOMOperations(){return console.warn("DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`"),P.all},get operations(){return P.all},get consumer(){return U.consumer}};window.CableReady=X;export{O as MorphCallbacks,_ as StreamFromElement,$ as SubscribingElement,j as UpdatesForElement,E as Utils,X as default};
|
2
|
-
//# sourceMappingURL=cable_ready.min.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"cable_ready.min.js","sources":["../../../javascript/enums.js","../../../javascript/active_element.js","../../../javascript/utils.js","../../../javascript/morph_callbacks.js","../../../javascript/operations.js","../../../javascript/operation_store.js","../../../javascript/cable_ready.js","../../../javascript/cable_consumer.js","../../../javascript/elements/subscribing_element.js","../../../javascript/elements/stream_from_element.js","../../../javascript/elements/updates_for_element.js","../../../javascript/updatable/inner_updates_compat.js","../../../javascript/index.js","../../../javascript/elements/index.js"],"sourcesContent":["export const inputTags = {\n INPUT: true,\n TEXTAREA: true,\n SELECT: true\n}\n\nexport const mutableTags = {\n INPUT: true,\n TEXTAREA: true,\n OPTION: true\n}\n\nexport const textInputTypes = {\n 'datetime-local': true,\n 'select-multiple': true,\n 'select-one': true,\n color: true,\n date: true,\n datetime: true,\n email: true,\n month: true,\n number: true,\n password: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n textarea: true,\n time: true,\n url: true,\n week: true\n}\n","let activeElement\n\nexport default {\n get element () {\n return activeElement\n },\n set (element) {\n activeElement = element\n }\n}\n","import { inputTags, textInputTypes } from './enums'\nimport ActiveElement from './active_element'\n\n// Indicates if the passed element is considered a text input.\n//\nconst isTextInput = element => {\n return inputTags[element.tagName] && textInputTypes[element.type]\n}\n\n// Assigns focus to the appropriate element... preferring the explicitly passed selector\n//\n// * selector - a CSS selector for the element that should have focus\n//\nconst assignFocus = selector => {\n const element =\n selector && selector.nodeType === Node.ELEMENT_NODE\n ? selector\n : document.querySelector(selector)\n const focusElement = element || ActiveElement.element\n if (focusElement && focusElement.focus) focusElement.focus()\n}\n\n// Dispatches an event on the passed element\n//\n// * element - the element\n// * name - the name of the event\n// * detail - the event detail\n//\nconst dispatch = (element, name, detail = {}) => {\n const init = { bubbles: true, cancelable: true, detail: detail }\n const evt = new CustomEvent(name, init)\n element.dispatchEvent(evt)\n if (window.jQuery) window.jQuery(element).trigger(name, detail)\n}\n\n// Accepts an xPath query and returns the element found at that position in the DOM\n//\nconst xpathToElement = xpath => {\n return document.evaluate(\n xpath,\n document,\n null,\n XPathResult.FIRST_ORDERED_NODE_TYPE,\n null\n ).singleNodeValue\n}\n\n// Return an array with the class names to be used\n//\n// * names - could be a string or an array of strings for multiple classes.\n//\nconst getClassNames = names => Array(names).flat()\n\n// Perform operation for either the first or all of the elements returned by CSS selector\n//\n// * operation - the instruction payload from perform\n// * callback - the operation function to run for each element\n//\nconst processElements = (operation, callback) => {\n Array.from(\n operation.selectAll ? operation.element : [operation.element]\n ).forEach(callback)\n}\n\n// camelCase to kebab-case\n//\nconst kebabize = str => {\n return str\n .split('')\n .map((letter, idx) => {\n return letter.toUpperCase() === letter\n ? `${idx !== 0 ? '-' : ''}${letter.toLowerCase()}`\n : letter\n })\n .join('')\n}\n\n// Provide a standardized pipeline of checks and modifications to all operations based on provided options\n// Currently skips execution if cancelled and implements an optional delay\n//\nconst operate = (operation, callback) => {\n if (!operation.cancel) {\n operation.delay ? setTimeout(callback, operation.delay) : callback()\n return true\n }\n return false\n}\n\n// Dispatch life-cycle events with standardized naming\nconst before = (target, operation) =>\n dispatch(\n target,\n `cable-ready:before-${kebabize(operation.operation)}`,\n operation\n )\n\nconst after = (target, operation) =>\n dispatch(\n target,\n `cable-ready:after-${kebabize(operation.operation)}`,\n operation\n )\n\nfunction debounce (func, timeout) {\n let timer\n return (...args) => {\n clearTimeout(timer)\n timer = setTimeout(() => func.apply(this, args), timeout)\n }\n}\n\nfunction handleErrors (response) {\n if (!response.ok) throw Error(response.statusText)\n return response\n}\n\n// A proxy method to wrap a fetch call in error handling\n//\n// * url - the URL to fetch\n// * additionalHeaders - an object of additional headers passed to fetch\n//\nasync function graciouslyFetch (url, additionalHeaders) {\n try {\n const response = await fetch(url, {\n headers: {\n 'X-REQUESTED-WITH': 'XmlHttpRequest',\n ...additionalHeaders\n }\n })\n if (response == undefined) return\n\n handleErrors(response)\n\n return response\n } catch (e) {\n console.error(`Could not fetch ${url}`)\n }\n}\n\nexport {\n isTextInput,\n assignFocus,\n dispatch,\n xpathToElement,\n getClassNames,\n processElements,\n operate,\n before,\n after,\n debounce,\n handleErrors,\n graciouslyFetch,\n kebabize\n}\n","import { mutableTags } from './enums'\nimport { isTextInput } from './utils'\nimport ActiveElement from './active_element'\n\n// Indicates whether or not we should morph an element via onBeforeElUpdated callback\n// SEE: https://github.com/patrick-steele-idem/morphdom#morphdomfromnode-tonode-options--node\n//\nconst shouldMorph = operation => (fromEl, toEl) => {\n return !shouldMorphCallbacks\n .map(callback => {\n return typeof callback === 'function'\n ? callback(operation, fromEl, toEl)\n : true\n })\n .includes(false)\n}\n\n// Execute any pluggable functions that modify elements after morphing via onElUpdated callback\n//\nconst didMorph = operation => el => {\n didMorphCallbacks.forEach(callback => {\n if (typeof callback === 'function') callback(operation, el)\n })\n}\n\nconst verifyNotMutable = (detail, fromEl, toEl) => {\n // Skip nodes that are equal:\n // https://github.com/patrick-steele-idem/morphdom#can-i-make-morphdom-blaze-through-the-dom-tree-even-faster-yes\n if (!mutableTags[fromEl.tagName] && fromEl.isEqualNode(toEl)) return false\n return true\n}\n\nconst verifyNotContentEditable = (detail, fromEl, toEl) => {\n if (fromEl === ActiveElement.element && fromEl.isContentEditable) return false\n return true\n}\n\nconst verifyNotPermanent = (detail, fromEl, toEl) => {\n const { permanentAttributeName } = detail\n if (!permanentAttributeName) return true\n\n const permanent = fromEl.closest(`[${permanentAttributeName}]`)\n\n // only morph attributes on the active non-permanent text input\n if (!permanent && fromEl === ActiveElement.element && isTextInput(fromEl)) {\n const ignore = { value: true }\n Array.from(toEl.attributes).forEach(attribute => {\n if (!ignore[attribute.name])\n fromEl.setAttribute(attribute.name, attribute.value)\n })\n return false\n }\n\n return !permanent\n}\n\nconst shouldMorphCallbacks = [\n verifyNotMutable,\n verifyNotPermanent,\n verifyNotContentEditable\n]\nconst didMorphCallbacks = []\n\nexport {\n shouldMorphCallbacks,\n didMorphCallbacks,\n shouldMorph,\n didMorph,\n verifyNotMutable,\n verifyNotContentEditable,\n verifyNotPermanent\n}\n","import morphdom from 'morphdom'\nimport { shouldMorph, didMorph } from './morph_callbacks'\nimport {\n assignFocus,\n dispatch,\n getClassNames,\n processElements,\n before,\n after,\n operate\n} from './utils'\n\nexport default {\n // DOM Mutations\n\n append: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.insertAdjacentHTML('beforeend', html || '')\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n graft: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { parent, focusSelector } = operation\n const parentElement = document.querySelector(parent)\n if (parentElement) {\n parentElement.appendChild(element)\n assignFocus(focusSelector)\n }\n })\n after(element, operation)\n })\n },\n\n innerHtml: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.innerHTML = html || ''\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n insertAdjacentHtml: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, position, focusSelector } = operation\n element.insertAdjacentHTML(position || 'beforeend', html || '')\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n insertAdjacentText: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { text, position, focusSelector } = operation\n element.insertAdjacentText(position || 'beforeend', text || '')\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n morph: operation => {\n processElements(operation, element => {\n const { html } = operation\n const template = document.createElement('template')\n template.innerHTML = String(html).trim()\n operation.content = template.content\n const parent = element.parentElement\n const ordinal = Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { childrenOnly, focusSelector } = operation\n morphdom(\n element,\n childrenOnly ? template.content : template.innerHTML,\n {\n childrenOnly: !!childrenOnly,\n onBeforeElUpdated: shouldMorph(operation),\n onElUpdated: didMorph(operation)\n }\n )\n assignFocus(focusSelector)\n })\n after(parent.children[ordinal], operation)\n })\n },\n\n outerHtml: operation => {\n processElements(operation, element => {\n const parent = element.parentElement\n const ordinal = Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.outerHTML = html || ''\n assignFocus(focusSelector)\n })\n after(parent.children[ordinal], operation)\n })\n },\n\n prepend: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.insertAdjacentHTML('afterbegin', html || '')\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n remove: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { focusSelector } = operation\n element.remove()\n assignFocus(focusSelector)\n })\n after(document, operation)\n })\n },\n\n replace: operation => {\n processElements(operation, element => {\n const parent = element.parentElement\n const ordinal = Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.outerHTML = html || ''\n assignFocus(focusSelector)\n })\n after(parent.children[ordinal], operation)\n })\n },\n\n textContent: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { text, focusSelector } = operation\n element.textContent = (text != null) ? text : ''\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n // Element Property Mutations\n\n addCssClass: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.classList.add(...getClassNames(name || ''))\n })\n after(element, operation)\n })\n },\n\n removeAttribute: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.removeAttribute(name)\n })\n after(element, operation)\n })\n },\n\n removeCssClass: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.classList.remove(...getClassNames(name))\n })\n after(element, operation)\n })\n },\n\n setAttribute: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.setAttribute(name, value || '')\n })\n after(element, operation)\n })\n },\n\n setDatasetProperty: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.dataset[name] = value || ''\n })\n after(element, operation)\n })\n },\n\n setProperty: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n if (name in element) element[name] = value || ''\n })\n after(element, operation)\n })\n },\n\n setStyle: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.style[name] = value || ''\n })\n after(element, operation)\n })\n },\n\n setStyles: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { styles } = operation\n for (let [name, value] of Object.entries(styles))\n element.style[name] = value || ''\n })\n after(element, operation)\n })\n },\n\n setValue: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { value } = operation\n element.value = value || ''\n })\n after(element, operation)\n })\n },\n\n // DOM Events\n\n dispatchEvent: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, detail } = operation\n dispatch(element, name, detail)\n })\n after(element, operation)\n })\n },\n\n setMeta: operation => {\n before(document, operation)\n operate(operation, () => {\n const { name, content } = operation\n let meta = document.head.querySelector(`meta[name='${name}']`)\n if (!meta) {\n meta = document.createElement('meta')\n meta.name = name\n document.head.appendChild(meta)\n }\n meta.content = content\n })\n after(document, operation)\n },\n\n // Browser Manipulations\n\n clearStorage: operation => {\n before(document, operation)\n operate(operation, () => {\n const { type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.clear()\n })\n after(document, operation)\n },\n\n go: operation => {\n before(window, operation)\n operate(operation, () => {\n const { delta } = operation\n history.go(delta)\n })\n after(window, operation)\n },\n\n pushState: operation => {\n before(window, operation)\n operate(operation, () => {\n const { state, title, url } = operation\n history.pushState(state || {}, title || '', url)\n })\n after(window, operation)\n },\n\n redirectTo: operation => {\n before(window, operation)\n operate(operation, () => {\n let { url, action } = operation\n action = action || 'advance'\n if (window.Turbo) window.Turbo.visit(url, { action })\n if (window.Turbolinks) window.Turbolinks.visit(url, { action })\n if (!window.Turbo && !window.Turbolinks) window.location.href = url\n })\n after(window, operation)\n },\n\n reload: operation => {\n before(window, operation)\n operate(operation, () => {\n window.location.reload()\n })\n after(window, operation)\n },\n\n removeStorageItem: operation => {\n before(document, operation)\n operate(operation, () => {\n const { key, type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.removeItem(key)\n })\n after(document, operation)\n },\n\n replaceState: operation => {\n before(window, operation)\n operate(operation, () => {\n const { state, title, url } = operation\n history.replaceState(state || {}, title || '', url)\n })\n after(window, operation)\n },\n\n scrollIntoView: operation => {\n const { element } = operation\n before(element, operation)\n operate(operation, () => {\n element.scrollIntoView(operation)\n })\n after(element, operation)\n },\n\n setCookie: operation => {\n before(document, operation)\n operate(operation, () => {\n const { cookie } = operation\n document.cookie = cookie || ''\n })\n after(document, operation)\n },\n\n setFocus: operation => {\n const { element } = operation\n before(element, operation)\n operate(operation, () => {\n assignFocus(element)\n })\n after(element, operation)\n },\n\n setStorageItem: operation => {\n before(document, operation)\n operate(operation, () => {\n const { key, value, type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.setItem(key, value || '')\n })\n after(document, operation)\n },\n\n // Notifications\n\n consoleLog: operation => {\n before(document, operation)\n operate(operation, () => {\n const { message, level } = operation\n level && ['warn', 'info', 'error'].includes(level)\n ? console[level](message || '')\n : console.log(message || '')\n })\n after(document, operation)\n },\n\n consoleTable: operation => {\n before(document, operation)\n operate(operation, () => {\n const { data, columns } = operation\n console.table(data, columns || [])\n })\n after(document, operation)\n },\n\n notification: operation => {\n before(document, operation)\n operate(operation, () => {\n const { title, options } = operation\n Notification.requestPermission().then(result => {\n operation.permission = result\n if (result === 'granted') new Notification(title || '', options)\n })\n })\n after(document, operation)\n }\n}\n","import Operations from './operations'\n\nlet operations = Operations\n\nconst add = newOperations => {\n operations = { ...operations, ...newOperations }\n}\n\nconst addOperations = operations => {\n add(operations)\n}\n\nconst addOperation = (name, operation) => {\n const operations = {}\n operations[name] = operation\n\n add(operations)\n}\n\nexport { addOperation, addOperations }\n\nexport default {\n get all () {\n return operations\n }\n}\n","import { xpathToElement, dispatch } from './utils'\n\nimport ActiveElement from './active_element'\nimport OperationStore from './operation_store'\n\nconst perform = (\n operations,\n options = { emitMissingElementWarnings: true }\n) => {\n const batches = {}\n operations.forEach(operation => {\n if (!!operation.batch)\n batches[operation.batch] = batches[operation.batch]\n ? ++batches[operation.batch]\n : 1\n })\n operations.forEach(operation => {\n const name = operation.operation\n try {\n if (operation.selector) {\n operation.element = operation.xpath\n ? xpathToElement(operation.selector)\n : document[\n operation.selectAll ? 'querySelectorAll' : 'querySelector'\n ](operation.selector)\n } else {\n operation.element = document\n }\n if (operation.element || options.emitMissingElementWarnings) {\n ActiveElement.set(document.activeElement)\n const cableReadyOperation = OperationStore.all[name]\n\n if (cableReadyOperation) {\n cableReadyOperation(operation)\n if (!!operation.batch && --batches[operation.batch] === 0)\n dispatch(document, 'cable-ready:batch-complete', {\n batch: operation.batch\n })\n } else {\n console.error(\n `CableReady couldn't find the \"${name}\" operation. Make sure you use the camelized form when calling an operation method.`\n )\n }\n }\n } catch (e) {\n if (operation.element) {\n console.error(\n `CableReady detected an error in ${name || 'operation'}: ${\n e.message\n }. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`\n )\n console.error(e)\n } else {\n console.warn(\n `CableReady ${name ||\n 'operation'} failed due to missing DOM element for selector: '${\n operation.selector\n }'`\n )\n }\n }\n })\n}\n\nconst performAsync = (\n operations,\n options = { emitMissingElementWarnings: true }\n) => {\n return new Promise((resolve, reject) => {\n try {\n resolve(perform(operations, options))\n } catch (err) {\n reject(err)\n }\n })\n}\n\nexport { perform, performAsync }\n","let consumer\n\nconst BACKOFF = [25, 50, 75, 100, 200, 250, 500, 800, 1000, 2000]\n\nconst wait = (ms) => new Promise(resolve => setTimeout(resolve, ms))\n\nconst getConsumerWithRetry = async (retry = 0) => {\n if (consumer) return consumer\n\n if (retry >= BACKOFF.length) {\n throw new Error(\"Couldn't obtain a Action Cable consumer within 5s\")\n }\n\n await wait(BACKOFF[retry])\n\n return await getConsumerWithRetry(retry + 1)\n}\n\nexport default {\n setConsumer (value) {\n consumer = value\n },\n\n get consumer () {\n return consumer\n },\n\n async getConsumer () {\n return await getConsumerWithRetry()\n }\n}\n","export default class SubscribingElement extends HTMLElement {\n disconnectedCallback () {\n if (this.channel) this.channel.unsubscribe()\n }\n\n createSubscription (consumer, channel, receivedCallback) {\n this.channel = consumer.subscriptions.create(\n {\n channel,\n identifier: this.identifier\n },\n {\n received: receivedCallback\n }\n )\n }\n\n get preview () {\n return (\n document.documentElement.hasAttribute('data-turbolinks-preview') ||\n document.documentElement.hasAttribute('data-turbo-preview')\n )\n }\n\n get identifier () {\n return this.getAttribute('identifier')\n }\n}\n","import { perform } from '../cable_ready'\nimport SubscribingElement from './subscribing_element'\nimport CableConsumer from '../cable_consumer'\n\nexport default class StreamFromElement extends SubscribingElement {\n async connectedCallback () {\n if (this.preview) return\n\n const consumer = await CableConsumer.getConsumer()\n\n if (consumer) {\n this.createSubscription(\n consumer,\n 'CableReady::Stream',\n this.performOperations\n )\n } else {\n console.error(\n 'The `stream_from` helper cannot connect without an ActionCable consumer.\\nPlease run `rails generate cable_ready:helpers` to fix this.'\n )\n }\n }\n\n performOperations (data) {\n if (data.cableReady) perform(data.operations)\n }\n}\n","import morphdom from 'morphdom'\n\nimport SubscribingElement from './subscribing_element'\n\nimport { shouldMorph } from '../morph_callbacks'\nimport { debounce, assignFocus, dispatch, graciouslyFetch } from '../utils'\n\nimport ActiveElement from '../active_element'\nimport CableConsumer from '../cable_consumer'\n\nconst template = `\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n`\n\nfunction url (element) {\n return element.hasAttribute('url')\n ? element.getAttribute('url')\n : location.href\n}\n\nexport default class UpdatesForElement extends SubscribingElement {\n constructor () {\n super()\n const shadowRoot = this.attachShadow({ mode: 'open' })\n shadowRoot.innerHTML = template\n }\n\n async connectedCallback () {\n if (this.preview) return\n this.update = debounce(this.update.bind(this), this.debounce)\n\n const consumer = await CableConsumer.getConsumer()\n\n if (consumer) {\n this.createSubscription(consumer, 'CableReady::Stream', this.update)\n } else {\n console.error(\n 'The `updates-for` helper cannot connect without an ActionCable consumer.\\nPlease run `rails generate cable_ready:helpers` to fix this.'\n )\n }\n }\n\n async update (data) {\n const blocks = Array.from(\n document.querySelectorAll(this.query),\n element => new Block(element)\n )\n\n // first updates-for element in the DOM *at any given moment* updates all of the others\n if (blocks[0].element !== this) return\n\n // hold a reference to the active element so that it can be restored after the morph\n ActiveElement.set(document.activeElement)\n\n // store all retrieved HTML in an object keyed by URL to minimize fetch calls\n this.html = {}\n\n const uniqueUrls = [...new Set(blocks.map(block => block.url))]\n\n await Promise.all(\n uniqueUrls.map(async url => {\n if (!this.html.hasOwnProperty(url)) {\n const response = await graciouslyFetch(url, {\n 'X-Cable-Ready': 'update'\n })\n this.html[url] = await response.text()\n }\n })\n )\n\n // track current block index for each URL; referred to as fragments\n this.index = {}\n\n blocks.forEach(block => {\n // if the block's URL is not in the index, initialize it to 0; otherwise, increment it\n this.index.hasOwnProperty(block.url)\n ? this.index[block.url]++\n : (this.index[block.url] = 0)\n\n block.process(data, this.html, this.index)\n })\n }\n\n get query () {\n return `updates-for[identifier=\"${this.identifier}\"]`\n }\n\n get identifier () {\n return this.getAttribute('identifier')\n }\n\n get debounce () {\n return this.hasAttribute('debounce')\n ? parseInt(this.getAttribute('debounce'))\n : 20\n }\n}\n\nclass Block {\n constructor (element) {\n this.element = element\n }\n\n async process (data, html, index) {\n // with the index incremented, we can now safely bail - before a fetch - if there's no work to be done\n if (!this.shouldUpdate(data)) return\n\n const blockIndex = index[this.url]\n const template = document.createElement('template')\n this.element.setAttribute('updating', 'updating')\n\n template.innerHTML = String(html[this.url]).trim()\n\n await this.resolveTurboFrames(template.content)\n\n const fragments = template.content.querySelectorAll(this.query)\n\n if (fragments.length <= blockIndex) {\n console.warn(\n `Update aborted due to insufficient number of elements. The offending url is ${this.url}.`\n )\n return\n }\n\n const operation = {\n element: this.element,\n html: fragments[blockIndex],\n permanentAttributeName: 'data-ignore-updates'\n }\n\n dispatch(this.element, 'cable-ready:before-update', operation)\n morphdom(this.element, fragments[blockIndex], {\n childrenOnly: true,\n onBeforeElUpdated: shouldMorph(operation),\n onElUpdated: _ => {\n this.element.removeAttribute('updating')\n dispatch(this.element, 'cable-ready:after-update', operation)\n assignFocus(operation.focusSelector)\n }\n })\n }\n\n async resolveTurboFrames (documentFragment) {\n const reloadingTurboFrames = [\n ...documentFragment.querySelectorAll(\n 'turbo-frame[src]:not([loading=\"lazy\"])'\n )\n ]\n\n return Promise.all(\n reloadingTurboFrames.map(frame => {\n return new Promise(async resolve => {\n const frameResponse = await graciouslyFetch(\n frame.getAttribute('src'),\n {\n 'Turbo-Frame': frame.id,\n 'X-Cable-Ready': 'update'\n }\n )\n\n const frameTemplate = document.createElement('template')\n frameTemplate.innerHTML = await frameResponse.text()\n\n // recurse here to get all nested eager loaded frames\n await this.resolveTurboFrames(frameTemplate.content)\n\n documentFragment.querySelector(\n `turbo-frame#${frame.id}`\n ).innerHTML = String(\n frameTemplate.content.querySelector(`turbo-frame#${frame.id}`)\n .innerHTML\n ).trim()\n\n resolve()\n })\n })\n )\n }\n\n shouldUpdate (data) {\n // if everything that could prevent an update is false, update this block\n return !this.ignoresInnerUpdates && this.hasChangesSelectedForUpdate(data)\n }\n\n hasChangesSelectedForUpdate (data) {\n // if there's an only attribute, only update if at least one of the attributes changed is in the allow list\n const only = this.element.getAttribute('only')\n\n return !(\n only &&\n data.changed &&\n !only.split(' ').some(attribute => data.changed.includes(attribute))\n )\n }\n\n get ignoresInnerUpdates () {\n // don't update during a Reflex or Turbolinks redraw\n return (\n this.element.hasAttribute('ignore-inner-updates') &&\n this.element.hasAttribute('performing-inner-update')\n )\n }\n\n get url () {\n return this.element.hasAttribute('url')\n ? this.element.getAttribute('url')\n : location.href\n }\n\n get identifier () {\n return this.element.identifier\n }\n\n get query () {\n return this.element.query\n }\n}\n","export const registerInnerUpdates = () => {\n document.addEventListener('stimulus-reflex:before', event => {\n recursiveMarkUpdatesForElements(event.detail.element)\n })\n\n document.addEventListener('stimulus-reflex:after', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.detail.element)\n })\n })\n\n document.addEventListener('turbo:submit-start', event => {\n recursiveMarkUpdatesForElements(event.target)\n })\n\n document.addEventListener('turbo:submit-end', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n}\n\nconst recursiveMarkUpdatesForElements = leaf => {\n const closestUpdatesFor = leaf && leaf.parentElement.closest('updates-for')\n if (closestUpdatesFor) {\n closestUpdatesFor.setAttribute('performing-inner-update', '')\n recursiveMarkUpdatesForElements(closestUpdatesFor)\n }\n}\n\nconst recursiveUnmarkUpdatesForElements = leaf => {\n const closestUpdatesFor = leaf && leaf.parentElement.closest('updates-for')\n if (closestUpdatesFor) {\n closestUpdatesFor.removeAttribute('performing-inner-update')\n recursiveUnmarkUpdatesForElements(closestUpdatesFor)\n }\n}\n","import packageInfo from '../package.json'\nimport { perform, performAsync } from './cable_ready'\nimport { initialize } from './elements'\nimport { shouldMorphCallbacks, didMorphCallbacks } from './morph_callbacks'\n\nimport * as MorphCallbacks from './morph_callbacks'\nimport * as Utils from './utils'\n\nimport OperationStore, { addOperation, addOperations } from './operation_store'\nimport StreamFromElement from './elements/stream_from_element'\nimport UpdatesForElement from './elements/updates_for_element'\nimport SubscribingElement from './elements/subscribing_element'\nimport CableConsumer from './cable_consumer'\n\nexport {\n Utils,\n MorphCallbacks,\n StreamFromElement,\n UpdatesForElement,\n SubscribingElement\n}\n\nconst global = {\n perform,\n performAsync,\n shouldMorphCallbacks,\n didMorphCallbacks,\n initialize,\n addOperation,\n addOperations,\n version: packageInfo.version,\n cable: CableConsumer,\n get DOMOperations () {\n console.warn(\n 'DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`'\n )\n return OperationStore.all\n },\n get operations () {\n return OperationStore.all\n },\n get consumer () {\n return CableConsumer.consumer\n }\n}\n\nwindow.CableReady = global\n\nexport default global\n","import CableConsumer from '../cable_consumer'\n\nimport StreamFromElement from './stream_from_element'\nimport UpdatesForElement from './updates_for_element'\n\nimport { registerInnerUpdates } from '../updatable/inner_updates_compat'\n\nconst initialize = (initializeOptions = {}) => {\n const { consumer } = initializeOptions\n\n registerInnerUpdates()\n\n if (consumer) {\n CableConsumer.setConsumer(consumer)\n } else {\n console.error(\n 'CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`.'\n )\n }\n\n if (!customElements.get('stream-from')) {\n customElements.define('stream-from', StreamFromElement)\n }\n\n if (!customElements.get('updates-for')) {\n customElements.define('updates-for', UpdatesForElement)\n }\n}\n\nexport { initialize }\n"],"names":["inputTags","INPUT","TEXTAREA","SELECT","mutableTags","OPTION","textInputTypes","color","date","datetime","email","month","number","password","range","search","tel","text","textarea","time","url","week","activeElement","ActiveElement","element","set","isTextInput","tagName","type","assignFocus","selector","focusElement","nodeType","Node","ELEMENT_NODE","document","querySelector","focus","dispatch","name","detail","evt","CustomEvent","bubbles","cancelable","dispatchEvent","window","jQuery","trigger","xpathToElement","xpath","evaluate","XPathResult","FIRST_ORDERED_NODE_TYPE","singleNodeValue","getClassNames","names","Array","flat","processElements","operation","callback","from","selectAll","forEach","kebabize","str","split","map","letter","idx","toUpperCase","toLowerCase","join","operate","cancel","delay","setTimeout","before","target","after","debounce","func","timeout","timer","args","clearTimeout","apply","this","handleErrors","response","ok","Error","statusText","async","graciouslyFetch","additionalHeaders","fetch","headers","undefined","e","console","error","shouldMorph","fromEl","toEl","shouldMorphCallbacks","includes","didMorph","el","didMorphCallbacks","verifyNotMutable","isEqualNode","verifyNotContentEditable","isContentEditable","verifyNotPermanent","permanentAttributeName","permanent","closest","ignore","value","attributes","attribute","setAttribute","Operations","append","html","focusSelector","insertAdjacentHTML","graft","parent","parentElement","appendChild","innerHtml","innerHTML","insertAdjacentHtml","position","insertAdjacentText","morph","template","createElement","String","trim","content","ordinal","children","indexOf","childrenOnly","morphdom","onBeforeElUpdated","onElUpdated","outerHtml","outerHTML","prepend","remove","replace","textContent","addCssClass","classList","add","removeAttribute","removeCssClass","setDatasetProperty","dataset","setProperty","setStyle","style","setStyles","styles","Object","entries","setValue","setMeta","meta","head","clearStorage","sessionStorage","localStorage","clear","go","delta","history","pushState","state","title","redirectTo","action","Turbo","visit","Turbolinks","location","href","reload","removeStorageItem","key","removeItem","replaceState","scrollIntoView","setCookie","cookie","setFocus","setStorageItem","setItem","consoleLog","message","level","log","consoleTable","data","columns","table","notification","options","Notification","requestPermission","then","result","permission","operations","newOperations","OperationStore","all","perform","emitMissingElementWarnings","batches","batch","cableReadyOperation","warn","consumer","BACKOFF","getConsumerWithRetry","retry","length","ms","Promise","resolve","CableConsumer","setConsumer","SubscribingElement","HTMLElement","disconnectedCallback","channel","unsubscribe","createSubscription","receivedCallback","subscriptions","create","identifier","received","preview","documentElement","hasAttribute","getAttribute","StreamFromElement","getConsumer","performOperations","cableReady","UpdatesForElement","constructor","super","attachShadow","mode","update","bind","blocks","querySelectorAll","query","Block","uniqueUrls","Set","block","hasOwnProperty","index","process","parseInt","shouldUpdate","blockIndex","resolveTurboFrames","fragments","_","documentFragment","reloadingTurboFrames","frame","frameResponse","id","frameTemplate","ignoresInnerUpdates","hasChangesSelectedForUpdate","only","changed","some","recursiveMarkUpdatesForElements","leaf","closestUpdatesFor","recursiveUnmarkUpdatesForElements","global","performAsync","reject","err","initialize","initializeOptions","addEventListener","event","customElements","get","define","addOperation","addOperations","version","packageInfo","cable","DOMOperations","CableReady"],"mappings":"2CAAO,MAAMA,EAAY,CACvBC,OAAO,EACPC,UAAU,EACVC,QAAQ,GAGGC,EAAc,CACzBH,OAAO,EACPC,UAAU,EACVG,QAAQ,GAGGC,EAAiB,CAC5B,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,MAAM,GC9BR,IAAIC,EAEJ,IAAeC,EAAA,CACTC,cACF,OAAOF,GAETG,IAAKD,GACHF,EAAgBE,ICFpB,MAAME,EAAcF,GACXxB,EAAUwB,EAAQG,UAAYrB,EAAekB,EAAQI,MAOxDC,EAAc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AIzBtL,OAAO0Q,WAAajB"}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("morphdom")):"function"==typeof define&&define.amd?define(["exports","morphdom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CableReady={},e.morphdom)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t),r="5.0.0-pre9";const s={INPUT:!0,TEXTAREA:!0,SELECT:!0},a={INPUT:!0,TEXTAREA:!0,OPTION:!0},i={"datetime-local":!0,"select-multiple":!0,"select-one":!0,color:!0,date:!0,datetime:!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,textarea:!0,time:!0,url:!0,week:!0};let l;var c={get element(){return l},set(e){l=e}};const u=e=>s[e.tagName]&&i[e.type],d=e=>{const t=(e&&e.nodeType===Node.ELEMENT_NODE?e:document.querySelector(e))||c.element;t&&t.focus&&t.focus()},m=(e,t,n={})=>{const o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e.dispatchEvent(o),window.jQuery&&window.jQuery(e).trigger(t,n)},h=e=>document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,p=e=>Array(e).flat(),f=(e,t)=>{Array.from(e.selectAll?e.element:[e.element]).forEach(t)},b=e=>e.split("").map(((e,t)=>e.toUpperCase()===e?`${0!==t?"-":""}${e.toLowerCase()}`:e)).join(""),y=(e,t)=>!e.cancel&&(e.delay?setTimeout(t,e.delay):t(),!0),g=(e,t)=>m(e,`cable-ready:before-${b(t.operation)}`,t),w=(e,t)=>m(e,`cable-ready:after-${b(t.operation)}`,t);function E(e,t){let n;return(...o)=>{clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}}function v(e){if(!e.ok)throw Error(e.statusText);return e}async function T(e,t){try{const n=await fetch(e,{headers:{"X-REQUESTED-WITH":"XmlHttpRequest",...t}});if(null==n)return;return v(n),n}catch(t){console.error(`Could not fetch ${e}`)}}var S=Object.freeze({__proto__:null,isTextInput:u,assignFocus:d,dispatch:m,xpathToElement:h,getClassNames:p,processElements:f,operate:y,before:g,after:w,debounce:E,handleErrors:v,graciouslyFetch:T,kebabize:b});const A=e=>(t,n)=>!k.map((o=>"function"!=typeof o||o(e,t,n))).includes(!1),C=e=>t=>{L.forEach((n=>{"function"==typeof n&&n(e,t)}))},x=(e,t,n)=>!(!a[t.tagName]&&t.isEqualNode(n)),M=(e,t,n)=>t!==c.element||!t.isContentEditable,O=(e,t,n)=>{const{permanentAttributeName:o}=e;if(!o)return!0;const r=t.closest(`[${o}]`);if(!r&&t===c.element&&u(t)){const e={value:!0};return Array.from(n.attributes).forEach((n=>{e[n.name]||t.setAttribute(n.name,n.value)})),!1}return!r},k=[x,O,M],L=[];var R=Object.freeze({__proto__:null,shouldMorphCallbacks:k,didMorphCallbacks:L,shouldMorph:A,didMorph:C,verifyNotMutable:x,verifyNotContentEditable:M,verifyNotPermanent:O}),P={append:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.insertAdjacentHTML("beforeend",n||""),d(o)})),w(t,e)}))},graft:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{parent:n,focusSelector:o}=e,r=document.querySelector(n);r&&(r.appendChild(t),d(o))})),w(t,e)}))},innerHtml:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.innerHTML=n||"",d(o)})),w(t,e)}))},insertAdjacentHtml:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{html:n,position:o,focusSelector:r}=e;t.insertAdjacentHTML(o||"beforeend",n||""),d(r)})),w(t,e)}))},insertAdjacentText:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{text:n,position:o,focusSelector:r}=e;t.insertAdjacentText(o||"beforeend",n||""),d(r)})),w(t,e)}))},morph:e=>{f(e,(t=>{const{html:n}=e,r=document.createElement("template");r.innerHTML=String(n).trim(),e.content=r.content;const s=t.parentElement,a=Array.from(s.children).indexOf(t);g(t,e),y(e,(()=>{const{childrenOnly:n,focusSelector:s}=e;o.default(t,n?r.content:r.innerHTML,{childrenOnly:!!n,onBeforeElUpdated:A(e),onElUpdated:C(e)}),d(s)})),w(s.children[a],e)}))},outerHtml:e=>{f(e,(t=>{const n=t.parentElement,o=Array.from(n.children).indexOf(t);g(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.outerHTML=n||"",d(o)})),w(n.children[o],e)}))},prepend:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.insertAdjacentHTML("afterbegin",n||""),d(o)})),w(t,e)}))},remove:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{focusSelector:n}=e;t.remove(),d(n)})),w(document,e)}))},replace:e=>{f(e,(t=>{const n=t.parentElement,o=Array.from(n.children).indexOf(t);g(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.outerHTML=n||"",d(o)})),w(n.children[o],e)}))},textContent:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{text:n,focusSelector:o}=e;t.textContent=null!=n?n:"",d(o)})),w(t,e)}))},addCssClass:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n}=e;t.classList.add(...p(n||""))})),w(t,e)}))},removeAttribute:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n}=e;t.removeAttribute(n)})),w(t,e)}))},removeCssClass:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n}=e;t.classList.remove(...p(n))})),w(t,e)}))},setAttribute:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n,value:o}=e;t.setAttribute(n,o||"")})),w(t,e)}))},setDatasetProperty:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n,value:o}=e;t.dataset[n]=o||""})),w(t,e)}))},setProperty:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n,value:o}=e;n in t&&(t[n]=o||"")})),w(t,e)}))},setStyle:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n,value:o}=e;t.style[n]=o||""})),w(t,e)}))},setStyles:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{styles:n}=e;for(let[e,o]of Object.entries(n))t.style[e]=o||""})),w(t,e)}))},setValue:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{value:n}=e;t.value=n||""})),w(t,e)}))},dispatchEvent:e=>{f(e,(t=>{g(t,e),y(e,(()=>{const{name:n,detail:o}=e;m(t,n,o)})),w(t,e)}))},setMeta:e=>{g(document,e),y(e,(()=>{const{name:t,content:n}=e;let o=document.head.querySelector(`meta[name='${t}']`);o||(o=document.createElement("meta"),o.name=t,document.head.appendChild(o)),o.content=n})),w(document,e)},clearStorage:e=>{g(document,e),y(e,(()=>{const{type:t}=e;("session"===t?sessionStorage:localStorage).clear()})),w(document,e)},go:e=>{g(window,e),y(e,(()=>{const{delta:t}=e;history.go(t)})),w(window,e)},pushState:e=>{g(window,e),y(e,(()=>{const{state:t,title:n,url:o}=e;history.pushState(t||{},n||"",o)})),w(window,e)},redirectTo:e=>{g(window,e),y(e,(()=>{let{url:t,action:n}=e;n=n||"advance",window.Turbo&&window.Turbo.visit(t,{action:n}),window.Turbolinks&&window.Turbolinks.visit(t,{action:n}),window.Turbo||window.Turbolinks||(window.location.href=t)})),w(window,e)},reload:e=>{g(window,e),y(e,(()=>{window.location.reload()})),w(window,e)},removeStorageItem:e=>{g(document,e),y(e,(()=>{const{key:t,type:n}=e;("session"===n?sessionStorage:localStorage).removeItem(t)})),w(document,e)},replaceState:e=>{g(window,e),y(e,(()=>{const{state:t,title:n,url:o}=e;history.replaceState(t||{},n||"",o)})),w(window,e)},scrollIntoView:e=>{const{element:t}=e;g(t,e),y(e,(()=>{t.scrollIntoView(e)})),w(t,e)},setCookie:e=>{g(document,e),y(e,(()=>{const{cookie:t}=e;document.cookie=t||""})),w(document,e)},setFocus:e=>{const{element:t}=e;g(t,e),y(e,(()=>{d(t)})),w(t,e)},setStorageItem:e=>{g(document,e),y(e,(()=>{const{key:t,value:n,type:o}=e;("session"===o?sessionStorage:localStorage).setItem(t,n||"")})),w(document,e)},consoleLog:e=>{g(document,e),y(e,(()=>{const{message:t,level:n}=e;n&&["warn","info","error"].includes(n)?console[n](t||""):console.log(t||"")})),w(document,e)},consoleTable:e=>{g(document,e),y(e,(()=>{const{data:t,columns:n}=e;console.table(t,n||[])})),w(document,e)},notification:e=>{g(document,e),y(e,(()=>{const{title:t,options:n}=e;Notification.requestPermission().then((o=>{e.permission=o,"granted"===o&&new Notification(t||"",n)}))})),w(document,e)}};let q=P;const H=e=>{q={...q,...e}};var N={get all(){return q}};const U=(e,t={emitMissingElementWarnings:!0})=>{const n={};e.forEach((e=>{e.batch&&(n[e.batch]=n[e.batch]?++n[e.batch]:1)})),e.forEach((e=>{const o=e.operation;try{if(e.selector?e.element=e.xpath?h(e.selector):document[e.selectAll?"querySelectorAll":"querySelector"](e.selector):e.element=document,e.element||t.emitMissingElementWarnings){c.set(document.activeElement);const t=N.all[o];t?(t(e),e.batch&&0==--n[e.batch]&&m(document,"cable-ready:batch-complete",{batch:e.batch})):console.error(`CableReady couldn't find the "${o}" operation. Make sure you use the camelized form when calling an operation method.`)}}catch(t){e.element?(console.error(`CableReady detected an error in ${o||"operation"}: ${t.message}. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`),console.error(t)):console.warn(`CableReady ${o||"operation"} failed due to missing DOM element for selector: '${e.selector}'`)}}))};let _;const I=[25,50,75,100,200,250,500,800,1e3,2e3],$=async(e=0)=>{if(_)return _;if(e>=I.length)throw new Error("Couldn't obtain a Action Cable consumer within 5s");var t;return await(t=I[e],new Promise((e=>setTimeout(e,t)))),await $(e+1)};var j={setConsumer(e){_=e},get consumer(){return _},getConsumer:async()=>await $()};class F extends HTMLElement{disconnectedCallback(){this.channel&&this.channel.unsubscribe()}createSubscription(e,t,n){this.channel=e.subscriptions.create({channel:t,identifier:this.identifier},{received:n})}get preview(){return document.documentElement.hasAttribute("data-turbolinks-preview")||document.documentElement.hasAttribute("data-turbo-preview")}get identifier(){return this.getAttribute("identifier")}}class D extends F{async connectedCallback(){if(this.preview)return;const e=await j.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.performOperations):console.error("The `stream_from` helper cannot connect without an ActionCable consumer.\nPlease run `rails generate cable_ready:helpers` to fix this.")}performOperations(e){e.cableReady&&U(e.operations)}}class z extends F{constructor(){super();this.attachShadow({mode:"open"}).innerHTML="\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n"}async connectedCallback(){if(this.preview)return;this.update=E(this.update.bind(this),this.debounce);const e=await j.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.update):console.error("The `updates-for` helper cannot connect without an ActionCable consumer.\nPlease run `rails generate cable_ready:helpers` to fix this.")}async update(e){const t=Array.from(document.querySelectorAll(this.query),(e=>new X(e)));if(t[0].element!==this)return;c.set(document.activeElement),this.html={};const n=[...new Set(t.map((e=>e.url)))];await Promise.all(n.map((async e=>{if(!this.html.hasOwnProperty(e)){const t=await T(e,{"X-Cable-Ready":"update"});this.html[e]=await t.text()}}))),this.index={},t.forEach((t=>{this.index.hasOwnProperty(t.url)?this.index[t.url]++:this.index[t.url]=0,t.process(e,this.html,this.index)}))}get query(){return`updates-for[identifier="${this.identifier}"]`}get identifier(){return this.getAttribute("identifier")}get debounce(){return this.hasAttribute("debounce")?parseInt(this.getAttribute("debounce")):20}}class X{constructor(e){this.element=e}async process(e,t,n){if(!this.shouldUpdate(e))return;const r=n[this.url],s=document.createElement("template");this.element.setAttribute("updating","updating"),s.innerHTML=String(t[this.url]).trim(),await this.resolveTurboFrames(s.content);const a=s.content.querySelectorAll(this.query);if(a.length<=r)return void console.warn(`Update aborted due to insufficient number of elements. The offending url is ${this.url}.`);const i={element:this.element,html:a[r],permanentAttributeName:"data-ignore-updates"};m(this.element,"cable-ready:before-update",i),o.default(this.element,a[r],{childrenOnly:!0,onBeforeElUpdated:A(i),onElUpdated:e=>{this.element.removeAttribute("updating"),m(this.element,"cable-ready:after-update",i),d(i.focusSelector)}})}async resolveTurboFrames(e){const t=[...e.querySelectorAll('turbo-frame[src]:not([loading="lazy"])')];return Promise.all(t.map((t=>new Promise((async n=>{const o=await T(t.getAttribute("src"),{"Turbo-Frame":t.id,"X-Cable-Ready":"update"}),r=document.createElement("template");r.innerHTML=await o.text(),await this.resolveTurboFrames(r.content),e.querySelector(`turbo-frame#${t.id}`).innerHTML=String(r.content.querySelector(`turbo-frame#${t.id}`).innerHTML).trim(),n()})))))}shouldUpdate(e){return!this.ignoresInnerUpdates&&this.hasChangesSelectedForUpdate(e)}hasChangesSelectedForUpdate(e){const t=this.element.getAttribute("only");return!(t&&e.changed&&!t.split(" ").some((t=>e.changed.includes(t))))}get ignoresInnerUpdates(){return this.element.hasAttribute("ignore-inner-updates")&&this.element.hasAttribute("performing-inner-update")}get url(){return this.element.hasAttribute("url")?this.element.getAttribute("url"):location.href}get identifier(){return this.element.identifier}get query(){return this.element.query}}const V=e=>{const t=e&&e.parentElement.closest("updates-for");t&&(t.setAttribute("performing-inner-update",""),V(t))},W=e=>{const t=e&&e.parentElement.closest("updates-for");t&&(t.removeAttribute("performing-inner-update"),W(t))},Q={perform:U,performAsync:(e,t={emitMissingElementWarnings:!0})=>new Promise(((n,o)=>{try{n(U(e,t))}catch(e){o(e)}})),shouldMorphCallbacks:k,didMorphCallbacks:L,initialize:(e={})=>{const{consumer:t}=e;document.addEventListener("stimulus-reflex:before",(e=>{V(e.detail.element)})),document.addEventListener("stimulus-reflex:after",(e=>{setTimeout((()=>{W(e.detail.element)}))})),document.addEventListener("turbo:submit-start",(e=>{V(e.target)})),document.addEventListener("turbo:submit-end",(e=>{setTimeout((()=>{W(e.target)}))})),t?j.setConsumer(t):console.error("CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`."),customElements.get("stream-from")||customElements.define("stream-from",D),customElements.get("updates-for")||customElements.define("updates-for",z)},addOperation:(e,t)=>{const n={};n[e]=t,H(n)},addOperations:e=>{H(e)},version:r,cable:j,get DOMOperations(){return console.warn("DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`"),N.all},get operations(){return N.all},get consumer(){return j.consumer}};window.CableReady=Q,e.MorphCallbacks=R,e.StreamFromElement=D,e.SubscribingElement=F,e.UpdatesForElement=z,e.Utils=S,e.default=Q,Object.defineProperty(e,"__esModule",{value:!0})}));
|
2
|
-
//# sourceMappingURL=cable_ready.umd.min.js.map
|