@web-canvas-ui/react 0.1.1 → 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.
- package/README.md +172 -76
- package/index.js +2682 -0
- package/package.json +36 -27
- package/types/canvas-handle.d.ts +22 -0
- package/types/components/Button/button.d.ts +20 -0
- package/types/components/Button/logic.d.ts +3 -0
- package/types/components/CanvasView/canvasView.d.ts +28 -0
- package/types/components/CanvasView/index.d.ts +2 -0
- package/types/components/Carousel/carousel.d.ts +31 -0
- package/types/components/Carousel/logic.d.ts +2 -0
- package/types/components/Checkbox/checkbox.d.ts +8 -0
- package/types/components/ChoiceGroup/choiceGroup.d.ts +33 -0
- package/types/components/ChoiceGroup/logic.d.ts +3 -0
- package/types/components/Circle/circle.d.ts +9 -0
- package/types/components/Collapse/collapse.d.ts +32 -0
- package/types/components/Collapse/logic.d.ts +1 -0
- package/types/components/CustomDraw/customDraw.d.ts +22 -0
- package/types/components/CustomDraw/index.d.ts +2 -0
- package/types/components/DatePicker/datePicker.d.ts +24 -0
- package/types/components/Dialog/dialog.d.ts +20 -0
- package/types/components/Dropdown/dropdown.d.ts +30 -0
- package/types/components/Dropdown/logic.d.ts +5 -0
- package/{components/Grid/grid.ts → types/components/Grid/grid.d.ts} +3 -4
- package/{components/GridItem/gridItem.ts → types/components/GridItem/gridItem.d.ts} +1 -4
- package/{components/Group/group.ts → types/components/Group/group.d.ts} +1 -4
- package/types/components/Icon/icon.d.ts +14 -0
- package/types/components/Image/image.d.ts +12 -0
- package/types/components/Input/input.d.ts +32 -0
- package/types/components/Progress/progress.d.ts +15 -0
- package/types/components/Radio/radio.d.ts +8 -0
- package/types/components/Rect/rect.d.ts +11 -0
- package/types/components/Slider/logic.d.ts +1 -0
- package/types/components/Slider/slider.d.ts +17 -0
- package/types/components/Switch/logic.d.ts +2 -0
- package/types/components/Switch/switch.d.ts +14 -0
- package/types/components/Tabs/logic.d.ts +2 -0
- package/types/components/Tabs/tabs.d.ts +35 -0
- package/types/components/Text/text.d.ts +39 -0
- package/types/components/Textarea/textarea.d.ts +10 -0
- package/types/components/Upload/upload.d.ts +20 -0
- package/types/components/Video/index.d.ts +2 -0
- package/types/components/Video/video.d.ts +20 -0
- package/types/components/draw-utils.d.ts +48 -0
- package/types/components/shared.d.ts +7 -0
- package/types/components/size.d.ts +6 -0
- package/{components/types.ts → types/components/types.d.ts} +3 -12
- package/types/engine/carousel.d.ts +10 -0
- package/types/engine/events.d.ts +14 -0
- package/types/engine/hit-test.d.ts +31 -0
- package/types/engine/images.d.ts +8 -0
- package/types/engine/interaction.d.ts +11 -0
- package/types/engine/layout.d.ts +6 -0
- package/types/engine/nodes.d.ts +18 -0
- package/{engine/state.ts → types/engine/state.d.ts} +27 -22
- package/types/engine/text-controls.d.ts +10 -0
- package/types/engine/transform.d.ts +13 -0
- package/types/engine/videos.d.ts +14 -0
- package/types/engine/vnodes.d.ts +36 -0
- package/types/engine.d.ts +36 -0
- package/types/image-assets.d.ts +2 -0
- package/types/input-bridge.d.ts +40 -0
- package/types/react/Canvas.d.ts +4 -0
- package/types/react/components.d.ts +30 -0
- package/types/react/index.d.ts +4 -0
- package/types/renderer.d.ts +20 -0
- package/types/scene.d.ts +15 -0
- package/{types.ts → types/types.d.ts} +10 -142
- package/types/video-assets.d.ts +11 -0
- package/Canvas.tsx +0 -142
- package/__tests__/pure-logic.test.ts +0 -153
- package/__tests__/scene-and-node.test.ts +0 -131
- package/__tests__/scratch-space.test.ts +0 -30
- package/__tests__/textarea-caret.test.ts +0 -96
- package/__tests__/utils.test.ts +0 -114
- package/canvas-handle.ts +0 -114
- package/components/Button/button.ts +0 -57
- package/components/Button/logic.ts +0 -11
- package/components/CanvasView/canvasView.ts +0 -103
- package/components/CanvasView/index.ts +0 -7
- package/components/Carousel/carousel.ts +0 -107
- package/components/Carousel/logic.ts +0 -36
- package/components/Checkbox/checkbox.ts +0 -14
- package/components/ChoiceGroup/choiceGroup.ts +0 -172
- package/components/ChoiceGroup/logic.ts +0 -14
- package/components/Circle/circle.ts +0 -31
- package/components/Collapse/collapse.ts +0 -69
- package/components/Collapse/logic.ts +0 -14
- package/components/CustomDraw/customDraw.ts +0 -50
- package/components/CustomDraw/index.ts +0 -7
- package/components/DatePicker/datePicker.ts +0 -70
- package/components/Dialog/dialog.ts +0 -102
- package/components/Dropdown/dropdown.ts +0 -125
- package/components/Dropdown/logic.ts +0 -29
- package/components/Icon/icon.ts +0 -669
- package/components/Image/image.ts +0 -69
- package/components/Input/input.ts +0 -139
- package/components/Progress/progress.ts +0 -59
- package/components/Radio/radio.ts +0 -14
- package/components/Rect/rect.ts +0 -35
- package/components/Slider/logic.ts +0 -19
- package/components/Slider/slider.ts +0 -58
- package/components/Switch/logic.ts +0 -8
- package/components/Switch/switch.ts +0 -37
- package/components/Tabs/logic.ts +0 -14
- package/components/Tabs/tabs.ts +0 -78
- package/components/Text/text.ts +0 -95
- package/components/Textarea/textarea.ts +0 -16
- package/components/Upload/upload.ts +0 -66
- package/components/draw-utils.ts +0 -230
- package/components/shared.ts +0 -15
- package/components/size.ts +0 -20
- package/components.ts +0 -98
- package/engine/__tests__/carousel.test.ts +0 -218
- package/engine/__tests__/hit-test.test.ts +0 -282
- package/engine/__tests__/layout.test.ts +0 -474
- package/engine/carousel.ts +0 -150
- package/engine/events.ts +0 -73
- package/engine/hit-test.ts +0 -321
- package/engine/images.ts +0 -41
- package/engine/interaction.ts +0 -442
- package/engine/layout.ts +0 -355
- package/engine/nodes.ts +0 -166
- package/engine/text-controls.ts +0 -122
- package/engine/transform.ts +0 -61
- package/engine/vnodes.ts +0 -204
- package/engine.ts +0 -162
- package/image-assets.ts +0 -37
- package/index.ts +0 -78
- package/input-bridge.ts +0 -285
- package/renderer.ts +0 -303
- package/scene.ts +0 -122
- package/theme.scss +0 -234
- package/web-canvas-ui-react-0.1.1.tgz +0 -0
- /package/{components/Button/index.ts → types/components/Button/index.d.ts} +0 -0
- /package/{components/Carousel/index.ts → types/components/Carousel/index.d.ts} +0 -0
- /package/{components/Checkbox/index.ts → types/components/Checkbox/index.d.ts} +0 -0
- /package/{components/ChoiceGroup/index.ts → types/components/ChoiceGroup/index.d.ts} +0 -0
- /package/{components/Circle/index.ts → types/components/Circle/index.d.ts} +0 -0
- /package/{components/Collapse/index.ts → types/components/Collapse/index.d.ts} +0 -0
- /package/{components/DatePicker/index.ts → types/components/DatePicker/index.d.ts} +0 -0
- /package/{components/Dialog/index.ts → types/components/Dialog/index.d.ts} +0 -0
- /package/{components/Dropdown/index.ts → types/components/Dropdown/index.d.ts} +0 -0
- /package/{components/Grid/index.ts → types/components/Grid/index.d.ts} +0 -0
- /package/{components/GridItem/index.ts → types/components/GridItem/index.d.ts} +0 -0
- /package/{components/Group/index.ts → types/components/Group/index.d.ts} +0 -0
- /package/{components/Icon/index.ts → types/components/Icon/index.d.ts} +0 -0
- /package/{components/Image/index.ts → types/components/Image/index.d.ts} +0 -0
- /package/{components/Input/index.ts → types/components/Input/index.d.ts} +0 -0
- /package/{components/Progress/index.ts → types/components/Progress/index.d.ts} +0 -0
- /package/{components/Radio/index.ts → types/components/Radio/index.d.ts} +0 -0
- /package/{components/Rect/index.ts → types/components/Rect/index.d.ts} +0 -0
- /package/{components/Slider/index.ts → types/components/Slider/index.d.ts} +0 -0
- /package/{components/Switch/index.ts → types/components/Switch/index.d.ts} +0 -0
- /package/{components/Tabs/index.ts → types/components/Tabs/index.d.ts} +0 -0
- /package/{components/Text/index.ts → types/components/Text/index.d.ts} +0 -0
- /package/{components/Textarea/index.ts → types/components/Textarea/index.d.ts} +0 -0
- /package/{components/Upload/index.ts → types/components/Upload/index.d.ts} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { TransformProps } from '../../types';
|
|
2
|
+
export interface TextProps extends TransformProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
children?: never;
|
|
5
|
+
fontSize?: number;
|
|
6
|
+
/** Wrap width. Falls back to the box the parent container hands down when unset. */
|
|
7
|
+
width?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Maximum number of wrapped lines; the last one is cut with an ellipsis. Falls back to the number
|
|
10
|
+
* of lines that fit the container's box, and to "no limit" when neither is declared.
|
|
11
|
+
*/
|
|
12
|
+
maxLines?: number;
|
|
13
|
+
fontFamily?: string;
|
|
14
|
+
color?: string;
|
|
15
|
+
baseline?: CanvasTextBaseline;
|
|
16
|
+
textAlign?: CanvasTextAlign;
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
}
|
|
19
|
+
export interface TextBox {
|
|
20
|
+
lines: string[];
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
/** Public props plus the content box a parent container hands down to this node. */
|
|
25
|
+
export type TextDrawProps = TextProps & {
|
|
26
|
+
_availableWidth?: number;
|
|
27
|
+
_availableHeight?: number;
|
|
28
|
+
};
|
|
29
|
+
export declare const Text: import("../shared").MarkedComponent<TextProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves `props` into the lines it renders and the box they occupy. {@link drawText} paints these
|
|
32
|
+
* lines and the layout pass sizes the node from the same result, so a Text node's reported height can
|
|
33
|
+
* never disagree with the glyphs it actually draws.
|
|
34
|
+
*
|
|
35
|
+
* A box handed down by the container is the fallback, not the override: declaring `width` or
|
|
36
|
+
* `maxLines` keeps the author in charge, so a node can stay narrower than its cell on purpose.
|
|
37
|
+
*/
|
|
38
|
+
export declare function measureTextBox(props: TextDrawProps): TextBox;
|
|
39
|
+
export declare function drawText(context: CanvasRenderingContext2D, props: TextDrawProps): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InputProps, InputDrawProps } from '../Input';
|
|
2
|
+
export interface TextareaProps extends Omit<InputProps, 'type'> {
|
|
3
|
+
rows?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const Textarea: import("../shared").MarkedComponent<TextareaProps>;
|
|
6
|
+
/** Public props plus the engine-injected caret/scroll state consumed by the draw layer. */
|
|
7
|
+
export type TextareaDrawProps = Omit<InputDrawProps, 'type'> & {
|
|
8
|
+
rows?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function drawTextarea(context: CanvasRenderingContext2D, props: TextareaDrawProps): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TransformProps } from '../../types';
|
|
2
|
+
import { type IconName } from '../Icon';
|
|
3
|
+
export interface UploadProps extends TransformProps {
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
text?: string;
|
|
7
|
+
icon?: IconName;
|
|
8
|
+
iconSize?: number;
|
|
9
|
+
accept?: string;
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
backgroundColor?: string;
|
|
13
|
+
textColor?: string;
|
|
14
|
+
borderColor?: string;
|
|
15
|
+
borderRadius?: number;
|
|
16
|
+
fontSize?: number;
|
|
17
|
+
onChange?: (files: File[]) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const Upload: import("../shared").MarkedComponent<UploadProps>;
|
|
20
|
+
export declare function drawUpload(context: CanvasRenderingContext2D, props: UploadProps): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TransformProps } from '../../types';
|
|
2
|
+
import { type MediaObjectFit } from '../draw-utils';
|
|
3
|
+
export interface VideoProps extends TransformProps {
|
|
4
|
+
src: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
objectFit?: MediaObjectFit;
|
|
8
|
+
/** Start playback as soon as the frame draws; browsers still require `muted` for autoplay. */
|
|
9
|
+
autoplay?: boolean;
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
muted?: boolean;
|
|
12
|
+
/** Declarative play/pause: `paused: false` plays, `paused: true` pauses, omitted leaves control to `autoplay`. */
|
|
13
|
+
paused?: boolean;
|
|
14
|
+
/** Seek target in seconds; set once (e.g. in `onTimeUpdate`) to jump, not every frame. */
|
|
15
|
+
currentTime?: number;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
onTimeUpdate?: (currentTime: number, duration: number) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const Video: import("../shared").MarkedComponent<VideoProps>;
|
|
20
|
+
export declare function drawVideo(context: CanvasRenderingContext2D, props: VideoProps): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare function number(value: unknown, fallback: number): number;
|
|
2
|
+
export declare function string(value: unknown, fallback: string): string;
|
|
3
|
+
/** Measures rendered text width; drawing passes a context, layout passes `measureTextWidth`. */
|
|
4
|
+
export type TextMeasurer = (text: string) => number;
|
|
5
|
+
/** Baseline-to-baseline multiplier, shared by Text drawing and the pass that sizes it. */
|
|
6
|
+
export declare const TEXT_LINE_HEIGHT = 1.2;
|
|
7
|
+
/**
|
|
8
|
+
* Wraps `text` into lines at most `width` wide, keeping at most `maxLines` of them; a clamped
|
|
9
|
+
* block ends with an ellipsis instead of silently losing the rest. `maxLines` <= 0 means "no
|
|
10
|
+
* limit"; any positive limit keeps at least one line. Callers supply the measurer so that drawing
|
|
11
|
+
* (live context) and layout ({@link measureTextWidth}) share one algorithm and therefore one result.
|
|
12
|
+
*/
|
|
13
|
+
export declare function measureLines(measure: TextMeasurer, text: string, width: number, maxLines?: number): string[];
|
|
14
|
+
export declare function wrapText(context: CanvasRenderingContext2D, text: string, width: number): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Truncates `text` with a trailing ellipsis so it fits within `maxWidth` for the
|
|
17
|
+
* context's current font. Display-only labels (buttons, tabs, dropdown rows…) use
|
|
18
|
+
* this to stay inside their box; editable controls clip instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function fitText(context: CanvasRenderingContext2D, text: string, maxWidth: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* Measures the rendered width of `text` for a given CSS `font` string using a
|
|
23
|
+
* shared offscreen context. Draw, hit-test and layout code must all go through
|
|
24
|
+
* this helper so their width calculations stay byte-for-byte identical.
|
|
25
|
+
* Falls back to a deterministic estimate when no canvas is available (SSR/tests).
|
|
26
|
+
*/
|
|
27
|
+
export declare function measureTextWidth(text: string, font: string): number;
|
|
28
|
+
/** How a media source is fitted into its box; shared by the `<Image>` and `<Video>` draw paths. */
|
|
29
|
+
export type MediaObjectFit = 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
30
|
+
/**
|
|
31
|
+
* Draws a raster source (image or video frame) into the `width`x`height` box at the current
|
|
32
|
+
* origin under the CSS `objectFit` semantics, clipping to the box. Shared so `<Image>` and
|
|
33
|
+
* `<Video>` scale identically; the caller saves/restores the context around the clip.
|
|
34
|
+
*/
|
|
35
|
+
export declare function drawFitMedia(context: CanvasRenderingContext2D, source: CanvasImageSource, sourceWidth: number, sourceHeight: number, width: number, height: number, fit: MediaObjectFit): void;
|
|
36
|
+
/**
|
|
37
|
+
* Width a classic vertical scrollbar occupies, 0 on platforms that float scrollbars over the
|
|
38
|
+
* content. Measured once from a throwaway scroller and cached, the same way the measurement context
|
|
39
|
+
* is; without a document (SSR, unit tests) there is nothing to reserve.
|
|
40
|
+
*/
|
|
41
|
+
export declare function verticalScrollbarWidth(): number;
|
|
42
|
+
export declare function setThemeCanvasSource(canvas: HTMLCanvasElement, source: HTMLCanvasElement): void;
|
|
43
|
+
/**
|
|
44
|
+
* Drops every cached theme colour so the next read recomputes it. Call this whenever the theme can
|
|
45
|
+
* change (for example from a MutationObserver watching the canvas / ancestor `class` or `style`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function invalidateThemeColors(): void;
|
|
48
|
+
export declare function themeColor(context: CanvasRenderingContext2D, token: string, fallback: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentKind } from '../types';
|
|
2
|
+
export declare const kindSymbol: unique symbol;
|
|
3
|
+
export type MarkedComponent<Props = Record<string, unknown>> = ((props: Props) => null) & {
|
|
4
|
+
displayName?: string;
|
|
5
|
+
[kindSymbol]?: ComponentKind;
|
|
6
|
+
};
|
|
7
|
+
export declare function createComponent<Props>(kind: ComponentKind): MarkedComponent<Props>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ComponentSize {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function componentWidth(props: Record<string, unknown>, fallback: number): number;
|
|
6
|
+
export declare function componentHeight(props: Record<string, unknown>, fallback: number): number;
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
export type { ButtonProps } from './Button';
|
|
2
|
-
export type {
|
|
3
|
-
CanvasViewFit,
|
|
4
|
-
CanvasViewPointerEvent,
|
|
5
|
-
CanvasViewPointerEventHandler,
|
|
6
|
-
CanvasViewProps,
|
|
7
|
-
} from './CanvasView';
|
|
2
|
+
export type { CanvasViewFit, CanvasViewPointerEvent, CanvasViewPointerEventHandler, CanvasViewProps, } from './CanvasView';
|
|
8
3
|
export type { CarouselItemProps, CarouselProps } from './Carousel';
|
|
9
4
|
export type { CheckboxProps } from './Checkbox';
|
|
10
5
|
export type { ChoiceGroupProps, ChoiceOption } from './ChoiceGroup';
|
|
11
6
|
export type { CircleProps } from './Circle';
|
|
12
7
|
export type { CollapseItemProps, CollapseProps } from './Collapse';
|
|
13
|
-
export type {
|
|
14
|
-
CustomDrawClickEvent,
|
|
15
|
-
CustomDrawHitTest,
|
|
16
|
-
CustomDrawProps,
|
|
17
|
-
CustomDrawSize,
|
|
18
|
-
} from './CustomDraw';
|
|
8
|
+
export type { CustomDrawClickEvent, CustomDrawHitTest, CustomDrawProps, CustomDrawSize, } from './CustomDraw';
|
|
19
9
|
export type { DatePickerProps } from './DatePicker';
|
|
20
10
|
export type { DialogProps } from './Dialog';
|
|
21
11
|
export type { DropdownOption, DropdownProps } from './Dropdown';
|
|
@@ -34,4 +24,5 @@ export type { TabItemProps, TabsProps } from './Tabs';
|
|
|
34
24
|
export type { TextProps } from './Text';
|
|
35
25
|
export type { TextareaProps } from './Textarea';
|
|
36
26
|
export type { UploadProps } from './Upload';
|
|
27
|
+
export type { VideoProps } from './Video';
|
|
37
28
|
export type { ComponentSize } from './size';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SceneNode } from '../scene';
|
|
2
|
+
import type { CarouselTransition, EngineCore, EngineState } from './state';
|
|
3
|
+
/**
|
|
4
|
+
* The carousel state machine: autoplay timing, index transitions and the
|
|
5
|
+
* per-frame easing that slides items. Driven by {@link advanceCarousels} from the
|
|
6
|
+
* render loop and {@link changeCarousel} from pointer interaction.
|
|
7
|
+
*/
|
|
8
|
+
export declare function transitionProgress(transition: CarouselTransition, time: number): number;
|
|
9
|
+
export declare function changeCarousel(core: EngineCore, state: EngineState, node: SceneNode, requestedIndex: number): void;
|
|
10
|
+
export declare function advanceCarousels(core: EngineCore, state: EngineState, time: number): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SceneNode } from '../scene';
|
|
2
|
+
import type { CanvasPointerEvent } from '../types';
|
|
3
|
+
import type { CanvasViewPointerEvent } from '../components/CanvasView';
|
|
4
|
+
import type { HitResult } from './hit-test';
|
|
5
|
+
import type { EngineCore } from './state';
|
|
6
|
+
/**
|
|
7
|
+
* Translates resolved pointer geometry into the public {@link CanvasUIEvent}
|
|
8
|
+
* stream and the per-node `canvasView` pointer callbacks.
|
|
9
|
+
*/
|
|
10
|
+
export declare function emitPointerEvent(core: EngineCore, type: 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel', event: CanvasPointerEvent, hit: HitResult | null, point: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}): void;
|
|
14
|
+
export declare function emitCanvasViewPointerEvent(type: CanvasViewPointerEvent['type'], node: SceneNode, x: number, y: number, event: CanvasPointerEvent): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SceneNode } from '../scene';
|
|
2
|
+
import type { EngineCore } from './state';
|
|
3
|
+
/**
|
|
4
|
+
* Geometry: resolve client (viewport) coordinates to canvas / node-local space and
|
|
5
|
+
* determine which interactive node, if any, is under a pointer, honouring modal
|
|
6
|
+
* dialogs and grid/carousel clipping. Pure apart from reading the live scene graph.
|
|
7
|
+
*/
|
|
8
|
+
export interface HitResult {
|
|
9
|
+
node: SceneNode;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function canvasPoint(core: EngineCore, canvas: HTMLCanvasElement, clientX: number, clientY: number): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
} | null;
|
|
17
|
+
export declare function localPoint(core: EngineCore, canvas: HTMLCanvasElement, clientX: number, clientY: number, target: SceneNode): {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare function isWithinClip(core: EngineCore, canvas: HTMLCanvasElement, clientX: number, clientY: number, node: SceneNode): boolean;
|
|
22
|
+
export declare function findHit(core: EngineCore, canvas: HTMLCanvasElement, clientX: number, clientY: number): HitResult | null;
|
|
23
|
+
export declare function findCarouselControlHit(core: EngineCore, canvas: HTMLCanvasElement, clientX: number, clientY: number): {
|
|
24
|
+
node: SceneNode;
|
|
25
|
+
index: number;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare function findGridScrollbarHit(core: EngineCore, canvas: HTMLCanvasElement, clientX: number, clientY: number): {
|
|
28
|
+
node: SceneNode;
|
|
29
|
+
pointerY: number;
|
|
30
|
+
scrollTop: number;
|
|
31
|
+
} | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VNode } from '../types';
|
|
2
|
+
import type { EngineCore, EngineState } from './state';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribes the engine to the shared image cache for every `image` source in the
|
|
5
|
+
* tree, tearing down subscriptions for sources that disappear. Load errors mark the
|
|
6
|
+
* scene dirty and forward to each image node's `onError` callback.
|
|
7
|
+
*/
|
|
8
|
+
export declare function syncImages(core: EngineCore, state: EngineState, tree: VNode[]): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CanvasPointerEvent, CanvasWheelEvent } from '../types';
|
|
2
|
+
import type { EngineCore, EngineState } from './state';
|
|
3
|
+
/**
|
|
4
|
+
* Turns raw pointer/wheel events into state mutations on the scene graph: routes a
|
|
5
|
+
* press to the correct component, drives sliders, buttons, tabs, collapses, dropdowns,
|
|
6
|
+
* dialogs and grid scrolling, and emits the public event stream.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pointerDown(core: EngineCore, state: EngineState, event: CanvasPointerEvent): void;
|
|
9
|
+
export declare function pointerMove(core: EngineCore, state: EngineState, event: CanvasPointerEvent): void;
|
|
10
|
+
export declare function pointerUp(core: EngineCore, state: EngineState, event: CanvasPointerEvent, cancelled?: boolean): void;
|
|
11
|
+
export declare function wheel(core: EngineCore, state: EngineState, event: CanvasWheelEvent): void;
|
|
@@ -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;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import type { SceneNode } from '../scene';
|
|
2
2
|
import type { CanvasRenderer } from '../renderer';
|
|
3
3
|
import type { CanvasUIEvent, InputLayout, TextControlProps, WebInputBridge } from '../types';
|
|
4
|
-
|
|
4
|
+
import type { VirtualGridLayout } from './vnodes';
|
|
5
5
|
/** A text input/date/textarea currently mirrored into the DOM overlay bridge. */
|
|
6
6
|
export interface MountedTextControl {
|
|
7
7
|
node: SceneNode;
|
|
8
8
|
dispose: () => void;
|
|
9
9
|
layout: InputLayout;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
/** A text control discovered during the `prepare` pass, awaiting sync. */
|
|
13
12
|
export interface TextControlDescription {
|
|
14
13
|
id: string;
|
|
15
14
|
props: TextControlProps;
|
|
16
15
|
layout: InputLayout;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
export interface CarouselTransition {
|
|
20
18
|
from: number;
|
|
21
19
|
to: number;
|
|
@@ -23,20 +21,23 @@ export interface CarouselTransition {
|
|
|
23
21
|
startedAt: number;
|
|
24
22
|
duration: number;
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
export interface PointerSequence {
|
|
28
25
|
target: SceneNode | null;
|
|
29
26
|
x: number;
|
|
30
27
|
y: number;
|
|
31
28
|
eligible: boolean;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
export interface GridScrollGesture {
|
|
35
31
|
node: SceneNode;
|
|
36
32
|
pointerY: number;
|
|
37
33
|
scrollTop: number;
|
|
38
34
|
}
|
|
39
|
-
|
|
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
|
+
}
|
|
40
41
|
/**
|
|
41
42
|
* Immutable services and configuration shared by every engine behaviour module:
|
|
42
43
|
* the scene graph, renderer, canvas context, DOM input bridge and callbacks.
|
|
@@ -50,26 +51,30 @@ export interface EngineCore {
|
|
|
50
51
|
readonly pixelRatio: number;
|
|
51
52
|
readonly onFrame?: (time: number) => void;
|
|
52
53
|
readonly onEvent?: (event: CanvasUIEvent) => void;
|
|
54
|
+
readonly refreshVirtualGrids: () => void;
|
|
53
55
|
}
|
|
54
|
-
|
|
55
56
|
/**
|
|
56
57
|
* All engine-mutable state that survives across frames and pointer events.
|
|
57
58
|
* Extracted from the former {@link CanvasEngine} private fields so behaviour
|
|
58
59
|
* modules can operate on it explicitly instead of via a God-class `this`.
|
|
59
60
|
*/
|
|
60
|
-
export class EngineState {
|
|
61
|
-
readonly textControls
|
|
62
|
-
readonly inputValues
|
|
63
|
-
readonly imageSubscriptions
|
|
64
|
-
readonly
|
|
65
|
-
readonly
|
|
66
|
-
readonly
|
|
67
|
-
readonly
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
readonly
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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;
|
|
75
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,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,4 @@
|
|
|
1
|
+
import type { CanvasHandle } from '../canvas-handle';
|
|
2
|
+
import type { CanvasProps } from '../types';
|
|
3
|
+
export type { CanvasExportOptions, CanvasHandle } from '../canvas-handle';
|
|
4
|
+
export declare const Canvas: import("react").ForwardRefExoticComponent<CanvasProps & import("react").RefAttributes<CanvasHandle>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { VNode } from '../types';
|
|
2
|
+
export type * from '../components/types';
|
|
3
|
+
export { Group } from '../components/Group';
|
|
4
|
+
export { Grid } from '../components/Grid';
|
|
5
|
+
export { GridItem } from '../components/GridItem';
|
|
6
|
+
export { Rect } from '../components/Rect';
|
|
7
|
+
export { Circle } from '../components/Circle';
|
|
8
|
+
export { Text } from '../components/Text';
|
|
9
|
+
export { Input } from '../components/Input';
|
|
10
|
+
export { Textarea } from '../components/Textarea';
|
|
11
|
+
export { Dropdown } from '../components/Dropdown';
|
|
12
|
+
export { Slider } from '../components/Slider';
|
|
13
|
+
export { Switch } from '../components/Switch';
|
|
14
|
+
export { DatePicker } from '../components/DatePicker';
|
|
15
|
+
export { Radio } from '../components/Radio';
|
|
16
|
+
export { Checkbox } from '../components/Checkbox';
|
|
17
|
+
export { Upload } from '../components/Upload';
|
|
18
|
+
export { Carousel, CarouselItem } from '../components/Carousel';
|
|
19
|
+
export type { ChoiceOption } from '../components/ChoiceGroup';
|
|
20
|
+
export { Button } from '../components/Button';
|
|
21
|
+
export { Image } from '../components/Image';
|
|
22
|
+
export { Icon } from '../components/Icon';
|
|
23
|
+
export { Dialog } from '../components/Dialog';
|
|
24
|
+
export { Progress } from '../components/Progress';
|
|
25
|
+
export { Tabs, TabItem } from '../components/Tabs';
|
|
26
|
+
export { Collapse, CollapseItem } from '../components/Collapse';
|
|
27
|
+
export { CustomDraw } from '../components/CustomDraw';
|
|
28
|
+
export { CanvasView } from '../components/CanvasView';
|
|
29
|
+
export { Video } from '../components/Video';
|
|
30
|
+
export declare function compileChildren(children: unknown): VNode[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Canvas } from './Canvas';
|
|
2
|
+
export type { CanvasExportOptions, CanvasHandle } from './Canvas';
|
|
3
|
+
export { Group, Grid, GridItem, Rect, Circle, Text, Input, DatePicker, Radio, Checkbox, Textarea, Dropdown, Slider, Switch, Button, Upload, Carousel, CarouselItem, Image, Icon, Dialog, Progress, Tabs, TabItem, Collapse, CollapseItem, CustomDraw, CanvasView, Video, } from './components';
|
|
4
|
+
export type { CanvasProps, GroupProps, GridProps, GridItemProps, ImageProps, IconName, IconProps, IconVariant, DialogProps, ProgressProps, TabsProps, TabItemProps, CollapseProps, CollapseItemProps, RectProps, CircleProps, TextProps, InputProps, DatePickerProps, RadioProps, CheckboxProps, UploadProps, CarouselProps, CarouselItemProps, ChoiceOption, TextareaProps, DropdownOption, DropdownProps, SliderProps, SwitchProps, ButtonProps, ComponentSize, CustomDrawProps, CustomDrawSize, CustomDrawClickEvent, CustomDrawHitTest, CanvasViewFit, CanvasViewPointerEvent, CanvasViewPointerEventHandler, CanvasViewProps, VideoProps, CanvasUIEvent, CanvasUIPointerEvent, CanvasUIWheelEvent, CanvasUIEventTarget, } from '../types';
|
|
@@ -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
|
+
}
|