docblocks-react-ui 0.16.0 → 0.18.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.
@@ -1,6 +1,74 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
1
  import { clsx } from "clsx";
3
2
  import { twMerge } from "tailwind-merge";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/shared/ui/cn.ts
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+ //#endregion
9
+ //#region src/shared/errors.ts
10
+ /**
11
+ * Typed react-ui errors.
12
+ *
13
+ * Mirrors docblocks-core's typed command errors: a failed prop contract,
14
+ * a failed blob-store lookup, or a failed fetch throws a named class
15
+ * (never a raw Error), so a consumer can catch by class and the error's
16
+ * identity survives the React boundary.
17
+ */
18
+ /** Base class for all docblocks-react-ui errors. */
19
+ var DocBlocksUiError = class extends Error {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = "DocBlocksUiError";
23
+ }
24
+ };
25
+ /** The EditorProvider's prop contract was violated: a mount-immutable prop
26
+ * (the `doc` instance, the `rootBlockId`) changed, or a required prop is
27
+ * absent. */
28
+ var EditorProviderError = class extends DocBlocksUiError {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = "EditorProviderError";
32
+ }
33
+ };
34
+ /** The blob store has no stored object for the file id. */
35
+ var BlobNotFoundError = class extends DocBlocksUiError {
36
+ constructor(message) {
37
+ super(message);
38
+ this.name = "BlobNotFoundError";
39
+ }
40
+ };
41
+ /** The PDF bytes could not be fetched (a non-ok HTTP response). */
42
+ var PdfFetchError = class extends DocBlocksUiError {
43
+ constructor(message) {
44
+ super(message);
45
+ this.name = "PdfFetchError";
46
+ }
47
+ };
48
+ /** The canvas paste's internal invariant was violated: a non-shape canvas
49
+ * item reached the item insert (the connectors are handled in a
50
+ * follow-up pass). */
51
+ var CanvasPasteError = class extends DocBlocksUiError {
52
+ constructor(message) {
53
+ super(message);
54
+ this.name = "CanvasPasteError";
55
+ }
56
+ };
57
+ /** The slash command's block type is outside the known registry set. */
58
+ var UnknownSlashCommandError = class extends DocBlocksUiError {
59
+ constructor(message) {
60
+ super(message);
61
+ this.name = "UnknownSlashCommandError";
62
+ }
63
+ };
64
+ /** The exhaustiveness backstop: a value escaped a closed union's types. */
65
+ var UnhandledValueError = class extends DocBlocksUiError {
66
+ constructor(message) {
67
+ super(message);
68
+ this.name = "UnhandledValueError";
69
+ }
70
+ };
71
+ //#endregion
4
72
  //#region src/shared/ui/icons/ChevronLeft.tsx
5
73
  function ChevronLeft(props) {
6
74
  return /* @__PURE__ */ jsx("svg", {
@@ -124,11 +192,6 @@ function X(props) {
124
192
  });
125
193
  }
126
194
  //#endregion
127
- //#region src/shared/ui/cn.ts
128
- function cn(...inputs) {
129
- return twMerge(clsx(inputs));
130
- }
131
- //#endregion
132
195
  //#region src/shared/utils.ts
133
196
  /** Clamps a value into the inclusive [min, max] range. */
134
197
  function clamp(value, min, max) {
@@ -163,10 +226,15 @@ function isSafeDownloadHref(url) {
163
226
  * slipped past the types.
164
227
  */
165
228
  function assertNever(value) {
166
- throw new Error(`Unhandled value: ${String(value)}`);
229
+ throw new UnhandledValueError(`Unhandled value: ${String(value)}`);
167
230
  }
168
231
  //#endregion
169
232
  //#region src/pdf/constants.ts
233
+ /** The fullscreen zoom's bounds + the per-click step: the scale's units
234
+ * are the css px per pdf point (the device pixel ratio stands the backing
235
+ * store's scale, not this factor). */
236
+ const ZOOM_MIN = .25;
237
+ const ZOOM_STEP = 1.25;
170
238
  /** The iframe's embeddable-url gate: http(s) and the library-owned blob URL
171
239
  * may stand the viewer's iframe. Data / javascript schemes and unparseable
172
240
  * URLs stand the download-only fallback. */
@@ -179,4 +247,4 @@ function isEmbeddablePdfUrl(url) {
179
247
  }
180
248
  }
181
249
  //#endregion
182
- export { preventDefault as a, X as c, Minus as d, LoaderCircle as f, isSafeDownloadHref as i, TriangleAlert as l, ChevronLeft as m, assertNever as n, stopPropagation as o, ChevronRight as p, clamp as r, cn as s, isEmbeddablePdfUrl as t, Plus as u };
250
+ export { cn as C, UnknownSlashCommandError as S, CanvasPasteError as _, clamp as a, PdfFetchError as b, stopPropagation as c, Plus as d, Minus as f, BlobNotFoundError as g, ChevronLeft as h, assertNever as i, X as l, ChevronRight as m, ZOOM_STEP as n, isSafeDownloadHref as o, LoaderCircle as p, isEmbeddablePdfUrl as r, preventDefault as s, ZOOM_MIN as t, TriangleAlert as u, DocBlocksUiError as v, UnhandledValueError as x, EditorProviderError as y };
@@ -1,7 +1,6 @@
1
- import { n as BlockRendererMap } from "./index-YJcgf8Hh.mjs";
1
+ import { a as PresenceCrypto, i as EditorStore, n as BlockRendererMap } from "./index-G44JW36p.mjs";
2
2
  import { ComponentType, ReactNode } from "react";
3
- import { AttributeType, Block, BlockContent, BlockId, BlockType, CanvasTextAttrs, Change, ConnectorAttrs, DatabaseFilterPayload, Doc, DocAttributeValue, DocMeta, Geometry, MentionKind, MentionMark, PresenceSelection, PresenceState, Selection, SelectionView, ShapeAttrs, SyncEmbedRef, SyncProvider } from "docblocks-core";
4
- import { StoreApi } from "zustand/vanilla";
3
+ import { AttributeType, BlockId, DatabaseFilterPayload, Doc, DocAttributeValue, MentionKind, MentionMark, SelectionView, SyncEmbedRef, SyncProvider } from "docblocks-core";
5
4
  //#region src/editor-provider/models/attributes.d.ts
6
5
  /** The props an attribute-value renderer receives (the `renderAttribute` provider prop). */
7
6
  interface RenderAttributeProps {
@@ -29,11 +28,6 @@ interface AttributeTypePickerProps {
29
28
  type AttributeTypePicker = ComponentType<AttributeTypePickerProps>;
30
29
  //#endregion
31
30
  //#region src/blob-store.d.ts
32
- /**
33
- * The blob bridge: the library does not own storage. Documents hold only an
34
- * opaque file id; the consumer's store returns the bytes and authoritative
35
- * metadata, and notifies open views when that metadata changes.
36
- */
37
31
  /** The blob's authoritative display metadata. */
38
32
  interface BlobMeta {
39
33
  /** The current display and suggested download name. */
@@ -125,7 +119,12 @@ declare function isBridgeError(error: unknown): error is BridgeError;
125
119
  */
126
120
  declare function toBridgeError(error: unknown): BridgeError;
127
121
  //#endregion
128
- //#region src/database/bridge/models.d.ts
122
+ //#region src/database/bridge/wire-types.d.ts
123
+ /**
124
+ * The wire's data model's types (the opaque ids, the table / column's
125
+ * schema entries, the query's inputs — the filter / the sort / the page,
126
+ * the ordered row's wire + the page / table's snapshots).
127
+ */
129
128
  /** An opaque stable identifier (the table / row / field / operation id). */
130
129
  type Id = string;
131
130
  /** The consumer's revision stand (the row / column / table's version). */
@@ -255,6 +254,8 @@ type PageSnapshot = RowPage & {
255
254
  type TableSnapshot = TableDescription & {
256
255
  page: PageSnapshot;
257
256
  };
257
+ //#endregion
258
+ //#region src/database/bridge/event-types.d.ts
258
259
  /** The write's context: the client-issued idempotency key (a UUID, unique
259
260
  * within the operation retention) + the issue time + the optional CAS
260
261
  * revision (its absence selects the LWW default — the last committed
@@ -413,6 +414,13 @@ interface SubscriptionObserver {
413
414
  interface SubscriptionHandle {
414
415
  unsubscribe(): void;
415
416
  }
417
+ //#endregion
418
+ //#region src/database/bridge/grid-types.d.ts
419
+ /**
420
+ * The grid-facing's contract's shapes (the bridge column / table
421
+ * description's view over the wire's schema — the display attributes
422
+ * flattened, the cell annotation + the value's parse contract).
423
+ */
416
424
  /**
417
425
  * A bridge column (the grid's view over the wire's `Column` — the display
418
426
  * attributes flattened, the reference relation's fields in the wire's
@@ -492,6 +500,8 @@ type CellValueParse = {
492
500
  ok: false;
493
501
  error: string;
494
502
  };
503
+ //#endregion
504
+ //#region src/database/bridge/mutation-types.d.ts
495
505
  /** A batch operation (the mixed batch's element; the ordered `ops[]`
496
506
  * commit as one transaction — either the whole batch or none). */
497
507
  type BatchOp = {
@@ -828,202 +838,6 @@ declare function DatabaseTable({ bridge, tableId, readOnly, view, onViewChange,
828
838
  */
829
839
  declare function useTableList(bridge: DatabaseBridge): UseTableList;
830
840
  //#endregion
831
- //#region src/canvas/clipboard/models.d.ts
832
- /** The one copied canvas item (the deep data; the ids stand the originals). */
833
- type ClipboardItem = {
834
- type: "shape";
835
- attrs?: ShapeAttrs;
836
- geometry?: Geometry;
837
- } | {
838
- type: "connector";
839
- attrs: ConnectorAttrs;
840
- geometry?: Geometry;
841
- } | {
842
- type: "canvas-text";
843
- attrs?: CanvasTextAttrs;
844
- content?: BlockContent;
845
- geometry?: Geometry;
846
- } | {
847
- type: "group";
848
- attrs: {
849
- members: BlockId[];
850
- title?: string;
851
- };
852
- geometry?: Geometry;
853
- };
854
- /** The deep copy of the copied canvas items (the ids stand the originals). */
855
- interface CanvasClipboard {
856
- /** The copied items with the original ids (top-level + the containers' transitive members). */
857
- entries: {
858
- id: BlockId;
859
- item: ClipboardItem;
860
- }[];
861
- /** The top-level ids (the selection order) — the paste's selection stand. */
862
- ids: BlockId[];
863
- }
864
- //#endregion
865
- //#region src/presence/models.d.ts
866
- /** The local selection's sharing grant: no sharing, sharing over the whole
867
- * room (plaintext), or a targeted user-id list (encrypted per target). */
868
- type PresenceSharingMode = "off" | "everyone" | string[];
869
- /**
870
- * The consumer's selection cipher (the privacy's stand): the library
871
- * orchestrates the publish/receive pipeline and the consumer brings the
872
- * keys. An entry is an opaque string — the algorithm is the consumer's
873
- * choice.
874
- */
875
- interface PresenceCrypto {
876
- /**
877
- * Encrypt the local selection for the grant: one opaque entry per target
878
- * (grant order; no target id inside an entry — the recipient tries each
879
- * entry with its own `decrypt`).
880
- */
881
- encrypt(selection: PresenceSelection, grant: string[]): Promise<string[]>;
882
- /** Try to decrypt a received entry for the local user. Null when the entry is not addressed to the local user. */
883
- decrypt(entry: string): Promise<PresenceSelection | null>;
884
- }
885
- /** One live roster entry: the peer's identity and whether its selection stands visible to the local user. */
886
- interface PresencePeer {
887
- peerId: string;
888
- userId?: string;
889
- name?: string;
890
- updatedAt: number;
891
- /** True when the peer's selection is accepted locally (decrypted, everyone, or legacy plaintext). */
892
- selectionVisible: boolean;
893
- }
894
- /** The presence sharing's session state (per EditorProvider instance). */
895
- interface PresenceSharing {
896
- /** The local grant (session state; the default "off"; not persisted, not on the wire). */
897
- sharing: PresenceSharingMode;
898
- /** Set the local grant. A no-op over the read-only modes. */
899
- setSharing: (mode: PresenceSharingMode) => void;
900
- /** The live roster of the connected peers (the identity frames are always published). */
901
- peers: PresencePeer[];
902
- }
903
- /** The presence identity's wire payload: the stable user id + the optional display label. */
904
- interface PresenceIdentity {
905
- userId?: string;
906
- name?: string;
907
- }
908
- //#endregion
909
- //#region src/state/models.d.ts
910
- /**
911
- * The slash File command's upload stand: the block the skeleton stands on
912
- * + the phase. View state per editor (not doc data, no wire).
913
- */
914
- interface FileUploadStand {
915
- /** The block the skeleton stand stands on (the trigger phrase's block). */
916
- blockId: BlockId;
917
- /**
918
- * The stand's phase: `picker` — the OS dialog's open (the file's not
919
- * delivered yet), `uploading` — the in-flight upload, `failed` — the
920
- * refused stand's error line (the stand's click dismisses it).
921
- */
922
- phase: "picker" | "uploading" | "failed";
923
- }
924
- /**
925
- * Per-instance editor state: a projection of one docblocks-core Doc.
926
- *
927
- * The store is never the source of truth — writes go command -> Doc ->
928
- * onChange -> applyChange. Slice references are stable across changes a
929
- * slice is not involved in, so a component selecting one block re-renders
930
- * only when that block actually changed.
931
- */
932
- interface EditorState {
933
- /** Block snapshots keyed by id; a block keeps its reference while its JSON is unchanged. */
934
- blocks: Record<BlockId, Block>;
935
- /**
936
- * The entry-list block ids: the document root's children (the page
937
- * sequence), or the subtree entry's derived segment (the subtree root
938
- * and its deeper followers — re-derived only when the change can affect
939
- * it, see `applyChange`'s invalidation: a peer or a local insert into
940
- * the segment grows it without touching the subtree root itself).
941
- */
942
- rootChildren: BlockId[];
943
- /** Document meta; replaced only when the title changed. */
944
- meta: DocMeta;
945
- /**
946
- * The sequence-structure stamp: bumped only when the entry sequence's
947
- * structure changes (a rootChildren change, or a sequence block's
948
- * `indent` / `list` kind changing) — never on a text/mark change of an
949
- * unchanged structure. The motion view's row derivation keys on it, so a
950
- * text-only edit re-renders the edited row through its own subscription
951
- * only (the origin is irrelevant — every change flows through
952
- * `applyChange`).
953
- */
954
- seqStamp: number;
955
- /** Local view selection; a separate slice so caret moves never re-render blocks. */
956
- selection: Selection;
957
- /**
958
- * The collapsed block ids (the derived segment's rows are hidden). Local
959
- * view state — never document data, no wire traffic; a separate slice,
960
- * reset on remount.
961
- */
962
- collapsedIds: BlockId[];
963
- /** Remote peers' ephemeral state; a separate slice for the same reason. */
964
- presence: PresenceState[];
965
- /**
966
- * The local selection's sharing grant (session state per provider
967
- * instance; the default "off" — not document data, never on the wire).
968
- * A separate slice so a grant change never re-renders blocks.
969
- */
970
- sharing: PresenceSharingMode;
971
- /**
972
- * The canvas clipboard: the deep copy of
973
- * the copied canvas items — the view state per editor (not doc data, no
974
- * wire); `null` when empty. A separate slice so the copy never re-renders
975
- * blocks.
976
- */
977
- canvasClipboard: CanvasClipboard | null;
978
- /**
979
- * The slash File command's pending file upload stand (the phrase block's
980
- * row stands the skeleton over its content while the popover stands
981
- * closed). `null` when idle. A separate slice so a stand change never
982
- * re-renders the other blocks.
983
- */
984
- fileUpload: FileUploadStand | null;
985
- /**
986
- * The per-change stamp: bumped whenever `applyChange` writes the store
987
- * (a `blocks` / `rootChildren` / `meta` change). The live `lastUpdatedAt`
988
- * display's re-render source — the Yjs-only `meta.updatedAt` moves on
989
- * every local transaction and is not part of the `meta` slice (the
990
- * slice is replaced only over the `metaChanged`). A separate slice so
991
- * only the stamp's subscribers re-render over the changes.
992
- */
993
- changeStamp: number;
994
- /**
995
- * The canvas-chrome stamp: bumped only when a block's CHROME fields
996
- * (the `type`, the `geometry`, the `attrs`, the `children` — the
997
- * figures' boxes, the port dots' data, the connectors' line attrs, the
998
- * surface's structure) change or a block is added / removed — never
999
- * on a content-only change of an unchanged shape (a keystroke in a
1000
- * figure's text). The canvas chrome's components key their memos on
1001
- * the stamp (an O(1) read — the per-surface JSON digest stood the
1002
- * O(siblings) stand per line per store notification). A separate slice
1003
- * so only the chrome's subscribers re-render over the changes.
1004
- */
1005
- chromeStamp: number;
1006
- }
1007
- /** Internal write functions, called by the EditorProvider subscriptions. */
1008
- interface EditorActions {
1009
- /** Re-reads the blocks a doc change touched, keeping stable references for the unchanged ones. */
1010
- applyChange: (change: Change) => void;
1011
- /** Replaces the presence slice. */
1012
- setPresence: (peers: PresenceState[]) => void;
1013
- /** Sets the local sharing grant. */
1014
- setSharing: (mode: PresenceSharingMode) => void;
1015
- /** Replaces the selection slice. */
1016
- setSelection: (selection: Selection) => void;
1017
- /** Sets the collapsed state of one list item (view state, no doc command). */
1018
- setCollapsed: (id: BlockId, collapsed: boolean) => void;
1019
- /** Replaces the canvas clipboard slice (the copy / the clear). */
1020
- setCanvasClipboard: (clipboard: CanvasClipboard | null) => void;
1021
- /** Replaces the pending file upload stand (the set / the clear). */
1022
- setFileUpload: (stand: FileUploadStand | null) => void;
1023
- }
1024
- /** The per-instance vanilla store created by `createEditorStore`. */
1025
- type EditorStore = StoreApi<EditorState & EditorActions>;
1026
- //#endregion
1027
841
  //#region src/editor-provider/models/mentions.d.ts
1028
842
  /** A mention search result: the stable target id + the display label. */
1029
843
  interface MentionEntry {
@@ -1585,4 +1399,4 @@ declare const DEFAULT_EMBED_SANDBOX = "allow-scripts allow-same-origin allow-for
1585
1399
  /** Read the per-instance editor context; throws outside an EditorProvider. */
1586
1400
  declare function useEditorContext(): EditorContextValue;
1587
1401
  //#endregion
1588
- export { MutationReceipt as $, UseTableList as A, AttributeTypePicker as At, BridgeColumnAnnotation as B, PresencePeer as C, isBridgeError as Ct, DatabaseTable as D, BlobRef as Dt, useTableList as E, BlobMeta as Et, emptyFilter as F, Column as G, BridgeValueInput as H, filterIsComplete as I, FilterConditionInput as J, DatabaseBridge as K, FilterBuilder as L, DatabaseTablePhase as M, RenderAttribute as Mt, DatabaseTableRow as N, RenderAttributeProps as Nt, DatabaseTableProps as O, BlobStore as Ot, UseDatabaseTable as P, MutationContext as Q, BatchOp as R, PresenceIdentity as S, BridgeErrorCode as St, PresenceSharingMode as T, toBridgeError as Tt, CellMap as U, BridgeTableDescription as V, CellValueParse as W, Id as X, FilterInput as Y, IsoInstant as Z, EditorMode as _, TableEvent as _t, EditorContextValue as a, ProtocolLimits as at, MentionProvider as b, BRIDGE_ERROR_CODES as bt, SelectionRef as c, Revision as ct, PdfPreviewProps as d, SortInput as dt, OperationStatus as et, CoverPresetSets as f, SubscriptionHandle as ft, AccessLevel as g, TableEnvelopeBase as gt, DocTags as h, TableDescription as ht, EditorProviderProps as i, ProtocolDescriptor as it, useDatabaseTable as j, AttributeTypePickerProps as jt, DatabaseTableView as k, createMemoryBlobStore as kt, PresenceConfig as l, RowPage as lt, DocTag as m, SubscriptionStatus as mt, DEFAULT_EMBED_SANDBOX as n, PageSnapshot as nt, EmbedSandboxPolicy as o, QueryOperator as ot, DocDescription as p, SubscriptionObserver as pt, DomainEvent as q, EditorProvider as r, ProtocolCapability as rt, SyncEmbedResolver as s, QuerySemantics as st, useEditorContext as t, PageQuery as tt, PdfPreview as u, RowWire as ut, MentionEntry as v, TableRef as vt, PresenceSharing as w, isBridgeErrorCode as wt, PresenceCrypto as x, BridgeError as xt, MentionInteractions as y, TableSnapshot as yt, BridgeColumn as z };
1402
+ export { Column as $, emptyFilter as A, DomainEvent as B, DatabaseTableProps as C, BlobStore as Ct, DatabaseTablePhase as D, RenderAttribute as Dt, useDatabaseTable as E, AttributeTypePickerProps as Et, BridgeColumn as F, ProtocolDescriptor as G, MutationReceipt as H, BridgeColumnAnnotation as I, SubscriptionObserver as J, ProtocolLimits as K, BridgeTableDescription as L, FilterBuilder as M, BatchOp as N, DatabaseTableRow as O, RenderAttributeProps as Ot, DatabaseBridge as P, CellMap as Q, BridgeValueInput as R, DatabaseTable as S, BlobRef as St, UseTableList as T, AttributeTypePicker as Tt, OperationStatus as U, MutationContext as V, ProtocolCapability as W, TableEnvelopeBase as X, SubscriptionStatus as Y, TableEvent as Z, EditorMode as _, BridgeErrorCode as _t, EditorContextValue as a, PageSnapshot as at, MentionProvider as b, toBridgeError as bt, SelectionRef as c, Revision as ct, PdfPreviewProps as d, SortInput as dt, FilterConditionInput as et, CoverPresetSets as f, TableDescription as ft, AccessLevel as g, BridgeError as gt, DocTags as h, BRIDGE_ERROR_CODES as ht, EditorProviderProps as i, PageQuery as it, filterIsComplete as j, UseDatabaseTable as k, PresenceConfig as l, RowPage as lt, DocTag as m, TableSnapshot as mt, DEFAULT_EMBED_SANDBOX as n, Id as nt, EmbedSandboxPolicy as o, QueryOperator as ot, DocDescription as p, TableRef as pt, SubscriptionHandle as q, EditorProvider as r, IsoInstant as rt, SyncEmbedResolver as s, QuerySemantics as st, useEditorContext as t, FilterInput as tt, PdfPreview as u, RowWire as ut, MentionEntry as v, isBridgeError as vt, DatabaseTableView as w, createMemoryBlobStore as wt, useTableList as x, BlobMeta as xt, MentionInteractions as y, isBridgeErrorCode as yt, CellValueParse as z };
@@ -0,0 +1,236 @@
1
+ import { ComponentType, ReactNode } from "react";
2
+ import { Block, BlockContent, BlockId, BlockType, CanvasTextAttrs, Change, ConnectorAttrs, Doc, DocMeta, Geometry, MentionKind, PresenceSelection, PresenceState, Selection, ShapeAttrs, TextRun } from "docblocks-core";
3
+ import { StoreApi } from "zustand/vanilla";
4
+ //#region src/canvas/clipboard/models.d.ts
5
+ /** The one copied canvas item (the deep data; the ids stand the originals). */
6
+ type ClipboardItem = {
7
+ type: "shape";
8
+ attrs?: ShapeAttrs;
9
+ geometry?: Geometry;
10
+ } | {
11
+ type: "connector";
12
+ attrs: ConnectorAttrs;
13
+ geometry?: Geometry;
14
+ } | {
15
+ type: "canvas-text";
16
+ attrs?: CanvasTextAttrs;
17
+ content?: BlockContent;
18
+ geometry?: Geometry;
19
+ } | {
20
+ type: "group";
21
+ attrs: {
22
+ members: BlockId[];
23
+ title?: string;
24
+ };
25
+ geometry?: Geometry;
26
+ };
27
+ /** The deep copy of the copied canvas items (the ids stand the originals). */
28
+ interface CanvasClipboard {
29
+ /** The copied items with the original ids (top-level + the containers' transitive members). */
30
+ entries: {
31
+ id: BlockId;
32
+ item: ClipboardItem;
33
+ }[];
34
+ /** The top-level ids (the selection order) — the paste's selection stand. */
35
+ ids: BlockId[];
36
+ }
37
+ //#endregion
38
+ //#region src/presence/models.d.ts
39
+ /** The local selection's sharing grant: no sharing, sharing over the whole
40
+ * room (plaintext), or a targeted user-id list (encrypted per target). */
41
+ type PresenceSharingMode = "off" | "everyone" | string[];
42
+ /**
43
+ * The consumer's selection cipher (the privacy's stand): the library
44
+ * orchestrates the publish/receive pipeline and the consumer brings the
45
+ * keys. An entry is an opaque string — the algorithm is the consumer's
46
+ * choice.
47
+ */
48
+ interface PresenceCrypto {
49
+ /**
50
+ * Encrypt the local selection for the grant: one opaque entry per target
51
+ * (grant order; no target id inside an entry — the recipient tries each
52
+ * entry with its own `decrypt`).
53
+ */
54
+ encrypt(selection: PresenceSelection, grant: string[]): Promise<string[]>;
55
+ /** Try to decrypt a received entry for the local user. Null when the entry is not addressed to the local user. */
56
+ decrypt(entry: string): Promise<PresenceSelection | null>;
57
+ }
58
+ /** One live roster entry: the peer's identity and whether its selection stands visible to the local user. */
59
+ interface PresencePeer {
60
+ peerId: string;
61
+ userId?: string;
62
+ name?: string;
63
+ updatedAt: number;
64
+ /** True when the peer's selection is accepted locally (decrypted, everyone, or legacy plaintext). */
65
+ selectionVisible: boolean;
66
+ }
67
+ /** The presence sharing's session state (per EditorProvider instance). */
68
+ interface PresenceSharing {
69
+ /** The local grant (session state; the default "off"; not persisted, not on the wire). */
70
+ sharing: PresenceSharingMode;
71
+ /** Set the local grant. A no-op over the read-only modes. */
72
+ setSharing: (mode: PresenceSharingMode) => void;
73
+ /** The live roster of the connected peers (the identity frames are always published). */
74
+ peers: PresencePeer[];
75
+ }
76
+ /** The presence identity's wire payload: the stable user id + the optional display label. */
77
+ interface PresenceIdentity {
78
+ userId?: string;
79
+ name?: string;
80
+ }
81
+ //#endregion
82
+ //#region src/state/models.d.ts
83
+ /**
84
+ * The slash File command's upload stand: the block the skeleton stands on
85
+ * + the phase. View state per editor (not doc data, no wire).
86
+ */
87
+ interface FileUploadStand {
88
+ /** The block the skeleton stand stands on (the trigger phrase's block). */
89
+ blockId: BlockId;
90
+ /**
91
+ * The stand's phase: `picker` — the OS dialog's open (the file's not
92
+ * delivered yet), `uploading` — the in-flight upload, `failed` — the
93
+ * refused stand's error line (the stand's click dismisses it).
94
+ */
95
+ phase: "picker" | "uploading" | "failed";
96
+ }
97
+ /**
98
+ * Per-instance editor state: a projection of one docblocks-core Doc.
99
+ *
100
+ * The store is never the source of truth — writes go command -> Doc ->
101
+ * onChange -> applyChange. Slice references are stable across changes a
102
+ * slice is not involved in, so a component selecting one block re-renders
103
+ * only when that block actually changed.
104
+ */
105
+ interface EditorState {
106
+ /** Block snapshots keyed by id; a block keeps its reference while its JSON is unchanged. */
107
+ blocks: Record<BlockId, Block>;
108
+ /**
109
+ * The entry-list block ids: the document root's children (the page
110
+ * sequence), or the subtree entry's derived segment (the subtree root
111
+ * and its deeper followers — re-derived only when the change can affect
112
+ * it, see `applyChange`'s invalidation: a peer or a local insert into
113
+ * the segment grows it without touching the subtree root itself).
114
+ */
115
+ rootChildren: BlockId[];
116
+ /** Document meta; replaced only when the title changed. */
117
+ meta: DocMeta;
118
+ /**
119
+ * The sequence-structure stamp: bumped only when the entry sequence's
120
+ * structure changes (a rootChildren change, or a sequence block's
121
+ * `indent` / `list` kind changing) — never on a text/mark change of an
122
+ * unchanged structure. The motion view's row derivation keys on it, so a
123
+ * text-only edit re-renders the edited row through its own subscription
124
+ * only (the origin is irrelevant — every change flows through
125
+ * `applyChange`).
126
+ */
127
+ seqStamp: number;
128
+ /** Local view selection; a separate slice so caret moves never re-render blocks. */
129
+ selection: Selection;
130
+ /**
131
+ * The collapsed block ids (the derived segment's rows are hidden). Local
132
+ * view state — never document data, no wire traffic; a separate slice,
133
+ * reset on remount.
134
+ */
135
+ collapsedIds: BlockId[];
136
+ /** Remote peers' ephemeral state; a separate slice for the same reason. */
137
+ presence: PresenceState[];
138
+ /**
139
+ * The local selection's sharing grant (session state per provider
140
+ * instance; the default "off" — not document data, never on the wire).
141
+ * A separate slice so a grant change never re-renders blocks.
142
+ */
143
+ sharing: PresenceSharingMode;
144
+ /**
145
+ * The canvas clipboard: the deep copy of
146
+ * the copied canvas items — the view state per editor (not doc data, no
147
+ * wire); `null` when empty. A separate slice so the copy never re-renders
148
+ * blocks.
149
+ */
150
+ canvasClipboard: CanvasClipboard | null;
151
+ /**
152
+ * The slash File command's pending file upload stand (the phrase block's
153
+ * row stands the skeleton over its content while the popover stands
154
+ * closed). `null` when idle. A separate slice so a stand change never
155
+ * re-renders the other blocks.
156
+ */
157
+ fileUpload: FileUploadStand | null;
158
+ /**
159
+ * The per-change stamp: bumped whenever `applyChange` writes the store
160
+ * (a `blocks` / `rootChildren` / `meta` change). The live `lastUpdatedAt`
161
+ * display's re-render source — the Yjs-only `meta.updatedAt` moves on
162
+ * every local transaction and is not part of the `meta` slice (the
163
+ * slice is replaced only over the `metaChanged`). A separate slice so
164
+ * only the stamp's subscribers re-render over the changes.
165
+ */
166
+ changeStamp: number;
167
+ /**
168
+ * The canvas-chrome stamp: bumped only when a block's CHROME fields
169
+ * (the `type`, the `geometry`, the `attrs`, the `children` — the
170
+ * figures' boxes, the port dots' data, the connectors' line attrs, the
171
+ * surface's structure) change or a block is added / removed — never
172
+ * on a content-only change of an unchanged shape (a keystroke in a
173
+ * figure's text). The canvas chrome's components key their memos on
174
+ * the stamp (an O(1) read — the per-surface JSON digest stood the
175
+ * O(siblings) stand per line per store notification). A separate slice
176
+ * so only the chrome's subscribers re-render over the changes.
177
+ */
178
+ chromeStamp: number;
179
+ }
180
+ /** Internal write functions, called by the EditorProvider subscriptions. */
181
+ interface EditorActions {
182
+ /** Re-reads the blocks a doc change touched, keeping stable references for the unchanged ones. */
183
+ applyChange: (change: Change) => void;
184
+ /** Replaces the presence slice. */
185
+ setPresence: (peers: PresenceState[]) => void;
186
+ /** Sets the local sharing grant. */
187
+ setSharing: (mode: PresenceSharingMode) => void;
188
+ /** Replaces the selection slice. */
189
+ setSelection: (selection: Selection) => void;
190
+ /** Sets the collapsed state of one list item (view state, no doc command). */
191
+ setCollapsed: (id: BlockId, collapsed: boolean) => void;
192
+ /** Replaces the canvas clipboard slice (the copy / the clear). */
193
+ setCanvasClipboard: (clipboard: CanvasClipboard | null) => void;
194
+ /** Replaces the pending file upload stand (the set / the clear). */
195
+ setFileUpload: (stand: FileUploadStand | null) => void;
196
+ }
197
+ /** The per-instance vanilla store created by `createEditorStore`. */
198
+ type EditorStore = StoreApi<EditorState & EditorActions>;
199
+ //#endregion
200
+ //#region src/blocks/renderers.d.ts
201
+ /** The props a block renderer receives: the block id and its plain snapshot. */
202
+ interface BlockRendererProps {
203
+ id: BlockId;
204
+ block: Block;
205
+ }
206
+ /**
207
+ * A consumer renderer for a block type; resolved in place of the built-in
208
+ * renderer. Replacing a text-editable type swaps the whole block view,
209
+ * including the wrapper, the contenteditable element, and its editing
210
+ * affordance — a renderer that needs editing drives the core commands
211
+ * through the hooks (the consumer builds its own UI on top of them).
212
+ *
213
+ * The built-in text renderers read the per-block context (the page
214
+ * context — the root, a table cell, or a frame — and the flat page
215
+ * sequence) for the keyboard gestures; a consumer renderer does not read
216
+ * it — the context is part of the built-in rendering, not of the renderer
217
+ * contract. Nesting is a derived notion (the flat page model: a block's
218
+ * `indent` attr relative to its preceding block, not a data field), so a
219
+ * replaced block does not receive its derived nested content — the
220
+ * sequence rendering stands a block's deeper followers as a nested slot
221
+ * AFTER the replaced view (the content is never dropped); a renderer that
222
+ * wants to render them itself drives the doc through the hooks.
223
+ *
224
+ * A renderer is a plain render function, not a component: it is invoked
225
+ * during the block view's render, so it must not call hooks itself —
226
+ * return a component's output from a wrapper component if needed.
227
+ */
228
+ type BlockRenderer = (props: BlockRendererProps) => ReactNode;
229
+ /**
230
+ * Per-instance consumer renderers, keyed by block type. A type without an
231
+ * entry keeps its built-in renderer; a type with neither renders the
232
+ * placeholder (future block types keep working).
233
+ */
234
+ type BlockRendererMap = Partial<Record<BlockType, BlockRenderer>>;
235
+ //#endregion
236
+ export { PresenceCrypto as a, PresenceSharing as c, EditorStore as i, PresenceSharingMode as l, BlockRendererMap as n, PresenceIdentity as o, BlockRendererProps as r, PresencePeer as s, BlockRenderer as t };