fix(mindspace): refresh published HTML after workspace sync
Keep online publication snapshots aligned when public/*.html changes, default static page binds to public access with MindSpace delivery URLs, and split browser-safe workspace helpers out of the Vite import chain. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { normalizeWorkspaceRelativePath } from './mindspace-pages.mjs';
|
||||
import {
|
||||
normalizeWorkspaceRelativePath,
|
||||
resolveAssetWorkspaceRelativePath,
|
||||
resolvePageWorkspaceRelativePath,
|
||||
} from './mindspace-workspace-relative-path.mjs';
|
||||
import { resolvePublishDir } from './user-publish.mjs';
|
||||
|
||||
export { normalizeWorkspaceRelativePath };
|
||||
export {
|
||||
normalizeWorkspaceRelativePath,
|
||||
resolveAssetWorkspaceRelativePath,
|
||||
resolvePageWorkspaceRelativePath,
|
||||
};
|
||||
|
||||
export async function readWorkspacePublishHtml(h5Root, userId, relativePath) {
|
||||
const normalized = normalizeWorkspaceRelativePath(relativePath);
|
||||
@@ -15,29 +23,3 @@ export async function readWorkspacePublishHtml(h5Root, userId, relativePath) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolvePageWorkspaceRelativePath(snapshot) {
|
||||
if (!snapshot || typeof snapshot !== 'object') return null;
|
||||
return normalizeWorkspaceRelativePath(snapshot.relative_path) || null;
|
||||
}
|
||||
|
||||
export function resolveAssetWorkspaceRelativePath({
|
||||
categoryCode = null,
|
||||
originalFilename = null,
|
||||
explicitPath = null,
|
||||
} = {}) {
|
||||
const explicit = normalizeWorkspaceRelativePath(explicitPath);
|
||||
if (explicit) return explicit;
|
||||
const filename = String(originalFilename ?? '')
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/^\/+/, '');
|
||||
if (!filename) return null;
|
||||
if (/^(?:public|oa)\//i.test(filename)) {
|
||||
return normalizeWorkspaceRelativePath(filename);
|
||||
}
|
||||
const category = String(categoryCode ?? '').trim();
|
||||
if (category === 'public' || category === 'oa') {
|
||||
return normalizeWorkspaceRelativePath(`${category}/${filename}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user