@scrawl-board/board 0.1.0-beta.0 → 0.1.0-beta.2

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/browser.d.ts CHANGED
@@ -5,6 +5,9 @@ type StrokeId = string & {
5
5
 
6
6
  /** Wire grammar: `asset:<namespace>:<opaque-id>`. Interpreted only by the Host. */
7
7
  type AssetRef = string;
8
+ declare function isAssetRef(value: unknown): value is AssetRef;
9
+ /** Throws on malformed input; use `isAssetRef` where a boolean is wanted instead. */
10
+ declare function assetRef(value: string): AssetRef;
8
11
  type AssetKind = "image";
9
12
  type AssetPurpose = "render" | "thumbnail" | "export";
10
13
  interface AssetResolveRequest {
@@ -46,6 +49,12 @@ interface AssetIngestor {
46
49
  ingest(request: AssetIngestRequest): Promise<AssetIngestResult>;
47
50
  }
48
51
  type AssetResolutionErrorCode = "resolver-unavailable" | "not-found" | "forbidden" | "offline" | "unsupported-type" | "too-large" | "invalid-content" | "decode-failed" | "budget-exceeded" | "aborted" | "unknown";
52
+ declare class AssetResolutionError extends Error {
53
+ readonly code: AssetResolutionErrorCode;
54
+ readonly retryable: boolean;
55
+ readonly ref?: AssetRef | undefined;
56
+ constructor(code: AssetResolutionErrorCode, retryable: boolean, message: string, ref?: AssetRef | undefined);
57
+ }
49
58
  /** Runtime event for a resolution/ingestion failure — never carries credentials or a fetchable location. */
50
59
  interface AssetDiagnostic {
51
60
  code: AssetResolutionErrorCode;
@@ -54,6 +63,9 @@ interface AssetDiagnostic {
54
63
  objectKind: "image" | "custom";
55
64
  retryable: boolean;
56
65
  }
66
+ declare const SUPPORTED_ASSET_MEDIA_TYPES: readonly ["image/png", "image/jpeg", "image/webp"];
67
+ type SupportedAssetMediaType = (typeof SUPPORTED_ASSET_MEDIA_TYPES)[number];
68
+ declare function clampAssetCacheBytes(value: number | undefined): number;
57
69
 
58
70
  type Mat2x3 = [number, number, number, number, number, number];
59
71
 
@@ -101,6 +113,7 @@ interface CustomBoardObject {
101
113
  };
102
114
  props: JsonValue;
103
115
  }
116
+ declare function cloneCustomObject(object: CustomBoardObject): CustomBoardObject;
104
117
  /**
105
118
  * The read-only view handed to `describe`. Deep-readonly by construction
106
119
  * (not derived via a shallow `Readonly<>`) because `describe` must treat its
@@ -676,6 +689,27 @@ interface BoardView {
676
689
  y: number;
677
690
  zoom: number;
678
691
  }
692
+ /**
693
+ * The rendered board surface's color, reference grid, and shape stroke
694
+ * width — the subset of {@link ScrawlTheme} that reaches the rendering
695
+ * engine directly (everything else is UI-chrome-only, applied as CSS). Any
696
+ * field left unset keeps its current value.
697
+ */
698
+ interface BoardThemeOptions {
699
+ /** The board/canvas background color — distinct from UI chrome panels. */
700
+ surface?: string;
701
+ /** `"flat"` (default): a plain, uniform board surface. `"textured"`: a subtle "melamine" micro-noise + satin sheen, like a physical whiteboard. */
702
+ surfaceTexture?: "flat" | "textured";
703
+ /** `"none"` (default) keeps the board a plain surface; `"line"`/`"dot"` draw a zoom-adaptive reference grid. */
704
+ gridMode?: "none" | "line" | "dot";
705
+ gridColor?: string;
706
+ /** Grid spacing in board units at 100% zoom. Ignored when `gridMode` is `"none"`. */
707
+ gridSpacing?: number;
708
+ /** On-screen grid line/dot width in CSS pixels — stays this width at any zoom, since the grid is a reference aid, not content. */
709
+ gridLineWidth?: number;
710
+ /** Shape (rectangle, ellipse, arrow, ...) border width, in board units — scales with zoom like ink, since it's part of the drawn content. */
711
+ shapeStrokeWidth?: number;
712
+ }
679
713
  /**
680
714
  * A Host-owned comment, summarized for Board-side search and marker
681
715
  * rendering. Comments are not Document content — they carry no undo
@@ -867,22 +901,26 @@ interface CreateBoardControllerOptions {
867
901
  * Trusted Custom tool/object registrations (ticket #22, design:
868
902
  * docs/research/extension-contracts.md). Validated atomically at
869
903
  * construction; registration failure throws before any controller is
870
- * returned. Not yet re-exported from a public package entry point —
871
- * internal-only until the reference Extension proves the seam.
904
+ * returned.
872
905
  */
873
906
  extensions?: readonly ScrawlExtension[];
874
907
  /**
875
908
  * Optional Host-managed Asset capabilities (ticket #23, design:
876
909
  * docs/research/asset-resolution-resource-policy.md). Without a
877
910
  * resolver, referenced Assets preserve their Document geometry and
878
- * render an accessible placeholder. Not yet re-exported from a public
879
- * package entry point — internal-only until the reference resolver
880
- * proves the seam, matching how `extensions` is scoped.
911
+ * render an accessible placeholder.
881
912
  */
882
913
  assetResolver?: AssetResolver;
883
914
  assetIngestor?: AssetIngestor;
884
915
  /** Clamped to 64–512MiB; defaults to 256MiB. */
885
916
  assetCacheBytes?: number;
917
+ /**
918
+ * The rendered board surface's color and reference grid. Defaults to the
919
+ * light theme preset's values; `<Scrawl>` keeps this current across theme
920
+ * changes via `boardTheme.set` below — a headless/browser-tier Host that
921
+ * doesn't use the React theme system can set this directly instead.
922
+ */
923
+ boardTheme?: BoardThemeOptions;
886
924
  }
887
925
  interface BoardController {
888
926
  readonly document: ReadonlyBoardDocument;
@@ -908,6 +946,10 @@ interface BoardController {
908
946
  undo(): void;
909
947
  redo(): void;
910
948
  };
949
+ readonly boardTheme: {
950
+ /** Live update of the board surface color/grid/shape-stroke-width — the controller's identity stays fixed across theme changes. */
951
+ set(theme: BoardThemeOptions): void;
952
+ };
911
953
  readonly view: {
912
954
  fit(): void;
913
955
  zoomTo(value: number): void;
@@ -1008,5 +1050,5 @@ type LocalBoard = {
1008
1050
  };
1009
1051
  declare function createLocalBoard(options: LocalBoardOptions): LocalBoard;
1010
1052
 
1011
- export { STAMPS, createBoardController, createLocalBoard, isStampKind, stampDataUrl };
1012
- export type { ApplyOpsResult, BoardController, BoardControllerError, BoardEventMap, BoardObject, BoardObjectInput, BoardObjectPatch, BoardSnapshot, BoardStyle, BoardView, BuiltInTool, CollaborationAdapter, CollaborationReceiver, CollaborationSession, CollaborationSnapshot, CollaboratorIdentity, CommentMarker, ControllerOp, CreateBoardControllerOptions, DeepReadonly, DocumentContext, LoadResult, LocalBoard, LocalBoardOptions, LocalBoardSnapshot, PersistenceAdapter, PersistenceDiagnostic, PersistenceSnapshot, PresenceCursor, PresenceUser, PresenceView, ReadonlyBoardDocument, ReadonlyDocumentChange, ScreenPoint, ScreenRect, StampKind };
1053
+ export { AssetResolutionError, STAMPS, SUPPORTED_ASSET_MEDIA_TYPES, assetRef, clampAssetCacheBytes, cloneCustomObject, createBoardController, createLocalBoard, isAssetRef, isStampKind, stampDataUrl };
1054
+ export type { ApplyOpsResult, AssetDiagnostic, AssetIngestRequest, AssetIngestResult, AssetIngestor, AssetKind, AssetPurpose, AssetRef, AssetResolutionErrorCode, AssetResolveRequest, AssetResolveResult, AssetResolver, BoardController, BoardControllerError, BoardEventMap, BoardKeyInput, BoardObject, BoardObjectInput, BoardObjectPatch, BoardPointerInput, BoardScene, BoardSnapshot, BoardStyle, BoardThemeOptions, BoardView, BuiltInTool, CollaborationAdapter, CollaborationReceiver, CollaborationSession, CollaborationSnapshot, CollaboratorIdentity, CommentMarker, ControllerOp, CreateBoardControllerOptions, CustomBoardObject, CustomObjectAddInput, CustomObjectDefinition, CustomTool, CustomToolDefinition, DeepReadonly, DocumentContext, ExtensionCommand, ExtensionDiagnostic, ExtensionHitResult, ExtensionId, ExtensionRequirement, InputModifiers, JsonObject, JsonValue, LoadResult, LocalBoard, LocalBoardOptions, LocalBoardSnapshot, Mat2x3, ObjectDescribeContext, ObjectIntent, ObjectType, PersistenceAdapter, PersistenceDiagnostic, PersistenceSnapshot, PresenceCursor, PresenceUser, PresenceView, QueryableBoardObject, ReadonlyBoardDocument, ReadonlyCustomObject, ReadonlyDocumentChange, SceneEllipse, SceneGroup, SceneImage, ScenePath, SceneRect, SceneText, ScrawlExtension, ScreenPoint, ScreenRect, StampKind, SupportedAssetMediaType, ToolCancelReason, ToolCapabilities, ToolCursor, ToolId };