stimulus_reflex 3.5.0.pre9 → 3.5.0.pre10

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.

Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/Gemfile.lock +122 -127
  4. data/README.md +10 -16
  5. data/app/assets/javascripts/stimulus_reflex.js +710 -505
  6. data/app/assets/javascripts/stimulus_reflex.min.js +1 -1
  7. data/app/assets/javascripts/stimulus_reflex.min.js.map +1 -1
  8. data/app/assets/javascripts/stimulus_reflex.umd.js +660 -500
  9. data/app/assets/javascripts/stimulus_reflex.umd.min.js +660 -500
  10. data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +1 -1
  11. data/app/channels/stimulus_reflex/channel.rb +9 -7
  12. data/bin/console +0 -2
  13. data/bin/standardize +2 -1
  14. data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +72 -7
  15. data/lib/generators/stimulus_reflex/templates/app/controllers/examples_controller.rb.tt +9 -0
  16. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/consumer.js.tt +6 -0
  17. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.esbuild.tt +4 -0
  18. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt +2 -0
  19. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.shakapacker.tt +5 -0
  20. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.vite.tt +1 -0
  21. data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.webpacker.tt +5 -0
  22. data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +4 -0
  23. data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +2 -0
  24. data/lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt +9 -0
  25. data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
  26. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +141 -0
  27. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +11 -0
  28. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +74 -0
  29. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.esbuild.tt +7 -0
  30. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +5 -0
  31. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.shakapacker.tt +5 -0
  32. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.vite.tt +5 -0
  33. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt +5 -0
  34. data/{test/tmp/app/reflexes/user_reflex.rb → lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt} +38 -9
  35. data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +27 -0
  36. data/lib/generators/stimulus_reflex/templates/app/views/examples/show.html.erb.tt +207 -0
  37. data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +22 -0
  38. data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +18 -13
  39. data/lib/generators/stimulus_reflex/templates/esbuild.config.mjs.tt +94 -0
  40. data/lib/install/action_cable.rb +155 -0
  41. data/lib/install/broadcaster.rb +90 -0
  42. data/lib/install/bundle.rb +56 -0
  43. data/lib/install/compression.rb +41 -0
  44. data/lib/install/config.rb +87 -0
  45. data/lib/install/development.rb +110 -0
  46. data/lib/install/esbuild.rb +114 -0
  47. data/lib/install/example.rb +22 -0
  48. data/lib/install/importmap.rb +133 -0
  49. data/lib/install/initializers.rb +25 -0
  50. data/lib/install/mrujs.rb +133 -0
  51. data/lib/install/npm_packages.rb +25 -0
  52. data/lib/install/reflexes.rb +25 -0
  53. data/lib/install/shakapacker.rb +64 -0
  54. data/lib/install/spring.rb +54 -0
  55. data/lib/install/updatable.rb +34 -0
  56. data/lib/install/vite.rb +64 -0
  57. data/lib/install/webpacker.rb +90 -0
  58. data/lib/install/yarn.rb +55 -0
  59. data/lib/stimulus_reflex/broadcasters/broadcaster.rb +15 -8
  60. data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +7 -8
  61. data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +10 -10
  62. data/lib/stimulus_reflex/broadcasters/update.rb +3 -0
  63. data/lib/stimulus_reflex/cable_readiness.rb +29 -0
  64. data/lib/stimulus_reflex/cable_ready_channels.rb +5 -5
  65. data/lib/stimulus_reflex/callbacks.rb +17 -1
  66. data/lib/stimulus_reflex/concern_enhancer.rb +6 -4
  67. data/lib/stimulus_reflex/configuration.rb +12 -2
  68. data/lib/stimulus_reflex/dataset.rb +11 -1
  69. data/lib/stimulus_reflex/engine.rb +20 -9
  70. data/lib/stimulus_reflex/html/document.rb +59 -0
  71. data/lib/stimulus_reflex/html/document_fragment.rb +13 -0
  72. data/lib/stimulus_reflex/importmap.rb +3 -0
  73. data/lib/stimulus_reflex/installer.rb +274 -0
  74. data/lib/stimulus_reflex/open_struct_fix.rb +2 -0
  75. data/lib/stimulus_reflex/reflex.rb +25 -25
  76. data/lib/stimulus_reflex/reflex_data.rb +15 -3
  77. data/lib/stimulus_reflex/reflex_factory.rb +4 -2
  78. data/lib/stimulus_reflex/request_parameters.rb +2 -0
  79. data/lib/stimulus_reflex/utils/logger.rb +10 -0
  80. data/lib/stimulus_reflex/utils/sanity_checker.rb +8 -48
  81. data/lib/stimulus_reflex/version.rb +1 -1
  82. data/lib/stimulus_reflex.rb +2 -0
  83. data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +252 -0
  84. data/package.json +34 -28
  85. data/{rollup.config.js → rollup.config.mjs} +8 -7
  86. data/stimulus_reflex.gemspec +16 -19
  87. data/yarn.lock +1320 -742
  88. metadata +124 -77
  89. data/LATEST +0 -1
  90. data/lib/generators/stimulus_reflex/initializer_generator.rb +0 -14
  91. data/test/broadcasters/broadcaster_test.rb +0 -11
  92. data/test/broadcasters/broadcaster_test_case.rb +0 -39
  93. data/test/broadcasters/nothing_broadcaster_test.rb +0 -31
  94. data/test/broadcasters/page_broadcaster_test.rb +0 -79
  95. data/test/broadcasters/selector_broadcaster_test.rb +0 -173
  96. data/test/callbacks_test.rb +0 -652
  97. data/test/concern_enhancer_test.rb +0 -54
  98. data/test/element_test.rb +0 -254
  99. data/test/generators/stimulus_reflex_generator_test.rb +0 -58
  100. data/test/reflex_test.rb +0 -43
  101. data/test/test_helper.rb +0 -71
  102. data/test/tmp/app/reflexes/application_reflex.rb +0 -12
  103. data/yarn-error.log +0 -4964
