@paged-media/plugin-api 0.2.53-canary.0 → 0.2.55-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/assets.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Disposable } from "./host";
2
+ import type { PageId } from "./wire";
2
3
  /** What `host.assets` can serve. `"fonts"` gates `getFontFace` (W-06);
3
4
  * `"images"` gates `getPlacedImage` (C-5 / I-04 — OPEN since core v42:
4
5
  * the engine serves a placed image's original bytes, so `validate`
@@ -46,6 +47,27 @@ export interface PlacedImageAsset {
46
47
  /** Natural pixel height of the placed image. */
47
48
  height: number;
48
49
  }
50
+ /**
51
+ * What {@link AssetSurface.registerDocumentFont} did. Never a throw (the
52
+ * undeclared-`fonts` gate aside, as on every asset door):
53
+ *
54
+ * - `registered` — the document holds the face now; `pageIds` are the pages
55
+ * the engine laid out again because text there resolves to it;
56
+ * - `held` — the document already held a face for the family (and style),
57
+ * so nothing was sent: the door fills a gap, it never replaces a face;
58
+ * - `refused` — nothing was registered; `reason` says why (the
59
+ * `document.write` gate, the per-face budget, bytes the canvas cannot
60
+ * draw, the engine's own refusal or a dead channel).
61
+ */
62
+ export type DocumentFontOutcome = {
63
+ status: "registered";
64
+ pageIds: PageId[];
65
+ } | {
66
+ status: "held";
67
+ } | {
68
+ status: "refused";
69
+ reason: string;
70
+ };
49
71
  /**
50
72
  * The asset accessor a bundle reaches through `host.assets`. Two reads:
51
73
  * DOCUMENT-registered font face bytes by family (+ optional style), and
@@ -54,9 +76,10 @@ export interface PlacedImageAsset {
54
76
  * the document already holds, and the host answers from that or
55
77
  * `null`. Capability-gated per kind: `getFontFace` requires
56
78
  * `capabilities.assets` ∋ `"fonts"`, `getPlacedImage` ∋ `"images"`
57
- * (the host gate throws in `'enforce'`, warns in `'warn'`). One write
58
- * sits beside the reads — `registerFont`, scene-layer faces only (W-15);
59
- * it adds nothing the document can see.
79
+ * (the host gate throws in `'enforce'`, warns in `'warn'`). Two writes
80
+ * sit beside the reads — `registerFont`, scene-layer faces only (W-15),
81
+ * which adds nothing the document can see, and `registerDocumentFont`,
82
+ * a face for the document where it has none (ADR 328).
60
83
  */
61
84
  export interface AssetSurface {
62
85
  /**
@@ -93,4 +116,33 @@ export interface AssetSurface {
93
116
  * inert `Disposable` — scene text keeps its fallback face.
94
117
  */
95
118
  registerFont(bytes: Uint8Array, family: string, style?: string): Promise<Disposable>;
119
+ /**
120
+ * ADR 328 — give the DOCUMENT a face for `family` (+ `style`) when it
121
+ * holds none: the engine's document registry takes the bytes
122
+ * (`registerFont` with `scope: "document"`), the text that names the
123
+ * family is laid out and drawn in them, and the Fonts collection no
124
+ * longer flags the family missing. For a bundle that writes NATIVE text
125
+ * in a face the document lacks — paged.web's bake names the face each
126
+ * run was shaped in — so the text it wrote is drawn as it was shaped.
127
+ *
128
+ * It fills a gap and never replaces: when the document already holds a
129
+ * face for the family in that style (any face of the family when
130
+ * `style` is omitted), nothing is sent and the outcome is `held`. So a
131
+ * bundle cannot change how text that already resolves is drawn.
132
+ *
133
+ * The face is not undoable and is not written into a saved file (a
134
+ * document names its fonts; it carries no face bytes): the engine keeps
135
+ * it for the session, for every document opened after too. A bundle
136
+ * whose text needs it in a later session provides it again (at
137
+ * `document.onDidOpen`, or when it writes the text).
138
+ *
139
+ * Gates: `capabilities.assets` ∋ `"fonts"` (throws in 'enforce', as on
140
+ * every asset door) and `capabilities.document.write` (it changes how
141
+ * the document lays out; refused in 'enforce'). Refused, too: a face
142
+ * over `ASSET_BUDGETS.maxFontFaceBytes`, bytes that are not a TrueType
143
+ * or OpenType face (WOFF and WOFF2 included — the canvas reads neither),
144
+ * an empty family. Never throws otherwise. Calls for one face at the
145
+ * same time register it once. Probe `supports("assets.documentFont@1")`.
146
+ */
147
+ registerDocumentFont(bytes: Uint8Array, family: string, style?: string): Promise<DocumentFontOutcome>;
96
148
  }
package/dist/host.d.ts CHANGED
@@ -794,14 +794,37 @@ export interface WillSaveEvent {
794
794
  /** The container being written. */
795
795
  format: "paged";
796
796
  }
