@pptx-editor.dev/core/automation

Functions (4)

createAutomationHostfunctionSource ↗

Build a host over a port.

declare function createAutomationHost(composition: AutomationHostComposition): AutomationHost;

createServerAutomationHostfunctionSource ↗

Open .pptx bytes as a headless host. Never throws for a malformed file.

declare function createServerAutomationHost(bytes: Uint8Array, options?: ServerAutomationOptions): {
    readonly ok: true;
    readonly host: AutomationHost;
} | {
    readonly ok: false;
    readonly error: ServerAutomationRejection;
};

createStoreAutomationHostfunctionSource ↗

A host over a store: the server host's composition, and the base of the editor's.

declare function createStoreAutomationHost(store: PptxDocumentStore, options?: StoreAutomationOptions): AutomationHost;

storeAutomationPortfunctionSource ↗

A port over a store this host owns or shares. New part names never reuse a name the store has held, so a name in the history always means one part.

declare function storeAutomationPort(store: PptxDocumentStore, options?: StoreAutomationOptions): AutomationDocumentPort;

Interfaces (51)

AutomationAdjustmentsReadinterfaceSource ↗

The adjust values of a preset geometry (a:prstGeom/a:avLst, ECMA-376 Part 1, 20.1.9.5), in the order the preset defines them. A length is a fraction of the shape size (the guide value / 100 000); an angle is in degrees (the guide value / 60 000).

interface AutomationAdjustmentsRead
MemberTypeSummary
presetstring`a:prstGeom/@prst`.
valuesreadonly number[]

AutomationBackgroundFillReadinterfaceSource ↗

The fill of a background (p:bg, ECMA-376 Part 1, 19.3.1.1): the own one of the part, or the one it shows from the layout or master. Colors are #RRGGBB; transparency is 0 to 1.

interface AutomationBackgroundFillRead
MemberTypeSummary
backgroundColorstring | null
colorstring | nullThe solid color.
foregroundColorstring | nullThe pattern colors (`a:fgClr`, `a:bgClr`).
gradientTypestring | nullThe gradient shading: `linear` (`a:lin`), `circle`, `rect`, or `shape` (`a:path/@path`), or `shadeToTitle` (`p:bgPr/@shadeToTitle`).
patternstring | nullThe pattern preset (`ST_PresetPatternVal`).
transparencynumber | nullThe transparency of a solid color (`a:alpha`) or a picture (`a:alphaModFix`).
type'solid' | 'gradient' | 'pattern' | 'picture' | 'unsupported'`solid`, `gradient`, `pattern`, `picture`, or `unsupported` (`a:noFill`, `a:grpFill`).

AutomationBackgroundReadinterfaceSource ↗

The background of a slide, a layout, or a master.

interface AutomationBackgroundRead
MemberTypeSummary
fillAutomationBackgroundFillRead
followsMasterbooleanThe part has no own `p:bg`, so it shows the background of its layout or master.
graphicsHiddenboolean`showMasterSp="0"`: the shapes of the level above do not show. False for a master.

AutomationBatchRequestinterfaceSource ↗

One ordered batch, and the revision it was planned against.

interface AutomationBatchRequest
MemberTypeSummary
expectedRevision?numberRefuse the whole batch unless the host is at this revision.
historyGroup?stringBatches that carry the same group, one after the other, are one undo step in a host that keeps an undo history. A client sends one group for the batches of one sync that it splits. A host without a history ignores it.
operationsreadonly AutomationOperation[]

AutomationBatchResponseinterfaceSource ↗

A verdict, one result per operation in request order, and the revision afterwards.

interface AutomationBatchResponse
MemberTypeSummary
changedbooleanWhether the batch moved the presentation.
okbooleanTrue only when every operation succeeded and the commands committed.
resultsreadonly AutomationOperationResult[]
revisionnumberThe host's revision after the batch. Unchanged when nothing committed.

AutomationBindingReadinterfaceSource ↗

One binding of the host: an id that names a shape. Bindings are never file content.

interface AutomationBindingRead
MemberTypeSummary
idstring
type'shape'What the binding names. Only `shape`.

AutomationBoxinterfaceSource ↗

A box in points. Each field is optional on writes.

interface AutomationBox
MemberTypeSummary
height?number
left?number
top?number
width?number

AutomationCapabilitiesinterfaceSource ↗

What a host supports, fixed at construction and frozen.

A headless host reports selection false: it has no reader to select for, and refuses the selection operations rather than inventing a selection.

interface AutomationCapabilities
MemberTypeSummary
autofitbooleanText writes re-fit text bodies by their autofit rules (a text measurer is present).
documentbooleanReading and editing the presentation. Every operation but the selection ones needs it.
eventsbooleanChange notification through [AutomationHost.subscribe](AutomationHost.subscribe).
imagesbooleanPictures of slides and shapes through [AutomationHost.renderImage](AutomationHost.renderImage). Drawing needs a DOM and a canvas, so only a browser host reports it.
savebooleanSerializing the current presentation back to `.pptx` bytes.
selectionbooleanA reader's slide, shape, or text selection exists and can be read and set.

AutomationCellAddressinterfaceSource ↗

A table cell whose text body a text operation addresses instead of the shape's own: the cell at this grid position, or the anchor of the merged block that covers it.

interface AutomationCellAddress
MemberTypeSummary
columnnumber
rownumber

AutomationCellMarginsWriteinterfaceSource ↗

Cell margins a write sets, in points. Null removes one, back to its default.

interface AutomationCellMarginsWrite
MemberTypeSummary
bottom?number | null
left?number | null
right?number | null
top?number | null

AutomationChangeEventinterfaceSource ↗

The presentation moved. Coarse on purpose: a consumer reads again what it needs.

