Skip to content

cupertino-files / IWorkDocument

Class: IWorkDocument ​

Defined in: src/tsa/document.ts:124

Extended by ​

Constructors ​

Constructor ​

protected new IWorkDocument(container, store): IWorkDocument

Defined in: src/tsa/document.ts:129

Parameters ​

container ​

IWorkContainer

store ​

ObjectStore

Returns ​

IWorkDocument

Properties ​

container ​

readonly container: IWorkContainer

Defined in: src/tsa/document.ts:125


format ​

readonly format: FormatInfo

Defined in: src/tsa/document.ts:127


store ​

readonly store: ObjectStore

Defined in: src/tsa/document.ts:126

Accessors ​

app ​

Get Signature ​

get app(): IWorkApp

Defined in: src/tsa/document.ts:167

Returns ​

IWorkApp


era ​

Get Signature ​

get era(): "iwork13" | "iwork16" | "iwork19" | "modern" | "current" | "future"

Defined in: src/tsa/document.ts:316

Format era this document was written by (see tsp/version.ts).

Returns ​

"iwork13" | "iwork16" | "iwork19" | "modern" | "current" | "future"

Methods ​

allText() ​

allText(): string

Defined in: src/tsa/document.ts:259

Concatenated plain text of all in-document storages (reading order approximation).

Returns ​

string


audit() ​

audit(): AuditFinding[]

Defined in: src/tsa/document.ts:239

Every fault this library knows how to recognise offline, across the whole document — the checks a person otherwise performs by opening the file in an app. Each finding names a state some review round has already watched an app refuse, repair destructively, or render against the author's intent. save() refuses the error classes it can see; audit() reports them without saving, warnings included, so a builder can ask "what would a person object to?" before shipping a document.

Returns ​

AuditFinding[]

Agent Tool ​

audit_document


charts() ​

charts(): ChartModel[]

Defined in: src/tsa/document.ts:207

Every chart, with its plotted data (see ChartModel).

Returns ​

ChartModel[]


compact() ​

compact(): number

Defined in: src/tsa/document.ts:341

Drop archives nothing can reach, returning how many went.

What this collects today is very little, and that is worth knowing before reaching for it. Removing a sheet or a table unlinks it from the document tree, but the calc engine keeps its own references to every table it ever knew, so those archives stay genuinely reachable. The gap is in removal — unregistering a table's formula owners is calc-engine surgery this library does not do yet — not in the walk. What compaction does reclaim is objects created and then abandoned.

Roots are the package metadata, each component's first object, and every selection archive; see ObjectStore.prune for the scan and for why it errs towards keeping things. It is a no-op on every untouched document in the corpus, which is the property that matters: a collector that trims a file nobody edited is broken.

Returns ​

number


compatibility() ​

compatibility(): CompatibilityReport

Defined in: src/tsa/document.ts:297

What this library can and cannot do with THIS document: declared versions, the era they place it in, structural probes (unknown type IDs, cell-storage generation, patch archives, collaboration state) and any unsupported features. Loading never fails on version grounds — this is how a caller finds out what to expect.

Returns ​

CompatibilityReport


compatibilitySummary() ​

compatibilitySummary(): string

Defined in: src/tsa/document.ts:311

One-line human summary of compatibility.

Returns ​

string


drawables() ​

drawables(): DrawableModel[]

Defined in: src/tsa/document.ts:192

Every object that carries drawable geometry (shapes, images, boxes).

Returns ​

DrawableModel[]


images() ​

images(): ImageModel[]

Defined in: src/tsa/document.ts:212

Every image, with filter/mask access (see ImageModel).

Returns ​

ImageModel[]


object() ​

object(id): IwaObject | undefined

Defined in: src/tsa/document.ts:266

Parameters ​

id ​

bigint

Returns ​

IwaObject | undefined


pruneRoots() ​

protected pruneRoots(): bigint[]

Defined in: src/tsa/document.ts:353

Objects that must survive compact.

The package metadata anchors the component and data tables, and each component's first object anchors that component — a component whose objects all vanished would still be listed in the metadata, which is a worse state than a few extra archives.

Returns ​

bigint[]


save() ​

save(): Uint8Array

Defined in: src/tsa/document.ts:372

Returns ​

Uint8Array


stats() ​

stats(): DocumentStats

Defined in: src/tsa/document.ts:274

Returns ​

DocumentStats


stylesheets() ​

stylesheets(): StylesheetModel[]

Defined in: src/tsa/document.ts:183

All stylesheets (document + theme).

Returns ​

StylesheetModel[]


tables() ​

tables(): TableModel[]

Defined in: src/tsa/document.ts:223

Every table (see TableModel).

Lives on the base because tables are not a Numbers feature: Pages documents and Keynote slides embed the same TST archives, and the reading and writing code is identical for all three.

Returns ​

TableModel[]


textStorages() ​

textStorages(kind?): TextStorage[]

Defined in: src/tsa/document.ts:172

Every text storage in the document (bodies, headers, cells, notes …).

Parameters ​

kind? ​

number

Returns ​

TextStorage[]


typeNameOf() ​

typeNameOf(obj): string | undefined

Defined in: src/tsa/document.ts:270

Parameters ​

obj ​

IwaObject

Returns ​

string | undefined


loadStore() ​

protected static loadStore(bytes, app, extractors): object

Defined in: src/tsa/document.ts:152

Parameters ​

bytes ​

Uint8Array

app ​

IWorkApp

extractors ​

ReadonlyMap<number, ReferenceExtractor>

Returns ​

object

container ​

container: IWorkContainer

store ​

store: ObjectStore


open() ​

static open(bytes): IWorkDocument

Defined in: src/tsa/document.ts:139

Load any modern iWork document, auto-detecting the app. Prefer the app subclasses' load when the type is known — they expose richer APIs.

Parameters ​

bytes ​

Uint8Array

Returns ​

IWorkDocument

MIT licensed. Independently made — not by Apple in California. Not affiliated with or endorsed by Apple Inc.