pixiboardjs 0.1.0-alpha.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.
@@ -0,0 +1,657 @@
1
+ export { AssetUnavailableError, BoardDestroyedError, CapabilityError, CapabilityUnavailableError, DocumentValidationError, NodeNotFoundError, NodeTypeNotRegisteredError, NodeValidationError, PermissionDeniedError, RESIZE_HANDLES, TransactionConflictError, createPixiBoard, resizeHandleAxes, resizeHandleCursor } from './index.js';
2
+ import { P as PixiBoard, B as BoardNode, J as JsonValue, W as WorldBounds, a as Point, V as ViewportSnapshot, b as BoardDocument, A as AssetRecord } from './types-DnR8yhxj.js';
3
+ export { c as BoardCapabilities, d as BoardChangeEvent, e as BoardDocumentUpdate, f as BoardLifecycleState, g as BoardNodeCreateInput, h as BoardNodePatch, i as BoardRuntimePorts, j as BrowserEventPort, C as CaptureInput, k as CaptureResult, l as ChangeOrigin, m as CustomDisplayFactory, n as CustomDisplayObject, o as CustomNodeDataDefinition, p as CustomNodeDefinition, q as CustomNodeRenderer, r as CustomNodeRendererContext, s as CustomNodeRendererRegistry, t as CustomNodeView, u as CustomResizePolicy, v as CustomTextureLease, D as DocumentLoadOptions, w as DocumentPersistence, H as HistoryChangeEvent, N as NodeGeometry, x as NodeHandle, y as NodeHandleEventMap, z as NodeInput, E as NodeListFilter, F as NodePatch, G as NodeQuery, I as NodeResizeRequest, K as NodeTypeDefinition, L as NodeTypeRegistrationDisposer, M as NodeTypeRegistrationOptions, O as PixiBoardOptions, Q as PixiBoardRendererOptions, R as PublicBoardEventMap, S as PublicNodeTypeDefinition, T as PublicRendererOptions, U as RenderCompleteEvent, X as RendererApplyResult, Y as ResizeHandle, Z as ResizeObserverPort, _ as RuntimeRenderer, $ as SelectionChangeEvent, a0 as TickerPort, a1 as TransactionOptions, a2 as TransactionOrigin, a3 as TransformBounds, a4 as TransformHandlePlacement, a5 as TransformSession, a6 as ViewportChangeEvent } from './types-DnR8yhxj.js';
4
+
5
+ type DomTransformerOptions = {
6
+ /**
7
+ * Where the handle elements are appended. Must be positioned (the overlay is
8
+ * absolutely positioned inside it) and should sit above the canvas.
9
+ */
10
+ overlay: HTMLElement;
11
+ /**
12
+ * Element the pointer coordinates are measured against — normally the same
13
+ * element the canvas fills, so screen points match `viewport.toScreen()`.
14
+ * Defaults to `overlay`.
15
+ */
16
+ surface?: HTMLElement;
17
+ /** Handle size in CSS pixels. */
18
+ size?: number;
19
+ /** Prefix for the generated class names; see `attachDomTransformer` docs. */
20
+ classPrefix?: string;
21
+ };
22
+ type DomTransformer = {
23
+ /** Re-projects the handles. Call on selection, document and viewport change. */
24
+ refresh(): void;
25
+ /** Enables or disables handle hit-testing without hiding the handles. */
26
+ setInteractive(interactive: boolean): void;
27
+ /** True while a handle drag is in flight. */
28
+ dragging(): boolean;
29
+ destroy(): void;
30
+ };
31
+ /**
32
+ * Renders the eight resize control points as real DOM elements over the board
33
+ * and drives `board.transform` from their pointer events.
34
+ *
35
+ * Handles must be real elements rather than CSS pseudo-elements: a pseudo
36
+ * element is never an `event.target`, so it can be styled but never grabbed.
37
+ * They also live in their own overlay with `pointer-events: auto` while the
38
+ * rest of the overlay stays transparent to the pointer, so a drag that starts
39
+ * on a handle never reaches the canvas's own select/drag handlers.
40
+ *
41
+ * Styling is left to the host: each handle carries
42
+ * `<prefix>-handle` and `<prefix>-handle-<direction>` classes plus a
43
+ * `data-handle` attribute, and only the properties this needs to work
44
+ * (position, size, cursor, pointer-events) are set inline.
45
+ */
46
+ declare function attachDomTransformer(board: PixiBoard, options: DomTransformerOptions): DomTransformer;
47
+
48
+ /**
49
+ * Where on a node's world bounds an overlay item hangs.
50
+ *
51
+ * The named values are the nine box positions; the object form takes
52
+ * normalized coordinates so a caller can anchor at, say, the 25% mark without
53
+ * the enum growing a case for it.
54
+ */
55
+ type OverlayAnchor = "top-left" | "top" | "top-right" | "left" | "center" | "right" | "bottom-left" | "bottom" | "bottom-right" | {
56
+ x: number;
57
+ y: number;
58
+ };
59
+ /**
60
+ * How an item's own size reacts to zoom. This is deliberately independent of
61
+ * the anchor: *where* something sits and *how big it draws* are different
62
+ * questions, and every combination of the two is legitimate.
63
+ *
64
+ * - `screen` — constant CSS pixels at any zoom. Correct for chrome that
65
+ * describes content without being part of it: labels, badges, tooltips.
66
+ * - `world` — scales 1:1 with the viewport, so it behaves like content.
67
+ * Correct for annotations that belong to the document.
68
+ * - `clamped` — scales with the viewport but stops at `min`/`max`, so an
69
+ * annotation stays legible when zoomed far out without growing absurdly
70
+ * when zoomed in.
71
+ */
72
+ type OverlayScaleMode = "screen" | "world" | {
73
+ mode: "clamped";
74
+ min: number;
75
+ max: number;
76
+ };
77
+ /**
78
+ * What happens to an item when the viewport is zoomed out far enough that
79
+ * items would otherwise pile onto each other.
80
+ *
81
+ * `collapse` only describes intent; the DOM layer decides how to express it
82
+ * (a modifier class, typically) so this module stays render-agnostic.
83
+ */
84
+ type OverlayDeclutter = {
85
+ /** Below this viewport scale the item is dropped entirely. */
86
+ minScale?: number;
87
+ /** Below this viewport scale the item is reported as collapsed. */
88
+ collapseBelowScale?: number;
89
+ };
90
+ type OverlayItem = {
91
+ /**
92
+ * Stable within one layer. Defaults to the node id; supply it explicitly
93
+ * when one node contributes several items, otherwise they would share a
94
+ * pooled element and overwrite each other.
95
+ */
96
+ key?: string;
97
+ anchor?: OverlayAnchor;
98
+ /** Screen-pixel nudge applied after anchoring, before scaling. */
99
+ offset?: Point;
100
+ scale?: OverlayScaleMode;
101
+ declutter?: OverlayDeclutter;
102
+ /** Opaque payload handed back to the renderer callback. */
103
+ data?: unknown;
104
+ className?: string;
105
+ };
106
+ type OverlayPlacement = {
107
+ key: string;
108
+ nodeId: string;
109
+ /** Screen position of the anchor point, in CSS pixels. */
110
+ screen: Point;
111
+ /** Multiplier the item should draw itself at; 1 for `screen` mode. */
112
+ scale: number;
113
+ collapsed: boolean;
114
+ data?: unknown;
115
+ className?: string;
116
+ };
117
+ type OverlayBoundsResolver = (node: Readonly<BoardNode<JsonValue>>) => WorldBounds;
118
+ /**
119
+ * The world bounds every overlay measures against — the same resolver the
120
+ * renderer culls with, so an overlay never drifts from what the user sees.
121
+ *
122
+ * Everything that positions or sizes an overlay must go through this. Mixing a
123
+ * node's raw `x`/`y` with dimensions taken from resolved bounds puts the two in
124
+ * different coordinate frames, which shows up as a box that is displaced from
125
+ * the very outlines it is supposed to enclose.
126
+ */
127
+ declare function resolveOverlayBounds(node: Readonly<BoardNode<JsonValue>>, nodeTypes: {
128
+ get(type: string): {
129
+ getBounds(node: BoardNode<never>): WorldBounds;
130
+ } | undefined;
131
+ }): WorldBounds;
132
+ declare function anchorRatio(anchor?: OverlayAnchor): Point;
133
+ /**
134
+ * The world point an item hangs from.
135
+ *
136
+ * Anchoring uses the node's *world bounds* rather than its raw x/y/width so a
137
+ * rotated or custom-bounds node still gets a label that hugs what the user
138
+ * actually sees.
139
+ */
140
+ declare function anchorWorldPoint(bounds: WorldBounds, anchor?: OverlayAnchor): Point;
141
+ declare function resolveScale(mode: OverlayScaleMode | undefined, viewportScale: number): number;
142
+ /**
143
+ * Projects one item into screen space, or returns undefined when declutter
144
+ * rules say it should not exist at this zoom at all.
145
+ *
146
+ * Kept free of DOM types on purpose: this is the part worth unit-testing, and
147
+ * the workspace's test runner is a plain Node environment.
148
+ */
149
+ declare function projectOverlayItem(node: Readonly<BoardNode<JsonValue>>, item: OverlayItem, viewport: ViewportSnapshot, bounds: WorldBounds): OverlayPlacement | undefined;
150
+
151
+ type OverlayRenderContext = {
152
+ /** The element to fill. Reused across nodes — clear anything you own. */
153
+ element: HTMLElement;
154
+ placement: OverlayPlacement;
155
+ node: Readonly<BoardNode<JsonValue>>;
156
+ };
157
+ type OverlayLayerOptions = {
158
+ /**
159
+ * Where item elements are appended. Must be positioned, sized like the
160
+ * canvas, and normally `pointer-events: none` so the board keeps receiving
161
+ * input; an item that needs clicks can re-enable them on itself.
162
+ */
163
+ container: HTMLElement;
164
+ /**
165
+ * Produces the overlay item for a node, or undefined for "nothing here".
166
+ * Called for every candidate node on every rebuild, so keep it cheap and
167
+ * free of side effects.
168
+ */
169
+ item(node: Readonly<BoardNode<JsonValue>>): OverlayItem | undefined;
170
+ /** Fills a pooled element. Called whenever the item's content may have changed. */
171
+ render(context: OverlayRenderContext): void;
172
+ /** Class applied to every pooled element. Defaults to `pixiboard-overlay-item`. */
173
+ itemClassName?: string;
174
+ /** Class applied while an item is collapsed by declutter rules. */
175
+ collapsedClassName?: string;
176
+ /**
177
+ * For interactive overlay items, forwards wheel gestures back to this board
178
+ * surface so zooming and panning do not get trapped in the DOM layer.
179
+ */
180
+ wheelSurface?: HTMLElement;
181
+ /**
182
+ * Restricts the layer to a set of candidate nodes. Defaults to the board's
183
+ * visible set, so overlay cost tracks what is on screen rather than document
184
+ * size — the whole point of pairing an overlay with a virtualized renderer.
185
+ *
186
+ * Returning undefined means "no culling information", and the layer falls
187
+ * back to the whole document rather than showing nothing. Supply a function
188
+ * that always returns undefined to opt out of culling entirely.
189
+ */
190
+ candidates?(): Iterable<string> | undefined;
191
+ /**
192
+ * Runs at the end of every flush, inside the same batched frame. Use it for
193
+ * chrome that belongs to the layer but is not per-node — a bounding box
194
+ * around a whole selection, say — so it shares one animation frame with the
195
+ * items instead of scheduling a second pass of its own.
196
+ */
197
+ onFlush?(): void;
198
+ /** Schedules a batched flush. Defaults to `requestAnimationFrame`. */
199
+ schedule?(callback: () => void): () => void;
200
+ };
201
+ type OverlayLayer = {
202
+ /** Marks the layer dirty; the flush itself is batched. */
203
+ refresh(): void;
204
+ /** Flushes any pending work immediately. Mostly for tests and teardown. */
205
+ flush(): void;
206
+ /** Number of elements currently attached (pooled spares excluded). */
207
+ size(): number;
208
+ destroy(): void;
209
+ };
210
+ /**
211
+ * Projects board nodes onto positioned DOM elements that track the viewport.
212
+ *
213
+ * Three implementation choices are load-bearing rather than incidental:
214
+ *
215
+ * 1. **Elements are pooled by key.** A naive layer calls `replaceChildren()`
216
+ * every frame, which throws away and rebuilds the whole subtree during a
217
+ * pan — the single most expensive thing an overlay can do.
218
+ * 2. **Positioning goes through `transform`, never `left`/`top`.** Writing
219
+ * `left`/`top` per frame forces layout for every item; a transform is
220
+ * handled by the compositor.
221
+ * 3. **Flushes are batched into one animation frame.** Viewport and document
222
+ * changes both invalidate the layer and routinely arrive together, so
223
+ * reacting to each one directly would project everything several times per
224
+ * frame.
225
+ */
226
+ declare function attachOverlayLayer(board: PixiBoard, options: OverlayLayerOptions): OverlayLayer;
227
+
228
+ type SelectionOverlayOptions = {
229
+ /** Where outlines are appended. Should sit above the canvas and below handles. */
230
+ container: HTMLElement;
231
+ /** Prefix for the generated class names. Defaults to `pixiboard`. */
232
+ classPrefix?: string;
233
+ /**
234
+ * Also draws a single box around the union of a multi-node selection.
235
+ * Defaults to true.
236
+ */
237
+ groupBox?: boolean;
238
+ /** Padding in CSS pixels between the group box and the selection. */
239
+ groupBoxPadding?: number;
240
+ schedule?(callback: () => void): () => void;
241
+ };
242
+ /**
243
+ * Draws an outline around every selected node, plus an optional box around a
244
+ * multi-node selection.
245
+ *
246
+ * Outlines are sized in *screen* pixels from the projected corners rather than
247
+ * scaled with `transform`, so the border stays exactly as thick at any zoom —
248
+ * a scaled outline would thin out to invisibility when zoomed out and turn
249
+ * into a slab when zoomed in.
250
+ */
251
+ declare function attachSelectionOverlay(board: PixiBoard, options: SelectionOverlayOptions): OverlayLayer;
252
+ type LabelOverlayOptions = {
253
+ container: HTMLElement;
254
+ /** Surface that should keep receiving wheel zoom/pan when labels are interactive. */
255
+ wheelSurface?: HTMLElement;
256
+ /**
257
+ * The text for a node, or undefined for "no label here". Defaults to the
258
+ * node's `name`, falling back to its type.
259
+ */
260
+ text?(node: Readonly<BoardNode<JsonValue>>): string | undefined;
261
+ /** An optional icon or prefix element content, rendered before the text. */
262
+ icon?(node: Readonly<BoardNode<JsonValue>>): string | undefined;
263
+ classPrefix?: string;
264
+ /** Defaults to `bottom-left`, i.e. hanging under the node. */
265
+ anchor?: OverlayAnchor;
266
+ /** Screen-pixel offset from the anchor. Defaults to 6px below. */
267
+ offset?: {
268
+ x: number;
269
+ y: number;
270
+ };
271
+ /** Defaults to `screen`: a label describes content without being content. */
272
+ scale?: OverlayScaleMode;
273
+ /** Defaults to hiding below 0.25 and collapsing below 0.5. */
274
+ declutter?: OverlayDeclutter;
275
+ schedule?(callback: () => void): () => void;
276
+ };
277
+ /**
278
+ * Labels nodes with a name and optional icon.
279
+ *
280
+ * Unlike selection outlines this *does* follow the visible set: labels are
281
+ * pure decoration for what is on screen, and a document with 100k media nodes
282
+ * must not put 100k elements in the DOM.
283
+ */
284
+ declare function attachLabelOverlay(board: PixiBoard, options: LabelOverlayOptions): OverlayLayer;
285
+
286
+ type BrowserDocumentMetadata = Record<string, JsonValue>;
287
+ type BrowserDocumentRecord = {
288
+ snapshot: BoardDocument;
289
+ metadata: BrowserDocumentMetadata;
290
+ savedAt: number;
291
+ };
292
+ type SaveBrowserDocumentInput = {
293
+ snapshot: BoardDocument;
294
+ metadata?: BrowserDocumentMetadata;
295
+ /**
296
+ * Compare-and-swap guard for shared browser storage. `null` requires that no
297
+ * document exists; `undefined` preserves the legacy unconditional write.
298
+ */
299
+ expectedRevision?: number | null;
300
+ };
301
+ type SaveBrowserDocumentOptions = {
302
+ expectedRevision?: number | null;
303
+ };
304
+ type AssetStorageLocation = {
305
+ kind: "indexeddb";
306
+ } | {
307
+ kind: "opfs";
308
+ key: string;
309
+ };
310
+ type AssetBinaryVariant = "original" | "preview" | "waveform";
311
+ type StoredAssetBinary = {
312
+ storage: AssetStorageLocation;
313
+ size: number;
314
+ mimeType: string;
315
+ updatedAt: number;
316
+ };
317
+ type StoredAssetEntry = {
318
+ id: string;
319
+ record: AssetRecord;
320
+ binaries: Record<string, StoredAssetBinary>;
321
+ createdAt: number;
322
+ updatedAt: number;
323
+ quarantinedAt?: number;
324
+ };
325
+ type BrowserAsset = {
326
+ entry: StoredAssetEntry;
327
+ variant: AssetBinaryVariant;
328
+ binary: StoredAssetBinary;
329
+ blob: Blob;
330
+ };
331
+ type PutAssetOptions = {
332
+ signal?: AbortSignal;
333
+ preferOpfs?: boolean;
334
+ variant?: AssetBinaryVariant;
335
+ };
336
+ type GetAssetOptions = AdapterOperationOptions & {
337
+ variant?: AssetBinaryVariant;
338
+ };
339
+ type AdapterOperationOptions = {
340
+ signal?: AbortSignal;
341
+ };
342
+ interface PortLifecycle {
343
+ close?(): void | Promise<void>;
344
+ destroy?(): void | Promise<void>;
345
+ }
346
+ interface IndexedDbPort extends PortLifecycle {
347
+ loadDocument(signal: AbortSignal): Promise<BrowserDocumentRecord | undefined>;
348
+ saveDocument(record: BrowserDocumentRecord, signal: AbortSignal, options?: SaveBrowserDocumentOptions): Promise<void>;
349
+ getAssetEntry(id: string, signal: AbortSignal): Promise<StoredAssetEntry | undefined>;
350
+ listAssetEntries(signal: AbortSignal): Promise<StoredAssetEntry[]>;
351
+ getAssetBlob(id: string, variant: AssetBinaryVariant, signal: AbortSignal): Promise<Blob | undefined>;
352
+ /** Atomically commits metadata and the optional IndexedDB Blob fallback. */
353
+ putAssetEntry(entry: StoredAssetEntry, binaryWrite: {
354
+ variant: AssetBinaryVariant;
355
+ blob: Blob;
356
+ } | undefined, signal: AbortSignal): Promise<void>;
357
+ /** Atomically commits the document plus asset metadata and optional Blob fallback. */
358
+ commitAssetAndDocument(document: BrowserDocumentRecord, entry: StoredAssetEntry, binaryWrite: {
359
+ variant: AssetBinaryVariant;
360
+ blob: Blob;
361
+ } | undefined, signal: AbortSignal, options?: SaveBrowserDocumentOptions): Promise<void>;
362
+ /** Atomically removes asset metadata and any IndexedDB Blob fallback. */
363
+ deleteAssetEntry(entry: StoredAssetEntry, signal: AbortSignal): Promise<void>;
364
+ }
365
+ interface OpfsPort extends PortLifecycle {
366
+ isAvailable(signal: AbortSignal): Promise<boolean>;
367
+ get(key: string, signal: AbortSignal): Promise<Blob | undefined>;
368
+ put(key: string, blob: Blob, signal: AbortSignal): Promise<void>;
369
+ delete(key: string, signal: AbortSignal): Promise<void>;
370
+ }
371
+ interface ObjectUrlPort extends PortLifecycle {
372
+ create(blob: Blob): string;
373
+ revoke(url: string): void;
374
+ }
375
+ type BrowserDownloadRequest = {
376
+ url: string;
377
+ fileName: string;
378
+ mimeType: string;
379
+ };
380
+ interface DownloadPort extends PortLifecycle {
381
+ download(request: BrowserDownloadRequest): void | Promise<void>;
382
+ }
383
+ interface ObjectUrlLease {
384
+ readonly assetId: string;
385
+ readonly variant: AssetBinaryVariant;
386
+ readonly url: string;
387
+ readonly revoked: boolean;
388
+ revoke(): void;
389
+ }
390
+ type AssetGcRoots = {
391
+ assetIds?: Iterable<string>;
392
+ historyAssetIds?: Iterable<string>;
393
+ activeJobAssetIds?: Iterable<string>;
394
+ explicitLeaseAssetIds?: Iterable<string>;
395
+ };
396
+ type AssetGcOptions = AssetGcRoots & {
397
+ quarantineMs?: number;
398
+ now?: number;
399
+ signal?: AbortSignal;
400
+ };
401
+ type AssetGcResult = {
402
+ roots: string[];
403
+ retained: string[];
404
+ quarantined: string[];
405
+ restored: string[];
406
+ deleted: string[];
407
+ };
408
+ type BrowserCleanupOperation = "metadata-compensation" | "import-compensation" | "replace-old-opfs" | "delete-opfs" | "gc-opfs" | "destroy-port" | "cleanup-observer";
409
+ type BrowserCleanupError = {
410
+ operation: BrowserCleanupOperation;
411
+ error: unknown;
412
+ timestamp: number;
413
+ assetId?: string;
414
+ variant?: AssetBinaryVariant;
415
+ key?: string;
416
+ port?: "indexeddb" | "opfs" | "object-urls" | "download";
417
+ };
418
+ type BrowserImportSourceType = "file" | "blob" | "text" | "url";
419
+ type BrowserPrepareImportOptions = AdapterOperationOptions & {
420
+ assetId?: string;
421
+ kind?: string;
422
+ name?: string;
423
+ mimeType?: string;
424
+ assetMetadata?: Record<string, JsonValue>;
425
+ request?: RequestInit;
426
+ };
427
+ type BrowserPreparedImport = {
428
+ sourceType: BrowserImportSourceType;
429
+ asset: AssetRecord;
430
+ blob: Blob;
431
+ fileName: string;
432
+ };
433
+ type BrowserCommitImportOptions = AdapterOperationOptions & {
434
+ document: BoardDocument;
435
+ documentMetadata?: BrowserDocumentMetadata;
436
+ expectedRevision?: number | null;
437
+ nodeId?: string;
438
+ nodeType?: string;
439
+ nodeProps?: JsonValue;
440
+ x?: number;
441
+ y?: number;
442
+ width?: number;
443
+ height?: number;
444
+ zIndex?: number;
445
+ preferOpfs?: boolean;
446
+ };
447
+ type BrowserImportOptions = BrowserPrepareImportOptions & BrowserCommitImportOptions;
448
+ type BrowserImportResult = {
449
+ sourceType: BrowserImportSourceType;
450
+ document: BoardDocument;
451
+ asset: AssetRecord;
452
+ node: BoardNode;
453
+ entry: StoredAssetEntry;
454
+ };
455
+ type BrowserAssetExport = {
456
+ assetId: string;
457
+ variant: AssetBinaryVariant;
458
+ blob: Blob;
459
+ fileName: string;
460
+ mimeType: string;
461
+ };
462
+ type BrowserExportOptions = GetAssetOptions & {
463
+ fileName?: string;
464
+ };
465
+ type BrowserAdapterCapabilities = {
466
+ persistence: true;
467
+ indexedDb: true;
468
+ opfs: boolean;
469
+ blobFallback: true;
470
+ import: readonly BrowserImportSourceType[];
471
+ objectUrl: true;
472
+ download: boolean;
473
+ desktopFileSystem: false;
474
+ };
475
+ type BrowserPersistenceAdapterOptions = {
476
+ indexedDb: IndexedDbPort;
477
+ opfs?: OpfsPort;
478
+ objectUrls?: ObjectUrlPort;
479
+ download?: DownloadPort;
480
+ fetch?: typeof globalThis.fetch;
481
+ now?: () => number;
482
+ idFactory?: () => string;
483
+ storageKeyFactory?: (assetId: string, variant: AssetBinaryVariant) => string;
484
+ opfsThresholdBytes?: number;
485
+ defaultGcQuarantineMs?: number;
486
+ onCleanupError?: (record: BrowserCleanupError) => void;
487
+ };
488
+
489
+ declare const DEFAULT_OPFS_THRESHOLD_BYTES: number;
490
+ declare class BrowserPersistenceAdapter {
491
+ #private;
492
+ constructor(options: BrowserPersistenceAdapterOptions);
493
+ get signal(): AbortSignal;
494
+ get destroyed(): boolean;
495
+ get cleanupErrors(): readonly BrowserCleanupError[];
496
+ capabilities(options?: AdapterOperationOptions): Promise<BrowserAdapterCapabilities>;
497
+ load(options?: AdapterOperationOptions): Promise<BoardDocument | null>;
498
+ save(document: BoardDocument, options?: AdapterOperationOptions): Promise<void>;
499
+ loadDocument(options?: AdapterOperationOptions): Promise<BrowserDocumentRecord | null>;
500
+ saveDocument(input: SaveBrowserDocumentInput, options?: AdapterOperationOptions): Promise<void>;
501
+ prepareFile(file: File, options?: BrowserPrepareImportOptions): Promise<BrowserPreparedImport>;
502
+ prepareBlob(blob: Blob, options?: BrowserPrepareImportOptions): Promise<BrowserPreparedImport>;
503
+ prepareText(value: string, options?: BrowserPrepareImportOptions): Promise<BrowserPreparedImport>;
504
+ prepareUrl(url: string, options?: BrowserPrepareImportOptions): Promise<BrowserPreparedImport>;
505
+ commitImport(prepared: BrowserPreparedImport, options: BrowserCommitImportOptions): Promise<BrowserImportResult>;
506
+ importFile(file: File, options: BrowserImportOptions): Promise<BrowserImportResult>;
507
+ importBlob(blob: Blob, options: BrowserImportOptions): Promise<BrowserImportResult>;
508
+ importText(value: string, options: BrowserImportOptions): Promise<BrowserImportResult>;
509
+ importUrl(url: string, options: BrowserImportOptions): Promise<BrowserImportResult>;
510
+ putAsset(record: AssetRecord, blob: Blob, options?: PutAssetOptions): Promise<StoredAssetEntry>;
511
+ putDerivative(assetId: string, variant: Exclude<AssetBinaryVariant, "original">, blob: Blob, options?: Omit<PutAssetOptions, "variant">): Promise<StoredAssetEntry>;
512
+ getAsset(id: string, options?: GetAssetOptions): Promise<BrowserAsset | null>;
513
+ resolveAsset(id: string, variant?: AssetBinaryVariant, options?: AdapterOperationOptions): Promise<BrowserAsset | null>;
514
+ listAssets(options?: AdapterOperationOptions): Promise<StoredAssetEntry[]>;
515
+ deleteAsset(id: string, options?: AdapterOperationOptions): Promise<boolean>;
516
+ leaseObjectUrl(id: string, options?: GetAssetOptions): Promise<ObjectUrlLease>;
517
+ exportAsset(id: string, options?: BrowserExportOptions): Promise<BrowserAssetExport>;
518
+ downloadAsset(id: string, options?: BrowserExportOptions): Promise<BrowserAssetExport>;
519
+ collectAssetGarbage(options?: AssetGcOptions): Promise<AssetGcResult>;
520
+ destroy(): Promise<void>;
521
+ }
522
+
523
+ type BrowserAdapterContractHarness = {
524
+ createAdapter(): BrowserPersistenceAdapter | Promise<BrowserPersistenceAdapter>;
525
+ inspectObjectUrl?(url: string): Promise<{
526
+ type: string;
527
+ text: string;
528
+ }>;
529
+ };
530
+ type BrowserAdapterContractEvidence = {
531
+ imports: Array<{
532
+ sourceType: string;
533
+ kind: string;
534
+ revision: number;
535
+ storage: string;
536
+ }>;
537
+ transactionRevisions: number[];
538
+ derivativeText: string;
539
+ objectUrlRevoked: boolean;
540
+ export: {
541
+ fileName: string;
542
+ mimeType: string;
543
+ text: string;
544
+ };
545
+ download: boolean;
546
+ restored: {
547
+ revision: number;
548
+ assetIds: string[];
549
+ nodeTypes: string[];
550
+ };
551
+ gc: {
552
+ quarantined: string[];
553
+ deleted: string[];
554
+ };
555
+ recreated: boolean;
556
+ capabilities: Awaited<ReturnType<BrowserPersistenceAdapter["capabilities"]>>;
557
+ };
558
+ declare function runBrowserAdapterContract(harness: BrowserAdapterContractHarness): Promise<BrowserAdapterContractEvidence>;
559
+
560
+ type NativeDownloadPortOptions = {
561
+ document?: Document;
562
+ };
563
+ declare class NativeDownloadPort implements DownloadPort {
564
+ #private;
565
+ constructor(options?: NativeDownloadPortOptions);
566
+ download(request: BrowserDownloadRequest): void;
567
+ }
568
+
569
+ declare class BrowserPersistenceError extends Error {
570
+ readonly cause?: unknown;
571
+ constructor(message: string, options?: {
572
+ cause?: unknown;
573
+ });
574
+ }
575
+ declare class BrowserPersistenceDestroyedError extends BrowserPersistenceError {
576
+ constructor();
577
+ }
578
+ declare class BrowserPersistenceAbortError extends BrowserPersistenceError {
579
+ constructor(reason?: unknown);
580
+ }
581
+ declare class BrowserAssetNotFoundError extends BrowserPersistenceError {
582
+ constructor(assetId: string);
583
+ }
584
+ declare class BrowserAssetBinaryMissingError extends BrowserPersistenceError {
585
+ constructor(assetId: string, variant?: string);
586
+ }
587
+ declare class BrowserStorageKeyCollisionError extends BrowserPersistenceError {
588
+ constructor(key: string);
589
+ }
590
+ declare class BrowserStorageCapabilityError extends BrowserPersistenceError {
591
+ readonly capability: "indexeddb" | "opfs" | "object-url";
592
+ constructor(capability: "indexeddb" | "opfs" | "object-url");
593
+ }
594
+ declare class BrowserDocumentConflictError extends BrowserPersistenceError {
595
+ readonly expectedRevision: number | null;
596
+ readonly actualRevision: number | null;
597
+ constructor(expectedRevision: number | null, actualRevision: number | null);
598
+ }
599
+ declare class BrowserStorageQuotaError extends BrowserPersistenceError {
600
+ readonly retryable = true;
601
+ constructor(cause?: unknown);
602
+ }
603
+ declare function isBrowserQuotaError(error: unknown): boolean;
604
+
605
+ type NativeIndexedDbPortOptions = {
606
+ databaseName?: string;
607
+ indexedDb?: IDBFactory | null;
608
+ };
609
+ declare class NativeIndexedDbPort implements IndexedDbPort {
610
+ #private;
611
+ constructor(options?: NativeIndexedDbPortOptions);
612
+ loadDocument(signal: AbortSignal): Promise<BrowserDocumentRecord | undefined>;
613
+ saveDocument(record: BrowserDocumentRecord, signal: AbortSignal, options?: SaveBrowserDocumentOptions): Promise<void>;
614
+ getAssetEntry(id: string, signal: AbortSignal): Promise<StoredAssetEntry | undefined>;
615
+ listAssetEntries(signal: AbortSignal): Promise<StoredAssetEntry[]>;
616
+ getAssetBlob(id: string, variant: AssetBinaryVariant, signal: AbortSignal): Promise<Blob | undefined>;
617
+ putAssetEntry(entry: StoredAssetEntry, binaryWrite: {
618
+ variant: AssetBinaryVariant;
619
+ blob: Blob;
620
+ } | undefined, signal: AbortSignal): Promise<void>;
621
+ commitAssetAndDocument(document: BrowserDocumentRecord, entry: StoredAssetEntry, binaryWrite: {
622
+ variant: AssetBinaryVariant;
623
+ blob: Blob;
624
+ } | undefined, signal: AbortSignal, options?: SaveBrowserDocumentOptions): Promise<void>;
625
+ deleteAssetEntry(entry: StoredAssetEntry, signal: AbortSignal): Promise<void>;
626
+ close(): Promise<void>;
627
+ }
628
+
629
+ type UrlApi = {
630
+ createObjectURL(blob: Blob): string;
631
+ revokeObjectURL(url: string): void;
632
+ };
633
+ declare class NativeObjectUrlPort implements ObjectUrlPort {
634
+ #private;
635
+ constructor(url?: UrlApi);
636
+ create(blob: Blob): string;
637
+ revoke(url: string): void;
638
+ }
639
+
640
+ type NativeOpfsPortOptions = {
641
+ directoryName?: string;
642
+ getRootDirectory?: () => Promise<FileSystemDirectoryHandle>;
643
+ };
644
+ declare class NativeOpfsPort implements OpfsPort {
645
+ #private;
646
+ constructor(options?: NativeOpfsPortOptions);
647
+ isAvailable(signal: AbortSignal): Promise<boolean>;
648
+ get(key: string, signal: AbortSignal): Promise<Blob | undefined>;
649
+ put(key: string, blob: Blob, signal: AbortSignal): Promise<void>;
650
+ delete(key: string, signal: AbortSignal): Promise<void>;
651
+ }
652
+
653
+ declare function indexedDbPersistence(options?: {
654
+ database?: string;
655
+ }): BrowserPersistenceAdapter;
656
+
657
+ export { type AdapterOperationOptions, type AssetBinaryVariant, type AssetGcOptions, type AssetGcResult, type AssetGcRoots, type AssetStorageLocation, BoardDocument, BoardNode, type BrowserAdapterCapabilities, type BrowserAdapterContractEvidence, type BrowserAdapterContractHarness, type BrowserAsset, BrowserAssetBinaryMissingError, type BrowserAssetExport, BrowserAssetNotFoundError, type BrowserCleanupError, type BrowserCleanupOperation, type BrowserCommitImportOptions, BrowserDocumentConflictError, type BrowserDocumentMetadata, type BrowserDocumentRecord, type BrowserDownloadRequest, type BrowserExportOptions, type BrowserImportOptions, type BrowserImportResult, type BrowserImportSourceType, BrowserPersistenceAbortError, BrowserPersistenceAdapter, type BrowserPersistenceAdapterOptions, BrowserPersistenceDestroyedError, BrowserPersistenceError, type BrowserPrepareImportOptions, type BrowserPreparedImport, BrowserStorageCapabilityError, BrowserStorageKeyCollisionError, BrowserStorageQuotaError, DEFAULT_OPFS_THRESHOLD_BYTES, type DomTransformer, type DomTransformerOptions, type DownloadPort, type GetAssetOptions, type IndexedDbPort, JsonValue, type LabelOverlayOptions, NativeDownloadPort, type NativeDownloadPortOptions, NativeIndexedDbPort, type NativeIndexedDbPortOptions, NativeObjectUrlPort, NativeOpfsPort, type NativeOpfsPortOptions, type ObjectUrlLease, type ObjectUrlPort, type OpfsPort, type OverlayAnchor, type OverlayBoundsResolver, type OverlayDeclutter, type OverlayItem, type OverlayLayer, type OverlayLayerOptions, type OverlayPlacement, type OverlayRenderContext, type OverlayScaleMode, PixiBoard, Point, type PortLifecycle, type PutAssetOptions, type SaveBrowserDocumentInput, type SaveBrowserDocumentOptions, type SelectionOverlayOptions, type StoredAssetBinary, type StoredAssetEntry, ViewportSnapshot, WorldBounds, anchorRatio, anchorWorldPoint, attachDomTransformer, attachLabelOverlay, attachOverlayLayer, attachSelectionOverlay, indexedDbPersistence, isBrowserQuotaError, projectOverlayItem, resolveOverlayBounds, resolveScale, runBrowserAdapterContract };