cupertino-files / IWorkDocument
Class: IWorkDocument
Defined in: src/tsa/document.ts:124
Extended by
Constructors
Constructor
protectednew IWorkDocument(container,store):IWorkDocument
Defined in: src/tsa/document.ts:129
Parameters
container
store
Returns
IWorkDocument
Properties
container
readonlycontainer:IWorkContainer
Defined in: src/tsa/document.ts:125
format
readonlyformat:FormatInfo
Defined in: src/tsa/document.ts:127
store
readonlystore:ObjectStore
Defined in: src/tsa/document.ts:126
Accessors
app
Get Signature
get app():
IWorkApp
Defined in: src/tsa/document.ts:167
Returns
era
Get Signature
get era():
"iwork13"|"iwork16"|"iwork19"|"modern"|"current"|"future"
Defined in: src/tsa/document.ts:285
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:228
Concatenated plain text of all in-document storages (reading order approximation).
Returns
string
charts()
charts():
ChartModel[]
Defined in: src/tsa/document.ts:207
Every chart, with its plotted data (see ChartModel).
Returns
compact()
compact():
number
Defined in: src/tsa/document.ts:310
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:266
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:280
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
images()
images():
ImageModel[]
Defined in: src/tsa/document.ts:212
Every image, with filter/mask access (see ImageModel).
Returns
object()
object(
id):IwaObject|undefined
Defined in: src/tsa/document.ts:235
Parameters
id
bigint
Returns
IwaObject | undefined
pruneRoots()
protectedpruneRoots():bigint[]
Defined in: src/tsa/document.ts:322
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:341
Returns
Uint8Array
stats()
stats():
DocumentStats
Defined in: src/tsa/document.ts:243
Returns
stylesheets()
stylesheets():
StylesheetModel[]
Defined in: src/tsa/document.ts:183
All stylesheets (document + theme).
Returns
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
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
typeNameOf()
typeNameOf(
obj):string|undefined
Defined in: src/tsa/document.ts:239
Parameters
obj
Returns
string | undefined
loadStore()
protectedstaticloadStore(bytes,app,extractors):object
Defined in: src/tsa/document.ts:152
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: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