@draftably/editor 0.1.0 → 0.3.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 (104) hide show
  1. package/README.md +4 -5
  2. package/dist/assets/engine.worker-BY9GKt7x.js +7505 -0
  3. package/dist/element.js +1 -1
  4. package/dist/index.js +20202 -2
  5. package/dist/types/src/cli/raster-fonts.d.ts +3 -0
  6. package/dist/types/src/components/controls.d.ts +8 -5
  7. package/dist/types/src/dsl/compile.d.ts +13 -0
  8. package/dist/types/src/dsl/corridors.d.ts +38 -0
  9. package/dist/types/src/model/types.d.ts +9 -0
  10. package/dist/types/src/state/canvas-commands.d.ts +169 -0
  11. package/dist/types/src/state/canvas-keyboard.d.ts +15 -0
  12. package/dist/types/src/state/links.d.ts +4 -1
  13. package/dist/types/src/state/workspace.d.ts +3 -0
  14. package/package.json +1 -1
  15. package/dist/assets/engine.worker-DmHew5f6.js +0 -6813
  16. package/dist/assets/import-d2.worker-CnXfFXoa.js +0 -5395
  17. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +0 -87
  18. package/dist/chunks/arc-rJj0TtXf.js +0 -83
  19. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +0 -4781
  20. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +0 -1440
  21. package/dist/chunks/browser-iNhbPsGc.js +0 -40
  22. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +0 -1524
  23. package/dist/chunks/channel-qMvPU6eH.js +0 -5
  24. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +0 -670
  25. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +0 -18
  26. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +0 -262
  27. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +0 -68
  28. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +0 -19
  29. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +0 -8
  30. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +0 -19
  31. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +0 -8
  32. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +0 -451
  33. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +0 -1570
  34. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +0 -2608
  35. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +0 -22361
  36. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +0 -299
  37. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +0 -18791
  38. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +0 -2157
  39. package/dist/chunks/defaultLocale-BgPVtth8.js +0 -171
  40. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +0 -531
  41. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +0 -153
  42. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +0 -346
  43. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +0 -480
  44. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +0 -219
  45. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +0 -2586
  46. package/dist/chunks/dot-importer-B23jwEkx.js +0 -1547
  47. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +0 -109
  48. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +0 -49229
  49. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +0 -1064
  50. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +0 -1771
  51. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +0 -2729
  52. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +0 -815
  53. package/dist/chunks/graph-CKJmgLki.js +0 -1541
  54. package/dist/chunks/import-core-C-I1wGfw.js +0 -145
  55. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +0 -24
  56. package/dist/chunks/init-DjUOC4st.js +0 -16
  57. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +0 -624
  58. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +0 -834
  59. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +0 -724
  60. package/dist/chunks/katex-BsrBVQKd.js +0 -11314
  61. package/dist/chunks/linear-4t7D_ros.js +0 -259
  62. package/dist/chunks/mermaid-facade-BoLWBerE.js +0 -289
  63. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +0 -478
  64. package/dist/chunks/mermaid.core-DXv6D2Sm.js +0 -19244
  65. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +0 -837
  66. package/dist/chunks/mount-C1Xk_GQz.js +0 -22131
  67. package/dist/chunks/ordinal-DfAQgscy.js +0 -61
  68. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +0 -95
  69. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +0 -208
  70. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +0 -1029
  71. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +0 -77
  72. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +0 -889
  73. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +0 -859
  74. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +0 -2972
  75. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +0 -46
  76. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +0 -1520
  77. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +0 -4991
  78. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +0 -13
  79. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +0 -1058
  80. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +0 -7945
  81. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +0 -1578
  82. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +0 -678
  83. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +0 -1536
  84. package/dist/types/src/cli/png.d.ts +0 -23
  85. package/dist/types/src/import/browser.d.ts +0 -3
  86. package/dist/types/src/import/detect.d.ts +0 -31
  87. package/dist/types/src/import/dot-importer.d.ts +0 -3
  88. package/dist/types/src/import/import-core.d.ts +0 -105
  89. package/dist/types/src/import/mermaid-facade.d.ts +0 -120
  90. package/dist/types/src/import/mermaid-importer.d.ts +0 -4
  91. package/dist/types/src/import/mermaid-sequence.d.ts +0 -8
  92. package/dist/types/src/import/scratch.d.ts +0 -3
  93. package/dist/types/src/lib/source-hash.d.ts +0 -7
  94. package/dist/types/src/model/candidates.d.ts +0 -53
  95. package/dist/types/src/model/embed.d.ts +0 -17
  96. package/dist/types/src/model/examples.d.ts +0 -15
  97. package/dist/types/src/model/label-hits.d.ts +0 -27
  98. package/dist/types/src/model/static-scene.d.ts +0 -15
  99. package/dist/types/src/state/commands.d.ts +0 -529
  100. package/dist/types/src/state/comparison.d.ts +0 -151
  101. package/dist/types/src/state/files.d.ts +0 -61
  102. package/dist/types/src/state/keyboard.d.ts +0 -6
  103. package/dist/types/src/state/launch.d.ts +0 -61
  104. package/dist/types/src/state/ui.d.ts +0 -39
