stimulus_reflex 3.5.0.pre8 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1218
- data/Gemfile +0 -1
- data/Gemfile.lock +145 -193
- data/README.md +48 -20
- data/Rakefile +0 -8
- data/app/assets/javascripts/stimulus_reflex.js +1174 -0
- data/app/assets/javascripts/stimulus_reflex.min.js +2 -0
- data/app/assets/javascripts/stimulus_reflex.min.js.map +1 -0
- data/app/assets/javascripts/stimulus_reflex.umd.js +1064 -0
- data/app/assets/javascripts/stimulus_reflex.umd.min.js +1065 -0
- data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +1 -0
- data/app/channels/stimulus_reflex/channel.rb +28 -7
- data/bin/console +0 -2
- data/bin/standardize +2 -1
- data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +72 -7
- data/lib/generators/stimulus_reflex/templates/app/controllers/examples_controller.rb.tt +9 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/consumer.js.tt +6 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.esbuild.tt +4 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt +2 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.shakapacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.vite.tt +1 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.webpacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +4 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +2 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt +9 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +114 -74
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +11 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +49 -35
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.esbuild.tt +7 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.shakapacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.vite.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt +38 -7
- data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +10 -2
- data/lib/generators/stimulus_reflex/templates/app/views/examples/show.html.erb.tt +207 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +22 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +18 -13
- data/lib/generators/stimulus_reflex/templates/esbuild.config.mjs.tt +94 -0
- data/lib/install/action_cable.rb +155 -0
- data/lib/install/broadcaster.rb +90 -0
- data/lib/install/bundle.rb +56 -0
- data/lib/install/compression.rb +41 -0
- data/lib/install/config.rb +87 -0
- data/lib/install/development.rb +110 -0
- data/lib/install/esbuild.rb +114 -0
- data/lib/install/example.rb +22 -0
- data/lib/install/importmap.rb +133 -0
- data/lib/install/initializers.rb +25 -0
- data/lib/install/mrujs.rb +133 -0
- data/lib/install/npm_packages.rb +25 -0
- data/lib/install/reflexes.rb +25 -0
- data/lib/install/shakapacker.rb +64 -0
- data/lib/install/spring.rb +54 -0
- data/lib/install/updatable.rb +34 -0
- data/lib/install/vite.rb +64 -0
- data/lib/install/webpacker.rb +90 -0
- data/lib/install/yarn.rb +55 -0
- data/lib/stimulus_reflex/broadcasters/broadcaster.rb +15 -8
- data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +7 -8
- data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +10 -10
- data/lib/stimulus_reflex/broadcasters/update.rb +3 -0
- data/lib/stimulus_reflex/cable_readiness.rb +29 -0
- data/lib/stimulus_reflex/cable_ready_channels.rb +5 -5
- data/lib/stimulus_reflex/callbacks.rb +17 -1
- data/lib/stimulus_reflex/concern_enhancer.rb +6 -4
- data/lib/stimulus_reflex/configuration.rb +12 -2
- data/lib/stimulus_reflex/dataset.rb +11 -1
- data/lib/stimulus_reflex/engine.rb +40 -0
- data/lib/stimulus_reflex/html/document.rb +59 -0
- data/lib/stimulus_reflex/html/document_fragment.rb +13 -0
- data/lib/stimulus_reflex/importmap.rb +7 -0
- data/lib/stimulus_reflex/installer.rb +274 -0
- data/lib/stimulus_reflex/open_struct_fix.rb +31 -0
- data/lib/stimulus_reflex/reflex.rb +32 -25
- data/lib/stimulus_reflex/reflex_data.rb +18 -2
- data/lib/stimulus_reflex/reflex_factory.rb +6 -3
- data/lib/stimulus_reflex/request_parameters.rb +2 -0
- data/lib/stimulus_reflex/utils/logger.rb +12 -0
- data/lib/stimulus_reflex/utils/sanity_checker.rb +8 -106
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/stimulus_reflex.rb +4 -6
- data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +252 -0
- data/package.json +73 -0
- data/rollup.config.mjs +86 -0
- data/stimulus_reflex.gemspec +60 -0
- data/web-test-runner.config.mjs +12 -0
- data/yarn.lock +5098 -0
- metadata +191 -78
- data/LATEST +0 -1
- data/lib/generators/USAGE +0 -14
- data/lib/generators/stimulus_reflex/initializer_generator.rb +0 -14
- data/lib/tasks/stimulus_reflex/install.rake +0 -116
- data/test/broadcasters/broadcaster_test.rb +0 -11
- data/test/broadcasters/broadcaster_test_case.rb +0 -39
- data/test/broadcasters/nothing_broadcaster_test.rb +0 -30
- data/test/broadcasters/page_broadcaster_test.rb +0 -77
- data/test/broadcasters/selector_broadcaster_test.rb +0 -167
- data/test/callbacks_test.rb +0 -652
- data/test/concern_enhancer_test.rb +0 -54
- data/test/element_test.rb +0 -254
- data/test/generators/stimulus_reflex_generator_test.rb +0 -58
- data/test/reflex_test.rb +0 -43
- data/test/test_helper.rb +0 -71
- data/test/tmp/app/reflexes/application_reflex.rb +0 -19
- data/test/tmp/app/reflexes/demo_reflex.rb +0 -35
@@ -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
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
{
|
2
|
+
"name": "stimulus_reflex",
|
3
|
+
"version": "3.5.0-pre10",
|
4
|
+
"description": "Build reactive applications with the Rails tooling you already know and love.",
|
5
|
+
"keywords": [
|
6
|
+
"ruby",
|
7
|
+
"rails",
|
8
|
+
"websockets",
|
9
|
+
"actioncable",
|
10
|
+
"turbolinks",
|
11
|
+
"reactive",
|
12
|
+
"cable",
|
13
|
+
"ujs",
|
14
|
+
"ssr",
|
15
|
+
"stimulus",
|
16
|
+
"reflex",
|
17
|
+
"stimulus_reflex",
|
18
|
+
"dom",
|
19
|
+
"morphdom"
|
20
|
+
],
|
21
|
+
"homepage": "https://docs.stimulusreflex.com",
|
22
|
+
"bugs": "https://github.com/stimulusreflex/stimulus_reflex/issues",
|
23
|
+
"repository": "https://github.com/stimulusreflex/stimulus_reflex",
|
24
|
+
"license": "MIT",
|
25
|
+
"author": "Nathan Hopkins <natehop@gmail.com>",
|
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",
|
38
|
+
"files": [
|
39
|
+
"dist/*",
|
40
|
+
"javascript/*"
|
41
|
+
],
|
42
|
+
"scripts": {
|
43
|
+
"lint": "yarn run format --check",
|
44
|
+
"format": "yarn run prettier-standard ./javascript/**/*.js rollup.config.mjs",
|
45
|
+
"build": "yarn rollup -c",
|
46
|
+
"build:watch": "yarn rollup -wc",
|
47
|
+
"watch": "yarn build:watch",
|
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"
|
52
|
+
},
|
53
|
+
"peerDependencies": {
|
54
|
+
"@hotwired/stimulus": ">= 3.0"
|
55
|
+
},
|
56
|
+
"dependencies": {
|
57
|
+
"@hotwired/stimulus": ">= 3.0, < 4",
|
58
|
+
"@rails/actioncable": ">= 6.0, < 8",
|
59
|
+
"cable_ready": "5.0.0-pre10"
|
60
|
+
},
|
61
|
+
"devDependencies": {
|
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",
|
69
|
+
"prettier-standard": "^16.4.1",
|
70
|
+
"rollup": "^3.17.1",
|
71
|
+
"vitepress": "^1.0.0-alpha.47"
|
72
|
+
}
|
73
|
+
}
|
data/rollup.config.mjs
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve'
|
2
|
+
import json from '@rollup/plugin-json'
|
3
|
+
import terser from '@rollup/plugin-terser'
|
4
|
+
|
5
|
+
const pretty = () => {
|
6
|
+
return terser({
|
7
|
+
mangle: false,
|
8
|
+
compress: false,
|
9
|
+
format: {
|
10
|
+
beautify: true,
|
11
|
+
indent_level: 2
|
12
|
+
}
|
13
|
+
})
|
14
|
+
}
|
15
|
+
|
16
|
+
const minify = () => {
|
17
|
+
return terser({
|
18
|
+
mangle: true,
|
19
|
+
compress: true
|
20
|
+
})
|
21
|
+
}
|
22
|
+
|
23
|
+
const esConfig = {
|
24
|
+
format: 'es',
|
25
|
+
inlineDynamicImports: true
|
26
|
+
}
|
27
|
+
|
28
|
+
const umdConfig = {
|
29
|
+
name: 'StimulusReflex',
|
30
|
+
format: 'umd',
|
31
|
+
exports: 'named',
|
32
|
+
globals: {
|
33
|
+
'@rails/actioncable': 'ActionCable',
|
34
|
+
morphdom: 'morphdom',
|
35
|
+
cable_ready: 'CableReady',
|
36
|
+
'@hotwired/stimulus': 'Stimulus'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
const baseName = 'stimulus_reflex'
|
41
|
+
const distFolders = ['dist', 'app/assets/javascripts']
|
42
|
+
|
43
|
+
const output = distFolders
|
44
|
+
.map(distFolder => [
|
45
|
+
{
|
46
|
+
...umdConfig,
|
47
|
+
file: `${distFolder}/${baseName}.umd.js`,
|
48
|
+
plugins: [pretty()]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
...umdConfig,
|
52
|
+
file: `${distFolder}/${baseName}.umd.min.js`,
|
53
|
+
sourcemap: true,
|
54
|
+
plugins: [pretty()]
|
55
|
+
},
|
56
|
+
{
|
57
|
+
...esConfig,
|
58
|
+
file: `${distFolder}/${baseName}.js`,
|
59
|
+
format: 'es',
|
60
|
+
plugins: [pretty()]
|
61
|
+
},
|
62
|
+
{
|
63
|
+
...esConfig,
|
64
|
+
file: `${distFolder}/${baseName}.min.js`,
|
65
|
+
sourcemap: true,
|
66
|
+
plugins: [minify()]
|
67
|
+
}
|
68
|
+
])
|
69
|
+
.flat()
|
70
|
+
|
71
|
+
export default [
|
72
|
+
{
|
73
|
+
external: [
|
74
|
+
'morphdom',
|
75
|
+
'@hotwired/stimulus',
|
76
|
+
'cable_ready',
|
77
|
+
'@rails/actioncable'
|
78
|
+
],
|
79
|
+
input: 'javascript/index.js',
|
80
|
+
output,
|
81
|
+
plugins: [resolve(), json()],
|
82
|
+
watch: {
|
83
|
+
include: 'javascript/**'
|
84
|
+
}
|
85
|
+
}
|
86
|
+
]
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("lib/stimulus_reflex/version", __dir__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "stimulus_reflex"
|
7
|
+
gem.license = "MIT"
|
8
|
+
gem.version = StimulusReflex::VERSION
|
9
|
+
gem.authors = ["Nathan Hopkins"]
|
10
|
+
gem.email = ["natehop@gmail.com"]
|
11
|
+
gem.homepage = "https://github.com/stimulusreflex/stimulus_reflex"
|
12
|
+
gem.summary = "Build reactive applications with the Rails tooling you already know and love."
|
13
|
+
gem.post_install_message = <<~MESSAGE
|
14
|
+
Finish installation by running:
|
15
|
+
|
16
|
+
rake stimulus_reflex:install
|
17
|
+
|
18
|
+
Get support for StimulusReflex and CableReady on Discord:
|
19
|
+
|
20
|
+
https://discord.gg/stimulus-reflex
|
21
|
+
|
22
|
+
MESSAGE
|
23
|
+
|
24
|
+
gem.metadata = {
|
25
|
+
"bug_tracker_uri" => "https://github.com/stimulusreflex/stimulus_reflex/issues",
|
26
|
+
"changelog_uri" => "https://github.com/stimulusreflex/stimulus_reflex/CHANGELOG.md",
|
27
|
+
"documentation_uri" => "https://docs.stimulusreflex.com",
|
28
|
+
"homepage_uri" => gem.homepage,
|
29
|
+
"source_code_uri" => gem.homepage
|
30
|
+
}
|
31
|
+
|
32
|
+
gem.files = Dir[
|
33
|
+
"lib/**/*.{rb,rake,tt}",
|
34
|
+
"app/**/*.rb",
|
35
|
+
"app/assets/javascripts/*",
|
36
|
+
"bin/*",
|
37
|
+
"[A-Z]*"
|
38
|
+
]
|
39
|
+
|
40
|
+
gem.required_ruby_version = ">= 2.7.0"
|
41
|
+
|
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
|
48
|
+
|
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"
|
53
|
+
|
54
|
+
gem.add_development_dependency "bundler", "~> 2.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"
|
60
|
+
end
|