fix(engine): use resolve_embed for sibling theme assets
`AssetPath::resolve` concatenates, so manifest-relative SVG paths ended up under `…/theme.ron/<name>.svg` and the asset server reported all 53 references missing. `resolve_embed` is the RFC 1808 sibling-resolution method that strips the base path's last segment first, giving the intended `…/<name>.svg`. Default theme now loads cleanly from the embedded:// source. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,9 +35,9 @@ pub enum CardThemeLoaderError {
|
|||||||
Parse(#[from] ron::error::SpannedError),
|
Parse(#[from] ron::error::SpannedError),
|
||||||
#[error("manifest validation: {0}")]
|
#[error("manifest validation: {0}")]
|
||||||
Validation(#[from] ManifestError),
|
Validation(#[from] ManifestError),
|
||||||
/// `AssetPath::resolve` rejected a manifest-relative path. Almost
|
/// `AssetPath::resolve_embed` rejected a manifest-relative path.
|
||||||
/// always means the manifest contains an absolute path or a
|
/// Almost always means the manifest contains an absolute path or
|
||||||
/// surface that includes a custom asset source the manifest
|
/// a surface that includes a custom asset source the manifest
|
||||||
/// shouldn't be reaching across.
|
/// shouldn't be reaching across.
|
||||||
#[error("could not resolve asset path: {0}")]
|
#[error("could not resolve asset path: {0}")]
|
||||||
PathResolve(#[from] ParseAssetPathError),
|
PathResolve(#[from] ParseAssetPathError),
|
||||||
@@ -73,12 +73,18 @@ impl AssetLoader for CardThemeLoader {
|
|||||||
// it via `.loader()`.
|
// it via `.loader()`.
|
||||||
let manifest_path: AssetPath<'static> = load_context.path().clone();
|
let manifest_path: AssetPath<'static> = load_context.path().clone();
|
||||||
|
|
||||||
let back_path = manifest_path.resolve(&path_to_str(&manifest.back))?;
|
// `resolve_embed` is the RFC 1808 sibling-resolution method:
|
||||||
|
// the last segment of the base path (the manifest filename) is
|
||||||
|
// stripped before concatenation, so `themes/foo/theme.ron` +
|
||||||
|
// `hearts_4.svg` resolves to `themes/foo/hearts_4.svg`. Plain
|
||||||
|
// `resolve` would concatenate, giving `themes/foo/theme.ron/hearts_4.svg`,
|
||||||
|
// which is never what manifest-relative references mean.
|
||||||
|
let back_path = manifest_path.resolve_embed(&path_to_str(&manifest.back))?;
|
||||||
let face_full: Vec<(CardKey, AssetPath<'static>)> = face_paths
|
let face_full: Vec<(CardKey, AssetPath<'static>)> = face_paths
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(k, p)| {
|
.map(|(k, p)| {
|
||||||
manifest_path
|
manifest_path
|
||||||
.resolve(&path_to_str(p))
|
.resolve_embed(&path_to_str(p))
|
||||||
.map(|ap| (*k, ap))
|
.map(|ap| (*k, ap))
|
||||||
})
|
})
|
||||||
.collect::<Result<_, _>>()?;
|
.collect::<Result<_, _>>()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user