mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(tools): 2.0 phase 5 wave 4 - office, ebooks, data, archives (14 tools) (#224)
This commit is contained in:
@@ -0,0 +1,291 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// make-tiny-pptx.mjs
|
||||
//
|
||||
// Builds a minimal ECMA-376 (OOXML) presentation skeleton and writes it to
|
||||
// tests/fixtures/documents/tiny.pptx using adm-zip (root devDep).
|
||||
//
|
||||
// ACCEPTANCE (2026-06-12, snapotter/snapotter:latest + libreoffice-impress):
|
||||
// soffice --headless --norestore --nolockcheck --nodefault \
|
||||
// --convert-to pdf --outdir /tmp /tmp/tiny.pptx
|
||||
// Result: /tmp/tiny.pdf produced, 8454 bytes. Impress opens the skeleton
|
||||
// and renders the single-slide text box via impress_pdf_Export filter.
|
||||
// NOTE: libreoffice-impress must be added to the Dockerfile (wave 3b image
|
||||
// only had libreoffice-writer + libreoffice-calc).
|
||||
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import AdmZip from "adm-zip";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const outPath = join(__dirname, "..", "..", "tests", "fixtures", "documents", "tiny.pptx");
|
||||
|
||||
const zip = new AdmZip();
|
||||
|
||||
// [Content_Types].xml
|
||||
zip.addFile(
|
||||
"[Content_Types].xml",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
||||
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
||||
<Default Extension="xml" ContentType="application/xml"/>
|
||||
<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>
|
||||
<Override PartName="/ppt/slides/slide1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>
|
||||
<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
|
||||
<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>
|
||||
<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
|
||||
</Types>`),
|
||||
);
|
||||
|
||||
// _rels/.rels
|
||||
zip.addFile(
|
||||
"_rels/.rels",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
||||
</Relationships>`),
|
||||
);
|
||||
|
||||
// ppt/presentation.xml
|
||||
zip.addFile(
|
||||
"ppt/presentation.xml",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
||||
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
||||
<p:sldMasterIdLst>
|
||||
<p:sldMasterId id="2147483648" r:id="rId1"/>
|
||||
</p:sldMasterIdLst>
|
||||
<p:sldIdLst>
|
||||
<p:sldId id="256" r:id="rId2"/>
|
||||
</p:sldIdLst>
|
||||
<p:sldSz cx="9144000" cy="6858000" type="screen4x3"/>
|
||||
<p:notesSz cx="6858000" cy="9144000"/>
|
||||
</p:presentation>`),
|
||||
);
|
||||
|
||||
// ppt/_rels/presentation.xml.rels
|
||||
zip.addFile(
|
||||
"ppt/_rels/presentation.xml.rels",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>
|
||||
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide1.xml"/>
|
||||
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
|
||||
</Relationships>`),
|
||||
);
|
||||
|
||||
// ppt/slides/slide1.xml
|
||||
zip.addFile(
|
||||
"ppt/slides/slide1.xml",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
||||
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
||||
<p:cSld>
|
||||
<p:spTree>
|
||||
<p:nvGrpSpPr>
|
||||
<p:cNvPr id="1" name=""/>
|
||||
<p:cNvGrpSpPr/>
|
||||
<p:nvPr/>
|
||||
</p:nvGrpSpPr>
|
||||
<p:grpSpPr>
|
||||
<a:xfrm>
|
||||
<a:off x="0" y="0"/>
|
||||
<a:ext cx="0" cy="0"/>
|
||||
<a:chOff x="0" y="0"/>
|
||||
<a:chExt cx="0" cy="0"/>
|
||||
</a:xfrm>
|
||||
</p:grpSpPr>
|
||||
<p:sp>
|
||||
<p:nvSpPr>
|
||||
<p:cNvPr id="2" name="TextBox 1"/>
|
||||
<p:cNvSpPr txBox="1"/>
|
||||
<p:nvPr/>
|
||||
</p:nvSpPr>
|
||||
<p:spPr>
|
||||
<a:xfrm>
|
||||
<a:off x="457200" y="457200"/>
|
||||
<a:ext cx="8229600" cy="5943600"/>
|
||||
</a:xfrm>
|
||||
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
||||
</p:spPr>
|
||||
<p:txBody>
|
||||
<a:bodyPr wrap="square" rtlCol="0"/>
|
||||
<a:lstStyle/>
|
||||
<a:p>
|
||||
<a:r>
|
||||
<a:rPr lang="en-US" dirty="0"/>
|
||||
<a:t>SnapOtter pptx fixture</a:t>
|
||||
</a:r>
|
||||
</a:p>
|
||||
</p:txBody>
|
||||
</p:sp>
|
||||
</p:spTree>
|
||||
</p:cSld>
|
||||
</p:sld>`),
|
||||
);
|
||||
|
||||
// ppt/slides/_rels/slide1.xml.rels
|
||||
zip.addFile(
|
||||
"ppt/slides/_rels/slide1.xml.rels",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>
|
||||
</Relationships>`),
|
||||
);
|
||||
|
||||
// ppt/slideLayouts/slideLayout1.xml
|
||||
zip.addFile(
|
||||
"ppt/slideLayouts/slideLayout1.xml",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
||||
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
|
||||
type="blank" preserve="1">
|
||||
<p:cSld name="Blank">
|
||||
<p:spTree>
|
||||
<p:nvGrpSpPr>
|
||||
<p:cNvPr id="1" name=""/>
|
||||
<p:cNvGrpSpPr/>
|
||||
<p:nvPr/>
|
||||
</p:nvGrpSpPr>
|
||||
<p:grpSpPr>
|
||||
<a:xfrm>
|
||||
<a:off x="0" y="0"/>
|
||||
<a:ext cx="0" cy="0"/>
|
||||
<a:chOff x="0" y="0"/>
|
||||
<a:chExt cx="0" cy="0"/>
|
||||
</a:xfrm>
|
||||
</p:grpSpPr>
|
||||
</p:spTree>
|
||||
</p:cSld>
|
||||
</p:sldLayout>`),
|
||||
);
|
||||
|
||||
// ppt/slideLayouts/_rels/slideLayout1.xml.rels
|
||||
zip.addFile(
|
||||
"ppt/slideLayouts/_rels/slideLayout1.xml.rels",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="../slideMasters/slideMaster1.xml"/>
|
||||
</Relationships>`),
|
||||
);
|
||||
|
||||
// ppt/slideMasters/slideMaster1.xml
|
||||
zip.addFile(
|
||||
"ppt/slideMasters/slideMaster1.xml",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<p:sldMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
||||
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
||||
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
||||
<p:cSld>
|
||||
<p:bg>
|
||||
<p:bgPr>
|
||||
<a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill>
|
||||
<a:effectLst/>
|
||||
</p:bgPr>
|
||||
</p:bg>
|
||||
<p:spTree>
|
||||
<p:nvGrpSpPr>
|
||||
<p:cNvPr id="1" name=""/>
|
||||
<p:cNvGrpSpPr/>
|
||||
<p:nvPr/>
|
||||
</p:nvGrpSpPr>
|
||||
<p:grpSpPr>
|
||||
<a:xfrm>
|
||||
<a:off x="0" y="0"/>
|
||||
<a:ext cx="0" cy="0"/>
|
||||
<a:chOff x="0" y="0"/>
|
||||
<a:chExt cx="0" cy="0"/>
|
||||
</a:xfrm>
|
||||
</p:grpSpPr>
|
||||
</p:spTree>
|
||||
</p:cSld>
|
||||
<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2"
|
||||
accent1="accent1" accent2="accent2" accent3="accent3"
|
||||
accent4="accent4" accent5="accent5" accent6="accent6"
|
||||
hlink="hlink" folHlink="folHlink"/>
|
||||
<p:sldLayoutIdLst>
|
||||
<p:sldLayoutId id="2147483649" r:id="rId1"/>
|
||||
</p:sldLayoutIdLst>
|
||||
<p:txStyles>
|
||||
<p:titleStyle/>
|
||||
<p:bodyStyle/>
|
||||
<p:otherStyle/>
|
||||
</p:txStyles>
|
||||
</p:sldMaster>`),
|
||||
);
|
||||
|
||||
// ppt/slideMasters/_rels/slideMaster1.xml.rels
|
||||
zip.addFile(
|
||||
"ppt/slideMasters/_rels/slideMaster1.xml.rels",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>
|
||||
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/>
|
||||
</Relationships>`),
|
||||
);
|
||||
|
||||
// ppt/theme/theme1.xml
|
||||
zip.addFile(
|
||||
"ppt/theme/theme1.xml",
|
||||
Buffer.from(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Blank">
|
||||
<a:themeElements>
|
||||
<a:clrScheme name="Office">
|
||||
<a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1>
|
||||
<a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1>
|
||||
<a:dk2><a:srgbClr val="44546A"/></a:dk2>
|
||||
<a:lt2><a:srgbClr val="E7E6E6"/></a:lt2>
|
||||
<a:accent1><a:srgbClr val="4472C4"/></a:accent1>
|
||||
<a:accent2><a:srgbClr val="ED7D31"/></a:accent2>
|
||||
<a:accent3><a:srgbClr val="A5A5A5"/></a:accent3>
|
||||
<a:accent4><a:srgbClr val="FFC000"/></a:accent4>
|
||||
<a:accent5><a:srgbClr val="5B9BD5"/></a:accent5>
|
||||
<a:accent6><a:srgbClr val="70AD47"/></a:accent6>
|
||||
<a:hlink><a:srgbClr val="0563C1"/></a:hlink>
|
||||
<a:folHlink><a:srgbClr val="954F72"/></a:folHlink>
|
||||
</a:clrScheme>
|
||||
<a:fontScheme name="Office">
|
||||
<a:majorFont>
|
||||
<a:latin typeface="Calibri Light"/>
|
||||
<a:ea typeface=""/>
|
||||
<a:cs typeface=""/>
|
||||
</a:majorFont>
|
||||
<a:minorFont>
|
||||
<a:latin typeface="Calibri"/>
|
||||
<a:ea typeface=""/>
|
||||
<a:cs typeface=""/>
|
||||
</a:minorFont>
|
||||
</a:fontScheme>
|
||||
<a:fmtScheme name="Office">
|
||||
<a:fillStyleLst>
|
||||
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
||||
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
||||
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
||||
</a:fillStyleLst>
|
||||
<a:lnStyleLst>
|
||||
<a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln>
|
||||
<a:ln w="12700"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln>
|
||||
<a:ln w="19050"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln>
|
||||
</a:lnStyleLst>
|
||||
<a:effectStyleLst>
|
||||
<a:effectStyle><a:effectLst/></a:effectStyle>
|
||||
<a:effectStyle><a:effectLst/></a:effectStyle>
|
||||
<a:effectStyle><a:effectLst/></a:effectStyle>
|
||||
</a:effectStyleLst>
|
||||
<a:bgFillStyleLst>
|
||||
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
||||
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
||||
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
||||
</a:bgFillStyleLst>
|
||||
</a:fmtScheme>
|
||||
</a:themeElements>
|
||||
<a:objectDefaults/>
|
||||
<a:extraClrSchemeLst/>
|
||||
</a:theme>`),
|
||||
);
|
||||
|
||||
zip.writeZip(outPath);
|
||||
console.log(`Wrote ${outPath}`);
|
||||
Reference in New Issue
Block a user