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
@@ -15,6 +15,8 @@ require "stimulus_reflex/cable_ready_channels"
15
15
  require "stimulus_reflex/concern_enhancer"
16
16
  require "stimulus_reflex/configuration"
17
17
  require "stimulus_reflex/callbacks"
18
+ require "stimulus_reflex/html/document"
19
+ require "stimulus_reflex/html/document_fragment"
18
20
  require "stimulus_reflex/request_parameters"
19
21
  require "stimulus_reflex/reflex"
20
22
  require "stimulus_reflex/reflex_data"
@@ -0,0 +1,252 @@
1
+ # frozen_string_literal: true
2
+
3
+ include Rails.application.routes.url_helpers
4
+
5
+ SR_STEPS = {
6
+ "action_cable" => "Action Cable",
7
+ "webpacker" => "Install StimulusReflex using Webpacker",
8
+ "shakapacker" => "Install StimulusReflex using Shakapacker",
9
+ "npm_packages" => "StimulusReflex and CableReady and related npm packages",
10
+ "reflexes" => "Create app/reflexes and related files",
11
+ "importmap" => "Install StimulusReflex using importmaps",
12
+ "esbuild" => "Install StimulusReflex using esbuild",
13
+ "config" => "Client initialization",
14
+ "initializers" => "StimulusReflex and CableReady initializers",
15
+ "example" => "Create an Example Reflex",
16
+ "development" => "development environment configuration",
17
+ "spring" => "Disable spring gem. Spring has been removed from Rails 7",
18
+ "mrujs" => "Swap out Rails UJS for mrujs",
19
+ "broadcaster" => "Make CableReady available to channels, controllers, jobs and models",
20
+ "updatable" => "Include CableReady::Updatable in Active Record model classes",
21
+ "yarn" => "Resolve npm dependency changes",
22
+ "bundle" => "Resolve gem dependency changes and install configuration changes",
23
+ "vite" => "Install StimulusReflex using Vite",
24
+ "compression" => "Compress WebSocket traffic with gzip"
25
+ }
26
+
27
+ SR_BUNDLERS = {
28
+ "webpacker" => ["npm_packages", "webpacker", "config", "action_cable", "reflexes", "development", "initializers", "broadcaster", "updatable", "example", "spring", "yarn", "bundle"],
29
+ "esbuild" => ["npm_packages", "esbuild", "config", "action_cable", "reflexes", "development", "initializers", "broadcaster", "updatable", "example", "spring", "yarn", "bundle"],
30
+ "vite" => ["npm_packages", "vite", "config", "action_cable", "reflexes", "development", "initializers", "broadcaster", "updatable", "example", "spring", "yarn", "bundle"],
31
+ "shakapacker" => ["npm_packages", "shakapacker", "config", "action_cable", "reflexes", "development", "initializers", "broadcaster", "updatable", "example", "spring", "yarn", "bundle"],
32
+ "importmap" => ["config", "action_cable", "importmap", "reflexes", "development", "initializers", "broadcaster", "updatable", "example", "spring", "bundle"]
33
+ }
34
+
35
+ def run_install_template(template, force: false, trace: false)
36
+ puts "--- [#{template}] ----"
37
+
38
+ if Rails.root.join("tmp/stimulus_reflex_installer/halt").exist?
39
+ FileUtils.rm(Rails.root.join("tmp/stimulus_reflex_installer/halt"))
40
+ puts "StimulusReflex installation halted. Please fix the issues above and try again."
41
+ exit
42
+ end
43
+ if Rails.root.join("tmp/stimulus_reflex_installer/#{template}").exist? && !force
44
+ puts "👍 #{SR_STEPS[template]}"
45
+ return
46
+ end
47
+
48
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/#{template}.rb", __dir__)} SKIP_SANITY_CHECK=true #{"--trace" if trace}"
49
+
50
+ puts
51
+ end
52
+
53
+ namespace :stimulus_reflex do
54
+ desc "✨ Install StimulusReflex and CableReady ✨"
55
+ task :install do
56
+ FileUtils.mkdir_p(Rails.root.join("tmp/stimulus_reflex_installer/templates"))
57
+ FileUtils.mkdir_p(Rails.root.join("tmp/stimulus_reflex_installer/working"))
58
+ install_complete = Rails.root.join("tmp/stimulus_reflex_installer/complete")
59
+
60
+ bundler = nil
61
+ options = {}
62
+
63
+ ARGV.each do |arg|
64
+ # make sure we have a valid build tool specified, or proceed to automatic detection
65
+ if ["webpacker", "esbuild", "vite", "shakapacker", "importmap"].include?(arg)
66
+ bundler = arg
67
+ else
68
+ kv = arg.split("=")
69
+ if kv.length == 2
70
+ kv[1] = if kv[1] == "true"
71
+ true
72
+ else
73
+ (kv[1] == "false") ? false : kv[1]
74
+ end
75
+ options[kv[0]] = kv[1]
76
+ end
77
+ end
78
+ end
79
+
80
+ options_path = Rails.root.join("tmp/stimulus_reflex_installer/options")
81
+ options_path.write(options.to_yaml)
82
+
83
+ if install_complete.exist?
84
+ puts "✨ \e[38;5;220mStimulusReflex\e[0m and \e[38;5;220mCableReady\e[0m are already installed ✨"
85
+ puts
86
+ puts "To restart the installation process, run: \e[38;5;231mrails stimulus_reflex:install:restart\e[0m"
87
+ puts
88
+ puts "To get started, check out \e[4;97mhttps://docs.stimulusreflex.com/hello-world/quickstart\e[0m"
89
+ puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
90
+ puts
91
+ exit
92
+ end
93
+
94
+ # if there is an installation in progress, continue where we left off
95
+ cached_entrypoint = Rails.root.join("tmp/stimulus_reflex_installer/entrypoint")
96
+ if cached_entrypoint.exist?
97
+ entrypoint = File.read(cached_entrypoint)
98
+ puts "✨ Resuming \e[38;5;220mStimulusReflex\e[0m and \e[38;5;220mCableReady\e[0m installation ✨"
99
+ puts
100
+ puts "If you have any setup issues, please consult \e[4;97mhttps://docs.stimulusreflex.com/hello-world/setup\e[0m"
101
+ puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
102
+ puts
103
+ puts "Resuming installation into \e[1m#{entrypoint}\e[22m"
104
+ puts "Run \e[1;94mrails stimulus_reflex:install:restart\e[0m to restart the installation process"
105
+ puts
106
+ else
107
+ puts "✨ Installing \e[38;5;220mStimulusReflex\e[0m and \e[38;5;220mCableReady\e[0m ✨"
108
+ puts
109
+ puts "If you have any setup issues, please consult \e[4;97mhttps://docs.stimulusreflex.com/hello-world/setup\e[0m"
110
+ puts "or get help on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m. \e[38;5;196mWe are here for you.\e[0m 💙"
111
+ if Rails.root.join(".git").exist?
112
+ puts
113
+ puts "We recommend running \e[1;94mgit commit\e[0m before proceeding. A diff will be generated at the end."
114
+ end
115
+
116
+ if options.key? "entrypoint"
117
+ entrypoint = options["entrypoint"]
118
+ else
119
+ entrypoint = [
120
+ "app/javascript",
121
+ "app/frontend"
122
+ ].find { |path| File.exist?(Rails.root.join(path)) } || "app/javascript"
123
+
124
+ puts
125
+ puts "Where do JavaScript files live in your app? Our best guess is: \e[1m#{entrypoint}\e[22m 🤔"
126
+ puts "Press enter to accept this, or type a different path."
127
+ print "> "
128
+ input = $stdin.gets.chomp
129
+ entrypoint = input unless input.blank?
130
+ end
131
+ File.write(cached_entrypoint, entrypoint)
132
+ end
133
+
134
+ # verify their bundler before starting, unless they explicitly specified on CLI
135
+ if !bundler
136
+ # auto-detect build tool based on existing packages and configuration
137
+ if Rails.root.join("config/importmap.rb").exist?
138
+ bundler = "importmap"
139
+ elsif Rails.root.join("package.json").exist?
140
+ package_json = File.read(Rails.root.join("package.json"))
141
+ bundler = "webpacker" if package_json.include?('"@rails/webpacker":')
142
+ bundler = "esbuild" if package_json.include?('"esbuild":')
143
+ bundler = "vite" if package_json.include?('"vite":')
144
+ bundler = "shakapacker" if package_json.include?('"shakapacker":')
145
+ if !bundler
146
+ puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use StimulusReflex."
147
+ exit
148
+ end
149
+ else
150
+ puts "❌ You must be using a node-based bundler such as esbuild, webpacker, vite or shakapacker (package.json) or importmap (config/importmap.rb) to use StimulusReflex."
151
+ exit
152
+ end
153
+
154
+ puts
155
+ puts "It looks like you're using \e[1m#{bundler}\e[22m as your bundler. Is that correct? (Y/n)"
156
+ print "> "
157
+ input = $stdin.gets.chomp
158
+ if input.downcase == "n"
159
+ puts
160
+ puts "StimulusReflex installation supports: esbuild, webpacker, vite, shakapacker and importmap."
161
+ puts "Please run \e[1;94mrails stimulus_reflex:install [bundler]\e[0m to install StimulusReflex and CableReady."
162
+ exit
163
+ end
164
+ end
165
+
166
+ File.write("tmp/stimulus_reflex_installer/bundler", bundler)
167
+ FileUtils.touch("tmp/stimulus_reflex_installer/backups")
168
+ File.write("tmp/stimulus_reflex_installer/template_src", File.expand_path("../../generators/stimulus_reflex/templates/", __dir__))
169
+
170
+ `bin/spring stop` if defined?(Spring)
171
+
172
+ # do the things
173
+ SR_BUNDLERS[bundler].each do |template|
174
+ run_install_template(template, trace: !!options["trace"])
175
+ end
176
+
177
+ puts
178
+ puts "🎉 \e[1;92mStimulusReflex and CableReady have been successfully installed!\e[22m 🎉"
179
+ puts
180
+ puts "👉 \e[4;97mhttps://docs.stimulusreflex.com/hello-world/quickstart\e[0m"
181
+ puts
182
+ puts "Join over 2000 StimulusReflex developers on Discord: \e[4;97mhttps://discord.gg/stimulus-reflex\e[0m"
183
+ puts
184
+
185
+ backups = File.readlines("tmp/stimulus_reflex_installer/backups").map(&:chomp)
186
+
187
+ if backups.any?
188
+ puts "🙆 The following files were modified during installation:"
189
+ puts
190
+ backups.each { |backup| puts " #{backup}" }
191
+ puts
192
+ puts "Each of these files has been backed up with a .bak extension. Please review the changes carefully."
193
+ puts "If you're happy with the changes, you can delete the .bak files."
194
+ puts
195
+ end
196
+
197
+ if Rails.root.join(".git").exist?
198
+ system "git diff > tmp/stimulus_reflex_installer.diff"
199
+ puts "🏮 A diff of all changes has been saved to \e[1mtmp/stimulus_reflex_installer.diff\e[22m"
200
+ puts
201
+ end
202
+
203
+ if Rails.root.join("app/reflexes/example_reflex.rb").exist?
204
+ launch = Rails.root.join("bin/dev").exist? ? "bin/dev" : "rails s"
205
+ puts "🚀 Launch \e[1;94m#{launch}\e[0m to access the example at ⚡ \e[4;97mhttp://localhost:3000/example\e[0m ⚡"
206
+ puts "Once you're finished with the example, you can remove it with \e[1;94mrails destroy stimulus_reflex example\e[0m"
207
+ puts
208
+ end
209
+
210
+ FileUtils.touch(install_complete)
211
+ `pkill -f spring` if Rails.root.join("tmp/stimulus_reflex_installer/kill_spring").exist?
212
+ exit
213
+ end
214
+
215
+ namespace :install do
216
+ desc "Restart StimulusReflex and CableReady installation"
217
+ task :restart do
218
+ FileUtils.rm_rf Rails.root.join("tmp/stimulus_reflex_installer")
219
+ system "rails stimulus_reflex:install #{ARGV.join(" ")}"
220
+ exit
221
+ end
222
+
223
+ desc <<~DESC
224
+ Run specific StimulusReflex install steps
225
+
226
+ #{SR_STEPS.sort.map { |step, description| "#{step.ljust(20)} #{description}" }.join("\n")}
227
+ DESC
228
+ task :step do
229
+ def warning(step = nil, force_exit = true)
230
+ return if step.to_s.include?("=")
231
+ if step
232
+ puts "⚠️ #{step} is not a valid step. Valid steps are: #{SR_STEPS.keys.join(", ")}"
233
+ else
234
+ puts "❌ You must specify a step to re-run. Valid steps are: #{SR_STEPS.keys.join(", ")}"
235
+ puts "Example: \e[1;94mrails stimulus_reflex:install:step initializers\e[0m"
236
+ end
237
+ exit if force_exit
238
+ end
239
+
240
+ warning if ARGV.empty?
241
+
242
+ ARGV.each do |step|
243
+ SR_STEPS.include?(step) ? run_install_template(step, force: true) : warning(step, false)
244
+ end
245
+
246
+ run_install_template(:bundle, force: true)
247
+ run_install_template(:yarn, force: true)
248
+
249
+ exit
250
+ end
251
+ end
252
+ end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stimulus_reflex",
3
- "version": "3.5.0-pre9",
3
+ "version": "3.5.0-pre10",
4
4
  "description": "Build reactive applications with the Rails tooling you already know and love.",
5
5
  "keywords": [
6
6
  "ruby",
@@ -18,50 +18,56 @@
18
18
  "dom",
19
19
  "morphdom"
20
20
  ],
21
- "homepage": "https://docs.stimulusreflex.com/",
22
- "bugs": {
23
- "url": "https://github.com/stimulusreflex/stimulus_reflex/issues"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com:stimulusreflex/stimulus_reflex.git"
28
- },
21
+ "homepage": "https://docs.stimulusreflex.com",
22
+ "bugs": "https://github.com/stimulusreflex/stimulus_reflex/issues",
23
+ "repository": "https://github.com/stimulusreflex/stimulus_reflex",
29
24
  "license": "MIT",
30
25
  "author": "Nathan Hopkins <natehop@gmail.com>",
31
- "main": "./dist/stimulus_reflex.umd.min.js",
32
- "module": "./dist/stimulus_reflex.min.js",
26
+ "contributors": [
27
+ "Andrew Mason <andrewmcodes@protonmail.com>",
28
+ "Julian Rubisch <julian@julianrubisch.at>",
29
+ "Marco Roth <marco.roth@intergga.ch>",
30
+ "Nathan Hopkins <natehop@gmail.com>"
31
+ ],
32
+ "main": "./dist/stimulus_reflex.js",
33
+ "module": "./dist/stimulus_reflex.js",
34
+ "browser": "./dist/stimulus_reflex.js",
35
+ "import": "./dist/stimulus_reflex.js",
36
+ "unpkg": "./dist/stimulus_reflex.umd.js",
37
+ "umd": "./dist/stimulus_reflex.umd.js",
33
38
  "files": [
34
39
  "dist/*",
35
40
  "javascript/*"
36
41
  ],
37
42
  "scripts": {
38
- "lint": "yarn prettier-standard:check",
39
- "format": "yarn prettier-standard:format",
43
+ "lint": "yarn run format --check",
44
+ "format": "yarn run prettier-standard ./javascript/**/*.js rollup.config.mjs",
40
45
  "build": "yarn rollup -c",
41
46
  "build:watch": "yarn rollup -wc",
42
47
  "watch": "yarn build:watch",
43
- "prettier-standard:check": "yarn run prettier-standard --check ./javascript/**/*.js rollup.config.js",
44
- "prettier-standard:format": "yarn run prettier-standard ./javascript/**/*.js rollup.config.js",
45
- "test": "web-test-runner javascript/test/**/*.test.js"
48
+ "test": "web-test-runner javascript/test/**/*.test.js",
49
+ "docs:dev": "vitepress dev docs",
50
+ "docs:build": "vitepress build docs",
51
+ "docs:preview": "vitepress preview docs"
46
52
  },
47
53
  "peerDependencies": {
48
54
  "@hotwired/stimulus": ">= 3.0"
49
55
  },
50
56
  "dependencies": {
51
- "@hotwired/stimulus": ">= 3.0",
52
- "@rails/actioncable": ">= 6.0",
53
- "cable_ready": ">= 5.0.0-pre9"
57
+ "@hotwired/stimulus": ">= 3.0, < 4",
58
+ "@rails/actioncable": ">= 6.0, < 8",
59
+ "cable_ready": "5.0.0-pre10"
54
60
  },
