@hozo/canvas 0.1.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/LICENSE +21 -0
- package/README.md +152 -0
- package/dist/accessibility.d.ts +20 -0
- package/dist/accessibility.d.ts.map +1 -0
- package/dist/accessibility.js +9 -0
- package/dist/accessibility.js.map +1 -0
- package/dist/hit-test.d.ts +96 -0
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +354 -0
- package/dist/hit-test.js.map +1 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +317 -0
- package/dist/index.js.map +1 -0
- package/dist/index.native.d.ts +83 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/index.native.js +435 -0
- package/dist/index.native.js.map +1 -0
- package/dist/render-canvas-2d.d.ts +6 -0
- package/dist/render-canvas-2d.d.ts.map +1 -0
- package/dist/render-canvas-2d.js +213 -0
- package/dist/render-canvas-2d.js.map +1 -0
- package/dist/scene.d.ts +495 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +591 -0
- package/dist/scene.js.map +1 -0
- package/dist/viewport.d.ts +9 -0
- package/dist/viewport.d.ts.map +1 -0
- package/dist/viewport.js +2 -0
- package/dist/viewport.js.map +1 -0
- package/dist/wrap-text.d.ts +28 -0
- package/dist/wrap-text.d.ts.map +1 -0
- package/dist/wrap-text.js +148 -0
- package/dist/wrap-text.js.map +1 -0
- package/package.json +79 -0
- package/src/accessibility.ts +28 -0
- package/src/hit-test.ts +499 -0
- package/src/index.native.tsx +733 -0
- package/src/index.tsx +510 -0
- package/src/render-canvas-2d.ts +259 -0
- package/src/scene.tsx +1037 -0
- package/src/viewport.ts +8 -0
- package/src/wrap-text.ts +157 -0
package/dist/scene.js
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
/** Builds the cancellable event shared by pointer, keyboard, and accessibility activation. */
|
|
4
|
+
export function canvasPressEvent(point, surfacePoint, modifiers = {}) {
|
|
5
|
+
let defaultPrevented = false;
|
|
6
|
+
const event = { point, surfacePoint };
|
|
7
|
+
// Keep the two historical coordinate fields as the enumerable payload.
|
|
8
|
+
// Consumers that log or spread an event do not suddenly acquire browser
|
|
9
|
+
// bookkeeping, while direct event access follows the familiar DOM shape.
|
|
10
|
+
Object.defineProperties(event, {
|
|
11
|
+
altKey: { value: modifiers.altKey ?? false, enumerable: false },
|
|
12
|
+
ctrlKey: { value: modifiers.ctrlKey ?? false, enumerable: false },
|
|
13
|
+
metaKey: { value: modifiers.metaKey ?? false, enumerable: false },
|
|
14
|
+
shiftKey: { value: modifiers.shiftKey ?? false, enumerable: false },
|
|
15
|
+
button: { value: modifiers.button ?? 0, enumerable: false },
|
|
16
|
+
defaultPrevented: { get: () => defaultPrevented, enumerable: false },
|
|
17
|
+
preventDefault: {
|
|
18
|
+
value: () => {
|
|
19
|
+
defaultPrevented = true;
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return event;
|
|
25
|
+
}
|
|
26
|
+
/** Whether a paint is a gradient rather than a colour. */
|
|
27
|
+
export function isGradient(paint) {
|
|
28
|
+
return typeof paint === 'object' && paint !== null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether this paint puts anything on the surface, per channel.
|
|
32
|
+
*
|
|
33
|
+
* Both renderers had these two conditions written out, identically and
|
|
34
|
+
* separately -- Canvas2D in `applyPaint`, Skia in `paintLayers`. Hit
|
|
35
|
+
* testing needs the same answer for a third time, and a hit test that
|
|
36
|
+
* disagrees with the paint is worse than one that refuses: it reports a
|
|
37
|
+
* press on something nobody can see. So the condition is written once and
|
|
38
|
+
* all three read it.
|
|
39
|
+
*
|
|
40
|
+
* The defaults are the platforms' own and agree: an unset `strokeWidth`
|
|
41
|
+
* is 1 in Canvas2D and in Skia, so `?? 1` is not a Hozo policy.
|
|
42
|
+
*/
|
|
43
|
+
export function paintStrokes(paint) {
|
|
44
|
+
return paint.stroke !== undefined && paint.stroke !== 'none' && (paint.strokeWidth ?? 1) > 0;
|
|
45
|
+
}
|
|
46
|
+
export function paintFills(paint) {
|
|
47
|
+
return paint.fill !== 'none' && (paint.fill !== undefined || paint.stroke === undefined);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The four fields both platforms take, defaulted once.
|
|
51
|
+
*
|
|
52
|
+
* Shared so a face cannot differ between the surfaces for a reason Hozo
|
|
53
|
+
* chose. What it cannot make equal is the face a *system* resolves these
|
|
54
|
+
* to, which is why `fontFamily` is passed through untouched rather than
|
|
55
|
+
* mapped to something clever.
|
|
56
|
+
*/
|
|
57
|
+
export function textFontSpec(props) {
|
|
58
|
+
return {
|
|
59
|
+
fontFamily: props.fontFamily ?? 'sans-serif',
|
|
60
|
+
fontSize: props.fontSize,
|
|
61
|
+
fontStyle: props.fontStyle ?? 'normal',
|
|
62
|
+
fontWeight: props.fontWeight ?? 'normal',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The same four as the CSS shorthand `CanvasRenderingContext2D.font` takes. */
|
|
66
|
+
export function cssFontShorthand(props) {
|
|
67
|
+
const font = textFontSpec(props);
|
|
68
|
+
return `${font.fontStyle} ${font.fontWeight} ${font.fontSize}px ${font.fontFamily}`;
|
|
69
|
+
}
|
|
70
|
+
class CanvasInteractionStore {
|
|
71
|
+
#handlers = new Map();
|
|
72
|
+
#labels = new Map();
|
|
73
|
+
#destinations = new Map();
|
|
74
|
+
#listeners = new Set();
|
|
75
|
+
#version = 0;
|
|
76
|
+
get version() {
|
|
77
|
+
return this.#version;
|
|
78
|
+
}
|
|
79
|
+
subscribe(listener) {
|
|
80
|
+
this.#listeners.add(listener);
|
|
81
|
+
return () => {
|
|
82
|
+
this.#listeners.delete(listener);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
set(id, handler, label, destination) {
|
|
86
|
+
const previousHas = this.has(id);
|
|
87
|
+
const previousLabel = this.#labels.get(id);
|
|
88
|
+
const previousDestination = this.#destinations.get(id);
|
|
89
|
+
if (handler === undefined)
|
|
90
|
+
this.#handlers.delete(id);
|
|
91
|
+
else
|
|
92
|
+
this.#handlers.set(id, handler);
|
|
93
|
+
if (label === undefined)
|
|
94
|
+
this.#labels.delete(id);
|
|
95
|
+
else
|
|
96
|
+
this.#labels.set(id, label);
|
|
97
|
+
if (destination === undefined)
|
|
98
|
+
this.#destinations.delete(id);
|
|
99
|
+
else
|
|
100
|
+
this.#destinations.set(id, destination);
|
|
101
|
+
if (previousHas !== this.has(id) ||
|
|
102
|
+
previousLabel !== label ||
|
|
103
|
+
previousDestination?.href !== destination?.href ||
|
|
104
|
+
previousDestination?.external !== destination?.external ||
|
|
105
|
+
previousDestination?.replace !== destination?.replace) {
|
|
106
|
+
this.#emit();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
label(id) {
|
|
110
|
+
return this.#labels.get(id);
|
|
111
|
+
}
|
|
112
|
+
remove(id) {
|
|
113
|
+
const hadInteraction = this.has(id);
|
|
114
|
+
this.#handlers.delete(id);
|
|
115
|
+
this.#labels.delete(id);
|
|
116
|
+
this.#destinations.delete(id);
|
|
117
|
+
if (hadInteraction)
|
|
118
|
+
this.#emit();
|
|
119
|
+
}
|
|
120
|
+
has(id) {
|
|
121
|
+
return this.#handlers.has(id) || this.#destinations.has(id);
|
|
122
|
+
}
|
|
123
|
+
press(id, event) {
|
|
124
|
+
this.#handlers.get(id)?.(event);
|
|
125
|
+
}
|
|
126
|
+
destination(id) {
|
|
127
|
+
return this.#destinations.get(id);
|
|
128
|
+
}
|
|
129
|
+
#emit() {
|
|
130
|
+
this.#version += 1;
|
|
131
|
+
for (const listener of this.#listeners)
|
|
132
|
+
listener();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Which shape is currently indicated, and who to tell when that changes.
|
|
137
|
+
*
|
|
138
|
+
* The active id lives here rather than in each surface because it is one
|
|
139
|
+
* fact about the scene: two pointers cannot indicate two different shapes
|
|
140
|
+
* and both be right, and a tooltip that believed otherwise would show
|
|
141
|
+
* two.
|
|
142
|
+
*/
|
|
143
|
+
class CanvasActiveStore {
|
|
144
|
+
#handlers = new Map();
|
|
145
|
+
#activeId;
|
|
146
|
+
set(id, handler) {
|
|
147
|
+
this.#handlers.set(id, handler);
|
|
148
|
+
}
|
|
149
|
+
remove(id) {
|
|
150
|
+
this.#handlers.delete(id);
|
|
151
|
+
// A shape that unmounts while indicated leaves nothing to be
|
|
152
|
+
// indicated, and the handler it would have been told through is the
|
|
153
|
+
// one that just went away.
|
|
154
|
+
if (this.#activeId === id)
|
|
155
|
+
this.#activeId = undefined;
|
|
156
|
+
}
|
|
157
|
+
has(id) {
|
|
158
|
+
return this.#handlers.has(id);
|
|
159
|
+
}
|
|
160
|
+
get activeId() {
|
|
161
|
+
return this.#activeId;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Moves the indication, telling the shape that lost it and the one that
|
|
165
|
+
* gained it, in that order.
|
|
166
|
+
*
|
|
167
|
+
* Nothing happens when the target has not changed, so a pointer moving
|
|
168
|
+
* across one shape reports once rather than once per pixel -- which is
|
|
169
|
+
* what makes this usable from `onPointerMove` at all.
|
|
170
|
+
*/
|
|
171
|
+
activate(id, event) {
|
|
172
|
+
if (this.#activeId === id)
|
|
173
|
+
return;
|
|
174
|
+
const previous = this.#activeId;
|
|
175
|
+
this.#activeId = id;
|
|
176
|
+
if (previous !== undefined)
|
|
177
|
+
this.#handlers.get(previous)?.(undefined);
|
|
178
|
+
if (id !== undefined && event !== undefined)
|
|
179
|
+
this.#handlers.get(id)?.(event);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function sceneValueEqual(left, right) {
|
|
183
|
+
if (Object.is(left, right))
|
|
184
|
+
return true;
|
|
185
|
+
if (!left || !right || typeof left !== 'object' || typeof right !== 'object')
|
|
186
|
+
return false;
|
|
187
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
188
|
+
return (Array.isArray(left) &&
|
|
189
|
+
Array.isArray(right) &&
|
|
190
|
+
left.length === right.length &&
|
|
191
|
+
left.every((value, index) => sceneValueEqual(value, right[index])));
|
|
192
|
+
}
|
|
193
|
+
const leftRecord = left;
|
|
194
|
+
const rightRecord = right;
|
|
195
|
+
const leftKeys = Object.keys(leftRecord);
|
|
196
|
+
const rightKeys = Object.keys(rightRecord);
|
|
197
|
+
return (leftKeys.length === rightKeys.length &&
|
|
198
|
+
leftKeys.every((key) => key in rightRecord && sceneValueEqual(leftRecord[key], rightRecord[key])));
|
|
199
|
+
}
|
|
200
|
+
function flatNodeEqual(left, right) {
|
|
201
|
+
return left.kind === right.kind && sceneValueEqual(left.props, right.props);
|
|
202
|
+
}
|
|
203
|
+
/** A small platform-neutral retained scene. It is deliberately not Hozo's semantic/SVG IR. */
|
|
204
|
+
export class CanvasSceneStore {
|
|
205
|
+
#nodes = new Map();
|
|
206
|
+
#listeners = new Set();
|
|
207
|
+
#nextOrder = 0;
|
|
208
|
+
#version = 0;
|
|
209
|
+
get version() {
|
|
210
|
+
return this.#version;
|
|
211
|
+
}
|
|
212
|
+
subscribe(listener) {
|
|
213
|
+
this.#listeners.add(listener);
|
|
214
|
+
return () => {
|
|
215
|
+
this.#listeners.delete(listener);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
upsert(id, parentId, node) {
|
|
219
|
+
const previous = this.#nodes.get(id);
|
|
220
|
+
if (previous && previous.parentId === parentId && flatNodeEqual(previous.node, node))
|
|
221
|
+
return;
|
|
222
|
+
this.#nodes.set(id, {
|
|
223
|
+
id,
|
|
224
|
+
parentId,
|
|
225
|
+
order: previous?.order ?? this.#nextOrder++,
|
|
226
|
+
node,
|
|
227
|
+
});
|
|
228
|
+
this.#emit();
|
|
229
|
+
}
|
|
230
|
+
remove(id) {
|
|
231
|
+
if (!this.#nodes.delete(id))
|
|
232
|
+
return;
|
|
233
|
+
this.#emit();
|
|
234
|
+
}
|
|
235
|
+
snapshot() {
|
|
236
|
+
const childrenByParent = new Map();
|
|
237
|
+
for (const stored of this.#nodes.values()) {
|
|
238
|
+
const siblings = childrenByParent.get(stored.parentId) ?? [];
|
|
239
|
+
siblings.push(stored);
|
|
240
|
+
childrenByParent.set(stored.parentId, siblings);
|
|
241
|
+
}
|
|
242
|
+
for (const siblings of childrenByParent.values()) {
|
|
243
|
+
siblings.sort((a, b) => a.order - b.order);
|
|
244
|
+
}
|
|
245
|
+
const build = (parentId, ancestors) => {
|
|
246
|
+
const result = [];
|
|
247
|
+
for (const stored of childrenByParent.get(parentId) ?? []) {
|
|
248
|
+
// A malformed custom renderer cannot turn a parent cycle into an
|
|
249
|
+
// infinite traversal. The public marker components never create one.
|
|
250
|
+
if (ancestors.has(stored.id))
|
|
251
|
+
continue;
|
|
252
|
+
if (stored.node.kind === 'group' || stored.node.kind === 'clip') {
|
|
253
|
+
const nextAncestors = new Set(ancestors).add(stored.id);
|
|
254
|
+
result.push({
|
|
255
|
+
...stored.node,
|
|
256
|
+
id: stored.id,
|
|
257
|
+
children: build(stored.id, nextAncestors),
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
result.push({ ...stored.node, id: stored.id });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
265
|
+
};
|
|
266
|
+
return build(undefined, new Set());
|
|
267
|
+
}
|
|
268
|
+
#emit() {
|
|
269
|
+
this.#version += 1;
|
|
270
|
+
for (const listener of this.#listeners)
|
|
271
|
+
listener();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const SceneContext = createContext(undefined);
|
|
275
|
+
const useIsoLayoutEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;
|
|
276
|
+
function useSceneNode(node) {
|
|
277
|
+
const context = useContext(SceneContext);
|
|
278
|
+
const id = useId();
|
|
279
|
+
if (!context) {
|
|
280
|
+
throw new Error('Canvas shapes must be rendered inside <Canvas>.');
|
|
281
|
+
}
|
|
282
|
+
useIsoLayoutEffect(() => () => context.store.remove(id), [context.store, id]);
|
|
283
|
+
useIsoLayoutEffect(() => {
|
|
284
|
+
context.store.upsert(id, context.parentId, node);
|
|
285
|
+
}, [context.store, context.parentId, id, node]);
|
|
286
|
+
return {
|
|
287
|
+
store: context.store,
|
|
288
|
+
interactions: context.interactions,
|
|
289
|
+
active: context.active,
|
|
290
|
+
id,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function interactiveLeaf(
|
|
294
|
+
// Every leaf kind, which it did not used to be. The list was spelled out
|
|
295
|
+
// while it meant something -- first the four closed shapes, then lines,
|
|
296
|
+
// then paths -- and the plain leaf beside it was for the shapes the hit
|
|
297
|
+
// test could not answer for. Text was the last of those, so the
|
|
298
|
+
// distinction and the plain `leaf` went with it.
|
|
299
|
+
kind) {
|
|
300
|
+
const Component = ({ onPress, onActiveChange, accessibilityLabel, disabled, href, external, replace, ...props }) => {
|
|
301
|
+
// Not memoised. `props` is a rest object, new on every render, so a
|
|
302
|
+
// memo keyed on it recomputed every time -- the cost of a hook with
|
|
303
|
+
// none of the saving, on every shape in the scene.
|
|
304
|
+
const node = { kind, props };
|
|
305
|
+
const context = useSceneNode(node);
|
|
306
|
+
useIsoLayoutEffect(() => {
|
|
307
|
+
if ((!onPress && !href) || disabled) {
|
|
308
|
+
context.interactions.remove(context.id);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
context.interactions.set(context.id, onPress, accessibilityLabel, href === undefined ? undefined : { href, external, replace });
|
|
312
|
+
return () => context.interactions.remove(context.id);
|
|
313
|
+
}, [
|
|
314
|
+
context.interactions,
|
|
315
|
+
context.id,
|
|
316
|
+
onPress,
|
|
317
|
+
accessibilityLabel,
|
|
318
|
+
disabled,
|
|
319
|
+
href,
|
|
320
|
+
external,
|
|
321
|
+
replace,
|
|
322
|
+
]);
|
|
323
|
+
useIsoLayoutEffect(() => {
|
|
324
|
+
if (!onActiveChange || disabled) {
|
|
325
|
+
context.active.remove(context.id);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
context.active.set(context.id, onActiveChange);
|
|
329
|
+
return () => context.active.remove(context.id);
|
|
330
|
+
}, [context.active, context.id, onActiveChange, disabled]);
|
|
331
|
+
return null;
|
|
332
|
+
};
|
|
333
|
+
Component.displayName = `Canvas.${kind}`;
|
|
334
|
+
return Component;
|
|
335
|
+
}
|
|
336
|
+
export const Rect = interactiveLeaf('rect');
|
|
337
|
+
export const RoundedRect = interactiveLeaf('rounded-rect');
|
|
338
|
+
export const Circle = interactiveLeaf('circle');
|
|
339
|
+
export const Ellipse = interactiveLeaf('ellipse');
|
|
340
|
+
export const Line = interactiveLeaf('line');
|
|
341
|
+
// Text is not interactive: its region is a run of glyphs, and neither
|
|
342
|
+
// renderer offers a containment test for one. `Path` is, now that each
|
|
343
|
+
// surface answers for its own -- see `CanvasPathHitTest`.
|
|
344
|
+
export const Text = interactiveLeaf('text');
|
|
345
|
+
export const Path = interactiveLeaf('path');
|
|
346
|
+
export function Group({ children, ...props }) {
|
|
347
|
+
// A rest object is new on every render; see `interactiveLeaf`.
|
|
348
|
+
const node = { kind: 'group', props };
|
|
349
|
+
const context = useSceneNode(node);
|
|
350
|
+
return (_jsx(SceneContext.Provider, { value: {
|
|
351
|
+
store: context.store,
|
|
352
|
+
interactions: context.interactions,
|
|
353
|
+
active: context.active,
|
|
354
|
+
parentId: context.id,
|
|
355
|
+
}, children: children }));
|
|
356
|
+
}
|
|
357
|
+
export function Clip({ children, ...props }) {
|
|
358
|
+
// A rest object is new on every render; see `interactiveLeaf`.
|
|
359
|
+
const node = { kind: 'clip', props };
|
|
360
|
+
const context = useSceneNode(node);
|
|
361
|
+
return (_jsx(SceneContext.Provider, { value: {
|
|
362
|
+
store: context.store,
|
|
363
|
+
interactions: context.interactions,
|
|
364
|
+
active: context.active,
|
|
365
|
+
parentId: context.id,
|
|
366
|
+
}, children: children }));
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* A cache that forgets, because the things it holds are not a fixed set.
|
|
370
|
+
*
|
|
371
|
+
* Fonts are: a chart uses a handful of specs and reuses them, so an
|
|
372
|
+
* unbounded map is fine there. Paths are not. A line chart that animates
|
|
373
|
+
* builds a new `d` string every frame, and each one parsed by `Path2D`
|
|
374
|
+
* or by `MakeFromSVGString` was kept for the life of the process -- the
|
|
375
|
+
* exact workload #154 describes as Canvas mode's reason to exist.
|
|
376
|
+
*
|
|
377
|
+
* Least-recently-used, by the oldest insertion, which a `Map` gives for
|
|
378
|
+
* free: its iteration order is insertion order, so the first key is the
|
|
379
|
+
* oldest. Re-inserting on a hit is what makes "oldest insertion" mean
|
|
380
|
+
* "least recently used".
|
|
381
|
+
*
|
|
382
|
+
* The bound is generous rather than tuned. A frame draws every path it
|
|
383
|
+
* has, so anything smaller than one frame's worth of paths would evict
|
|
384
|
+
* entries it is about to need; anything larger only delays the same
|
|
385
|
+
* behaviour.
|
|
386
|
+
*/
|
|
387
|
+
export class BoundedCache {
|
|
388
|
+
#entries = new Map();
|
|
389
|
+
#limit;
|
|
390
|
+
constructor(limit) {
|
|
391
|
+
this.#limit = limit;
|
|
392
|
+
}
|
|
393
|
+
get size() {
|
|
394
|
+
return this.#entries.size;
|
|
395
|
+
}
|
|
396
|
+
get(key) {
|
|
397
|
+
const value = this.#entries.get(key);
|
|
398
|
+
if (value === undefined)
|
|
399
|
+
return undefined;
|
|
400
|
+
this.#entries.delete(key);
|
|
401
|
+
this.#entries.set(key, value);
|
|
402
|
+
return value;
|
|
403
|
+
}
|
|
404
|
+
set(key, value) {
|
|
405
|
+
this.#entries.delete(key);
|
|
406
|
+
this.#entries.set(key, value);
|
|
407
|
+
while (this.#entries.size > this.#limit) {
|
|
408
|
+
const oldest = this.#entries.keys().next().value;
|
|
409
|
+
if (oldest === undefined)
|
|
410
|
+
break;
|
|
411
|
+
this.#entries.delete(oldest);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* The compiler's proof that every shape was handled.
|
|
417
|
+
*
|
|
418
|
+
* Three places switch on `kind` -- the two renderers and the hit test --
|
|
419
|
+
* and none of them was checked. Adding a kind to `CanvasLeafNode`
|
|
420
|
+
* produced no error in any of them, verified by adding one: zero
|
|
421
|
+
* diagnostics, because `drawNode` returns `void` so a missing case falls
|
|
422
|
+
* through, `renderNode` returns `ReactNode` and `undefined` is a valid
|
|
423
|
+
* one, and `pointInNode`'s caller takes its result as a condition. A
|
|
424
|
+
* shape whose renderer was forgotten drew nothing, refused every press,
|
|
425
|
+
* and said nothing about either.
|
|
426
|
+
*
|
|
427
|
+
* The parameter typed `never` is what fixes that: reaching it with a kind
|
|
428
|
+
* still in the union is a compile error naming the kind. At run time it
|
|
429
|
+
* warns rather than throws -- the type has already made this unreachable
|
|
430
|
+
* from TypeScript, and a hand-built scene from JavaScript should lose one
|
|
431
|
+
* shape rather than the whole chart.
|
|
432
|
+
*/
|
|
433
|
+
export function unhandledShape(node, where) {
|
|
434
|
+
const kind = node.kind;
|
|
435
|
+
console.warn(`[hozo] ${where} has no case for a Canvas ${String(kind)}, so it does nothing.`);
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The named interactive shapes, in the order they were drawn.
|
|
440
|
+
*
|
|
441
|
+
* Scene order and not registration order, so the tab order a keyboard
|
|
442
|
+
* walks is the order an eye reads. The registry knows the handlers; only
|
|
443
|
+
* the scene knows where they sit.
|
|
444
|
+
*
|
|
445
|
+
* Unnamed ones are left out and reported instead. A `<button>` with no
|
|
446
|
+
* accessible name is announced as "button" and is the invisible control
|
|
447
|
+
* this whole route exists to avoid, so the shape stays pointer-only and
|
|
448
|
+
* says so rather than becoming one.
|
|
449
|
+
*/
|
|
450
|
+
const warned = new Set();
|
|
451
|
+
export function canvasControls(scene, interactions, warn) {
|
|
452
|
+
const found = [];
|
|
453
|
+
const walk = (nodes) => {
|
|
454
|
+
for (const node of nodes) {
|
|
455
|
+
if (node.id !== undefined && interactions.has(node.id)) {
|
|
456
|
+
const label = interactions.label(node.id);
|
|
457
|
+
if (label === undefined) {
|
|
458
|
+
// Once per shape, not once per render: `useId` is stable for
|
|
459
|
+
// the life of the component, and a redraw is not new news.
|
|
460
|
+
if (!warned.has(node.id)) {
|
|
461
|
+
warned.add(node.id);
|
|
462
|
+
warn?.(`an interactive Canvas ${node.kind} has no accessibilityLabel, so it can only be ` +
|
|
463
|
+
'reached with a pointer. Name it to give it a keyboard control.');
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
found.push({ id: node.id, label, destination: interactions.destination(node.id) });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (node.kind === 'group' || node.kind === 'clip')
|
|
471
|
+
walk(node.children);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
walk(scene);
|
|
475
|
+
return found;
|
|
476
|
+
}
|
|
477
|
+
const reportedLosses = new Set();
|
|
478
|
+
/**
|
|
479
|
+
* The drawn words a person using a screen reader will never get.
|
|
480
|
+
*
|
|
481
|
+
* Canvas text is pixels. Unlike SVG, where the fix was a role that stops
|
|
482
|
+
* hiding the children, there is nothing here to expose -- so `role="img"`
|
|
483
|
+
* on a Canvas is right, and the defect is not the role but the silence.
|
|
484
|
+
*
|
|
485
|
+
* Four things mean nothing was lost, and each is the author saying
|
|
486
|
+
* something different rather than the same suppression spelled four ways:
|
|
487
|
+
*
|
|
488
|
+
* - an `accessibleFallback`: "the content is here". The fix, and the
|
|
489
|
+
* only one that supplies the data. Whether it really contains it is
|
|
490
|
+
* not checkable from here, and presence is the honest signal.
|
|
491
|
+
* - `decorative` on the surface: "this drawing carries no information".
|
|
492
|
+
* - `decorative` on the text: "these words are decoration".
|
|
493
|
+
* - the words being in the name already.
|
|
494
|
+
*
|
|
495
|
+
* Returns what is lost rather than a boolean, so a caller can say which
|
|
496
|
+
* words rather than that some exist.
|
|
497
|
+
*/
|
|
498
|
+
export function canvasUnreadableText(scene, accessibleName) {
|
|
499
|
+
const name = (accessibleName ?? '').toLowerCase();
|
|
500
|
+
const lost = [];
|
|
501
|
+
const walk = (nodes) => {
|
|
502
|
+
for (const node of nodes) {
|
|
503
|
+
if (node.kind === 'group' || node.kind === 'clip') {
|
|
504
|
+
walk(node.children);
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (node.kind !== 'text' || node.props.decorative)
|
|
508
|
+
continue;
|
|
509
|
+
const text = node.props.text.trim();
|
|
510
|
+
if (text !== '' && !name.includes(text.toLowerCase()))
|
|
511
|
+
lost.push(text);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
walk(scene);
|
|
515
|
+
return lost;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Says it once per surface per distinct loss.
|
|
519
|
+
*
|
|
520
|
+
* Not once ever: a chart whose labels change has lost different words and
|
|
521
|
+
* that is news. Not once per render either -- a redraw is not.
|
|
522
|
+
*/
|
|
523
|
+
export function reportUnreadableText(lost, warn) {
|
|
524
|
+
if (lost.length === 0)
|
|
525
|
+
return;
|
|
526
|
+
const key = lost.join('\u0000');
|
|
527
|
+
if (reportedLosses.has(key))
|
|
528
|
+
return;
|
|
529
|
+
reportedLosses.add(key);
|
|
530
|
+
const shown = lost.slice(0, 3).join('", "');
|
|
531
|
+
const rest = lost.length > 3 ? ` and ${lost.length - 3} more` : '';
|
|
532
|
+
warn(`this Canvas draws words no screen reader can read -- "${shown}"${rest}. Canvas text is ` +
|
|
533
|
+
'pixels, and the accessibilityLabel on the surface does not contain them. Pass an ' +
|
|
534
|
+
'accessibleFallback with the same information -- a table, a list, a paragraph -- or mark ' +
|
|
535
|
+
'the text decorative if it carries none.');
|
|
536
|
+
}
|
|
537
|
+
/** Shared by the Web and Native roots; `collector` executes arbitrary React composition. */
|
|
538
|
+
export function useCanvasScene(children) {
|
|
539
|
+
const storeRef = useRef(null);
|
|
540
|
+
if (!storeRef.current)
|
|
541
|
+
storeRef.current = new CanvasSceneStore();
|
|
542
|
+
const store = storeRef.current;
|
|
543
|
+
const interactionStoreRef = useRef(null);
|
|
544
|
+
if (!interactionStoreRef.current)
|
|
545
|
+
interactionStoreRef.current = new CanvasInteractionStore();
|
|
546
|
+
const interactions = interactionStoreRef.current;
|
|
547
|
+
const activeStoreRef = useRef(null);
|
|
548
|
+
if (!activeStoreRef.current)
|
|
549
|
+
activeStoreRef.current = new CanvasActiveStore();
|
|
550
|
+
const active = activeStoreRef.current;
|
|
551
|
+
const [revision, setRevision] = useState(store.version);
|
|
552
|
+
const [interactionRevision, setInteractionRevision] = useState(interactions.version);
|
|
553
|
+
useIsoLayoutEffect(() => {
|
|
554
|
+
setRevision(store.version);
|
|
555
|
+
return store.subscribe(() => setRevision(store.version));
|
|
556
|
+
}, [store]);
|
|
557
|
+
useIsoLayoutEffect(() => {
|
|
558
|
+
setInteractionRevision(interactions.version);
|
|
559
|
+
return interactions.subscribe(() => setInteractionRevision(interactions.version));
|
|
560
|
+
}, [interactions]);
|
|
561
|
+
const rootContext = useMemo(() => ({ store, interactions, active }), [store, interactions, active]);
|
|
562
|
+
const collector = useMemo(() => _jsx(SceneContext.Provider, { value: rootContext, children: children }), [rootContext, children]);
|
|
563
|
+
// A shape is worth hit testing if either handler is on it. Without the
|
|
564
|
+
// second half a hover-only shape would never be found, and `onActiveChange`
|
|
565
|
+
// would be a prop that type-checks and never fires.
|
|
566
|
+
const isInteractive = useCallback((id) => interactions.has(id) || active.has(id), [interactions, active]);
|
|
567
|
+
const press = useCallback((id, event) => {
|
|
568
|
+
interactions.press(id, event);
|
|
569
|
+
return event.defaultPrevented ? undefined : interactions.destination(id);
|
|
570
|
+
}, [interactions]);
|
|
571
|
+
const activate = useCallback((id, event) => active.activate(id, event), [active]);
|
|
572
|
+
return {
|
|
573
|
+
// `revision` is read by nothing, and that is the point of it: a
|
|
574
|
+
// counter the store bumps, whose only job is to invalidate this
|
|
575
|
+
// snapshot. `biome check --unsafe` removed it once, and every hover
|
|
576
|
+
// and press test in this package failed with nothing under the
|
|
577
|
+
// pointer, because the scene never refreshed.
|
|
578
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: it is what invalidates the snapshot
|
|
579
|
+
scene: useMemo(() => store.snapshot(), [store, revision]),
|
|
580
|
+
// A scene revision redraws the platform surface, but must not rerender
|
|
581
|
+
// every marker just because the root observed it. Stable provider value
|
|
582
|
+
// and element identity keep large scenes from doing that second pass.
|
|
583
|
+
collector,
|
|
584
|
+
isInteractive,
|
|
585
|
+
press,
|
|
586
|
+
activate,
|
|
587
|
+
interactions,
|
|
588
|
+
interactionRevision,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
//# sourceMappingURL=scene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.js","sourceRoot":"","sources":["../src/scene.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,EACL,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AAsCd,8FAA8F;AAC9F,MAAM,UAAU,gBAAgB,CAC9B,KAAkB,EAClB,YAAyB,EACzB,SAAS,GAAyB,EAAE;IAEpC,IAAI,gBAAgB,GAAG,KAAK,CAAA;IAC5B,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAA;IACrC,uEAAuE;IACvE,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE;QAC7B,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,IAAI,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/D,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,IAAI,KAAK,EAAE,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AAE,CAAC,CAAA;IAC1E,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAA;IACD,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,EAAsB,EAAE,KAAmC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,EAC3F,CAAC,MAAM,CAAC,CACT,CAAA;IAED,OAAO;QACL,gEAAgE;QAChE,gEAAgE;QAChE,oEAAoE;QACpE,+DAA+D;QAC/D,8CAA8C;QAC9C,+FAA+F;QAC/F,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzD,uEAAuE;QACvE,wEAAwE;QACxE,sEAAsE;QACtE,SAAS;QACT,aAAa;QACb,KAAK;QACL,QAAQ;QACR,YAAY;QACZ,mBAAmB;KACpB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Platform-free geometry used to map a scene onto its drawing surface. */
|
|
2
|
+
export interface CanvasViewport {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
pixelRatio: number;
|
|
6
|
+
viewBox?: readonly [x: number, y: number, width: number, height: number];
|
|
7
|
+
fit?: 'contain' | 'stretch';
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACxE,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAC5B"}
|
package/dist/viewport.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TextProps } from './scene.tsx';
|
|
2
|
+
/**
|
|
3
|
+
* Greedily fills lines no wider than `maxWidth`, measured by `widthOf`.
|
|
4
|
+
*
|
|
5
|
+
* Greedy rather than balanced (Knuth-Plass and the like): a chart label
|
|
6
|
+
* is two or three lines, where the two agree, and greedy is the rule
|
|
7
|
+
* every browser and both renderers already follow for everything else on
|
|
8
|
+
* the screen.
|
|
9
|
+
*
|
|
10
|
+
* `\n` always breaks, and a line's trailing spaces are dropped -- they
|
|
11
|
+
* would otherwise push a line over the width with nothing visible in the
|
|
12
|
+
* space they take.
|
|
13
|
+
*/
|
|
14
|
+
export declare function wrapText(text: string, maxWidth: number, widthOf: (run: string) => number): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Every line of a run, with the baseline each one sits on.
|
|
17
|
+
*
|
|
18
|
+
* One line when there is no `maxWidth`, so everything downstream is
|
|
19
|
+
* written against lines rather than against a special case. Lives here
|
|
20
|
+
* rather than in the hit test because both renderers need it too, and
|
|
21
|
+
* a renderer importing from the hit test would have the arrow pointing
|
|
22
|
+
* the wrong way.
|
|
23
|
+
*/
|
|
24
|
+
export declare function textLines(props: TextProps, widthOf: (run: string) => number): {
|
|
25
|
+
text: string;
|
|
26
|
+
y: number;
|
|
27
|
+
}[];
|
|
28
|
+
//# sourceMappingURL=wrap-text.d.ts.map
|