hotwire-livereload 1.4.0 → 1.4.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b3a325fa089d62215f26cf3fbac951e3ac91d0b03af7aed02fa2a49075969e
|
4
|
+
data.tar.gz: 24e7339a71da29f35b1930f95f18f0c035aa0221b411fe4a58f27d10384dbb76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01e7cc071040c5fbafa3fac11adcdfff171695a82c6d6d90db06c8d2010032beb4172ae667b029512737c0afb79c005bcd2e54084661ff662bbae28157087a68
|
7
|
+
data.tar.gz: 41e86aa960b2796d65aa26e1d8034a819e5ecdfea578b5995e275f713d666f9b4ffd6a9c6337a6bf17834394ac194382aa2ddf9ff74843fb0f7644ed20bfd2fa
|
@@ -396,19 +396,19 @@
|
|
396
396
|
this.subscriptions = subscriptions;
|
397
397
|
this.pendingSubscriptions = [];
|
398
398
|
}
|
399
|
-
SubscriptionGuarantor2.prototype.guarantee = function guarantee(
|
400
|
-
if (this.pendingSubscriptions.indexOf(
|
401
|
-
logger.log("SubscriptionGuarantor guaranteeing " +
|
402
|
-
this.pendingSubscriptions.push(
|
399
|
+
SubscriptionGuarantor2.prototype.guarantee = function guarantee(subscription2) {
|
400
|
+
if (this.pendingSubscriptions.indexOf(subscription2) == -1) {
|
401
|
+
logger.log("SubscriptionGuarantor guaranteeing " + subscription2.identifier);
|
402
|
+
this.pendingSubscriptions.push(subscription2);
|
403
403
|
} else {
|
404
|
-
logger.log("SubscriptionGuarantor already guaranteeing " +
|
404
|
+
logger.log("SubscriptionGuarantor already guaranteeing " + subscription2.identifier);
|
405
405
|
}
|
406
406
|
this.startGuaranteeing();
|
407
407
|
};
|
408
|
-
SubscriptionGuarantor2.prototype.forget = function forget(
|
409
|
-
logger.log("SubscriptionGuarantor forgetting " +
|
408
|
+
SubscriptionGuarantor2.prototype.forget = function forget(subscription2) {
|
409
|
+
logger.log("SubscriptionGuarantor forgetting " + subscription2.identifier);
|
410
410
|
this.pendingSubscriptions = this.pendingSubscriptions.filter(function(s) {
|
411
|
-
return s !==
|
411
|
+
return s !== subscription2;
|
412
412
|
});
|
413
413
|
};
|
414
414
|
SubscriptionGuarantor2.prototype.startGuaranteeing = function startGuaranteeing() {
|
@@ -422,9 +422,9 @@
|
|
422
422
|
var _this = this;
|
423
423
|
this.retryTimeout = setTimeout(function() {
|
424
424
|
if (_this.subscriptions && typeof _this.subscriptions.subscribe === "function") {
|
425
|
-
_this.pendingSubscriptions.map(function(
|
426
|
-
logger.log("SubscriptionGuarantor resubscribing " +
|
427
|
-
_this.subscriptions.subscribe(
|
425
|
+
_this.pendingSubscriptions.map(function(subscription2) {
|
426
|
+
logger.log("SubscriptionGuarantor resubscribing " + subscription2.identifier);
|
427
|
+
_this.subscriptions.subscribe(subscription2);
|
428
428
|
});
|
429
429
|
}
|
430
430
|
}, 500);
|
@@ -443,37 +443,37 @@
|
|
443
443
|
var params = (typeof channel === "undefined" ? "undefined" : _typeof(channel)) === "object" ? channel : {
|
444
444
|
channel
|
445
445
|
};
|
446
|
-
var
|
447
|
-
return this.add(
|
446
|
+
var subscription2 = new Subscription(this.consumer, params, mixin);
|
447
|
+
return this.add(subscription2);
|
448
448
|
};
|
449
|
-
Subscriptions2.prototype.add = function add(
|
450
|
-
this.subscriptions.push(
|
449
|
+
Subscriptions2.prototype.add = function add(subscription2) {
|
450
|
+
this.subscriptions.push(subscription2);
|
451
451
|
this.consumer.ensureActiveConnection();
|
452
|
-
this.notify(
|
453
|
-
this.subscribe(
|
454
|
-
return
|
455
|
-
};
|
456
|
-
Subscriptions2.prototype.remove = function remove2(
|
457
|
-
this.forget(
|
458
|
-
if (!this.findAll(
|
459
|
-
this.sendCommand(
|
452
|
+
this.notify(subscription2, "initialized");
|
453
|
+
this.subscribe(subscription2);
|
454
|
+
return subscription2;
|
455
|
+
};
|
456
|
+
Subscriptions2.prototype.remove = function remove2(subscription2) {
|
457
|
+
this.forget(subscription2);
|
458
|
+
if (!this.findAll(subscription2.identifier).length) {
|
459
|
+
this.sendCommand(subscription2, "unsubscribe");
|
460
460
|
}
|
461
|
-
return
|
461
|
+
return subscription2;
|
462
462
|
};
|
463
463
|
Subscriptions2.prototype.reject = function reject(identifier) {
|
464
464
|
var _this = this;
|
465
|
-
return this.findAll(identifier).map(function(
|
466
|
-
_this.forget(
|
467
|
-
_this.notify(
|
468
|
-
return
|
465
|
+
return this.findAll(identifier).map(function(subscription2) {
|
466
|
+
_this.forget(subscription2);
|
467
|
+
_this.notify(subscription2, "rejected");
|
468
|
+
return subscription2;
|
469
469
|
});
|
470
470
|
};
|
471
|
-
Subscriptions2.prototype.forget = function forget(
|
472
|
-
this.guarantor.forget(
|
471
|
+
Subscriptions2.prototype.forget = function forget(subscription2) {
|
472
|
+
this.guarantor.forget(subscription2);
|
473
473
|
this.subscriptions = this.subscriptions.filter(function(s) {
|
474
|
-
return s !==
|
474
|
+
return s !== subscription2;
|
475
475
|
});
|
476
|
-
return
|
476
|
+
return subscription2;
|
477
477
|
};
|
478
478
|
Subscriptions2.prototype.findAll = function findAll(identifier) {
|
479
479
|
return this.subscriptions.filter(function(s) {
|
@@ -482,8 +482,8 @@
|
|
482
482
|
};
|
483
483
|
Subscriptions2.prototype.reload = function reload() {
|
484
484
|
var _this2 = this;
|
485
|
-
return this.subscriptions.map(function(
|
486
|
-
return _this2.subscribe(
|
485
|
+
return this.subscriptions.map(function(subscription2) {
|
486
|
+
return _this2.subscribe(subscription2);
|
487
487
|
});
|
488
488
|
};
|
489
489
|
Subscriptions2.prototype.notifyAll = function notifyAll(callbackName) {
|
@@ -491,38 +491,38 @@
|
|
491
491
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
492
492
|
args[_key - 1] = arguments[_key];
|
493
493
|
}
|
494
|
-
return this.subscriptions.map(function(
|
495
|
-
return _this3.notify.apply(_this3, [
|
494
|
+
return this.subscriptions.map(function(subscription2) {
|
495
|
+
return _this3.notify.apply(_this3, [subscription2, callbackName].concat(args));
|
496
496
|
});
|
497
497
|
};
|
498
|
-
Subscriptions2.prototype.notify = function notify(
|
498
|
+
Subscriptions2.prototype.notify = function notify(subscription2, callbackName) {
|
499
499
|
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
500
500
|
args[_key2 - 2] = arguments[_key2];
|
501
501
|
}
|
502
502
|
var subscriptions = void 0;
|
503
|
-
if (typeof
|
504
|
-
subscriptions = this.findAll(
|
503
|
+
if (typeof subscription2 === "string") {
|
504
|
+
subscriptions = this.findAll(subscription2);
|
505
505
|
} else {
|
506
|
-
subscriptions = [
|
506
|
+
subscriptions = [subscription2];
|
507
507
|
}
|
508
|
-
return subscriptions.map(function(
|
509
|
-
return typeof
|
508
|
+
return subscriptions.map(function(subscription3) {
|
509
|
+
return typeof subscription3[callbackName] === "function" ? subscription3[callbackName].apply(subscription3, args) : void 0;
|
510
510
|
});
|
511
511
|
};
|
512
|
-
Subscriptions2.prototype.subscribe = function subscribe(
|
513
|
-
if (this.sendCommand(
|
514
|
-
this.guarantor.guarantee(
|
512
|
+
Subscriptions2.prototype.subscribe = function subscribe(subscription2) {
|
513
|
+
if (this.sendCommand(subscription2, "subscribe")) {
|
514
|
+
this.guarantor.guarantee(subscription2);
|
515
515
|
}
|
516
516
|
};
|
517
517
|
Subscriptions2.prototype.confirmSubscription = function confirmSubscription(identifier) {
|
518
518
|
var _this4 = this;
|
519
519
|
logger.log("Subscription confirmed " + identifier);
|
520
|
-
this.findAll(identifier).map(function(
|
521
|
-
return _this4.guarantor.forget(
|
520
|
+
this.findAll(identifier).map(function(subscription2) {
|
521
|
+
return _this4.guarantor.forget(subscription2);
|
522
522
|
});
|
523
523
|
};
|
524
|
-
Subscriptions2.prototype.sendCommand = function sendCommand(
|
525
|
-
var identifier =
|
524
|
+
Subscriptions2.prototype.sendCommand = function sendCommand(subscription2, command) {
|
525
|
+
var identifier = subscription2.identifier;
|
526
526
|
return this.consumer.send({
|
527
527
|
command,
|
528
528
|
identifier
|
@@ -704,7 +704,8 @@
|
|
704
704
|
|
705
705
|
// app/javascript/hotwire-livereload.js
|
706
706
|
var consumer = (0, import_actioncable.createConsumer)();
|
707
|
-
|
707
|
+
var subscription = null;
|
708
|
+
var createSubscription = () => consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
708
709
|
received: hotwire_livereload_received_default,
|
709
710
|
connected() {
|
710
711
|
console.log("[Hotwire::Livereload] Websocket connected");
|
@@ -713,8 +714,14 @@
|
|
713
714
|
console.log("[Hotwire::Livereload] Websocket disconnected");
|
714
715
|
}
|
715
716
|
});
|
717
|
+
subscription = createSubscription();
|
716
718
|
document.addEventListener("turbo:load", () => {
|
717
719
|
hotwire_livereload_scroll_position_default.restore();
|
718
720
|
hotwire_livereload_scroll_position_default.remove();
|
721
|
+
if (subscription) {
|
722
|
+
consumer.subscriptions.remove(subscription);
|
723
|
+
subscription = null;
|
724
|
+
}
|
725
|
+
subscription = createSubscription();
|
719
726
|
});
|
720
727
|
})();
|
@@ -3,7 +3,9 @@ import received from "./lib/hotwire-livereload-received"
|
|
3
3
|
import scrollPosition from "./lib/hotwire-livereload-scroll-position"
|
4
4
|
|
5
5
|
const consumer = createConsumer()
|
6
|
-
|
6
|
+
let subscription = null
|
7
|
+
|
8
|
+
const createSubscription = () => consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
7
9
|
received,
|
8
10
|
|
9
11
|
connected() {
|
@@ -15,8 +17,16 @@ consumer.subscriptions.create("Hotwire::Livereload::ReloadChannel", {
|
|
15
17
|
},
|
16
18
|
})
|
17
19
|
|
20
|
+
subscription = createSubscription()
|
21
|
+
|
18
22
|
document.addEventListener("turbo:load", () => {
|
19
23
|
scrollPosition.restore()
|
20
24
|
scrollPosition.remove()
|
25
|
+
|
26
|
+
if (subscription) {
|
27
|
+
consumer.subscriptions.remove(subscription)
|
28
|
+
subscription = null
|
29
|
+
}
|
30
|
+
subscription = createSubscription()
|
21
31
|
})
|
22
32
|
|
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.4.
|
4
|
+
version: 1.4.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: 2024-
|
11
|
+
date: 2024-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|