e3063ea806
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>
26 lines
798 B
JavaScript
26 lines
798 B
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import {
|
|
normalizeWorkspaceRelativePath,
|
|
resolveAssetWorkspaceRelativePath,
|
|
resolvePageWorkspaceRelativePath,
|
|
} from './mindspace-workspace-relative-path.mjs';
|
|
import { resolvePublishDir } from './user-publish.mjs';
|
|
|
|
export {
|
|
normalizeWorkspaceRelativePath,
|
|
resolveAssetWorkspaceRelativePath,
|
|
resolvePageWorkspaceRelativePath,
|
|
};
|
|
|
|
export async function readWorkspacePublishHtml(h5Root, userId, relativePath) {
|
|
const normalized = normalizeWorkspaceRelativePath(relativePath);
|
|
if (!h5Root || !userId || !normalized) return null;
|
|
const filePath = path.join(resolvePublishDir(h5Root, { id: userId }), ...normalized.split('/'));
|
|
try {
|
|
return await fs.promises.readFile(filePath, 'utf8');
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|