@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/react.d.ts CHANGED
@@ -8,6 +8,9 @@ type StrokeId = string & {
8
8
 
9
9
  /** Wire grammar: `asset:<namespace>:<opaque-id>`. Interpreted only by the Host. */
10
10
  type AssetRef = string;
11
+ declare function isAssetRef(value: unknown): value is AssetRef;
12
+ /** Throws on malformed input; use `isAssetRef` where a boolean is wanted instead. */
13
+ declare function assetRef(value: string): AssetRef;
11
14
  type AssetKind = "image";
12
15
  type AssetPurpose = "render" | "thumbnail" | "export";
13
16
  interface AssetResolveRequest {
@@ -49,6 +52,12 @@ interface AssetIngestor {
49
52
  ingest(request: AssetIngestRequest): Promise<AssetIngestResult>;
50
53
  }
51
54
  type AssetResolutionErrorCode = "resolver-unavailable" | "not-found" | "forbidden" | "offline" | "unsupported-type" | "too-large" | "invalid-content" | "decode-failed" | "budget-exceeded" | "aborted" | "unknown";
55
+ declare class AssetResolutionError extends Error {
56
+ readonly code: AssetResolutionErrorCode;
57
+ readonly retryable: boolean;
58
+ readonly ref?: AssetRef | undefined;
59
+ constructor(code: AssetResolutionErrorCode, retryable: boolean, message: string, ref?: AssetRef | undefined);
60
+ }
52
61
  /** Runtime event for a resolution/ingestion failure — never carries credentials or a fetchable location. */
53
62
  interface AssetDiagnostic {
54
63
  code: AssetResolutionErrorCode;
@@ -57,6 +66,9 @@ interface AssetDiagnostic {
57
66
  objectKind: "image" | "custom";
58
67
  retryable: boolean;
59
68
  }
69
+ declare const SUPPORTED_ASSET_MEDIA_TYPES: readonly ["image/png", "image/jpeg", "image/webp"];
70
+ type SupportedAssetMediaType = (typeof SUPPORTED_ASSET_MEDIA_TYPES)[number];
71
+ declare function clampAssetCacheBytes(value: number | undefined): number;
60
72
 
61
73
  type Mat2x3 = [number, number, number, number, number, number];
62
74
 
@@ -104,6 +116,7 @@ interface CustomBoardObject {
104
116
  };
105
117
  props: JsonValue;
106
118
  }
119
+ declare function cloneCustomObject(object: CustomBoardObject): CustomBoardObject;
107
120
  /**
108
121
  * The read-only view handed to `describe`. Deep-readonly by construction
109
122
  * (not derived via a shallow `Readonly<>`) because `describe` must treat its
@@ -672,6 +685,27 @@ interface BoardView {
672
685
  y: number;
673
686
  zoom: number;
674
687
  }
688
+ /**
689
+ * The rendered board surface's color, reference grid, and shape stroke
690
+ * width — the subset of {@link ScrawlTheme} that reaches the rendering
691
+ * engine directly (everything else is UI-chrome-only, applied as CSS). Any
692
+ * field left unset keeps its current value.
693
+ */
694
+ interface BoardThemeOptions {
695
+ /** The board/canvas background color — distinct from UI chrome panels. */
696
+ surface?: string;
697
+ /** `"flat"` (default): a plain, uniform board surface. `"textured"`: a subtle "melamine" micro-noise + satin sheen, like a physical whiteboard. */
698
+ surfaceTexture?: "flat" | "textured";
699
+ /** `"none"` (default) keeps the board a plain surface; `"line"`/`"dot"` draw a zoom-adaptive reference grid. */
700
+ gridMode?: "none" | "line" | "dot";
701
+ gridColor?: string;
702
+ /** Grid spacing in board units at 100% zoom. Ignored when `gridMode` is `"none"`. */
703
+ gridSpacing?: number;
704
+ /** On-screen grid line/dot width in CSS pixels — stays this width at any zoom, since the grid is a reference aid, not content. */
705
+ gridLineWidth?: number;
706
+ /** Shape (rectangle, ellipse, arrow, ...) border width, in board units — scales with zoom like ink, since it's part of the drawn content. */
707
+ shapeStrokeWidth?: number;
708
+ }
675
709
  /**
676
710
  * A Host-owned comment, summarized for Board-side search and marker
677
711
  * rendering. Comments are not Document content — they carry no undo
@@ -863,22 +897,26 @@ interface CreateBoardControllerOptions {
863
897
  * Trusted Custom tool/object registrations (ticket #22, design:
864
898
  * docs/research/extension-contracts.md). Validated atomically at
865
899
  * construction; registration failure throws before any controller is
866
- * returned. Not yet re-exported from a public package entry point —
867
- * internal-only until the reference Extension proves the seam.
900
+ * returned.
868
901
  */
869
902
  extensions?: readonly ScrawlExtension[];
870
903
  /**
871
904
  * Optional Host-managed Asset capabilities (ticket #23, design:
872
905
  * docs/research/asset-resolution-resource-policy.md). Without a
873
906
  * resolver, referenced Assets preserve their Document geometry and
874
- * render an accessible placeholder. Not yet re-exported from a public
875
- * package entry point — internal-only until the reference resolver
876
- * proves the seam, matching how `extensions` is scoped.
907
+ * render an accessible placeholder.
877
908
  */
878
909
  assetResolver?: AssetResolver;
879
910
  assetIngestor?: AssetIngestor;
880
911
  /** Clamped to 64–512MiB; defaults to 256MiB. */
881
912
  assetCacheBytes?: number;
913
+ /**
914
+ * The rendered board surface's color and reference grid. Defaults to the
915
+ * light theme preset's values; `<Scrawl>` keeps this current across theme
916
+ * changes via `boardTheme.set` below — a headless/browser-tier Host that
917
+ * doesn't use the React theme system can set this directly instead.
918
+ */
919
+ boardTheme?: BoardThemeOptions;
882
920
  }
883
921
  interface BoardController {
884
922
  readonly document: ReadonlyBoardDocument;
@@ -904,6 +942,10 @@ interface BoardController {
904
942
  undo(): void;
905
943
  redo(): void;
906
944
  };
945
+ readonly boardTheme: {
946
+ /** Live update of the board surface color/grid/shape-stroke-width — the controller's identity stays fixed across theme changes. */
947
+ set(theme: BoardThemeOptions): void;
948
+ };
907
949
  readonly view: {
908
950
  fit(): void;
909
951
  zoomTo(value: number): void;
@@ -1000,30 +1042,76 @@ type LocalBoard = {
1000
1042
 
1001
1043
  type ScrawlThemePreset = "light" | "dark";
1002
1044
  type ScrawlDensity = "comfortable" | "compact";
1045
+ type ScrawlGridMode = "none" | "line" | "dot";
1046
+ type ScrawlSurfaceTexture = "flat" | "textured";
1047
+ /**
1048
+ * Every field is optional — anything you don't set falls back to the
1049
+ * chosen `preset` ("light" or "dark", see {@link resolveScrawlTheme}).
1050
+ * Overrides are semantic, board-local runtime configuration: they never
1051
+ * get written into the Document or into exports, so switching themes is
1052
+ * always non-destructive.
1053
+ */
1003
1054
  interface ScrawlTheme {
1055
+ /** UI chrome background — toolbar/panel base surface. Distinct from `boardSurface` (the canvas itself). */
1004
1056
  surface?: string;
1057
+ /** UI chrome background, one step up from `surface` — popovers, dropdowns, elevated panels. */
1005
1058
  surfaceRaised?: string;
1059
+ /** UI chrome background, one step down from `surface` — subtle fills, hover states. */
1006
1060
  surfaceMuted?: string;
1061
+ /** Primary UI text color. Checked for contrast against `surface`. */
1007
1062
  text?: string;
1063
+ /** Secondary/de-emphasized UI text color. Checked for contrast against `surface`. */
1008
1064
  textMuted?: string;
1065
+ /** Borders and dividers between UI chrome elements. */
1009
1066
  edge?: string;
1067
+ /** Focus ring color. Checked for contrast against `surface`. */
1010
1068
  focus?: string;
1069
+ /** Selection highlight color (e.g. selected list items, not board object selection). */
1011
1070
  selection?: string;
1071
+ /** Destructive/error state color (delete confirmations, error text). */
1012
1072
  danger?: string;
1073
+ /** Warning state color. */
1013
1074
  warning?: string;
1075
+ /** Success/confirmation state color. */
1014
1076
  success?: string;
1077
+ /** Font stack for UI chrome (toolbar labels, menus, dialogs). */
1015
1078
  uiFontFamily?: string;
1079
+ /** Font stack for board content and data (e.g. table cell text). */
1016
1080
  dataFontFamily?: string;
1081
+ /** Base UI font size in px. Range: 12–24. */
1017
1082
  baseFontSize?: number;
1083
+ /** Regular UI font weight. Range: 300–900. */
1018
1084
  regularWeight?: number;
1085
+ /** Emphasized UI font weight (headings, active states). Range: 300–900. */
1019
1086
  strongWeight?: number;
1087
+ /** Corner radius for small controls (buttons, inputs) in px. Range: 0–32. */
1020
1088
  controlRadius?: number;
1089
+ /** Corner radius for panels/dialogs in px. Range: 0–32. */
1021
1090
  panelRadius?: number;
1091
+ /** CSS `box-shadow` value for subtle elevation (e.g. toolbar). */
1022
1092
  elevationLow?: string;
1093
+ /** CSS `box-shadow` value for prominent elevation (e.g. modals). */
1023
1094
  elevationHigh?: string;
1095
+ /** UI transition duration in ms. Range: 0–500. */
1024
1096
  motionDuration?: number;
1097
+ /** CSS easing function for UI transitions. */
1025
1098
  motionEasing?: string;
1099
+ /** UI chrome spacing/sizing scale. */
1026
1100
  density?: ScrawlDensity;
1101
+ /** The rendered board/canvas surface color — distinct from `surface` (UI chrome panels). */
1102
+ boardSurface?: string;
1103
+ /** `"flat"` (default): a plain, uniform board surface. `"textured"`: a subtle "melamine" micro-noise + satin sheen, like a physical whiteboard. */
1104
+ boardSurfaceTexture?: ScrawlSurfaceTexture;
1105
+ /** `"none"` (default) keeps the board a plain surface; `"line"`/`"dot"` draw a zoom-adaptive reference grid. */
1106
+ gridMode?: ScrawlGridMode;
1107
+ /** Grid line/dot color. Ignored when `gridMode` is `"none"`. */
1108
+ gridColor?: string;
1109
+ /** Grid spacing in board units at 100% zoom. Ignored when `gridMode` is `"none"`. */
1110
+ gridSpacing?: number;
1111
+ /** On-screen grid line/dot width in CSS pixels. Range: 0.5–8. A reference aid, so unlike shape/ink strokes it stays this width at any zoom. */
1112
+ gridLineWidth?: number;
1113
+ /** Shape (rectangle, ellipse, arrow, ...) border width, in board units. Range: 0.01–5. Scales with zoom like ink, since it's part of the drawn content. */
1114
+ shapeStrokeWidth?: number;
1027
1115
  }
1028
1116
  type ResolvedScrawlTheme = Required<ScrawlTheme>;
1029
1117
  interface ScrawlThemeDiagnostic {
@@ -1167,5 +1255,5 @@ type ScrawlBoardProps = {
1167
1255
  };
1168
1256
  declare function ScrawlBoard({ documentId, initialDocument, onReady, className, style }: ScrawlBoardProps): react.JSX.Element;
1169
1257
 
1170
- export { DefaultBoardChrome, InlineEditors, MultiplayerCursors, Scrawl, ScrawlBoard, ScrawlCanvas, ScrawlDefaultUI, ScrawlPortal, ScrawlProvider, StyleShelf, resolveScrawlTheme, scrawlThemePresets, useScrawlController, useScrawlSnapshot, useScrawlTheme, validateScrawlTheme };
1171
- export type { BoardController, BoardSlotProps, BoardSnapshot, BoardStyle, CommentMarker, CreateBoardControllerOptions, DefaultBoardChromeProps, DefaultUIRegion, DefaultUISlot, DefaultUISlots, DialogSlotProps, InlineEditorsProps, LocalBoard, LocalBoardSnapshot, MultiplayerCursorsProps, PresenceCursor, PresenceUser, PresenceView, ScrawlBoardProps, ScrawlCanvasProps, ScrawlDefaultUIProps, ScrawlProps, ScrawlProviderProps, ScrawlResolvedTheme, ScrawlTheme, ScrawlThemeDiagnostic, ScrawlThemePreset, StyleShelfProps };
1258
+ export { AssetResolutionError, DefaultBoardChrome, InlineEditors, MultiplayerCursors, SUPPORTED_ASSET_MEDIA_TYPES, Scrawl, ScrawlBoard, ScrawlCanvas, ScrawlDefaultUI, ScrawlPortal, ScrawlProvider, StyleShelf, assetRef, clampAssetCacheBytes, cloneCustomObject, isAssetRef, resolveScrawlTheme, scrawlThemePresets, useScrawlController, useScrawlSnapshot, useScrawlTheme, validateScrawlTheme };
1259
+ export type { AssetDiagnostic, AssetIngestRequest, AssetIngestResult, AssetIngestor, AssetKind, AssetPurpose, AssetRef, AssetResolutionErrorCode, AssetResolveRequest, AssetResolveResult, AssetResolver, BoardController, BoardKeyInput, BoardPointerInput, BoardScene, BoardSlotProps, BoardSnapshot, BoardStyle, BoardThemeOptions, CommentMarker, CreateBoardControllerOptions, CustomBoardObject, CustomObjectAddInput, CustomObjectDefinition, CustomTool, CustomToolDefinition, DefaultBoardChromeProps, DefaultUIRegion, DefaultUISlot, DefaultUISlots, DialogSlotProps, ExtensionCommand, ExtensionDiagnostic, ExtensionHitResult, ExtensionId, ExtensionRequirement, InlineEditorsProps, InputModifiers, JsonObject, JsonValue, LocalBoard, LocalBoardSnapshot, Mat2x3, MultiplayerCursorsProps, ObjectDescribeContext, ObjectIntent, ObjectType, PresenceCursor, PresenceUser, PresenceView, QueryableBoardObject, ReadonlyCustomObject, SceneEllipse, SceneGroup, SceneImage, ScenePath, SceneRect, SceneText, ScrawlBoardProps, ScrawlCanvasProps, ScrawlDefaultUIProps, ScrawlDensity, ScrawlExtension, ScrawlGridMode, ScrawlProps, ScrawlProviderProps, ScrawlResolvedTheme, ScrawlSurfaceTexture, ScrawlTheme, ScrawlThemeDiagnostic, ScrawlThemePreset, StyleShelfProps, SupportedAssetMediaType, ToolCancelReason, ToolCapabilities, ToolCursor, ToolId };