@@ -0,0 +1,3 @@
1
+ import type { FaceId } from '../model/fonts';
2
+ /** Each face's TrueType file, written once to a folder named by the fonts' content. */
3
+ export declare function fontFiles(): Record<FaceId, string>;
@@ -1,6 +1,6 @@
1
1
  /** Small form and button primitives shared by panels, menus and dialogs. */
2
2
  import { type JSX } from 'solid-js';
3
- import { type CommandId } from '../state/commands';
3
+ import type { Command } from '../state/canvas-commands';
4
4
  /** Attributes that give an element the shared tooltip. See `Tips`. */
5
5
  export declare const tip: (label: string, keys?: string, hint?: string) => {
6
6
  'data-tip': string;
@@ -20,12 +20,15 @@ export declare function IconButton(props: {
20
20
  pressed?: boolean;
21
21
  variant?: 'ghost' | 'primary';
22
22
  } & Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>): JSX.Element;
23
- /** An icon button that runs a command and explains itself from the command's own words. */
24
- export declare function CommandButton(props: {
25
- command: CommandId;
23
+ /**
24
+ * An icon button for one table of commands: it runs a command and explains itself from the
25
+ * command's own words.
26
+ */
27
+ export declare const commandButton: <Id extends string>(table: Record<Id, Command>, run: (id: Id) => void, enabled: (id: Id) => boolean) => (props: {
28
+ command: Id;
26
29
  label?: string;
27
30
  pressed?: boolean;
28
- }): JSX.Element;
31
+ }) => JSX.Element;
29
32
  /** Text with each word of a query marked where it matches. */
30
33
  export declare function Highlight(props: {
31
34
  text: string;
@@ -1,5 +1,6 @@
1
1
  import { type ResolvedAppearance } from '../model/appearance';
2
2
  import type { CellsChrome, Lane, SequenceLayout } from '../model/types';
3
+ import { type Planned } from './corridors';
3
4
  import { GROUP_HEADER, GROUP_INSET, contentOrigin } from './frame';
4
5
  import { type Model, type ModelEdge, type ModelLayout, type ModelObject } from './syntax';
5
6
  /** The single render context. Browser window size changes the camera, never the layout. */
@@ -44,6 +45,8 @@ export interface Diagnostic {
44
45
  /** A connection as the file declares it, plus the lane a fold's wrap edge returns along. */
45
46
  export interface SceneEdge extends ModelEdge {
46
47
  lane?: Lane;
48
+ /** A forward line's route, planned from its scope's ranks and corridors (`planRoutes`). */
49
+ plan?: Planned;
47
50
  /** A sequence message: the height of its row; it is drawn straight between lifelines there. */
48
51
  row?: number;
49
52
  }
@@ -149,6 +152,16 @@ export declare function crossings(paths: Array<Array<{
149
152
  }>>): number;
150
153
  /** The order of up to six items that scores fewest crossings; the first such, from `items`. */
151
154
  export declare function fewestCrossings<T>(items: T[], score: (order: T[]) => number): T[];
155
+ /**
156
+ * The corridors a `flow` scope keeps for lines that skip ranks: the ranks with their stand-ins,
157
+ * each line's stand-ins by its index in the scope's pairs, and each stand-in's place across the
158
+ * run, in the scope's coordinates.
159
+ */
160
+ export interface Corridors {
161
+ order: string[][];
162
+ chains: Map<number, string[]>;
163
+ across: Map<string, number>;
164
+ }
152
165
  /**
153
166
  * Lay out a model. `arranged` holds world positions from layout engines; scopes that an engine
154
167
  * governs take their children's relative placement from it instead of their built-in recipe.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Routes for a `flow` scope's forward lines, planned from its ranks as a layered layout routes its
3
+ * edges: out of the source's trailing side, along a track in each gap the line turns in, down a
4
+ * corridor through each rank it skips, and into the target's leading side. The ranks' order already
5
+ * keeps crossings few, so the plan only has to place ports and order each gap's tracks. The router
6
+ * takes a planned route as it is when it clears every box.
7
+ */
8
+ import type { Point, Rect } from '../model/types';
9
+ export interface PlanLine {
10
+ id: string;
11
+ /** Source, the stand-ins of the ranks it skips, target. */
12
+ chain: string[];
13
+ }
14
+ export interface Planned {
15
+ points: Point[];
16
+ fromOffset: number;
17
+ toOffset: number;
18
+ }
19
+ /**
20
+ * Space between ports on one side and between neighbouring tracks in a gap, as the router keeps
21
+ * them: ports `max(portGap, edgeGap)` apart and tracks `edgeGap` apart.
22
+ */
23
+ export interface Spacing {
24
+ port: number;
25
+ track: number;
26
+ }
27
+ /**
28
+ * Plans each line of `lines`. `order` is the ranks with stand-ins, `box` each real member's drawn
29
+ * box and `across` each stand-in's place across the run, all in drawing coordinates. Lines that
30
+ * cannot be planned (a member without a box) are left out.
31
+ */
32
+ export declare function planRoutes(axis: 'down' | 'right', order: string[][], lines: PlanLine[], box: (id: string) => Rect | undefined, across: (id: string) => number | undefined, spacing?: Spacing): Map<string, Planned>;
33
+ /**
34
+ * The room each gap between ranks needs for the tracks `planRoutes` lays in it: a standoff from
35
+ * the boxes either side and a pitch between tracks, by gap index; a gap with no track is absent.
36
+ * `box` may be a member's slot: only its place across the run counts.
37
+ */
38
+ export declare function trackRoom(axis: 'down' | 'right', order: string[][], lines: PlanLine[], box: (id: string) => Rect | undefined, across: (id: string) => number | undefined, spacing?: Spacing): number[];
@@ -93,6 +93,15 @@ export interface EdgeLayout {
93
93
  toOffset?: number;
94
94
  /** A sequence message: drawn straight between the two lifelines at this height, not routed. */
95
95
  row?: number;
96
+ /**
97
+ * Set by the compiler for a forward line in a `flow` scope: its route planned from the ranks.
98
+ * The quick router takes it as it is when it clears every box.
99
+ */
100
+ plan?: {
101
+ points: Point[];
102
+ fromOffset: number;
103
+ toOffset: number;
104
+ };
96
105
  }
97
106
  /**
98
107
  * A channel between two bands of a fold: a level line at `y`, or an upright one at `x`. With
@@ -0,0 +1,169 @@
1
+ export interface Command {
2
+ label: string;
3
+ /** Shortcut shown in menus. */
4
+ keys?: string;
5
+ icon?: string;
6
+ /** What it does, in a sentence: shown in tooltips and the palette. */
7
+ hint?: string;
8
+ run: () => unknown;
9
+ /** Allowed while a timeline preview is open. */
10
+ duringTimeline?: boolean;
11
+ /** Exits the brush before running. */
12
+ endsBrush?: boolean;
13
+ enabled?: () => boolean;
14
+ /** Why this cannot work here, shown instead of running it. */
15
+ blocked?: () => string | null;
16
+ }
17
+ declare function undoCommand(): void;
18
+ declare function redoCommand(): void;
19
+ export declare const hasSelection: () => boolean;
20
+ export declare const canvasCommands: {
21
+ undo: {
22
+ hint: string;
23
+ label: string;
24
+ keys: string;
25
+ icon: string;
26
+ run: typeof undoCommand;
27
+ duringTimeline: true;
28
+ enabled: () => boolean;
29
+ };
30
+ redo: {
31
+ hint: string;
32
+ label: string;
33
+ keys: string;
34
+ icon: string;
35
+ run: typeof redoCommand;
36
+ enabled: () => boolean;
37
+ };
38
+ 'add-node': {
39
+ hint: string;
40
+ label: string;
41
+ keys: string;
42
+ icon: string;
43
+ run: () => void;
44
+ };
45
+ 'add-connected': {
46
+ hint: string;
47
+ label: string;
48
+ keys: string;
49
+ icon: string;
50
+ run: () => string | undefined;
51
+ };
52
+ duplicate: {
53
+ hint: string;
54
+ enabled: () => boolean;
55
+ label: string;
56
+ keys: string;
57
+ icon: string;
58
+ run: () => void;
59
+ };
60
+ group: {
61
+ hint: string;
62
+ enabled: () => boolean;
63
+ label: string;
64
+ keys: string;
65
+ icon: string;
66
+ run: () => string;
67
+ };
68
+ ungroup: {
69
+ hint: string;
70
+ enabled: () => boolean;
71
+ label: string;
72
+ keys: string;
73
+ run: () => void;
74
+ };
75
+ pin: {
76
+ hint: string;
77
+ enabled: () => boolean;
78
+ label: string;
79
+ keys: string;
80
+ icon: string;
81
+ run: () => void;
82
+ };
83
+ delete: {
84
+ hint: string;
85
+ label: string;
86
+ enabled: () => boolean;
87
+ keys: string;
88
+ icon: string;
89
+ run: () => void;
90
+ };
91
+ 'delete-deep': {
92
+ label: string;
93
+ keys: string;
94
+ run: () => void;
95
+ };
96
+ layout: {
97
+ hint: string;
98
+ label: string;
99
+ keys: string;
100
+ icon: string;
101
+ run: () => Promise<import("./session/layout").LayoutOutcome>;
102
+ blocked: () => string | null;
103
+ endsBrush: true;
104
+ };
105
+ 'layout-rebuild': {
106
+ hint: string;
107
+ label: string;
108
+ keys: string;
109
+ run: () => Promise<import("./session/layout").LayoutOutcome>;
110
+ blocked: () => string | null;
111
+ endsBrush: true;
112
+ };
113
+ 'layout-accept': {
114
+ label: string;
115
+ run: () => void;
116
+ };
117
+ 'layout-discard': {
118
+ label: string;
119
+ run: () => void;
120
+ };
121
+ reroute: {
122
+ hint: string;
123
+ label: string;
124
+ keys: string;
125
+ icon: string;
126
+ run: () => void;
127
+ };
128
+ 'auto-ports': {
129
+ hint: string;
130
+ label: string;
131
+ keys: string;
132
+ run: () => void;
133
+ };
134
+ fit: {
135
+ hint: string;
136
+ label: string;
137
+ keys: string;
138
+ icon: string;
139
+ run: () => void;
140
+ duringTimeline: true;
141
+ };
142
+ 'zoom-in': {
143
+ label: string;
144
+ keys: string;
145
+ icon: string;
146
+ run: () => void;
147
+ duringTimeline: true;
148
+ };
149
+ 'zoom-out': {
150
+ label: string;
151
+ keys: string;
152
+ icon: string;
153
+ run: () => void;
154
+ duringTimeline: true;
155
+ };
156
+ 'reset-camera': {
157
+ label: string;
158
+ keys: string;
159
+ run: () => void;
160
+ duringTimeline: true;
161
+ };
162
+ };
163
+ export type CanvasCommandId = keyof typeof canvasCommands;
164
+ /** Run `command` unless a timeline preview or its own check blocks it, reporting failures. */
165
+ export declare function runChecked(id: string, command: Command): undefined;
166
+ export declare const checkedEnabled: (command: Command) => boolean;
167
+ export declare const runCanvasCommand: (id: CanvasCommandId) => undefined;
168
+ export declare const canvasCommandEnabled: (id: CanvasCommandId) => boolean;
169
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Canvas shortcuts and shape copy and paste for the active session. The app runs its own keys
3
+ * around these in `keyboard.ts`; an embedded editor uses them as they are.
4
+ */
5
+ export declare const isEditable: (el: EventTarget | null) => boolean;
6
+ /**
7
+ * Run the canvas shortcut for `e`. True when the key was used, or belongs to a field, so the host
8
+ * should not act on it. `closeMenu` lets Escape close the host's open menu, before it clears the
9
+ * selection; it returns true when it closed one.
10
+ */
11
+ export declare function handleCanvasKey(e: KeyboardEvent, closeMenu?: () => boolean): boolean;
12
+ export declare function handleKeyUp(e: KeyboardEvent): void;
13
+ export declare function copyShapes(e: ClipboardEvent): void;
14
+ /** Paste copied shapes: from the clipboard text, or the session's own copy when it is empty. */
15
+ export declare function pasteShapes(e: ClipboardEvent): void;
@@ -4,8 +4,11 @@ import type { DiagramSession } from './session';
4
4
  * Null when no file on disk is open.
5
5
  */
6
6
  export declare function linkBase(s: DiagramSession): string | null;
7
+ /** `href` joined to a URL `link-base`, or null. */
8
+ export declare const joined: (s: DiagramSession, href: string) => string | null;
7
9
  /** What opening `href` does, for a tooltip or the Inspector. */
8
10
  export declare function describeLink(s: DiagramSession, href: string): string;
11
+ /** A path inside the served folder, relative to it, or null. */
12
+ export declare function servedPath(file: string): string | null;
9
13
  /** A link as an exported SVG carries it: file paths from the diagram's folder, URLs as written. */
10
14
  export declare function exportHref(s: DiagramSession, href: string): string;
11
- export declare function openLink(s: DiagramSession, href: string): void;
@@ -0,0 +1,3 @@
1
+ import type { WorkspaceInfo } from '../server/workspace';
2
+ /** The served folder, or null on the static site and in an embedded editor. */
3
+ export declare const workspace: import("solid-js").Accessor<WorkspaceInfo | null>, setWorkspace: import("solid-js").Setter<WorkspaceInfo | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftably/editor",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "The Draftably diagram editor: drag boxes and lines, and get the .draft source back.",
5
5
  "license": "MIT",
6
6
  "type": "module",