@phun-ky/arclace 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0](https://github.com/phun-ky/arclace/compare/0.2.0...0.3.0) (2026-11-04)
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * Update code that uses the following:
8
+
9
+ - stop is now end: stopElement is endElement, stopSide is endSide,
10
+ geometry.stop and geometry.stopSide are geometry.end and
11
+ geometry.endSide, .arc-anchor-stop is .arc-anchor-end, and
12
+ data-stop-side is data-end-side
13
+ - options are checked before anything is added. Wrong types throw a
14
+ TypeError (strokeWidth: '3', label: 0, dashed: 'no', an empty or
15
+ non-string id) and values out of range a RangeError (type: 'wavy',
16
+ arrow: 'yes', an unknown side, a negative strokeWidth, spacing,
17
+ radius or offset). defaults can't set an id, and autoUpdate must be
18
+ true, false or 'frame'
19
+ - failures throw ArclaceError, exported, instead of Error. An invalid
20
+ selector throws an ArclaceError with the SyntaxError as its cause
21
+ - find() returns [] for a selector that matches nothing, instead of
22
+ throwing
23
+ - disconnect() throws a TypeError for a target that is not a
24
+ connection, a string, an element, null or undefined
25
+ - setOptions() throws after the connection was removed or its
26
+ instance destroyed, and when given an id
27
+ - DEFAULT_CONNECTION_OPTIONS is frozen, and geometry is a read-only
28
+ frozen object
29
+ - the Connection constructor is private in the types; connections
30
+ come from connect() and connectAll(). ArcConnectionParamsType and
31
+ ArcOptionalKeysType are no longer exported
32
+ - the path builders check their points (finite x and y) and sides
33
+
34
+ ### Documentation
35
+
36
+ * ✏️ assurance case and VEX statements ([73b4fe6](https://github.com/phun-ky/arclace/commit/73b4fe6bd0e1e553de71c8817d9720b1b27cc360)), references [#19](https://github.com/phun-ky/arclace/issues/19)
37
+ * ✏️ governance, roadmap and a contributing guide for Arclace ([5f5b33a](https://github.com/phun-ky/arclace/commit/5f5b33a54fa331e6ebf428f1773a0bd28013a6f2)), references [#20](https://github.com/phun-ky/arclace/issues/20) [#21](https://github.com/phun-ky/arclace/issues/21) [#19](https://github.com/phun-ky/arclace/issues/19) [#60](https://github.com/phun-ky/arclace/issues/60) [#19](https://github.com/phun-ky/arclace/issues/19)
38
+ * ✏️ link the ArclaceError source in the API reference ([d22f104](https://github.com/phun-ky/arclace/commit/d22f104088255aaa66037ee3e162c7ed8e4e575a)), references [#20](https://github.com/phun-ky/arclace/issues/20)
39
+ * ✏️ record the API review in the assurance case and OpenSSF answers ([e4cc02f](https://github.com/phun-ky/arclace/commit/e4cc02f294bc523da5c1f993972adab1e2a1a927)), closes [#20](https://github.com/phun-ky/arclace/issues/20), references [#21](https://github.com/phun-ky/arclace/issues/21)
40
+
41
+ ### Refactoring
42
+
43
+ * 💡 review the API for 1.0 ([94f3569](https://github.com/phun-ky/arclace/commit/94f3569d6be4ae66bd2ddc81b546a40301f24104)), references [#20](https://github.com/phun-ky/arclace/issues/20) [#20](https://github.com/phun-ky/arclace/issues/20)
44
+
3
45
  ## [0.2.0](https://github.com/phun-ky/arclace/compare/0.1.0...0.2.0) (2026-11-04)
4
46
 
5
47
  ### ⚠ BREAKING CHANGES
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @phun-ky/arclace
2
2
 
3
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/16333/badge)](https://www.bestpractices.dev/projects/16333)
4
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/phun-ky/arclace/badge)](https://scorecard.dev/viewer/?uri=github.com/phun-ky/arclace)
5
+
3
6
  > Draw SVG lines between DOM elements.
4
7
 
5
8
  Point it at two elements and it draws a line between them: a curve, a straight
@@ -60,8 +63,8 @@ import { createConnections } from '@phun-ky/arclace';
60
63
 
61
64
  const arclace = createConnections(
62
65
  [
63
- { startElement: '#a', stopElement: '#b' },
64
- { startElement: '#b', stopElement: '#c', label: 'then' }
66
+ { startElement: '#a', endElement: '#b' },
67
+ { startElement: '#b', endElement: '#c', label: 'then' }
65
68
  ],
66
69
  { container: '#diagram', defaults: { type: 'orthogonal', arrow: 'end' } }
67
70
  );
@@ -109,60 +112,78 @@ overlay doesn't block clicks (`pointer-events: none`).
109
112
  | `defaults` | [Connection options](#connection-options) | `{}` | Defaults for every connection made by this instance. |
110
113
  | `className` | `string` | | Extra classes for the overlay. |
111
114
 
112
- | Member | Description |
113
- | -------------------------------- | -------------------------------------------------------------------------------- |
114
- | `connect(start, stop, options?)` | Connects two elements (or selectors) and draws the line. Returns a `Connection`. |
115
- | `connectAll(definitions)` | Connects many `{ startElement, stopElement, ...options }` pairs in one go. |
116
- | `get(id)` | The connection with that id. |
117
- | `find(element)` | Every connection that starts or stops at an element. |
118
- | `disconnect(target)` | Removes a connection, a connection by id, or every connection of an element. |
119
- | `clear()` | Removes every connection. |
120
- | `update()` | Remeasures and redraws everything. |
121
- | `destroy()` | Removes everything and stops listening for changes. |
122
- | `connections` | All connections, in the order they were made. |
123
- | `container`, `svg` | The container and the overlay. |
115
+ | Member | Description |
116
+ | ------------------------------- | ------------------------------------------------------------------------------------------------------------- |
117
+ | `connect(start, end, options?)` | Connects two elements (or selectors) and draws the line. Returns a `Connection`. |
118
+ | `connectAll(definitions)` | Connects many `{ startElement, endElement, ...options }` pairs in one go: all of them or, if one fails, none. |
119
+ | `get(id)` | The connection with that id. |
120
+ | `find(element)` | Every connection that starts or ends at an element. `[]` when a selector matches nothing. |
121
+ | `disconnect(target)` | Removes a connection, a connection by id, or every connection of an element. |
122
+ | `clear()` | Removes every connection. |
123
+ | `update()` | Remeasures and redraws everything. |
124
+ | `destroy()` | Removes everything and stops listening for changes. |
125
+ | `connections` | All connections, in the order they were made. |
126
+ | `container`, `svg` | The container and the overlay. |
124
127
 
125
128
  ### `Connection`
126
129
 
127
- | Member | Description |
128
- | ----------------------------------- | ------------------------------------------------------------------------------------------------ |
129
- | `setOptions(options)` | Changes options and redraws. |
130
- | `remove()` | Removes the connection. |
131
- | `update()` | Redraws (all connections of the instance, since spreading depends on the others). |
132
- | `options` | The options in effect, with defaults filled in. |
133
- | `geometry` | `{ start, stop, startSide, stopSide, labelPoint, d }` from the last draw, or `null` when hidden. |
134
- | `id`, `startElement`, `stopElement` | |
135
- | `element`, `path` | The connection's `<g>` and `<path>`, for styling or event listeners. |
130
+ | Member | Description |
131
+ | ---------------------------------- | ---------------------------------------------------------------------------------------------- |
132
+ | `setOptions(options)` | Changes options and redraws. |
133
+ | `remove()` | Removes the connection. |
134
+ | `update()` | Redraws (all connections of the instance, since spreading depends on the others). |
135
+ | `options` | The options in effect, with defaults filled in. |
136
+ | `geometry` | `{ start, end, startSide, endSide, labelPoint, d }` from the last draw, or `null` when hidden. |
137
+ | `id`, `startElement`, `endElement` | |
138
+ | `element`, `path` | The connection's `<g>` and `<path>`, for styling or event listeners. |
136
139
 
137
140
  A connection is hidden while one of its elements is detached or `display: none`,
138
141
  and shown again when it comes back.
139
142
 
140
143
  ### Connection options
141
144
 
142
- | Option | Type | Default | Description |
143
- | ------------- | -------------------------------------------------- | ---------- | ------------------------------------------------------------------------------ |
144
- | `id` | `string` | generated | Unique id, for `get()` and `disconnect()`. |
145
- | `type` | `'bezier' \| 'straight' \| 'orthogonal'` | `'bezier'` | How the line is drawn. |
146
- | `startSide` | `'auto' \| 'top' \| 'right' \| 'bottom' \| 'left'` | `'auto'` | Side of the start element. `auto` picks the side facing the other element. |
147
- | `stopSide` | same as `startSide` | `'auto'` | Side of the stop element. |
148
- | `arrow` | `'none' \| 'start' \| 'end' \| 'both'` | `'none'` | Arrow heads. |
149
- | `label` | `string` | | Text in the middle of the line. |
150
- | `color` | `string` | | Line color. Without it, lines use `--arc-color` or the container's text color. |
151
- | `strokeWidth` | `number` | `2` | Line width in pixels. Arrows and anchors scale with it. |
152
- | `dashed` | `boolean` | `false` | Dashed line. |
153
- | `animated` | `boolean` | `false` | Dashes flowing from start to stop. Needs `style.css`. |
154
- | `anchors` | `boolean` | `false` | Dots where the line meets the elements. |
155
- | `className` | `string` | | Extra classes for the connection's `<g>`. |
156
- | `gap` | `number` | `0` | Space between the element edge and the line end. |
157
- | `spread` | `boolean` | `true` | Spread lines that share a side of an element. |
158
- | `spacing` | `number` | `16` | Distance between spread lines. Shrinks to fit the side. |
159
- | `curvature` | `number` | `1` | `bezier`: how far the curve bulges out. |
160
- | `radius` | `number` | `8` | `orthogonal`: corner radius. `0` for sharp corners. |
161
- | `offset` | `number` | `20` | `orthogonal`: how far the line goes straight out of an element before turning. |
145
+ | Option | Type | Default | Description |
146
+ | ------------- | -------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------- |
147
+ | `id` | `string` | generated | Unique id, for `get()` and `disconnect()`. |
148
+ | `type` | `'bezier' \| 'straight' \| 'orthogonal'` | `'bezier'` | How the line is drawn. |
149
+ | `startSide` | `'auto' \| 'top' \| 'right' \| 'bottom' \| 'left'` | `'auto'` | Side of the start element. `auto` picks the side facing the other element. |
150
+ | `endSide` | same as `startSide` | `'auto'` | Side of the end element. |
151
+ | `arrow` | `'none' \| 'start' \| 'end' \| 'both'` | `'none'` | Arrow heads. |
152
+ | `label` | `string` | | Text in the middle of the line. |
153
+ | `color` | `string` | | Line color. Without it, lines use `--arc-color` or the container's text color. |
154
+ | `strokeWidth` | `number` | `2` | Line width in pixels, `0` or more. Arrows and anchors scale with it. |
155
+ | `dashed` | `boolean` | `false` | Dashed line. |
156
+ | `animated` | `boolean` | `false` | Dashes flowing from start to end. Needs `style.css`. |
157
+ | `anchors` | `boolean` | `false` | Dots where the line meets the elements. |
158
+ | `className` | `string` | | Extra classes for the connection's `<g>`. |
159
+ | `gap` | `number` | `0` | Space between the element edge and the line end. Negative moves the end into the element. |
160
+ | `spread` | `boolean` | `true` | Spread lines that share a side of an element. |
161
+ | `spacing` | `number` | `16` | Distance between spread lines, `0` or more. Shrinks to fit the side. |
162
+ | `curvature` | `number` | `1` | `bezier`: how far the curve bulges out. Negative bulges the other way. |
163
+ | `radius` | `number` | `8` | `orthogonal`: corner radius, `0` or more. `0` for sharp corners. |
164
+ | `offset` | `number` | `20` | `orthogonal`: how far the line goes straight out of an element before turning, `0` or more. |
162
165
 
163
166
  The path builders `bezierPath`, `straightPath` and `orthogonalPath` are also
164
167
  exported if you want to draw lines between points yourself.
165
168
 
169
+ ### Errors
170
+
171
+ Options are checked when they are given, so a mistake fails at once with a
172
+ message that names the option:
173
+
174
+ - **`TypeError`:** a value of the wrong type, for example `strokeWidth: '3'`,
175
+ `label: 0`, or a target that is neither an element nor a selector.
176
+ - **`RangeError`:** a value out of range, for example `type: 'wavy'`,
177
+ `startSide: 'middle'` or `radius: -5`.
178
+ - **`ArclaceError`:** Arclace can't do what was asked: a selector matches
179
+ nothing or is invalid (with the browser's error as `cause`), an id is taken,
180
+ or the connection or the instance has been removed. It is exported, for
181
+ `instanceof` checks.
182
+
183
+ Every message starts with `arclace:`. When a call throws, nothing is added, so
184
+ the lines already drawn keep working. An option set to `undefined` uses the
185
+ default, and option names Arclace doesn't know are ignored.
186
+
166
187
  ## Styling
167
188
 
168
189
  Each connection is rendered as:
@@ -172,7 +193,7 @@ Each connection is rendered as:
172
193
  class="arc-connection arc-bezier"
173
194
  data-type="bezier"
174
195
  data-start-side="right"
175
- data-stop-side="left"
196
+ data-end-side="left"
176
197
  >
177
198
  <marker class="arc-marker">…</marker>
178
199
  <!-- arrow -->
@@ -181,7 +202,7 @@ Each connection is rendered as:
181
202
  <!-- label -->
182
203
  <circle class="arc-anchor arc-anchor-start" />
183
204
  <!-- anchors -->
184
- <circle class="arc-anchor arc-anchor-stop" />
205
+ <circle class="arc-anchor arc-anchor-end" />
185
206
  </g>
186
207
  ```
187
208
 
package/dist/arclace.d.ts CHANGED
@@ -52,9 +52,9 @@ type ArcConnectionOptionsType = {
52
52
  */
53
53
  startSide?: ArcSideOptionType;
54
54
  /**
55
- * The side of the stop element the line arrives at. Defaults to `'auto'`.
55
+ * The side of the end element the line arrives at. Defaults to `'auto'`.
56
56
  */
57
- stopSide?: ArcSideOptionType;
57
+ endSide?: ArcSideOptionType;
58
58
  /**
59
59
  * Where to draw arrow heads. Defaults to `'none'`.
60
60
  */
@@ -77,7 +77,7 @@ type ArcConnectionOptionsType = {
77
77
  */
78
78
  dashed?: boolean;
79
79
  /**
80
- * Animate the dashes from start to stop. Implies `dashed`. Requires the
80
+ * Animate the dashes from start to end. Implies `dashed`. Requires the
81
81
  * stylesheet. Defaults to `false`.
82
82
  */
83
83
  animated?: boolean;
@@ -127,7 +127,7 @@ type ArcConnectionOptionsType = {
127
127
  */
128
128
  type ArcConnectionDefinitionType = ArcConnectionOptionsType & {
129
129
  startElement: ArcElementTargetType;
130
- stopElement: ArcElementTargetType;
130
+ endElement: ArcElementTargetType;
131
131
  };
132
132
  /**
133
133
  * Options for a {@link Arclace} instance.
@@ -162,37 +162,28 @@ type ArcOptionsType = {
162
162
  */
163
163
  type ArcGeometryType = {
164
164
  start: ArcPointInterface;
165
- stop: ArcPointInterface;
165
+ end: ArcPointInterface;
166
166
  startSide: ArcSideType;
167
- stopSide: ArcSideType;
167
+ endSide: ArcSideType;
168
168
  labelPoint: ArcPointInterface;
169
169
  d: string;
170
170
  };
171
171
 
172
172
  /**
173
- * Connection options that have no default.
173
+ * Connection options with every default filled in. `label`, `color` and
174
+ * `className` have no default.
174
175
  */
175
- type ArcOptionalKeysType = 'id' | 'label' | 'color' | 'className';
176
- /**
177
- * Connection options with every default filled in.
178
- */
179
- type ArcResolvedConnectionOptionsType = Required<Omit<ArcConnectionOptionsType, ArcOptionalKeysType>> & Pick<ArcConnectionOptionsType, ArcOptionalKeysType> & {
176
+ type ArcResolvedConnectionOptionsType = Required<Omit<ArcConnectionOptionsType, 'id' | 'label' | 'color' | 'className'>> & Pick<ArcConnectionOptionsType, 'label' | 'color' | 'className'> & {
180
177
  id: string;
181
178
  };
182
179
  /**
183
- * Options every connection falls back to.
180
+ * Options every connection falls back to. Frozen: set your own defaults with
181
+ * the `defaults` option of {@link Arclace} instead.
184
182
  */
185
- declare const DEFAULT_CONNECTION_OPTIONS: Required<Omit<ArcConnectionOptionsType, ArcOptionalKeysType>>;
186
- type ArcConnectionParamsType = {
187
- id: string;
188
- startElement: Element;
189
- stopElement: Element;
190
- options: ArcConnectionOptionsType;
191
- defaults?: ArcConnectionOptionsType;
192
- owner: Arclace;
193
- };
183
+ declare const DEFAULT_CONNECTION_OPTIONS: Readonly<Required<Omit<ArcConnectionOptionsType, 'id' | 'label' | 'color' | 'className'>>>;
194
184
  /**
195
- * A line between two elements. Created with {@link Arclace.connect}.
185
+ * A line between two elements. Created with {@link Arclace.connect} or
186
+ * {@link Arclace.connectAll}, not with `new`.
196
187
  *
197
188
  * Each connection renders as:
198
189
  *
@@ -202,7 +193,7 @@ type ArcConnectionParamsType = {
202
193
  * <path class="arc-path" />
203
194
  * <text class="arc-label">…</text> <!-- when `label` is set -->
204
195
  * <circle class="arc-anchor arc-anchor-start" /> <!-- when `anchors` is set -->
205
- * <circle class="arc-anchor arc-anchor-stop" />
196
+ * <circle class="arc-anchor arc-anchor-end" />
206
197
  * </g>
207
198
  * ```
208
199
  *
@@ -213,7 +204,7 @@ declare class Connection {
213
204
  #private;
214
205
  readonly id: string;
215
206
  readonly startElement: Element;
216
- readonly stopElement: Element;
207
+ readonly endElement: Element;
217
208
  /**
218
209
  * The `<g>` element holding everything this connection draws.
219
210
  */
@@ -222,12 +213,12 @@ declare class Connection {
222
213
  * The `<path>` element of the line.
223
214
  */
224
215
  readonly path: SVGPathElement;
216
+ private constructor();
225
217
  /**
226
218
  * The geometry from the last update, or `null` when the connection is
227
219
  * hidden because one of its elements is not rendered.
228
220
  */
229
- geometry: ArcGeometryType | null;
230
- constructor(params: ArcConnectionParamsType);
221
+ get geometry(): Readonly<ArcGeometryType> | null;
231
222
  /**
232
223
  * The connection's options merged with the instance defaults.
233
224
  */
@@ -239,6 +230,9 @@ declare class Connection {
239
230
  * ```ts
240
231
  * connection.setOptions({ type: 'orthogonal', arrow: 'end' });
241
232
  * ```
233
+ * @throws {TypeError} When an option has the wrong type, or `id` is set.
234
+ * @throws {RangeError} When an option is out of range.
235
+ * @throws {ArclaceError} When the connection has been removed.
242
236
  */
243
237
  setOptions(options: Omit<ArcConnectionOptionsType, 'id'>): this;
244
238
  /**
@@ -276,6 +270,12 @@ declare class Arclace {
276
270
  * The SVG overlay all lines are drawn in.
277
271
  */
278
272
  readonly svg: SVGSVGElement;
273
+ /**
274
+ * @throws {TypeError} When an option has the wrong type.
275
+ * @throws {RangeError} When an option is out of range.
276
+ * @throws {ArclaceError} When there is no DOM, or the container can't be
277
+ * found.
278
+ */
279
279
  constructor(options?: ArcOptionsType);
280
280
  /**
281
281
  * All current connections, in the order they were made.
@@ -285,23 +285,32 @@ declare class Arclace {
285
285
  * Connects two elements and draws the line right away.
286
286
  *
287
287
  * @param startElement - The element (or selector) the line starts at.
288
- * @param stopElement - The element (or selector) the line stops at.
288
+ * @param endElement - The element (or selector) the line ends at.
289
289
  * @param options - Options for this connection, merged over the instance defaults.
290
- * @throws {Error} When an element can't be found or the id is taken.
290
+ * @throws {TypeError} When an element or an option has the wrong type.
291
+ * @throws {RangeError} When an option is out of range.
292
+ * @throws {ArclaceError} When an element can't be found, the id is taken
293
+ * or the instance has been destroyed. Nothing is added.
291
294
  * @example
292
295
  * ```ts
293
296
  * const connection = arclace.connect(a, b, { type: 'orthogonal', arrow: 'end' });
294
297
  * ```
295
298
  */
296
- connect(startElement: ArcElementTargetType, stopElement: ArcElementTargetType, options?: ArcConnectionOptionsType): Connection;
299
+ connect(startElement: ArcElementTargetType, endElement: ArcElementTargetType, options?: ArcConnectionOptionsType): Connection;
297
300
  /**
298
- * Connects many pairs of elements and draws them in one go.
301
+ * Connects many pairs of elements and draws them in one go. Every
302
+ * definition is checked first, so either all of them are added or none.
299
303
  *
304
+ * @throws {TypeError} When `definitions` isn't an array, or an element or
305
+ * an option has the wrong type.
306
+ * @throws {RangeError} When an option is out of range.
307
+ * @throws {ArclaceError} When an element can't be found, an id is taken or
308
+ * repeated, or the instance has been destroyed.
300
309
  * @example
301
310
  * ```ts
302
311
  * arclace.connectAll([
303
- * { startElement: '#a', stopElement: '#b' },
304
- * { startElement: '#a', stopElement: '#c', dashed: true }
312
+ * { startElement: '#a', endElement: '#b' },
313
+ * { startElement: '#a', endElement: '#c', dashed: true }
305
314
  * ]);
306
315
  * ```
307
316
  */
@@ -311,7 +320,11 @@ declare class Arclace {
311
320
  */
312
321
  get(id: string): Connection | undefined;
313
322
  /**
314
- * Returns every connection that starts or stops at an element.
323
+ * Returns every connection that starts or ends at an element. A selector
324
+ * that matches nothing returns an empty array.
325
+ *
326
+ * @throws {TypeError} When the target is neither an element nor a string.
327
+ * @throws {ArclaceError} When the selector is invalid.
315
328
  */
316
329
  find(target: ArcElementTargetType): Connection[];
317
330
  /**
@@ -319,7 +332,10 @@ declare class Arclace {
319
332
  *
320
333
  * @param target - A connection, a connection id, or an element (or
321
334
  * selector) whose connections should all be removed. Targets that match
322
- * nothing are ignored.
335
+ * nothing, and `null` or `undefined`, are ignored.
336
+ * @throws {TypeError} When the target is another kind of value.
337
+ * @throws {ArclaceError} When a string is neither an id nor a valid
338
+ * selector.
323
339
  * @example
324
340
  * ```ts
325
341
  * arclace.disconnect(connection);
@@ -353,8 +369,8 @@ declare class Arclace {
353
369
  *
354
370
  * const arclace = createConnections(
355
371
  * [
356
- * { startElement: '#a', stopElement: '#b' },
357
- * { startElement: '#b', stopElement: '#c', arrow: 'end' }
372
+ * { startElement: '#a', endElement: '#b' },
373
+ * { startElement: '#b', endElement: '#c', arrow: 'end' }
358
374
  * ],
359
375
  * { defaults: { type: 'orthogonal' } }
360
376
  * );
@@ -362,6 +378,29 @@ declare class Arclace {
362
378
  */
363
379
  declare const createConnections: (definitions: ArcConnectionDefinitionType[], options?: ArcOptionsType) => Arclace;
364
380
 
381
+ /**
382
+ * Thrown when Arclace can't do what was asked, for example when a selector
383
+ * matches nothing, an id is taken, or the instance has been destroyed.
384
+ *
385
+ * Arguments of the wrong type throw a `TypeError`, and values out of range a
386
+ * `RangeError`, instead. When another error is behind the failure, such as
387
+ * an invalid selector, it is the `cause`.
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * try {
392
+ * arclace.connect('#a', '#b', { id: 'a-to-b' });
393
+ * arclace.connect('#b', '#c', { id: 'a-to-b' }); // the id is taken
394
+ * } catch (error) {
395
+ * if (error instanceof ArclaceError) console.warn(error.message);
396
+ * }
397
+ * ```
398
+ */
399
+ declare class ArclaceError extends Error {
400
+ name: string;
401
+ constructor(message: string, options?: ErrorOptions);
402
+ }
403
+
365
404
  type ArcPathResultType = {
366
405
  /**
367
406
  * SVG path data.
@@ -375,25 +414,31 @@ type ArcPathResultType = {
375
414
  /**
376
415
  * A straight line between two points.
377
416
  *
417
+ * @throws {TypeError} When a point doesn't have finite `x` and `y`.
378
418
  * @example
379
419
  * ```ts
380
420
  * straightPath({ x: 0, y: 0 }, { x: 100, y: 0 }).d; // 'M 0 0 L 100 0'
381
421
  * ```
382
422
  */
383
- declare const straightPath: (start: ArcPointInterface, stop: ArcPointInterface) => ArcPathResultType;
423
+ declare const straightPath: (start: ArcPointInterface, end: ArcPointInterface) => ArcPathResultType;
384
424
  /**
385
- * A cubic bezier curve that leaves `start` and arrives at `stop`
425
+ * A cubic bezier curve that leaves `start` and arrives at `end`
386
426
  * perpendicular to their sides.
387
427
  *
428
+ * @throws {TypeError} When a point or `curvature` isn't finite.
429
+ * @throws {RangeError} When a side isn't `top`, `right`, `bottom` or `left`.
388
430
  * @example
389
431
  * ```ts
390
432
  * bezierPath({ x: 0, y: 0 }, 'right', { x: 200, y: 100 }, 'left').d;
391
433
  * ```
392
434
  */
393
- declare const bezierPath: (start: ArcPointInterface, startSide: ArcSideType, stop: ArcPointInterface, stopSide: ArcSideType, curvature?: number) => ArcPathResultType;
435
+ declare const bezierPath: (start: ArcPointInterface, startSide: ArcSideType, end: ArcPointInterface, endSide: ArcSideType, curvature?: number) => ArcPathResultType;
394
436
  /**
395
437
  * An orthogonal line with rounded corners.
396
438
  *
439
+ * @throws {TypeError} When a point, `radius` or `offset` isn't finite.
440
+ * @throws {RangeError} When a side isn't `top`, `right`, `bottom` or `left`,
441
+ * or `radius` or `offset` is negative.
397
442
  * @example
398
443
  * ```ts
399
444
  * orthogonalPath({ x: 0, y: 0 }, 'right', { x: 200, y: 100 }, 'left', {
@@ -402,10 +447,10 @@ declare const bezierPath: (start: ArcPointInterface, startSide: ArcSideType, sto
402
447
  * }).d;
403
448
  * ```
404
449
  */
405
- declare const orthogonalPath: (start: ArcPointInterface, startSide: ArcSideType, stop: ArcPointInterface, stopSide: ArcSideType, { radius, offset }?: {
450
+ declare const orthogonalPath: (start: ArcPointInterface, startSide: ArcSideType, end: ArcPointInterface, endSide: ArcSideType, { radius, offset }?: {
406
451
  radius?: number;
407
452
  offset?: number;
408
453
  }) => ArcPathResultType;
409
454
 
410
- export { Arclace, Connection, DEFAULT_CONNECTION_OPTIONS, bezierPath, createConnections, orthogonalPath, straightPath };
411
- export type { ArcArrowType, ArcConnectionDefinitionType, ArcConnectionOptionsType, ArcConnectionParamsType, ArcElementTargetType, ArcGeometryType, ArcOptionalKeysType, ArcOptionsType, ArcPathResultType, ArcPathType, ArcPointInterface, ArcRectInterface, ArcResolvedConnectionOptionsType, ArcSideOptionType, ArcSideType };
455
+ export { Arclace, ArclaceError, Connection, DEFAULT_CONNECTION_OPTIONS, bezierPath, createConnections, orthogonalPath, straightPath };
456
+ export type { ArcArrowType, ArcConnectionDefinitionType, ArcConnectionOptionsType, ArcElementTargetType, ArcGeometryType, ArcOptionsType, ArcPathResultType, ArcPathType, ArcPointInterface, ArcRectInterface, ArcResolvedConnectionOptionsType, ArcSideOptionType, ArcSideType };