@phun-ky/arclace 0.0.0-stage β†’ 0.2.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 ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ ## [0.2.0](https://github.com/phun-ky/arclace/compare/0.1.0...0.2.0) (2026-11-04)
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * πŸ’‘ rename the package to Arclace
8
+
9
+ ### Tasks
10
+
11
+ * πŸ€– sign off every commit with a prepare-commit-msg hook ([940e06b](https://github.com/phun-ky/arclace/commit/940e06b72871db570ccb516f76d81bcb5ea3e53b)), references [#18](https://github.com/phun-ky/arclace/issues/18)
12
+ * πŸ€– skip the first release under a new package name ([738c8b6](https://github.com/phun-ky/arclace/commit/738c8b6534c860d53361811781268ae0bf08c7dd)), references [#58](https://github.com/phun-ky/arclace/issues/58)
13
+
14
+ ### Documentation
15
+
16
+ * ✏️ add a VitePress docs site with the API reference ([3125b4c](https://github.com/phun-ky/arclace/commit/3125b4c17ac477aa9b331dac6513a2ce69a93d2e)), references [#15](https://github.com/phun-ky/arclace/issues/15)
17
+ * ✏️ explain the name Arclace ([180ca0d](https://github.com/phun-ky/arclace/commit/180ca0d781d85e1ff7b96cb41d1b5cc6cc07f495)), references [#58](https://github.com/phun-ky/arclace/issues/58)
18
+ * ✏️ rewrite the security policy and add security insights ([2942a2c](https://github.com/phun-ky/arclace/commit/2942a2cb86c595810ae5c5493e664ad13b5bebf2)), references [#17](https://github.com/phun-ky/arclace/issues/17)
19
+ * ✏️ show the markup the playground example runs on ([a5251de](https://github.com/phun-ky/arclace/commit/a5251de0298dc051cc2eb451e3e30b70c3644f92)), references [#16](https://github.com/phun-ky/arclace/issues/16)
20
+ * ✏️ tell where connect-the-things comes from ([9df2bdf](https://github.com/phun-ky/arclace/commit/9df2bdff7e9dcf50e223fb60e64eb0301406acf7)), references [#56](https://github.com/phun-ky/arclace/issues/56)
21
+
22
+ ### Refactoring
23
+
24
+ * πŸ’‘ rename the package to Arclace ([5758e91](https://github.com/phun-ky/arclace/commit/5758e91483c20a13b2010e0afab0635e04ee8cd0))
25
+
26
+ ## 0.1.0 (2026-11-03)
27
+
28
+ ### Tasks
29
+
30
+ * πŸ€– fix the labeler rules, issue template labels and triage ([b45a57a](https://github.com/phun-ky/connect-the-things/commit/b45a57a93b5885da18e76911f6c8f21816c34a03)), references [#10](https://github.com/phun-ky/connect-the-things/issues/10)
31
+ * πŸ€– group Dependabot updates and add GitHub Actions ([ad5216e](https://github.com/phun-ky/connect-the-things/commit/ad5216e8f88c8d9357b94e6401b873e1350bb805)), references [#9](https://github.com/phun-ky/connect-the-things/issues/9)
32
+ * πŸ€– ignore the .claude directory ([27ed8ce](https://github.com/phun-ky/connect-the-things/commit/27ed8ce590218370d09f1d4534f082320eac518c)), references [#49](https://github.com/phun-ky/connect-the-things/issues/49)
33
+ * πŸ€– lint and API docs tooling ([2dd8e60](https://github.com/phun-ky/connect-the-things/commit/2dd8e60a1c1e019e5786bbfb2a1cc2c5091b16cc)), references [#3](https://github.com/phun-ky/connect-the-things/issues/3)
34
+ * πŸ€– move to ESLint 10 and lint every file type ([1b1d7ac](https://github.com/phun-ky/connect-the-things/commit/1b1d7acd6197723c78070ab9ca0bdd81c95b1be4)), references [#6](https://github.com/phun-ky/connect-the-things/issues/6)
35
+ * πŸ€– refresh development dependencies and override katex ([e157c35](https://github.com/phun-ky/connect-the-things/commit/e157c359b453a0d6bba14763c2a1d34553eb4877)), references [#11](https://github.com/phun-ky/connect-the-things/issues/11)
36
+ * πŸ€– upgrade release-it to 21 and the changelog plugin to 12 ([4c4704e](https://github.com/phun-ky/connect-the-things/commit/4c4704ece6498cc88a7a387b56611531589d27df)), references [#44](https://github.com/phun-ky/connect-the-things/issues/44) [#12](https://github.com/phun-ky/connect-the-things/issues/12)
37
+
38
+ ### Feature
39
+
40
+ * 🎸 draw SVG lines between DOM elements ([62ee4e3](https://github.com/phun-ky/connect-the-things/commit/62ee4e359bfec916643a9f5da506979562651f33)), references [#3](https://github.com/phun-ky/connect-the-things/issues/3)
41
+
42
+ ### Bug
43
+
44
+ * πŸ› ship ES modules with types that resolve everywhere ([390da51](https://github.com/phun-ky/connect-the-things/commit/390da51be2a84fb5a02bae9ed1f6957680ebdb8d)), references [#4](https://github.com/phun-ky/connect-the-things/issues/4)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2026 Alexander Vassbotn RΓΈyne-Helgesen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,316 @@
1
- # Temporary Holding Version
1
+ # @phun-ky/arclace
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Draw SVG lines between DOM elements.
4
+
5
+ Point it at two elements and it draws a line between them: a curve, a straight
6
+ line or an orthogonal "circuit board" line, with optional arrows, labels and
7
+ anchors. The lines follow the elements when they move, resize, scroll or get
8
+ zoomed.
9
+
10
+ It's framework agnostic and has zero dependencies. You keep your own HTML for
11
+ the boxes; Arclace only draws the lines.
12
+
13
+ - **Three line types**: `bezier`, `straight` and `orthogonal` (with rounded
14
+ corners)
15
+ - **Automatic sides**: lines leave and enter on the sides that face each other,
16
+ or on sides you pick
17
+ - **Spreading**: several lines on the same side of an element are spread out and
18
+ ordered so they don't cross
19
+ - **Arrows, labels, anchors, dashed and animated lines**
20
+ - **Keeps itself in sync** with resizes, scrolling and DOM/style changes, or on
21
+ every frame if you want
22
+ - **Works in scrolled and CSS-transformed containers**, so it fits pan/zoom
23
+ canvases
24
+ - **Styled with CSS**: everything uses `currentColor` and plain class names
25
+
26
+ ## Install
27
+
28
+ ```shell
29
+ npm i @phun-ky/arclace
30
+ ```
31
+
32
+ ES modules; `require()` needs Node 22.12 or later. A UMD build is available for
33
+ script tags (see [Without a bundler](#without-a-bundler)).
34
+
35
+ ## Usage
36
+
37
+ ```html
38
+ <div id="diagram">
39
+ <div class="box" id="a">A</div>
40
+ <div class="box" id="b">B</div>
41
+ <div class="box" id="c">C</div>
42
+ </div>
43
+ ```
44
+
45
+ ```ts
46
+ import { Arclace } from '@phun-ky/arclace';
47
+ // Optional: label halo, hollow anchors and the dash animation
48
+ import '@phun-ky/arclace/style.css';
49
+
50
+ const arclace = new Arclace({ container: '#diagram' });
51
+
52
+ arclace.connect('#a', '#b', { arrow: 'end', label: 'depends on' });
53
+ arclace.connect('#a', '#c', { type: 'orthogonal', dashed: true });
54
+ ```
55
+
56
+ Or create everything at once:
57
+
58
+ ```ts
59
+ import { createConnections } from '@phun-ky/arclace';
60
+
61
+ const arclace = createConnections(
62
+ [
63
+ { startElement: '#a', stopElement: '#b' },
64
+ { startElement: '#b', stopElement: '#c', label: 'then' }
65
+ ],
66
+ { container: '#diagram', defaults: { type: 'orthogonal', arrow: 'end' } }
67
+ );
68
+ ```
69
+
70
+ ### Without a bundler
71
+
72
+ ```html
73
+ <link
74
+ rel="stylesheet"
75
+ href="https://unpkg.com/@phun-ky/arclace/dist/style.css"
76
+ />
77
+ <script src="https://unpkg.com/@phun-ky/arclace"></script>
78
+ <script>
79
+ const arclace = new Arclace.Arclace();
80
+
81
+ arclace.connect('#a', '#b');
82
+ </script>
83
+ ```
84
+
85
+ ## How it works
86
+
87
+ Each instance adds one `<svg class="arc-svg">` to its container, absolutely
88
+ positioned over the container's content, and draws every line into it. The
89
+ overlay doesn't block clicks (`pointer-events: none`).
90
+
91
+ - Put all the elements you connect inside the container. If the container is
92
+ `position: static` it is changed to `position: relative` so the overlay
93
+ scrolls and clips with it (and changed back on `destroy()`). The default
94
+ container is `document.body`.
95
+ - Positions are measured relative to the overlay itself, so lines stay correct
96
+ in scrolled containers and when the container is scaled with CSS transforms
97
+ (for example by a pan/zoom library).
98
+ - The overlay is the container's first child, so it is painted below positioned
99
+ elements that come after it. Set `z-index` on `.arc-svg` to change that.
100
+
101
+ ## API
102
+
103
+ ### `new Arclace(options?)`
104
+
105
+ | Option | Type | Default | Description |
106
+ | ------------ | ----------------------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | `container` | `Element \| string` | `document.body` | The element the overlay is added to. |
108
+ | `autoUpdate` | `boolean \| 'frame'` | `true` | `true` redraws on window resize, scroll, element resize and DOM/style changes in the container. `'frame'` redraws every animation frame. `false` only redraws when you call `update()`. |
109
+ | `defaults` | [Connection options](#connection-options) | `{}` | Defaults for every connection made by this instance. |
110
+ | `className` | `string` | | Extra classes for the overlay. |
111
+
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. |
124
+
125
+ ### `Connection`
126
+
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. |
136
+
137
+ A connection is hidden while one of its elements is detached or `display: none`,
138
+ and shown again when it comes back.
139
+
140
+ ### Connection options
141
+
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. |
162
+
163
+ The path builders `bezierPath`, `straightPath` and `orthogonalPath` are also
164
+ exported if you want to draw lines between points yourself.
165
+
166
+ ## Styling
167
+
168
+ Each connection is rendered as:
169
+
170
+ ```html
171
+ <g
172
+ class="arc-connection arc-bezier"
173
+ data-type="bezier"
174
+ data-start-side="right"
175
+ data-stop-side="left"
176
+ >
177
+ <marker class="arc-marker">…</marker>
178
+ <!-- arrow -->
179
+ <path class="arc-path" />
180
+ <text class="arc-label">…</text>
181
+ <!-- label -->
182
+ <circle class="arc-anchor arc-anchor-start" />
183
+ <!-- anchors -->
184
+ <circle class="arc-anchor arc-anchor-stop" />
185
+ </g>
186
+ ```
187
+
188
+ Lines, arrows and anchors use `currentColor`, so `color` on `.arc-connection`
189
+ colors all of them:
190
+
191
+ ```css
192
+ .arc-connection {
193
+ color: #6e625e;
194
+ }
195
+
196
+ .arc-connection.important {
197
+ color: #0054f0;
198
+ }
199
+
200
+ .arc-path {
201
+ stroke-width: 3;
202
+ }
203
+ ```
204
+
205
+ `style.css` is optional. It adds a halo behind labels, hollow anchors and the
206
+ `animated` dash animation (turned off with `prefers-reduced-motion`), and these
207
+ custom properties:
208
+
209
+ | Property | Default |
210
+ | ------------------- | -------------- |
211
+ | `--arc-color` | `currentColor` |
212
+ | `--arc-label-color` | `currentColor` |
213
+ | `--arc-label-halo` | `#fff` |
214
+ | `--arc-label-size` | `12px` |
215
+ | `--arc-anchor-fill` | `#fff` |
216
+
217
+ ### Clickable lines
218
+
219
+ The overlay ignores the pointer so it never blocks your page. To make lines
220
+ clickable, turn pointer events back on for the paths:
221
+
222
+ ```css
223
+ .arc-path {
224
+ pointer-events: visibleStroke;
225
+ cursor: pointer;
226
+ }
227
+ ```
228
+
229
+ ```ts
230
+ connection.path.addEventListener('click', () => console.log(connection.id));
231
+ ```
232
+
233
+ ## Keeping lines in sync
234
+
235
+ With the default `autoUpdate: true`, lines are redrawn (at most once per frame)
236
+ when:
237
+
238
+ - the window resizes or anything scrolls
239
+ - the container or a connected element changes size
240
+ - elements are added or removed in the container, or their `style`, `class` or
241
+ `hidden` attributes change. Dragging by setting `style.left`/`top` or
242
+ `style.transform` just works.
243
+
244
+ For movement it can't observe, like CSS transitions and animations, either call
245
+ `arclace.update()` yourself or use `autoUpdate: 'frame'`.
246
+
247
+ ## With frameworks
248
+
249
+ Create the instance after the elements are mounted and destroy it on unmount. In
250
+ React:
251
+
252
+ ```tsx
253
+ useEffect(() => {
254
+ const arclace = new Arclace({ container: containerRef.current });
255
+
256
+ arclace.connect(aRef.current, bRef.current, { arrow: 'end' });
257
+
258
+ return () => arclace.destroy();
259
+ }, []);
260
+ ```
261
+
262
+ ## Development
263
+
264
+ ```shell
265
+ npm i
266
+ npm run dev # demo at http://localhost:5173
267
+ npm test
268
+ npm run test:ci # with coverage thresholds
269
+ npm run lint
270
+ npm run build # dist/
271
+ npm run check:pack # pack, install and run every example in Chrome
272
+ npm run docs:gen # API docs in docs/api/
273
+ npm run docs:dev # docs site at http://localhost:5173/arclace/
274
+ ```
275
+
276
+ ## Background
277
+
278
+ Arclace comes from [SPECCER](https://speccer.dev). While building SPECCER, I
279
+ spent most of the time on my own SVG feature for drawing the lines between its
280
+ pins and the elements they point at, with bezier curves shaped into curly
281
+ brackets.
282
+
283
+ I then found I could reuse that code to give a better overview of design tokens
284
+ and how they relate to one another. The first public proof of concept is
285
+ [on CodePen](https://codepen.io/editor/phun-ky/pen/01783ae7-e010-76d8-9429-43a7be9da34f).
286
+ After years of other work taking priority, I split the line drawing out into
287
+ this package, so it can connect anything on a page.
288
+
289
+ ## Why Arclace?
290
+
291
+ Arclace combines **arc** and **lace**: the curve of a line, and the act of
292
+ threading separate things together.
293
+
294
+ **Arc** reflects the library's visual character and its origins in
295
+ [SPECCER](https://speccer.dev). There, curved SVG lines formed curly brackets
296
+ between annotation pins and the HTML elements they described. The same drawing
297
+ code later found another use: showing how design tokens relate to each other.
298
+
299
+ **Lace** captures the broader purpose: joining elements with visible threads,
300
+ the way a lace runs through eyelets. Move, resize, scroll or zoom an element,
301
+ and the lace follows. Whether a connection curves, runs straight or turns a
302
+ corner, it makes a relationship visible.
303
+
304
+ Together, the words tie the library's drawing roots to its wider role in
305
+ diagrams, node editors, flowcharts and annotated interfaces. And it reads
306
+ naturally in code:
307
+
308
+ ```js
309
+ new Arclace({ container: '#diagram' });
310
+ ```
311
+
312
+ Pronounced "ARK-lays".
313
+
314
+ ## License
315
+
316
+ [MIT](LICENSE) Β© 2021-2026 Alexander Vassbotn RΓΈyne-Helgesen