@yaks/canvas 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 +134 -2
- package/_dist/comp.d.ts +50 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/geom.d.ts +25 -0
- package/_dist/geom.d.ts.map +1 -0
- package/_dist/graph.d.ts +3 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/mod.d.ts +56 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/place.d.ts +10 -0
- package/_dist/place.d.ts.map +1 -0
- package/_dist/plugin.d.ts +20 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/search.d.ts +10 -0
- package/_dist/search.d.ts.map +1 -0
- package/_dist/view.d.ts +27 -0
- package/_dist/view.d.ts.map +1 -0
- package/_dist/vocab.d.ts +7 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/comp.js +67 -0
- package/comp.js.map +1 -0
- package/comp.ts +140 -0
- package/deno.json +1 -0
- package/geom.js +38 -0
- package/geom.js.map +1 -0
- package/geom.ts +58 -0
- package/graph.js +8 -0
- package/graph.js.map +1 -0
- package/graph.ts +9 -0
- package/mod.js +56 -0
- package/mod.js.map +1 -0
- package/mod.ts +58 -0
- package/package.json +26 -4
- package/place.js +46 -0
- package/place.js.map +1 -0
- package/place.ts +35 -0
- package/plugin.js +33 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +34 -0
- package/search.js +23 -0
- package/search.js.map +1 -0
- package/search.ts +18 -0
- package/view.js +65 -0
- package/view.js.map +1 -0
- package/view.ts +70 -0
- package/vocab.js +14 -0
- package/vocab.js.map +1 -0
- package/vocab.json +394 -0
- package/vocab.ts +16 -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,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yaks/canvas
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Graph components and geometry helpers for spatial and split-pane interfaces. The
|
|
4
|
+
package defines the stored layout schema; a graph storage adapter persists it.
|
|
5
|
+
Applications render the layout and handle input. An entity is a record
|
|
6
|
+
identified by `entity.eid`; its components are named objects such as
|
|
7
|
+
`pin: {x, y, w, h}`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
deno add jsr:@yaks/canvas
|
|
13
|
+
# or: npx jsr add @yaks/canvas
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Components and graph setup
|
|
17
|
+
|
|
18
|
+
A `canvas` groups spatial content. A `card` references the displayed entity; a
|
|
19
|
+
`pin` gives its position and stacking order. A `camera` stores viewport centre,
|
|
20
|
+
scale and dimensions, and a `cursor` stores the current selection. A `layout`
|
|
21
|
+
groups split-screen `pane`s. A `fold` records collapsed sections, and a `shelf`
|
|
22
|
+
records set-aside items. A `client` identifies an open window.
|
|
23
|
+
|
|
24
|
+
Create an in-memory graph:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { loadVocab } from '@yaks/vocab'
|
|
28
|
+
import { graph } from '@yaks/graph'
|
|
29
|
+
import { canvas, canvasDoc } from '@yaks/canvas'
|
|
30
|
+
import { ram } from '@yaks/ram'
|
|
31
|
+
|
|
32
|
+
let vocab = loadVocab([canvasDoc])
|
|
33
|
+
let g = graph({ storage: ram(vocab), vocab, plugins: [canvas()] })
|
|
34
|
+
await g.apply([{ entity: { eid: 'workspace' }, canvas: {} }])
|
|
35
|
+
let [workspace] = await g.read('.canvas')
|
|
36
|
+
workspace.entity.eid // 'workspace'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Layout state is stored as graph entities, so other clients and tools can query
|
|
40
|
+
and update it through the same graph API as application content.
|
|
41
|
+
|
|
42
|
+
## Reference deletion
|
|
43
|
+
|
|
44
|
+
`card.target` declares `death: cascade`: deleting the referenced entity also
|
|
45
|
+
deletes its card in the graph transaction. The plugin does not add a cleanup
|
|
46
|
+
hook; reference deletion is enforced by the graph vocabulary.
|
|
47
|
+
|
|
48
|
+
## Where each piece lives
|
|
49
|
+
|
|
50
|
+
Every component declares `sync: "server"`, making it eligible for replication to
|
|
51
|
+
the server when the application configures [@yaks/sync](../sync). The schema
|
|
52
|
+
does not establish a network connection by itself.
|
|
53
|
+
|
|
54
|
+
| component | sync | why |
|
|
55
|
+
| --------------------------------------------- | -------- | ---------------------------------------------------- |
|
|
56
|
+
| `canvas`, `card`, `pin` | `server` | shared spatial content |
|
|
57
|
+
| `layout`, `pane` | `server` | a named arrangement, meant to be reopened and shared |
|
|
58
|
+
| `client`, `camera`, `cursor`, `fold`, `shelf` | `server` | per-window, but something else has to read them |
|
|
59
|
+
|
|
60
|
+
Per-window components also sync to the `server`, allowing another client to
|
|
61
|
+
restore or inspect a viewport and tools to update a selection. Applications
|
|
62
|
+
should declare `sync: none` for transient state that should not be replicated,
|
|
63
|
+
such as an in-progress drag.
|
|
64
|
+
|
|
65
|
+
## The geometry is plain functions
|
|
66
|
+
|
|
67
|
+
These functions use numbers without assuming pixels or another unit. They need
|
|
68
|
+
no DOM or transformation matrices, so browser and terminal clients can use the
|
|
69
|
+
same calculations. Below, `camera` is a `Camera` and `pins` are `Pin`s.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { frame, place, visible } from '@yaks/canvas'
|
|
73
|
+
|
|
74
|
+
let pins = [{ x: 0, y: 0, w: 320, h: 200 }, { x: 400, y: 0, w: 320, h: 200 }]
|
|
75
|
+
let camera = { x: 0, y: 0, zoom: 1, w: 1200, h: 800 }
|
|
76
|
+
|
|
77
|
+
visible(camera, pins) // what is on screen — called every frame
|
|
78
|
+
place(pins, { w: 320, h: 200 }) // where the next card goes
|
|
79
|
+
frame(pins, { w: 1200, h: 800 }) // the camera that fits everything
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`place` searches candidate positions left to right, then top to bottom, within
|
|
83
|
+
the existing bounds. If none is free it places the card to the right; an empty
|
|
84
|
+
canvas starts at the origin. The default candidate spacing includes a 24-unit
|
|
85
|
+
gap. The function is deterministic and does not modify the pins.
|
|
86
|
+
|
|
87
|
+
## Exports
|
|
88
|
+
|
|
89
|
+
| export | is |
|
|
90
|
+
| --------------------------------- | ----------------------------------------------------- |
|
|
91
|
+
| `canvasDoc` | the components, to load beside your own |
|
|
92
|
+
| `canvas()` | the @yaks/graph plugin |
|
|
93
|
+
| `CANVAS`, `CARD`, `PIN`, … | their names; `PER_CLIENT` is the per-window set |
|
|
94
|
+
| `Card`, `Pin`, `Camera`, `Cursor` | the component types |
|
|
95
|
+
| `Point`, `Size`, `Rect` | the geometry types |
|
|
96
|
+
| `rect`, `bounds`, `overlaps` | a pin's box, the box around many, whether two overlap |
|
|
97
|
+
| `top(pins)` | the frontmost stacking order in use |
|
|
98
|
+
| `world(camera)` | the part of the plane a camera can see |
|
|
99
|
+
| `visible(camera, pins)` | the pins on screen |
|
|
100
|
+
| `frame(pins, size)` | the camera that fits everything |
|
|
101
|
+
| `place(pins, size)` | where the next card goes |
|
|
102
|
+
| `zoomed`, `ZOOM_MIN`, `ZOOM_MAX` | the one zoom range every camera move shares |
|
|
103
|
+
|
|
104
|
+
## What is deliberately not here
|
|
105
|
+
|
|
106
|
+
**Rendering.** This package records what the pieces are and where they sit;
|
|
107
|
+
drawing them is a client's job, and the two should be replaceable independently.
|
|
108
|
+
|
|
109
|
+
**A `before` ordering.** `before` names another kind, and only a vocabulary that
|
|
110
|
+
combines these components with its own content component can decide which of the
|
|
111
|
+
two wins. A package cannot order itself against a kind it does not ship — it
|
|
112
|
+
would not load on its own.
|
|
113
|
+
|
|
114
|
+
**Layout algorithms.** `place` computes a default position for a new card. A
|
|
115
|
+
client that knows a drop point should use it.
|
|
116
|
+
|
|
117
|
+
## Dependencies
|
|
118
|
+
|
|
119
|
+
A component package over [@yaks/graph](https://jsr.io/@yaks/graph), built the
|
|
120
|
+
same way any application's own plugin is — like
|
|
121
|
+
[@yaks/member](https://jsr.io/@yaks/member) and
|
|
122
|
+
[@yaks/edge](https://jsr.io/@yaks/edge), it uses the public graph plugin
|
|
123
|
+
interface.
|
|
124
|
+
|
|
125
|
+
## Compatibility
|
|
126
|
+
|
|
127
|
+
Pure TypeScript, no platform API — the geometry is arithmetic and the vocabulary
|
|
128
|
+
is JSON. Runs on **Deno**, **Node**, and in the **browser**.
|
|
129
|
+
|
|
130
|
+
## Search-link drops
|
|
131
|
+
|
|
132
|
+
`searchBoard(url, origin)` recognizes a local `/?<query>` link and returns the
|
|
133
|
+
document and live-board specification for a canvas drop. A foreign URL or a
|
|
134
|
+
non-search page is not a board. The search chip carries the ordinary URL; only a
|
|
135
|
+
canvas-enabled drop consumer creates this board.
|
package/_dist/comp.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { VocabDoc } from "@yaks/vocab";
|
|
2
|
+
/** The component naming a wall things are arranged on. */ export declare let CANVAS: string;
|
|
3
|
+
/** The component naming one thing shown on a canvas. */ export declare let CARD: string;
|
|
4
|
+
/** The component naming where a card sits. */ export declare let PIN: string;
|
|
5
|
+
/** The component naming where one window is looking. */ export declare let CAMERA: string;
|
|
6
|
+
/** The component naming one open window. */ export declare let CLIENT: string;
|
|
7
|
+
/** The component naming what one window has open. */ export declare let CURSOR: string;
|
|
8
|
+
/** The component naming a split of the screen into panes. */ export declare let LAYOUT: string;
|
|
9
|
+
/** The component naming one region of a layout. */ export declare let PANE: string;
|
|
10
|
+
/** The component naming the sections one window has collapsed. */ export declare let FOLD: string;
|
|
11
|
+
/** The component naming what one window holds off the canvas. */ export declare let SHELF: string;
|
|
12
|
+
/** The components that describe one window rather than the shared space. */ export declare let PER_CLIENT: string[];
|
|
13
|
+
/** A `card` component: one entity shown on a canvas. */ export type Card = {
|
|
14
|
+
/** the entity this card displays — the card dies with it */ target?: string;
|
|
15
|
+
/** the view the card renders that entity in */ view?: string;
|
|
16
|
+
};
|
|
17
|
+
/** A `pin` component: a card's place on the plane. `x`/`y` are its top-left
|
|
18
|
+
* corner in canvas units; `w`/`h` its size, where `0` means "however big it
|
|
19
|
+
* needs to be"; `z` its place in the stack. */ export type Pin = {
|
|
20
|
+
/** the canvas it is pinned to */ canvas?: string;
|
|
21
|
+
/** left edge, in canvas units */ x?: number;
|
|
22
|
+
/** top edge, in canvas units */ y?: number;
|
|
23
|
+
/** width, or 0 for automatic */ w?: number;
|
|
24
|
+
/** height, or 0 for automatic */ h?: number;
|
|
25
|
+
/** stacking order — higher sits in front */ z?: number;
|
|
26
|
+
};
|
|
27
|
+
/** A `camera` component: where one window is looking at one canvas. `x`/`y`
|
|
28
|
+
* are the centre of the viewport in canvas units, `zoom` its scale, and
|
|
29
|
+
* `w`/`h` the size of the window in screen pixels. */ export type Camera = {
|
|
30
|
+
/** the window doing the looking */ client?: string;
|
|
31
|
+
/** the canvas it is looking at */ canvas?: string;
|
|
32
|
+
/** viewport centre, in canvas units */ x: number;
|
|
33
|
+
/** viewport centre, in canvas units */ y: number;
|
|
34
|
+
/** scale: 2 means everything is drawn twice as large */ zoom: number;
|
|
35
|
+
/** viewport width, in screen pixels */ w: number;
|
|
36
|
+
/** viewport height, in screen pixels */ h: number;
|
|
37
|
+
};
|
|
38
|
+
/** A `cursor` component: what one window currently has open. */ export type Cursor = {
|
|
39
|
+
/** the window */ client?: string;
|
|
40
|
+
/** the entity it is showing */ target?: string;
|
|
41
|
+
/** the view it is showing that entity in */ view?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The canvas vocabulary, to load beside your own:
|
|
45
|
+
* `loadVocab([canvasDoc, ...mine], [idKeywords, nameKeywords])`.
|
|
46
|
+
*
|
|
47
|
+
* It declares nothing about what a card shows — `card.target` points at any
|
|
48
|
+
* entity in your own vocabulary — only where things sit and who is looking.
|
|
49
|
+
*/ export declare let canvasDoc: VocabDoc;
|
|
50
|
+
//# sourceMappingURL=comp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comp.d.ts","sources":["../comp.ts"],"names":[],"mappings":"AAwCA,cAAc,QAAQ,2BAAgC;AAGtD,wDAAwD,GACxD,OAAO,YAAI,eAAiB;AAE5B,sDAAsD,GACtD,OAAO,YAAI,aAAa;AAExB,4CAA4C,GAC5C,OAAO,YAAI,YAAW;AAEtB,sDAAsD,GACtD,OAAO,YAAI,eAAiB;AAE5B,0CAA0C,GAC1C,OAAO,YAAI,eAAiB;AAE5B,mDAAmD,GACnD,OAAO,YAAI,eAAiB;AAE5B,2DAA2D,GAC3D,OAAO,YAAI,eAAiB;AAE5B,iDAAiD,GACjD,OAAO,YAAI,aAAa;AAExB,gEAAgE,GAChE,OAAO,YAAI,aAAa;AAExB,+DAA+D,GAC/D,OAAO,YAAI,cAAe;AAE1B,0EAA0E,GAC1E,OAAO,YAAI,YAAY,MAAM,GAA0C;AAEvE,sDAAsD,GACtD,YAAY;EACV,0DAA0D,GAC1D,SAAS,MAAM;EACf,6CAA6C,GAC7C,OAAO,MAAM;;AAGf;;6CAE6C,GAC7C,YAAY;EACV,+BAA+B,GAC/B,SAAS,MAAM;EACf,+BAA+B,GAC/B,IAAI,MAAM;EACV,8BAA8B,GAC9B,IAAI,MAAM;EACV,8BAA8B,GAC9B,IAAI,MAAM;EACV,+BAA+B,GAC/B,IAAI,MAAM;EACV,0CAA0C,GAC1C,IAAI,MAAM;;AAGZ;;oDAEoD,GACpD,YAAY;EACV,iCAAiC,GACjC,SAAS,MAAM;EACf,gCAAgC,GAChC,SAAS,MAAM;EACf,qCAAqC,GACrC,GAAG,MAAM;EACT,qCAAqC,GACrC,GAAG,MAAM;EACT,sDAAsD,GACtD,MAAM,MAAM;EACZ,qCAAqC,GACrC,GAAG,MAAM;EACT,sCAAsC,GACtC,GAAG,MAAM;;AAGX,8DAA8D,GAC9D,YAAY;EACV,eAAe,GACf,SAAS,MAAM;EACf,6BAA6B,GAC7B,SAAS,MAAM;EACf,0CAA0C,GAC1C,OAAO,MAAM;;AAGf;;;;;;CAMC,GACD,OAAO,YAAI,WAAW,SAAc"}
|
package/_dist/geom.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Pin } from "./comp.js";
|
|
2
|
+
/** A place on the plane. */ export type Point = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
/** How big something is. */ export type Size = {
|
|
7
|
+
w: number;
|
|
8
|
+
h: number;
|
|
9
|
+
};
|
|
10
|
+
/** A box: its top-left corner, and its size. */ export type Rect = Point & Size;
|
|
11
|
+
/**
|
|
12
|
+
* The box a pin occupies. A pin with no position sits at the origin, and one
|
|
13
|
+
* with no size has no extent — which is what a stored `w: 0` means: "however
|
|
14
|
+
* big it needs to be", not yet measured.
|
|
15
|
+
*/ export declare let rect: (p: Pin) => Rect;
|
|
16
|
+
/** Do two boxes share any area? Touching edges do not count — a box placed
|
|
17
|
+
* exactly beside another is beside it, not on it. */ export declare let overlaps: (a: Rect, b: Rect) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The smallest box containing every pin — what "everything on the wall" is,
|
|
20
|
+
* as one rectangle. Nothing pinned has no bounds, so this answers `undefined`
|
|
21
|
+
* rather than inventing an empty box at the origin.
|
|
22
|
+
*/ export declare let bounds: (pins: Pin[]) => Rect | undefined;
|
|
23
|
+
/** The frontmost stacking order in use, or 0 when nothing is pinned — so the
|
|
24
|
+
* next card goes on top at `top(pins) + 1`. */ export declare let top: (pins: Pin[]) => number;
|
|
25
|
+
//# sourceMappingURL=geom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geom.d.ts","sources":["../geom.ts"],"names":[],"mappings":"AAQA,cAAc,GAAG,oBAAmB;AAEpC,0BAA0B,GAC1B,YAAY;EAAU,GAAG,MAAM;EAAE,GAAG,MAAM;;AAE1C,0BAA0B,GAC1B,YAAY;EAAS,GAAG,MAAM;EAAE,GAAG,MAAM;;AAEzC,8CAA8C,GAC9C,YAAY,OAAO,QAAQ;AAE3B;;;;CAIC,GACD,OAAO,YAAI,OAAQ,GAAG,QAAM,KAK1B;AAEF;mDACmD,GACnD,OAAO,YAAI,WAAY,GAAG,MAAM,GAAG,SAAO,OAAO,CACyB;AAE1E;;;;CAIC,GACD,OAAO,YAAI,SAAU,MAAM,UAAQ,OAAO,SAAS,CAWlD;AAED;6CAC6C,GAC7C,OAAO,YAAI,MAAO,MAAM,UAAQ,MAAM,CACW"}
|
package/_dist/graph.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,2BAAgC;AAGpD,kEAAkE,GAClE,OAAO,YAAI,eAAc,SAAsB"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/canvas — the spatial-UI component domain for a
|
|
3
|
+
* {@link https://jsr.io/@yaks/graph | @yaks/graph}: the interface is data.
|
|
4
|
+
*
|
|
5
|
+
* Picture a wall of sticky notes. The wall is a `canvas`; each note is a
|
|
6
|
+
* `card` showing something, and its `pin` records where on the wall it sits.
|
|
7
|
+
* Whoever is looking has a `camera` — a centre, a scale, and the size of
|
|
8
|
+
* their window — and a `cursor` naming what they have open. There is a second
|
|
9
|
+
* way to arrange the same things (`layout` and `pane`, a split of the screen
|
|
10
|
+
* rather than a plane), a `fold` for the sections someone has collapsed, and
|
|
11
|
+
* a `shelf` for what they are holding off the wall.
|
|
12
|
+
*
|
|
13
|
+
* All of it is entities carrying components, which is the whole idea: a layout
|
|
14
|
+
* is stored, queried, shared and undone exactly like the content it frames,
|
|
15
|
+
* and a card is something another window — or a script, or an agent — can
|
|
16
|
+
* read and move. A private view model can do none of that.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
20
|
+
* import { graph } from '@yaks/graph'
|
|
21
|
+
* import { ram } from '@yaks/ram'
|
|
22
|
+
* import { canvas, canvasDoc } from '@yaks/canvas'
|
|
23
|
+
*
|
|
24
|
+
* let vocab = loadVocab([canvasDoc])
|
|
25
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [canvas()] })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## One rule, declared
|
|
29
|
+
* A card is deleted with the thing it shows — `death: cascade` on
|
|
30
|
+
* `card.target`, which the graph enforces in the same transaction as the delete
|
|
31
|
+
* that caused it. There is no hook and no orphan sweep.
|
|
32
|
+
*
|
|
33
|
+
* ## Where each piece lives
|
|
34
|
+
* Every component declares a {@link https://jsr.io/@yaks/vocab | @yaks/vocab}
|
|
35
|
+
* `sync` value, and all of them declare `server`. For the shared ones that is
|
|
36
|
+
* obvious — a wall nobody else can see is not a wall. The per-window ones
|
|
37
|
+
* (`camera`, `cursor`, `fold`, `shelf`, `client`) are the interesting
|
|
38
|
+
* decision: they describe one window, so `sync: none` looks right, and it is
|
|
39
|
+
* wrong. Something other than that window has to read them — a second tab
|
|
40
|
+
* restoring the viewport it left, a directory of who is looking at what, a tool
|
|
41
|
+
* that moves somebody's open card by writing their `cursor`.
|
|
42
|
+
*
|
|
43
|
+
* ## The geometry is plain functions
|
|
44
|
+
* {@link visible} is what a renderer calls every frame, {@link place} computes
|
|
45
|
+
* where the next card goes, and {@link frame} computes the camera that fits
|
|
46
|
+
* everything. They take plain objects and touch no platform API, so a browser
|
|
47
|
+
* canvas and a terminal compute the same result rather than drifting apart.
|
|
48
|
+
*
|
|
49
|
+
* @module
|
|
50
|
+
*/ export * from "./comp.js";
|
|
51
|
+
export * from "./geom.js";
|
|
52
|
+
export * from "./view.js";
|
|
53
|
+
export * from "./place.js";
|
|
54
|
+
export * from "./plugin.js";
|
|
55
|
+
export * from "./search.js";
|
|
56
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDC,GAED,0BAAyB;AACzB,0BAAyB;AACzB,0BAAyB;AACzB,2BAA0B;AAC1B,4BAA2B;AAE3B,4BAA2B"}
|
package/_dist/place.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Pin } from "./comp.js";
|
|
2
|
+
import { type Size } from "./geom.js";
|
|
3
|
+
import type { Point } from "./geom.js";
|
|
4
|
+
/**
|
|
5
|
+
* The top-left corner for a new card of `size`, leaving `gap` between it and
|
|
6
|
+
* anything already pinned: the first free slot inside the wall's own extent,
|
|
7
|
+
* or just to the right of everything when the wall is full. An empty wall
|
|
8
|
+
* starts at the origin.
|
|
9
|
+
*/ export declare let place: (pins: Pin[], size: Size, gap?: number) => Point;
|
|
10
|
+
//# sourceMappingURL=place.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place.d.ts","sources":["../place.ts"],"names":[],"mappings":"AAYA,cAAc,GAAG,oBAAmB;AACpC,SAAiC,KAAK,IAAI,oBAAmB;AAC7D,cAAc,KAAK,oBAAmB;AAEtC;;;;;CAKC,GACD,OAAO,YAAI,QAAS,MAAM,OAAO,MAAM,MAAM,iBAAW,MAYvD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Plugin } from "@yaks/graph";
|
|
2
|
+
/**
|
|
3
|
+
* The canvas plugin: the spatial-UI components, contributed to a graph.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
7
|
+
* import { graph } from '@yaks/graph'
|
|
8
|
+
* import { ram } from '@yaks/ram'
|
|
9
|
+
* import { canvas, canvasDoc } from '@yaks/canvas'
|
|
10
|
+
*
|
|
11
|
+
* let vocab = loadVocab([canvasDoc])
|
|
12
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [canvas()] })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Rendering is a client's job; this only declares what the pieces are. The
|
|
16
|
+
* geometry a renderer needs — {@link visible}, {@link place},
|
|
17
|
+
* {@link frame} — are plain functions beside it, framework-free on purpose,
|
|
18
|
+
* so a web canvas and a terminal share one answer.
|
|
19
|
+
*/ export declare let canvas: () => Plugin;
|
|
20
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sources":["../plugin.ts"],"names":[],"mappings":"AASA,cAAc,MAAM,2BAAgC;AAGpD;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,cAAa,OAGtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sources":["../search.ts"],"names":[],"mappings":"AAIA,OAAO,YAAI,cAAe,KAAK,MAAM,EAAE,QAAQ,MAAM;EACnD;IAAO,OAAO,MAAM;IAAE,MAAM,MAAM;;EAClC;IAAS,OAAO,MAAM;;IACpB,IAAI,CAUP"}
|
package/_dist/view.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Camera, Pin } from "./comp.js";
|
|
2
|
+
import { type Rect, type Size } from "./geom.js";
|
|
3
|
+
/** How far out a camera may pull back. */ export declare let ZOOM_MIN: number;
|
|
4
|
+
/** How far in a camera may push. */ export declare let ZOOM_MAX: number;
|
|
5
|
+
/** A zoom held inside the range every camera move shares, so a pinch and a
|
|
6
|
+
* fit-to-content cannot disagree about how far is too far. */ export declare let zoomed: (z: number) => number;
|
|
7
|
+
/**
|
|
8
|
+
* The part of the plane a camera can see, in canvas units. Zooming in shows
|
|
9
|
+
* less of the plane, so the window's pixel size is divided by the scale.
|
|
10
|
+
*/ export declare let world: (cam: Camera) => Rect;
|
|
11
|
+
/**
|
|
12
|
+
* The pins on screen — everything overlapping what the camera sees, in the
|
|
13
|
+
* order given. This is the one question a renderer asks every frame, so it is
|
|
14
|
+
* a filter over plain objects and nothing more.
|
|
15
|
+
*/ export declare let visible: <T extends Pin>(cam: Camera, pins: T[]) => T[];
|
|
16
|
+
/**
|
|
17
|
+
* The camera that frames everything: centred on the pins, pulled back until
|
|
18
|
+
* they fit, with `fill` of the window given over to them (the rest is the
|
|
19
|
+
* breathing room around the edge). Nothing pinned frames the origin at 1:1 —
|
|
20
|
+
* an empty wall looks the same from anywhere.
|
|
21
|
+
*
|
|
22
|
+
* The zoom is set by whichever axes the content actually spans: cards with no
|
|
23
|
+
* measured size still spread the bounds apart, and that spread is what gets
|
|
24
|
+
* fitted. Content with no extent at all — one unmeasured card, or several
|
|
25
|
+
* stacked on the same spot — constrains nothing, and frames at 1:1.
|
|
26
|
+
*/ export declare let frame: (pins: Pin[], size: Size, fill?: number) => Camera;
|
|
27
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sources":["../view.ts"],"names":[],"mappings":"AAUA,cAAc,MAAM,EAAE,GAAG,oBAAmB;AAC5C,SAA2B,KAAK,IAAI,EAAQ,KAAK,IAAI,oBAAmB;AAExE,wCAAwC,GACxC,OAAO,YAAI,iBAAc;AAEzB,kCAAkC,GAClC,OAAO,YAAI,iBAAY;AAEvB;4DAC4D,GAC5D,OAAO,YAAI,SAAU,GAAG,MAAM,KAAG,MAAM,CACI;AAE3C;;;CAGC,GACD,OAAO,YAAI,QAAS,KAAK,WAAS,KAKhC;AAEF;;;;CAIC,GACD,OAAO,YAAI,UAAW,UAAU,KAAK,KAAK,QAAQ,MAAM,QAAM,IAG7D;AAED;;;;;;;;;;CAUC,GACD,OAAO,YAAI,QAAS,MAAM,OAAO,MAAM,MAAM,kBAAa,OAazD"}
|
package/_dist/vocab.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VocabDoc } from "@yaks/vocab";
|
|
2
|
+
import { canvasDoc } from "./comp.js";
|
|
3
|
+
export { canvasDoc };
|
|
4
|
+
/** What this package is: its manifest's description, the one place it is
|
|
5
|
+
* written, which a host stamps on each document here. */ export declare let description: string;
|
|
6
|
+
/** Every document this plugin declares. */ export declare let docs: VocabDoc[];
|
|
7
|
+
//# sourceMappingURL=vocab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,2BAAgC;AACtD,SAAS,SAAS,oBAAmB;AAGrC,SAAS,SAAS,GAAE;AAEpB;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,yCAAyC,GACzC,OAAO,YAAI,MAAM,WAAwB"}
|