@dineug/erd-editor 3.8.0 → 3.9.1

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/components/erd/canvas/column-drag-ghost/ColumnDragGhost.d.ts +10 -0
  3. package/dist/components/erd/canvas/column-drag-ghost/columnDragPointer.d.ts +28 -0
  4. package/dist/components/erd/canvas/sceneTokens.d.ts +31 -5
  5. package/dist/components/erd/canvas/table/cellLayout.d.ts +6 -6
  6. package/dist/components/erd/canvas/table/colorEdge.d.ts +10 -0
  7. package/dist/components/erd/canvas/table/column/Column.d.ts +12 -3
  8. package/dist/components/erd/canvas/useMoveEntity.d.ts +6 -0
  9. package/dist/components/erd/diff-viewer/diff.d.ts +9 -2
  10. package/dist/components/erd/diff-viewer/diffContext.d.ts +9 -0
  11. package/dist/components/primitives/context-menu/context-menu-content/ContextMenuContent.d.ts +2 -0
  12. package/dist/components/primitives/context-menu/context-menu-content/fitMenu.d.ts +20 -0
  13. package/dist/components/table-view/Table.styles.d.ts +6 -1
  14. package/dist/components/table-view/column/useColumnCell.d.ts +5 -0
  15. package/dist/components/visualization/Visualization.styles.d.ts +4 -1
  16. package/dist/components/visualization/captureDrag.d.ts +14 -0
  17. package/dist/components/visualization/useViewGestures.d.ts +2 -2
  18. package/dist/constants/layout.d.ts +29 -6
  19. package/dist/engine/index.js +14 -13
  20. package/dist/engine/modules/editor/generator.actions.d.ts +3 -2
  21. package/dist/engine/modules/relationship/fkColumns.d.ts +9 -0
  22. package/dist/engine/modules/relationship/generator.actions.d.ts +10 -1
  23. package/dist/engine/modules/settings/generator.actions.d.ts +15 -0
  24. package/dist/engine/modules/table/generator.actions.d.ts +7 -0
  25. package/dist/engine/peer-store.d.ts +93 -0
  26. package/dist/engine/presence.d.ts +23 -0
  27. package/dist/engine/rx-operators/bufferCircuitBreaker.d.ts +5 -0
  28. package/dist/engine/rx-operators/createSharedStreamActionsCompressor.d.ts +10 -0
  29. package/dist/engine/rx-operators/flushOnNotifier.d.ts +9 -0
  30. package/dist/engine/rx-operators/groupByStreamActions.d.ts +3 -1
  31. package/dist/engine/rx-operators/sharedStreamActionsCompressor.d.ts +2 -3
  32. package/dist/engine/rx-store.d.ts +14 -1
  33. package/dist/engine/shared-store.d.ts +11 -1
  34. package/dist/engine/stream-flush.d.ts +12 -0
  35. package/dist/engine/tag.d.ts +2 -0
  36. package/dist/engine/to-width.d.ts +7 -0
  37. package/dist/erd-editor.umd.js +330 -315
  38. package/dist/hooks/usePinchZoom.d.ts +27 -0
  39. package/dist/index.js +5508 -6091
  40. package/dist/konva/scene/columnDropTarget.d.ts +10 -3
  41. package/dist/konva/scene/viewLayout.d.ts +10 -5
  42. package/dist/konva/scene/viewport.d.ts +6 -0
  43. package/dist/peer/index.d.ts +29 -0
  44. package/dist/peer/index.js +230 -0
  45. package/dist/schemaGCService-_8A8Oh9Q.js +38 -0
  46. package/dist/shared-store-CtJL8B4I.js +1072 -0
  47. package/dist/{schemaGCService-CXVjeF9p.js → store-hooks-DuNN9ZKu.js} +3697 -3541
  48. package/dist/styles/elevation.styles.d.ts +7 -0
  49. package/dist/themes/radix-ui-theme.config.d.ts +12 -0
  50. package/dist/themes/tokens.d.ts +7 -0
  51. package/dist/utils/calcTable.d.ts +10 -5
  52. package/dist/utils/domEvent.d.ts +2 -0
  53. package/dist/utils/pinch.d.ts +34 -0
  54. package/dist/utils/validation.d.ts +1 -0
  55. package/dist/workers/exportPng.shared-worker.js +26 -26
  56. package/package.json +6 -2
