@zsherman/canvas 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +373 -0
  3. package/README.md +15 -2
  4. package/THIRD_PARTY_NOTICES.md +117 -0
  5. package/dist/dom/canvas/assets.js +89 -0
  6. package/dist/dom/canvas/board-store.js +56 -0
  7. package/dist/dom/canvas/canvas-actions.js +78 -0
  8. package/dist/dom/canvas/canvas-board.js +557 -0
  9. package/dist/dom/canvas/canvas-board.styles.js +110 -0
  10. package/dist/dom/canvas/canvas-chrome.js +1167 -0
  11. package/dist/dom/canvas/canvas-chrome.styles.js +220 -0
  12. package/dist/dom/canvas/canvas-comments.js +950 -0
  13. package/dist/dom/canvas/canvas-comments.styles.js +231 -0
  14. package/dist/dom/canvas/canvas-context.js +196 -0
  15. package/dist/dom/canvas/canvas-controller.js +697 -0
  16. package/dist/dom/canvas/canvas-cursor-chat.js +120 -0
  17. package/dist/dom/canvas/canvas-cursor-chat.styles.js +55 -0
  18. package/dist/dom/canvas/canvas-menus.js +276 -0
  19. package/dist/dom/canvas/canvas-menus.styles.js +7 -0
  20. package/dist/dom/canvas/canvas-style-bar.js +930 -0
  21. package/dist/dom/canvas/canvas-style-bar.styles.js +52 -0
  22. package/dist/dom/canvas/canvas-surface.js +1354 -0
  23. package/dist/dom/canvas/canvas-surface.styles.js +345 -0
  24. package/dist/dom/canvas/canvas-tool-rail.js +406 -0
  25. package/dist/dom/canvas/canvas-tool-rail.styles.js +20 -0
  26. package/dist/dom/canvas/comments.js +58 -0
  27. package/dist/dom/canvas/equality.js +13 -0
  28. package/dist/dom/canvas/export-png.js +496 -0
  29. package/dist/dom/canvas/gesture-machine.js +91 -0
  30. package/dist/dom/canvas/handlers.js +18 -0
  31. package/dist/dom/canvas/index.js +9 -0
  32. package/dist/dom/canvas/input.js +85 -0
  33. package/dist/dom/canvas/instant.js +28 -0
  34. package/dist/dom/canvas/kernel.js +39 -0
  35. package/dist/dom/canvas/motion.js +686 -0
  36. package/dist/dom/canvas/palette.js +165 -0
  37. package/dist/dom/canvas/random-id.js +15 -0
  38. package/dist/dom/canvas/scene-renderer.js +559 -0
  39. package/dist/dom/canvas/scene.styles.js +7 -0
  40. package/dist/dom/canvas/surface-model.js +324 -0
  41. package/dist/dom/canvas/uploads.js +294 -0
  42. package/dist/dom/index.js +9 -0
  43. package/dist/dom/kernel/actions.js +455 -0
  44. package/dist/dom/kernel/board.js +856 -0
  45. package/dist/dom/kernel/claims.js +40 -0
  46. package/dist/dom/kernel/clipboard.js +30 -0
  47. package/dist/dom/kernel/constants.js +210 -0
  48. package/dist/dom/kernel/contract.js +0 -0
  49. package/dist/dom/kernel/decode.js +85 -0
  50. package/dist/dom/kernel/editor.js +2077 -0
  51. package/dist/dom/kernel/errors.js +82 -0
  52. package/dist/dom/kernel/fonts/inter.js +7924 -0
  53. package/dist/dom/kernel/fractional-index.js +54 -0
  54. package/dist/dom/kernel/geometry.js +123 -0
  55. package/dist/dom/kernel/hit-test.js +156 -0
  56. package/dist/dom/kernel/index.js +22 -0
  57. package/dist/dom/kernel/inspect.js +116 -0
  58. package/dist/dom/kernel/kernel.js +251 -0
  59. package/dist/dom/kernel/outline.js +64 -0
  60. package/dist/dom/kernel/plan.js +1370 -0
  61. package/dist/dom/kernel/rev.js +173 -0
  62. package/dist/dom/kernel/scene.js +580 -0
  63. package/dist/dom/kernel/schema.js +1109 -0
  64. package/dist/dom/kernel/snap.js +258 -0
  65. package/dist/dom/kernel/svg.js +148 -0
  66. package/dist/dom/kernel/text.js +142 -0
  67. package/dist/solid/canvas/assets.jsx +89 -0
  68. package/dist/solid/canvas/board-store.jsx +56 -0
  69. package/dist/solid/canvas/canvas-actions.jsx +78 -0
  70. package/dist/solid/canvas/canvas-board.jsx +326 -0
  71. package/dist/solid/canvas/canvas-board.styles.jsx +110 -0
  72. package/dist/solid/canvas/canvas-chrome.jsx +612 -0
  73. package/dist/solid/canvas/canvas-chrome.styles.jsx +220 -0
  74. package/dist/solid/canvas/canvas-comments.jsx +435 -0
  75. package/dist/solid/canvas/canvas-comments.styles.jsx +231 -0
  76. package/dist/solid/canvas/canvas-context.jsx +174 -0
  77. package/dist/solid/canvas/canvas-controller.jsx +697 -0
  78. package/dist/solid/canvas/canvas-cursor-chat.jsx +87 -0
  79. package/dist/solid/canvas/canvas-cursor-chat.styles.jsx +55 -0
  80. package/dist/solid/canvas/canvas-menus.jsx +223 -0
  81. package/dist/solid/canvas/canvas-menus.styles.jsx +7 -0
  82. package/dist/solid/canvas/canvas-style-bar.jsx +486 -0
  83. package/dist/solid/canvas/canvas-style-bar.styles.jsx +52 -0
  84. package/dist/solid/canvas/canvas-surface.jsx +681 -0
  85. package/dist/solid/canvas/canvas-surface.styles.jsx +345 -0
  86. package/dist/solid/canvas/canvas-tool-rail.jsx +195 -0
  87. package/dist/solid/canvas/canvas-tool-rail.styles.jsx +20 -0
  88. package/dist/solid/canvas/comments.jsx +58 -0
  89. package/dist/solid/canvas/equality.jsx +13 -0
  90. package/dist/solid/canvas/export-png.jsx +496 -0
  91. package/dist/solid/canvas/gesture-machine.jsx +91 -0
  92. package/dist/solid/canvas/handlers.jsx +18 -0
  93. package/dist/solid/canvas/index.jsx +9 -0
  94. package/dist/solid/canvas/input.jsx +85 -0
  95. package/dist/solid/canvas/instant.jsx +28 -0
  96. package/dist/solid/canvas/kernel.jsx +39 -0
  97. package/dist/solid/canvas/motion.jsx +686 -0
  98. package/dist/solid/canvas/palette.jsx +165 -0
  99. package/dist/solid/canvas/random-id.jsx +15 -0
  100. package/dist/solid/canvas/scene-renderer.jsx +559 -0
  101. package/dist/solid/canvas/scene.styles.jsx +7 -0
  102. package/dist/solid/canvas/surface-model.jsx +324 -0
  103. package/dist/solid/canvas/uploads.jsx +294 -0
  104. package/dist/solid/index.jsx +9 -0
  105. package/dist/solid/kernel/actions.jsx +455 -0
  106. package/dist/solid/kernel/board.jsx +856 -0
  107. package/dist/solid/kernel/claims.jsx +40 -0
  108. package/dist/solid/kernel/clipboard.jsx +30 -0
  109. package/dist/solid/kernel/constants.jsx +210 -0
  110. package/dist/solid/kernel/contract.jsx +0 -0
  111. package/dist/solid/kernel/decode.jsx +85 -0
  112. package/dist/solid/kernel/editor.jsx +2077 -0
  113. package/dist/solid/kernel/errors.jsx +82 -0
  114. package/dist/solid/kernel/fonts/inter.jsx +7924 -0
  115. package/dist/solid/kernel/fractional-index.jsx +54 -0
  116. package/dist/solid/kernel/geometry.jsx +123 -0
  117. package/dist/solid/kernel/hit-test.jsx +156 -0
  118. package/dist/solid/kernel/index.jsx +22 -0
  119. package/dist/solid/kernel/inspect.jsx +116 -0
  120. package/dist/solid/kernel/kernel.jsx +251 -0
  121. package/dist/solid/kernel/outline.jsx +64 -0
  122. package/dist/solid/kernel/plan.jsx +1370 -0
  123. package/dist/solid/kernel/rev.jsx +173 -0
  124. package/dist/solid/kernel/scene.jsx +580 -0
  125. package/dist/solid/kernel/schema.jsx +1109 -0
  126. package/dist/solid/kernel/snap.jsx +258 -0
  127. package/dist/solid/kernel/svg.jsx +148 -0
  128. package/dist/solid/kernel/text.jsx +142 -0
  129. package/dist/styles.css +1 -0
  130. package/dist/types/canvas/assets.d.ts +111 -0
  131. package/dist/types/canvas/board-store.d.ts +86 -0
  132. package/dist/types/canvas/canvas-actions.d.ts +21 -0
  133. package/dist/types/canvas/canvas-board.d.ts +53 -0
  134. package/dist/types/canvas/canvas-board.styles.d.ts +94 -0
  135. package/dist/types/canvas/canvas-chrome.d.ts +109 -0
  136. package/dist/types/canvas/canvas-chrome.styles.d.ts +193 -0
  137. package/dist/types/canvas/canvas-comments.d.ts +20 -0
  138. package/dist/types/canvas/canvas-comments.styles.d.ts +208 -0
  139. package/dist/types/canvas/canvas-context.d.ts +104 -0
  140. package/dist/types/canvas/canvas-controller.d.ts +159 -0
  141. package/dist/types/canvas/canvas-cursor-chat.d.ts +13 -0
  142. package/dist/types/canvas/canvas-cursor-chat.styles.d.ts +54 -0
  143. package/dist/types/canvas/canvas-menus.d.ts +21 -0
  144. package/dist/types/canvas/canvas-menus.styles.d.ts +6 -0
  145. package/dist/types/canvas/canvas-style-bar.d.ts +19 -0
  146. package/dist/types/canvas/canvas-style-bar.styles.d.ts +43 -0
  147. package/dist/types/canvas/canvas-surface.d.ts +15 -0
  148. package/dist/types/canvas/canvas-surface.styles.d.ts +313 -0
  149. package/dist/types/canvas/canvas-tool-rail.d.ts +41 -0
  150. package/dist/types/canvas/canvas-tool-rail.styles.d.ts +15 -0
  151. package/dist/types/canvas/comments.d.ts +106 -0
  152. package/dist/types/canvas/equality.d.ts +4 -0
  153. package/dist/types/canvas/export-png.d.ts +77 -0
  154. package/dist/types/canvas/gesture-machine.d.ts +46 -0
  155. package/dist/types/canvas/handlers.d.ts +7 -0
  156. package/dist/types/canvas/index.d.ts +18 -0
  157. package/dist/types/canvas/input.d.ts +63 -0
  158. package/dist/types/canvas/instant.d.ts +13 -0
  159. package/dist/types/canvas/kernel.d.ts +27 -0
  160. package/dist/types/canvas/motion.d.ts +72 -0
  161. package/dist/types/canvas/palette.d.ts +46 -0
  162. package/dist/types/canvas/random-id.d.ts +6 -0
  163. package/dist/types/canvas/scene-renderer.d.ts +27 -0
  164. package/dist/types/canvas/scene.styles.d.ts +4 -0
  165. package/dist/types/canvas/surface-model.d.ts +113 -0
  166. package/dist/types/canvas/uploads.d.ts +58 -0
  167. package/dist/types/index.d.ts +1 -0
  168. package/dist/types/kernel/actions.d.ts +19 -0
  169. package/dist/types/kernel/board.d.ts +137 -0
  170. package/dist/types/kernel/claims.d.ts +29 -0
  171. package/dist/types/kernel/clipboard.d.ts +10 -0
  172. package/dist/types/kernel/constants.d.ts +195 -0
  173. package/dist/types/kernel/contract.d.ts +1533 -0
  174. package/dist/types/kernel/decode.d.ts +60 -0
  175. package/dist/types/kernel/editor.d.ts +12 -0
  176. package/dist/types/kernel/errors.d.ts +11 -0
  177. package/dist/types/kernel/fractional-index.d.ts +7 -0
  178. package/dist/types/kernel/geometry.d.ts +42 -0
  179. package/dist/types/kernel/hit-test.d.ts +16 -0
  180. package/dist/types/kernel/index.d.ts +8 -0
  181. package/dist/types/kernel/inspect.d.ts +6 -0
  182. package/dist/types/kernel/kernel.d.ts +6 -0
  183. package/dist/types/kernel/outline.d.ts +4 -0
  184. package/dist/types/kernel/plan.d.ts +20 -0
  185. package/dist/types/kernel/rev.d.ts +21 -0
  186. package/dist/types/kernel/scene.d.ts +16 -0
  187. package/dist/types/kernel/schema.d.ts +3436 -0
  188. package/dist/types/kernel/snap.d.ts +41 -0
  189. package/dist/types/kernel/svg.d.ts +3 -0
  190. package/dist/types/kernel/text.d.ts +21 -0
  191. package/docs/api.json +207 -0
  192. package/docs/canvas.md +444 -0
  193. package/docs/kernel.md +108 -0
  194. package/docs/llms.txt +41 -0
  195. package/docs/search-index.json +52 -0
  196. package/package.json +60 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # @zsherman/canvas
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6c9c479: Fixes found by running every e2e spec against the 0.1.0 tarballs.
8
+
9
+ - PeekPanel: after a click on a row, the row's button or link has focus, so Escape and J/K work in Safari, which doesn't focus a clicked button.
10
+ - CardInput: the brand marks fit their plate; the square ones (American Express, Diners Club) no longer spill over its edge.
11
+ - DatePicker: a disabled trigger inside its group fades once, not twice (the group carries `data-slot="date-picker-group"`).
12
+ - Command palette block: the launcher's defaults sit in `:where(.launcher)`, so a class you pass (the app shell's header search on phones) wins whatever order the CSS loads in.
13
+ - HeatMatrix (`@zsherman/charts`): the corner label uses `--sui-text-muted`, which meets 4.5:1 in light mode.
14
+ - EventCalendar (`@zsherman/calendar`): the day headers' and list rows' focus rings are inset, so the header cells and the list scroller no longer cut them; the calendar takes its width from its parent instead of widening it.
15
+ - CanvasBoard (`@zsherman/canvas`): cursors and comment pins are marked as seated on the board (they pan under its edge like shapes).
16
+ - Every package names its repository, for npm's trusted publishing.
17
+ - Updated dependencies [6c9c479]
18
+ - @zsherman/kit@0.1.1
19
+
20
+ ## 0.1.0
21
+
22
+ The first published release, on npm as `@zsherman/canvas` (it was `@solid-ui/canvas` 0.0.1 inside the repository). Versioned with `@zsherman/kit`: every package in the family shares one version, and each one's `@zsherman/kit` peer range is that version's minor.
23
+
24
+ A shared whiteboard for @zsherman/kit: notes, shapes, text, arrows, ink, images, comments, presence and agent proposals on an optimistic store the app owns, on a copy of Hyper's canvas kernel, themed with the kit's --sui-* tokens.
package/LICENSE ADDED
@@ -0,0 +1,373 @@
1
+ Mozilla Public License Version 2.0
2
+ ==================================
3
+
4
+ 1. Definitions
5
+ --------------
6
+
7
+ 1.1. "Contributor"
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
+
11
+ 1.2. "Contributor Version"
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
+
15
+ 1.3. "Contribution"
16
+ means Covered Software of a particular Contributor.
17
+
18
+ 1.4. "Covered Software"
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
+
24
+ 1.5. "Incompatible With Secondary Licenses"
25
+ means
26
+
27
+ (a) that the initial Contributor has attached the notice described
28
+ in Exhibit B to the Covered Software; or
29
+
30
+ (b) that the Covered Software was made available under the terms of
31
+ version 1.1 or earlier of the License, but not also under the
32
+ terms of a Secondary License.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+
52
+ (a) any file in Source Code Form that results from an addition to,
53
+ deletion from, or modification of the contents of Covered
54
+ Software; or
55
+
56
+ (b) any new file in Source Code Form that contains any Covered
57
+ Software.
58
+
59
+ 1.11. "Patent Claims" of a Contributor
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
+
67
+ 1.12. "Secondary License"
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
+
73
+ 1.13. "Source Code Form"
74
+ means the form of the work preferred for making modifications.
75
+
76
+ 1.14. "You" (or "Your")
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
+
86
+ 2. License Grants and Conditions
87
+ --------------------------------
88
+
89
+ 2.1. Grants
90
+
91
+ Each Contributor hereby grants You a world-wide, royalty-free,
92
+ non-exclusive license:
93
+
94
+ (a) under intellectual property rights (other than patent or trademark)
95
+ Licensable by such Contributor to use, reproduce, make available,
96
+ modify, display, perform, distribute, and otherwise exploit its
97
+ Contributions, either on an unmodified basis, with Modifications, or
98
+ as part of a Larger Work; and
99
+
100
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
101
+ for sale, have made, import, and otherwise transfer either its
102
+ Contributions or its Contributor Version.
103
+
104
+ 2.2. Effective Date
105
+
106
+ The licenses granted in Section 2.1 with respect to any Contribution
107
+ become effective for each Contribution on the date the Contributor first
108
+ distributes such Contribution.
109
+
110
+ 2.3. Limitations on Grant Scope
111
+
112
+ The licenses granted in this Section 2 are the only rights granted under
113
+ this License. No additional rights or licenses will be implied from the
114
+ distribution or licensing of Covered Software under this License.
115
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
+ Contributor:
117
+
118
+ (a) for any code that a Contributor has removed from Covered Software;
119
+ or
120
+
121
+ (b) for infringements caused by: (i) Your and any other third party's
122
+ modifications of Covered Software, or (ii) the combination of its
123
+ Contributions with other software (except as part of its Contributor
124
+ Version); or
125
+
126
+ (c) under Patent Claims infringed by Covered Software in the absence of
127
+ its Contributions.
128
+
129
+ This License does not grant any rights in the trademarks, service marks,
130
+ or logos of any Contributor (except as may be necessary to comply with
131
+ the notice requirements in Section 3.4).
132
+
133
+ 2.4. Subsequent Licenses
134
+
135
+ No Contributor makes additional grants as a result of Your choice to
136
+ distribute the Covered Software under a subsequent version of this
137
+ License (see Section 10.2) or under the terms of a Secondary License (if
138
+ permitted under the terms of Section 3.3).
139
+
140
+ 2.5. Representation
141
+
142
+ Each Contributor represents that the Contributor believes its
143
+ Contributions are its original creation(s) or it has sufficient rights
144
+ to grant the rights to its Contributions conveyed by this License.
145
+
146
+ 2.6. Fair Use
147
+
148
+ This License is not intended to limit any rights You have under
149
+ applicable copyright doctrines of fair use, fair dealing, or other
150
+ equivalents.
151
+
152
+ 2.7. Conditions
153
+
154
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
+ in Section 2.1.
156
+
157
+ 3. Responsibilities
158
+ -------------------
159
+
160
+ 3.1. Distribution of Source Form
161
+
162
+ All distribution of Covered Software in Source Code Form, including any
163
+ Modifications that You create or to which You contribute, must be under
164
+ the terms of this License. You must inform recipients that the Source
165
+ Code Form of the Covered Software is governed by the terms of this
166
+ License, and how they can obtain a copy of this License. You may not
167
+ attempt to alter or restrict the recipients' rights in the Source Code
168
+ Form.
169
+
170
+ 3.2. Distribution of Executable Form
171
+
172
+ If You distribute Covered Software in Executable Form then:
173
+
174
+ (a) such Covered Software must also be made available in Source Code
175
+ Form, as described in Section 3.1, and You must inform recipients of
176
+ the Executable Form how they can obtain a copy of such Source Code
177
+ Form by reasonable means in a timely manner, at a charge no more
178
+ than the cost of distribution to the recipient; and
179
+
180
+ (b) You may distribute such Executable Form under the terms of this
181
+ License, or sublicense it under different terms, provided that the
182
+ license for the Executable Form does not attempt to limit or alter
183
+ the recipients' rights in the Source Code Form under this License.
184
+
185
+ 3.3. Distribution of a Larger Work
186
+
187
+ You may create and distribute a Larger Work under terms of Your choice,
188
+ provided that You also comply with the requirements of this License for
189
+ the Covered Software. If the Larger Work is a combination of Covered
190
+ Software with a work governed by one or more Secondary Licenses, and the
191
+ Covered Software is not Incompatible With Secondary Licenses, this
192
+ License permits You to additionally distribute such Covered Software
193
+ under the terms of such Secondary License(s), so that the recipient of
194
+ the Larger Work may, at their option, further distribute the Covered
195
+ Software under the terms of either this License or such Secondary
196
+ License(s).
197
+
198
+ 3.4. Notices
199
+
200
+ You may not remove or alter the substance of any license notices
201
+ (including copyright notices, patent notices, disclaimers of warranty,
202
+ or limitations of liability) contained within the Source Code Form of
203
+ the Covered Software, except that You may alter any license notices to
204
+ the extent required to remedy known factual inaccuracies.
205
+
206
+ 3.5. Application of Additional Terms
207
+
208
+ You may choose to offer, and to charge a fee for, warranty, support,
209
+ indemnity or liability obligations to one or more recipients of Covered
210
+ Software. However, You may do so only on Your own behalf, and not on
211
+ behalf of any Contributor. You must make it absolutely clear that any
212
+ such warranty, support, indemnity, or liability obligation is offered by
213
+ You alone, and You hereby agree to indemnify every Contributor for any
214
+ liability incurred by such Contributor as a result of warranty, support,
215
+ indemnity or liability terms You offer. You may include additional
216
+ disclaimers of warranty and limitations of liability specific to any
217
+ jurisdiction.
218
+
219
+ 4. Inability to Comply Due to Statute or Regulation
220
+ ---------------------------------------------------
221
+
222
+ If it is impossible for You to comply with any of the terms of this
223
+ License with respect to some or all of the Covered Software due to
224
+ statute, judicial order, or regulation then You must: (a) comply with
225
+ the terms of this License to the maximum extent possible; and (b)
226
+ describe the limitations and the code they affect. Such description must
227
+ be placed in a text file included with all distributions of the Covered
228
+ Software under this License. Except to the extent prohibited by statute
229
+ or regulation, such description must be sufficiently detailed for a
230
+ recipient of ordinary skill to be able to understand it.
231
+
232
+ 5. Termination
233
+ --------------
234
+
235
+ 5.1. The rights granted under this License will terminate automatically
236
+ if You fail to comply with any of its terms. However, if You become
237
+ compliant, then the rights granted under this License from a particular
238
+ Contributor are reinstated (a) provisionally, unless and until such
239
+ Contributor explicitly and finally terminates Your grants, and (b) on an
240
+ ongoing basis, if such Contributor fails to notify You of the
241
+ non-compliance by some reasonable means prior to 60 days after You have
242
+ come back into compliance. Moreover, Your grants from a particular
243
+ Contributor are reinstated on an ongoing basis if such Contributor
244
+ notifies You of the non-compliance by some reasonable means, this is the
245
+ first time You have received notice of non-compliance with this License
246
+ from such Contributor, and You become compliant prior to 30 days after
247
+ Your receipt of the notice.
248
+
249
+ 5.2. If You initiate litigation against any entity by asserting a patent
250
+ infringement claim (excluding declaratory judgment actions,
251
+ counter-claims, and cross-claims) alleging that a Contributor Version
252
+ directly or indirectly infringes any patent, then the rights granted to
253
+ You by any and all Contributors for the Covered Software under Section
254
+ 2.1 of this License shall terminate.
255
+
256
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257
+ end user license agreements (excluding distributors and resellers) which
258
+ have been validly granted by You or Your distributors under this License
259
+ prior to termination shall survive termination.
260
+
261
+ ************************************************************************
262
+ * *
263
+ * 6. Disclaimer of Warranty *
264
+ * ------------------------- *
265
+ * *
266
+ * Covered Software is provided under this License on an "as is" *
267
+ * basis, without warranty of any kind, either expressed, implied, or *
268
+ * statutory, including, without limitation, warranties that the *
269
+ * Covered Software is free of defects, merchantable, fit for a *
270
+ * particular purpose or non-infringing. The entire risk as to the *
271
+ * quality and performance of the Covered Software is with You. *
272
+ * Should any Covered Software prove defective in any respect, You *
273
+ * (not any Contributor) assume the cost of any necessary servicing, *
274
+ * repair, or correction. This disclaimer of warranty constitutes an *
275
+ * essential part of this License. No use of any Covered Software is *
276
+ * authorized under this License except under this disclaimer. *
277
+ * *
278
+ ************************************************************************
279
+
280
+ ************************************************************************
281
+ * *
282
+ * 7. Limitation of Liability *
283
+ * -------------------------- *
284
+ * *
285
+ * Under no circumstances and under no legal theory, whether tort *
286
+ * (including negligence), contract, or otherwise, shall any *
287
+ * Contributor, or anyone who distributes Covered Software as *
288
+ * permitted above, be liable to You for any direct, indirect, *
289
+ * special, incidental, or consequential damages of any character *
290
+ * including, without limitation, damages for lost profits, loss of *
291
+ * goodwill, work stoppage, computer failure or malfunction, or any *
292
+ * and all other commercial damages or losses, even if such party *
293
+ * shall have been informed of the possibility of such damages. This *
294
+ * limitation of liability shall not apply to liability for death or *
295
+ * personal injury resulting from such party's negligence to the *
296
+ * extent applicable law prohibits such limitation. Some *
297
+ * jurisdictions do not allow the exclusion or limitation of *
298
+ * incidental or consequential damages, so this exclusion and *
299
+ * limitation may not apply to You. *
300
+ * *
301
+ ************************************************************************
302
+
303
+ 8. Litigation
304
+ -------------
305
+
306
+ Any litigation relating to this License may be brought only in the
307
+ courts of a jurisdiction where the defendant maintains its principal
308
+ place of business and such litigation shall be governed by laws of that
309
+ jurisdiction, without reference to its conflict-of-law provisions.
310
+ Nothing in this Section shall prevent a party's ability to bring
311
+ cross-claims or counter-claims.
312
+
313
+ 9. Miscellaneous
314
+ ----------------
315
+
316
+ This License represents the complete agreement concerning the subject
317
+ matter hereof. If any provision of this License is held to be
318
+ unenforceable, such provision shall be reformed only to the extent
319
+ necessary to make it enforceable. Any law or regulation which provides
320
+ that the language of a contract shall be construed against the drafter
321
+ shall not be used to construe this License against a Contributor.
322
+
323
+ 10. Versions of the License
324
+ ---------------------------
325
+
326
+ 10.1. New Versions
327
+
328
+ Mozilla Foundation is the license steward. Except as provided in Section
329
+ 10.3, no one other than the license steward has the right to modify or
330
+ publish new versions of this License. Each version will be given a
331
+ distinguishing version number.
332
+
333
+ 10.2. Effect of New Versions
334
+
335
+ You may distribute the Covered Software under the terms of the version
336
+ of the License under which You originally received the Covered Software,
337
+ or under the terms of any subsequent version published by the license
338
+ steward.
339
+
340
+ 10.3. Modified Versions
341
+
342
+ If you create software not governed by this License, and you want to
343
+ create a new license for such software, you may create and use a
344
+ modified version of this License if you rename the license and remove
345
+ any references to the name of the license steward (except to note that
346
+ such modified license differs from this License).
347
+
348
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
349
+ Licenses
350
+
351
+ If You choose to distribute Source Code Form that is Incompatible With
352
+ Secondary Licenses under the terms of this version of the License, the
353
+ notice described in Exhibit B of this License must be attached.
354
+
355
+ Exhibit A - Source Code Form License Notice
356
+ -------------------------------------------
357
+
358
+ This Source Code Form is subject to the terms of the Mozilla Public
359
+ License, v. 2.0. If a copy of the MPL was not distributed with this
360
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
361
+
362
+ If it is not possible or desirable to put the notice in a particular
363
+ file, then You may include the notice in a location (such as a LICENSE
364
+ file in a relevant directory) where a recipient would be likely to look
365
+ for such a notice.
366
+
367
+ You may add additional accurate notices of copyright ownership.
368
+
369
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
+ ---------------------------------------------------------
371
+
372
+ This Source Code Form is "Incompatible With Secondary Licenses", as
373
+ defined by the Mozilla Public License, v. 2.0.
package/README.md CHANGED
@@ -1,3 +1,16 @@
1
- # Temporary Holding Version
1
+ # @zsherman/canvas
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
+ A shared whiteboard for `@zsherman/kit`: sticky notes, shapes, text, arrows, ink, images, comments, presence and agent proposals on an optimistic store the app owns, themed with the kit's `--sui-*` tokens.
4
+
5
+ ```sh
6
+ npm install @zsherman/canvas @zsherman/kit @fontsource-variable/inter solid-js@^2 @solidjs/web@^2
7
+ ```
8
+
9
+ ```ts
10
+ import "@zsherman/kit/styles.css";
11
+ import "@zsherman/canvas/styles.css";
12
+ // The board lays text out with Inter's metrics: load the font it draws with.
13
+ import "@fontsource-variable/inter/standard.css";
14
+ ```
15
+
16
+ Start with [docs/llms.txt](./docs/llms.txt).
@@ -0,0 +1,117 @@
1
+ # Third-party notices
2
+
3
+ `@zsherman/canvas` contains a copy of one package's source and data derived from a font, and asks the app to load that font from another package (installed with it, not bundled).
4
+
5
+ ## @hypervideo/canvas-kernel 0.3.0 (copied)
6
+
7
+ - Use: the board kernel (`dist/*/kernel`, from `src/kernel`): planning and applying board changes, text layout, scenes, hit-testing, the agent outline, SVG, and the editor machine. Copied at hyper-libs commit `19cb458` with no local edits (UPSTREAM.md in the repository).
8
+ - Source: https://github.com/hypervideo/hyper-libs/tree/main/packages/canvas-kernel
9
+ - License: Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/). The kernel's files are Covered Software under the MPL: their source is available at the address above, and changes to them are listed in UPSTREAM.md.
10
+
11
+ ## Inter (advance tables, copied)
12
+
13
+ - Use: `dist/*/kernel/fonts/inter.json`, Inter Variable's glyph advances and metrics, from which the kernel lays text out. The board draws text in Inter, which the app loads (`@fontsource-variable/inter`, a dependency).
14
+ - Source: https://github.com/rsms/inter
15
+ - License: SIL Open Font License 1.1, at the end of this file.
16
+
17
+ ## Drawesome (by way of @zsherman/kit's Draw toolbar)
18
+
19
+ The style bar's pen tray is `@zsherman/kit/draw-toolbar`, whose pen artwork is adapted from Drawesome by Benji Taylor (MIT); the kit's THIRD_PARTY_NOTICES.md carries the notice.
20
+
21
+ ## Inter license
22
+
23
+ ```
24
+ Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
25
+
26
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
27
+ This license is copied below, and is also available with a FAQ at:
28
+ http://scripts.sil.org/OFL
29
+
30
+
31
+ -----------------------------------------------------------
32
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
33
+ -----------------------------------------------------------
34
+
35
+ PREAMBLE
36
+ The goals of the Open Font License (OFL) are to stimulate worldwide
37
+ development of collaborative font projects, to support the font creation
38
+ efforts of academic and linguistic communities, and to provide a free and
39
+ open framework in which fonts may be shared and improved in partnership
40
+ with others.
41
+
42
+ The OFL allows the licensed fonts to be used, studied, modified and
43
+ redistributed freely as long as they are not sold by themselves. The
44
+ fonts, including any derivative works, can be bundled, embedded,
45
+ redistributed and/or sold with any software provided that any reserved
46
+ names are not used by derivative works. The fonts and derivatives,
47
+ however, cannot be released under any other type of license. The
48
+ requirement for fonts to remain under this license does not apply
49
+ to any document created using the fonts or their derivatives.
50
+
51
+ DEFINITIONS
52
+ "Font Software" refers to the set of files released by the Copyright
53
+ Holder(s) under this license and clearly marked as such. This may
54
+ include source files, build scripts and documentation.
55
+
56
+ "Reserved Font Name" refers to any names specified as such after the
57
+ copyright statement(s).
58
+
59
+ "Original Version" refers to the collection of Font Software components as
60
+ distributed by the Copyright Holder(s).
61
+
62
+ "Modified Version" refers to any derivative made by adding to, deleting,
63
+ or substituting -- in part or in whole -- any of the components of the
64
+ Original Version, by changing formats or by porting the Font Software to a
65
+ new environment.
66
+
67
+ "Author" refers to any designer, engineer, programmer, technical
68
+ writer or other person who contributed to the Font Software.
69
+
70
+ PERMISSION & CONDITIONS
71
+ Permission is hereby granted, free of charge, to any person obtaining
72
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
73
+ redistribute, and sell modified and unmodified copies of the Font
74
+ Software, subject to the following conditions:
75
+
76
+ 1) Neither the Font Software nor any of its individual components,
77
+ in Original or Modified Versions, may be sold by itself.
78
+
79
+ 2) Original or Modified Versions of the Font Software may be bundled,
80
+ redistributed and/or sold with any software, provided that each copy
81
+ contains the above copyright notice and this license. These can be
82
+ included either as stand-alone text files, human-readable headers or
83
+ in the appropriate machine-readable metadata fields within text or
84
+ binary files as long as those fields can be easily viewed by the user.
85
+
86
+ 3) No Modified Version of the Font Software may use the Reserved Font
87
+ Name(s) unless explicit written permission is granted by the corresponding
88
+ Copyright Holder. This restriction only applies to the primary font name as
89
+ presented to the users.
90
+
91
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
92
+ Software shall not be used to promote, endorse or advertise any
93
+ Modified Version, except to acknowledge the contribution(s) of the
94
+ Copyright Holder(s) and the Author(s) or with their explicit written
95
+ permission.
96
+
97
+ 5) The Font Software, modified or unmodified, in part or in whole,
98
+ must be distributed entirely under this license, and must not be
99
+ distributed under any other license. The requirement for fonts to
100
+ remain under this license does not apply to any document created
101
+ using the Font Software.
102
+
103
+ TERMINATION
104
+ This license becomes null and void if any of the above conditions are
105
+ not met.
106
+
107
+ DISCLAIMER
108
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
109
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
110
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
111
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
112
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
113
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
114
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
115
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
116
+ OTHER DEALINGS IN THE FONT SOFTWARE.
117
+ ```
@@ -0,0 +1,89 @@
1
+ // src/canvas/assets.ts
2
+ /** The width hint steps: powers of two from 256 to 4096 device pixels. */
3
+ function widthStep(pixels) {
4
+ const step = 2 ** Math.ceil(Math.log2(Math.max(pixels, 1)));
5
+ return Math.min(Math.max(step, 256), 4096);
6
+ }
7
+ /** Names people know image types by; others read as their subtype. */
8
+ const TYPE_NAMES = /* @__PURE__ */ new Map([
9
+ ["image/avif", "AVIF"],
10
+ ["image/gif", "GIF"],
11
+ ["image/heic", "HEIC"],
12
+ ["image/jpeg", "JPEG"],
13
+ ["image/png", "PNG"],
14
+ ["image/svg+xml", "SVG"],
15
+ ["image/webp", "WebP"]
16
+ ]);
17
+ /** The host's types as a list a person reads, such as "PNG, JPEG or GIF". */
18
+ function typeList(accept) {
19
+ const names = [...new Set(accept.map((type) => TYPE_NAMES.get(type) ?? (type.split("/").at(-1) ?? type).toUpperCase()))];
20
+ const last = names.pop();
21
+ if (last === void 0) return "";
22
+ return names.length === 0 ? last : `${names.join(", ")} or ${last}`;
23
+ }
24
+ /** Why a file is not uploaded, by the host's rules, or null when it can be. */
25
+ function fileProblem(file, assets) {
26
+ if (!assets.accept.includes(file.type)) return `${file.name} isn't a supported image. Use ${typeList(assets.accept)}.`;
27
+ if (file.size > assets.maxBytes) return `${file.name} is too large. Images can be up to ${formatBytes(assets.maxBytes)}.`;
28
+ return null;
29
+ }
30
+ /**
31
+ * What a rejected upload says to the viewer: the host's message and whether
32
+ * to offer Retry, or no message and Retry for a rejection not written for
33
+ * people.
34
+ */
35
+ function failureOf(cause) {
36
+ if (cause instanceof Error && "retryable" in cause && (cause.retryable === true || cause.retryable === false)) {
37
+ const message = cause.message.trim();
38
+ return {
39
+ message: message === "" ? null : message,
40
+ retryable: cause.retryable
41
+ };
42
+ }
43
+ return {
44
+ message: null,
45
+ retryable: true
46
+ };
47
+ }
48
+ /**
49
+ * A size in decimal units, as hosts state limits, to one decimal at most:
50
+ * 10,000,000 bytes is "10 MB" and 5,242,880 is "5.2 MB".
51
+ */
52
+ function formatBytes(bytes) {
53
+ const mb = Math.round(bytes / 1e5) / 10;
54
+ return mb < 1 ? `${Math.round(bytes / 1e3)} KB` : `${mb} MB`;
55
+ }
56
+ /** How long reading an image's size may take before the board guesses. */
57
+ const SIZE_TIMEOUT_MS = 1500;
58
+ /**
59
+ * An image file's size as it displays, with EXIF orientation applied, read
60
+ * from the browser's own decoder in a detached image; null when it has no
61
+ * intrinsic size, such as some SVGs, or cannot be read in time.
62
+ */
63
+ function naturalSize(file) {
64
+ if (!("Image" in globalThis) || !("createObjectURL" in URL)) return Promise.resolve(null);
65
+ return new Promise((resolve) => {
66
+ const url = URL.createObjectURL(file);
67
+ const image = new Image();
68
+ let done = false;
69
+ const finish = (size) => {
70
+ if (done) return;
71
+ done = true;
72
+ clearTimeout(timer);
73
+ image.onload = null;
74
+ image.onerror = null;
75
+ image.src = "";
76
+ URL.revokeObjectURL(url);
77
+ resolve(size);
78
+ };
79
+ const timer = setTimeout(() => finish(null), SIZE_TIMEOUT_MS);
80
+ image.decoding = "async";
81
+ image.onload = () => finish(image.naturalWidth > 0 && image.naturalHeight > 0 ? {
82
+ h: image.naturalHeight,
83
+ w: image.naturalWidth
84
+ } : null);
85
+ image.onerror = () => finish(null);
86
+ image.src = url;
87
+ });
88
+ }
89
+ export { failureOf, fileProblem, formatBytes, naturalSize, widthStep };
@@ -0,0 +1,56 @@
1
+ // src/canvas/board-store.ts
2
+ /**
3
+ * A board with no shapes and no history, as the kernel's `EMPTY_BOARD`. It is
4
+ * spelled out here because importing a value from the kernel would load the
5
+ * kernel with the page instead of when a board first needs it.
6
+ */
7
+ const EMPTY_BOARD = Object.freeze({
8
+ head: 0,
9
+ ["shapes"]: Object.freeze([]),
10
+ transactions: Object.freeze([])
11
+ });
12
+ const CONFIRMED = { _tag: "Confirmed" };
13
+ /**
14
+ * A board in memory, for a single-player board, tests and examples, and the
15
+ * reference for the store contract: it keeps every commit, confirms it at
16
+ * once and refuses none.
17
+ */
18
+ function createMemoryBoardStore({ actor, board: initialBoard = EMPTY_BOARD, connection, presence: initialPresence = [] }) {
19
+ let board = initialBoard;
20
+ let presence = initialPresence;
21
+ const listeners = /* @__PURE__ */ new Set();
22
+ const notify = () => {
23
+ for (const listener of Array.from(listeners)) listener();
24
+ };
25
+ const store = {
26
+ actor,
27
+ commit(change) {
28
+ board = change.board;
29
+ notify();
30
+ return CONFIRMED;
31
+ },
32
+ getBoard: () => board,
33
+ getPresence: () => presence,
34
+ publish() {},
35
+ setBoard(next) {
36
+ board = next;
37
+ notify();
38
+ },
39
+ setPresence(next) {
40
+ presence = next;
41
+ notify();
42
+ },
43
+ subscribe(listener) {
44
+ listeners.add(listener);
45
+ return () => {
46
+ listeners.delete(listener);
47
+ };
48
+ }
49
+ };
50
+ if (connection === void 0) return store;
51
+ return {
52
+ ...store,
53
+ connection
54
+ };
55
+ }
56
+ export { createMemoryBoardStore };