superglue 2.0.0.alpha.2 → 2.0.0.alpha.8

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: c623e4cdef9e492b0d0bbf70ff81eaecdf6b87afdd22ff9588ec662c74c5942a
4
- data.tar.gz: 85470818c873297c7a119dc0a7370ecedf0ac269082dfef1d663c33b44d695fe
3
+ metadata.gz: 3239bf29458613c97b65cba82454502a2f3aa7c7862b56fb6f7c35b93eaa52ae
4
+ data.tar.gz: c7a4f01902228e4509fcc53be51f5c242e4c4c8ee7d6fe8786220a920ce608a6
5
5
  SHA512:
6
- metadata.gz: 831982e9a9100f6a335b7d4e8f565facff1e65e6bfd3cb53290aeb905e7c60ed7ea6fe00b2975327f9b9fcb46591c556a4a73b90188634eccfd836145d083fa8
7
- data.tar.gz: d69bde09f1ed1d9665230104f61d238e4e30c22c3bf9d676d30c80e01274c2ba9a0dad64cbe3592725fa56dc8b6e8798c90b148c6f373924410c439ea497f25f
6
+ metadata.gz: 149bee1ac1801fef07d29e7cadecdb62a6c681e97b1711b0f33e9a196ea9cf8521803fdddf1dbeb1c8dfbd45224149dfe2451772846ba0fd22f5beacb6151148
7
+ data.tar.gz: 388e7ce6dbb46710b12011ea38bfd8367b9961e300524f3a86eea53bf9e29c581616eebb92683d1bb0d5672ebb426bade3168c8276b1bbf06a9ba942cff7c1bb
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  module Superglue::Streams::Broadcasts
2
5
  def broadcast_save_to(*streamables, **opts)
3
6
  broadcast_action_to(*streamables, action: :save, **opts)
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  module Superglue::Streams::StreamName
2
5
  def verified_stream_name(signed_stream_name)
3
6
  Superglue.signed_stream_verifier.verified signed_stream_name
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  class Superglue::StreamsChannel < ActionCable::Channel::Base
2
5
  extend Superglue::Streams::StreamName
3
6
  extend Superglue::Streams::Broadcasts
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  module Superglue::RequestIdTracking
2
5
  extend ActiveSupport::Concern
3
6
 
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  module Superglue::StreamsHelper
2
5
  def stream_from_props(*streamables, **attributes)
3
6
  raise ArgumentError, "streamables can't be blank" unless streamables.any?(&:present?)
@@ -33,7 +36,7 @@ module Superglue::StreamsHelper
33
36
  broadcast_action_props(action: "append", model:, target:, options:, **rendering)
34
37
  end
35
38
 
36
- def broadcast_save_props(model: nil, partial: nil, target: nil, options: {}, **rendering)
39
+ def broadcast_save_props(model: nil, target: nil, options: {}, **rendering)
37
40
  if model && !target
38
41
  target = fragment_id(model)
39
42
  end
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  class Superglue::Streams::ActionBroadcastJob < ActiveJob::Base
2
5
  discard_on ActiveJob::DeserializationError
3
6
 
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  class Superglue::Streams::BroadcastStreamJob < ActiveJob::Base
2
5
  discard_on ActiveJob::DeserializationError
3
6
 
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  module Superglue::Broadcastable
2
5
  extend ActiveSupport::Concern
3
6
 
@@ -129,7 +132,7 @@ module Superglue::Broadcastable
129
132
  def broadcast_target_default
130
133
  self.class.broadcast_target_default
131
134
  end
132
-
135
+
133
136
  private
134
137
 
135
138
  def extract_options_and_add_target(rendering = {}, target: broadcast_target_default)
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  class Superglue::Debouncer
2
5
  attr_reader :delay, :scheduled_task
3
6
 
@@ -1,3 +1,6 @@
1
+ # This file was ported from the amazing folks at turbo-rails
2
+ # You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
3
+
1
4
  class Superglue::ThreadDebouncer
2
5
  delegate :wait, to: :debouncer
3
6
 
@@ -40,7 +40,7 @@ module Superglue
40
40
  insert_jsx_rendering_defaults
41
41
 
42
42
  say "Installing Superglue and friends"
43
- run "yarn add react react-dom @reduxjs/toolkit react-redux @thoughtbot/superglue@2.0.0-alpha.2"
43
+ run "yarn add react react-dom @reduxjs/toolkit react-redux @thoughtbot/superglue@2.0.0-alpha.8"
44
44
 
45
45
  if use_typescript
46
46
  run "yarn add -D @types/react-dom @types/react @types/node @thoughtbot/candy_wrapper"
@@ -16,6 +16,8 @@ end
16
16
  if path
