active_storage-async_variants-ui 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 279f3c8402b7c582403983ff679ecf6fead34d5a90e72f8952f27647ce9f1a5b
4
- data.tar.gz: d931c539a3661e61c0f9fa20a144d399f8f10910169fb5aed75206cdda09c99a
3
+ metadata.gz: e005a7ad73b45c7f8d6e7ede189bb0aa1e17a295d7ca68096ba745a3e8dfa264
4
+ data.tar.gz: 4da955bf3e81bdd833602160fc8508f79c3d05c159ec6229ffb241254df1894e
5
5
  SHA512:
6
- metadata.gz: b58f2d6f42a0122f79ea9d1c831cd53476353be2f2a98666bd0983919343a92dd20b4045c6803246ddc458aaa9e912412eee3baa5362d7fb446a418abdc206e8
7
- data.tar.gz: 5e6a2837652e6e17388f3abf00e22a087ebe1cb6ca5e7d383e6a8a2a1d43f7f800ac78a05541cb91ecf95692bcbfa6a843b730842719588abc7dff6d92c282d7
6
+ metadata.gz: 98a2bc9515eb63b696f92936673124ecd33234f924c7b8fc00741da28ab5e1d5aad21923565645e1be0c042f42c57e5b7930af2845b46deddd215f2cb392a647
7
+ data.tar.gz: 8bc97a17fd4641e9c4824c768f2fb72e23c247014e906d6279f15e750a60337a16d20d1d6ece692588494f213bd8520aaf9b76e5f7a2d7d7e5837702b5be8691
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.2.0]
2
+
3
+ - Video previews on the stock preview graph: a video's image variant keeps its record on the extracted-frame blob (`preview_image`), so the state endpoint now rebuilds a `Preview` (via a `repr=preview` param the helper round-trips) and reads state, progress, and the processed URL from there. Format-bearing variations are canonicalized to the declared named variant so a URL-rebuilt digest matches the stored record.
4
+ - Retry goes through the representation's `retry!`, so a video preview's failed record on the frame blob is actually replaced; previously the endpoint searched the source blob with the wrong digest and retry silently did nothing for videos.
5
+ - Fix: the failed state's retry form now carries `repr`, so retrying a video preview replaces its frame record instead of recording a stray variant on the video blob.
6
+ - Requires `active_storage-async_variants` >= 0.10. Hand `image_tag`/`video_tag` a video's `representation(...)` (a `Preview`), not its `variant(...)`, while it is unprocessed.
7
+
1
8
  ## [0.1.0]
2
9
 
3
10
  - Initial release. Extracted from `active_storage-async_variants` (≤ 0.8.0), which now ships the UI-free plumbing. This gem layers on the opinionated UI:
@@ -26,17 +26,14 @@ module ActiveStorage
26
26
  end
27
27
 
28
28
  def retry
29
- @variant.blob.variant_records.where(
30
- variation_digest: @variant.variation.digest,
31
- state: "failed",
32
- ).destroy_all
33
- @variant.enqueue!
29
+ @variant.retry!
34
30
 
35
31
  redirect_to Rails.application.routes.url_helpers.async_variant_state_path(
36
32
  signed_blob_id: params[:signed_blob_id],
37
33
  variation_key: params[:variation_key],
38
34
  kind: params[:kind],
39
35
  direct: params[:direct],
36
+ repr: params[:repr],
40
37
  opts: async_variant_html_options.presence,
41
38
  ), status: :see_other
42
39
  end
@@ -47,12 +44,29 @@ module ActiveStorage
47
44
 
48
45
  def set_variant
49
46
  blob = ActiveStorage::Blob.find_signed!(params[:signed_blob_id])
50
- variation = ActiveStorage::Variation.decode(params[:variation_key])
51
- @variant = blob.variant(variation)
47
+ variation = canonical_variation(blob, ActiveStorage::Variation.decode(params[:variation_key]))
48
+ # A video's image preview keeps its variant record on the extracted-frame
49
+ # blob, so rebuild it as a Preview to read state from the right place;
50
+ # everything else is a plain Variant. The helper round-trips which one
51
+ # via the `repr` param.
52
+ @variant = params[:repr] == "preview" ? blob.preview(variation) : blob.variant(variation)
52
53
  rescue ActiveSupport::MessageVerifier::InvalidSignature
53
54
  head :not_found
54
55
  end
55
56
 
57
+ # The URL key round-trips a declared variant's transformations to strings
58
+ # (format: :webp -> "webp"), which Marshal-digests differently from the
59
+ # symbol form the variant record was created with -- so the record lookup
60
+ # would miss. Recover the declared transformations (symbol-preserving) when
61
+ # this variation matches a named variant; NamedVariantScan is itself
62
+ # format-string/symbol tolerant.
63
+ def canonical_variation(blob, variation)
64
+ found = ActiveStorage::AsyncVariants::NamedVariantScan.find(blob, variation)
65
+ return variation unless found
66
+ attachment, name, _ = found
67
+ ActiveStorage::Variation.wrap(attachment.send(:named_variants)[name].transformations)
68
+ end
69
+
56
70
  def async_variant_kind
57
71
  params[:kind].to_s == "video" ? :video : :image
58
72
  end
@@ -16,7 +16,7 @@
16
16
  </style>
17
17
  <%# In the light DOM so its submit reaches Turbo, and so preventDefault on the
18
18
  buttons doesn't also cancel the submit. %>
19
- <form action="<%= Rails.application.routes.url_helpers.async_variant_state_retry_path(signed_blob_id:, variation_key:, kind:, direct:, opts: html_options) %>"
19
+ <form action="<%= Rails.application.routes.url_helpers.async_variant_state_retry_path(signed_blob_id:, variation_key:, kind:, direct:, repr:, opts: html_options) %>"
20
20
  method="post"
21
21
  id="<%= form_id %>"
22
22
  data-turbo-frame="<%= async_variant_frame_id(variant) %>"
@@ -6,5 +6,6 @@
6
6
  direct: async_variant_direct?,
7
7
  signed_blob_id: params[:signed_blob_id],
8
8
  variation_key: params[:variation_key],
9
+ repr: params[:repr],
9
10
  } %>
10
11
  <% end %>
@@ -56,6 +56,11 @@ module ActiveStorage
56
56
  variation_key: variant.variation.key,
57
57
  kind:,
58
58
  direct:,
59
+ # Preserve which representation the caller passed: a video's image
60
+ # preview keeps its variant record on the extracted-frame blob, so the
61
+ # state endpoint must rebuild it as a Preview (blob.preview), not a
62
+ # Variant (blob.variant) -- otherwise it reads state off the wrong blob.
63
+ repr: variant.is_a?(ActiveStorage::Preview) ? "preview" : "variant",
59
64
  opts: html_options.slice(*PASS_THROUGH_HTML_OPTIONS),
60
65
  )
61
66
  end
@@ -3,7 +3,7 @@
3
3
  module ActiveStorage
4
4
  module AsyncVariants
5
5
  module UI
6
- VERSION = "0.1.0"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage-async_variants-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-06-10 00:00:00.000000000 Z
10
+ date: 2026-11-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: active_storage-async_variants
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '0.9'
18
+ version: '0.10'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '0.9'
25
+ version: '0.10'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: turbo-rails
28
28
  requirement: !ruby/object:Gem::Requirement