Skip to content

feat(ImageCropper): support static asset fingerprint - #1160

Merged
ArgoZhang merged 3 commits into
masterfrom
feat-image-fingerprint
Oct 7, 2026
Merged

ArgoZhang merged 3 commits into
masterfrom
feat-image-fingerprint

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1159

Summary By Copilot

ImageCropper loaded cropper.bundle.css from a hard-coded _content URL, so the browser kept serving the stale stylesheet after a package upgrade. The stylesheet URL is now passed to JavaScript through the init options and resolved with the Assets fingerprint helper on .NET 9+, which appends the content hash as a query string. Earlier target frameworks keep the plain path, and the JavaScript side now takes the URL from options.styleUrl instead of embedding it. The element null check moved ahead of the stylesheet load so a missing container no longer triggers an extra request.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Only the stylesheet URL source changed. The markup, component parameters, and public API are untouched, and the non-fingerprint path is preserved for frameworks below .NET 9.

Verification

  • Manual (required)
  • Automated

dotnet build ./src/components/BootstrapBlazor.ImageCropper/BootstrapBlazor.ImageCropper.csproj -c Debug succeeded for all five target frameworks (net6.0/net7.0/net8.0/net9.0/net10.0) with 0 warnings and 0 errors.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Enable cache-busted loading of the ImageCropper stylesheet while preserving compatibility with earlier target frameworks.

New Features:

  • Support fingerprinted ImageCropper stylesheets on .NET 9 and later to prevent stale asset caching.

Bug Fixes:

  • Avoid loading the cropper stylesheet when the target ImageCropper element is missing.

Enhancements:

  • Pass the resolved stylesheet URL through ImageCropper initialization options while preserving the unfingerprinted path on earlier target frameworks.

Build:

  • Update ImageCropper project configuration to support the asset fingerprinting changes.

Chores:

  • Update repository ignore rules.

- pass cropper.bundle.css url to JS via options.styleUrl
- resolve url with Assets helper on .NET 9+ to enable cache busting
- replace hard-coded path in addLink call
@bb-auto bb-auto Bot added the enhancement New feature or request label Oct 7, 2026
@bb-auto bb-auto Bot added this to the v10.0.0 milestone Oct 7, 2026
bb-auto[bot]
bb-auto Bot previously approved these changes Oct 7, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@sourcery-ai

sourcery-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The ImageCropper now supplies its stylesheet URL from .NET initialization, using fingerprinted static asset resolution on .NET 9+ and the existing unversioned path on earlier frameworks; JavaScript consumes that URL after confirming the target element exists.

Sequence diagram for fingerprinted ImageCropper stylesheet loading

sequenceDiagram
    participant Component as ImageCropper
    participant Assets as Assets helper
    participant JS as ImageCropper JavaScript
    participant DOM as Browser DOM
    participant CSS as cropper.bundle.css

    Component->>Assets: Assets[CropperStylePath]
    Assets-->>Component: Fingerprinted styleUrl
    Component->>JS: init(id, invoke, options)
    JS->>DOM: getElementById(id)
    alt target element exists
        JS->>CSS: addLink(styleUrl)
        CSS-->>DOM: Load stylesheet
    else target element missing
        JS-->>Component: return
    end
Loading

File-Level Changes

Change Details Files
Resolve the cropper stylesheet through the framework asset fingerprinting mechanism when available, while preserving the existing path on older target frameworks.
  • Define the shared static asset path.
  • Use the .NET 9+ Assets helper to append the fingerprint; retain the plain URL for earlier frameworks.
  • Pass the resolved stylesheet URL through the JavaScript initialization options.
src/components/BootstrapBlazor.ImageCropper/ImageCropper.razor.cs
Make stylesheet loading use the initialization-provided URL and avoid requests when the target element is missing.
  • Move the element existence check before stylesheet loading.
  • Read styleUrl from options and load it instead of a hard-coded URL.
src/components/BootstrapBlazor.ImageCropper/ImageCropper.razor.js

Assessment against linked issues

Issue Objective Addressed Explanation
#1159 Pass the ImageCropper stylesheet URL from .NET to JavaScript instead of hard-coding the asset path in JavaScript. ✅
#1159 Resolve the stylesheet URL through the .NET 9+ Assets fingerprint helper so upgraded packages receive a cache-busting content hash, while preserving the unfingerprinted path on earlier target frameworks. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

bb-auto[bot]
bb-auto Bot previously approved these changes Oct 7, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/components/BootstrapBlazor.ImageCropper/ImageCropper.razor.js" line_range="13" />
<code_context>
     const image = el.querySelector(".bb-cropper-image");
-    const { options: op, triggerOnCropEndAsync } = options;
+    const { options: op, triggerOnCropEndAsync, styleUrl } = options;
+    await addLink(styleUrl);
     if (triggerOnCropEndAsync) {
         let cropData = null;
</code_context>
<issue_to_address>
**Removed components retain croppers**

When the component is removed and `dispose(id)` runs while `addLink(styleUrl)` is pending, `dispose(id)` finds no `Data` entry while `addLink(styleUrl)` is pending; `init` then resumes, creates a `Cropper` for the detached element, and stores it in `Data`, retaining the removed component and allowing callbacks through its disposed interop reference.

After `addLink` resolves, have `init` check whether the component was disposed and abort before creating or storing the cropper.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/components/BootstrapBlazor.ImageCropper/ImageCropper.razor.js

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit 2bf225d into master Oct 7, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the feat-image-fingerprint branch October 7, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ImageCropper): support static asset fingerprint

1 participant