hotwire-livereload 1.2.2 → 1.3.0
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 +4 -4
- data/README.md +3 -1
- data/app/assets/javascripts/hotwire-livereload-turbo-stream.js +17 -13
- data/app/assets/javascripts/hotwire-livereload.js +119 -20
- data/app/helpers/hotwire/livereload/livereload_tags_helper.rb +2 -2
- data/app/javascript/hotwire-livereload.js +21 -0
- data/app/javascript/lib/hotwire-livereload-scroll-position.js +24 -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 +18 -7
- 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: 588323a498a0f2aa7b4ebb53c417b0f937b3d9df5e06af8ec4039e26f35de0c9
|
4
|
+
data.tar.gz: 15c0688010ad47a244cbcf4c1bb543ce199f5ba9f73b822228b9d5aafe71c5b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4389aeae81c93d5f9ec646748e587a084bebf0993173bce97bf3629f81dd1c8763d31635729218b0e2631b5529a16e2d63403c696301f24c9a788d84aa6c5fc
|
7
|
+
data.tar.gz: 429fb41ac85243a1dd9aa0b7f5461b189e10f06f98e5547af125f65996026b4ea44ea1ceceb8c0dbe07ce297091438490d257b51b0e7f9319e0e7e7a80bbf6f2
|
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,7 @@
|
|
76
80
|
});
|
77
81
|
|
78
82
|
// app/javascript/lib/hotwire-livereload-received.js
|
79
|
-
var import_debounce =
|
83
|
+
var import_debounce = __toESM(require_debounce());
|
80
84
|
var hotwire_livereload_received_default = (0, import_debounce.default)(({ force_reload }) => {
|
81
85
|
const onErrorPage = document.title === "Action Controller: Exception caught";
|
82
86
|
if (onErrorPage || force_reload) {
|
@@ -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,7 +450,7 @@
|
|
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
456
|
Subscriptions2.prototype.remove = function remove(subscription) {
|
@@ -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;
|
@@ -546,9 +607,9 @@
|
|
546
607
|
// node_modules/debounce/index.js
|
547
608
|
var require_debounce = __commonJS({
|
548
609
|
"node_modules/debounce/index.js"(exports, module) {
|
549
|
-
function
|
610
|
+
function debounce3(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;
|
@@ -592,16 +653,16 @@
|
|
592
653
|
};
|
593
654
|
return debounced;
|
594
655
|
}
|
595
|
-
|
596
|
-
module.exports =
|
656
|
+
debounce3.debounce = debounce3;
|
657
|
+
module.exports = debounce3;
|
597
658
|
}
|
598
659
|
});
|
599
660
|
|
600
661
|
// app/javascript/hotwire-livereload.js
|
601
|
-
var import_actioncable =
|
662
|
+
var import_actioncable = __toESM(require_action_cable());
|
602
663
|
|
603
664
|
// app/javascript/lib/hotwire-livereload-received.js
|
604
|
-
var import_debounce =
|
665
|
+
var import_debounce = __toESM(require_debounce());
|
605
666
|
var hotwire_livereload_received_default = (0, import_debounce.default)(({ force_reload }) => {
|
606
667
|
const onErrorPage = document.title === "Action Controller: Exception caught";
|
607
668
|
if (onErrorPage || force_reload) {
|
@@ -613,7 +674,30 @@
|
|
613
674
|
}
|
614
675
|
}, 300);
|
615
676
|
|
677
|
+
// app/javascript/lib/hotwire-livereload-scroll-position.js
|
678
|
+
var KEY = "hotwire-livereload-scrollPosition";
|
679
|
+
function read() {
|
680
|
+
const value = localStorage.getItem(KEY);
|
681
|
+
if (!value)
|
682
|
+
return 0;
|
683
|
+
return parseInt(value);
|
684
|
+
}
|
685
|
+
function save() {
|
686
|
+
const pos = window.scrollY;
|
687
|
+
localStorage.setItem(KEY, pos.toString());
|
688
|
+
}
|
689
|
+
function reset() {
|
690
|
+
localStorage.setItem(KEY, "0");
|
691
|
+
}
|
692
|
+
function restore() {
|
693
|
+
const value = read();
|
694
|
+
console.log("[Hotwire::Livereload] Restoring scroll position to", value);
|
695
|
+
window.scrollTo(0, value);
|
696
|
+
}
|
697
|
+
var hotwire_livereload_scroll_position_default = { read, save, restore, reset };
|
698
|
+
|
616
699
|
// app/javascript/hotwire-livereload.js
|
700
|
+
var import_debounce2 = __toESM(require_debounce());
|
617
701
|
var consumer = (0, import_actioncable.createConsumer)();
|
618
702
|
consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
619
703
|
received: hotwire_livereload_received_default,
|
@@ -624,4 +708,19 @@
|
|
624
708
|
console.log("[Hotwire::Livereload] Websocket disconnected");
|
625
709
|
}
|
626
710
|
});
|
711
|
+
var debouncedScroll = (0, import_debounce2.default)(() => {
|
712
|
+
if (window.scrollY !== 0)
|
713
|
+
return hotwire_livereload_scroll_position_default.save();
|
714
|
+
setTimeout(() => {
|
715
|
+
if (window.scrollY !== 0)
|
716
|
+
return;
|
717
|
+
hotwire_livereload_scroll_position_default.save();
|
718
|
+
}, 1e3);
|
719
|
+
}, 100);
|
720
|
+
window.addEventListener("scroll", debouncedScroll);
|
721
|
+
document.addEventListener("turbo:click", hotwire_livereload_scroll_position_default.reset);
|
722
|
+
document.addEventListener("turbo:before-visit", hotwire_livereload_scroll_position_default.restore);
|
723
|
+
document.addEventListener("turbo:load", hotwire_livereload_scroll_position_default.restore);
|
724
|
+
document.addEventListener("DOMContentLoaded", hotwire_livereload_scroll_position_default.restore);
|
725
|
+
document.addEventListener("turbo:frame-load", hotwire_livereload_scroll_position_default.restore);
|
627
726
|
})();
|
@@ -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,7 @@
|
|
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"
|
4
|
+
import debounce from "debounce"
|
3
5
|
|
4
6
|
const consumer = createConsumer()
|
5
7
|
consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
@@ -13,3 +15,22 @@ consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
|
13
15
|
console.log("[Hotwire::Livereload] Websocket disconnected")
|
14
16
|
},
|
15
17
|
})
|
18
|
+
|
19
|
+
const debouncedScroll = debounce(() => {
|
20
|
+
if (window.scrollY !== 0) return scrollPosition.save();
|
21
|
+
|
22
|
+
// On a second update, the page mysteriously jumps to the top and sends a scroll event.
|
23
|
+
// So we wait a bit and if the page is still is at the top, it was likely on purpose.
|
24
|
+
setTimeout(() => {
|
25
|
+
if (window.scrollY !== 0) return;
|
26
|
+
scrollPosition.save();
|
27
|
+
}, 1000);
|
28
|
+
}, 100)
|
29
|
+
window.addEventListener("scroll", debouncedScroll)
|
30
|
+
|
31
|
+
document.addEventListener("turbo:click", scrollPosition.reset)
|
32
|
+
document.addEventListener("turbo:before-visit", scrollPosition.restore)
|
33
|
+
document.addEventListener("turbo:load", scrollPosition.restore)
|
34
|
+
document.addEventListener("DOMContentLoaded", scrollPosition.restore)
|
35
|
+
document.addEventListener("turbo:frame-load", scrollPosition.restore)
|
36
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
const KEY = "hotwire-livereload-scrollPosition"
|
2
|
+
|
3
|
+
export function read() {
|
4
|
+
const value = localStorage.getItem(KEY)
|
5
|
+
if (!value) return 0;
|
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 reset() {
|
15
|
+
localStorage.setItem(KEY, "0");
|
16
|
+
}
|
17
|
+
|
18
|
+
export function restore() {
|
19
|
+
const value = read()
|
20
|
+
console.log("[Hotwire::Livereload] Restoring scroll position to", value)
|
21
|
+
window.scrollTo(0, value)
|
22
|
+
}
|
23
|
+
|
24
|
+
export default { read, save, restore, reset }
|
@@ -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
|
|
@@ -53,9 +64,9 @@ module Hotwire
|
|
53
64
|
force_reload_paths = options.force_reload_paths.map(&:to_s).uniq.join("|")
|
54
65
|
|
55
66
|
@listener = Listen.to(*listen_paths) do |modified, added, removed|
|
56
|
-
unless File.
|
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.0
|
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: 2023-10-11 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.
|