turbo-rails 0.7.13 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 580519d63f8208480ca58ba6a406d3b8d012365af8e96768a447ad1848576d0d
4
- data.tar.gz: e12f497a997e28c2850a8bb2d2731717a97d82d3e46fea0d3b35829190b3fd4e
3
+ metadata.gz: c262e76eb847e212773e7befcc963473e87b06f2bf01eefdff938cff52eb1779
4
+ data.tar.gz: ced8870cfb3301bcd13b551f47bf327400780e9a72844547a482ff3207ca4481
5
5
  SHA512:
6
- metadata.gz: b8c233bab026cd81eaeebe394e92cd19d217e08f2dce28e0cfbc3f6490c8536e833bdb70db2f3056da82f3a61253d97da13881dc82de48dfe23e106eb48cb7dc
7
- data.tar.gz: 67df314bd48116ff91f246f212ca3775361a9a18cce54842e5f19d00f465eadee3f500269288d49c200ed6414b83873d53ff32eb46d0cb8a99dd12c658716923
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(Event.prototype, "submitter", {
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
- void (target || document.documentElement).dispatchEvent(event);
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
- if (event.target instanceof HTMLFormElement) {
734
- const form = event.target;
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
- uncomment_lines "Gemfile", /gem ['"]redis['"]/
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"
@@ -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", __dir__)}"
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
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "0.7.13"
2
+ VERSION = "0.8.1"
3
3
  end
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.7.13
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-16 00:00:00.000000000 Z
13
+ date: 2021-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails