fix(frontend): restore project library manifest inside buildLoadPayload (P2.4)
The inline manifest-restore in the load .then was being tree-shaken out of the lazy ProjectByIdPage chunk (the deployed bundle had the save wiring but not the load). Move it into buildLoadPayload, which is an exported helper (used by tests) so its body is never dropped. Reloaded projects now re-send their manifest.
This commit is contained in:
parent
288ab46521
commit
4a21c4f938
|
|
@ -55,16 +55,9 @@ export const ProjectByIdPage: React.FC = () => {
|
|||
|
||||
getProjectById(id)
|
||||
.then((project) => {
|
||||
// buildLoadPayload also restores the library manifest (P2.4).
|
||||
const payload = buildLoadPayload(project);
|
||||
loadProjectState(payload);
|
||||
// P2.4 — restore the declared library manifest (compile scope), also
|
||||
// clearing any stale example manifest from before this load.
|
||||
try {
|
||||
const libs = JSON.parse(project.libraries_json || '[]');
|
||||
useLibraryManifestStore.getState().setLibraries(Array.isArray(libs) ? libs : null);
|
||||
} catch {
|
||||
useLibraryManifestStore.getState().setLibraries(null);
|
||||
}
|
||||
setCurrentProject({
|
||||
id: project.id,
|
||||
slug: project.slug,
|
||||
|
|
@ -146,6 +139,7 @@ interface RawProject {
|
|||
files: { name: string; content: string }[];
|
||||
file_groups?: { groupId: string; files: { name: string; content: string }[] }[];
|
||||
boards_json?: string;
|
||||
libraries_json?: string; // P2.4 — declared library manifest (compile scope)
|
||||
code: string;
|
||||
components_json: string;
|
||||
wires_json: string;
|
||||
|
|
@ -239,6 +233,16 @@ export function buildLoadPayload(project: RawProject) {
|
|||
wires = [];
|
||||
}
|
||||
|
||||
// P2.4 — restore the project's declared library manifest as the compile
|
||||
// scope (clearing any stale example manifest from before this load). Done
|
||||
// here, inside this exported helper, so the call is never tree-shaken.
|
||||
try {
|
||||
const libs = JSON.parse(project.libraries_json || '[]');
|
||||
useLibraryManifestStore.getState().setLibraries(Array.isArray(libs) ? libs : null);
|
||||
} catch {
|
||||
useLibraryManifestStore.getState().setLibraries(null);
|
||||
}
|
||||
|
||||
return {
|
||||
boards,
|
||||
fileGroups,
|
||||
|
|
|
|||
Loading…
Reference in New Issue