Fix What's New dialog layout and improve dev styling/debugging.
Trigger cinny-mobile / dispatch (push) Successful in 1s
Trigger cinny-mobile / dispatch (push) Successful in 1s
Portal the updates dialog to document.body with stable data attributes, fix max-width (invalid S800 token), bundle update images for Capacitor, and add readable vanilla-extract class names plus portalContainer tap fixes.
This commit is contained in:
@@ -7,6 +7,11 @@ const bundledMarkdownByFile = import.meta.glob('../../../public/update/*.md', {
|
||||
eager: true,
|
||||
}) as Record<string, string>;
|
||||
|
||||
const bundledImageByFile = import.meta.glob('../../../public/update/images/*', {
|
||||
import: 'default',
|
||||
eager: true,
|
||||
}) as Record<string, string>;
|
||||
|
||||
function getUpdateBaseUrl(): string {
|
||||
const basePath = trimTrailingSlash(import.meta.env.BASE_URL || './');
|
||||
const relative =
|
||||
@@ -88,12 +93,28 @@ function loadBundledDocument(file: string): ParsedUpdateDoc | null {
|
||||
return parseUpdateMarkdown(safeFile, entry[1]);
|
||||
}
|
||||
|
||||
function resolveBundledImageUrl(normalizedPath: string): string | undefined {
|
||||
const needle = normalizedPath.replace(/^\/+/, '');
|
||||
if (!needle) return undefined;
|
||||
|
||||
const entry = Object.entries(bundledImageByFile).find(([path]) => {
|
||||
const normalized = path.replace(/\\/g, '/');
|
||||
return normalized.endsWith(`/${needle}`) || normalized.endsWith(`/${needle.split('/').pop() ?? ''}`);
|
||||
});
|
||||
|
||||
return entry?.[1];
|
||||
}
|
||||
|
||||
export function resolveUpdateAssetUrl(src: string | undefined): string | undefined {
|
||||
if (!src) return undefined;
|
||||
if (/^(https?:|data:|blob:|capacitor:)/i.test(src)) return src;
|
||||
|
||||
const normalized = src.replace(/^\.\//, '').replace(/^\/+/, '');
|
||||
const bundled = resolveBundledImageUrl(normalized);
|
||||
if (bundled) return bundled;
|
||||
|
||||
if (src.startsWith('/')) return src;
|
||||
|
||||
const normalized = src.replace(/^\.\//, '');
|
||||
return new URL(normalized, `${getUpdateBaseUrl()}/`).href;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user