@@ -0,0 +1,93 @@
1
+ import { AnyAction, CompositionActions } from '@dineug/r-html';
2
+ import { FocusType } from './modules/editor/state';
3
+ import { RootState } from './state';
4
+ import { Unsubscribe, ValuesType } from '../internal-types';
5
+ export type PeerStoreOptions = {
6
+ nickname: string;
7
+ toWidth?: (text: string) => number;
8
+ /** Sends the focused cell to the other peers. A headless session turns it off. */
9
+ presence?: boolean;
10
+ /** Refuses every dispatch, undo and redo, as a readonly document does. */
11
+ readonly?: boolean;
12
+ };
13
+ /** The cell to focus before an edit, so the others see where the peer works. */
14
+ export type DispatchFocus = {
15
+ tableId: string;
16
+ columnId?: string;
17
+ focusType: FocusType;
18
+ };
19
+ export type DispatchOptions = {
20
+ /** Names the dispatch as one undo unit, echoed back by undo and redo. */
21
+ label?: string;
22
+ focus?: DispatchFocus;
23
+ };
24
+ export type DispatchReport = {
25
+ label: string | null;
26
+ /** The document changes the dispatch made, version stamped, in order. */
27
+ actions: AnyAction[];
28
+ createdIds: string[];
29
+ /** Outbound batches that carried a document change. */
30
+ batches: number;
31
+ /** Undo entries the history took in. */
32
+ historyEntries: number;
33
+ };
34
+ /**
35
+ * What an undo or redo reverted: the dispatch's label, how many history
36
+ * entries it took, and the labels passed over because the engine made them
37
+ * no undo entry. Zero entries means there was nothing left to revert.
38
+ */
39
+ export type RevertResult = {
40
+ label: string | null;
41
+ entries: number;
42
+ skipped: string[];
43
+ };
44
+ /** Why a peer store refused a call before dispatching anything. */
45
+ export declare const PeerStoreErrorCode: {
46
+ readonly readonly: "readonly";
47
+ readonly destroyed: "destroyed";
48
+ };
49
+ export type PeerStoreErrorCode = ValuesType<typeof PeerStoreErrorCode>;
50
+ /** A refusal: the code says why, operation names the call, and nothing moved. */
51
+ export declare class PeerStoreError extends Error {
52
+ readonly code: PeerStoreErrorCode;
53
+ readonly operation: string;
54
+ constructor(code: PeerStoreErrorCode, operation: string);
55
+ }
56
+ export type PeerStore = {
57
+ readonly editorId: string;
58
+ /** The document as the element would save it. */
59
+ readonly value: string;
60
+ /** The live state, for readers that serialize it another way. */
61
+ readonly state: RootState;
62
+ readonly isReadonly: boolean;
63
+ readonly isDestroyed: boolean;
64
+ setReadonly: (readonly: boolean) => void;
65
+ /**
66
+ * Replaces the document and forgets every undo entry and label with it,
67
+ * since those were taken against the old one. The one reseed operation.
68
+ */
69
+ setInitialValue: (value: string) => void;
70
+ mergeClock: (version: number) => void;
71
+ dispatch: (actions: CompositionActions, options?: DispatchOptions) => DispatchReport;
72
+ /** Applies another peer's batch now, so a read right after sees it. */
73
+ receive: (actions: AnyAction[] | AnyAction) => void;
74
+ /**
75
+ * Runs dispatches as one undo unit under label, so one undo reverts every
76
+ * entry they made. A group inside another joins it; undo, redo and a reseed
77
+ * are refused inside one, since the unit would no longer match the history.
78
+ */
79
+ group: <T>(label: string, run: () => T) => T;
80
+ undo: () => RevertResult;
81
+ redo: () => RevertResult;
82
+ subscribe: (fn: (actions: AnyAction[]) => void) => Unsubscribe;
83
+ /** Closes the history's stream groups, then the outbound pipe's. */
84
+ flushStreamBuffers: () => void;
85
+ destroy: () => void;
86
+ };
87
+ /**
88
+ * A collaborating editor with no screen: the element's store pipeline, driven
89
+ * by dispatches instead of a pointer. Stream buffers close when a dispatch
90
+ * ends rather than after a quiet period, so one dispatch is one outbound batch.
91
+ */
92
+ export declare function createPeerStore({ nickname, toWidth, presence, readonly, }: PeerStoreOptions): PeerStore;
93
+ //# sourceMappingURL=peer-store.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { Editor } from './modules/editor/state';
2
+ import { RxStore } from './rx-store';
3
+ /** A third of the expiry, so two beats can go missing before a peer drops the cell. */
4
+ export declare const FOCUS_HEARTBEAT_MS: number;
5
+ export type FocusPresence = {
6
+ destroy: () => void;
7
+ };
8
+ declare const SHARED_TRACKER_MAPS: readonly ["sharedMouseTrackerMap", "sharedFocusTrackerMap", "sharedSelectionTrackerMap", "sharedDragSelectTrackerMap"];
9
+ type SharedTrackerMaps = Pick<Editor, (typeof SHARED_TRACKER_MAPS)[number]>;
10
+ /**
11
+ * Clears the expiry the engine set on every tracker another peer sent, and the
12
+ * trackers with it. A pending expiry is a Node timer the reducer never releases,
13
+ * so a closed peer's process would wait up to 90 seconds for it.
14
+ */
15
+ export declare function clearSharedTrackers(editor: SharedTrackerMaps): void;
16
+ /**
17
+ * The focus half of the element's presence tracker: the focused cell goes out
18
+ * when it changes, again on every heartbeat and whenever a peer joins. Mouse,
19
+ * selection and drag selection are never sent.
20
+ */
21
+ export declare function createFocusPresence(store: Pick<RxStore, 'state' | 'subscribe' | 'dispatch'>): FocusPresence;
22
+ export {};
23
+ //# sourceMappingURL=presence.d.ts.map
@@ -1,4 +1,9 @@
1
1
  import { AnyAction } from '@dineug/r-html';
2
2
  import { Observable } from 'rxjs';
3
+ /**
4
+ * Holds the source's batches while the circuit is open, flushes them when it
5
+ * closes and lets batches straight through until it opens again. The source is
6
+ * subscribed once, so a cold upstream's timers cannot flush ahead of its value.
7
+ */
3
8
  export declare const bufferCircuitBreaker: (openingNotifier$: Observable<any>, closingNotifier$: Observable<any>) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
4
9
  //# sourceMappingURL=bufferCircuitBreaker.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { AnyAction } from '@dineug/r-html';
2
+ import { Observable } from 'rxjs';
3
+ import { StreamBufferOperator } from './groupByStreamActions';
4
+ /**
5
+ * Builds the outbound compressor around what closes an edit stream's group,
6
+ * left to groupByStreamActions' 200 ms quiet period when omitted. Presence
7
+ * keeps its own 100 ms throttle either way.
8
+ */
9
+ export declare const createSharedStreamActionsCompressor: (streamBufferOperator?: StreamBufferOperator) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
10
+ //# sourceMappingURL=createSharedStreamActionsCompressor.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { Observable } from 'rxjs';
2
+ import { StreamBufferOperator } from './groupByStreamActions';
3
+ /**
4
+ * Closes a stream buffer when the notifier fires instead of after a quiet
5
+ * period. A group arms only once it holds a value, so a tick with nothing
6
+ * pending emits nothing and an extra tick is harmless.
7
+ */
8
+ export declare const flushOnNotifier: (notifier$: Observable<unknown>) => StreamBufferOperator;
9
+ //# sourceMappingURL=flushOnNotifier.d.ts.map
@@ -1,6 +1,8 @@
1
1
  import { AnyAction } from '@dineug/r-html';
2
2
  import { MonoTypeOperatorFunction, Observable } from 'rxjs';
3
3
  type Regroup = [string, Array<string> | ReadonlyArray<string>];
4
- export declare const groupByStreamActions: (streamActionTypes: Array<string> | ReadonlyArray<string>, regroups?: Regroup[], bufferClosingNotifierOperator?: MonoTypeOperatorFunction<Array<AnyAction>>) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
4
+ /** Runs on a stream group's batches; each value it emits closes the buffer. */
5
+ export type StreamBufferOperator = MonoTypeOperatorFunction<Array<AnyAction>>;
6
+ export declare const groupByStreamActions: (streamActionTypes: Array<string> | ReadonlyArray<string>, regroups?: Regroup[], bufferClosingNotifierOperator?: StreamBufferOperator) => (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
5
7
  export {};
6
8
  //# sourceMappingURL=groupByStreamActions.d.ts.map
@@ -1,4 +1,3 @@
1
- import { AnyAction } from '@dineug/r-html';
2
- import { Observable } from 'rxjs';
3
- export declare const sharedStreamActionsCompressor: (source$: Observable<Array<AnyAction>>) => Observable<AnyAction[]>;
1
+ /** The editor's compressor: a 200 ms quiet period closes each stream group. */
2
+ export declare const sharedStreamActionsCompressor: (source$: import('rxjs').Observable<Array<import('@dineug/r-html').AnyAction>>) => import('rxjs').Observable<import('@dineug/r-html').AnyAction[]>;
4
3
  //# sourceMappingURL=sharedStreamActionsCompressor.d.ts.map
@@ -7,12 +7,25 @@ export type RxStore = Store & {
7
7
  undo: () => void;
8
8
  redo: () => void;
9
9
  history: History;
10
+ resetHistory: () => void;
10
11
  change$: Observable<Array<AnyAction>>;
12
+ /**
13
+ * Closes the stream groups the history is still buffering, now. A no-op
14
+ * unless the store was created with manualStreamFlush.
15
+ */
16
+ flushStreamBuffers: () => void;
11
17
  };
12
18
  export type RxStoreOptions = {
13
19
  getReadonly?: () => boolean;
14
20
  getHistory?: (options: HistoryOptions) => History;
21
+ /** Closes stream buffers on flushStreamBuffers() instead of after 200 ms. */
22
+ manualStreamFlush?: boolean;
23
+ /**
24
+ * Keeps the state a plain object when false. Nothing renders from a
25
+ * headless store, and the reactive proxy reads DOM globals Node lacks.
26
+ */
27
+ observable?: boolean;
15
28
  };
16
29
  export declare const HISTORY_LIMIT = 2048;
17
- export declare function createRxStore(context: EngineContext, { getReadonly, getHistory }?: RxStoreOptions): RxStore;
30
+ export declare function createRxStore(context: EngineContext, { getReadonly, getHistory, manualStreamFlush, observable, }?: RxStoreOptions): RxStore;
18
31
  //# sourceMappingURL=rx-store.d.ts.map
@@ -7,10 +7,20 @@ export type SharedStore = {
7
7
  dispatch: (actions: Array<AnyAction> | AnyAction) => void;
8
8
  dispatchSync: (actions: Array<AnyAction> | AnyAction) => void;
9
9
  subscribe: (fn: (value: AnyAction[]) => void) => Unsubscribe;
10
+ /**
11
+ * Sends the stream groups still held back from the peers, now. A no-op
12
+ * unless the store was created with manualStreamFlush.
13
+ */
14
+ flushStreamBuffers: () => void;
10
15
  destroy: () => void;
11
16
  };
12
17
  export type SharedStoreConfig = {
13
18
  getNickname?: () => string;
14
19
  };
15
- export declare function createSharedStore(store: RxStore, config?: SharedStoreConfig): SharedStore;
20
+ /** Not part of getSharedStore's config: only a headless peer sets this. */
21
+ export type SharedStoreInternalOptions = {
22
+ /** Closes stream buffers on flushStreamBuffers() instead of after 200 ms. */
23
+ manualStreamFlush?: boolean;
24
+ };
25
+ export declare function createSharedStore(store: RxStore, config?: SharedStoreConfig, internal?: SharedStoreInternalOptions): SharedStore;
16
26
  //# sourceMappingURL=shared-store.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { RxStore } from './rx-store';
2
+ import { SharedStore } from './shared-store';
3
+ export type StreamFlusher = {
4
+ /** History first, then the outbound pipe, so a batch never precedes its undo entry. */
5
+ flush: () => void;
6
+ };
7
+ /**
8
+ * Closes both stores' stream buffers now. Each store knows how many ticks its
9
+ * own pipe needs, so this knows neither the tick count nor any rxjs type.
10
+ */
11
+ export declare function createStreamFlusher(rxStore: Pick<RxStore, 'flushStreamBuffers'>, sharedStore: Pick<SharedStore, 'flushStreamBuffers'>): StreamFlusher;
12
+ //# sourceMappingURL=stream-flush.d.ts.map
@@ -4,6 +4,8 @@ export declare const Tag: {
4
4
  readonly shared: 1;
5
5
  readonly changeOnly: 2;
6
6
  readonly following: 4;
7
+ /** A step a pointer drag streams, where an undo of the same move is one jump. */
8
+ readonly drag: 8;
7
9
  };
8
10
  export declare function attachActionTag(tag: number, action: AnyAction): AnyAction;
9
11
  export declare function attachActionsTag(tag: number, actions: AnyAction[]): AnyAction[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The text width a peer measures with no canvas, the same estimate the
3
+ * replica worker falls back to. A reload recalculates every width, so an
4
+ * estimate written by a headless edit never outlives the next open.
5
+ */
6
+ export declare const defaultToWidth: (text: string) => number;
7
+ //# sourceMappingURL=to-width.d.ts.map