@hypen-space/web 0.5.2 → 0.5.3
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/dist/canvas/accessibility.d.ts +118 -11
- package/dist/canvas/accessibility.js +470 -108
- package/dist/canvas/accessibility.js.map +1 -1
- package/dist/canvas/dispatch.d.ts +24 -0
- package/dist/canvas/dispatch.js +62 -0
- package/dist/canvas/dispatch.js.map +1 -0
- package/dist/canvas/editing.d.ts +178 -0
- package/dist/canvas/editing.js +590 -0
- package/dist/canvas/editing.js.map +1 -0
- package/dist/canvas/events.d.ts +28 -23
- package/dist/canvas/events.js +76 -128
- package/dist/canvas/events.js.map +1 -1
- package/dist/canvas/focus.d.ts +78 -0
- package/dist/canvas/focus.js +182 -0
- package/dist/canvas/focus.js.map +1 -0
- package/dist/canvas/index.d.ts +3 -1
- package/dist/canvas/index.js +3 -1
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/paint.d.ts +16 -3
- package/dist/canvas/paint.js +283 -41
- package/dist/canvas/paint.js.map +1 -1
- package/dist/canvas/renderer.d.ts +20 -1
- package/dist/canvas/renderer.js +181 -50
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/selection.js +31 -177
- package/dist/canvas/selection.js.map +1 -1
- package/dist/canvas/text-geometry.d.ts +72 -0
- package/dist/canvas/text-geometry.js +244 -0
- package/dist/canvas/text-geometry.js.map +1 -0
- package/dist/canvas/text.js +42 -9
- package/dist/canvas/text.js.map +1 -1
- package/dist/canvas/types.d.ts +7 -1
- package/dist/canvas/variants.d.ts +4 -1
- package/dist/canvas/variants.js +22 -3
- package/dist/canvas/variants.js.map +1 -1
- package/dist/dom/a11y-styles.d.ts +20 -0
- package/dist/dom/a11y-styles.js +61 -0
- package/dist/dom/a11y-styles.js.map +1 -0
- package/dist/dom/applicators/aria.d.ts +19 -0
- package/dist/dom/applicators/aria.js +36 -0
- package/dist/dom/applicators/aria.js.map +1 -0
- package/dist/dom/applicators/events.d.ts +7 -0
- package/dist/dom/applicators/events.js +35 -8
- package/dist/dom/applicators/events.js.map +1 -1
- package/dist/dom/applicators/index.js +4 -0
- package/dist/dom/applicators/index.js.map +1 -1
- package/dist/dom/components/hypenapp.d.ts +25 -1
- package/dist/dom/components/hypenapp.js +213 -245
- package/dist/dom/components/hypenapp.js.map +1 -1
- package/dist/dom/components/index.js +7 -0
- package/dist/dom/components/index.js.map +1 -1
- package/dist/dom/components/spinner.js +24 -10
- package/dist/dom/components/spinner.js.map +1 -1
- package/dist/dom/components/tabs.d.ts +27 -0
- package/dist/dom/components/tabs.js +69 -0
- package/dist/dom/components/tabs.js.map +1 -0
- package/dist/dom/components/visuallyhidden.d.ts +9 -0
- package/dist/dom/components/visuallyhidden.js +26 -0
- package/dist/dom/components/visuallyhidden.js.map +1 -0
- package/dist/dom/operability.d.ts +100 -0
- package/dist/dom/operability.js +298 -0
- package/dist/dom/operability.js.map +1 -0
- package/dist/dom/renderer.d.ts +98 -5
- package/dist/dom/renderer.js +398 -63
- package/dist/dom/renderer.js.map +1 -1
- package/dist/dom/route-focus.d.ts +42 -0
- package/dist/dom/route-focus.js +88 -0
- package/dist/dom/route-focus.js.map +1 -0
- package/dist/dom/semantics.d.ts +35 -0
- package/dist/dom/semantics.js +184 -0
- package/dist/dom/semantics.js.map +1 -0
- package/package.json +2 -2
- package/src/canvas/QUICKSTART.md +4 -4
- package/src/canvas/README.md +55 -29
- package/src/canvas/accessibility.ts +507 -115
- package/src/canvas/dispatch.ts +78 -0
- package/src/canvas/editing.ts +697 -0
- package/src/canvas/events.ts +89 -142
- package/src/canvas/focus.ts +216 -0
- package/src/canvas/index.ts +8 -1
- package/src/canvas/paint.ts +339 -42
- package/src/canvas/renderer.ts +218 -70
- package/src/canvas/selection.ts +52 -210
- package/src/canvas/text-geometry.ts +311 -0
- package/src/canvas/text.ts +43 -9
- package/src/canvas/types.ts +14 -1
- package/src/canvas/variants.ts +24 -5
- package/src/dom/a11y-styles.ts +65 -0
- package/src/dom/applicators/aria.ts +41 -0
- package/src/dom/applicators/events.ts +38 -7
- package/src/dom/applicators/index.ts +5 -0
- package/src/dom/components/hypenapp.ts +244 -272
- package/src/dom/components/index.ts +7 -0
- package/src/dom/components/spinner.ts +31 -13
- package/src/dom/components/tabs.ts +76 -0
- package/src/dom/components/visuallyhidden.ts +30 -0
- package/src/dom/operability.ts +312 -0
- package/src/dom/renderer.ts +455 -63
- package/src/dom/route-focus.ts +98 -0
- package/src/dom/semantics.ts +199 -0
- package/dist/canvas/input.d.ts +0 -76
- package/dist/canvas/input.js +0 -207
- package/dist/canvas/input.js.map +0 -1
- package/src/canvas/input.ts +0 -251
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus Manager
|
|
3
|
+
*
|
|
4
|
+
* Real DOM focus on accessibility-mirror elements (canvas fallback content)
|
|
5
|
+
* is the single source of truth for canvas focus. Tab/Shift+Tab traverse
|
|
6
|
+
* the mirror natively; `focusin`/`focusout` translate DOM focus into
|
|
7
|
+
* `node.focused` + repaint; the pointer path (canvas hit-test) funnels into
|
|
8
|
+
* the same place by focusing the node's mirror element.
|
|
9
|
+
*
|
|
10
|
+
* Loop-free by construction: DOM focus events only ever *read* into node
|
|
11
|
+
* state — nothing in the sync path calls `.focus()` back.
|
|
12
|
+
*
|
|
13
|
+
* The mirror also carries keyboard/AT interaction back to the engine:
|
|
14
|
+
* Enter/Space on a mirror `<button>` produces a native `click` (dispatched
|
|
15
|
+
* to the node's action), and keydown/keyup on the focused element dispatch
|
|
16
|
+
* the node's `onKeyDown`/`onKeyUp` applicators — which the old
|
|
17
|
+
* canvas-attached listeners never could (a canvas without tabindex never
|
|
18
|
+
* receives key events).
|
|
19
|
+
*/
|
|
20
|
+
import { dispatchNodeEvent } from "./dispatch.js";
|
|
21
|
+
export class FocusManager {
|
|
22
|
+
mirror;
|
|
23
|
+
engine;
|
|
24
|
+
hooks;
|
|
25
|
+
focusedNode = null;
|
|
26
|
+
boundFocusIn = (e) => this.onFocusIn(e);
|
|
27
|
+
boundFocusOut = (e) => this.onFocusOut(e);
|
|
28
|
+
boundClick = (e) => this.onMirrorClick(e);
|
|
29
|
+
boundKeyDown = (e) => this.onMirrorKey("keydown", e);
|
|
30
|
+
boundKeyUp = (e) => this.onMirrorKey("keyup", e);
|
|
31
|
+
constructor(mirror, engine, hooks) {
|
|
32
|
+
this.mirror = mirror;
|
|
33
|
+
this.engine = engine;
|
|
34
|
+
this.hooks = hooks;
|
|
35
|
+
const root = mirror.getRoot();
|
|
36
|
+
if (root && typeof root.addEventListener === "function") {
|
|
37
|
+
root.addEventListener("focusin", this.boundFocusIn);
|
|
38
|
+
root.addEventListener("focusout", this.boundFocusOut);
|
|
39
|
+
root.addEventListener("click", this.boundClick);
|
|
40
|
+
root.addEventListener("keydown", this.boundKeyDown);
|
|
41
|
+
root.addEventListener("keyup", this.boundKeyUp);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
45
|
+
// DOM → node state (the only direction focus state flows)
|
|
46
|
+
// -------------------------------------------------------------------------
|
|
47
|
+
/** Climb from an event target to the mirror element's virtual node. */
|
|
48
|
+
resolveNode(target) {
|
|
49
|
+
let el = target;
|
|
50
|
+
const root = this.mirror.getRoot();
|
|
51
|
+
while (el && el !== root) {
|
|
52
|
+
const id = el.getAttribute?.("data-hypen-id");
|
|
53
|
+
if (id) {
|
|
54
|
+
return this.hooks.getNode(id) ?? null;
|
|
55
|
+
}
|
|
56
|
+
el = el.parentNode ?? null;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
onFocusIn(e) {
|
|
61
|
+
this.syncFocus(this.resolveNode(e.target));
|
|
62
|
+
}
|
|
63
|
+
onFocusOut(e) {
|
|
64
|
+
// If focus moves to another mirror element, its focusin handles the
|
|
65
|
+
// transition; a handoff to the editor's IME proxy keeps the node
|
|
66
|
+
// focused; only a departure from both clears focus.
|
|
67
|
+
const next = e.relatedTarget;
|
|
68
|
+
if (next && this.hooks.isAuxFocusTarget?.(next))
|
|
69
|
+
return;
|
|
70
|
+
const root = this.mirror.getRoot();
|
|
71
|
+
if (!next || !root || !(root.contains?.(next) ?? false)) {
|
|
72
|
+
this.syncFocus(null);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Update node.focused flags from the new DOM focus target. Idempotent. */
|
|
76
|
+
syncFocus(node) {
|
|
77
|
+
if (node === this.focusedNode)
|
|
78
|
+
return;
|
|
79
|
+
const prev = this.focusedNode;
|
|
80
|
+
if (prev) {
|
|
81
|
+
prev.focused = false;
|
|
82
|
+
dispatchNodeEvent(this.engine, prev, "blur", {});
|
|
83
|
+
}
|
|
84
|
+
this.focusedNode = node;
|
|
85
|
+
if (node) {
|
|
86
|
+
node.focused = true;
|
|
87
|
+
dispatchNodeEvent(this.engine, node, "focus", {});
|
|
88
|
+
}
|
|
89
|
+
this.hooks.onFocusChange(node, prev);
|
|
90
|
+
}
|
|
91
|
+
// -------------------------------------------------------------------------
|
|
92
|
+
// Pointer path — canvas hit-test funnels into DOM focus
|
|
93
|
+
// -------------------------------------------------------------------------
|
|
94
|
+
/**
|
|
95
|
+
* Focus a node from the canvas pointer path. Focuses the mirror element
|
|
96
|
+
* (so `document.activeElement` agrees) and syncs node state directly —
|
|
97
|
+
* in real browsers the element's focusin already did that synchronously
|
|
98
|
+
* and the second sync is a no-op; in environments without focus events
|
|
99
|
+
* the direct sync keeps behavior identical.
|
|
100
|
+
*/
|
|
101
|
+
requestFocus(node) {
|
|
102
|
+
if (!node) {
|
|
103
|
+
this.clearFocus();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const el = this.mirror.getElement(node.id);
|
|
107
|
+
el?.focus?.({ preventScroll: true });
|
|
108
|
+
this.syncFocus(node);
|
|
109
|
+
}
|
|
110
|
+
/** Pointer landed on nothing focusable: blur any mirror focus and clear. */
|
|
111
|
+
clearFocus() {
|
|
112
|
+
if (typeof document !== "undefined") {
|
|
113
|
+
const active = document.activeElement;
|
|
114
|
+
const root = this.mirror.getRoot();
|
|
115
|
+
if (active &&
|
|
116
|
+
((root && (root.contains?.(active) ?? false)) ||
|
|
117
|
+
this.hooks.isAuxFocusTarget?.(active))) {
|
|
118
|
+
active.blur?.();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.syncFocus(null);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clear focus if the focused node is `node` or one of its descendants —
|
|
125
|
+
* called before a subtree is removed/detached (the mirror element may
|
|
126
|
+
* leave the DOM without a browser blur when focus sits on the IME proxy).
|
|
127
|
+
*/
|
|
128
|
+
clearIfWithin(node) {
|
|
129
|
+
let current = this.focusedNode;
|
|
130
|
+
while (current) {
|
|
131
|
+
if (current === node) {
|
|
132
|
+
this.syncFocus(null);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
current = current.parent;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
getFocusedNode() {
|
|
139
|
+
return this.focusedNode;
|
|
140
|
+
}
|
|
141
|
+
// -------------------------------------------------------------------------
|
|
142
|
+
// Mirror interaction → engine actions
|
|
143
|
+
// -------------------------------------------------------------------------
|
|
144
|
+
/**
|
|
145
|
+
* Native click on a mirror element — keyboard activation (Enter/Space on
|
|
146
|
+
* a real `<button>`) or an AT-initiated action. Pointer clicks never land
|
|
147
|
+
* here (fallback content has no rendered boxes), so this can't double-fire
|
|
148
|
+
* with the canvas hit-test click path.
|
|
149
|
+
*/
|
|
150
|
+
onMirrorClick(e) {
|
|
151
|
+
const node = this.resolveNode(e.target);
|
|
152
|
+
if (!node)
|
|
153
|
+
return;
|
|
154
|
+
if (!node.clickable)
|
|
155
|
+
return;
|
|
156
|
+
dispatchNodeEvent(this.engine, node, "click", {});
|
|
157
|
+
}
|
|
158
|
+
onMirrorKey(type, e) {
|
|
159
|
+
const node = this.resolveNode(e.target);
|
|
160
|
+
if (!node)
|
|
161
|
+
return;
|
|
162
|
+
dispatchNodeEvent(this.engine, node, type, {
|
|
163
|
+
key: e.key,
|
|
164
|
+
code: e.code,
|
|
165
|
+
ctrlKey: e.ctrlKey,
|
|
166
|
+
shiftKey: e.shiftKey,
|
|
167
|
+
altKey: e.altKey,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
destroy() {
|
|
171
|
+
const root = this.mirror.getRoot();
|
|
172
|
+
if (root && typeof root.removeEventListener === "function") {
|
|
173
|
+
root.removeEventListener("focusin", this.boundFocusIn);
|
|
174
|
+
root.removeEventListener("focusout", this.boundFocusOut);
|
|
175
|
+
root.removeEventListener("click", this.boundClick);
|
|
176
|
+
root.removeEventListener("keydown", this.boundKeyDown);
|
|
177
|
+
root.removeEventListener("keyup", this.boundKeyUp);
|
|
178
|
+
}
|
|
179
|
+
this.focusedNode = null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.js","sourceRoot":"","sources":["../../src/canvas/focus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,iBAAiB,EAAuB,MAAM,eAAe,CAAC;AAevE,MAAM,OAAO,YAAY;IACf,MAAM,CAAqB;IAC3B,MAAM,CAAiB;IACvB,KAAK,CAAoB;IACzB,WAAW,GAAuB,IAAI,CAAC;IAEvC,YAAY,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAe,CAAC,CAAC;IAC7D,aAAa,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAe,CAAC,CAAC;IAC/D,UAAU,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACjD,YAAY,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAA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AU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACzD,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YACnD,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACvD,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
export { CanvasRenderer } from "./renderer.js";
|
|
7
7
|
export { registerPainter } from "./paint.js";
|
|
8
8
|
export { CanvasEventManager } from "./events.js";
|
|
9
|
-
export { InputOverlay } from "./input.js";
|
|
10
9
|
export { AccessibilityLayer } from "./accessibility.js";
|
|
10
|
+
export { FocusManager } from "./focus.js";
|
|
11
|
+
export { TextEditController } from "./editing.js";
|
|
11
12
|
export { initTaffyLayout } from "./layout.js";
|
|
12
13
|
export { ScrollManager } from "./scroll.js";
|
|
13
14
|
export { DirtyRectTracker } from "./dirty.js";
|
|
14
15
|
export { SelectionManager } from "./selection.js";
|
|
16
|
+
export { pointToOffset, offsetToCaretRect, rangeToRects, type TextGeometry, } from "./text-geometry.js";
|
|
15
17
|
export type { VirtualNode, Layout, Rectangle, Point, FontStyle, TextStyle, TextMetrics, ScrollState, CanvasRendererOptions, PainterFunction, LayoutFunction, } from "./types.js";
|
package/dist/canvas/index.js
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
export { CanvasRenderer } from "./renderer.js";
|
|
7
7
|
export { registerPainter } from "./paint.js";
|
|
8
8
|
export { CanvasEventManager } from "./events.js";
|
|
9
|
-
export { InputOverlay } from "./input.js";
|
|
10
9
|
export { AccessibilityLayer } from "./accessibility.js";
|
|
10
|
+
export { FocusManager } from "./focus.js";
|
|
11
|
+
export { TextEditController } from "./editing.js";
|
|
11
12
|
export { initTaffyLayout } from "./layout.js";
|
|
12
13
|
export { ScrollManager } from "./scroll.js";
|
|
13
14
|
export { DirtyRectTracker } from "./dirty.js";
|
|
14
15
|
export { SelectionManager } from "./selection.js";
|
|
16
|
+
export { pointToOffset, offsetToCaretRect, rangeToRects, } from "./text-geometry.js";
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
package/dist/canvas/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,GAEb,MAAM,oBAAoB,CAAC"}
|
package/dist/canvas/paint.d.ts
CHANGED
|
@@ -3,17 +3,30 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Drawing virtual nodes to canvas
|
|
5
5
|
*/
|
|
6
|
-
import type { VirtualNode, PainterFunction } from "./types.js";
|
|
6
|
+
import type { VirtualNode, PainterFunction, Rectangle } from "./types.js";
|
|
7
7
|
import type { SelectionManager } from "./selection.js";
|
|
8
|
+
import type { TextEditController } from "./editing.js";
|
|
8
9
|
export declare function setSelectionManager(mgr: SelectionManager | null): void;
|
|
10
|
+
export declare function setTextEditor(editor: TextEditController | null): void;
|
|
9
11
|
/**
|
|
10
12
|
* Register a custom painter for a component type
|
|
11
13
|
*/
|
|
12
14
|
export declare function registerPainter(type: string, painter: PainterFunction): void;
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
16
|
+
* Clear cached per-character advances. Must be called when web fonts finish
|
|
17
|
+
* loading: the cache is keyed by CSS font string, which is identical before
|
|
18
|
+
* and after a webfont replaces its fallback, so advances measured against
|
|
19
|
+
* the fallback font would otherwise poison letter-spaced rendering
|
|
20
|
+
* permanently.
|
|
15
21
|
*/
|
|
16
|
-
export declare function
|
|
22
|
+
export declare function clearCharAdvanceCache(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Paint a virtual node and its children.
|
|
25
|
+
*
|
|
26
|
+
* `cull` (optional) is the dirty region being repainted — subtrees that
|
|
27
|
+
* provably cannot reach it are skipped entirely.
|
|
28
|
+
*/
|
|
29
|
+
export declare function paintNode(ctx: CanvasRenderingContext2D, node: VirtualNode, cull?: Rectangle | null): void;
|
|
17
30
|
/** Returns width/height of the cached image, or null if unknown. */
|
|
18
31
|
export declare function getImageNaturalAspect(src: string): number | null;
|
|
19
32
|
/** Test helper: seed the intrinsic-size cache without loading a real image. */
|