@web-canvas-ui/angular 0.0.0-stage → 0.2.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.
Files changed (93) hide show
  1. package/README.md +1084 -2
  2. package/index.js +4224 -0
  3. package/package.json +40 -5
  4. package/theme.css +327 -0
  5. package/types/angular/Canvas.d.ts +41 -0
  6. package/types/angular/index.d.ts +4 -0
  7. package/types/angular/node-directives.d.ts +317 -0
  8. package/types/canvas-handle.d.ts +22 -0
  9. package/types/components/Button/button.d.ts +20 -0
  10. package/types/components/Button/index.d.ts +3 -0
  11. package/types/components/Button/logic.d.ts +3 -0
  12. package/types/components/CanvasView/canvasView.d.ts +28 -0
  13. package/types/components/CanvasView/index.d.ts +2 -0
  14. package/types/components/Carousel/carousel.d.ts +31 -0
  15. package/types/components/Carousel/index.d.ts +3 -0
  16. package/types/components/Carousel/logic.d.ts +2 -0
  17. package/types/components/Checkbox/checkbox.d.ts +8 -0
  18. package/types/components/Checkbox/index.d.ts +2 -0
  19. package/types/components/ChoiceGroup/choiceGroup.d.ts +33 -0
  20. package/types/components/ChoiceGroup/index.d.ts +3 -0
  21. package/types/components/ChoiceGroup/logic.d.ts +3 -0
  22. package/types/components/Circle/circle.d.ts +9 -0
  23. package/types/components/Circle/index.d.ts +2 -0
  24. package/types/components/Collapse/collapse.d.ts +32 -0
  25. package/types/components/Collapse/index.d.ts +3 -0
  26. package/types/components/Collapse/logic.d.ts +1 -0
  27. package/types/components/CustomDraw/customDraw.d.ts +22 -0
  28. package/types/components/CustomDraw/index.d.ts +2 -0
  29. package/types/components/DatePicker/datePicker.d.ts +24 -0
  30. package/types/components/DatePicker/index.d.ts +2 -0
  31. package/types/components/Dialog/dialog.d.ts +20 -0
  32. package/types/components/Dialog/index.d.ts +2 -0
  33. package/types/components/Dropdown/dropdown.d.ts +30 -0
  34. package/types/components/Dropdown/index.d.ts +3 -0
  35. package/types/components/Dropdown/logic.d.ts +5 -0
  36. package/types/components/Grid/grid.d.ts +14 -0
  37. package/types/components/Grid/index.d.ts +2 -0
  38. package/types/components/GridItem/gridItem.d.ts +8 -0
  39. package/types/components/GridItem/index.d.ts +2 -0
  40. package/types/components/Group/group.d.ts +5 -0
  41. package/types/components/Group/index.d.ts +2 -0
  42. package/types/components/Icon/icon.d.ts +14 -0
  43. package/types/components/Icon/index.d.ts +2 -0
  44. package/types/components/Image/image.d.ts +12 -0
  45. package/types/components/Image/index.d.ts +2 -0
  46. package/types/components/Input/index.d.ts +2 -0
  47. package/types/components/Input/input.d.ts +32 -0
  48. package/types/components/Progress/index.d.ts +2 -0
  49. package/types/components/Progress/progress.d.ts +15 -0
  50. package/types/components/Radio/index.d.ts +2 -0
  51. package/types/components/Radio/radio.d.ts +8 -0
  52. package/types/components/Rect/index.d.ts +2 -0
  53. package/types/components/Rect/rect.d.ts +11 -0
  54. package/types/components/Slider/index.d.ts +3 -0
  55. package/types/components/Slider/logic.d.ts +1 -0
  56. package/types/components/Slider/slider.d.ts +17 -0
  57. package/types/components/Switch/index.d.ts +3 -0
  58. package/types/components/Switch/logic.d.ts +2 -0
  59. package/types/components/Switch/switch.d.ts +14 -0
  60. package/types/components/Tabs/index.d.ts +3 -0
  61. package/types/components/Tabs/logic.d.ts +2 -0
  62. package/types/components/Tabs/tabs.d.ts +35 -0
  63. package/types/components/Text/index.d.ts +2 -0
  64. package/types/components/Text/text.d.ts +39 -0
  65. package/types/components/Textarea/index.d.ts +2 -0
  66. package/types/components/Textarea/textarea.d.ts +10 -0
  67. package/types/components/Upload/index.d.ts +2 -0
  68. package/types/components/Upload/upload.d.ts +20 -0
  69. package/types/components/Video/index.d.ts +2 -0
  70. package/types/components/Video/video.d.ts +20 -0
  71. package/types/components/draw-utils.d.ts +48 -0
  72. package/types/components/shared.d.ts +7 -0
  73. package/types/components/size.d.ts +6 -0
  74. package/types/components/types.d.ts +28 -0
  75. package/types/engine/carousel.d.ts +10 -0
  76. package/types/engine/events.d.ts +14 -0
  77. package/types/engine/hit-test.d.ts +31 -0
  78. package/types/engine/images.d.ts +8 -0
  79. package/types/engine/interaction.d.ts +11 -0
  80. package/types/engine/layout.d.ts +6 -0
  81. package/types/engine/nodes.d.ts +18 -0
  82. package/types/engine/state.d.ts +80 -0
  83. package/types/engine/text-controls.d.ts +10 -0
  84. package/types/engine/transform.d.ts +13 -0
  85. package/types/engine/videos.d.ts +14 -0
  86. package/types/engine/vnodes.d.ts +36 -0
  87. package/types/engine.d.ts +36 -0
  88. package/types/image-assets.d.ts +2 -0
  89. package/types/input-bridge.d.ts +40 -0
  90. package/types/renderer.d.ts +20 -0
  91. package/types/scene.d.ts +15 -0
  92. package/types/types.d.ts +124 -0
  93. package/types/video-assets.d.ts +11 -0
@@ -0,0 +1,6 @@
1
+ import type { SceneNode } from '../scene';
2
+ import type { Transform, VNode } from '../types';
3
+ import type { EngineCore, EngineState, TextControlDescription } from './state';
4
+ export declare function activeCollapseKeys(state: EngineState, stateKey: string, props: Record<string, unknown>): Set<string>;
5
+ export declare function layoutCollapseNodes(parent: SceneNode, active: Set<string>): void;
6
+ export declare function prepare(core: EngineCore, state: EngineState, vnodes: VNode[], parentTransform: Transform, parentVisible: boolean, parentPath: string, descriptions: TextControlDescription[]): VNode[];
@@ -0,0 +1,18 @@
1
+ import type { SceneNode } from '../scene';
2
+ import type { CanvasUIEventTarget, InputLayout } from '../types';
3
+ /**
4
+ * Pure predicates and derived getters over a {@link SceneNode} subtree.
5
+ * None of these read engine-level mutable state — they only inspect nodes.
6
+ */
7
+ export declare function hasVisibleAncestors(node: SceneNode): boolean;
8
+ export declare function hasVisibleOpenDialog(node: SceneNode, parentVisible: boolean): boolean;
9
+ export declare function eventTarget(node: SceneNode): CanvasUIEventTarget;
10
+ export declare function isCanvasElement(value: unknown): value is HTMLCanvasElement;
11
+ export declare function isInteractive(type: string): boolean;
12
+ export declare function isDescendantOf(node: SceneNode, ancestor: SceneNode): boolean;
13
+ export declare function setTreeVisibility(node: SceneNode, visible: boolean): void;
14
+ export declare function controlSize(node: SceneNode): {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ export declare function isTextControlVisible(node: SceneNode, layout: InputLayout): boolean;
@@ -0,0 +1,80 @@
1
+ import type { SceneNode } from '../scene';
2
+ import type { CanvasRenderer } from '../renderer';
3
+ import type { CanvasUIEvent, InputLayout, TextControlProps, WebInputBridge } from '../types';
4
+ import type { VirtualGridLayout } from './vnodes';
5
+ /** A text input/date/textarea currently mirrored into the DOM overlay bridge. */
6
+ export interface MountedTextControl {
7
+ node: SceneNode;
8
+ dispose: () => void;
9
+ layout: InputLayout;
10
+ }
11
+ /** A text control discovered during the `prepare` pass, awaiting sync. */
12
+ export interface TextControlDescription {
13
+ id: string;
14
+ props: TextControlProps;
15
+ layout: InputLayout;
16
+ }
17
+ export interface CarouselTransition {
18
+ from: number;
19
+ to: number;
20
+ direction: -1 | 1;
21
+ startedAt: number;
22
+ duration: number;
23
+ }
24
+ export interface PointerSequence {
25
+ target: SceneNode | null;
26
+ x: number;
27
+ y: number;
28
+ eligible: boolean;
29
+ }
30
+ export interface GridScrollGesture {
31
+ node: SceneNode;
32
+ pointerY: number;
33
+ scrollTop: number;
34
+ }
35
+ /** Per-video-node tracker of the last observed playback position, for dirty scheduling. */
36
+ export interface VideoFrameTracker {
37
+ src: string;
38
+ time: number;
39
+ playing: boolean;
40
+ }
41
+ /**
42
+ * Immutable services and configuration shared by every engine behaviour module:
43
+ * the scene graph, renderer, canvas context, DOM input bridge and callbacks.
44
+ * {@link CanvasEngine} owns exactly one of these for its lifetime.
45
+ */
46
+ export interface EngineCore {
47
+ readonly scene: SceneNode;
48
+ readonly renderer: CanvasRenderer;
49
+ readonly context: CanvasRenderingContext2D;
50
+ readonly inputBridge: WebInputBridge;
51
+ readonly pixelRatio: number;
52
+ readonly onFrame?: (time: number) => void;
53
+ readonly onEvent?: (event: CanvasUIEvent) => void;
54
+ readonly refreshVirtualGrids: () => void;
55
+ }
56
+ /**
57
+ * All engine-mutable state that survives across frames and pointer events.
58
+ * Extracted from the former {@link CanvasEngine} private fields so behaviour
59
+ * modules can operate on it explicitly instead of via a God-class `this`.
60
+ */
61
+ export declare class EngineState {
62
+ readonly textControls: Map<string, MountedTextControl>;
63
+ readonly inputValues: Map<string, string>;
64
+ readonly imageSubscriptions: Map<string, () => void>;
65
+ readonly videoSubscriptions: Map<string, () => void>;
66
+ readonly videoFrames: Map<SceneNode, VideoFrameTracker>;
67
+ readonly tabSelections: Map<string, string>;
68
+ readonly carouselSelections: Map<string, number>;
69
+ readonly carouselFrameTimes: Map<string, number>;
70
+ readonly carouselTransitions: Map<string, CarouselTransition>;
71
+ readonly collapseSelections: Map<string, Set<string>>;
72
+ readonly gridScrollPositions: Map<string, number>;
73
+ readonly virtualGridLayouts: Map<string, VirtualGridLayout>;
74
+ readonly activeVirtualGridKeys: Set<string>;
75
+ readonly pointerSequences: Map<number, PointerSequence>;
76
+ activeSlider: SceneNode | null;
77
+ activeButton: SceneNode | null;
78
+ activeGridScroll: GridScrollGesture | null;
79
+ currentFrameTime: number;
80
+ }
@@ -0,0 +1,10 @@
1
+ import type { SceneNode } from '../scene';
2
+ import type { EngineCore, EngineState, TextControlDescription } from './state';
3
+ /**
4
+ * Keeps the off-canvas DOM input overlay (text inputs / textareas / date pickers)
5
+ * in sync with the scene graph: mount/update/teardown bridges and push value,
6
+ * focus and scroll state back into the corresponding {@link SceneNode}s.
7
+ */
8
+ export declare function syncTextControls(core: EngineCore, state: EngineState, descriptions: TextControlDescription[]): void;
9
+ export declare function updateTextControlVisibility(core: EngineCore, state: EngineState): void;
10
+ export declare function removeTextControls(state: EngineState, node: SceneNode): void;
@@ -0,0 +1,13 @@
1
+ import type { SceneNode } from '../scene';
2
+ import type { Transform } from '../types';
3
+ /**
4
+ * Pure 2D affine-transform math shared by hit-testing, layout and input routing.
5
+ * A transform is the `[a, b, c, d, e, f]` matrix tuple used by the Canvas API.
6
+ */
7
+ export declare function multiplyTransform(parent: Transform, props: Record<string, unknown>): Transform;
8
+ export declare function invertPoint(x: number, y: number, transform: Transform): {
9
+ x: number;
10
+ y: number;
11
+ } | null;
12
+ /** Accumulated world transform of a node from the scene root down to it. */
13
+ export declare function nodeTransform(node: SceneNode): Transform;
@@ -0,0 +1,14 @@
1
+ import type { EngineCore, EngineState } from './state';
2
+ /**
3
+ * Subscribes the engine to the shared video pool for every `video` source in the scene,
4
+ * tearing down (and unloading) subscriptions for sources that disappear. Load events mark
5
+ * the scene dirty and forward to each video node's `onError`/`onTimeUpdate` callbacks.
6
+ */
7
+ export declare function syncVideos(core: EngineCore, state: EngineState): void;
8
+ /**
9
+ * Keeps the scene dirty exactly while a video advances: a drawn frame is worth one repaint,
10
+ * so a new frame (or a video that just started playing) dirties the scene once. Paused,
11
+ * ended and hidden videos cost nothing, and the loop survives seeks and playback-rate
12
+ * changes because it watches `currentTime` rather than a paused flag.
13
+ */
14
+ export declare function advanceVideos(core: EngineCore, state: EngineState): void;
@@ -0,0 +1,36 @@
1
+ import type { VNode } from '../types';
2
+ import type { CarouselTransition } from './state';
3
+ export interface VirtualGridLayout {
4
+ token: unknown;
5
+ width: number;
6
+ contentHeight: number;
7
+ entries: {
8
+ child: VNode;
9
+ index: number;
10
+ top: number;
11
+ bottom: number;
12
+ maxBottom: number;
13
+ }[];
14
+ }
15
+ export declare function createVirtualGridLayout(vnode: VNode): VirtualGridLayout;
16
+ export declare function visibleGridChildren(layout: VirtualGridLayout, scrollTop: number, height: number, overscan: number): VNode[];
17
+ /**
18
+ * Pure helpers that rewrite a VNode tree during the `prepare` normalization pass,
19
+ * plus metrics used by grid scrolling. They never touch engine state.
20
+ */
21
+ export declare function layoutGridChildren(vnode: VNode): {
22
+ children: VNode[];
23
+ contentHeight: number;
24
+ width: number;
25
+ };
26
+ export declare function translateChildren(children: VNode[], offsetX: number, offsetY: number): VNode[];
27
+ export declare function setVNodeVisibility(children: VNode[], parentVisible: boolean): VNode[];
28
+ export declare function carouselItemOffset(index: number, transition: CarouselTransition | undefined | null, progress: number, width: number): number;
29
+ export declare function gridScrollbarMetrics(props: Record<string, unknown>): {
30
+ width: number;
31
+ height: number;
32
+ maxScroll: number;
33
+ thumbHeight: number;
34
+ trackX: number;
35
+ thumbY: number;
36
+ };
@@ -0,0 +1,36 @@
1
+ import { SceneNode } from './scene';
2
+ import { CanvasRenderer } from './renderer';
3
+ import type { CanvasPointerEvent, CanvasUIEvent, CanvasWheelEvent, VNode, WebInputBridge } from './types';
4
+ /**
5
+ * Public entry point of the canvas rendering engine.
6
+ *
7
+ * <p>{@code CanvasEngine} is intentionally a thin orchestrator: it owns the
8
+ * {@link EngineCore} services and the {@link EngineState} container, wires them into
9
+ * a render loop, and delegates every concrete behaviour to a cohesive module under
10
+ * {@code ./engine} (layout normalization, hit-testing, interaction, carousel,
11
+ * text controls, images, videos, events). The public surface is unchanged from when this
12
+ * was a single God class.</p>
13
+ */
14
+ export declare class CanvasEngine {
15
+ readonly scene: SceneNode;
16
+ readonly renderer: CanvasRenderer;
17
+ private readonly state;
18
+ private readonly context;
19
+ private readonly core;
20
+ private animationFrame;
21
+ private themeObserver;
22
+ private running;
23
+ private tree;
24
+ constructor(context: CanvasRenderingContext2D, inputBridge: WebInputBridge, onFrame?: (time: number) => void, pixelRatio?: number, onEvent?: (event: CanvasUIEvent) => void);
25
+ update(tree: VNode[]): void;
26
+ private reconcile;
27
+ render(): void;
28
+ requestRender(): void;
29
+ renderTo(context: CanvasRenderingContext2D, scaleX: number, scaleY: number): void;
30
+ start(): void;
31
+ pointerDown(event: CanvasPointerEvent): void;
32
+ pointerMove(event: CanvasPointerEvent): void;
33
+ pointerUp(event: CanvasPointerEvent, cancelled?: boolean): void;
34
+ wheel(event: CanvasWheelEvent): void;
35
+ destroy(): void;
36
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getCanvasImage(src: string): HTMLImageElement | null;
2
+ export declare function subscribeCanvasImage(src: string, listener: (error: Error | null) => void): () => void;
@@ -0,0 +1,40 @@
1
+ import type { InputEvents, InputLayout, TextControlProps, WebInputBridge as WebInputBridgeContract } from './types';
2
+ /**
3
+ * The CSS that makes the transparent element lay its text out where the Canvas drawing puts it: same
4
+ * font metrics, same horizontal inset. Left to the browser default font, a click is converted into a
5
+ * character index for one layout while the caret is painted for another, so the caret lands on the
6
+ * wrong glyph (and typing looks one character behind). Pure so it can be checked without a DOM.
7
+ */
8
+ export declare function overlayTextStyle(props: TextControlProps, multiline: boolean): Record<string, string>;
9
+ export declare class WebInputBridge implements WebInputBridgeContract {
10
+ private readonly mounted;
11
+ private readonly fileInputs;
12
+ private readonly originalDisplay;
13
+ private overlayHidden;
14
+ private selectionTracked;
15
+ private readonly overlay;
16
+ constructor(overlay: HTMLElement);
17
+ mount(id: string, props: TextControlProps, layout: InputLayout, events: InputEvents): () => void;
18
+ update(id: string, props: TextControlProps, layout: InputLayout): void;
19
+ pickFiles(accept: string | undefined, multiple: boolean, onChange: (files: File[]) => void): void;
20
+ focus(id: string): void;
21
+ setOverlayVisible(visible: boolean): void;
22
+ private unmount;
23
+ destroy(): void;
24
+ private find;
25
+ private readonly handleInput;
26
+ private readonly handleSelection;
27
+ /**
28
+ * `select` only fires when a range is created, so the interactions that just move the caret —
29
+ * clicking into the text, arrow keys, Home/End — report nothing, and the drawn caret stays pinned
30
+ * to wherever the last edit left it. `selectionchange` is the event that actually tracks the
31
+ * caret; it is document-scoped, hence one shared listener refcounted over the mounted controls
32
+ * (re-adding the same callback would be a no-op, and unmounting one must not stop the others).
33
+ */
34
+ private trackSelections;
35
+ private untrackSelections;
36
+ private readonly handleSelectionChange;
37
+ private readonly handleFocus;
38
+ private readonly handleBlur;
39
+ private readonly handleTextareaScroll;
40
+ }
@@ -0,0 +1,20 @@
1
+ import { SceneNode } from './scene';
2
+ export declare class CanvasRenderer {
3
+ private gridCaches;
4
+ private cacheEnabled;
5
+ invalidateGridCache(): void;
6
+ render(context: CanvasRenderingContext2D, root: SceneNode, cacheEnabled?: boolean): void;
7
+ /**
8
+ * Runs a single node's draw function behind a save/restore pair and a try/catch so that a
9
+ * throwing draw (an `<Icon>` with an unknown name, a `<CustomDraw>`/`<CanvasView>` with invalid
10
+ * props, or a faulty user draw callback) only skips that one node instead of aborting the whole
11
+ * frame. The save/restore also contains any partial context mutation the draw made before it
12
+ * threw, so sibling nodes and later overlays still render from a clean state.
13
+ */
14
+ private safeDraw;
15
+ private drawNode;
16
+ private drawGrid;
17
+ private drawCachedGrid;
18
+ private drawDialogs;
19
+ private drawDropdownOverlays;
20
+ }
@@ -0,0 +1,15 @@
1
+ import type { ComponentKind, VNode } from './types';
2
+ export declare class SceneNode {
3
+ readonly children: SceneNode[];
4
+ parent: SceneNode | null;
5
+ dirty: boolean;
6
+ readonly type: ComponentKind | 'root';
7
+ props: Record<string, unknown>;
8
+ constructor(type: ComponentKind | 'root', props?: Record<string, unknown>);
9
+ setProps(props: Record<string, unknown>): void;
10
+ replaceProps(props: Record<string, unknown>): void;
11
+ markDirty(): void;
12
+ syncChildren(vnodes: VNode[], onRemove: (node: SceneNode) => void): void;
13
+ traverse(visitor: (node: SceneNode) => void): void;
14
+ }
15
+ export declare function descriptorKey(vnode: VNode, index: number, parentPath: string): string;
@@ -0,0 +1,124 @@
1
+ import type { ButtonProps, CarouselItemProps, CarouselProps, CheckboxProps, CircleProps, CollapseItemProps, CollapseProps, CustomDrawProps, CanvasViewProps, DatePickerProps, DialogProps, DropdownProps, GridItemProps, GridProps, GroupProps, IconProps, ImageProps, InputProps, ProgressProps, RadioProps, RectProps, SliderProps, SwitchProps, TabItemProps, TabsProps, TextProps, TextareaProps, UploadProps, VideoProps } from './components/types';
2
+ export type ComponentKind = 'group' | 'grid' | 'gridItem' | 'rect' | 'circle' | 'text' | 'input' | 'datePicker' | 'radio' | 'checkbox' | 'upload' | 'carousel' | 'carouselItem' | 'textarea' | 'dropdown' | 'slider' | 'switch' | 'button' | 'image' | 'icon' | 'dialog' | 'progress' | 'tabs' | 'tabItem' | 'collapse' | 'collapseItem' | 'customDraw' | 'canvasView' | 'video';
3
+ export type Transform = readonly [number, number, number, number, number, number];
4
+ export interface TransformProps {
5
+ x?: number;
6
+ y?: number;
7
+ rotation?: number;
8
+ scaleX?: number;
9
+ scaleY?: number;
10
+ visible?: boolean;
11
+ }
12
+ export interface CanvasWheelEvent {
13
+ currentTarget: HTMLCanvasElement;
14
+ clientX: number;
15
+ clientY: number;
16
+ deltaY: number;
17
+ preventDefault(): void;
18
+ }
19
+ export type { ButtonProps, CarouselItemProps, CarouselProps, CheckboxProps, ChoiceOption, CircleProps, CollapseItemProps, CollapseProps, ComponentSize, CustomDrawProps, CustomDrawSize, CustomDrawClickEvent, CustomDrawHitTest, CanvasViewFit, CanvasViewPointerEvent, CanvasViewPointerEventHandler, CanvasViewProps, DatePickerProps, DialogProps, DropdownOption, DropdownProps, GridItemProps, GridProps, GroupProps, IconName, IconProps, IconVariant, ImageProps, InputProps, ProgressProps, RadioProps, RectProps, SliderProps, SwitchProps, TabItemProps, TabsProps, TextProps, TextareaProps, UploadProps, VideoProps, } from './components/types';
20
+ export interface CanvasComponentProps {
21
+ group: Omit<GroupProps, 'children'>;
22
+ grid: Omit<GridProps, 'children'>;
23
+ gridItem: Omit<GridItemProps, 'children'>;
24
+ rect: RectProps;
25
+ circle: CircleProps;
26
+ text: TextProps;
27
+ input: InputProps;
28
+ datePicker: DatePickerProps;
29
+ radio: RadioProps;
30
+ checkbox: CheckboxProps;
31
+ upload: UploadProps;
32
+ carousel: Omit<CarouselProps, 'children'>;
33
+ carouselItem: CarouselItemProps;
34
+ textarea: TextareaProps;
35
+ dropdown: DropdownProps;
36
+ slider: SliderProps;
37
+ switch: SwitchProps;
38
+ button: Omit<ButtonProps, 'children'>;
39
+ image: ImageProps;
40
+ icon: IconProps;
41
+ dialog: Omit<DialogProps, 'children'>;
42
+ progress: ProgressProps;
43
+ tabs: Omit<TabsProps, 'children'>;
44
+ tabItem: Omit<TabItemProps, 'children'>;
45
+ collapse: Omit<CollapseProps, 'children'>;
46
+ collapseItem: Omit<CollapseItemProps, 'children'>;
47
+ customDraw: CustomDrawProps;
48
+ canvasView: CanvasViewProps;
49
+ video: VideoProps;
50
+ }
51
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
52
+ export type CanvasNodeProps = CanvasComponentProps[ComponentKind];
53
+ export type CanvasNodePropKey = KeysOfUnion<CanvasNodeProps>;
54
+ export type CanvasNodePropValue<Key extends CanvasNodePropKey> = CanvasNodeProps extends infer Props ? Props extends object ? Key extends keyof Props ? Props[Key] : never : never : never;
55
+ export interface VNode {
56
+ type: ComponentKind;
57
+ key: string | null;
58
+ props: Record<string, unknown>;
59
+ children: VNode[];
60
+ }
61
+ export interface InputLayout {
62
+ width: number;
63
+ height: number;
64
+ transform: Transform;
65
+ visible: boolean;
66
+ }
67
+ export type TextControlProps = InputProps | DatePickerProps | TextareaProps;
68
+ export interface InputEvents {
69
+ input: (value: string, cursor: number) => void;
70
+ selection: (cursor: number) => void;
71
+ focus: () => void;
72
+ blur: () => void;
73
+ scroll: (scrollTop: number, scrollHeight: number, clientHeight: number, clientWidth: number) => void;
74
+ }
75
+ export interface WebInputBridge {
76
+ mount(id: string, props: TextControlProps, layout: InputLayout, events: InputEvents): () => void;
77
+ update(id: string, props: TextControlProps, layout: InputLayout): void;
78
+ pickFiles(accept: string | undefined, multiple: boolean, onChange: (files: File[]) => void): void;
79
+ setOverlayVisible(visible: boolean): void;
80
+ destroy(): void;
81
+ }
82
+ export interface CanvasProps {
83
+ width: number;
84
+ height: number;
85
+ style?: object;
86
+ className?: string;
87
+ ariaLabel?: string;
88
+ onFrame?: (time: number) => void;
89
+ onEvent?: (event: CanvasUIEvent) => void;
90
+ children?: unknown;
91
+ }
92
+ export interface CanvasUIEventTarget {
93
+ readonly type: ComponentKind;
94
+ readonly key: string | null;
95
+ }
96
+ interface CanvasUIEventPosition {
97
+ readonly target: CanvasUIEventTarget | null;
98
+ readonly x: number;
99
+ readonly y: number;
100
+ readonly localX?: number;
101
+ readonly localY?: number;
102
+ }
103
+ export type CanvasUIPointerEvent = CanvasUIEventPosition & {
104
+ readonly type: 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel' | 'click';
105
+ readonly pointerId: number;
106
+ };
107
+ export type CanvasUIWheelEvent = CanvasUIEventPosition & {
108
+ readonly type: 'wheel';
109
+ readonly deltaY: number;
110
+ };
111
+ export type CanvasUIEvent = CanvasUIPointerEvent | CanvasUIWheelEvent;
112
+ export interface CanvasPointerEvent {
113
+ currentTarget: HTMLCanvasElement;
114
+ clientX: number;
115
+ clientY: number;
116
+ pointerId: number;
117
+ pointerType?: string;
118
+ pressure?: number;
119
+ isPrimary?: boolean;
120
+ button?: number;
121
+ buttons?: number;
122
+ preventDefault(): void;
123
+ }
124
+ export declare const IDENTITY_TRANSFORM: Transform;
@@ -0,0 +1,11 @@
1
+ export type VideoLoadListener = (error: Error | null) => void;
2
+ export type VideoTimeListener = (currentTime: number, duration: number) => void;
3
+ /** The pooled element for `src`; loading happens as a side effect. */
4
+ export declare function acquireCanvasVideoElement(src: string): HTMLVideoElement;
5
+ /** The pooled element only once its first frame is decodable; null triggers a redraw on ready. */
6
+ export declare function getCanvasVideo(src: string): HTMLVideoElement | null;
7
+ /** The pooled element if one exists, without acquiring a reference or starting a load. */
8
+ export declare function peekCanvasVideo(src: string): HTMLVideoElement | null;
9
+ export declare function subscribeCanvasVideo(src: string, onLoad: VideoLoadListener, onTime: VideoTimeListener): () => void;
10
+ /** Drops one node reference; unloads the shared element once no node holds it. */
11
+ export declare function releaseCanvasVideo(src: string): void;