interface AutomationChangeEvent
MemberTypeSummary
revisionnumber

AutomationCustomPropertyReadinterfaceSource ↗

One custom document property (docProps/custom.xml, ECMA-376 Part 1, 22.3). A Date is an ISO 8601 text in UTC.

interface AutomationCustomPropertyRead
MemberTypeSummary
keystring
type'String' | 'Number' | 'Boolean' | 'Date'
valuestring | number | boolean

AutomationCustomXmlPartReadinterfaceSource ↗

One custom XML part (ECMA-376 Part 1, 22.5): its item id and the namespace of its root.

interface AutomationCustomXmlPartRead
MemberTypeSummary
idstring`ds:itemID`, braced and upper case.
namespaceUristringThe namespace URI of the root element, or an empty string.

AutomationDocumentPortinterfaceSource ↗

What a host needs from the document it acts on.

interface AutomationDocumentPort
MemberTypeSummary
applyCommit ops as one transaction. A port with an undo history makes consecutive commits of one `historyGroup` a single undo step.
batchA working batch over `pkg` that keeps new part names unique for this document.
collaboratingTrue while the document is in a collaboration room. A table structure edit then marks the table, as the editor's own table commands do, so a save repairs the merge markup that a concurrent edit of a peer leaves.
committedCalled once after a batch that changed the document has committed and moved the selection. A browser port records the selection after the batch for redo.
currentPackageThe committed package, or null while there is none (an editor between mounts).
disposeRelease the port.
documentWhich document the port holds now, for a port that can change it (an editor that loads another presentation). A change forgets every handle, so an object of the previous document never addresses an object of the new one that has the same id.
measurerThe measurer text writes re-fit with, when the host has one.
renderImageA PNG picture of a slide or of one shape of it, from the committed package, for a host with the `images` capability. Rejects with a `CommandRefusal` when it cannot draw.
revisionMonotonic revision of the document.
saveThe document as `.pptx` bytes, or null when there is none.
selection?AutomationSelectionPortThe reader's selection, for a browser host.
subscribeChange notification for commits by anyone.
wholeDocumentMake the whole document ready for a reader of every part, as `save` does: a deck that is still opening opens the rest now. False when the document cannot be read whole (a slide did not parse). A port without it is always whole.

AutomationErrorinterfaceSource ↗

One refused operation. Plain data, not an Error: it crosses transports.

code is the stable part. detail is for logs and for the object model's diagnostic code; the object model never copies it into a message, because a store rejection reason would become documented API the moment somebody matched on it.

interface AutomationError
MemberTypeSummary
codeAutomationErrorCode
detail?stringMachine-ish specifics: the store's rejection reason, the bad argument's name.
messagestringHuman-readable, for a log. Never parsed.

AutomationFillReadinterfaceSource ↗

A shape fill. Colors are #RRGGBB; transparency is 0 to 1.

interface AutomationFillRead
MemberTypeSummary
foregroundColorstring | null
transparencynumber | null
typestring`noFill`, `solid`, `gradient`, `pattern`, `pictureAndTexture`, or `slideBackground`.

AutomationFontReadinterfaceSource ↗

The effective font of a text range. A field the runs disagree on is null.

interface AutomationFontRead
MemberTypeSummary
allCapsboolean | null
boldboolean | null
colorstring | null
doubleStrikethroughboolean | null
italicboolean | null
namestring | null
sizenumber | null
smallCapsboolean | null
strikethroughboolean | null
subscriptboolean | null
superscriptboolean | null
underlinestring | null`a:rPr/@u`, `none` without an underline.

AutomationFontWriteinterfaceSource ↗

Font properties a write sets.

interface AutomationFontWrite
MemberTypeSummary
allCaps?boolean
bold?boolean
color?string
doubleStrikethrough?boolean
italic?boolean
name?string
size?numberPoints.
smallCaps?boolean
strikethrough?boolean
subscript?boolean
superscript?boolean
underline?string`ST_TextUnderlineType`.

AutomationHandleinterfaceSource ↗

A stable reference to one presentation object, valid for the life of its host.

interface AutomationHandle<K extends AutomationObjectKind = AutomationObjectKind>
MemberTypeSummary
kindK
refAutomationHandleRef

AutomationHostinterfaceSource ↗

The protocol both hosts implement.

A batch is one revision, one undo step, and one transaction. Operations run in order, so a read sees the writes before it in the same batch. If any operation is refused, nothing is written.

interface AutomationHost
MemberTypeSummary
capabilitiesAutomationCapabilities
disposeRelease everything this host holds. Idempotent; every later call fails `disposed`.
executeRun one ordered batch.
renderImageA PNG picture of a slide or a shape, drawn from the current presentation. A host without the `images` capability answers `unsupported-capability`.
revisionMonotonic revision of the presentation this host acts on.
saveThe current presentation as `.pptx` bytes, through the normalizing writer.
subscribeChange notification. Returns an unsubscribe that is safe to call more than once.

AutomationHostCompositioninterfaceSource ↗

The port and the capabilities a host claims.

interface AutomationHostComposition
MemberTypeSummary
capabilitiesAutomationCapabilities
portAutomationDocumentPort

AutomationHyperlinkReadinterfaceSource ↗

One hyperlink of a slide.

interface AutomationHyperlinkRead
MemberTypeSummary
addressstring | null
lengthnumber | null
screenTipstring | null
shapeAutomationHandle<'shape'>
startnumber | nullFor a text link: the range it covers in the shape's text.
type'textRange' | 'shape'`textRange` or `shape`: what carries the link.

AutomationImageRequestinterfaceSource ↗

What [AutomationHost.renderImage](AutomationHost.renderImage) draws.

interface AutomationImageRequest
MemberTypeSummary
height?numberThe height of that box. Absent sizes: the picture has its own size.
targetAutomationHandleA slide, or a shape on a slide, as a `prepareImage` operation answered it.
width?numberThe width of the box the picture fits into, in pixels, keeping its aspect ratio.

AutomationImageTargetinterfaceSource ↗

What the port draws (AutomationDocumentPort.renderImage): a slide, or one shape of it.

interface AutomationImageTarget
MemberTypeSummary
height?numberThe height of that box.
shapeNodeId?stringThe tree node id of the shape; absent for the whole slide.
slideIndexnumberThe index of the slide in the presentation.
width?numberThe width of the box the picture fits into, in pixels, keeping its aspect ratio.

AutomationInsertSlidesOptionsinterfaceSource ↗

Options of a slide import (Office.js InsertSlideOptions).

interface AutomationInsertSlidesOptions
MemberTypeSummary
formatting?'keepSource' | 'useDestinationTheme'Keep the source layouts, masters, and themes (default), or use this presentation's.
sourceSlideIds?readonly string[]The source slides, by slide id, in the order they go in. Absent: every slide.
targetSlideId?stringThe slide the new slides follow, by id. Absent: they go first.

AutomationLayoutReadinterfaceSource ↗

A layout or master.

interface AutomationLayoutRead
MemberTypeSummary
idstring`p:sldLayoutId/@id` or `p:sldMasterId/@id`, as a string.
masterAutomationHandle<'slideMaster'> | null
namestring
typestring | nullFor a layout: `p:sldLayout/@type` (`cust` when absent). Null for a master.

AutomationLineReadinterfaceSource ↗

A shape outline. The weight is in points.

interface AutomationLineRead
MemberTypeSummary
colorstring | null
dashStylestring | nullThe `a:prstDash/@val` value, or null.
stylestring | nullThe compound line (`a:ln/@cmpd`).
transparencynumber | null
visibleboolean
weightnumber | null

AutomationLineWriteinterfaceSource ↗

Outline properties a write sets.

interface AutomationLineWrite
MemberTypeSummary
color?string
dashStyle?string`ST_PresetLineDashVal`.
style?string`ST_CompoundLine`.
transparency?number
visible?boolean
weight?numberPoints.

AutomationParagraphReadinterfaceSource ↗

The effective paragraph format of a text range. A field the paragraphs disagree on is null.

interface AutomationParagraphRead
MemberTypeSummary
alignmentstring | null`a:pPr/@algn`: `l`, `ctr`, `r`, `just`, `justLow`, `dist`, or `thaiDist`.
bulletStylestring | nullThe autonumber scheme (`ST_TextAutonumberScheme`) when numbered.
bulletTypestring | null`none`, `char`, or `autonum`.
bulletVisibleboolean | null
indentLevelnumber | null1-based list level (`a:pPr/@lvl` + 1).

AutomationParagraphWriteinterfaceSource ↗

Paragraph properties a write sets.

interface AutomationParagraphWrite
MemberTypeSummary
alignment?string`ST_TextAlignType`.
bulletStyle?string
bulletType?'none' | 'char' | 'autonum'`autonum` with a scheme, or `char`.
bulletVisible?boolean
indentLevel?number1-based list level, 1 to 9.

AutomationPlaceholderReadinterfaceSource ↗

ST_PlaceholderType read as the object model names it.

interface AutomationPlaceholderRead
MemberTypeSummary
containedTypestring | nullWhat the shape holds now: its own kind, as `AutomationShapeRead.type` spells it.
typestringThe `p:ph/@type` value (`obj` when absent, ECMA-376 Part 1, 19.7.10).

AutomationPresentationReadinterfaceSource ↗

The presentation. Lengths in points.

interface AutomationPresentationRead
MemberTypeSummary
idstringA stable id for the open presentation in this host.
slideHeightnumber
slideWidthnumber
titlestringThe core properties title.

AutomationPropertiesReadinterfaceSource ↗

The core and extended document properties.

interface AutomationPropertiesRead
MemberTypeSummary
authorstring
categorystring
commentsstring
companystring
creationDatestring | null
keywordsstring
lastAuthorstring
managerstring
revisionNumbernumber
subjectstring
titlestring

AutomationPropertiesWriteinterfaceSource ↗

Document properties a write sets.

interface AutomationPropertiesWrite
MemberTypeSummary
author?string
category?string
comments?string
company?string
keywords?string
manager?string
revisionNumber?number
subject?string
title?string

AutomationResultRefinterfaceSource ↗

The object an earlier operation of the same batch answered with, by its index.

How one batch adds a slide and then writes to it: the slide has no handle until the add runs, so the write names the add's result instead. A reference to an operation that answered null (getSlide with orNull) makes a read answer null and a write fail with invalid-handle.

interface AutomationResultRef
MemberTypeSummary
resultnumber

AutomationSelectionPortinterfaceSource ↗

A reader's selection, as the browser host's port reports and sets it.

interface AutomationSelectionPort
MemberTypeSummary
readThe selected slides (`p:sldId/@id`), the selected shapes, and the selected text.
selectShapes
selectSlides
selectText

AutomationSelectionReadinterfaceSource ↗

A reader's selection (browser host).

interface AutomationSelectionRead
MemberTypeSummary
shapesreadonly AutomationHandle<'shape'>[]
slidesreadonly AutomationHandle<'slide'>[]
text{ readonly shape: AutomationHandle<'shape'>; readonly start: number; readonly length: number; } | nullThe selected text: a shape and a range of its text, or null.

AutomationShapeReadinterfaceSource ↗

One shape, as plain values. Lengths in points, the rotation in degrees.

interface AutomationShapeRead
MemberTypeSummary
altTextDescriptionstring
altTextTitlestring
geometrystring | nullThe preset geometry (`a:prstGeom/@prst`), or null.
hasTextFramebooleanWhether the shape can hold text (`p:txBody`).
heightnumber
idstring`p:cNvPr/@id` as a string.
isDecorativebooleanThe decorative flag of the `a16:decorative` extension.
leftnumber
levelnumberGroup depth: 0 for a top-level shape.
namestring
parentGroupAutomationHandle<'shape'> | null
placeholderAutomationPlaceholderRead | null
rotationnumber
topnumber
typestring`geometricShape`, `line`, `textBox`, `placeholder`, `image`, `group`, `table`, `chart`, `diagram` (a `dgm:` frame), `media`, `ole`, `freeform`, or `unsupported`.
visibleboolean
widthnumber
zOrderPositionnumberPosition in the owner's z-order, from 0 at the back.

AutomationShapeWriteinterfaceSource ↗

Shape properties a write sets.

interface AutomationShapeWrite extends AutomationBox
MemberTypeSummary
altTextDescription?string
altTextTitle?string
isDecorative?boolean
name?string
rotation?number
visible?boolean

AutomationSlideReadinterfaceSource ↗

A slide.

interface AutomationSlideRead
MemberTypeSummary
hiddenboolean
idstring`p:sldId/@id`, as a string.
indexnumber
layoutAutomationHandle<'slideLayout'> | null
masterAutomationHandle<'slideMaster'> | null

AutomationTableCellFormatReadinterfaceSource ↗

The borders and margins of one table cell (a:tcPr, ECMA-376 Part 1, 21.1.3.17). A border reads as the cell shows it: its own line, else the table style's on a slide. Margins in points.

interface AutomationTableCellFormatRead
MemberTypeSummary
borders{ readonly left: AutomationLineRead; readonly right: AutomationLineRead; readonly top: AutomationLineRead; readonly bottom: AutomationLineRead; readonly diagonalDown: AutomationLineRead; readonly diagonalUp: AutomationLineRead; }
margins{ readonly left: number; readonly right: number; readonly top: number; readonly bottom: number; }

AutomationTableCellReadinterfaceSource ↗

One cell of a table, at its grid position.

interface AutomationTableCellRead
MemberTypeSummary
anchorstring`ST_TextAnchoringType` of the cell (`a:tcPr/@anchor`, default `t`).
anchorCenterboolean`a:tcPr/@anchorCtr`.
columnCountnumber
columnIndexnumber
rowCountnumberThe rows and columns the cell spans.
rowIndexnumber
textstring

AutomationTableReadinterfaceSource ↗

A table's grid and values. Widths and heights in points.

interface AutomationTableRead
MemberTypeSummary
columnCountnumber
columnWidthsreadonly number[]
mergedAreasreadonly { readonly rowIndex: number; readonly columnIndex: number; readonly rowCount: number; readonly columnCount: number; }[]Merged areas, top-left cell first.
rowCountnumber
rowHeightsreadonly number[]
style{ readonly styleId: string | null; readonly styleName: string | null; readonly firstRow: boolean; readonly lastRow: boolean; readonly firstColumn: boolean; readonly lastColumn: boolean; readonly bandedRows: boolean; readonly bandedColumns: boolean; }`a:tblPr` flags and the style id.
valuesreadonly (readonly string[])[]

AutomationTableStyleWriteinterfaceSource ↗

Table style options (a:tblPr flags, ECMA-376 Part 1, 21.1.3.15) and the style a write sets.

interface AutomationTableStyleWrite
MemberTypeSummary
bandedColumns?boolean
bandedRows?boolean
firstColumn?boolean
firstRow?boolean
lastColumn?boolean
lastRow?boolean
styleName?string | nullThe style by its `styleName`: one the presentation defines in `ppt/tableStyles.xml`, or the built-in default. Null removes the style choice.

AutomationTaginterfaceSource ↗

One key and value of a tag list (p:tagLst).

interface AutomationTag
MemberTypeSummary
keystring
valuestring

AutomationTextFrameReadinterfaceSource ↗

A text body's frame. Margins in points.

interface AutomationTextFrameRead
MemberTypeSummary
autoSize'none' | 'normal' | 'shape'`none`, `normal` (`a:normAutofit`), or `shape` (`a:spAutoFit`).
bottomMarginnumber
hasTextboolean
leftMarginnumber
rightMarginnumber
topMarginnumber
verticalAlignmentstring`a:bodyPr/@anchor`, with `anchorCtr` (`ctr` + centered reads as `ctrCentered`).
wordWrapboolean

AutomationTextFrameWriteinterfaceSource ↗

Text frame properties a write sets. Margins in points.

interface AutomationTextFrameWrite
MemberTypeSummary
autoSize?'none' | 'normal' | 'shape'
bottomMargin?number
leftMargin?number
rightMargin?number
topMargin?number
verticalAlignment?string`t`, `ctr`, `b`, or with a centered column `tCentered`, `ctrCentered`, `bCentered`.
wordWrap?boolean

AutomationTextRunReadinterfaceSource ↗

One run of a text body with its effective character format.

interface AutomationTextRunRead
MemberTypeSummary
fontAutomationFontRead
textstringThe run text; a paragraph break reads as `\r` and a line break as `\v`.

AutomationTextSpaninterfaceSource ↗

A stretch of a shape's text: a UTF-16 start and length. Absent means the whole text.

interface AutomationTextSpan
MemberTypeSummary
lengthnumber
startnumber

ServerAutomationOptionsinterfaceSource ↗

Options for a host over bytes.

interface ServerAutomationOptions extends StoreAutomationOptions
MemberTypeSummary
limits?ZipLimitsZip limits for the bounded reader.

