hotwire-spark 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a60c3dbc696c19fcf78bd3812bf58af629f7dfefa67d6274245453fefbbdbf4a
4
- data.tar.gz: a14f7ad1b6d4071e3b2e274597a069a34a90e59b2ff7e4eaeb1ddbb3ede86994
3
+ metadata.gz: 3ec47d67c54c6bd3dae46dd9f5b28f287a45eee3a25001a16a2868c6d10ac83b
4
+ data.tar.gz: 0a68d8c3317f9dd97b2415f507ea34a9611b763f47ff5a465daa26b1b666ca56
5
5
  SHA512:
6
- metadata.gz: 869ea5cbfe198c1a9f88bd11c1941ac5b2f55941b2d702ca60c8f921ade65923dba230fbe0e9b6e5b9f0ff5fb6f76aaad66785aaa975756399d661089c895bcf
7
- data.tar.gz: 2063ea1ede77efcf9747c1b31615c613f9a8ae633d1bec48b76e00a269ef148201a6888e97083b8356adb36fa9877d0e2dc873771835e167b3ae1dce5609d4ec
6
+ metadata.gz: af9ee7d3995fa2c9ff37a7399842feec7fbe875058aa9cc083f649df0f1a03c83daff92221bcb48346ea03a60dfb7b69bdd4f6cd5d90a2ce3d0687a9eac0417f
7
+ data.tar.gz: 762eea1538b421acf5f6f77638fdbfe1e1fec44517e95cc4828b6e60596dad09466d78d7e855c9996ae4561be6d63599e18597c0ec6dd90747ca3ed4087071bd
data/README.md CHANGED
@@ -62,14 +62,14 @@ config.hotwire.spark.html_paths += %w[ lib ]
62
62
 
63
63
  ### Monitored paths
64
64
 
65
- | Name | Description |
66
- |-----------------------|------------------------------------------------------------------------------------------------------------------------------|
67
- | `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/models`, `app/views`. |
68
- | `html_extensions` | The extensions to monitor for HTML content changes. By default: `rb`, `erb`. | |
69
- | `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets` or `app/assets/builds` if exists. |
70
- | `css_extensions` | The extensions to monitor for CSS changes. By default: `css`. | |
71
- | `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`. |
72
- | `stimulus_extensions` | The extensions to monitor for Stimulus changes. By default: `js`. | |
65
+ | Name | Description |
66
+ |-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
67
+ | `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/assets/images`, `app/models`, `app/views`. |
68
+ | `html_extensions` | The extensions to monitor for HTML content changes. By default: `rb`, `erb`, `png`, `jpg`, `jpeg`, `webp`, `svg`. |
69
+ | `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets` or `app/assets/builds` if exists. |
70
+ | `css_extensions` | The extensions to monitor for CSS changes. By default: `css`. |
71
+ | `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`. |
72
+ | `stimulus_extensions` | The extensions to monitor for Stimulus changes. By default: `js`. |
73
73
 
74
74
  ## License
75
75
 
@@ -15,8 +15,8 @@ class Hotwire::Spark::DefaultOptions
15
15
  enabled: Rails.env.development?,
16
16
  css_paths: File.directory?("app/assets/builds") ? %w[ app/assets/builds ] : %w[ app/assets/stylesheets ],
17
17
  css_extensions: %w[ css ],
18
- html_paths: %w[ app/controllers app/helpers app/models app/views ],
19
- html_extensions: %w[ rb erb ],
18
+ html_paths: %w[ app/controllers app/helpers app/assets/images app/models app/views ],
19
+ html_extensions: %w[ rb erb png jpg jpeg webp svg ],
20
20
  stimulus_paths: %w[ app/javascript/controllers ],
21
21
  stimulus_extensions: %w[ js ],
22
22
  html_reload_method: :morph
@@ -6,8 +6,9 @@ class Hotwire::Spark::Middleware
6
6
  def call(env)
7
7
  status, headers, response = @app.call(env)
8
8
 
9
- if html_response?(headers)
10
- @request = ActionDispatch::Request.new(env)
9
+ @request = ActionDispatch::Request.new(env)
10
+
11
+ if interceptable_request? && html_response?(headers)
11
12
  html = html_from(response)
12
13
  html = inject_javascript(html)
13
14
  html = inject_options(html)
@@ -19,6 +20,10 @@ class Hotwire::Spark::Middleware
19
20
  end
20
21
 
21
22
  private
23
+ def interceptable_request?
24
+ @request.controller_instance.present?
25
+ end
26
+
22
27
  def html_response?(headers)
23
28
  headers["Content-Type"]&.include?("text/html")
24
29
  end
@@ -1,5 +1,5 @@
1
1
  module Hotwire
2
2
  module Spark
3
- VERSION = "0.1.11"
3
+ VERSION = "0.1.12"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire-spark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia