2.0.1 • Published 1 year ago
keynote-archives v2.0.1
keynote-archives
Utilities to process Keynote presentations (*.key).
Protobuf files were taken from psobot / keynote-parser. Read more about the iWorkArchive format here. Generated by Keynote version 12.2.1 (current as of December 2022).
How to use?
npm install keynote-archives
Then import the package and unzip the inner files, dechunk the single IWA files and split each chunk into objects.
import { unzip, isIwaFile, dechunk, uncompress, splitObjectsAs, KeynoteArchives } from 'keynote-archives';
export async function decode(data: Uint8Array): void {
for await(const entry of unzip(data)) {
if(isIwaFile(entry.name)) {
for await(const snappyChunk of dechunk(entry.data)) {
const chunk = await uncompress(snappyChunk.data);
for await(const message of splitObjectsAs(chunk, KeynoteArchives)) {
...
}
}
}
}
}
Documentation
This package provides asynchronous functions to read IWA format. Here is a small overview about the terminology:
Here is what they do in detail:
unzip
: opens anUint8Array
as Zip file and returns multiple file entries, untilEOF
.dechunk
: opens anUint8Array
as IWA file and returns multiple Snappy-compressed chunks asUint8Array
, untilEOF
.uncompress
: opens anUint8Array
as Snappy chunk and returns uncompressed data asUint8Array
.splitObjectsAs
: opens an Uint8 array as IWA file chunk and returns multiple Protobuf-decoded IWA (JSON) objects, untilEOF
or error.decode
: (everything at once) opens an Uint8 array as Zip file and returns multipleArchiveEntry
s containing either a file or a list of IWA chunks with multiple IWA objects associated with an IWA file.analyzeChunkFor
: analyzes anUint8Array
IWA chunk forArchiveInfo
segments and returns archive infos and gaps for further analysis.
You will also get access to all archives types:
AllArchives
is a list of all archives.- for each Protobuf package
XXX
, you will get:- a list of all package-related archives
XXX$Archives
- a namespace
XXX
with all archivesXXX.yyy
- a list of all package-related archives
- a map for all Keynote archives by type number
KeynoteArchives
Workflow for contributors
npm install //Initialize NPM package...
npm run clean //Clean artifacts from last build
npm run generate-ts-from-proto //Generate Typescript files from Protobuf files...
npm run generate-index-from-ts //Create the index...
npm run build //Transpile to Javascript...