@yaks/diagram 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +222 -2
- package/_dist/ink.d.ts +30 -0
- package/_dist/ink.d.ts.map +1 -0
- package/_dist/layout.d.ts +92 -0
- package/_dist/layout.d.ts.map +1 -0
- package/_dist/mod.d.ts +20 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/mount.d.ts +55 -0
- package/_dist/mount.d.ts.map +1 -0
- package/_dist/pen.d.ts +50 -0
- package/_dist/pen.d.ts.map +1 -0
- package/_dist/shape.d.ts +44 -0
- package/_dist/shape.d.ts.map +1 -0
- package/_dist/steer.d.ts +13 -0
- package/_dist/steer.d.ts.map +1 -0
- package/_dist/styles.d.ts +25 -0
- package/_dist/styles.d.ts.map +1 -0
- package/_dist/svg.d.ts +22 -0
- package/_dist/svg.d.ts.map +1 -0
- package/_dist/tangle.d.ts +25 -0
- package/_dist/tangle.d.ts.map +1 -0
- package/_dist/view.d.ts +20 -0
- package/_dist/view.d.ts.map +1 -0
- package/deno.json +1 -0
- package/geometry.js +42 -0
- package/geometry.js.map +1 -0
- package/geometry.ts +44 -0
- package/ink.js +43 -0
- package/ink.js.map +1 -0
- package/ink.ts +61 -0
- package/layout.js +1048 -0
- package/layout.js.map +1 -0
- package/layout.ts +981 -0
- package/layout_bench.ts +27 -0
- package/mod.js +20 -0
- package/mod.js.map +1 -0
- package/mod.ts +20 -0
- package/mount.js +177 -0
- package/mount.js.map +1 -0
- package/mount.ts +205 -0
- package/package.json +18 -4
- package/pen.js +106 -0
- package/pen.js.map +1 -0
- package/pen.ts +130 -0
- package/shape.js +233 -0
- package/shape.js.map +1 -0
- package/shape.ts +204 -0
- package/steer.js +132 -0
- package/steer.js.map +1 -0
- package/steer.ts +112 -0
- package/styles.js +110 -0
- package/styles.js.map +1 -0
- package/styles.ts +110 -0
- package/svg.js +119 -0
- package/svg.js.map +1 -0
- package/svg.ts +193 -0
- package/tangle.js +151 -0
- package/tangle.js.map +1 -0
- package/tangle.ts +153 -0
- package/view.js +63 -0
- package/view.js.map +1 -0
- package/view.ts +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Jeff Peterson
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,223 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yaks/diagram
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Draws the [entities](../graph/README.md#data-model) a query selects, and the
|
|
4
|
+
references between them, as SVG. A drawing keeps each entity where it was as the
|
|
5
|
+
graph changes, so what a write adds is drawn in beside what it names.
|
|
6
|
+
|
|
7
|
+
- `layout(bundles, options?)` places a selection. It is pure: bundles in, a
|
|
8
|
+
`Layout` of nodes and links with positions out.
|
|
9
|
+
- `svg(layout, options?)` draws a layout as one `<svg>` string.
|
|
10
|
+
- `tangles(layout)` lists what makes a layout hard to read, as `svg()` draws it,
|
|
11
|
+
and `knots(layout, only?)` says what each involves. Both are pure.
|
|
12
|
+
- `progress(layout, reached)` and `tip(layout, drawn)` say how far a pen has
|
|
13
|
+
drawn each part as a reader moves through a story, and where the pen is. Both
|
|
14
|
+
are pure.
|
|
15
|
+
- `ink(svg, layout, drawn)` puts that on a drawing in a page.
|
|
16
|
+
- `mount(sheet, { graph, query })` keeps an element drawing a graph's answer to
|
|
17
|
+
a query, again after every commit.
|
|
18
|
+
- `css` is the stylesheet a drawing is meant to wear.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { layout, svg } from '@yaks/diagram'
|
|
22
|
+
import { assert, assertEquals } from '@std/assert'
|
|
23
|
+
|
|
24
|
+
let book = { entity: { eid: '0a' }, doc: { title: 'Dune' } }
|
|
25
|
+
let review = { entity: { eid: '0b' }, review: { of: '0a', stars: 5 } }
|
|
26
|
+
let drawn = layout([book, review])
|
|
27
|
+
assertEquals(drawn.links.map((l) => l.name), ['review.of'])
|
|
28
|
+
assert(svg(drawn).includes('>Dune</text>'))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## What is drawn
|
|
32
|
+
|
|
33
|
+
A **node** is an entity drawn as a shape: its short id (`label`), its title, and
|
|
34
|
+
its components. The title is `doc.title`, else the first line of `doc.body`,
|
|
35
|
+
else `file.path`, cut to fit its shape. The components `entity`, `created` and
|
|
36
|
+
`updated` are left off the list (`quiet` changes that).
|
|
37
|
+
|
|
38
|
+
Its shape comes from its components (`SHAPES`, or `options.shapes`): a person is
|
|
39
|
+
a circle, a persona or session a hexagon, a comment a note with a folded corner,
|
|
40
|
+
and anything else a box. A component's `status` (a task's) is written at the
|
|
41
|
+
box's top right beside a mark.
|
|
42
|
+
|
|
43
|
+
A **link** is a line between two drawn entities. It is one of:
|
|
44
|
+
|
|
45
|
+
- an entity with `edge{from, to}`, drawn as a line rather than a box, with a
|
|
46
|
+
diamond, its other components as its name (`contains`, `requires`) and its
|
|
47
|
+
short id;
|
|
48
|
+
- a property whose value, or one of whose values, is another drawn entity's eid,
|
|
49
|
+
named `comp.prop` (`comment.target`). `updated` and every `via` are not drawn,
|
|
50
|
+
since they would join everything to its writer.
|
|
51
|
+
|
|
52
|
+
A reference to an entity outside the selection draws nothing, so the query
|
|
53
|
+
decides how much of the graph is on the sheet.
|
|
54
|
+
|
|
55
|
+
## Places
|
|
56
|
+
|
|
57
|
+
`layout(bundles, { was })` keeps every entity of `was` where it was, with its
|
|
58
|
+
`order`, and every line between two of them keeps its bend and the place of its
|
|
59
|
+
name. A new entity `at` gives a place (fractions of the sheet's width and
|
|
60
|
+
height, by its eid, label or bundle) goes there. Each other new entity is placed
|
|
61
|
+
one at a time, the one with the most lines to what is already placed first, at
|
|
62
|
+
the cheapest free spot. A spot costs more when:
|
|
63
|
+
|
|
64
|
+
- it is within `APART` of another shape;
|
|
65
|
+
- a line already drawn runs through it, or one of its own lines would cross a
|
|
66
|
+
line, run through a shape, or leave a shape at nearly the angle of another;
|
|
67
|
+
- its lines are far from about 110 long between the shapes' rims, or too short
|
|
68
|
+
to write their names on;
|
|
69
|
+
- a shape already placed cannot be reached from it in a straight line, since a
|
|
70
|
+
later line to it would cross something;
|
|
71
|
+
- it is far from the sheet's middle, or below the sheet's bottom.
|
|
72
|
+
|
|
73
|
+
An actor (a round or hex shape: a person, persona or session) keeps to a side of
|
|
74
|
+
the sheet, the one with fewer actors, so what names both lands between them.
|
|
75
|
+
When no spot is free the sheet grows downward, so `height` can come back larger
|
|
76
|
+
than asked. An entity that leaves the selection gives up its place.
|
|
77
|
+
|
|
78
|
+
A line is straight unless something is in its way: once both its ends are placed
|
|
79
|
+
it takes the `bend` (how far its middle sits to one side) that runs through no
|
|
80
|
+
shape, crosses fewest lines and keeps clear of the lines beside it. Its `mid` is
|
|
81
|
+
how far along it its name is written, the spot nearest the middle that covers no
|
|
82
|
+
shape and no other name.
|
|
83
|
+
|
|
84
|
+
`tangles(layout)` names what is still tangled, with the short ids it involves:
|
|
85
|
+
shapes too close, a line through a shape, lines that cross or run over each
|
|
86
|
+
other, and a name written on a shape or another name. `knots(layout, only?)`
|
|
87
|
+
gives the same, each with the keys of the shapes and lines it involves (a node's
|
|
88
|
+
eid, a link's key), and with `only` just those that involve one of them.
|
|
89
|
+
|
|
90
|
+
### Making room
|
|
91
|
+
|
|
92
|
+
When a newcomer's lines are tangled from the spot it took, the layout tries
|
|
93
|
+
again, judging each arrangement by `knots`, and keeps the first in which nothing
|
|
94
|
+
that joined or moved is tangled:
|
|
95
|
+
|
|
96
|
+
1. the newcomer at its other spots, those whose lines route clear first, and
|
|
97
|
+
along the foot of the drawing nearest what it names, where what is outside
|
|
98
|
+
everything can reach round it;
|
|
99
|
+
2. then an entity in its way moved 40, 80 and then 120 units, away from the
|
|
100
|
+
newcomer's spot first, with the newcomer at each of those spots again.
|
|
101
|
+
|
|
102
|
+
In its way is what the newcomer's tangles involve, and what names two of the
|
|
103
|
+
entities it names, and so wants the same spot. When no arrangement is clear, the
|
|
104
|
+
one that adds fewest tangles wins, then the one that moves least. Each
|
|
105
|
+
arrangement draws the whole drawing again, so a drawing of n entities tries at
|
|
106
|
+
most 4000 / n² of them: 40 of ten, and none of more than 63.
|
|
107
|
+
|
|
108
|
+
A node that moved keeps its `order` and `stage`, and `moved` says where it was;
|
|
109
|
+
each line to it is drawn again, and its `moved` holds the bend and the place of
|
|
110
|
+
its name it had.
|
|
111
|
+
|
|
112
|
+
The placement is greedy and, but for making room, keeps what is placed, so it
|
|
113
|
+
cannot foresee a line that arrives later between two entities already placed; a
|
|
114
|
+
bend is how such a line gets around. Libraries were weighed for this: dagre and
|
|
115
|
+
elkjs lay out a whole graph at once, so what is placed moves as the graph grows,
|
|
116
|
+
and d3-force can hold placed nodes still but does not weigh crossings.
|
|
117
|
+
|
|
118
|
+
Every node and link carries `fresh`, true when it joined in this layout, and
|
|
119
|
+
`stage`, the `options.stage` it joined in (default 0).
|
|
120
|
+
|
|
121
|
+
`label` names a bundle's short id. Its default is the eid's handle
|
|
122
|
+
(`#a3f19c024b`); `mount` passes [@yaks/id](../id/README.md)'s `human(vocab)`, so
|
|
123
|
+
a numbered task reads `T-7`.
|
|
124
|
+
|
|
125
|
+
## The drawing
|
|
126
|
+
|
|
127
|
+
`svg()` emits classes and custom properties, never colours:
|
|
128
|
+
|
|
129
|
+
| class | what it is |
|
|
130
|
+
| ---------------------------------------------------- | -------------------------------------------------------------------- |
|
|
131
|
+
| `Diagram` | the `<svg>` (or `options.class`) |
|
|
132
|
+
| `Diagram_Node`, `-box` / `-round` / `-hex` / `-note` | a shape's group, with `data-key`, `data-eid` and `data-comps` |
|
|
133
|
+
| `Diagram_Fill`, `Diagram_Stroke` | a shape's inside and outline |
|
|
134
|
+
| `Diagram_Id`, `Diagram_Title`, `Diagram_Comps` | a shape's three lines of text |
|
|
135
|
+
| `Diagram_Mark`, `Diagram_State`, `is-<status>` | a status's mark and word |
|
|
136
|
+
| `Diagram_Link`, `-edge` / `-ref` | a line's group, with `data-key`, `data-from`, `data-to`, `data-name` |
|
|
137
|
+
| `Diagram_Line`, `Diagram_Name`, `Diagram_Sub` | a line, its name and an edge's short id |
|
|
138
|
+
| `Diagram_Dia` | an edge's diamond |
|
|
139
|
+
| `Diagram_Pen` | the pen, hidden until `ink()` puts it on a stroke |
|
|
140
|
+
| `is-new`, `--i` | joined in this layout; `--i` is its turn to be drawn |
|
|
141
|
+
| `is-moved` | a shape that moved in this layout to make room |
|
|
142
|
+
|
|
143
|
+
Each stroke has `pathLength="1"`, so a stylesheet draws it in with
|
|
144
|
+
`stroke-dashoffset`. `css` does that: each new shape, then the lines to it, is
|
|
145
|
+
drawn in one after another like a pen. It reads `--diagram-line`,
|
|
146
|
+
`--diagram-soft`, `--diagram-fill`, `--diagram-paper`, `--diagram-glow`,
|
|
147
|
+
`--diagram-font` and `--diagram-pen` (a stroke's duration), and draws nothing in
|
|
148
|
+
under `prefers-reduced-motion`.
|
|
149
|
+
|
|
150
|
+
What moved to make room glides there from where it was, easing in and out over
|
|
151
|
+
0.9 s, so a reader's eye can follow it: a shape with `is-moved` and an
|
|
152
|
+
`<animateTransform>`, each line to it with an `<animate>` of its path, and the
|
|
153
|
+
line's name carried along. SMIL is used because CSS cannot animate a path's `d`
|
|
154
|
+
in every browser. `svg(layout, { still: true })` draws it where it is, and
|
|
155
|
+
`mount` passes `still` under `prefers-reduced-motion`.
|
|
156
|
+
|
|
157
|
+
## Drawing it in as a reader goes
|
|
158
|
+
|
|
159
|
+
A page that tells a story in stages (steps a reader scrolls through) stamps what
|
|
160
|
+
each stage adds with `stage`, then says how far each stage has come in:
|
|
161
|
+
|
|
162
|
+
- `progress(layout, reached)` gives each item (by its key: a node's eid, a
|
|
163
|
+
link's key) how far it is drawn, 0 to 1, when stage `s` has come `reached(s)`
|
|
164
|
+
of the way. A stage's items are drawn one after another, each shape followed
|
|
165
|
+
by the lines that now reach it (`strokes`).
|
|
166
|
+
- `tip(layout, drawn)` is where the pen is: the latest item still being drawn,
|
|
167
|
+
as far along its outline or line as it has come, with its `stage`, so a page
|
|
168
|
+
can point from the step to the part it draws.
|
|
169
|
+
- `ink(svg, layout, drawn)` puts it on a drawing in a page: each item gets
|
|
170
|
+
`is-gone`, `is-drawing` or `is-drawn` and its stroke's dash offset, and the
|
|
171
|
+
pen moves to the tip. The drawing gets `is-inked`, which turns off the
|
|
172
|
+
time-driven drawing in of `css`.
|
|
173
|
+
|
|
174
|
+
## Mounting
|
|
175
|
+
|
|
176
|
+
`mount(sheet, { graph, query, width?, height?, at?, shapes?, stage?, drawn?, failed?, steered?, viewed? })`
|
|
177
|
+
writes the drawing into `sheet.innerHTML` and draws again after every commit,
|
|
178
|
+
seen through an `effect` hook on the graph (one per graph, however many
|
|
179
|
+
drawings). Commits that land while it reads are drawn by one more read. It
|
|
180
|
+
returns:
|
|
181
|
+
|
|
182
|
+
- `query(q, stage?)`: draw another query's answer, keeping the places of what
|
|
183
|
+
both select. It refuses as the graph refuses the query, and the old drawing
|
|
184
|
+
stays.
|
|
185
|
+
- `redraw()`: read and draw again.
|
|
186
|
+
- `layout`: the layout last drawn.
|
|
187
|
+
- `view` and `show(view)`: the part of the sheet in view, and showing another
|
|
188
|
+
(`undefined` shows all of it).
|
|
189
|
+
- `stop()`: stop following the graph and the reader's gestures.
|
|
190
|
+
|
|
191
|
+
`stage()` is asked as each commit lands, and what the commit adds is stamped
|
|
192
|
+
with its answer. `drawn(layout)` is told each layout once it is in the sheet.
|
|
193
|
+
`failed(err)` is told when a redraw after a commit fails; its default is
|
|
194
|
+
`reportError`.
|
|
195
|
+
|
|
196
|
+
A page wires clicks itself, from `data-eid` on the box it reaches.
|
|
197
|
+
|
|
198
|
+
## Zooming and panning
|
|
199
|
+
|
|
200
|
+
A **view** is the part of the sheet in view, `[x, y, width, height]` in the
|
|
201
|
+
sheet's units. `zoom(layout, view, k, [fx, fy])` zooms by `k` about a point
|
|
202
|
+
given as fractions of the view, which stays where it is;
|
|
203
|
+
`pan(layout, view,
|
|
204
|
+
dx, dy)` moves it. Both are pure and keep the view on the
|
|
205
|
+
sheet, between all of it and a sixth of it across. `whole(layout)` is all of it,
|
|
206
|
+
`zoomed(layout,
|
|
207
|
+
view)` says whether less is shown, and `within(view, point)`
|
|
208
|
+
says where a point of the sheet is, as fractions of the view.
|
|
209
|
+
|
|
210
|
+
A drawing mounted in a page is steered by its reader
|
|
211
|
+
(`steer(el, { layout,
|
|
212
|
+
view, set })`, unless `steered: false`):
|
|
213
|
+
|
|
214
|
+
- a pinch, on a touch screen or a trackpad (which a browser reports as a wheel
|
|
215
|
+
with ctrl held), or ctrl-scroll, zooms about where it happens;
|
|
216
|
+
- a drag pans, once zoomed in;
|
|
217
|
+
- plain scrolling scrolls the page, and so does one finger on a drawing shown
|
|
218
|
+
whole (`touch-action: pan-x pan-y`, `none` once zoomed);
|
|
219
|
+
- the click that ends a drag or a pinch is stopped before it reaches the page.
|
|
220
|
+
|
|
221
|
+
The sheet gets `is-zoomed` while zoomed in, and `css` gives it a grab cursor.
|
|
222
|
+
What is in view is kept as the graph changes, and `viewed(view)` is told each
|
|
223
|
+
time it changes, so what a page draws over the drawing can follow it.
|
package/_dist/ink.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Layout } from "./layout.js";
|
|
2
|
+
import { type Tip } from "./pen.js";
|
|
3
|
+
/** The part of a DOM element ink() uses. */ export type Inked = {
|
|
4
|
+
querySelectorAll(selector: string): Iterable<Inked>;
|
|
5
|
+
querySelector(selector: string): Inked | null;
|
|
6
|
+
getAttribute(name: string): string | null;
|
|
7
|
+
setAttribute(name: string, value: string): void;
|
|
8
|
+
classList: {
|
|
9
|
+
add(c: string): void;
|
|
10
|
+
toggle(c: string, on: boolean): void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Draw each item of `svg` (a drawing of `layout`) as far as `drawn` says,
|
|
15
|
+
* by its `data-key`, and put the pen at the tip. An item `drawn` leaves out is
|
|
16
|
+
* drawn whole. Returns the tip, if a stroke is part drawn.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { ink, layout, progress, svg } from '@yaks/diagram'
|
|
20
|
+
* import { parseHTML } from 'linkedom'
|
|
21
|
+
* import { equal } from '@yaks/testing'
|
|
22
|
+
*
|
|
23
|
+
* let drawn = layout([{ entity: { eid: '0a' }, doc: { title: 'Dune' } }])
|
|
24
|
+
* let { document } = parseHTML(`<div>${svg(drawn)}</div>`)
|
|
25
|
+
* let sheet = document.querySelector('svg')!
|
|
26
|
+
* equal(ink(sheet as never, drawn, progress(drawn, () => .5))?.key, '0a')
|
|
27
|
+
* equal(sheet.querySelector('[data-key="0a"]')!.classList.contains('is-drawing'), true)
|
|
28
|
+
* ```
|
|
29
|
+
*/ export declare let ink: (svg: Inked, layout: Layout, drawn: Map<string, number>) => Tip | undefined;
|
|
30
|
+
//# sourceMappingURL=ink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink.d.ts","sources":["../ink.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,sBAAqB;AACzC,SAAS,KAAK,GAAG,mBAAuB;AAExC,0CAA0C,GAC1C,YAAY;EACV,iBAAiB,UAAU,MAAM,GAAG,SAAS;EAC7C,cAAc,UAAU,MAAM,GAAG,QAAQ,IAAI;EAC7C,aAAa,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI;EACzC,aAAa,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,IAAI;EAC/C;IAAa,IAAI,GAAG,MAAM,GAAG,IAAI;IAAE,OAAO,GAAG,MAAM,EAAE,IAAI,OAAO,GAAG,IAAI;;;AAGzE;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,MACT,KAAK,OACL,QAAQ,QACR,OAAO,IAAI,MAAM,EAAE,MAAM,MACxB,MAAM,SAAS,CAuBjB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Bundle } from "@yaks/graph";
|
|
2
|
+
import { type Shape } from "./shape.js";
|
|
3
|
+
/** An entity drawn as a shape. */ export type Node = {
|
|
4
|
+
eid: string;
|
|
5
|
+
/** The short id a person reads: a human id, or the eid's handle. */ label: string;
|
|
6
|
+
/** What the entity says it is (the drawing cuts it to fit). */ title: string;
|
|
7
|
+
/** Its components, without the bookkeeping ones (`quiet`). */ comps: string[];
|
|
8
|
+
/** Its outline (`shapes`). */ shape: Shape;
|
|
9
|
+
/** A `status` one of its components carries, such as a task's. */ state?: string;
|
|
10
|
+
/** When it joined the drawing: 0 for the first entity ever drawn. */ order: number;
|
|
11
|
+
/** The stage of the story it joined in (`Options.stage`). */ stage: number;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
/** Joined the drawing in this layout. */ fresh: boolean;
|
|
15
|
+
/** Where it was before, when it moved in this layout to make room for a
|
|
16
|
+
* newcomer. */ moved?: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** A line between two drawn entities: an `edge{from, to}` entity, named by
|
|
22
|
+
* its other components, or a property holding the other's eid, named
|
|
23
|
+
* `comp.prop`. */ export type Link = {
|
|
24
|
+
key: string;
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
name: string;
|
|
28
|
+
/** The edge entity, and its short id, for a line that is one. */ eid?: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
/** How far aside its middle bends, to keep clear of other shapes and
|
|
31
|
+
* lines: to the left going from `from` to `to`, or the right when
|
|
32
|
+
* negative. */ bend: number;
|
|
33
|
+
/** How far along its curve its name is written, 0 to 1, clear of shapes
|
|
34
|
+
* and other names. */ mid: number;
|
|
35
|
+
order: number;
|
|
36
|
+
stage: number;
|
|
37
|
+
fresh: boolean;
|
|
38
|
+
/** Its bend and the place of its name before, when an end of it moved in
|
|
39
|
+
* this layout. */ moved?: {
|
|
40
|
+
bend: number;
|
|
41
|
+
mid: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/** A drawing's sheet, entities and lines. */ export type Layout = {
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
nodes: Node[];
|
|
48
|
+
links: Link[];
|
|
49
|
+
};
|
|
50
|
+
/** How a selection is laid out. */ export type Options = {
|
|
51
|
+
/** The previous layout: its entities keep their places. */ was?: Layout;
|
|
52
|
+
/** The sheet's size; it grows downward when the entities need room. */ width?: number;
|
|
53
|
+
height?: number;
|
|
54
|
+
/** The short id of a bundle (default: its eid's handle, `#a3f19c024b`). */ label?: (bundle: Bundle) => string;
|
|
55
|
+
/** Components left off a node's list (default: entity, created, updated). */ quiet?: readonly string[];
|
|
56
|
+
/** The shape each component draws its entity as (default `SHAPES`). */ shapes?: Record<string, Shape>;
|
|
57
|
+
/** Where a newcomer goes, as fractions of the sheet's width and height,
|
|
58
|
+
* when its place is known beforehand; any other takes the cheapest spot. */ at?: (node: {
|
|
59
|
+
eid: string;
|
|
60
|
+
label: string;
|
|
61
|
+
bundle: Bundle;
|
|
62
|
+
}) => [number, number] | undefined;
|
|
63
|
+
/** The stage what joins now is stamped with (default 0), so a page can draw
|
|
64
|
+
* each stage in as its reader reaches it. */ stage?: number;
|
|
65
|
+
};
|
|
66
|
+
/** `#` and the eid's first ten hex digits, the handle @yaks/id shows. */ export declare let handle: (eid: string) => string;
|
|
67
|
+
/** A line of at most n characters, ending in an ellipsis when cut. */ export declare let cut: (text: string, n: number) => string;
|
|
68
|
+
type Line = Omit<Link, 'order' | 'fresh' | 'stage' | 'label' | 'bend' | 'mid'>;
|
|
69
|
+
/** The lines a selection draws: each edge entity, and every property that
|
|
70
|
+
* names another selected entity. A line to an entity outside the selection is
|
|
71
|
+
* not drawn. */ export declare let links: (bundles: Bundle[]) => Line[];
|
|
72
|
+
/**
|
|
73
|
+
* Lay out a selection. Entities in `was` keep their places and order, and
|
|
74
|
+
* lines between them their bends; each new one takes the cheapest free spot,
|
|
75
|
+
* clear of the lines and shapes there, and each new line bends around what is
|
|
76
|
+
* in its way. When a newcomer has no spot clear of tangles, an entity in its
|
|
77
|
+
* way moves as little as it must, and says where it was in `moved`. A
|
|
78
|
+
* selection too big for the sheet gets a larger one of the same shape, and
|
|
79
|
+
* the sheet grows downward when nothing on it is free.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { layout } from '@yaks/diagram'
|
|
83
|
+
* import { equal } from '@yaks/testing'
|
|
84
|
+
*
|
|
85
|
+
* let a = { entity: { eid: '0a' }, doc: { title: 'Buy the cake' } }
|
|
86
|
+
* let b = { entity: { eid: '0b' }, comment: { target: '0a' } }
|
|
87
|
+
* let drawn = layout([a, b])
|
|
88
|
+
* equal(drawn.links.map((l) => l.name), ['comment.target'])
|
|
89
|
+
* equal(layout([a, b], { was: drawn }).nodes[0].x, drawn.nodes[0].x)
|
|
90
|
+
* ```
|
|
91
|
+
*/ export declare let layout: (bundles: Bundle[], opts?: Options) => Layout;
|
|
92
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sources":["../layout.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,2BAAgC;AAGpD,SAOE,KAAK,KAAK,qBAIO;AAEnB,gCAAgC,GAChC,YAAY;EACV,KAAK,MAAM;EACX,kEAAkE,GAClE,OAAO,MAAM;EACb,6DAA6D,GAC7D,OAAO,MAAM;EACb,4DAA4D,GAC5D,OAAO,MAAM;EACb,4BAA4B,GAC5B,OAAO;EACP,gEAAgE,GAChE,QAAQ,MAAM;EACd,mEAAmE,GACnE,OAAO,MAAM;EACb,2DAA2D,GAC3D,OAAO,MAAM;EACb,GAAG,MAAM;EACT,GAAG,MAAM;EACT,uCAAuC,GACvC,OAAO,OAAO;EACd;eACa,GACb;IAAU,GAAG,MAAM;IAAE,GAAG,MAAM;;;AAGhC;;gBAEgB,GAChB,YAAY;EACV,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,+DAA+D,GAC/D,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd;;eAEa,GACb,MAAM,MAAM;EACZ;sBACoB,GACpB,KAAK,MAAM;EACX,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,OAAO;EACd;kBACgB,GAChB;IAAU,MAAM,MAAM;IAAE,KAAK,MAAM;;;AAGrC,2CAA2C,GAC3C,YAAY;EACV,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,OAAO;EACP,OAAO;;AAGT,iCAAiC,GACjC,YAAY;EACV,yDAAyD,GACzD,MAAM;EACN,qEAAqE,GACrE,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,yEAAyE,GACzE,SAAS,QAAQ,WAAW,MAAM;EAClC,2EAA2E,GAC3E,iBAAiB,MAAM;EACvB,qEAAqE,GACrE,SAAS,OAAO,MAAM,EAAE;EACxB;4EAC0E,GAC1E,MACE;IAAQ,KAAK,MAAM;IAAE,OAAO,MAAM;IAAE,QAAQ;SACxC,MAAM,EAAE,MAAM,IAAI,SAAS;EACjC;6CAC2C,GAC3C,QAAQ,MAAM;;AAOhB,uEAAuE,GACvE,OAAO,YAAI,SAAU,KAAK,MAAM,KAAG,MAAM,CACiB;AAE1D,oEAAoE,GACpE,OAAO,YAAI,MAAO,MAAM,MAAM,EAAE,GAAG,MAAM,KAAG,MAAM,CACa;KAyB1D,OAAO,KACV,MACA,UAAU,UAAU,UAAU,UAAU,SAAS;AAGnD;;cAEc,GACd,OAAO,YAAI,QAAS,SAAS,aAAW,OA+BvC;AA6XD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,SAAU,SAAS,UAAU,OAAM,YAAe,OAyI5D"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/diagram — the entities a query selects, and the references between
|
|
3
|
+
* them, drawn as SVG. {@link layout} places them (pure), {@link svg} draws a
|
|
4
|
+
* layout as markup (pure), {@link progress} and {@link tip} say how far a pen
|
|
5
|
+
* has drawn each part as a reader moves through a story (pure), {@link ink}
|
|
6
|
+
* puts that on a drawing in a page, and {@link mount} keeps an element
|
|
7
|
+
* drawing a graph's answer as the graph changes.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/ export * from "./layout.js";
|
|
11
|
+
export * from "./shape.js";
|
|
12
|
+
export * from "./svg.js";
|
|
13
|
+
export * from "./pen.js";
|
|
14
|
+
export * from "./ink.js";
|
|
15
|
+
export * from "./mount.js";
|
|
16
|
+
export * from "./styles.js";
|
|
17
|
+
export * from "./tangle.js";
|
|
18
|
+
export * from "./view.js";
|
|
19
|
+
export * from "./steer.js";
|
|
20
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GACD,4BAA2B;AAC3B,2BAA0B;AAC1B,yBAAwB;AACxB,yBAAwB;AACxB,yBAAwB;AACxB,2BAA0B;AAC1B,4BAA2B;AAC3B,4BAA2B;AAC3B,0BAAyB;AACzB,2BAA0B"}
|
package/_dist/mount.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Graph } from "@yaks/graph";
|
|
2
|
+
import { type Layout, type Options } from "./layout.js";
|
|
3
|
+
import { type SvgOptions } from "./svg.js";
|
|
4
|
+
import { type View } from "./view.js";
|
|
5
|
+
/** What a drawing is drawn into: an element's markup. An element in a page
|
|
6
|
+
* is also steered: zoomed and panned by a reader's gestures. */ export type Sheet = {
|
|
7
|
+
innerHTML: string;
|
|
8
|
+
} | HTMLElement;
|
|
9
|
+
/** What a mounted drawing draws, and how. */ export type MountOptions = SvgOptions & Pick<Options, 'at' | 'shapes'> & {
|
|
10
|
+
graph: Graph;
|
|
11
|
+
/** What is drawn. */ query: string;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
/** The stage a commit belongs to, asked as it commits: what it adds is
|
|
15
|
+
* stamped with it (default 0). */ stage?: () => number;
|
|
16
|
+
/** Told each layout once it is drawn. */ drawn?: (layout: Layout) => void;
|
|
17
|
+
/** Told when a redraw after a commit fails (default: reportError). */ failed?: (err: unknown) => void;
|
|
18
|
+
/** Zoom and pan with a reader's gestures (default true, in a page). */ steered?: boolean;
|
|
19
|
+
/** Told the part of the sheet in view each time it changes. */ viewed?: (view: View) => void;
|
|
20
|
+
};
|
|
21
|
+
/** A mounted drawing. */ export type Mounted = {
|
|
22
|
+
/** Draw another query's answer. What this drawing has drawn before, under
|
|
23
|
+
* any query, keeps its place, order and stage; what it adds is stamped
|
|
24
|
+
* with `stage` (default: `MountOptions.stage`).
|
|
25
|
+
* Settles once drawn, and refuses as the graph refuses the query; the old
|
|
26
|
+
* drawing stays then. */ query: (query: string, stage?: number) => Promise<Layout>;
|
|
27
|
+
/** Read and draw again. */ redraw: () => Promise<Layout>;
|
|
28
|
+
/** The layout last drawn. */ readonly layout: Layout | undefined;
|
|
29
|
+
/** The part of the sheet in view. */ readonly view: View | undefined;
|
|
30
|
+
/** Show another part of the sheet; `undefined` shows all of it. */ show: (view: View | undefined) => void;
|
|
31
|
+
/** Stop following the graph. */ stop: () => void;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Keep `sheet` drawing what `query` selects in `graph`. Commits that land
|
|
35
|
+
* while a read is under way are drawn by one more read, not one each, and a
|
|
36
|
+
* commit that leaves the answer as it was draws nothing.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { graph } from '@yaks/graph'
|
|
40
|
+
* import { ram } from '@yaks/ram'
|
|
41
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
42
|
+
* import { mount } from '@yaks/diagram'
|
|
43
|
+
* import { assert } from '@std/assert'
|
|
44
|
+
*
|
|
45
|
+
* let vocab = loadVocab({ $defs: { doc: { component: true, properties: { title: { type: 'string' } } } } })
|
|
46
|
+
* let g = graph({ vocab, storage: ram(vocab) })
|
|
47
|
+
* let sheet = { innerHTML: '' }
|
|
48
|
+
* let drawing = mount(sheet, { graph: g, query: '.doc' })
|
|
49
|
+
* await g.apply([{ entity: { eid: crypto.randomUUID() }, doc: { title: 'Dune' } }])
|
|
50
|
+
* await drawing.redraw()
|
|
51
|
+
* assert(sheet.innerHTML.includes('Dune'))
|
|
52
|
+
* drawing.stop()
|
|
53
|
+
* ```
|
|
54
|
+
*/ export declare let mount: (sheet: Sheet, opts: MountOptions) => Mounted;
|
|
55
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sources":["../mount.ts"],"names":[],"mappings":"AAMA,cAAsB,KAAK,2BAAgC;AAC3D,SAAS,KAAK,MAAM,EAAU,KAAK,OAAO,sBAAqB;AAC/D,SAAc,KAAK,UAAU,mBAAkB;AAE/C,SAAc,KAAK,IAAI,oBAAkC;AAEzD;8DAC8D,GAC9D,YAAY;EAAU,WAAW,MAAM;IAAK;AAE5C,2CAA2C,GAC3C,YAAY,eAAe,aAAa,KAAK,SAAS,OAAO;EAC3D,OAAO;EACP,mBAAmB,GACnB,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,SAAS,MAAM;EACf;kCACgC,GAChC,cAAc,MAAM;EACpB,uCAAuC,GACvC,SAAS,QAAQ,WAAW,IAAI;EAChC,oEAAoE,GACpE,UAAU,KAAK,OAAO,KAAK,IAAI;EAC/B,qEAAqE,GACrE,UAAU,OAAO;EACjB,6DAA6D,GAC7D,UAAU,MAAM,SAAS,IAAI;;AAG/B,uBAAuB,GACvB,YAAY;EACV;;;;yBAIuB,GACvB,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK,QAAQ;EAClD,yBAAyB,GACzB,cAAc,QAAQ;EACtB,2BAA2B,YAClB,QAAQ,SAAS,SAAS;EACnC,mCAAmC,YAC1B,MAAM,OAAO,SAAS;EAC/B,iEAAiE,GACjE,OAAO,MAAM,OAAO,SAAS,KAAK,IAAI;EACtC,8BAA8B,GAC9B,YAAY,IAAI;;AA+BlB;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,YAAI,QAAS,OAAO,OAAO,MAAM,iBAAe,QAkGtD"}
|