Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/processors/obfProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,31 @@ class ObfProcessor extends BaseProcessor {
const obfBoard = this.createObfBoardFromPage(rootPage, 'Exported Board', tree.metadata);
await writeTextToPath(outputPath, JSON.stringify(obfBoard, null, 2));
} else {
const getPageFilename = (id: string): string => (id.endsWith('.obf') ? id : `${id}.obf`);
const files = Object.values(tree.pages).map((page) => {
const obfBoard = this.createObfBoardFromPage(page, 'Board', tree.metadata);
const obfContent = JSON.stringify(obfBoard, null, 2);
const name = page.id.endsWith('.obf') ? page.id : `${page.id}.obf`;
const name = getPageFilename(page.id);
return {
name,
data: new TextEncoder().encode(obfContent),
};
});
const manifest: ObfManifest = {
format: OBF_FORMAT_VERSION,
root: tree.metadata.defaultHomePageId,
paths: {
boards: Object.fromEntries(
Object.entries(tree.pages).map(([id, page]) => [id, getPageFilename(page.id)])
),
images: {}, //TODO Add support for saving images as files
sounds: {}, //TODO Add support for saving sounds as files
},
};
files.push({
name: 'manifest.json',
data: new TextEncoder().encode(JSON.stringify(manifest)),
});
const fileExists = await pathExists(outputPath);
this.zipFile = await this.options.zipAdapter(
fileExists ? outputPath : undefined,
Expand Down