hotwire-livereload 1.2.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/assets/javascripts/hotwire-livereload-turbo-stream.js +44 -13
- data/app/assets/javascripts/hotwire-livereload.js +110 -18
- data/app/helpers/hotwire/livereload/livereload_tags_helper.rb +2 -2
- data/app/javascript/hotwire-livereload.js +7 -0
- data/app/javascript/lib/hotwire-livereload-received.js +2 -0
- data/app/javascript/lib/hotwire-livereload-scroll-position.js +27 -0
- data/app/views/hotwire/livereload/_head_action_cable.html.erb +1 -1
- data/app/views/hotwire/livereload/_head_turbo_stream.html.erb +1 -1
- data/lib/hotwire/livereload/engine.rb +17 -6
- data/lib/hotwire/livereload/version.rb +1 -1
- data/lib/install/install.rb +3 -3
- data/lib/tasks/livereload_tasks.rake +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42f6430166f2bcdcb52940e92965a5e1d202c57b09966ddb72f76b746918b473
|
4
|
+
data.tar.gz: be8743a9b6cbced10614d8fb4fc9cae8306c4355648175a91ed716a763722453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 909b0a55ec3d9d4dcbb0f7536e72c380a2d2d8e885cc5d988fe64f91771b759a2809d65f3fad8e500e565a51620532ae1b43c338880c7da977f396852f3b2d6b
|
7
|
+
data.tar.gz: 90116c0e4b698346603d398cc3a4c7dd6616403f6caae041a014251ea24f57a5e36f83bc6e8554d1c65b21e36e92592c9a583f2f14ca042f357a7d324ecbff8d
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ https://user-images.githubusercontent.com/839922/148676469-0acfa036-832e-4b40-aa
|
|
12
12
|
|
13
13
|
Add `hotwire-livereload` to your Gemfile:
|
14
14
|
```
|
15
|
-
bundle add hotwire-livereload
|
15
|
+
bundle add hotwire-livereload --group development
|
16
16
|
```
|
17
17
|
|
18
18
|
Run installer:
|
@@ -30,6 +30,8 @@ Folders listened by default:
|
|
30
30
|
- `app/components`
|
31
31
|
- `config/locales`
|
32
32
|
|
33
|
+
The gem detects if you use [`jsbundling-rails`](https://github.com/rails/jsbundling-rails) or [`cssbundling-rails`](https://github.com/rails/cssbundling-rails) and watches for changes in their output folder `app/assets/builds` automatically.
|
34
|
+
|
33
35
|
## Configuration
|
34
36
|
|
35
37
|
You can watch for changes in additional folders by adding them to `listen_paths`:
|
@@ -5,28 +5,32 @@
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
9
8
|
var __commonJS = (cb, mod) => function __require() {
|
10
|
-
return mod || (0, cb[
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
11
10
|
};
|
12
|
-
var
|
13
|
-
if (
|
14
|
-
for (let key of __getOwnPropNames(
|
15
|
-
if (!__hasOwnProp.call(
|
16
|
-
__defProp(
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
16
|
}
|
18
|
-
return
|
19
|
-
};
|
20
|
-
var __toModule = (module) => {
|
21
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
17
|
+
return to;
|
22
18
|
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
+
mod
|
26
|
+
));
|
23
27
|
|
24
28
|
// node_modules/debounce/index.js
|
25
29
|
var require_debounce = __commonJS({
|
26
30
|
"node_modules/debounce/index.js"(exports, module) {
|
27
31
|
function debounce2(func, wait, immediate) {
|
28
32
|
var timeout, args, context, timestamp, result;
|
29
|
-
if (
|
33
|
+
if (null == wait)
|
30
34
|
wait = 100;
|
31
35
|
function later() {
|
32
36
|
var last = Date.now() - timestamp;
|
@@ -76,7 +80,33 @@
|
|
76
80
|
});
|
77
81
|
|
78
82
|
// app/javascript/lib/hotwire-livereload-received.js
|
79
|
-
var import_debounce =
|
83
|
+
var import_debounce = __toESM(require_debounce());
|
84
|
+
|
85
|
+
// app/javascript/lib/hotwire-livereload-scroll-position.js
|
86
|
+
var KEY = "hotwire-livereload-scrollPosition";
|
87
|
+
function read() {
|
88
|
+
const value = localStorage.getItem(KEY);
|
89
|
+
if (!value)
|
90
|
+
return;
|
91
|
+
return parseInt(value);
|
92
|
+
}
|
93
|
+
function save() {
|
94
|
+
const pos = window.scrollY;
|
95
|
+
localStorage.setItem(KEY, pos.toString());
|
96
|
+
}
|
97
|
+
function remove() {
|
98
|
+
localStorage.removeItem(KEY);
|
99
|
+
}
|
100
|
+
function restore() {
|
101
|
+
const value = read();
|
102
|
+
if (value) {
|
103
|
+
console.log("[Hotwire::Livereload] Restoring scroll position to", value);
|
104
|
+
window.scrollTo(0, value);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
var hotwire_livereload_scroll_position_default = { read, save, restore, remove };
|
108
|
+
|
109
|
+
// app/javascript/lib/hotwire-livereload-received.js
|
80
110
|
var hotwire_livereload_received_default = (0, import_debounce.default)(({ force_reload }) => {
|
81
111
|
const onErrorPage = document.title === "Action Controller: Exception caught";
|
82
112
|
if (onErrorPage || force_reload) {
|
@@ -84,6 +114,7 @@
|
|
84
114
|
document.location.reload();
|
85
115
|
} else {
|
86
116
|
console.log("[Hotwire::Livereload] Files changed. Reloading..");
|
117
|
+
hotwire_livereload_scroll_position_default.save();
|
87
118
|
Turbo.visit(window.location.href, { action: "replace" });
|
88
119
|
}
|
89
120
|
}, 300);
|
@@ -5,21 +5,25 @@
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
9
8
|
var __commonJS = (cb, mod) => function __require() {
|
10
|
-
return mod || (0, cb[
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
11
10
|
};
|
12
|
-
var
|
13
|
-
if (
|
14
|
-
for (let key of __getOwnPropNames(
|
15
|
-
if (!__hasOwnProp.call(
|
16
|
-
__defProp(
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
16
|
}
|
18
|
-
return
|
19
|
-
};
|
20
|
-
var __toModule = (module) => {
|
21
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
17
|
+
return to;
|
22
18
|
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
+
mod
|
26
|
+
));
|
23
27
|
|
24
28
|
// node_modules/@rails/actioncable/app/assets/javascripts/action_cable.js
|
25
29
|
var require_action_cable = __commonJS({
|
@@ -74,7 +78,7 @@
|
|
74
78
|
};
|
75
79
|
}();
|
76
80
|
var now = function now2() {
|
77
|
-
return new Date().getTime();
|
81
|
+
return (/* @__PURE__ */ new Date()).getTime();
|
78
82
|
};
|
79
83
|
var secondsSince = function secondsSince2(time) {
|
80
84
|
return (now() - time) / 1e3;
|
@@ -318,6 +322,7 @@
|
|
318
322
|
case message_types.ping:
|
319
323
|
return this.monitor.recordPing();
|
320
324
|
case message_types.confirmation:
|
325
|
+
this.subscriptions.confirmSubscription(identifier);
|
321
326
|
return this.subscriptions.notify(identifier, "connected");
|
322
327
|
case message_types.rejection:
|
323
328
|
return this.subscriptions.reject(identifier);
|
@@ -385,10 +390,52 @@
|
|
385
390
|
};
|
386
391
|
return Subscription2;
|
387
392
|
}();
|
393
|
+
var SubscriptionGuarantor = function() {
|
394
|
+
function SubscriptionGuarantor2(subscriptions) {
|
395
|
+
classCallCheck(this, SubscriptionGuarantor2);
|
396
|
+
this.subscriptions = subscriptions;
|
397
|
+
this.pendingSubscriptions = [];
|
398
|
+
}
|
399
|
+
SubscriptionGuarantor2.prototype.guarantee = function guarantee(subscription) {
|
400
|
+
if (this.pendingSubscriptions.indexOf(subscription) == -1) {
|
401
|
+
logger.log("SubscriptionGuarantor guaranteeing " + subscription.identifier);
|
402
|
+
this.pendingSubscriptions.push(subscription);
|
403
|
+
} else {
|
404
|
+
logger.log("SubscriptionGuarantor already guaranteeing " + subscription.identifier);
|
405
|
+
}
|
406
|
+
this.startGuaranteeing();
|
407
|
+
};
|
408
|
+
SubscriptionGuarantor2.prototype.forget = function forget(subscription) {
|
409
|
+
logger.log("SubscriptionGuarantor forgetting " + subscription.identifier);
|
410
|
+
this.pendingSubscriptions = this.pendingSubscriptions.filter(function(s) {
|
411
|
+
return s !== subscription;
|
412
|
+
});
|
413
|
+
};
|
414
|
+
SubscriptionGuarantor2.prototype.startGuaranteeing = function startGuaranteeing() {
|
415
|
+
this.stopGuaranteeing();
|
416
|
+
this.retrySubscribing();
|
417
|
+
};
|
418
|
+
SubscriptionGuarantor2.prototype.stopGuaranteeing = function stopGuaranteeing() {
|
419
|
+
clearTimeout(this.retryTimeout);
|
420
|
+
};
|
421
|
+
SubscriptionGuarantor2.prototype.retrySubscribing = function retrySubscribing() {
|
422
|
+
var _this = this;
|
423
|
+
this.retryTimeout = setTimeout(function() {
|
424
|
+
if (_this.subscriptions && typeof _this.subscriptions.subscribe === "function") {
|
425
|
+
_this.pendingSubscriptions.map(function(subscription) {
|
426
|
+
logger.log("SubscriptionGuarantor resubscribing " + subscription.identifier);
|
427
|
+
_this.subscriptions.subscribe(subscription);
|
428
|
+
});
|
429
|
+
}
|
430
|
+
}, 500);
|
431
|
+
};
|
432
|
+
return SubscriptionGuarantor2;
|
433
|
+
}();
|
388
434
|
var Subscriptions = function() {
|
389
435
|
function Subscriptions2(consumer2) {
|
390
436
|
classCallCheck(this, Subscriptions2);
|
391
437
|
this.consumer = consumer2;
|
438
|
+
this.guarantor = new SubscriptionGuarantor(this);
|
392
439
|
this.subscriptions = [];
|
393
440
|
}
|
394
441
|
Subscriptions2.prototype.create = function create(channelName, mixin) {
|
@@ -403,10 +450,10 @@
|
|
403
450
|
this.subscriptions.push(subscription);
|
404
451
|
this.consumer.ensureActiveConnection();
|
405
452
|
this.notify(subscription, "initialized");
|
406
|
-
this.
|
453
|
+
this.subscribe(subscription);
|
407
454
|
return subscription;
|
408
455
|
};
|
409
|
-
Subscriptions2.prototype.remove = function
|
456
|
+
Subscriptions2.prototype.remove = function remove2(subscription) {
|
410
457
|
this.forget(subscription);
|
411
458
|
if (!this.findAll(subscription.identifier).length) {
|
412
459
|
this.sendCommand(subscription, "unsubscribe");
|
@@ -422,6 +469,7 @@
|
|
422
469
|
});
|
423
470
|
};
|
424
471
|
Subscriptions2.prototype.forget = function forget(subscription) {
|
472
|
+
this.guarantor.forget(subscription);
|
425
473
|
this.subscriptions = this.subscriptions.filter(function(s) {
|
426
474
|
return s !== subscription;
|
427
475
|
});
|
@@ -435,7 +483,7 @@
|
|
435
483
|
Subscriptions2.prototype.reload = function reload() {
|
436
484
|
var _this2 = this;
|
437
485
|
return this.subscriptions.map(function(subscription) {
|
438
|
-
return _this2.
|
486
|
+
return _this2.subscribe(subscription);
|
439
487
|
});
|
440
488
|
};
|
441
489
|
Subscriptions2.prototype.notifyAll = function notifyAll(callbackName) {
|
@@ -461,6 +509,18 @@
|
|
461
509
|
return typeof subscription2[callbackName] === "function" ? subscription2[callbackName].apply(subscription2, args) : void 0;
|
462
510
|
});
|
463
511
|
};
|
512
|
+
Subscriptions2.prototype.subscribe = function subscribe(subscription) {
|
513
|
+
if (this.sendCommand(subscription, "subscribe")) {
|
514
|
+
this.guarantor.guarantee(subscription);
|
515
|
+
}
|
516
|
+
};
|
517
|
+
Subscriptions2.prototype.confirmSubscription = function confirmSubscription(identifier) {
|
518
|
+
var _this4 = this;
|
519
|
+
logger.log("Subscription confirmed " + identifier);
|
520
|
+
this.findAll(identifier).map(function(subscription) {
|
521
|
+
return _this4.guarantor.forget(subscription);
|
522
|
+
});
|
523
|
+
};
|
464
524
|
Subscriptions2.prototype.sendCommand = function sendCommand(subscription, command) {
|
465
525
|
var identifier = subscription.identifier;
|
466
526
|
return this.consumer.send({
|
@@ -531,6 +591,7 @@
|
|
531
591
|
exports2.INTERNAL = INTERNAL;
|
532
592
|
exports2.Subscription = Subscription;
|
533
593
|
exports2.Subscriptions = Subscriptions;
|
594
|
+
exports2.SubscriptionGuarantor = SubscriptionGuarantor;
|
534
595
|
exports2.adapters = adapters;
|
535
596
|
exports2.createWebSocketURL = createWebSocketURL;
|
536
597
|
exports2.logger = logger;
|
@@ -548,7 +609,7 @@
|
|
548
609
|
"node_modules/debounce/index.js"(exports, module) {
|
549
610
|
function debounce2(func, wait, immediate) {
|
550
611
|
var timeout, args, context, timestamp, result;
|
551
|
-
if (
|
612
|
+
if (null == wait)
|
552
613
|
wait = 100;
|
553
614
|
function later() {
|
554
615
|
var last = Date.now() - timestamp;
|
@@ -598,10 +659,36 @@
|
|
598
659
|
});
|
599
660
|
|
600
661
|
// app/javascript/hotwire-livereload.js
|
601
|
-
var import_actioncable =
|
662
|
+
var import_actioncable = __toESM(require_action_cable());
|
663
|
+
|
664
|
+
// app/javascript/lib/hotwire-livereload-received.js
|
665
|
+
var import_debounce = __toESM(require_debounce());
|
666
|
+
|
667
|
+
// app/javascript/lib/hotwire-livereload-scroll-position.js
|
668
|
+
var KEY = "hotwire-livereload-scrollPosition";
|
669
|
+
function read() {
|
670
|
+
const value = localStorage.getItem(KEY);
|
671
|
+
if (!value)
|
672
|
+
return;
|
673
|
+
return parseInt(value);
|
674
|
+
}
|
675
|
+
function save() {
|
676
|
+
const pos = window.scrollY;
|
677
|
+
localStorage.setItem(KEY, pos.toString());
|
678
|
+
}
|
679
|
+
function remove() {
|
680
|
+
localStorage.removeItem(KEY);
|
681
|
+
}
|
682
|
+
function restore() {
|
683
|
+
const value = read();
|
684
|
+
if (value) {
|
685
|
+
console.log("[Hotwire::Livereload] Restoring scroll position to", value);
|
686
|
+
window.scrollTo(0, value);
|
687
|
+
}
|
688
|
+
}
|
689
|
+
var hotwire_livereload_scroll_position_default = { read, save, restore, remove };
|
602
690
|
|
603
691
|
// app/javascript/lib/hotwire-livereload-received.js
|
604
|
-
var import_debounce = __toModule(require_debounce());
|
605
692
|
var hotwire_livereload_received_default = (0, import_debounce.default)(({ force_reload }) => {
|
606
693
|
const onErrorPage = document.title === "Action Controller: Exception caught";
|
607
694
|
if (onErrorPage || force_reload) {
|
@@ -609,6 +696,7 @@
|
|
609
696
|
document.location.reload();
|
610
697
|
} else {
|
611
698
|
console.log("[Hotwire::Livereload] Files changed. Reloading..");
|
699
|
+
hotwire_livereload_scroll_position_default.save();
|
612
700
|
Turbo.visit(window.location.href, { action: "replace" });
|
613
701
|
}
|
614
702
|
}, 300);
|
@@ -624,4 +712,8 @@
|
|
624
712
|
console.log("[Hotwire::Livereload] Websocket disconnected");
|
625
713
|
}
|
626
714
|
});
|
715
|
+
document.addEventListener("turbo:load", () => {
|
716
|
+
hotwire_livereload_scroll_position_default.restore();
|
717
|
+
hotwire_livereload_scroll_position_default.remove();
|
718
|
+
});
|
627
719
|
})();
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Hotwire::Livereload::LivereloadTagsHelper
|
2
2
|
def hotwire_livereload_tags
|
3
3
|
partial = if Hotwire::Livereload::Engine.config.hotwire_livereload.reload_method == :turbo_stream
|
4
|
-
|
4
|
+
"hotwire/livereload/head_turbo_stream"
|
5
5
|
else
|
6
|
-
|
6
|
+
"hotwire/livereload/head_action_cable"
|
7
7
|
end
|
8
8
|
|
9
9
|
render partial
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { createConsumer } from "@rails/actioncable"
|
2
2
|
import received from "./lib/hotwire-livereload-received"
|
3
|
+
import scrollPosition from "./lib/hotwire-livereload-scroll-position"
|
3
4
|
|
4
5
|
const consumer = createConsumer()
|
5
6
|
consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
@@ -13,3 +14,9 @@ consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
|
13
14
|
console.log("[Hotwire::Livereload] Websocket disconnected")
|
14
15
|
},
|
15
16
|
})
|
17
|
+
|
18
|
+
document.addEventListener("turbo:load", () => {
|
19
|
+
scrollPosition.restore()
|
20
|
+
scrollPosition.remove()
|
21
|
+
})
|
22
|
+
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import debounce from "debounce"
|
2
|
+
import scrollPosition from "./hotwire-livereload-scroll-position"
|
2
3
|
|
3
4
|
export default debounce(({force_reload}) => {
|
4
5
|
const onErrorPage = document.title === "Action Controller: Exception caught"
|
@@ -8,6 +9,7 @@ export default debounce(({force_reload}) => {
|
|
8
9
|
document.location.reload()
|
9
10
|
} else {
|
10
11
|
console.log("[Hotwire::Livereload] Files changed. Reloading..")
|
12
|
+
scrollPosition.save()
|
11
13
|
Turbo.visit(window.location.href, { action: 'replace' })
|
12
14
|
}
|
13
15
|
}, 300)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
const KEY = "hotwire-livereload-scrollPosition"
|
2
|
+
|
3
|
+
export function read() {
|
4
|
+
const value = localStorage.getItem(KEY)
|
5
|
+
if (!value) return
|
6
|
+
return parseInt(value)
|
7
|
+
}
|
8
|
+
|
9
|
+
export function save() {
|
10
|
+
const pos = window.scrollY
|
11
|
+
localStorage.setItem(KEY, pos.toString())
|
12
|
+
}
|
13
|
+
|
14
|
+
export function remove() {
|
15
|
+
localStorage.removeItem(KEY)
|
16
|
+
}
|
17
|
+
|
18
|
+
export function restore() {
|
19
|
+
const value = read()
|
20
|
+
if (value) {
|
21
|
+
console.log("[Hotwire::Livereload] Restoring scroll position to", value)
|
22
|
+
window.scrollTo(0, value)
|
23
|
+
}
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
export default { read, save, restore, remove }
|
@@ -11,14 +11,14 @@ module Hotwire
|
|
11
11
|
config.hotwire_livereload.force_reload_paths ||= []
|
12
12
|
config.hotwire_livereload.reload_method = :action_cable
|
13
13
|
config.hotwire_livereload.disable_default_listeners = false
|
14
|
-
config.autoload_once_paths = %W
|
14
|
+
config.autoload_once_paths = %W[
|
15
15
|
#{root}/app/channels
|
16
16
|
#{root}/app/helpers
|
17
|
-
|
17
|
+
]
|
18
18
|
|
19
19
|
initializer "hotwire_livereload.assets" do
|
20
20
|
if Rails.application.config.respond_to?(:assets)
|
21
|
-
Rails.application.config.assets.precompile += %w
|
21
|
+
Rails.application.config.assets.precompile += %w[hotwire-livereload.js hotwire-livereload-turbo-stream.js]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -41,8 +41,19 @@ module Hotwire
|
|
41
41
|
app/assets/images
|
42
42
|
app/components
|
43
43
|
config/locales
|
44
|
-
]
|
45
|
-
|
44
|
+
]
|
45
|
+
if defined?(Jsbundling)
|
46
|
+
default_listen_paths -= %w[app/javascript]
|
47
|
+
default_listen_paths += %w[app/assets/builds]
|
48
|
+
end
|
49
|
+
if defined?(Cssbundling)
|
50
|
+
default_listen_paths -= %w[app/assets/stylesheets]
|
51
|
+
default_listen_paths += %w[app/assets/builds]
|
52
|
+
end
|
53
|
+
options.listen_paths += default_listen_paths
|
54
|
+
.uniq
|
55
|
+
.map { |p| Rails.root.join(p) }
|
56
|
+
.select { |p| Dir.exist?(p) }
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
@@ -55,7 +66,7 @@ module Hotwire
|
|
55
66
|
@listener = Listen.to(*listen_paths) do |modified, added, removed|
|
56
67
|
unless File.exist?(DISABLE_FILE)
|
57
68
|
changed = [modified, removed, added].flatten.uniq
|
58
|
-
|
69
|
+
next unless changed.any?
|
59
70
|
|
60
71
|
force_reload = force_reload_paths.present? && changed.any? do |path|
|
61
72
|
path.match(%r{#{force_reload_paths}})
|
data/lib/install/install.rb
CHANGED
@@ -3,9 +3,9 @@ CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
|
|
3
3
|
|
4
4
|
if APP_LAYOUT_PATH.exist?
|
5
5
|
say "Add Hotwire Livereload tag in application layout"
|
6
|
-
content =
|
7
|
-
\n <%= hotwire_livereload_tags if Rails.env.development? %>
|
8
|
-
HTML
|
6
|
+
content = <<~HTML
|
7
|
+
\n <%= hotwire_livereload_tags if Rails.env.development? %>
|
8
|
+
HTML
|
9
9
|
insert_into_file APP_LAYOUT_PATH, content.chop, before: /\s*<\/head>/
|
10
10
|
else
|
11
11
|
say "Default application.html.erb is missing!", :red
|
@@ -1,7 +1,7 @@
|
|
1
1
|
namespace :livereload do
|
2
2
|
desc "Install Hotwire::Livereload into the app"
|
3
3
|
task :install do
|
4
|
-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb",
|
4
|
+
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
|
5
5
|
end
|
6
6
|
|
7
7
|
desc "Disable Hotwire::Livereload"
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotwire-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Platonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actioncable
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -54,6 +68,7 @@ files:
|
|
54
68
|
- app/javascript/hotwire-livereload-turbo-stream.js
|
55
69
|
- app/javascript/hotwire-livereload.js
|
56
70
|
- app/javascript/lib/hotwire-livereload-received.js
|
71
|
+
- app/javascript/lib/hotwire-livereload-scroll-position.js
|
57
72
|
- app/views/hotwire/livereload/_head_action_cable.html.erb
|
58
73
|
- app/views/hotwire/livereload/_head_turbo_stream.html.erb
|
59
74
|
- app/views/hotwire/livereload/_turbo_stream.html.erb
|
@@ -81,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
96
|
- !ruby/object:Gem::Version
|
82
97
|
version: '0'
|
83
98
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
99
|
+
rubygems_version: 3.4.20
|
85
100
|
signing_key:
|
86
101
|
specification_version: 4
|
87
102
|
summary: Automatically reload Hotwire Turbo when app files are modified.
|