hotwire-livereload 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42f6430166f2bcdcb52940e92965a5e1d202c57b09966ddb72f76b746918b473
4
- data.tar.gz: be8743a9b6cbced10614d8fb4fc9cae8306c4355648175a91ed716a763722453
3
+ metadata.gz: 44376128ac37b1619d34c7ee8dee64eb1901804cc170dd0bd5c2114973e98225
4
+ data.tar.gz: 9053700099d671c33b11fa0483100ec5f921016a7e2f1315113072c5c1bba587
5
5
  SHA512:
6
- metadata.gz: 909b0a55ec3d9d4dcbb0f7536e72c380a2d2d8e885cc5d988fe64f91771b759a2809d65f3fad8e500e565a51620532ae1b43c338880c7da977f396852f3b2d6b
7
- data.tar.gz: 90116c0e4b698346603d398cc3a4c7dd6616403f6caae041a014251ea24f57a5e36f83bc6e8554d1c65b21e36e92592c9a583f2f14ca042f357a7d324ecbff8d
6
+ metadata.gz: 5677a61e971bfa24bb8c8ea76970420e370e03003f07970632bf07b22c187cc6dfc3289963509c8597f7b12c08e112d8db56f308fa85008023c3160a9f700846
7
+ data.tar.gz: 4e91a4a01f3e5b8d54e18b2344351c17bef3e1ac09568adc3b1802dc6a8f95eaa4abc6c972e93c8edd7eafa61a944e2b390e339697b1bc802cc7a8e85176b6ff
data/README.md CHANGED
@@ -34,6 +34,8 @@ The gem detects if you use [`jsbundling-rails`](https://github.com/rails/jsbundl
34
34
 
35
35
  ## Configuration
36
36
 
37
+ ### Listen paths
38
+
37
39
  You can watch for changes in additional folders by adding them to `listen_paths`:
38
40
  ```ruby
39
41
  # config/environments/development.rb
@@ -58,6 +60,8 @@ Rails.application.configure do
58
60
  end
59
61
  ```
60
62
 
63
+ ### Force reload
64
+
61
65
  If you don't have `data-turbo-track="reload"` attribute on your JS and CSS bundles you might need to setup force reloading. This will trigger full browser reloading for JS and CSS files only:
62
66
  ```ruby
63
67
  # config/environments/development.rb
@@ -69,6 +73,8 @@ Rails.application.configure do
69
73
  end
70
74
  ```
71
75
 
76
+ ### Reload method
77
+
72
78
  Instead of a direct ActionCable websocket connection, you can reuse the existing TurboStream websocket connection and send updates using standard turbo-streams:
73
79
  ```ruby
74
80
  # config/environments/development.rb
@@ -90,6 +96,22 @@ In that case you need to place `hotwire_livereload_tags` helper in your layout *
90
96
  </head>
91
97
  ```
92
98
 
99
+ ### Listen options
100
+
101
+ [Listen gem](https://github.com/guard/listen), which is used for file system monitoring, accepts [options](https://github.com/guard/listen?tab=readme-ov-file#options) like enabling a fallback mechanism called "polling" to detect file changes.
102
+
103
+ By default, Listen uses a more efficient mechanism called "native" which relies on the operating system's file system events to detect changes. However, in some cases, such as when working with network-mounted file systems or in certain virtualized environments, the native mechanism may not work reliably. In such cases, enabling force_polling ensures that file changes are still detected, albeit with a slightly higher resource usage.
104
+
105
+ You may use listen_options to pass these options like:
106
+ ```ruby
107
+ # config/environments/development.rb
108
+
109
+ Rails.application.configure do
110
+ # ...
111
+ config.hotwire_livereload.listen_options[:force_polling] = true
112
+ end
113
+ ```
114
+
93
115
  ## Disable livereload
94
116
 
95
117
  To temporarily disable livereload use:
@@ -115,6 +115,7 @@
115
115
  } else {
116
116
  console.log("[Hotwire::Livereload] Files changed. Reloading..");
117
117
  hotwire_livereload_scroll_position_default.save();
118
+ Turbo.cache.clear();
118
119
  Turbo.visit(window.location.href, { action: "replace" });
119
120
  }
120
121
  }, 300);
@@ -697,6 +697,7 @@
697
697
  } else {
698
698
  console.log("[Hotwire::Livereload] Files changed. Reloading..");
699
699
  hotwire_livereload_scroll_position_default.save();
700
+ Turbo.cache.clear();
700
701
  Turbo.visit(window.location.href, { action: "replace" });
701
702
  }
702
703
  }, 300);
@@ -10,6 +10,7 @@ export default debounce(({force_reload}) => {
10
10
  } else {
11
11
  console.log("[Hotwire::Livereload] Files changed. Reloading..")
12
12
  scrollPosition.save()
13
+ Turbo.cache.clear()
13
14
  Turbo.visit(window.location.href, { action: 'replace' })
14
15
  }
15
16
  }, 300)
@@ -15,6 +15,7 @@ module Hotwire
15
15
  #{root}/app/channels
16
16
  #{root}/app/helpers
17
17
  ]
18
+ config.hotwire_livereload.listen_options ||= {}
18
19
 
19
20
  initializer "hotwire_livereload.assets" do
20
21
  if Rails.application.config.respond_to?(:assets)
@@ -63,7 +64,7 @@ module Hotwire
63
64
  listen_paths = options.listen_paths.map(&:to_s).uniq
64
65
  force_reload_paths = options.force_reload_paths.map(&:to_s).uniq.join("|")
65
66
 
66
- @listener = Listen.to(*listen_paths) do |modified, added, removed|
67
+ @listener = Listen.to(*listen_paths, **config.hotwire_livereload.listen_options) do |modified, added, removed|
67
68
  unless File.exist?(DISABLE_FILE)
68
69
  changed = [modified, removed, added].flatten.uniq
69
70
  next unless changed.any?
@@ -1,5 +1,5 @@
1
1
  module Hotwire
2
2
  module Livereload
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire-livereload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Platonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-04 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties