(app)
| 92 | }, |
| 93 | |
| 94 | async exportProjectData(app) { |
| 95 | if (!app.currentProject) return null; |
| 96 | |
| 97 | if (window.FileSystemSave && typeof window.FileSystemSave.buildProjectSnapshot === 'function') { |
| 98 | return await window.FileSystemSave.buildProjectSnapshot(app); |
| 99 | } |
| 100 | |
| 101 | try { |
| 102 | const projectId = app.currentProject.id; |
| 103 | const project = await db.projects.get(projectId); |
| 104 | if (!project) return null; |
| 105 | |
| 106 | const chapters = await listByProject('chapters', projectId, 'order'); |
| 107 | const scenes = await listByProject('scenes', projectId, 'order'); |
| 108 | const compendium = await listByProject('compendium', projectId); |
| 109 | const prompts = await listByProject('prompts', projectId); |
| 110 | const codex = await listByProject('codex', projectId); |
| 111 | const promptHistory = await listByProject('promptHistory', projectId); |
| 112 | const workshopSessions = await listByProject('workshopSessions', projectId, 'updatedAt'); |
| 113 | const sceneContents = {}; |
| 114 | |
| 115 | for (const scene of scenes) { |
| 116 | sceneContents[scene.id] = await getSceneContent(scene.id); |
| 117 | } |
| 118 | |
| 119 | return { |
| 120 | version: '2.1-backup', |
| 121 | exportedAt: new Date().toISOString(), |
| 122 | project, |
| 123 | chapters, |
| 124 | scenes, |
| 125 | sceneContents, |
| 126 | compendium, |
| 127 | prompts, |
| 128 | codex, |
| 129 | promptHistory, |
| 130 | workshopSessions |
| 131 | }; |
| 132 | } catch (e) { |
| 133 | console.error('Error exporting project data:', e); |
| 134 | return null; |
| 135 | } |
| 136 | }, |
| 137 | |
| 138 | async backupNow(app) { |
| 139 | switch (app.backupProvider) { |
nothing calls this directly
no test coverage detected