cupertino-files / IWorkDocument
Class: IWorkDocument
Defined in: src/tsa/document.ts:127
Extended by
Constructors
Constructor
protectednew IWorkDocument(container,store):IWorkDocument
Defined in: src/tsa/document.ts:132
Parameters
container
store
Returns
IWorkDocument
Properties
container
readonlycontainer:IWorkContainer
Defined in: src/tsa/document.ts:128
format
readonlyformat:FormatInfo
Defined in: src/tsa/document.ts:130
store
readonlystore:ObjectStore
Defined in: src/tsa/document.ts:129
Accessors
app
Get Signature
get app():
IWorkApp
Defined in: src/tsa/document.ts:170
Returns
era
Get Signature
get era():
"iwork13"|"iwork16"|"iwork19"|"modern"|"current"|"future"
Defined in: src/tsa/document.ts:336
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:279
Concatenated plain text of all in-document storages (reading order approximation).
Returns
string
audit()
audit():
AuditFinding[]
Defined in: src/tsa/document.ts:242
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
Agent Tool
audit_document
charts()
charts():
ChartModel[]
Defined in: src/tsa/document.ts:210
Every chart, with its plotted data (see ChartModel).
Returns
compact()
compact():
number
Defined in: src/tsa/document.ts:363
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, and the Data/ files (a removed picture's bytes) that no surviving object names; the count is archives and files together.
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, and ObjectStore.collectData for how a file is known to be live. 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:317
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
compatibilitySummary()
compatibilitySummary():
string
Defined in: src/tsa/document.ts:331
One-line human summary of compatibility.
Returns
string
drawables()
drawables():
DrawableModel[]
Defined in: src/tsa/document.ts:195
Every object that carries drawable geometry (shapes, images, boxes).
Returns
images()
images():
ImageModel[]
Defined in: src/tsa/document.ts:215
Every image, with filter/mask access (see ImageModel).
Returns
object()
object(
id):IwaObject|undefined
Defined in: src/tsa/document.ts:286
Parameters
id
bigint
Returns
IwaObject | undefined
pruneRoots()
protectedpruneRoots():bigint[]
Defined in: src/tsa/document.ts:375
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:394
Returns
Uint8Array
stats()
stats():
DocumentStats
Defined in: src/tsa/document.ts:294
Returns
stylesheets()
stylesheets():
StylesheetModel[]
Defined in: src/tsa/document.ts:186
All stylesheets (document + theme).
Returns
tables()
tables():
TableModel[]
Defined in: src/tsa/document.ts:226
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
textStorages()
textStorages(
kind?):TextStorage[]
Defined in: src/tsa/document.ts:175
Every text storage in the document (bodies, headers, cells, notes …).
Parameters
kind?
number
Returns
toMarkdown()
toMarkdown(
options?):string
Defined in: src/tsa/document.ts:270
The document as Markdown: paragraphs as paragraphs, headings by their named style, list paragraphs as list items, tables as pipe tables and charts as a table of their series. Pages, Numbers and Keynote each arrange this in their own structure — body, sheets, slides. Pictures are written through images, a sink that places each one and returns its link; without it they are left out.
Parameters
options?
MarkdownOptions = {}
Returns
string
Agent Tool
export_document
typeNameOf()
typeNameOf(
obj):string|undefined
Defined in: src/tsa/document.ts:290
Parameters
obj
Returns
string | undefined
loadStore()
protectedstaticloadStore(bytes,app,extractors):object
Defined in: src/tsa/document.ts:155
Parameters
bytes
Uint8Array
app
extractors
ReadonlyMap<number, ReferenceExtractor>
Returns
object
container
container:
IWorkContainer
store
store:
ObjectStore
open()
staticopen(bytes):IWorkDocument
Defined in: src/tsa/document.ts:142
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