[UEPR-546] Make library asset host configurable - #679
Open
adzhindzhi wants to merge 1 commit into
Open
Conversation
|
I presume "other platforms" includes the NGP? 👀 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes Scratch GUI’s library thumbnail asset URLs configurable by delegating URL construction to the active GUIStorage implementation, while preserving the current cdn.assets.scratch.mit.edu behavior as the default to avoid regressions.
Changes:
- Adds optional
getLibraryAssetUrl(assetId, dataFormat)to theGUIStoragecontract (+ PropTypes) to allow custom storage implementations to control library asset addressing. - Introduces
buildLibraryAssetUrlas the default/fallback URL builder that targets the legacy Scratch asset host. - Plumbs
storagefrom Redux config into library containers andLibraryComponent, replacing hardcoded thumbnail URLs with storage-driven URL construction.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/scratch-gui/src/lib/legacy-storage.ts | Implements getLibraryAssetUrl on legacy storage to preserve the current legacy asset-service URL behavior by default. |
| packages/scratch-gui/src/lib/legacy-library-asset-url.ts | Adds a shared helper to build legacy (or provided-host) library asset URLs in the Scratch asset-service shape. |
| packages/scratch-gui/src/gui-config.ts | Extends GUIStorage and GUIStoragePropType with optional getLibraryAssetUrl. |
| packages/scratch-gui/src/containers/sprite-library.jsx | Passes configured storage through to LibraryComponent so sprite thumbnails can use configurable URLs. |
| packages/scratch-gui/src/containers/costume-library.jsx | Passes configured storage through to LibraryComponent so costume thumbnails can use configurable URLs. |
| packages/scratch-gui/src/containers/backdrop-library.jsx | Passes configured storage through to LibraryComponent so backdrop thumbnails can use configurable URLs. |
| packages/scratch-gui/src/components/library/library.jsx | Replaces hardcoded CDN thumbnail URLs with a storage-aware getLibraryAssetUrl fallbacking to the legacy host. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+12
to
+17
| export const buildLibraryAssetUrl = (assetId: string, dataFormat: string, host?: string): string => { | ||
| if (!host) { | ||
| return `${LEGACY_LIBRARY_ASSET_HOST}/internalapi/asset/${assetId}.${dataFormat}/get/`; | ||
| } | ||
| return `${host}/internalapi/asset/${assetId}.${dataFormat}/get/`; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves
UEPR-546
Proposed Changes
getLibraryAssetUrlmethod in theGUIStorageconfigurationReason for Changes
Library thumbnail URLs were hardcoded to
https://cdn.assets.scratch.mit.edu, making the asset host non-configurable for other platforms.