Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version #4

Merged
merged 94 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
185e5b9
Configure engine importmaps
jorgemanrubia Nov 23, 2024
4a92741
System to detect file changes working
jorgemanrubia Nov 23, 2024
cee8b31
Css reloading works
jorgemanrubia Nov 23, 2024
0109bbe
Reloading HTML working
jorgemanrubia Nov 23, 2024
7cf5d6d
Build JS with rollup since the importmap path is a constant headache
jorgemanrubia Nov 24, 2024
60ae760
Reload stimulus controllers working
jorgemanrubia Nov 24, 2024
71bc32e
Separate controllers from commands
jorgemanrubia Nov 25, 2024
5b6bcb9
Add static invocation methods
jorgemanrubia Nov 25, 2024
8f4574f
Tidy up CSS reloader, make it async-friendly
jorgemanrubia Nov 25, 2024
a00582e
Make static method async too
jorgemanrubia Nov 25, 2024
dba1d6a
Tidy up HTML reloader
jorgemanrubia Nov 25, 2024
4216e47
Tidy up system to reload stimulus controllers
jorgemanrubia Nov 25, 2024
00f474e
Tidy up system to reload stimulus controllers
jorgemanrubia Nov 25, 2024
c4907f2
Don't restart cable server when reloading HTML
jorgemanrubia Nov 25, 2024
a8c9a8b
Move installation logic to installer
jorgemanrubia Nov 25, 2024
c259837
Format
jorgemanrubia Nov 25, 2024
281127c
Remove logs
jorgemanrubia Nov 25, 2024
5586a64
Remove logs
jorgemanrubia Nov 25, 2024
7553111
Add rubocop
jorgemanrubia Nov 25, 2024
fe037e3
Format
jorgemanrubia Nov 25, 2024
8d9c27f
Remove redundant local vars
jorgemanrubia Nov 25, 2024
0fe1b70
Add some basic logging
jorgemanrubia Nov 26, 2024
93b25bd
Pass the path to the action
jorgemanrubia Nov 26, 2024
13fe796
Only reload the CSS that changes
jorgemanrubia Nov 26, 2024
cd68dad
Default to all CSS
jorgemanrubia Nov 26, 2024
65ce1fd
Remove log
jorgemanrubia Nov 26, 2024
7b54351
Extract helpers to manipulate URLs
jorgemanrubia Nov 26, 2024
7f3f975
Reload HTML and stimulus controllers
jorgemanrubia Nov 26, 2024
4604542
Generate modern JS
jorgemanrubia Nov 26, 2024
6ca7bb8
No need to include ID
jorgemanrubia Nov 26, 2024
a84c2e5
CSSReload grabs the new link from a new document
jorgemanrubia Nov 26, 2024
f931771
Only change interesting JS files
jorgemanrubia Nov 26, 2024
5ecb278
Remove ;
jorgemanrubia Nov 26, 2024
56e2da8
Typo
jorgemanrubia Nov 26, 2024
f96ccd4
Rename puse_wire => hotwire_spark
jorgemanrubia Dec 3, 2024
7dbcfa1
Inject turbo_stream from middleware too
jorgemanrubia Dec 4, 2024
4129a20
Use a custom channel for turbo stream
jorgemanrubia Dec 4, 2024
9c29312
Reload stimulus controllers considering the new document that changed
jorgemanrubia Dec 4, 2024
a52d023
Use a cookie to intercept other requests too
jorgemanrubia Dec 4, 2024
cf69d50
Add temporary patch until solid cable's patch gets merged
jorgemanrubia Dec 5, 2024
8531abc
Use rails's DSL for time ago
jorgemanrubia Dec 5, 2024
5c80e36
Fix some rollup warnings
jorgemanrubia Dec 5, 2024
325226b
Drop turbo dependency and rely on vanilla action cable
jorgemanrubia Dec 5, 2024
977cdc3
Remove turbo-rails
jorgemanrubia Dec 5, 2024
965aba9
Rename variable
jorgemanrubia Dec 5, 2024
7f7f13d
Bust cache when fetching CSS links
jorgemanrubia Dec 5, 2024
16a9d02
Remove more turbo-rails references
jorgemanrubia Dec 5, 2024
8360939
Fix caching problem when loading CSS
jorgemanrubia Dec 5, 2024
eca8201
Rename concern
jorgemanrubia Dec 6, 2024
cefe0b4
Replace reloader with executor
jorgemanrubia Dec 9, 2024
1ea3cd8
Add system test for HTML reloads
jorgemanrubia Dec 14, 2024
8444c2d
Add css reload test
jorgemanrubia Dec 14, 2024
8a37d16
Copy
jorgemanrubia Dec 14, 2024
d20e792
Add stimulus controller change
jorgemanrubia Dec 14, 2024
355153e
Restore regular cable adapter
jorgemanrubia Dec 14, 2024
d9f72f3
Add test for adding new stimulus controllers
jorgemanrubia Dec 14, 2024
3c0a734
Tests passing and not hanging
jorgemanrubia Dec 14, 2024
9495456
Format
jorgemanrubia Dec 14, 2024
b23cb6f
Fix test run script
jorgemanrubia Dec 14, 2024
7aa1945
Support adding new CSS links too
jorgemanrubia Dec 14, 2024
273de45
Rename method
jorgemanrubia Dec 14, 2024
8bcd5d8
Stabilize tests
jorgemanrubia Dec 14, 2024
137dc44
Not needed
jorgemanrubia Dec 14, 2024
4fee7d6
Move method to system test base class
jorgemanrubia Dec 14, 2024
28e2fc8
Don't render errors, just log them to the console
jorgemanrubia Dec 14, 2024
f3f6450
Update gemspec
jorgemanrubia Dec 15, 2024
bb52227
Move initialization to the engine so that customizations are picked
jorgemanrubia Dec 15, 2024
e504615
Extract method
jorgemanrubia Dec 15, 2024
715af5c
Order method
jorgemanrubia Dec 15, 2024
5e0787c
Rename method
jorgemanrubia Dec 15, 2024
ae99fea
Extract method
jorgemanrubia Dec 15, 2024
95bd924
Extract method
jorgemanrubia Dec 15, 2024
e3fa36e
Rename
jorgemanrubia Dec 15, 2024
13dd08d
More concise
jorgemanrubia Dec 15, 2024
e0ee392
Replace with helper function
jorgemanrubia Dec 15, 2024
f924efd
Rename helper functions
jorgemanrubia Dec 16, 2024
1680c47
Handle invalid commands
jorgemanrubia Dec 16, 2024
90a06c8
Rename
jorgemanrubia Dec 16, 2024
99865ae
Remove logs
jorgemanrubia Dec 16, 2024
6d62dd3
Format
jorgemanrubia Dec 16, 2024
bc02c1a
Ignore params when comparing normalized paths
jorgemanrubia Dec 16, 2024
bbddf6f
More concise
jorgemanrubia Dec 16, 2024
bdc0c83
Rename
jorgemanrubia Dec 16, 2024
5de0a23
Rename
jorgemanrubia Dec 16, 2024
91e99f2
No need to use this patch anymore with 3.0.4 released
jorgemanrubia Dec 16, 2024
b8c0b5a
Update JS
jorgemanrubia Dec 16, 2024
ad87e96
Order method
jorgemanrubia Dec 16, 2024
d68597f
Push assets
jorgemanrubia Dec 16, 2024
034072f
Rename to hotwire-spark
jorgemanrubia Dec 16, 2024
19b9cd9
Initial README
jorgemanrubia Dec 17, 2024
e79457f
Format
jorgemanrubia Dec 17, 2024
4bba90d
Make the option to show logs optional and disabled by default
jorgemanrubia Dec 17, 2024
e637036
Copy
jorgemanrubia Dec 17, 2024
356047e
Format
jorgemanrubia Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ jobs:
- name: Run tests
env:
RAILS_ENV: test
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:test:prepare test
run: bin/rails db:test:prepare && bin/rails test

- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
/test/dummy/log/*.log
/test/dummy/storage/
/test/dummy/tmp/
/node_modules/

8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
source "https://rubygems.org"

# Specify your gem's dependencies in pulse_wire.gemspec.
# Specify your gem's dependencies in hotwire_spark.gemspec.
gemspec

gem "puma"

gem "sqlite3"

gem "propshaft"

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false

# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"

gem "propshaft"
gem "importmap-rails"
gem "stimulus-rails"
94 changes: 70 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
PATH
remote: .
specs:
pulse_wire (0.1.0)
hotwire-spark (0.1.0)
listen
rails (>= 8.0.0)
zeitwerk

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -78,28 +80,55 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
builder (3.3.0)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
cuprite (0.15.1)
capybara (~> 3.0)
ferrum (~> 0.15.0)
date (3.4.0)
drb (2.2.1)
erubi (1.13.0)
ferrum (0.15)
addressable (~> 2.5)
concurrent-ruby (~> 1.1)
webrick (~> 1.7)
websocket-driver (~> 0.7)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
importmap-rails (2.0.3)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.8.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.8.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.2)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -109,9 +138,10 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
matrix (0.4.2)
mini_mime (1.1.5)
minitest (5.25.1)
net-imap (0.5.1)
minitest (5.25.4)
net-imap (0.5.2)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -121,9 +151,9 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.4)
nokogiri (1.16.7-arm64-darwin)
nokogiri (1.17.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.17.0-x86_64-linux)
racc (~> 1.4)
parallel (1.26.3)
parser (3.3.6.0)
Expand All @@ -134,8 +164,10 @@ GEM
activesupport (>= 7.0.0)
rack
railties (>= 7.0.0)
psych (5.2.0)
psych (5.2.1)
date
stringio
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
Expand Down Expand Up @@ -164,9 +196,9 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (~> 1.14)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.0.0)
actionpack (= 8.0.0)
activesupport (= 8.0.0)
Expand All @@ -177,26 +209,30 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rdoc (6.8.1)
psych (>= 4.0.0)
regexp_parser (2.9.2)
reline (0.5.11)
reline (0.5.12)
io-console (~> 0.5)
rubocop (1.68.0)
rexml (3.3.9)
rubocop (1.52.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-minitest (0.34.5)
rubocop (>= 1.39, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-performance (1.23.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
Expand All @@ -211,32 +247,42 @@ GEM
rubocop-performance
rubocop-rails
ruby-progressbar (1.13.0)
securerandom (0.3.2)
securerandom (0.4.0)
sqlite3 (2.2.0-arm64-darwin)
sqlite3 (2.2.0-x86_64-linux-gnu)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.2)
thor (1.3.2)
timeout (0.4.2)
timeout (0.4.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
useragent (0.16.10)
useragent (0.16.11)
webrick (1.9.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.7.1)

PLATFORMS
arm64-darwin
x86_64-linux

DEPENDENCIES
capybara
cuprite
hotwire-spark!
importmap-rails
propshaft
pulse_wire!
puma
rubocop
rubocop-rails-omakase
sqlite3
stimulus-rails

BUNDLED WITH
2.5.23
43 changes: 32 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
# PulseWire
Short description and motivation.
# Hotwire Spark

## Usage
How to use my plugin.
**Hotwire Spark** is a live-reloading system for Hotwire applications. It enhances your development feedback loop by detecting source code changes and updating the page *smoothly* without requiring a manual reload.

## Installation
Add this line to your application's Gemfile:

Add the gem to the group `development`:

```ruby
gem "pulse_wire"
group :development do
gem "hotwire_spark"
end
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:
```bash
$ gem install pulse_wire
That's it!

## Hot it works

The system will listen for three kinds of changes and will take action depending on each:

* **HTML change:** it fetches the new document body and updates the current body with morphing. It uses [`idiomorph`](https://github.com/bigskysoftware/idiomorph) under the hood.
* **CSS change:** it fetches and reloads the stylesheet that changed.
* **Stimulus controller change:** it fetches the Stimulus controller that changed and reloads all the controllers in the page.

## Configuration

You can set configuration options on your `development.rb`. For example:

```ruby
config.hotwire.spark.html_paths += %w[ lib ]
```

## Contributing
Contribution directions go here.
| Name | Description |
|------------------|------------------------------------------------------------------------------------------------------------------------------|
| `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/models`, `app/views`. |
| `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets`. |
| `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`. |
| `enabled` | Enable or disable live reloading. By default, it's only enabled in `development`. |
| `logging` | Show logs in the browser console when reloading happens. It's false by default. |

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
Loading
Loading