55
61
  "devDependencies": {
56
- "@open-wc/testing": "^3.1.2",
57
- "@rollup/plugin-commonjs": "^21.0.3",
58
- "@rollup/plugin-json": "^4.1.0",
59
- "@rollup/plugin-node-resolve": "^13.1.3",
60
- "@web/dev-server-esbuild": "^0.3.0",
61
- "@web/dev-server-rollup": "^0.3.15",
62
- "@web/test-runner": "^0.13.27",
62
+ "@open-wc/testing": "^3.1.7",
63
+ "@rollup/plugin-json": "^6.0.0",
64
+ "@rollup/plugin-node-resolve": "^15.0.1",
65
+ "@rollup/plugin-terser": "^0.4.0",
66
+ "@web/dev-server-esbuild": "^0.3.3",
67
+ "@web/dev-server-rollup": "^0.3.21",
68
+ "@web/test-runner": "^0.15.0",
63
69
  "prettier-standard": "^16.4.1",
64
- "rollup": "^2.70.1",
65
- "rollup-plugin-terser": "^7.0.2"
70
+ "rollup": "^3.17.1",
71
+ "vitepress": "^1.0.0-alpha.47"
66
72
  }
67
73
  }
@@ -1,7 +1,6 @@
1
1
  import resolve from '@rollup/plugin-node-resolve'
2
- import commonjs from '@rollup/plugin-commonjs'
3
2
  import json from '@rollup/plugin-json'
4
- import { terser } from 'rollup-plugin-terser'
3
+ import terser from '@rollup/plugin-terser'
5
4
 
6
5
  const pretty = () => {
7
6
  return terser({
@@ -31,36 +30,38 @@ const umdConfig = {
31
30
  format: 'umd',
32
31
  exports: 'named',
33
32
  globals: {
33
+ '@rails/actioncable': 'ActionCable',
34
34
  morphdom: 'morphdom',
35
35
  cable_ready: 'CableReady',
36
36
  '@hotwired/stimulus': 'Stimulus'
37
37
  }
38
38
  }
39
39
 
40
+ const baseName = 'stimulus_reflex'
40
41
  const distFolders = ['dist', 'app/assets/javascripts']
41
42
 
42
43
  const output = distFolders
43
44
  .map(distFolder => [
44
45
  {
45
46
  ...umdConfig,
46
- file: `${distFolder}/stimulus_reflex.umd.js`,
47
+ file: `${distFolder}/${baseName}.umd.js`,
47
48
  plugins: [pretty()]
48
49
  },
49
50
  {
50
51
  ...umdConfig,
51
- file: `${distFolder}/stimulus_reflex.umd.min.js`,
52
+ file: `${distFolder}/${baseName}.umd.min.js`,
52
53
  sourcemap: true,
53
54
  plugins: [pretty()]
54
55
  },
55
56
  {
56
57
  ...esConfig,
57
- file: `${distFolder}/stimulus_reflex.js`,
58
+ file: `${distFolder}/${baseName}.js`,
58
59
  format: 'es',
59
60
  plugins: [pretty()]
60
61
  },
61
62
  {
62
63
  ...esConfig,
63
- file: `${distFolder}/stimulus_reflex.min.js`,
64
+ file: `${distFolder}/${baseName}.min.js`,
64
65
  sourcemap: true,
65
66
  plugins: [minify()]
66
67
  }
@@ -77,7 +78,7 @@ export default [
77
78
  ],
78
79
  input: 'javascript/index.js',
79
80
  output,
80
- plugins: [commonjs(), resolve(), json()],
81
+ plugins: [resolve(), json()],
81
82
  watch: {
82
83
  include: 'javascript/**'
83
84
  }
@@ -30,34 +30,31 @@ Gem::Specification.new do |gem|
30
30
  }
31
31
 
32
32
  gem.files = Dir[
33
- "lib/**/*.rb",
33
+ "lib/**/*.{rb,rake,tt}",
34
34
  "app/**/*.rb",
35
35
  "app/assets/javascripts/*",
36
36
  "bin/*",
37
37
  "[A-Z]*"
38
38
  ]
39
39
 
40
- gem.test_files = Dir["test/**/*.rb"]
41
-
42
40
  gem.required_ruby_version = ">= 2.7.0"
43
41
 
44
- rails_version = ">= 5.2"
45
- gem.add_dependency "actioncable", rails_version
46
- gem.add_dependency "actionpack", rails_version
47
- gem.add_dependency "actionview", rails_version
48
- gem.add_dependency "activesupport", rails_version
49
- gem.add_dependency "railties", rails_version
42
+ rails_version = [">= 5.2", "< 8"]
43
+ gem.add_dependency "actioncable", *rails_version
44
+ gem.add_dependency "actionpack", *rails_version
45
+ gem.add_dependency "actionview", *rails_version
46
+ gem.add_dependency "activesupport", *rails_version
47
+ gem.add_dependency "railties", *rails_version
50
48
 
51
- gem.add_dependency "cable_ready", ">= 5.0.0.pre9"
52
- gem.add_dependency "nokogiri"
53
- gem.add_dependency "rack"
54
- gem.add_dependency "redis"
49
+ gem.add_dependency "cable_ready", ">= 5.0.0.pre10"
50
+ gem.add_dependency "nokogiri", "~> 1.0"
51
+ gem.add_dependency "rack", "~> 2.0"
52
+ gem.add_dependency "redis", ">= 4.0", "< 6.0"
55
53
 
56
54
  gem.add_development_dependency "bundler", "~> 2.0"
57
- gem.add_development_dependency "mocha"
58
- gem.add_development_dependency "pry"
59
- gem.add_development_dependency "pry-nav"
60
- gem.add_development_dependency "rails", rails_version
61
- gem.add_development_dependency "rake"
62
- gem.add_development_dependency "standardrb", "~> 1.0"
55
+ gem.add_development_dependency "magic_frozen_string_literal", "~> 1.2"
56
+ gem.add_development_dependency "mocha", "~> 1.13"
57
+ gem.add_development_dependency "rails", *rails_version
58
+ gem.add_development_dependency "rake", "~> 13.0"
59
+ gem.add_development_dependency "standard", "~> 1.24"
63
60
  end