17
17
  json.action 'graft'
18
18
  json.path params[:props_at]
19
+ else
20
+ json.action 'savePage'
19
21
  end
20
22
 
21
23
  json.restoreStrategy 'fromCacheAndRevisitInBackground'
@@ -5,7 +5,7 @@ import { buildVisitAndRemote } from "./application_visit"
5
5
  import { pageIdentifierToPageComponent } from "./page_to_page_mapping"
6
6
  import { store } from "./store"
7
7
 
8
- if (typeof window !== "undefined") {
8
+ if (typeof window !== "undefined" && window.SUPERGLUE_INITIAL_PAGE_STATE) {
9
9
  document.addEventListener("DOMContentLoaded", function() {
10
10
  const appEl = document.getElementById("app")
11
11
  const location = window.location
@@ -9,7 +9,7 @@ import { visit, remote } from "@thoughtbot/superglue/action_creators"
9
9
  * bar. This file also adds support for data-sg-remote.
10
10
  */
11
11
  export const buildVisitAndRemote = (ref, store) => {
12
- const appRemote = (path, { dataset, ...options }) => {
12
+ const appRemote = (path, { dataset, ...options } = {}) => {
13
13
  /**
14
14
  * You can make use of `dataset` to add custom UJS options.
15
15
  * If you are implementing a progress bar, you can selectively
@@ -8,7 +8,7 @@ import {
8
8
  rootReducer
9
9
  } from "@thoughtbot/superglue"
10
10
 
11
- const { pages, superglue } = rootReducer
11
+ const { pages, superglue, fragments } = rootReducer
12
12
 
13
13
  export const store = configureStore({
14
14
  devTools: process.env.NODE_ENV !== "production",
@@ -21,7 +21,8 @@ export const store = configureStore({
21
21
  reducer: {
22
22
  superglue,
23
23
  pages,
24
- flash: flashSlice.reducer
24
+ flash: flashSlice.reducer,
25
+ fragments,
25
26
  }
26
27
  })
27
28
 
@@ -1,15 +1,17 @@
1
- import React from 'react';
2
- import { createRoot } from 'react-dom/client';
3
- import { Application, VisitResponse } from '@thoughtbot/superglue';
4
- import { buildVisitAndRemote } from './application_visit';
5
- import { pageIdentifierToPageComponent } from './page_to_page_mapping';
6
- import { store } from './store'
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { Application, SaveResponse } from "@thoughtbot/superglue";
4
+ import { buildVisitAndRemote } from "./application_visit";
5
+ import { pageIdentifierToPageComponent } from "./page_to_page_mapping";
6
+ import { store } from "./store";
7
7
 
8
8
  declare global {
9
- interface Window { SUPERGLUE_INITIAL_PAGE_STATE: VisitResponse; }
9
+ interface Window {
10
+ SUPERGLUE_INITIAL_PAGE_STATE: SaveResponse;
11
+ }
10
12
  }
11
13
 
12
- if (typeof window !== "undefined") {
14
+ if (typeof window !== "undefined" && window.SUPERGLUE_INITIAL_PAGE_STATE) {
13
15
  document.addEventListener("DOMContentLoaded", function () {
14
16
  const appEl = document.getElementById("app");
15
17
  const location = window.location;
@@ -37,4 +39,3 @@ if (typeof window !== "undefined") {
37
39
  }
38
40
  });
39
41
  }
40
-
@@ -18,7 +18,7 @@ export const buildVisitAndRemote: BuildVisitAndRemote = (
18
18
  ref,
19
19
  store: SuperglueStore
20
20
  ) => {
21
- const appRemote: ApplicationRemote = (path, { dataset, ...options }) => {
21
+ const appRemote: ApplicationRemote = (path, { dataset, ...options } = {}) => {
22
22
  /**
23
23
  * You can make use of `dataset` to add custom UJS options.
24
24
  * If you are implementing a progress bar, you can selectively
@@ -8,7 +8,7 @@ import {
8
8
  rootReducer,
9
9
  } from "@thoughtbot/superglue";
10
10
 
11
- const { pages, superglue } = rootReducer;
11
+ const { pages, superglue, fragments } = rootReducer;
12
12
 
13
13
  export const store = configureStore({
14
14
  devTools: process.env.NODE_ENV !== "production",
@@ -22,6 +22,7 @@ export const store = configureStore({
22
22
  superglue,
23
23
  pages,
24
24
  flash: flashSlice.reducer,
25
+ fragments,
25
26
  },
26
27
  });
27
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superglue
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha.2
4
+ version: 2.0.0.alpha.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johny Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-11 00:00:00.000000000 Z
11
+ date: 2025-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack