@dineug/erd-editor 3.4.0 → 3.5.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.
Files changed (140) hide show
  1. package/dist/components/appContext.d.ts +8 -1
  2. package/dist/components/erd/automatic-table-placement/createAutomaticTablePlacement.d.ts +17 -1
  3. package/dist/components/erd/canvas/Canvas.d.ts +5 -0
  4. package/dist/components/erd/canvas/Canvas.styles.d.ts +11 -0
  5. package/dist/components/erd/canvas/CanvasScene.d.ts +18 -0
  6. package/dist/components/erd/canvas/EditOverlay.d.ts +8 -0
  7. package/dist/components/erd/canvas/EditOverlay.styles.d.ts +6 -0
  8. package/dist/components/erd/canvas/SceneIcon.template.d.ts +21 -0
  9. package/dist/components/erd/canvas/drag-select/DragSelect.d.ts +11 -0
  10. package/dist/components/erd/canvas/duplicate-ghost/DuplicateGhost.d.ts +5 -0
  11. package/dist/components/erd/canvas/entityDrag.d.ts +4 -0
  12. package/dist/components/erd/canvas/high-level-table/HighLevelTable.d.ts +4 -0
  13. package/dist/components/erd/canvas/memo/Memo.d.ts +2 -0
  14. package/dist/components/erd/canvas/memo/memo-sash/MemoSash.d.ts +11 -1
  15. package/dist/components/erd/canvas/memo/memoCaret.d.ts +26 -0
  16. package/dist/components/erd/canvas/memo/memoScroll.d.ts +28 -0
  17. package/dist/components/erd/canvas/memo/memoText.d.ts +33 -0
  18. package/dist/components/erd/canvas/memo/useMoveMemo.d.ts +6 -0
  19. package/dist/components/erd/canvas/relationship-group/RelationshipGroup.d.ts +15 -0
  20. package/dist/components/erd/canvas/relationship-group/relationship/Relationship.template.d.ts +17 -0
  21. package/dist/components/erd/canvas/sceneHit.d.ts +18 -0
  22. package/dist/components/erd/canvas/sceneKind.d.ts +11 -0
  23. package/dist/components/erd/canvas/sceneRetention.d.ts +31 -0
  24. package/dist/components/erd/canvas/sceneTokens.d.ts +67 -0
  25. package/dist/components/erd/canvas/shared-drag-select/SharedDragSelect.d.ts +4 -0
  26. package/dist/components/erd/canvas/shared-mouse-tracker/SharedMouseTracker.d.ts +1 -0
  27. package/dist/components/erd/canvas/shared-mouse-tracker/shared-mouse-cursor/SharedMouseCursor.d.ts +5 -0
  28. package/dist/components/erd/canvas/table/Table.d.ts +8 -0
  29. package/dist/components/erd/canvas/table/cellLayout.d.ts +63 -0
  30. package/dist/components/erd/canvas/table/column/Column.d.ts +16 -6
  31. package/dist/components/erd/canvas/table/doubleClick.d.ts +14 -0
  32. package/dist/components/erd/canvas/table/useMoveTable.d.ts +1 -1
  33. package/dist/components/erd/canvas/useMoveEntity.d.ts +18 -0
  34. package/dist/components/erd/erd-context-menu/ErdContextMenu.d.ts +1 -2
  35. package/dist/components/erd/erd-context-menu/menus/drawRelationshipMenus.d.ts +2 -2
  36. package/dist/components/erd/erd-context-menu/menus/exportMenus.d.ts +2 -1
  37. package/dist/components/erd/hide-sign/hideSignBounds.d.ts +9 -0
  38. package/dist/components/erd/hitTest.d.ts +22 -0
  39. package/dist/components/erd/minimap/Minimap.styles.d.ts +0 -1
  40. package/dist/components/erd/minimap/MinimapScene.d.ts +16 -0
  41. package/dist/components/erd/minimap/memo/Memo.d.ts +5 -0
  42. package/dist/components/erd/minimap/minimapGeometry.d.ts +52 -0
  43. package/dist/components/erd/minimap/table/Table.d.ts +5 -0
  44. package/dist/components/erd/virtual-scroll/useVirtualScroll.d.ts +19 -0
  45. package/dist/components/global-styles/GlobalStyles.d.ts +3 -12
  46. package/dist/components/primitives/code-block/CodeBlock.styles.d.ts +1 -1
  47. package/dist/components/primitives/icon/icons.d.ts +50 -25
  48. package/dist/components/primitives/sash/Sash.stories.d.ts +1 -1
  49. package/dist/components/primitives/toast/Toast.d.ts +4 -0
  50. package/dist/components/primitives/toast/Toast.stories.d.ts +13 -0
  51. package/dist/components/primitives/toast/Toast.styles.d.ts +5 -0
  52. package/dist/components/{erd/canvas/table → table-view}/column/column-data-type/ColumnDataType.d.ts +1 -1
  53. package/dist/components/table-view/column/useColumnCell.d.ts +23 -0
  54. package/dist/components/themeContext.d.ts +9 -0
  55. package/dist/components/toast-container/openToastWhileRunning.d.ts +11 -0
  56. package/dist/components/visualization/Visualization.d.ts +6 -0
  57. package/dist/components/visualization/Visualization.styles.d.ts +6 -0
  58. package/dist/components/visualization/VisualizationScene.d.ts +21 -0
  59. package/dist/components/visualization/createVisualization.d.ts +67 -8
  60. package/dist/components/visualization/graph-node/GraphNode.d.ts +23 -0
  61. package/dist/components/visualization/table/Table.d.ts +0 -1
  62. package/dist/components/visualization/table/column/Column.d.ts +0 -1
  63. package/dist/components/visualization/visualizationView.d.ts +90 -0
  64. package/dist/constants/language.d.ts +2 -2
  65. package/dist/constants/layout.d.ts +6 -13
  66. package/dist/constants/schema.d.ts +1 -1
  67. package/dist/engine/modules/editor/actions.d.ts +12 -0
  68. package/dist/engine/modules/editor/atom.actions.d.ts +53 -0
  69. package/dist/engine/modules/editor/state.d.ts +20 -0
  70. package/dist/engine/modules/settings/atom.actions.d.ts +24 -0
  71. package/dist/engine.js +10 -10
  72. package/dist/erd-editor.js +23476 -13675
  73. package/dist/konva/batchDraw.d.ts +41 -0
  74. package/dist/konva/host.d.ts +29 -0
  75. package/dist/konva/scene/columnDropTarget.d.ts +13 -0
  76. package/dist/konva/scene/konvaFlip.d.ts +18 -0
  77. package/dist/konva/scene/metrics.d.ts +29 -0
  78. package/dist/konva/scene/renderScene.d.ts +34 -0
  79. package/dist/konva/scene/viewport.d.ts +38 -0
  80. package/dist/konva/testHandle.d.ts +22 -0
  81. package/dist/konva/theme.d.ts +31 -0
  82. package/dist/konva/workerDomStubs.d.ts +1 -0
  83. package/dist/{schemaGCService-DAGNq0wk.js → schemaGCService-DrlqIen8.js} +5246 -4789
  84. package/dist/services/export-png/ExportScene.d.ts +9 -0
  85. package/dist/services/export-png/documentScene.d.ts +20 -0
  86. package/dist/services/export-png/exportPng.shared-worker.d.ts +0 -0
  87. package/dist/services/export-png/exportPngService.d.ts +24 -0
  88. package/dist/services/export-png/index.d.ts +48 -0
  89. package/dist/services/export-png/pixelRatio.d.ts +21 -0
  90. package/dist/services/export-png/renderPng.d.ts +37 -0
  91. package/dist/services/export-png/textWidth.d.ts +27 -0
  92. package/dist/services/schema-gc/index.d.ts +5 -0
  93. package/dist/styles/colorPicker.style.d.ts +3 -7
  94. package/dist/styles/fonts.styles.d.ts +1 -1
  95. package/dist/styles/reset.styles.d.ts +1 -1
  96. package/dist/styles/scrollbar.styles.d.ts +3 -3
  97. package/dist/styles/typography.styles.d.ts +1 -1
  98. package/dist/themes/tokens.d.ts +4 -0
  99. package/dist/utils/calcTable.d.ts +1 -1
  100. package/dist/utils/draw-relationship/incremental.d.ts +70 -0
  101. package/dist/utils/draw-relationship/index.d.ts +47 -42
  102. package/dist/utils/draw-relationship/nudge.d.ts +2 -1
  103. package/dist/utils/draw-relationship/pathFinding.d.ts +3 -5
  104. package/dist/utils/draw-relationship/route.d.ts +4 -9
  105. package/dist/utils/draw-relationship/stub.d.ts +5 -16
  106. package/dist/utils/emitter.d.ts +16 -0
  107. package/dist/utils/file/exportFile.d.ts +10 -1
  108. package/dist/utils/focus.d.ts +1 -1
  109. package/dist/utils/globalEventObservable.d.ts +13 -12
  110. package/dist/utils/icon.d.ts +9 -1
  111. package/dist/utils/keyboard-shortcut/index.d.ts +6 -0
  112. package/dist/utils/schema-aml-parser/dataType.d.ts +5 -6
  113. package/dist/utils/schema-aml-parser/tokenizer.d.ts +3 -5
  114. package/dist/utils/schema-aml-parser/types.d.ts +13 -14
  115. package/dist/utils/schema-dbml-parser/dataType.d.ts +2 -2
  116. package/dist/utils/schema-dbml-parser/types.d.ts +5 -5
  117. package/dist/utils/schema-graphql-parser/dataType.d.ts +2 -2
  118. package/dist/utils/schema-graphql-parser/types.d.ts +7 -7
  119. package/package.json +6 -5
  120. package/dist/components/erd/canvas/canvas-svg/CanvasSvg.d.ts +0 -7
  121. package/dist/components/erd/canvas/canvas-svg/relationship/Relationship.template.d.ts +0 -3
  122. package/dist/components/erd/canvas/draw-relationship/DrawRelationship.styles.d.ts +0 -1
  123. package/dist/components/erd/canvas/duplicate-ghost/DuplicateGhost.styles.d.ts +0 -2
  124. package/dist/components/erd/canvas/high-level-table/HighLevelTable.styles.d.ts +0 -1
  125. package/dist/components/erd/canvas/memo/Memo.styles.d.ts +0 -6
  126. package/dist/components/erd/canvas/shared-mouse-tracker/shared-mouse-cursor/SharedMouseCursor.styles.d.ts +0 -1
  127. package/dist/components/erd/canvas/table/column/Column.styles.d.ts +0 -2
  128. package/dist/components/erd/drag-select/DragSelect.d.ts +0 -9
  129. package/dist/components/erd/drag-select/DragSelect.styles.d.ts +0 -1
  130. /package/dist/components/erd/canvas/{canvas-svg → relationship-group}/relationship/Relationship.d.ts +0 -0
  131. /package/dist/components/{erd/canvas/table → table-view}/Table.styles.d.ts +0 -0
  132. /package/dist/components/{erd/canvas/canvas-svg/CanvasSvg.styles.d.ts → table-view/column/Column.styles.d.ts} +0 -0
  133. /package/dist/components/{erd/canvas/table → table-view}/column/column-data-type/ColumnDataType.styles.d.ts +0 -0
  134. /package/dist/components/{erd/canvas/table → table-view}/column/column-key/ColumnKey.d.ts +0 -0
  135. /package/dist/components/{erd/canvas/table → table-view}/column/column-key/ColumnKey.styles.d.ts +0 -0
  136. /package/dist/components/{erd/canvas/table → table-view}/column/column-not-null/ColumnNotNull.d.ts +0 -0
  137. /package/dist/components/{erd/canvas/table → table-view}/column/column-not-null/ColumnNotNull.styles.d.ts +0 -0
  138. /package/dist/components/{erd/canvas/table → table-view}/column/column-option/ColumnOption.d.ts +0 -0
  139. /package/dist/components/{erd/canvas/table → table-view}/column/column-option/ColumnOption.styles.d.ts +0 -0
  140. /package/dist/{services/schema-gc/schemaGC.worker.d.ts → konva/jsx-types.test-d.d.ts} +0 -0
@@ -0,0 +1,9 @@
1
+ import { FC } from '@dineug/r-html';
2
+ export type ExportSceneProps = {};
3
+ /**
4
+ * The whole canvas box on one layer, with no culling and no zoom. An exported
5
+ * image is not a picture of the screen, so nothing here reads the scroll, the
6
+ * zoom or the viewport the editor's own scene is placed with.
7
+ */
8
+ declare const ExportScene: FC<ExportSceneProps>;
9
+ export default ExportScene;
@@ -0,0 +1,20 @@
1
+ import { Stage } from 'konva/lib/Stage';
2
+ import { Theme } from '../../themes/tokens';
3
+ export type DocumentSceneOptions = {
4
+ doc: string;
5
+ theme: Theme;
6
+ toWidth: (text: string) => number;
7
+ };
8
+ export type DocumentScene = {
9
+ stage: Stage;
10
+ destroy: () => void;
11
+ };
12
+ /**
13
+ * The whole document on a Stage of its own, off any screen. The store is built
14
+ * here rather than borrowed so the editor's scroll, zoom and selection cannot
15
+ * reach the image, which is the whole difference between this and a screenshot.
16
+ *
17
+ * @example
18
+ * const scene = await renderDocumentScene({ doc, theme, toWidth });
19
+ */
20
+ export declare function renderDocumentScene({ doc, theme, toWidth, }: DocumentSceneOptions): Promise<DocumentScene>;
@@ -0,0 +1,24 @@
1
+ import { RenderPngRequest, RenderPngResult } from './renderPng';
2
+ /**
3
+ * A png request as it crosses a realm boundary. The measurement itself cannot
4
+ * cross, so what travels is the widths the asking realm read for the probe
5
+ * strings and the answering realm has to reproduce them.
6
+ */
7
+ export type ExportPngRequest = RenderPngRequest & {
8
+ fontProbe: number[];
9
+ };
10
+ /**
11
+ * Draws a document off the thread that asked for it. Text is measured here
12
+ * rather than sent, because a table's reserved widths were laid out by a
13
+ * measurement, and a picture drawn by a different one does not fit them.
14
+ */
15
+ export declare class ExportPngService {
16
+ /**
17
+ * What this realm lays the probe strings out to. Answering it at all proves
18
+ * the module graph evaluated here, which is the failure a shared worker
19
+ * reports to nobody: its port stays open and every call after it hangs.
20
+ */
21
+ probeFontWidths(): Promise<number[]>;
22
+ render(request: ExportPngRequest): Promise<RenderPngResult>;
23
+ private createToWidth;
24
+ }
@@ -0,0 +1,48 @@
1
+ import { Theme } from '../../themes/tokens';
2
+ import { ResolutionReduction } from './renderPng';
3
+ import { ToWidth } from './textWidth';
4
+ export type { ResolutionReduction };
5
+ /** Which thread drew the image, which is the one thing a Promise cannot say. */
6
+ export type ExportPngRealm = 'worker' | 'main';
7
+ /**
8
+ * Where an export has got to. Started fires before any drawing begins, and
9
+ * again naming the main thread if the worker it first named gave way; finished
10
+ * fires once, and only after a blob exists.
11
+ */
12
+ export type ExportPngProgress = {
13
+ phase: 'started';
14
+ realm: ExportPngRealm;
15
+ } | {
16
+ phase: 'finished';
17
+ realm: ExportPngRealm;
18
+ width: number;
19
+ height: number;
20
+ };
21
+ export type DocumentPngOptions = {
22
+ doc: string;
23
+ theme: Theme;
24
+ /**
25
+ * How the editor measures a string. A realm that draws the document has to
26
+ * reproduce this to the pixel, so it is passed to be compared against rather
27
+ * than to be called across a boundary a function does not cross.
28
+ */
29
+ toWidth: ToWidth;
30
+ pixelRatio?: number;
31
+ /**
32
+ * Called once, after a file exists, when the box outran what a canvas holds
33
+ * and the image had to be scaled down. A caller with somewhere to put it is
34
+ * what turns a silent loss of resolution into something the author is told.
35
+ */
36
+ onResolutionReduced?: (reduction: ResolutionReduction) => void;
37
+ /** Called as the export moves, for a caller that shows it is running. */
38
+ onProgress?: (progress: ExportPngProgress) => void;
39
+ };
40
+ /**
41
+ * A png of the whole canvas box, whatever the editor is scrolled or zoomed to.
42
+ * The scene is drawn again from the document rather than read off the screen,
43
+ * which is what makes the image the same however the editor is being viewed.
44
+ *
45
+ * @example
46
+ * const blob = await createDocumentPng({ doc: toJson(store.state), theme, toWidth });
47
+ */
48
+ export declare function createDocumentPng({ doc, theme, toWidth, pixelRatio, onResolutionReduced, onProgress, }: DocumentPngOptions): Promise<Blob>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The largest raster a browser canvas will hold, as area rather than as one
3
+ * side. Chromium and WebKit both stop at exactly this many pixels however the
4
+ * box is shaped, and Firefox stops well above it, so this is the shared floor.
5
+ */
6
+ export declare const CANVAS_AREA_MAX: number;
7
+ /**
8
+ * The longest single side, kept at half of the 65535 every engine measured here
9
+ * accepted. The margin is spent on the side rather than the area because no box
10
+ * the schema allows reaches it at one image pixel per canvas unit.
11
+ */
12
+ export declare const CANVAS_SIDE_MAX = 32767;
13
+ /**
14
+ * The ratio that keeps a raster of that box inside what a canvas can hold. A
15
+ * tall box is bounded by its area, so a document narrow enough to fit under the
16
+ * ceiling keeps every pixel it was written with instead of being scaled down.
17
+ *
18
+ * @example
19
+ * fitPixelRatio(1, 20000, 20000);
20
+ */
21
+ export declare function fitPixelRatio(pixelRatio: number, width: number, height: number): number;
@@ -0,0 +1,37 @@
1
+ import { Theme } from '../../themes/tokens';
2
+ import { ToWidth } from './textWidth';
3
+ /** The box that was asked for and the raster that fitted inside a canvas. */
4
+ export type ResolutionReduction = {
5
+ documentWidth: number;
6
+ documentHeight: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ /** Everything a png needs that survives a structured clone to another realm. */
11
+ export type RenderPngRequest = {
12
+ doc: string;
13
+ theme: Theme;
14
+ pixelRatio: number;
15
+ };
16
+ export type RenderPngResult = {
17
+ blob: Blob;
18
+ width: number;
19
+ height: number;
20
+ /**
21
+ * Null when the box kept every pixel it was written with. A realm that drew
22
+ * the image is the only one that knows this, so it is carried back rather
23
+ * than recomputed by whoever asked for the file.
24
+ */
25
+ reduction: ResolutionReduction | null;
26
+ };
27
+ /**
28
+ * The whole document rastered, in whichever realm calls it. Nothing here reads
29
+ * a window, a screen or a stylesheet, so the same code answers on the main
30
+ * thread and inside the worker that keeps the main thread free.
31
+ *
32
+ * @example
33
+ * const { blob } = await renderDocumentPng({ doc, theme, pixelRatio: 1, toWidth });
34
+ */
35
+ export declare function renderDocumentPng({ doc, theme, pixelRatio, toWidth, }: RenderPngRequest & {
36
+ toWidth: ToWidth;
37
+ }): Promise<RenderPngResult>;
@@ -0,0 +1,27 @@
1
+ /** How the editor measures a string, which is what a table reserves room by. */
2
+ export type ToWidth = (text: string) => number;
3
+ /** The shorthand utils/text.ts sets on the context it measures with. */
4
+ export declare const SCENE_FONT: string;
5
+ /**
6
+ * Strings a divergence in font resolution shows up in. Latin covers the head of
7
+ * the family list, the ideographs cover whatever the host falls through to for
8
+ * them, and the punctuation covers a face that carries only part of the range.
9
+ */
10
+ export declare const FONT_PROBE_TEXTS: readonly ["ERD editor 0123456789", "가나다 漢字 テスト", "—…€· iIlL1"];
11
+ /**
12
+ * The same measurement utils/text.ts makes, on a canvas no document holds. A
13
+ * realm off the screen has no element to fall back to, so a realm with no 2d
14
+ * context has no way to lay a document out and says so rather than guessing.
15
+ */
16
+ export declare function createOffscreenToWidth(): ToWidth | null;
17
+ /**
18
+ * What the probe strings measure under one realm's font resolution. Comparing
19
+ * two of these is the only gate that fires: a worker's fonts.load resolves for
20
+ * a family it does not have, and fonts.check answers true for one nobody has.
21
+ *
22
+ * @example
23
+ * measureFontProbe(toWidth);
24
+ */
25
+ export declare function measureFontProbe(toWidth: ToWidth): number[];
26
+ /** Whether two realms lay the probe strings out to the same pixel. */
27
+ export declare function sameFontProbe(a: number[], b: number[]): boolean;
@@ -7,4 +7,9 @@ export type GCIds = {
7
7
  indexColumnIds: string[];
8
8
  memoIds: string[];
9
9
  };
10
+ /**
11
+ * Runs the collector off the main thread where a host builds a shared worker.
12
+ * There is no dedicated Worker rung between the two, because an inline worker
13
+ * import is a second copy of this whole service in the bundle.
14
+ */
10
15
  export declare function getSchemaGCService(): SchemaGCService | null;
@@ -1,10 +1,6 @@
1
1
  /**
2
- * Vendored from https://github.com/easylogic/colorpicker.
3
- *
4
- * Global, not scoped. The picker's markup is built by the upstream library at runtime, outside
5
- * anything r-html renders, so there is no element here to hang a generated component class on —
6
- * every selector below matches by the literal class names that library writes
7
- * (`.easylogic-colorpicker`, `.colorsets-contextmenu`), and scoping them would rename them out
8
- * from under it. Last in `setGlobalStyleOrder`, which is where it sat when it was a tree `<style>`.
2
+ * Vendored from https://github.com/easylogic/colorpicker. Global, not scoped:
3
+ * the upstream library builds its own markup at runtime, so every selector below
4
+ * matches literal class names that scoping would rename out from under it.
9
5
  */
10
6
  export declare const colorPickerStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1,4 +1,4 @@
1
1
  export declare const TextFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Open Sans', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'";
2
2
  export declare const CodeFontFamily: "'Menlo', 'Consolas', 'Bitstream Vera Sans Mono', monospace, 'Apple Color Emoji', 'Segoe UI Emoji'";
3
- /** Global, not scoped: `:host` is the shadow host, which no component class matches. */
3
+ /** Global, not scoped: :host is the shadow host, which no component class matches. */
4
4
  export declare const fontsStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Global, not scoped: every selector here is a type selector, the universal selector or `:host`,
2
+ * Global, not scoped: every selector here is a type selector, the universal selector or :host,
3
3
  * none of which survives having a component class prepended to it.
4
4
  */
5
5
  export declare const resetStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Global, not scoped. The `::-webkit-scrollbar*` pseudo elements have no element of their own to
3
- * hang a component class on, and `.scrollbar` is a hook class seven components opt into by
4
- * literal name (`class=${['scrollbar', ...]}`) — scoping it would rename it out from under them.
2
+ * Global, not scoped. The ::-webkit-scrollbar* pseudo elements have no element of their own to
3
+ * hang a component class on, and .scrollbar is a hook class seven components opt into by
4
+ * literal name (class=${['scrollbar', ...]}) — scoping it would rename it out from under them.
5
5
  */
6
6
  export declare const scrollbarStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -11,5 +11,5 @@ export declare const typography: {
11
11
  readonly normal: import('@dineug/r-html').CSSTemplateLiterals;
12
12
  readonly paragraph: import('@dineug/r-html').CSSTemplateLiterals;
13
13
  };
14
- /** Global, not scoped: `:host` is the shadow host, which no component class matches. */
14
+ /** Global, not scoped: :host is the shadow host, which no component class matches. */
15
15
  export declare const typographyStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -66,4 +66,8 @@ export type Theme = {
66
66
  diffCrossForeground: string;
67
67
  };
68
68
  export declare const ThemeTokens: ReadonlyArray<keyof Theme>;
69
+ /** The custom property one token is published under on :host. */
70
+ export declare const toThemeVariableName: (token: string) => string;
71
+ /** The custom property a host document overrides that token through. */
72
+ export declare const toThemeOverrideVariableName: (token: string) => string;
69
73
  export declare const themeToTokensString: (theme: Theme) => string;
@@ -3,7 +3,7 @@ import { RootState } from '../engine/state';
3
3
  import { Table } from '../internal-types';
4
4
  export declare function getWidthGeneration(): number;
5
5
  /**
6
- * Invalidates every cached table size. Called from `recalculateTableWidth`,
6
+ * Invalidates every cached table size. Called from recalculateTableWidth,
7
7
  * which rewrites widths without dispatching an action, and from the
8
8
  * relationship-sort hook for any action that is not a pure move.
9
9
  */
@@ -0,0 +1,70 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { Point } from '../../internal-types';
3
+ import { Obstacles } from './route';
4
+ export type DirtyBox = {
5
+ left: number;
6
+ top: number;
7
+ right: number;
8
+ bottom: number;
9
+ };
10
+ /**
11
+ * A route and the inputs it was computed from, so the next sort can tell whether
12
+ * anything it reads has moved. Anchors are recomputed in full every sort, so the
13
+ * turning points below are what a changed anchor shows up as.
14
+ */
15
+ export type RouteEntry = {
16
+ mx: number;
17
+ my: number;
18
+ mDirection: number;
19
+ lx: number;
20
+ ly: number;
21
+ lDirection: number;
22
+ startTableId: string;
23
+ endTableId: string;
24
+ /** The router's own output, before nudgeRoutes pushed anything apart. */
25
+ pristine: Point[];
26
+ /** What was finally drawn, which is what a reused group is put back onto. */
27
+ nudged: Point[];
28
+ bounds: DirtyBox;
29
+ };
30
+ export type SortCache = {
31
+ boxes: Map<string, DirtyBox>;
32
+ entries: Map<string, RouteEntry>;
33
+ };
34
+ export declare function getSortCache(state: RootState): SortCache;
35
+ export declare function boundsOfPoints(points: Point[]): DirtyBox;
36
+ /**
37
+ * Whether a moved table can change a route. The bounding box rather than the
38
+ * runs inside it: the router picks its lanes from every table reaching into the
39
+ * band between the two anchors, not only from the ones the route passes.
40
+ */
41
+ export declare function routeTouches(bounds: DirtyBox, boxes: DirtyBox[]): boolean;
42
+ /**
43
+ * Where this sort changed something, as lanes rather than as areas. Everything
44
+ * nudgeRoutes decides is decided one axis at a time, so a change is only ever
45
+ * felt by segments sharing that axis within a few lanes of it.
46
+ */
47
+ export type DirtyLanes = {
48
+ markSpan(vertical: boolean, from: number, to: number, low: number, high: number): void;
49
+ markBox(box: DirtyBox): void;
50
+ hits(vertical: boolean, from: number, to: number, low: number, high: number): boolean;
51
+ };
52
+ export declare function createDirtyLanes(): DirtyLanes;
53
+ /** Marks every axis-aligned run of a polyline as changed. */
54
+ export declare function markRoute(lanes: DirtyLanes, points: Point[]): void;
55
+ /**
56
+ * What nudgeRoutes needs to leave an untouched group where it already was: the
57
+ * routes this sort re-routed, the lanes they and the moved tables changed, and
58
+ * the coordinate every segment was last drawn at.
59
+ */
60
+ export type NudgeMemo = {
61
+ dirty: Set<string>;
62
+ lanes: DirtyLanes;
63
+ coordinate(relationshipId: string, index: number, vertical: boolean): number | undefined;
64
+ };
65
+ /**
66
+ * Which table boxes moved since the last sort, or null when so much changed that
67
+ * filtering costs more than re-routing. The cache's own snapshot is replaced
68
+ * here, so this runs once per sort.
69
+ */
70
+ export declare function diffTableBoxes(cache: SortCache, obstacles: Obstacles): DirtyBox[] | null;
@@ -94,18 +94,9 @@ export declare const isDirection: (value: string) => boolean;
94
94
  export declare const PATH_HEIGHT = 30;
95
95
  export declare const PATH_END_HEIGHT: number;
96
96
  /**
97
- * The cardinality decoration, measured outward from the anchor.
98
- *
99
- * The four are one shape and cannot be set independently: the second tick and
100
- * the ring share a centre at `LINE_SIZE + LINE_HEIGHT`, the guide line starts
101
- * where the longest stroke ends at `LINE_HEIGHT * 2 + 3`, and the ring has to
102
- * clear the first tick behind it and the guide line in front of it, which puts
103
- * its radius between those two.
104
- *
105
- * Scaled to 0.7 of what they were, so a decoration reaches 25px out rather than
106
- * 35px. `RELATIONSHIP_STROKE_WIDTH` thinned the connector; leaving the notation
107
- * at its old size would have made the crow's foot the heaviest thing on the
108
- * canvas.
97
+ * The cardinality decoration, measured outward from the anchor. The four are one
98
+ * shape and cannot be set independently: the ring shares a centre with the
99
+ * second tick and has to clear both the first tick and the guide line.
109
100
  */
110
101
  export declare const LINE_SIZE = 7;
111
102
  export declare const LINE_HEIGHT = 11;
@@ -114,50 +105,34 @@ export declare const CIRCLE_RADIUS = 6;
114
105
  export declare const PATH_LINE_HEIGHT: number;
115
106
  /**
116
107
  * How far apart the corridors of two relationships leaving the same table side
117
- * are placed. Without this every path on a side turns at the same `x` (or `y`),
118
- * so their first segments run down one another no matter how far apart the
119
- * anchors are spread.
108
+ * sit. Without it every path on a side turns at the same coordinate and their
109
+ * first segments run down one another however far the anchors are spread.
120
110
  */
121
111
  export declare const STUB_STEP = 12;
122
112
  /**
123
- * Corridors repeat every fourth slot. Growing the stub without limit would walk
124
- * a busy side's paths ever further from the table; wrapping keeps the longest
125
- * stub at `PATH_END_HEIGHT + 3 * STUB_STEP` while leaving four slots — at least
126
- * four anchor pitches apart — between any two that share a corridor.
113
+ * Corridors repeat every fourth slot. An unbounded stub walks a busy side's
114
+ * paths ever further from the table; wrapping caps the longest one and still
115
+ * leaves four slots between any two that share a corridor.
127
116
  */
128
117
  export declare const STUB_CYCLE = 4;
129
118
  /**
130
- * The shortest a stub may be clamped to.
131
- *
132
- * It has to clear `PATH_LINE_HEIGHT`: the cardinality decorations reach that far
133
- * out from the anchor and the guide line is drawn from there to the stub, so a
134
- * shorter stub draws that line backwards. It is not derived from it. 36 is where
135
- * the routing was measured, and letting it follow the decorations down to 26
136
- * when they shrank took the medium corpus from 168px of collinear overlap to
137
- * 484px — two tables facing each other closer than `2 * MIN_STUB` turn in
138
- * earlier, and the routing bench found them sharing a corridor for 316px.
119
+ * The shortest a stub may be clamped to. It has to clear PATH_LINE_HEIGHT or the
120
+ * guide line is drawn backwards, but it is not derived from it: this is where
121
+ * the routing was measured, and following the decorations down cost overlap.
139
122
  */
140
123
  export declare const MIN_STUB = 36;
141
124
  /**
142
- * The widest gap allowed between two anchors on the same table side.
143
- *
144
- * Anchors used to be spread over the whole edge, so two relationships on a tall
145
- * table splayed hundreds of pixels apart and converged again. Capping the pitch
146
- * keeps a side's anchors together as a group; the side is only filled when it
147
- * genuinely has that many relationships.
125
+ * The widest gap allowed between two anchors on the same table side. Capping the
126
+ * pitch keeps a side's anchors together as a group, so a tall table's edge is
127
+ * only filled when it genuinely has that many relationships.
148
128
  */
149
129
  export declare const ANCHOR_MAX_PITCH = 120;
150
130
  /** Keeps the outermost anchor of a side clear of the table's corners. */
151
131
  export declare const ANCHOR_EDGE_INSET = 12;
152
132
  /**
153
- * How far back from a corner a connector turns, when the corner is drawn as a
154
- * 45-degree cut rather than a right angle.
155
- *
156
- * Each cut is clamped to half of the shorter run it touches, so this is a ceiling
157
- * rather than a length: a short run keeps its right angle instead of losing the
158
- * whole of itself to two cuts. Two connectors turning the same way in
159
- * neighbouring lanes stay `NUDGE_GAP` apart through the corner, so a bundle bends
160
- * as a set of concentric cuts rather than converging on one.
133
+ * How far back from a corner a connector turns when the corner is cut to 45
134
+ * degrees. A ceiling rather than a length: each cut is clamped to half the
135
+ * shorter run it touches, so a short run keeps its right angle.
161
136
  */
162
137
  export declare const ROUTE_CHAMFER = 8;
163
138
  export declare function setStubSlots(relationship: Relationship, slots: readonly [number, number]): void;
@@ -165,3 +140,33 @@ export declare function setStubSlots(relationship: Relationship, slots: readonly
165
140
  export declare function getStubSlots(relationship: Relationship): readonly [number, number];
166
141
  export declare function setRoute(relationship: Relationship, points: Point[]): void;
167
142
  export declare function getRoute(relationship: Relationship): Point[] | undefined;
143
+ /**
144
+ * How far a connector reaches past its anchor, whichever decoration is furthest
145
+ * out. The ring shares a centre with the second tick, so its outer edge and the
146
+ * start of the guide line are the two candidates.
147
+ */
148
+ export declare const ROUTE_BBOX_REACH: number;
149
+ /**
150
+ * The longest stub a slot can ask for. It bounds where the turning points of an
151
+ * unrouted relationship can be, which is the only thing the route itself would
152
+ * have told us.
153
+ */
154
+ export declare const MAX_STUB: number;
155
+ export type BBox = {
156
+ x: number;
157
+ y: number;
158
+ width: number;
159
+ height: number;
160
+ };
161
+ /**
162
+ * Opens a sort, retiring every route box the previous one wrote. Identity
163
+ * outlives a sort, so the stamp a route carries is what separates a box for the
164
+ * current routes from one the next sort has already replaced.
165
+ */
166
+ export declare function nextSortEpoch(): void;
167
+ /**
168
+ * Everywhere a relationship can be drawn, for a culling test that must not lose
169
+ * a connector whose anchors are on screen and whose route is not. Without a
170
+ * route from this sort the stub ends are unknown, so the padding carries them.
171
+ */
172
+ export declare function getRouteBBox(relationship: Relationship, strokeWidth?: number): BBox;
@@ -1,3 +1,4 @@
1
1
  import { Point } from '../../internal-types';
2
+ import { NudgeMemo } from './incremental';
2
3
  import { Obstacles } from './route';
3
- export declare function nudgeRoutes(routes: Map<string, Point[]>, obstacles: Obstacles, endpoints: Map<string, [string, string]>): void;
4
+ export declare function nudgeRoutes(routes: Map<string, Point[]>, obstacles: Obstacles, endpoints: Map<string, [string, string]>, memo?: NudgeMemo): void;
@@ -2,10 +2,8 @@ import { Point, Relationship } from '../../internal-types';
2
2
  import { RelationshipPath } from '.';
3
3
  export declare function getRelationshipPath(relationship: Relationship): RelationshipPath;
4
4
  /**
5
- * The routing polyline as one `d`, so a connector is a single element whatever
6
- * the router and the corner cuts made of it.
7
- *
8
- * The segments are contiguous by construction — they come from a polyline — so
9
- * each one contributes its far end and nothing else.
5
+ * The routing polyline as one d, so a connector is a single element whatever the
6
+ * router and the corner cuts made of it. The segments are contiguous by
7
+ * construction, so each contributes its far end and nothing else.
10
8
  */
11
9
  export declare function toPathD(segments: Array<[Point, Point]>): string;
@@ -15,18 +15,13 @@ export declare function collectObstacles(state: RootState): Obstacles;
15
15
  /** Liang–Barsky, with no divisions until a slab actually clips. */
16
16
  export declare function segmentHitsBox(ax: number, ay: number, bx: number, by: number, left: number, top: number, right: number, bottom: number): boolean;
17
17
  /**
18
- * How many tables a polyline passes through, ignoring the two it connects.
19
- *
20
- * This is the hot function of the whole router: every candidate is scored with
21
- * it, and the nudge pass calls it twice per lane it tries. The polyline's own
22
- * bounding box is computed once and used to skip tables outright — a connector
23
- * spans a small part of the canvas, so most tables fail it. Every segment's box
24
- * sits inside the polyline's, so a table the polyline's box misses is a table
25
- * every segment's cheap reject would have missed too; the count is unchanged.
18
+ * How many tables a polyline passes through, ignoring the two it connects. The
19
+ * hot function of the router, so the polyline's own box is computed once to skip
20
+ * tables outright; every segment's box sits inside it, so the count is the same.
26
21
  */
27
22
  export declare function countBlocked(points: Point[], obstacles: Obstacles, skipA: string, skipB: string): number;
28
23
  /**
29
- * The cheapest orthogonal polyline from `m` to `l`, or a two-bend fallback when
24
+ * The cheapest orthogonal polyline from m to l, or a two-bend fallback when
30
25
  * nothing is feasible — a connector always has to be drawn.
31
26
  */
32
27
  export declare function routeOrthogonal(m: Point, mDirection: number, l: Point, lDirection: number, obstacles: Obstacles, skipA: string, skipB: string): Point[];
@@ -1,28 +1,17 @@
1
1
  import { Point, Relationship } from '../../internal-types';
2
2
  /**
3
- * Where a connector turns away from its anchor.
4
- *
5
- * Shared because two callers need the same answer: `pathFinding` draws from it,
6
- * and `relationshipSort` routes from it. Deriving it twice would let the routed
7
- * polyline and the guide line drift apart by a slot's worth of stub.
8
- */
9
- /**
10
- * Slot zero keeps the historical `PATH_END_HEIGHT`, so a relationship that never
11
- * went through `relationshipSort` draws exactly as it did before.
3
+ * Slot zero keeps the historical PATH_END_HEIGHT, so a relationship that never
4
+ * went through relationshipSort draws exactly as it did before.
12
5
  */
13
6
  export declare function stubFor(slot: number): number;
14
7
  /**
15
8
  * The axis-aligned distance between two anchors that point at each other, or
16
- * `null` when they do not.
17
- *
18
- * Only this arrangement can collapse: with a stub on each side, a gap of twice
19
- * the stub puts both turning points on the same spot and the connector vanishes,
20
- * and a smaller gap inverts it so the path runs backwards through both tables.
21
- * Nothing stops two tables being that close — the editor allows them to overlap.
9
+ * null when they do not. Only this arrangement can collapse: a gap of twice the
10
+ * stub puts both turning points on one spot, and a smaller gap inverts the path.
22
11
  */
23
12
  export declare function facingGap(start: Relationship['start'], end: Relationship['end']): number | null;
24
13
  /**
25
- * Below roughly `2 * MIN_STUB` the two cardinality decorations already overlap
14
+ * Below roughly 2 * MIN_STUB the two cardinality decorations already overlap
26
15
  * each other, which no stub length can fix; the clamp stops short of making it
27
16
  * worse by drawing the guide line backwards.
28
17
  */
@@ -18,6 +18,7 @@ declare const InternalActionType: {
18
18
  readonly mouseTrackerEnd: "mouseTrackerEnd";
19
19
  readonly openDiffViewer: "openDiffViewer";
20
20
  readonly duplicateDragStart: "duplicateDragStart";
21
+ readonly dragSelectStart: "dragSelectStart";
21
22
  };
22
23
  type InternalActionType = ValuesType<typeof InternalActionType>;
23
24
  type InternalActionMap = {
@@ -55,6 +56,10 @@ type InternalActionMap = {
55
56
  tableIds: string[];
56
57
  memoIds: string[];
57
58
  } | void;
59
+ [InternalActionType.dragSelectStart]: {
60
+ x: number;
61
+ y: number;
62
+ };
58
63
  };
59
64
  type ListenerRecord = {
60
65
  [P in keyof InternalActionMap]: (action: Action<P, InternalActionMap>) => void;
@@ -181,4 +186,15 @@ export declare const duplicateDragStartAction: {
181
186
  toString(): string;
182
187
  type: string;
183
188
  };
189
+ export declare const dragSelectStartAction: {
190
+ (payload: {
191
+ x: number;
192
+ y: number;
193
+ }): AnyAction<{
194
+ x: number;
195
+ y: number;
196
+ }>;
197
+ toString(): string;
198
+ type: string;
199
+ };
184
200
  export {};
@@ -1,3 +1,4 @@
1
+ import { DocumentPngOptions } from '../../services/export-png';
1
2
  type ExportOptions = {
2
3
  fileName: string;
3
4
  };
@@ -5,5 +6,13 @@ type ExportFileCallback = (blob: Blob, options: ExportOptions) => void;
5
6
  export declare function setExportFileCallback(callback: ExportFileCallback | null): void;
6
7
  export declare function exportJSON(json: string, name?: string): void;
7
8
  export declare function exportSchemaSQL(sql: string, name?: string): void;
8
- export declare function exportPNG(root: HTMLElement, name?: string): void;
9
+ /**
10
+ * Writes the whole document out as an image. What is on screen is not an input:
11
+ * the scene is rendered again off screen from the document alone, so the file a
12
+ * reader opens does not depend on where the author had scrolled or zoomed to.
13
+ *
14
+ * @example
15
+ * exportPNG({ doc: toJson(store.state), theme, toWidth }, databaseName);
16
+ */
17
+ export declare function exportPNG(options: DocumentPngOptions, name?: string): Promise<void>;
9
18
  export {};
@@ -2,6 +2,6 @@ import { FocusTable, FocusType, SharedFocus } from '../engine/modules/editor/sta
2
2
  export declare function isFocus(focusTable: Pick<FocusTable, 'tableId' | 'columnId' | 'focusType'> | null, focusType: FocusType, tableId: string, columnId?: string | null): boolean;
3
3
  export declare const isSelectColumn: (focusTable: FocusTable | null, tableId: string, columnId: string) => boolean;
4
4
  export declare function isEdit(focusTable: FocusTable | null, focusType: FocusType, tableId: string, columnId?: string | null): boolean;
5
- export declare function lastCursorFocus(input: HTMLInputElement): void;
5
+ export declare function lastCursorFocus(input: HTMLInputElement | HTMLTextAreaElement): void;
6
6
  export declare const toSharedFocus: (focusTable: FocusTable | null) => SharedFocus | null;
7
7
  export declare const toSharedFocusKey: (focus: SharedFocus | null) => string;