StoreAutomationOptionsinterfaceSource ↗

How a store host commits and measures.

interface StoreAutomationOptions
MemberTypeSummary
collaborating?booleanThe store is shared with a collaboration room. A table structure edit then marks the table, as the editor's table commands do in a room. Default `false`.
label?stringThe label of each committed transaction (undo history). Default `automation`.
measurer?TextMeasurerThe measurer text writes re-fit with (ECMA-376 Part 1, 21.1.2.1). Without one, a text write keeps the shape's size and font scale as they are.
renderImage?(target: AutomationImageTarget) => Promise<Uint8Array>Draws a PNG picture of a slide, or of one shape of it, from the committed package. With it, the host claims the `images` capability and `getImageAsBase64` works; without it, a picture request refuses with `unsupported-capability`. This lane has no layout or paint, so the caller supplies the drawing: `@pptx-editor.dev/editor-api` builds it from the editor's own paint and a rasterizer (`createServer({ rasterize })`). Rejects with a `CommandRefusal` when it cannot draw.

Type aliases (18)

AutomationBackgroundWritetypeSource ↗

A background write (p:cSld/p:bg, ECMA-376 Part 1, 19.3.1.1). A fill write gives the part an own p:bgPr; a field it leaves out keeps the current value, or takes the default.

type AutomationBackgroundWrite = 
/** Remove the own `p:bg`: show the background of the layout or master. */
{
    readonly kind: 'follow';
}
/** Copy the background the part shows into an own `p:bg`. */
 | {
    readonly kind: 'own';
}
/** `showMasterSp`: hide or show the shapes of the level above. */
 | {
    readonly kind: 'graphicsHidden';
    readonly hidden: boolean;
} | {
    readonly kind: 'solid';
    readonly color?: string;
    readonly transparency?: number;
}
/** The gradient shading: `linear`, or an `a:path` of `circle`, `rect`, or `shape`. */
 | {
    readonly kind: 'gradient';
    readonly gradientType?: 'linear' | 'circle' | 'rect' | 'shape';
} | {
    readonly kind: 'pattern';
    readonly pattern?: string;
    readonly foregroundColor?: string;
    readonly backgroundColor?: string;
}
/** A stretched picture from PNG, JPEG, or GIF bytes in base64, or the current picture. */
 | {
    readonly kind: 'picture';
    readonly base64?: string;
    readonly transparency?: number;
};

AutomationCellBorderSidetypeSource ↗

A line of a table cell: an edge, or a diagonal (a:lnTlToBr down, a:lnBlToTr up).

type AutomationCellBorderSide = 'left' | 'right' | 'top' | 'bottom' | 'diagonalDown' | 'diagonalUp';

AutomationCustomPropertyWritetypeSource ↗

A custom property value a write sets. A Date is an ISO 8601 text.

type AutomationCustomPropertyWrite = {
    readonly type: 'String';
    readonly value: string;
} | {
    readonly type: 'Number';
    readonly value: number;
} | {
    readonly type: 'Boolean';
    readonly value: boolean;
} | {
    readonly type: 'Date';
    readonly value: string;
};

AutomationErrorCodetypeSource ↗

Why an operation was refused, as a value to branch on.

Distinguishable on purpose: the object model maps each code to a different error, and a caller that retries stale-revision must not retry invalid-handle.

type AutomationErrorCode = 
/** Nothing was applied: `expectedRevision` did not match the host's revision. */
'stale-revision'
/** A handle this host never minted, one of another kind, or one whose object is gone. */
 | 'invalid-handle'
/** An argument outside its range: an index, an offset, a length, a size. */
 | 'invalid-argument'
/** The operation needs a capability this host reports false. */
 | 'unsupported-capability'
/** The host has been disposed. Every later call fails this way. */
 | 'disposed'
/** The store refused the transaction; nothing was applied. */
 | 'transaction-refused'
/** The operation is not one this protocol version defines. */
 | 'unknown-operation'
/** The target holds content this operation does not edit (a chart, a diagram, a picture). */
 | 'unsupported-content'
/** A lookup by key or index found nothing, and the caller did not ask for null. */
 | 'item-not-found'
/** The host is live but holds no presentation right now (an editor between mounts). */
 | 'document-unavailable';

AutomationFillWritetypeSource ↗

A fill write. Colors are #RRGGBB or a preset color name; transparency is 0 to 1.

type AutomationFillWrite = {
    readonly kind: 'solid';
    readonly color: string;
    readonly transparency?: number;
} | {
    readonly kind: 'clear';
}
/** Change the transparency of the current solid fill. */
 | {
    readonly kind: 'transparency';
    readonly transparency: number;
}
/** A picture fill (`a:blipFill`) from PNG, JPEG, or GIF bytes in base64, stretched. */
 | {
    readonly kind: 'image';
    readonly base64: string;
};

AutomationHandleReftypeSource ↗

An opaque host-minted name for a presentation object.

Branded so a consumer cannot invent one. Its content is meaningless outside the host that minted it: each host draws a random token when it starts and stamps it into every ref, so a ref passed to another host, even one open on the same bytes, is invalid-handle.

type AutomationHandleRef = string & {
    readonly [AUTOMATION_HANDLE_BRAND]: 'handle';
};

AutomationImageResulttypeSource ↗

A PNG picture as base64, or why it could not be drawn.

type AutomationImageResult = {
    readonly ok: true;
    readonly base64: string;
} | {
    readonly ok: false;
    readonly error: AutomationError;
};

AutomationItemKeytypeSource ↗

How a collection item is found: by position, or by the id the object model shows.

type AutomationItemKey = {
    readonly index: number;
} | {
    readonly id: string;
};

