@mocanvas/state 4.8.10 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLEAN_ROOM.md CHANGED
@@ -22,7 +22,13 @@ that projects can migrate, but it is not derived from it.
22
22
  5. **Dependencies must be MIT, Apache-2.0, BSD, ISC, CC0 or 0BSD.** Check the
23
23
  license before adding a crate or npm package. `cargo deny` and
24
24
  `license-checker` run in CI.
25
- 6. **If in doubt, name it differently** and add an alias in the compat package.
25
+ 6. **Vendored third-party assets follow rule 5 and must be listed in `NOTICE`.**
26
+ Artwork, fonts and data copied into this repository rather than installed
27
+ count here even though no package manager sees them. Record where the
28
+ material came from, at which version, and by which script — and never
29
+ vendor material whose licence rule 5 would not have allowed as a dependency.
30
+ The icon set's Phosphor artwork is the worked example.
31
+ 7. **If in doubt, name it differently** and add an alias in the compat package.
26
32
 
27
33
  ## The one exception: `apps/bench`
28
34
 
package/COMPAT.md CHANGED
@@ -253,6 +253,14 @@ local persistence, and `onUiEvent`. Those are canvas features.
253
253
  screen space is window-relative. mocanvas 1.x had one method that computed
254
254
  viewport space under the screen-space name; both now exist and mean what they
255
255
  say.
256
+ - **Icon names.** mocanvas ships its own artwork, so the *names* are the compat
257
+ surface, not the drawings. 154 are drawn and 26 more are aliases onto them,
258
+ covering the spellings tldraw uses — `tool-*`, `size-small`..`size-extra-large`,
259
+ `horizontal-align-*`, `vertical-align-*`, `cross-2`. A name the set does not
260
+ have renders the label's initial rather than an empty box, and `hasIcon(name)`
261
+ lets you check first. Two of tldraw's fill names, `fill-fill` and
262
+ `fill-lined-fill`, have no mocanvas equivalent and are not aliased: they name
263
+ style variants this canvas does not have. See `docs/UI.md` for the whole set.
256
264
  - **No watermark, licence key or telemetry.**
257
265
 
258
266
  ## File format
package/UI.md CHANGED
@@ -31,7 +31,8 @@ Source lives in `packages/mocanvas/src/ui/`:
31
31
  | --- | --- |
32
32
  | `DefaultUi.tsx` | The toolbar, the zoom bar, the stats chip, and the `DefaultUi` wrapper |
33
33
  | `StylePanel.tsx` | The style panel and `getStylePanelSections`, the rule for which rows appear |
34
- | `icons.tsx` | The whole icon set, plus the geo icons generated from canvas geometry |
34
+ | `icons.tsx` | The icon set: Phosphor artwork, our own drawings, the generated geo icons, and the aliases |
35
+ | `icons-phosphor.ts` | Generated — Phosphor path data. Re-run `pnpm icons:generate`, never edit |
35
36
  | `overlays.tsx` | The shared tooltip and popover layers, and `placeNear` |
36
37
  | `ui.css` | Every design token and every rule |
37
38
  | `useKeyboardShortcuts.ts` | The default key bindings |
@@ -108,9 +109,60 @@ Handles are drawn at 9px (corners), 6px (shape handles) and 5.5px (rotate) in
108
109
  screen space, with a 1.5px stroke. Their hit radius is a separate editor
109
110
  constant, `HANDLE_HIT_RADIUS` in `packages/editor/src/editor/selectionHandles.ts`.
110
111
 