797
+ /**
798
+ * One committed change to the document's content — one step in its history.
799
+ * `kind` names what committed it (the engine's own reply kind):
800
+ *
801
+ * - `mutationApplied` — a `mutate`: a bundle's write, a panel field, a command;
802
+ * - `undoApplied` / `redoApplied` — an undo or a redo;
803
+ * - `gestureCommitted` — a canvas gesture (a frame dragged, resized or
804
+ * rotated by its handles) committed on the engine (0.2.55);
805
+ * - `scriptResult` — a `paged.*` script finished (0.2.55). The engine names
806
+ * neither its pages nor whether it wrote, so `pageIds` is empty and
807
+ * `pagesUnknown` is set: treat every page as changed.
808
+ *
809
+ * A host from before 0.2.55 reports the first three only; probe
810
+ * `supports("document.onDidChange@2")` for the full set.
811
+ */
797
812
  export interface DocumentChangeEvent {
798
- kind: "mutationApplied" | "undoApplied" | "redoApplied";
813
+ kind: "mutationApplied" | "undoApplied" | "redoApplied" | "gestureCommitted" | "scriptResult";
814
+ /** The pages whose content the change touched (empty: none, unless
815
+ * `pagesUnknown`). */
799
816
  pageIds: PageId[];
817
+ /** Set when the host cannot say which pages changed (a script run):
818
+ * `pageIds` is then empty and any page may have changed. */
819
+ pagesUnknown?: true;
800
820
  /** Content-box reflow (protocol v38, C-2/S-05): present ONLY when the
801
821
  * change RESIZED a frame's content box (a `resizeFrame`) — never on a
802
822
  * pure transform (move/scale/rotate is display-only, §8.5). A
803
823
  * pagination consumer re-splits on this and ignores transform-only
804
- * changes (where it is absent). */
824
+ * changes (where it is absent). The engine reports it for a
825
+ * `resizeFrame` mutation only: a `gestureCommitted` never carries it,
826
+ * even for a resize by the handles, so a consumer that follows frame
827
+ * sizes re-reads geometry on a gesture commit. */
805
828
  reflow?: {
806
829
  frameId: string;
807
830
  contentBox: [number, number, number, number];
@@ -1081,6 +1104,15 @@ export interface DocumentSurface {
1081
1104
  * `supports("document.readStory@1")`; a host without the v54 read backend
1082
1105
  * throws `PluginApiNotImplemented` (a visible seam, never a fake value). */
1083
1106
  storyContent(storyId: string): Promise<StoryContent | null>;
1107
+ /**
1108
+ * Every committed change to the document, whatever committed it: a
1109
+ * mutation, an undo or redo, a canvas gesture's commit, a script run
1110
+ * (see {@link DocumentChangeEvent} for the kinds). A gesture still in
1111
+ * flight, a cancelled one and a script suspended on the host's objects
1112
+ * are not changes. Gated on `capabilities.document.read`. Probe
1113
+ * `supports("document.onDidChange@2")`: a host without it reports
1114
+ * mutations, undos and redos only.
1115
+ */
1084
1116
  onDidChange(listener: (e: DocumentChangeEvent) => void): Disposable;
1085
1117
  /**
1086
1118
  * W-22 — a document became the active one: opened from a file, created
@@ -1178,6 +1210,8 @@ export interface BakeContext {
1178
1210
  }
1179
1211
  export interface SelectionSurface {
1180
1212
  get(): ElementId[];
1213
+ /** Select as a click does: the host's selection AND the selection box
1214
+ * drawn around it follow. Resolves the ids the engine applied. */
1181
1215
  set(ids: ElementId[], mode?: SelectionMode): Promise<ElementId[]>;
1182
1216
  onDidChange(listener: (ids: ElementId[]) => void): Disposable;
1183
1217
  }
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export type { BundleHost, ContributionSurface, SceneLayerSurface, SceneLayerSubm
5
5
  export type { PanelSchema, PanelSchemaSection, PanelSchemaRow, SchemaPanelContribution, SchemaPanelRenderer, SchemaPanelRendererProps, WidgetValueBinding, BindingRef, SchemaGate, WidgetCollectionBinding, SchemaRowAction, SchemaListAction, SchemaListSpec, PanelSchemaWidgetRow, PanelSchemaPropertyRow, PropertyFieldAddress, PropertyFieldStyle, PropertyFieldOption, PropertySubField, PropertyListPresentation, } from "./panel-schema";
6
6
  export type { WidgetSurface, ColorPickerProps, CodeEditorProps, CodeEditorDiagnostic, CodeEditorLanguage, PropertyFieldProps, PropertyFrameProps, PropertyFieldTarget, } from "./widgets";
7
7
  export type { BindingTarget, BindingPropertyRequest, BindingPropertyWrite, BindingCollectionRequest, BindingRead, BindingResolved, BindingDecline, BindingWrite, BindingCollection, BindingOp, BindingProvider, BindingProviderScope, BindingProviderHandle, BindingReadResult, BindingWriteResult, BindingCollectionResult, ActiveBindingProvider, } from "./binding-provider";
8
- export type { AssetSurface, AssetKind, FontFaceAsset, FontFaceFormat, } from "./assets";
8
+ export type { AssetSurface, AssetKind, DocumentFontOutcome, FontFaceAsset, FontFaceFormat, } from "./assets";
9
9
  export type { ProviderTileWire, SnapshotPng } from "./wire";
10
10
  export type { SnapPointQuery, SnapPointResult, SnapPointHit, SnapAxisHit, SnapSegmentHit, SnapExclude, SnapSource, SnapSettings, } from "./wire";
11
11
  export type { MintedElement } from "./wire";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paged-media/plugin-api",
3
- "version": "0.2.53-canary.0",
3
+ "version": "0.2.55-canary.0",
4
4
  "description": "The Paged plugin contract: manifest, bundle lifecycle, the BundleHost surface, and the contribution + engine wire types. Type-only.",
5
5
  "license": "MPL-2.0 OR LicenseRef-PMEL",
6
6
  "type": "module",