AutomationNewShapetypeSource ↗

What a new shape is.

type AutomationNewShape = 
/** A preset geometry (`ST_ShapeType`, ECMA-376 Part 1, 20.1.10.56). */
{
    readonly kind: 'geometric';
    readonly geometry: string;
}
/** A connector: `straight`, `elbow`, or `curve`. */
 | {
    readonly kind: 'line';
    readonly connector: 'straight' | 'elbow' | 'curve';
} | {
    readonly kind: 'textBox';
    readonly text: string;
} | {
    readonly kind: 'table';
    readonly rows: number;
    readonly columns: number;
    readonly values?: readonly (readonly string[])[];
};

AutomationObjectKindtypeSource ↗

What kind of presentation object a handle names.

type AutomationObjectKind = 'presentation' | 'slide' | 'slideLayout' | 'slideMaster' | 'shape';

AutomationOperationtypeSource ↗

Every operation a host understands.

type AutomationOperation = {
    readonly op: 'getPresentation';
} | {
    readonly op: 'readPresentation';
} | {
    readonly op: 'setPageSetup';
    readonly slideWidth?: number;
    readonly slideHeight?: number;
} | {
    readonly op: 'getProperties';
} | {
    readonly op: 'setProperties';
    readonly properties: AutomationPropertiesWrite;
} | {
    readonly op: 'readCustomProperties';
    readonly owner: AutomationRef;
} | {
    readonly op: 'setCustomProperty';
    readonly owner: AutomationRef;
    readonly key: string;
    readonly value: AutomationCustomPropertyWrite;
} | {
    readonly op: 'deleteCustomProperty';
    readonly owner: AutomationRef;
    readonly key: string;
} | {
    readonly op: 'deleteCustomProperties';
    readonly owner: AutomationRef;
} | {
    readonly op: 'listCustomXmlParts';
    readonly owner: AutomationRef;
    readonly namespaceUri?: string;
} | {
    readonly op: 'readCustomXml';
    readonly owner: AutomationRef;
    readonly id: string;
} | {
    readonly op: 'addCustomXmlPart';
    readonly owner: AutomationRef;
    readonly xml: string;
    readonly id?: string;
} | {
    readonly op: 'setCustomXml';
    readonly owner: AutomationRef;
    readonly id: string;
    readonly xml: string;
} | {
    readonly op: 'deleteCustomXmlPart';
    readonly owner: AutomationRef;
    readonly id: string;
} | {
    readonly op: 'listSlides';
} | {
    readonly op: 'getSlide';
    readonly key: AutomationItemKey;
    readonly orNull?: boolean;
} | {
    readonly op: 'readSlide';
    readonly slide: AutomationRef;
} | {
    readonly op: 'addSlide';
    readonly index?: number;
    readonly layout?: AutomationRef;
    readonly master?: AutomationRef;
    readonly layoutId?: string;
    readonly masterId?: string;
} | {
    readonly op: 'getSlideLayout';
    readonly slide: AutomationRef;
} | {
    readonly op: 'getSlideMaster';
    readonly owner: AutomationRef;
} | {
    readonly op: 'deleteSlide';
    readonly slide: AutomationRef;
} | {
    readonly op: 'moveSlide';
    readonly slide: AutomationRef;
    readonly index: number;
} | {
    readonly op: 'applyLayout';
    readonly slide: AutomationRef;
    readonly layout: AutomationRef;
} | {
    readonly op: 'exportSlides';
    readonly slides: readonly AutomationRef[];
} | {
    readonly op: 'prepareImage';
    readonly target: AutomationRef;
    readonly width?: number;
    readonly height?: number;
} | {
    readonly op: 'insertSlides';
    readonly base64: string;
    readonly options?: AutomationInsertSlidesOptions;
} | {
    readonly op: 'listHyperlinks';
    readonly slide: AutomationRef;
} | {
    readonly op: 'listBindings';
    readonly owner: AutomationRef;
} | {
    readonly op: 'addBinding';
    readonly owner: AutomationRef;
    readonly shape: AutomationRef;
    readonly id: string;
} | {
    readonly op: 'addBindingFromSelection';
    readonly owner: AutomationRef;
    readonly id: string;
} | {
    readonly op: 'deleteBinding';
    readonly owner: AutomationRef;
    readonly id: string;
} | {
    readonly op: 'getBindingShape';
    readonly owner: AutomationRef;
    readonly id: string;
} | {
    readonly op: 'listMasters';
} | {
    readonly op: 'getMaster';
    readonly key: AutomationItemKey;
    readonly orNull?: boolean;
} | {
    readonly op: 'readMaster';
    readonly master: AutomationRef;
} | {
    readonly op: 'listLayouts';
    readonly master: AutomationRef;
} | {
    readonly op: 'getLayout';
    readonly master: AutomationRef;
    readonly key: AutomationItemKey;
    readonly orNull?: boolean;
} | {
    readonly op: 'readLayout';
    readonly layout: AutomationRef;
} | {
    readonly op: 'listShapes';
    readonly container: AutomationRef;
    readonly orNull?: boolean;
} | {
    readonly op: 'getShape';
    readonly container: AutomationRef;
    readonly key: AutomationItemKey;
    readonly orNull?: boolean;
} | {
    readonly op: 'readShape';
    readonly shape: AutomationRef;
    readonly group?: boolean;
    readonly orNull?: boolean;
} | {
    readonly op: 'addShape';
    readonly container: AutomationRef;
    readonly shape: AutomationNewShape;
    readonly box?: AutomationBox;
} | {
    readonly op: 'deleteShape';
    readonly shape: AutomationRef;
} | {
    readonly op: 'setShape';
    readonly shape: AutomationRef;
    readonly props: AutomationShapeWrite;
} | {
    readonly op: 'setZOrder';
    readonly shape: AutomationRef;
    readonly position: AutomationZOrder;
} | {
    readonly op: 'group';
    readonly shapes: readonly AutomationRef[];
} | {
    readonly op: 'ungroup';
    readonly group: AutomationRef;
} | {
    readonly op: 'getParentGroup';
    readonly shape: AutomationRef;
    readonly orNull?: boolean;
} | {
    readonly op: 'setShapeHyperlink';
    readonly shape: AutomationRef;
    readonly address: string | null;
    readonly screenTip?: string;
} | {
    readonly op: 'parentOf';
    readonly shape: AutomationRef;
    readonly kind: 'slide' | 'slideLayout' | 'slideMaster';
    readonly orNull?: boolean;
} | {
    readonly op: 'readFill';
    readonly shape: AutomationRef;
    readonly cell?: AutomationCellAddress;
} | {
    readonly op: 'setFill';
    readonly shape: AutomationRef;
    readonly fill: AutomationFillWrite;
    readonly cell?: AutomationCellAddress;
} | {
    readonly op: 'readBackground';
    readonly owner: AutomationRef;
} | {
    readonly op: 'setBackground';
    readonly owner: AutomationRef;
    readonly background: AutomationBackgroundWrite;
}
/** A color of the theme's `a:clrScheme`: `dk1`, `lt1`, … `accent6`, `hlink`, `folHlink`. */
 | {
    readonly op: 'readThemeColor';
    readonly owner: AutomationRef;
    readonly slot: string;
} | {
    readonly op: 'setThemeColor';
    readonly owner: AutomationRef;
    readonly slot: string;
    readonly color: string;
} | {
    readonly op: 'readLine';
    readonly shape: AutomationRef;
} | {
    readonly op: 'setLine';
    readonly shape: AutomationRef;
    readonly line: AutomationLineWrite;
} | {
    readonly op: 'readTextFrame';
    readonly shape: AutomationRef;
    readonly orNull?: boolean;
} | {
    readonly op: 'setTextFrame';
    readonly shape: AutomationRef;
    readonly props: AutomationTextFrameWrite;
} | {
    readonly op: 'readText';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly cell?: AutomationCellAddress;
    readonly orNull?: boolean;
} | {
    readonly op: 'setText';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly text: string;
    readonly cell?: AutomationCellAddress;
} | {
    readonly op: 'readFont';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly cell?: AutomationCellAddress;
    readonly orNull?: boolean;
} | {
    readonly op: 'readTextRuns';
    readonly shape: AutomationRef;
    readonly cell?: AutomationCellAddress;
} | {
    readonly op: 'setFont';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly font: AutomationFontWrite;
    readonly cell?: AutomationCellAddress;
} | {
    readonly op: 'readParagraph';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly cell?: AutomationCellAddress;
    readonly orNull?: boolean;
} | {
    readonly op: 'setParagraph';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly paragraph: AutomationParagraphWrite;
    readonly cell?: AutomationCellAddress;
} | {
    readonly op: 'setHyperlink';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
    readonly address: string | null;
    readonly screenTip?: string;
} | {
    readonly op: 'listTextHyperlinks';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
} | {
    readonly op: 'readTags';
    readonly owner: AutomationRef;
} | {
    readonly op: 'setTag';
    readonly owner: AutomationRef;
    readonly key: string;
    readonly value: string;
} | {
    readonly op: 'deleteTag';
    readonly owner: AutomationRef;
    readonly key: string;
} | {
    readonly op: 'readTable';
    readonly shape: AutomationRef;
} | {
    readonly op: 'readTableCell';
    readonly shape: AutomationRef;
    readonly row: number;
    readonly column: number;
} | {
    readonly op: 'setTableCell';
    readonly shape: AutomationRef;
    readonly row: number;
    readonly column: number;
    readonly text: string;
} | {
    readonly op: 'insertTableRows';
    readonly shape: AutomationRef;
    readonly index?: number;
    readonly count: number;
} | {
    readonly op: 'insertTableColumns';
    readonly shape: AutomationRef;
    readonly index?: number;
    readonly count: number;
} | {
    readonly op: 'deleteTableRows';
    readonly shape: AutomationRef;
    readonly index: number;
    readonly count: number;
} | {
    readonly op: 'deleteTableColumns';
    readonly shape: AutomationRef;
    readonly index: number;
    readonly count: number;
} | {
    readonly op: 'mergeTableCells';
    readonly shape: AutomationRef;
    readonly row: number;
    readonly column: number;
    readonly rowCount: number;
    readonly columnCount: number;
} | {
    readonly op: 'setTableCellAnchor';
    readonly shape: AutomationRef;
    readonly row: number;
    readonly column: number;
    readonly anchor: string;
    readonly anchorCenter: boolean;
} | {
    readonly op: 'splitTableCell';
    readonly shape: AutomationRef;
    readonly row: number;
    readonly column: number;
    readonly rowCount: number;
    readonly columnCount: number;
} | {
    readonly op: 'resizeTableCell';
    readonly shape: AutomationRef;
    readonly row: number;
    readonly column: number;
    readonly rowCount: number;
    readonly columnCount: number;
} | {
    readonly op: 'clearTable';
    readonly shape: AutomationRef;
    readonly text: boolean;
    readonly format: boolean;
} | {
    readonly op: 'readTableCellFormat';
    readonly shape: AutomationRef;
    readonly cell: AutomationCellAddress;
} | {
    readonly op: 'setTableCellBorder';
    readonly shape: AutomationRef;
    readonly cell: AutomationCellAddress;
    readonly side: AutomationCellBorderSide;
    readonly line: AutomationLineWrite;
} | {
    readonly op: 'setTableCellMargins';
    readonly shape: AutomationRef;
    readonly cell: AutomationCellAddress;
    readonly margins: AutomationCellMarginsWrite;
} | {
    readonly op: 'setTableStyle';
    readonly shape: AutomationRef;
    readonly style: AutomationTableStyleWrite;
} | {
    readonly op: 'readAdjustments';
    readonly shape: AutomationRef;
} | {
    readonly op: 'setAdjustment';
    readonly shape: AutomationRef;
    readonly index: number;
    readonly value: number;
} | {
    readonly op: 'setTableSize';
    readonly shape: AutomationRef;
    readonly target: 'row' | 'column';
    readonly index: number;
    readonly size: number;
} | {
    readonly op: 'readSelection';
} | {
    readonly op: 'selectSlides';
    readonly slides: readonly AutomationRef[];
} | {
    readonly op: 'selectShapes';
    readonly shapes: readonly AutomationRef[];
} | {
    readonly op: 'selectText';
    readonly shape: AutomationRef;
    readonly span?: AutomationTextSpan;
};