112
+ ## Where the icons come from
113
+
114
+ The set is 154 drawings plus 26 aliases, from three sources. Which one an icon
115
+ uses is decided by what the icon has to say.
116
+
117
+ | Source | Covers | Count |
118
+ | --- | --- | --- |
119
+ | [Phosphor Icons](https://phosphoricons.com) (MIT, `regular`) | Generic chrome: tools, history, alignment, distribution, text formatting, status, brands | 103 |
120
+ | Our own drawings | Anything describing *this* canvas: fill and dash styles, size steps, font families, text-alignment marks, arrowheads | 31 |
121
+ | The canvas geometry | The `geo-*` icons, generated from `getGeoGeometry` | 20 |
122
+
123
+ Phosphor's path data is inlined into `icons-phosphor.ts` by
124
+ `scripts/generate-phosphor-icons.mjs` (`pnpm icons:generate`). mocanvas takes no
125
+ runtime dependency on `@phosphor-icons/react` — that package is a devDependency
126
+ used only to run the generator, and the published bundle does not name it.
127
+ `NOTICE` carries the MIT notice we redistribute. Re-run the generator after
128
+ upgrading Phosphor, and review the diff: the map in the script is the only place
129
+ the correspondence is recorded.
130
+
131
+ Phosphor draws *filled* outlines on a 256 grid rather than strokes on ours, so
132
+ those are scaled into the same 24×24 box and painted with `fill`. The seam is
133
+ invisible at button sizes because Phosphor's `regular` weight is a 16/256
134
+ stroke — 1.5 on our grid, against our 1.75.
135
+
136
+ ## Aliases
137
+
138
+ `ICON_ALIASES` maps a second spelling onto artwork that already exists, mostly
139
+ tldraw's names, so an app ported from it asks for a name that answers instead of
140
+ falling back to an initial: `tool-pointer` → `select`, `size-small` → `size-s`,
141
+ `horizontal-align-start` → `text-align-left`, and so on.
142
+
143
+ An alias never introduces a drawing. If two names should look different they
144
+ belong in `ICONS`, and the distinctness test enforces that — aliases are exempt
145
+ by construction, because sharing one drawing is the whole point.
146
+
147
+ `hasIcon(name)` reports whether the set answers to a name, alias included;
148
+ `resolveIconName(name)` maps an alias to the name that owns the artwork.
149
+
150
+ ### Objects and text align differently
151
+
152
+ `align-left`, `align-center`, `align-right`, `align-top`, `align-bottom`,
153
+ `align-center-horizontal` and `align-center-vertical` align **objects** to each
154
+ other. `text-align-left`, `text-align-center` and `text-align-right` align
155
+ **text** within its box, and are what a shape label's horizontal alignment uses
156
+ (`horizontal-align-*` aliases onto them).
157
+
158
+ These were one set of names for both jobs until 4.9.0, which is why the align
159
+ menu used to show three ragged lines of text. A test asserts they never converge
160
+ again.
161
+
111
162
  ## Icon grid rules
112
163
 
113
- Icons are original artwork on a 24×24 viewBox, painted with `currentColor`.
164
+ The hand-drawn icons — everything that is not Phosphor — are original artwork on
165
+ a 24×24 viewBox, painted with `currentColor`.
114
166
 
115
167
  - **Grid.** 24×24. Ink, stroke included, stays inside it.
116
168
  - **Weight.** Stroke 1.75, round caps and joins. Only texture marks deviate and
@@ -130,6 +182,12 @@ Icons are original artwork on a 24×24 viewBox, painted with `currentColor`.
130
182
  is fitted into the box `getGeoIconBox(kind)` returns: square at `GEO_BOX` (16)
131
183
  by default, and flatter or narrower for kinds whose name implies a proportion
132
184
  (`rectangle`, `oval`, the four arrows). The longest side is always `GEO_BOX`.
185
+ - **Arrowheads** share one shaft, drawn by the `SHAFT` helper, so the eight read
186
+ as a family and the terminal is the only thing that changes between them.
187
+
188
+ `icons.test.tsx` checks what is checkable from the markup. The rest — whether an
189
+ icon reads heavier than its neighbour, whether two drawings are confusable — is
190
+ the gallery pass: `pnpm icons:gallery` renders every drawing to one page.
133
191
 
134
192
  Render one with `<Icon name="select" size={20} />`. `size` sets the SVG's
135
193
  attributes; buttons additionally take their icon size from `--mocanvas-ui-icon`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mocanvas/state",
3
- "version": "4.8.10",
3
+ "version": "4.9.0",
4
4
  "description": "Signals for mocanvas: atoms, computed values, transactions and React bindings.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Symbio Digital",