turbo-rails 0.7.13 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/turbo.js +21 -9
- data/lib/install/turbo_needs_redis.rb +11 -1
- data/lib/tasks/turbo_tasks.rake +2 -2
- data/lib/turbo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c262e76eb847e212773e7befcc963473e87b06f2bf01eefdff938cff52eb1779
|
4
|
+
data.tar.gz: ced8870cfb3301bcd13b551f47bf327400780e9a72844547a482ff3207ca4481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ef07542ceea019544fc6ecc3598452c21122d271c5805d211f2d932d449dc9288d09adaaf9ffcc910ddb1ab2feb53174a39adf8e80515efbe61eb2fde4833d
|
7
|
+
data.tar.gz: 12685cf32b4aef76070124bb52705b508363f330d7e465e7466c3a727d07c8b0299c15f315297390b0561b6881d5310e4e60e656fe7fe1337f3cfa3fcd5f854c
|
@@ -30,10 +30,17 @@ function clickCaptured(event) {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
(function() {
|
33
|
-
if ("SubmitEvent" in window) return;
|
34
33
|
if ("submitter" in Event.prototype) return;
|
34
|
+
let prototype;
|
35
|
+
if ("SubmitEvent" in window && /Apple Computer/.test(navigator.vendor)) {
|
36
|
+
prototype = window.SubmitEvent.prototype;
|
37
|
+
} else if ("SubmitEvent" in window) {
|
38
|
+
return;
|
39
|
+
} else {
|
40
|
+
prototype = window.Event.prototype;
|
41
|
+
}
|
35
42
|
addEventListener("click", clickCaptured, true);
|
36
|
-
Object.defineProperty(
|
43
|
+
Object.defineProperty(prototype, "submitter", {
|
37
44
|
get() {
|
38
45
|
if (this.type == "submit" && this.target instanceof HTMLFormElement) {
|
39
46
|
return submittersByForm.get(this.target);
|
@@ -247,7 +254,11 @@ function dispatch(eventName, {target: target, cancelable: cancelable, detail: de
|
|
247
254
|
bubbles: true,
|
248
255
|
detail: detail
|
249
256
|
});
|
250
|
-
|
257
|
+
if (target && target.isConnected) {
|
258
|
+
target.dispatchEvent(event);
|
259
|
+
} else {
|
260
|
+
document.documentElement.dispatchEvent(event);
|
261
|
+
}
|
251
262
|
return event;
|
252
263
|
}
|
253
264
|
|
@@ -730,8 +741,8 @@ class Snapshot {
|
|
730
741
|
class FormInterceptor {
|
731
742
|
constructor(delegate, element) {
|
732
743
|
this.submitBubbled = event => {
|
733
|
-
|
734
|
-
|
744
|
+
const form = event.target;
|
745
|
+
if (form instanceof HTMLFormElement && form.closest("turbo-frame, html") == this.element) {
|
735
746
|
const submitter = event.submitter || undefined;
|
736
747
|
if (this.delegate.shouldInterceptFormSubmission(form, submitter)) {
|
737
748
|
event.preventDefault();
|
@@ -2556,6 +2567,7 @@ class Session {
|
|
2556
2567
|
const form = document.createElement("form");
|
2557
2568
|
form.method = linkMethod;
|
2558
2569
|
form.action = link.getAttribute("href") || "undefined";
|
2570
|
+
form.hidden = true;
|
2559
2571
|
(_a = link.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(form, link);
|
2560
2572
|
return dispatch("submit", {
|
2561
2573
|
cancelable: true,
|
@@ -2588,7 +2600,7 @@ class Session {
|
|
2588
2600
|
this.notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL);
|
2589
2601
|
}
|
2590
2602
|
willSubmitForm(form, submitter) {
|
2591
|
-
return this.elementDriveEnabled(form) && this.elementDriveEnabled(submitter);
|
2603
|
+
return this.elementDriveEnabled(form) && (!submitter || this.elementDriveEnabled(submitter));
|
2592
2604
|
}
|
2593
2605
|
formSubmitted(form, submitter) {
|
2594
2606
|
this.navigator.submitForm(form, submitter);
|
@@ -2747,7 +2759,7 @@ const deprecatedLocationPropertyDescriptors = {
|
|
2747
2759
|
|
2748
2760
|
const session = new Session;
|
2749
2761
|
|
2750
|
-
const {navigator: navigator} = session;
|
2762
|
+
const {navigator: navigator$1} = session;
|
2751
2763
|
|
2752
2764
|
function start() {
|
2753
2765
|
session.start();
|
@@ -2783,7 +2795,7 @@ function setProgressBarDelay(delay) {
|
|
2783
2795
|
|
2784
2796
|
var Turbo = Object.freeze({
|
2785
2797
|
__proto__: null,
|
2786
|
-
navigator: navigator,
|
2798
|
+
navigator: navigator$1,
|
2787
2799
|
session: session,
|
2788
2800
|
PageRenderer: PageRenderer,
|
2789
2801
|
PageSnapshot: PageSnapshot,
|
@@ -3258,7 +3270,7 @@ var turbo_es2017Esm = Object.freeze({
|
|
3258
3270
|
clearCache: clearCache,
|
3259
3271
|
connectStreamSource: connectStreamSource,
|
3260
3272
|
disconnectStreamSource: disconnectStreamSource,
|
3261
|
-
navigator: navigator,
|
3273
|
+
navigator: navigator$1,
|
3262
3274
|
registerAdapter: registerAdapter,
|
3263
3275
|
renderStreamMessage: renderStreamMessage,
|
3264
3276
|
session: session,
|
@@ -1,6 +1,16 @@
|
|
1
1
|
if (cable_config_path = Rails.root.join("config/cable.yml")).exist?
|
2
2
|
say "Enable redis in bundle"
|
3
|
-
|
3
|
+
|
4
|
+
gemfile_content = File.read(Rails.root.join("Gemfile"))
|
5
|
+
pattern = /gem ['"]redis['"]/
|
6
|
+
|
7
|
+
if gemfile_content.match?(pattern)
|
8
|
+
uncomment_lines "Gemfile", pattern
|
9
|
+
else
|
10
|
+
gem 'redis', '~> 4.0', comment: "Use Redis as Action Cable adapter instead of default Async. The Async adapter\ndoes not support Turbo Stream broadcasting."
|
11
|
+
end
|
12
|
+
|
13
|
+
run_bundle
|
4
14
|
|
5
15
|
say "Switch development cable to use redis"
|
6
16
|
gsub_file cable_config_path.to_s, /development:\n\s+adapter: async/, "development:\n adapter: redis\n url: redis://localhost:6379/1"
|
data/lib/tasks/turbo_tasks.rake
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
def run_turbo_install_template(path)
|
2
|
-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb",
|
2
|
+
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}"
|
3
3
|
end
|
4
4
|
|
5
5
|
def redis_installed?
|
6
|
-
system('which redis-server')
|
6
|
+
system('which redis-server > /dev/null')
|
7
7
|
end
|
8
8
|
|
9
9
|
def switch_on_redis_if_available
|
data/lib/turbo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-09-
|
13
|
+
date: 2021-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|