AutomationOperationResulttypeSource ↗

One operation's outcome.

skipped is what makes an atomic batch honest. When a batch fails, every operation other than the failing one reports skipped, including reads and the operations before it: reporting those as ok would describe a state that was never published.

type AutomationOperationResult = {
    readonly status: 'ok';
    readonly value: AutomationValue;
} | {
    readonly status: 'error';
    readonly error: AutomationError;
} | {
    readonly status: 'skipped';
};

AutomationReftypeSource ↗

A handle, or the handle an earlier operation of the batch answered with.

type AutomationRef = AutomationHandle | AutomationResultRef;

AutomationSaveResulttypeSource ↗

.pptx bytes, or why they could not be produced.

type AutomationSaveResult = {
    readonly ok: true;
    readonly bytes: Uint8Array;
} | {
    readonly ok: false;
    readonly error: AutomationError;
};

AutomationUnsubscribetypeSource ↗

What a subscription returns. Calling it twice is safe.

type AutomationUnsubscribe = () => void;

AutomationValuetypeSource ↗

What an operation answered with.

type AutomationValue = {
    readonly kind: 'handle';
    readonly handle: AutomationHandle;
} | {
    readonly kind: 'handles';
    readonly handles: readonly AutomationHandle[];
}
/** A lookup that found nothing, asked for with `orNull`. */
 | {
    readonly kind: 'null';
} | {
    readonly kind: 'text';
    readonly text: string;
} | {
    readonly kind: 'number';
    readonly value: number;
} | {
    readonly kind: 'flag';
    readonly value: boolean;
}
/** `.pptx` bytes as base64: an exported slide. */
 | {
    readonly kind: 'base64';
    readonly base64: string;
} | {
    readonly kind: 'presentation';
    readonly presentation: AutomationPresentationRead;
} | {
    readonly kind: 'slide';
    readonly slide: AutomationSlideRead;
} | {
    readonly kind: 'layout';
    readonly layout: AutomationLayoutRead;
} | {
    readonly kind: 'shape';
    readonly shape: AutomationShapeRead;
} | {
    readonly kind: 'fill';
    readonly fill: AutomationFillRead;
} | {
    readonly kind: 'background';
    readonly background: AutomationBackgroundRead;
} | {
    readonly kind: 'line';
    readonly line: AutomationLineRead;
} | {
    readonly kind: 'textFrame';
    readonly textFrame: AutomationTextFrameRead;
} | {
    readonly kind: 'font';
    readonly font: AutomationFontRead;
} | {
    readonly kind: 'textRuns';
    readonly runs: readonly AutomationTextRunRead[];
} | {
    readonly kind: 'paragraph';
    readonly paragraph: AutomationParagraphRead;
} | {
    readonly kind: 'tags';
    readonly tags: readonly AutomationTag[];
} | {
    readonly kind: 'properties';
    readonly properties: AutomationPropertiesRead;
} | {
    readonly kind: 'customProperties';
    readonly properties: readonly AutomationCustomPropertyRead[];
} | {
    readonly kind: 'customXmlParts';
    readonly parts: readonly AutomationCustomXmlPartRead[];
} | {
    readonly kind: 'table';
    readonly table: AutomationTableRead;
} | {
    readonly kind: 'tableCell';
    readonly cell: AutomationTableCellRead;
} | {
    readonly kind: 'tableCellFormat';
    readonly format: AutomationTableCellFormatRead;
} | {
    readonly kind: 'adjustments';
    readonly adjustments: AutomationAdjustmentsRead;
} | {
    readonly kind: 'hyperlinks';
    readonly hyperlinks: readonly AutomationHyperlinkRead[];
} | {
    readonly kind: 'bindings';
    readonly bindings: readonly AutomationBindingRead[];
} | {
    readonly kind: 'selection';
    readonly selection: AutomationSelectionRead;
}
/** A command that committed. The effect is the response's revision. */
 | {
    readonly kind: 'applied';
};

AutomationZOrdertypeSource ↗

ShapeZOrder moves.

type AutomationZOrder = 'bringForward' | 'bringToFront' | 'sendBackward' | 'sendToBack';

ServerAutomationRejectiontypeSource ↗

Why bytes could not be opened.

type ServerAutomationRejection = PackageRejection | {
    readonly reason: 'empty';
};

Variables (2)

AUTOMATION_COMMANDSconstSource ↗

The operations that write. Every other operation only reads.

AUTOMATION_COMMANDS: ReadonlySet<AutomationOperation['op']>

MAX_BATCH_OPERATIONSconstSource ↗

The most operations one batch may carry.

MAX_BATCH_OPERATIONS = 10000