@hypen-space/web 0.4.1 → 0.4.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 +47 -0
- package/dist/canvas/events.d.ts +87 -0
- package/dist/canvas/index.d.ts +11 -0
- package/dist/canvas/index.js +19 -13
- package/dist/canvas/index.js.map +6 -6
- package/dist/canvas/input.d.ts +56 -0
- package/dist/canvas/layout.d.ts +10 -0
- package/dist/canvas/layout.js +17 -12
- package/dist/canvas/layout.js.map +4 -4
- package/dist/canvas/paint.d.ts +14 -0
- package/dist/canvas/paint.js +3 -2
- package/dist/canvas/paint.js.map +4 -4
- package/dist/canvas/renderer.d.ts +99 -0
- package/dist/canvas/renderer.js +19 -13
- package/dist/canvas/renderer.js.map +6 -6
- package/dist/canvas/text.d.ts +22 -0
- package/dist/canvas/text.js +2 -2
- package/dist/canvas/text.js.map +2 -2
- package/dist/canvas/types.d.ts +96 -0
- package/dist/canvas/utils.d.ts +44 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +46 -21
- package/dist/client.js.map +12 -11
- package/dist/dom/applicators/advanced-layout.d.ts +5 -0
- package/dist/dom/applicators/advanced-layout.js +1 -114
- package/dist/dom/applicators/advanced-layout.js.map +4 -5
- package/dist/dom/applicators/background.d.ts +5 -0
- package/dist/dom/applicators/border.d.ts +5 -0
- package/dist/dom/applicators/color.d.ts +5 -0
- package/dist/dom/applicators/display.d.ts +5 -0
- package/dist/dom/applicators/effects.d.ts +5 -0
- package/dist/dom/applicators/events.d.ts +8 -0
- package/dist/dom/applicators/events.js +3 -2
- package/dist/dom/applicators/events.js.map +3 -3
- package/dist/dom/applicators/font.d.ts +29 -0
- package/dist/dom/applicators/index.d.ts +76 -0
- package/dist/dom/applicators/index.js +3 -8
- package/dist/dom/applicators/index.js.map +4 -4
- package/dist/dom/applicators/layout.d.ts +10 -0
- package/dist/dom/applicators/margin.d.ts +11 -0
- package/dist/dom/applicators/padding.d.ts +11 -0
- package/dist/dom/applicators/size.d.ts +14 -0
- package/dist/dom/applicators/transform.d.ts +5 -0
- package/dist/dom/applicators/transition.d.ts +5 -0
- package/dist/dom/applicators/types.d.ts +6 -0
- package/dist/dom/applicators/typography.d.ts +5 -0
- package/dist/dom/canvas/index.d.ts +12 -0
- package/dist/dom/components/app.d.ts +8 -0
- package/dist/dom/components/app.js +55 -0
- package/dist/dom/components/app.js.map +10 -0
- package/dist/dom/components/audio.d.ts +5 -0
- package/dist/dom/components/avatar.d.ts +5 -0
- package/dist/dom/components/badge.d.ts +5 -0
- package/dist/dom/components/button.d.ts +9 -0
- package/dist/dom/components/card.d.ts +5 -0
- package/dist/dom/components/center.d.ts +9 -0
- package/dist/dom/components/checkbox.d.ts +5 -0
- package/dist/dom/components/column.d.ts +8 -0
- package/dist/dom/components/container.d.ts +5 -0
- package/dist/dom/components/divider.d.ts +5 -0
- package/dist/dom/components/grid.d.ts +7 -0
- package/dist/dom/components/heading.d.ts +5 -0
- package/dist/dom/components/hypenapp.d.ts +19 -0
- package/dist/dom/components/hypenapp.js +2 -4
- package/dist/dom/components/hypenapp.js.map +3 -3
- package/dist/dom/components/image.d.ts +5 -0
- package/dist/dom/components/index.d.ts +29 -0
- package/dist/dom/components/index.js +29 -5
- package/dist/dom/components/index.js.map +7 -6
- package/dist/dom/components/input.d.ts +5 -0
- package/dist/dom/components/link.d.ts +5 -0
- package/dist/dom/components/list.d.ts +5 -0
- package/dist/dom/components/paragraph.d.ts +5 -0
- package/dist/dom/components/progressbar.d.ts +5 -0
- package/dist/dom/components/route.d.ts +6 -0
- package/dist/dom/components/route.js +2 -2
- package/dist/dom/components/route.js.map +2 -2
- package/dist/dom/components/router.d.ts +5 -0
- package/dist/dom/components/row.d.ts +7 -0
- package/dist/dom/components/select.d.ts +5 -0
- package/dist/dom/components/slider.d.ts +5 -0
- package/dist/dom/components/spacer.d.ts +5 -0
- package/dist/dom/components/spinner.d.ts +5 -0
- package/dist/dom/components/stack.d.ts +5 -0
- package/dist/dom/components/switch.d.ts +5 -0
- package/dist/dom/components/text.d.ts +5 -0
- package/dist/dom/components/textarea.d.ts +5 -0
- package/dist/dom/components/video.d.ts +5 -0
- package/dist/dom/debug.d.ts +63 -0
- package/dist/dom/debug.js +2 -2
- package/dist/dom/debug.js.map +2 -2
- package/dist/dom/element-data.d.ts +94 -0
- package/dist/dom/events.d.ts +39 -0
- package/dist/dom/events.js +2 -2
- package/dist/dom/events.js.map +2 -2
- package/dist/dom/index.d.ts +10 -0
- package/dist/dom/index.js +46 -21
- package/dist/dom/index.js.map +12 -11
- package/dist/dom/renderer.d.ts +115 -0
- package/dist/dom/renderer.js +45 -20
- package/dist/dom/renderer.js.map +11 -10
- package/dist/hypen.d.ts +140 -0
- package/dist/hypen.js +46 -21
- package/dist/hypen.js.map +12 -11
- package/dist/index.d.ts +28 -0
- package/dist/index.js +64 -33
- package/dist/index.js.map +16 -15
- package/package.json +3 -2
- package/src/dom/components/index.ts +2 -0
- package/src/dom/renderer.ts +18 -6
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Layer
|
|
3
|
+
*
|
|
4
|
+
* Maintain shadow DOM for screen readers
|
|
5
|
+
*/
|
|
6
|
+
import type { VirtualNode } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Accessibility Manager
|
|
9
|
+
*/
|
|
10
|
+
export declare class AccessibilityLayer {
|
|
11
|
+
private shadowRoot;
|
|
12
|
+
private nodeMap;
|
|
13
|
+
private enabled;
|
|
14
|
+
constructor(container: HTMLElement | null, enabled?: boolean);
|
|
15
|
+
/**
|
|
16
|
+
* Sync shadow DOM with virtual tree
|
|
17
|
+
*/
|
|
18
|
+
syncTree(root: VirtualNode): void;
|
|
19
|
+
/**
|
|
20
|
+
* Create shadow DOM element for virtual node
|
|
21
|
+
*/
|
|
22
|
+
private createShadowNode;
|
|
23
|
+
/**
|
|
24
|
+
* Get text content from node tree
|
|
25
|
+
*/
|
|
26
|
+
private getNodeText;
|
|
27
|
+
/**
|
|
28
|
+
* Focus node in shadow DOM
|
|
29
|
+
*/
|
|
30
|
+
focusNode(nodeId: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Update single node
|
|
33
|
+
*/
|
|
34
|
+
updateNode(node: VirtualNode): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get shadow element by node ID
|
|
37
|
+
*/
|
|
38
|
+
getElement(nodeId: string): HTMLElement | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Enable or disable accessibility layer
|
|
41
|
+
*/
|
|
42
|
+
setEnabled(enabled: boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* Cleanup
|
|
45
|
+
*/
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event System
|
|
3
|
+
*
|
|
4
|
+
* Hit testing and event handling for canvas nodes
|
|
5
|
+
*/
|
|
6
|
+
import type { VirtualNode } from "./types.js";
|
|
7
|
+
interface IEngine {
|
|
8
|
+
dispatchAction(name: string, payload?: any): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Canvas Event Manager
|
|
12
|
+
*/
|
|
13
|
+
export declare class CanvasEventManager {
|
|
14
|
+
private canvas;
|
|
15
|
+
private engine;
|
|
16
|
+
private rootNode;
|
|
17
|
+
private hoveredNode;
|
|
18
|
+
private focusedNode;
|
|
19
|
+
private mouseDownNode;
|
|
20
|
+
constructor(canvas: HTMLCanvasElement, engine: IEngine);
|
|
21
|
+
/**
|
|
22
|
+
* Set the root node for hit testing
|
|
23
|
+
*/
|
|
24
|
+
setRootNode(node: VirtualNode | null): void;
|
|
25
|
+
/**
|
|
26
|
+
* Setup canvas event listeners
|
|
27
|
+
*/
|
|
28
|
+
private setupEventListeners;
|
|
29
|
+
/**
|
|
30
|
+
* Get canvas coordinates from mouse event
|
|
31
|
+
*/
|
|
32
|
+
private getCanvasCoordinates;
|
|
33
|
+
/**
|
|
34
|
+
* Find node at canvas coordinates
|
|
35
|
+
*/
|
|
36
|
+
private hitTest;
|
|
37
|
+
/**
|
|
38
|
+
* Recursively test node and children
|
|
39
|
+
*/
|
|
40
|
+
private hitTestNode;
|
|
41
|
+
/**
|
|
42
|
+
* Handle mouse move
|
|
43
|
+
*/
|
|
44
|
+
private onMouseMove;
|
|
45
|
+
/**
|
|
46
|
+
* Handle mouse down
|
|
47
|
+
*/
|
|
48
|
+
private onMouseDown;
|
|
49
|
+
/**
|
|
50
|
+
* Handle mouse up
|
|
51
|
+
*/
|
|
52
|
+
private onMouseUp;
|
|
53
|
+
/**
|
|
54
|
+
* Handle click
|
|
55
|
+
*/
|
|
56
|
+
private onClick;
|
|
57
|
+
/**
|
|
58
|
+
* Handle double click
|
|
59
|
+
*/
|
|
60
|
+
private onDoubleClick;
|
|
61
|
+
/**
|
|
62
|
+
* Handle keyboard events
|
|
63
|
+
*/
|
|
64
|
+
private onKeyDown;
|
|
65
|
+
private onKeyUp;
|
|
66
|
+
/**
|
|
67
|
+
* Set focused node
|
|
68
|
+
*/
|
|
69
|
+
private setFocus;
|
|
70
|
+
/**
|
|
71
|
+
* Update cursor based on node
|
|
72
|
+
*/
|
|
73
|
+
private updateCursor;
|
|
74
|
+
/**
|
|
75
|
+
* Dispatch event to engine
|
|
76
|
+
*/
|
|
77
|
+
private dispatchNodeEvent;
|
|
78
|
+
/**
|
|
79
|
+
* Request redraw from renderer
|
|
80
|
+
*/
|
|
81
|
+
private requestRedraw;
|
|
82
|
+
/**
|
|
83
|
+
* Cleanup
|
|
84
|
+
*/
|
|
85
|
+
destroy(): void;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Renderer for Hypen
|
|
3
|
+
*
|
|
4
|
+
* Browser-only module for rendering Hypen UI to Canvas
|
|
5
|
+
*/
|
|
6
|
+
export { CanvasRenderer } from "./renderer.js";
|
|
7
|
+
export { registerPainter } from "./paint.js";
|
|
8
|
+
export { CanvasEventManager } from "./events.js";
|
|
9
|
+
export { InputOverlay } from "./input.js";
|
|
10
|
+
export { AccessibilityLayer } from "./accessibility.js";
|
|
11
|
+
export type { VirtualNode, Layout, Rectangle, Point, FontStyle, TextStyle, TextMetrics, CanvasRendererOptions, PainterFunction, LayoutFunction, } from "./types.js";
|
package/dist/canvas/index.js
CHANGED
|
@@ -151,7 +151,7 @@ function getAbsoluteBounds(node) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// src/canvas/text.ts
|
|
154
|
-
import { frameworkLoggers } from "@hypen-space/core";
|
|
154
|
+
import { frameworkLoggers } from "@hypen-space/core/logger";
|
|
155
155
|
var log = frameworkLoggers.canvas;
|
|
156
156
|
var textMetricsCache = new Map;
|
|
157
157
|
function getCacheKey(text, fontStyle, maxWidth) {
|
|
@@ -287,7 +287,12 @@ function computeLayout(ctx, node, availableWidth, availableHeight, x = 0, y = 0)
|
|
|
287
287
|
let width = parseSize(props.width);
|
|
288
288
|
let height = parseSize(props.height);
|
|
289
289
|
const type = node.type.toLowerCase();
|
|
290
|
-
if (type === "
|
|
290
|
+
if (type === "app") {
|
|
291
|
+
if (width === null)
|
|
292
|
+
width = availableAfterMargin.width;
|
|
293
|
+
if (height === null)
|
|
294
|
+
height = availableAfterMargin.height;
|
|
295
|
+
} else if (type === "spacer") {
|
|
291
296
|
if (width === null)
|
|
292
297
|
width = availableAfterMargin.width;
|
|
293
298
|
if (height === null)
|
|
@@ -410,10 +415,10 @@ function layoutChildren(ctx, parent) {
|
|
|
410
415
|
return;
|
|
411
416
|
}
|
|
412
417
|
const flexDirection = props.flexDirection || (parent.type === "column" ? "column" : "row");
|
|
413
|
-
const justifyContent = props.justifyContent || "flex-start";
|
|
414
|
-
const alignItems = props.alignItems || "flex-start";
|
|
415
|
-
const gap = parseFloat(props.gap) || 0;
|
|
416
418
|
const isColumn = flexDirection === "column";
|
|
419
|
+
const justifyContent = isColumn ? props.verticalAlignment || "flex-start" : props.horizontalAlignment || "flex-start";
|
|
420
|
+
const alignItems = isColumn ? props.horizontalAlignment || "flex-start" : props.verticalAlignment || "flex-start";
|
|
421
|
+
const gap = parseFloat(props.gap) || 0;
|
|
417
422
|
const availableWidth = layout.contentWidth;
|
|
418
423
|
const availableHeight = layout.contentHeight;
|
|
419
424
|
const childInfo = [];
|
|
@@ -526,8 +531,8 @@ function layoutChildren(ctx, parent) {
|
|
|
526
531
|
function layoutStackChildren(ctx, parent) {
|
|
527
532
|
const layout = parent.layout;
|
|
528
533
|
const props = parent.props;
|
|
529
|
-
const
|
|
530
|
-
const
|
|
534
|
+
const horizontalAlignment = props.horizontalAlignment || "flex-start";
|
|
535
|
+
const verticalAlignment = props.verticalAlignment || "flex-start";
|
|
531
536
|
const availableWidth = layout.contentWidth;
|
|
532
537
|
const availableHeight = layout.contentHeight;
|
|
533
538
|
for (const child of parent.children) {
|
|
@@ -535,14 +540,14 @@ function layoutStackChildren(ctx, parent) {
|
|
|
535
540
|
const childLayout = child.layout;
|
|
536
541
|
let x = 0;
|
|
537
542
|
let y = 0;
|
|
538
|
-
if (
|
|
543
|
+
if (horizontalAlignment === "center") {
|
|
539
544
|
x = (availableWidth - childLayout.width) / 2;
|
|
540
|
-
} else if (
|
|
545
|
+
} else if (horizontalAlignment === "flex-end") {
|
|
541
546
|
x = availableWidth - childLayout.width;
|
|
542
547
|
}
|
|
543
|
-
if (
|
|
548
|
+
if (verticalAlignment === "center") {
|
|
544
549
|
y = (availableHeight - childLayout.height) / 2;
|
|
545
|
-
} else if (
|
|
550
|
+
} else if (verticalAlignment === "flex-end") {
|
|
546
551
|
y = availableHeight - childLayout.height;
|
|
547
552
|
}
|
|
548
553
|
childLayout.x = layout.x + layout.contentX + x;
|
|
@@ -629,6 +634,7 @@ function paintNode(ctx, node) {
|
|
|
629
634
|
case "link":
|
|
630
635
|
paintLink(ctx, node);
|
|
631
636
|
break;
|
|
637
|
+
case "app":
|
|
632
638
|
case "container":
|
|
633
639
|
case "box":
|
|
634
640
|
paintContainer(ctx, node);
|
|
@@ -1867,7 +1873,7 @@ class AccessibilityLayer {
|
|
|
1867
1873
|
}
|
|
1868
1874
|
|
|
1869
1875
|
// src/canvas/renderer.ts
|
|
1870
|
-
import { frameworkLoggers as frameworkLoggers2 } from "@hypen-space/core";
|
|
1876
|
+
import { frameworkLoggers as frameworkLoggers2 } from "@hypen-space/core/logger";
|
|
1871
1877
|
var log2 = frameworkLoggers2.canvas;
|
|
1872
1878
|
var DEFAULT_OPTIONS = {
|
|
1873
1879
|
devicePixelRatio: typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1,
|
|
@@ -2125,4 +2131,4 @@ export {
|
|
|
2125
2131
|
AccessibilityLayer
|
|
2126
2132
|
};
|
|
2127
2133
|
|
|
2128
|
-
//# debugId=
|
|
2134
|
+
//# debugId=E5B9EAD552EC078164756E2164756E21
|