@@ -1,173 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "broadcaster_test_case"
4
-
5
- module StimulusReflex
6
- class SelectorBroadcasterTest < StimulusReflex::BroadcasterTestCase
7
- test "morphs the contents of an element if the selector(s) are present in both original and morphed html fragments" do
8
- broadcaster = StimulusReflex::SelectorBroadcaster.new(@reflex)
9
- broadcaster.append_morph("#foo", '<div id="foo"><div>bar</div><div>baz</div></div>')
10
-
11
- expected = {
12
- "cableReady" => true,
13
- "operations" => [
14
- {
15
- "selector" => "#foo",
16
- "html" => "<div>bar</div><div>baz</div>",
17
- "payload" => {},
18
- "childrenOnly" => true,
19
- "permanentAttributeName" => nil,
20
- "stimulusReflex" => {
21
- "some" => "data",
22
- "morph" => "selector"
23
- },
24
- "reflexId" => "666",
25
- "operation" => "morph"
26
- }
27
- ],
28
- "version" => CableReady::VERSION
29
- }
30
-
31
- assert_broadcast_on @reflex.stream_name, expected do
32
- broadcaster.broadcast nil, some: :data
33
- end
34
- end
35
-
36
- test "replaces the contents of an element and ignores permanent-attributes if the selector(s) aren't present in the replacing html fragment" do
37
- broadcaster = StimulusReflex::SelectorBroadcaster.new(@reflex)
38
- broadcaster.append_morph("#foo", '<div id="baz"><span>bar</span></div>')
39
-
40
- expected = {
41
- "cableReady" => true,
42
- "operations" => [
43
- {
44
- "selector" => "#foo",
45
- "html" => '<div id="baz"><span>bar</span></div>',
46
- "payload" => {},
47
- "stimulusReflex" => {
48
- "some" => "data",
49
- "morph" => "selector"
50
- },
51
- "reflexId" => "666",
52
- "operation" => "innerHtml"
53
- }
54
- ],
55
- "version" => CableReady::VERSION
56
- }
57
-
58
- assert_broadcast_on @reflex.stream_name, expected do
59
- broadcaster.broadcast nil, some: :data
60
- end
61
- end
62
-
63
- test "morphs the contents of an element to an empty string if no content specified" do
64
- broadcaster = StimulusReflex::SelectorBroadcaster.new(@reflex)
65
- broadcaster.append_morph("#foo", nil)
66
-
67
- expected = {
68
- "cableReady" => true,
69
- "operations" => [
70
- {
71
- "selector" => "#foo",
72
- "html" => "",
73
- "payload" => {},
74
- "stimulusReflex" => {
75
- "some" => "data",
76
- "morph" => "selector"
77
- },
78
- "reflexId" => "666",
79
- "operation" => "innerHtml"
80
- }
81
- ],
82
- "version" => CableReady::VERSION
83
- }
84
-
85
- assert_broadcast_on @reflex.stream_name, expected do
86
- broadcaster.broadcast nil, some: :data
87
- end
88
- end
89
-
90
- test "morphs the contents of an element to an empty string if empty specified" do
91
- broadcaster = StimulusReflex::SelectorBroadcaster.new(@reflex)
92
- broadcaster.append_morph("#foo", "")
93
-
94
- expected = {
95
- "cableReady" => true,
96
- "operations" => [
97
- {
98
- "selector" => "#foo",
99
- "html" => "",
100
- "payload" => {},
101
- "stimulusReflex" => {
102
- "some" => "data",
103
- "morph" => "selector"
104
- },
105
- "reflexId" => "666",
106
- "operation" => "innerHtml"
107
- }
108
- ],
109
- "version" => CableReady::VERSION
110
- }
111
-
112
- assert_broadcast_on @reflex.stream_name, expected do
113
- broadcaster.broadcast nil, some: :data
114
- end
115
- end
116
-
117
- test "morphs the contents of an element to an empty string if no content specified, hash form" do
118
- broadcaster = StimulusReflex::SelectorBroadcaster.new(@reflex)
119
- broadcaster.append_morph({"#foo": nil}, nil)
120
-
121
- expected = {
122
- "cableReady" => true,
123
- "operations" => [
124
- {
125
- "selector" => "#foo",
126
- "html" => "",
127
- "payload" => {},
128
- "stimulusReflex" => {
129
- "some" => "data",
130
- "morph" => "selector"
131
- },
132
- "reflexId" => "666",
133
- "operation" => "innerHtml"
134
- }
135
- ],
136
- "version" => CableReady::VERSION
137
- }
138
-
139
- assert_broadcast_on @reflex.stream_name, expected do
140
- broadcaster.broadcast nil, some: :data
141
- end
142
- end
143
-
144
- test "morphs the contents of an element to specified HTML, hash form" do
145
- broadcaster = StimulusReflex::SelectorBroadcaster.new(@reflex)
146
- broadcaster.append_morph({"#foo": '<div id="foo"><div>bar</div><div>baz</div></div>'}, nil)
147
-
148
- expected = {
149
- "cableReady" => true,
150
- "operations" => [
151
- {
152
- "selector" => "#foo",
153
- "html" => "<div>bar</div><div>baz</div>",
154
- "payload" => {},
155
- "childrenOnly" => true,
156
- "permanentAttributeName" => nil,
157
- "stimulusReflex" => {
158
- "some" => "data",
159
- "morph" => "selector"
160
- },
161
- "reflexId" => "666",
162
- "operation" => "morph"
163
- }
164
- ],
165
- "version" => CableReady::VERSION
166
- }
167
-
168
- assert_broadcast_on @reflex.stream_name, expected do
169
- broadcaster.broadcast nil, some: :data
170
- end
171
- end
172
- end
173
- end