stimulus_reflex 3.5.0.pre10 → 3.5.0.rc2

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +10 -10
  3. data/README.md +3 -3
  4. data/app/assets/javascripts/stimulus_reflex.js +319 -23
  5. data/app/assets/javascripts/stimulus_reflex.umd.js +316 -25
  6. data/app/channels/stimulus_reflex/channel.rb +1 -18
  7. data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +4 -10
  8. data/lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt +1 -1
  9. data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +1 -1
  10. data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +5 -0
  11. data/lib/install/development.rb +2 -2
  12. data/lib/install/importmap.rb +3 -3
  13. data/lib/stimulus_reflex/cable_ready_channels.rb +1 -0
  14. data/lib/stimulus_reflex/engine.rb +0 -4
  15. data/lib/stimulus_reflex/importmap.rb +3 -3
  16. data/lib/stimulus_reflex/installer.rb +2 -2
  17. data/lib/stimulus_reflex/reflex.rb +17 -8
  18. data/lib/stimulus_reflex/reflex_data.rb +6 -2
  19. data/lib/stimulus_reflex/reflex_factory.rb +2 -1
  20. data/lib/stimulus_reflex/version.rb +1 -1
  21. data/lib/stimulus_reflex/version_checker.rb +54 -0
  22. data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +0 -2
  23. data/package.json +10 -8
  24. data/rollup.config.mjs +0 -19
  25. data/stimulus_reflex.gemspec +2 -2
  26. data/yarn.lock +173 -168
  27. metadata +15 -12
  28. data/app/assets/javascripts/stimulus_reflex.min.js +0 -2
  29. data/app/assets/javascripts/stimulus_reflex.min.js.map +0 -1
  30. data/app/assets/javascripts/stimulus_reflex.umd.min.js +0 -1065
  31. data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +0 -1
@@ -52,7 +52,7 @@ class StimulusReflex::ReflexData
52
52
  end
53
53
 
54
54
  def params
55
- form_params.merge(url_params)
55
+ form_params.deep_merge(url_params)
56
56
  end
57
57
 
58
58
  def form_params
@@ -85,8 +85,12 @@ class StimulusReflex::ReflexData
85
85
  data["reflexController"]
86
86
  end
87
87
 
88
+ def npm_version
89
+ data["version"].to_s
90
+ end
91
+
88
92
  def version
89
- data["version"].to_s.gsub("-pre", ".pre")
93
+ data["version"].to_s.gsub("-pre", ".pre").gsub("-rc", ".rc")
90
94
  end
91
95
 
92
96
  private
@@ -20,7 +20,8 @@ class StimulusReflex::ReflexFactory
20
20
  reflex_controller: reflex_data.reflex_controller,
21
21
  permanent_attribute_name: reflex_data.permanent_attribute_name,
22
22
  suppress_logging: reflex_data.suppress_logging,
23
- version: reflex_data.version
23
+ version: reflex_data.version,
24
+ npm_version: reflex_data.npm_version
24
25
  })
25
26
  end
26
27
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusReflex
4
- VERSION = "3.5.0.pre10"
4
+ VERSION = "3.5.0.rc2"
5
5
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StimulusReflex
4
+ class VersionMismatchError < StandardError
5
+ end
6
+
7
+ module VersionChecker
8
+ def check_version!
9
+ return if StimulusReflex.config.on_failed_sanity_checks == :ignore
10
+ return if version == StimulusReflex::VERSION
11
+
12
+ level = (StimulusReflex.config.on_failed_sanity_checks == :exit) ? "error" : "warn"
13
+ reason = (level == "error") ? "failed to execute your reflex action due to" : "noticed"
14
+
15
+ mismatch = "StimulusReflex #{reason} a version mismatch between your gem and JavaScript version. Package versions must match exactly.\n\nstimulus_reflex gem: #{StimulusReflex::VERSION}\nstimulus_reflex npm: #{npm_version}"
16
+
17
+ StimulusReflex.config.logger.error("\n\e[31m#{mismatch}\e[0m")
18
+
19
+ log = {
20
+ message: mismatch,
21
+ level: level,
22
+ reflexId: id
23
+ }
24
+
25
+ event = {
26
+ name: "stimulus-reflex:version-mismatch",
27
+ reflexId: id,
28
+ detail: {
29
+ message: mismatch,
30
+ gem: StimulusReflex::VERSION,
31
+ npm: npm_version,
32
+ level: level
33
+ }
34
+ }
35
+
36
+ toast = {
37
+ text: mismatch.to_s,
38
+ destination: "https://docs.stimulusreflex.com/hello-world/setup#upgrading-package-versions-and-sanity",
39
+ reflexId: id,
40
+ level: level
41
+ }
42
+
43
+ CableReady::Channels.instance[@channel.stream_name].tap { |channel|
44
+ channel.console_log(log)
45
+ channel.dispatch_event(event)
46
+ channel.stimulus_reflex_version_mismatch(toast) if Rails.env.development?
47
+ }.broadcast
48
+
49
+ return if level == "warn"
50
+
51
+ raise VersionMismatchError.new(mismatch)
52
+ end
53
+ end
54
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- include Rails.application.routes.url_helpers
4
-
5
3
  SR_STEPS = {
6
4
  "action_cable" => "Action Cable",
7
5
  "webpacker" => "Install StimulusReflex using Webpacker",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stimulus_reflex",
3
- "version": "3.5.0-pre10",
3
+ "version": "3.5.0-rc2",
4
4
  "description": "Build reactive applications with the Rails tooling you already know and love.",
5
5
  "keywords": [
6
6
  "ruby",
@@ -46,17 +46,18 @@
46
46
  "build:watch": "yarn rollup -wc",
47
47
  "watch": "yarn build:watch",
48
48
  "test": "web-test-runner javascript/test/**/*.test.js",
49
+ "test:watch": "yarn test --watch",
49
50
  "docs:dev": "vitepress dev docs",
50
- "docs:build": "vitepress build docs",
51
+ "docs:build": "vitepress build docs && cp docs/_redirects docs/.vitepress/dist",
51
52
  "docs:preview": "vitepress preview docs"
52
53
  },
53
54
  "peerDependencies": {
54
55
  "@hotwired/stimulus": ">= 3.0"
55
56
  },
56
57
  "dependencies": {
57
- "@hotwired/stimulus": ">= 3.0, < 4",
58
- "@rails/actioncable": ">= 6.0, < 8",
59
- "cable_ready": "5.0.0-pre10"
58
+ "@hotwired/stimulus": "^3",
59
+ "@rails/actioncable": "^6 || ^7",
60
+ "cable_ready": "5.0.0-rc2"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@open-wc/testing": "^3.1.7",
@@ -65,9 +66,10 @@
65
66
  "@rollup/plugin-terser": "^0.4.0",
66
67
  "@web/dev-server-esbuild": "^0.3.3",
67
68
  "@web/dev-server-rollup": "^0.3.21",
68
- "@web/test-runner": "^0.15.0",
69
+ "@web/test-runner": "^0.15.1",
69
70
  "prettier-standard": "^16.4.1",
70
- "rollup": "^3.17.1",
71
- "vitepress": "^1.0.0-alpha.47"
71
+ "rollup": "^3.19.1",
72
+ "toastify-js": "^1.12.0",
73
+ "vitepress": "^1.0.0-alpha.56"
72
74
  }
73
75
  }
data/rollup.config.mjs CHANGED
@@ -13,13 +13,6 @@ const pretty = () => {
13
13
  })
14
14
  }
15
15
 
16
- const minify = () => {
17
- return terser({
18
- mangle: true,
19
- compress: true
20
- })
21
- }
22
-
23
16
  const esConfig = {
24
17
  format: 'es',
25
18
  inlineDynamicImports: true
@@ -47,23 +40,11 @@ const output = distFolders
47
40
  file: `${distFolder}/${baseName}.umd.js`,
48
41
  plugins: [pretty()]
49
42
  },
50
- {
51
- ...umdConfig,
52
- file: `${distFolder}/${baseName}.umd.min.js`,
53
- sourcemap: true,
54
- plugins: [pretty()]
55
- },
56
43
  {
57
44
  ...esConfig,
58
45
  file: `${distFolder}/${baseName}.js`,
59
46
  format: 'es',
60
47
  plugins: [pretty()]
61
- },
62
- {
63
- ...esConfig,
64
- file: `${distFolder}/${baseName}.min.js`,
65
- sourcemap: true,
66
- plugins: [minify()]
67
48
  }
68
49
  ])
69
50
  .flat()
@@ -46,9 +46,9 @@ Gem::Specification.new do |gem|
46
46
  gem.add_dependency "activesupport", *rails_version
47
47
  gem.add_dependency "railties", *rails_version
48
48
 
49
- gem.add_dependency "cable_ready", ">= 5.0.0.pre10"
49
+ gem.add_dependency "cable_ready", ">= 5.0.0.rc2"
50
50
  gem.add_dependency "nokogiri", "~> 1.0"
51
- gem.add_dependency "rack", "~> 2.0"
51
+ gem.add_dependency "rack", ">= 2", "< 4"
52
52
  gem.add_dependency "redis", ">= 4.0", "< 6.0"
53
53
 
54
54
  gem.add_development_dependency "bundler", "~> 2.0"