@web-canvas-ui/react 0.1.2 → 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 (157) hide show
  1. package/README.md +172 -76
  2. package/index.js +2682 -0
  3. package/package.json +36 -27
  4. package/types/canvas-handle.d.ts +22 -0
  5. package/types/components/Button/button.d.ts +20 -0
  6. package/types/components/Button/logic.d.ts +3 -0
  7. package/types/components/CanvasView/canvasView.d.ts +28 -0
  8. package/types/components/CanvasView/index.d.ts +2 -0
  9. package/types/components/Carousel/carousel.d.ts +31 -0
  10. package/types/components/Carousel/logic.d.ts +2 -0
  11. package/types/components/Checkbox/checkbox.d.ts +8 -0
  12. package/types/components/ChoiceGroup/choiceGroup.d.ts +33 -0
  13. package/types/components/ChoiceGroup/logic.d.ts +3 -0
  14. package/types/components/Circle/circle.d.ts +9 -0
  15. package/types/components/Collapse/collapse.d.ts +32 -0
  16. package/types/components/Collapse/logic.d.ts +1 -0
  17. package/types/components/CustomDraw/customDraw.d.ts +22 -0
  18. package/types/components/CustomDraw/index.d.ts +2 -0
  19. package/types/components/DatePicker/datePicker.d.ts +24 -0
  20. package/types/components/Dialog/dialog.d.ts +20 -0
  21. package/types/components/Dropdown/dropdown.d.ts +30 -0
  22. package/types/components/Dropdown/logic.d.ts +5 -0
  23. package/{components/Grid/grid.ts → types/components/Grid/grid.d.ts} +3 -4
  24. package/{components/GridItem/gridItem.ts → types/components/GridItem/gridItem.d.ts} +1 -4
  25. package/{components/Group/group.ts → types/components/Group/group.d.ts} +1 -4
  26. package/types/components/Icon/icon.d.ts +14 -0
  27. package/types/components/Image/image.d.ts +12 -0
  28. package/types/components/Input/input.d.ts +32 -0
  29. package/types/components/Progress/progress.d.ts +15 -0
  30. package/types/components/Radio/radio.d.ts +8 -0
  31. package/types/components/Rect/rect.d.ts +11 -0
  32. package/types/components/Slider/logic.d.ts +1 -0
  33. package/types/components/Slider/slider.d.ts +17 -0
  34. package/types/components/Switch/logic.d.ts +2 -0
  35. package/types/components/Switch/switch.d.ts +14 -0
  36. package/types/components/Tabs/logic.d.ts +2 -0
  37. package/types/components/Tabs/tabs.d.ts +35 -0
  38. package/types/components/Text/text.d.ts +39 -0
  39. package/types/components/Textarea/textarea.d.ts +10 -0
  40. package/types/components/Upload/upload.d.ts +20 -0
  41. package/types/components/Video/index.d.ts +2 -0
  42. package/types/components/Video/video.d.ts +20 -0
  43. package/types/components/draw-utils.d.ts +48 -0
  44. package/types/components/shared.d.ts +7 -0
  45. package/types/components/size.d.ts +6 -0
  46. package/{components/types.ts → types/components/types.d.ts} +3 -12
  47. package/types/engine/carousel.d.ts +10 -0
  48. package/types/engine/events.d.ts +14 -0
  49. package/types/engine/hit-test.d.ts +31 -0
  50. package/types/engine/images.d.ts +8 -0
  51. package/types/engine/interaction.d.ts +11 -0
  52. package/types/engine/layout.d.ts +6 -0
  53. package/types/engine/nodes.d.ts +18 -0
  54. package/{engine/state.ts → types/engine/state.d.ts} +27 -22
  55. package/types/engine/text-controls.d.ts +10 -0
  56. package/types/engine/transform.d.ts +13 -0
  57. package/types/engine/videos.d.ts +14 -0
  58. package/types/engine/vnodes.d.ts +36 -0
  59. package/types/engine.d.ts +36 -0
  60. package/types/image-assets.d.ts +2 -0
  61. package/types/input-bridge.d.ts +40 -0
  62. package/types/react/Canvas.d.ts +4 -0
  63. package/types/react/components.d.ts +30 -0
  64. package/types/react/index.d.ts +4 -0
  65. package/types/renderer.d.ts +20 -0
  66. package/types/scene.d.ts +15 -0
  67. package/{types.ts → types/types.d.ts} +10 -142
  68. package/types/video-assets.d.ts +11 -0
  69. package/Canvas.tsx +0 -142
  70. package/__tests__/pure-logic.test.ts +0 -153
  71. package/__tests__/scene-and-node.test.ts +0 -131
  72. package/__tests__/scratch-space.test.ts +0 -30
  73. package/__tests__/textarea-caret.test.ts +0 -96
  74. package/__tests__/utils.test.ts +0 -114
  75. package/canvas-handle.ts +0 -114
  76. package/components/Button/button.ts +0 -57
  77. package/components/Button/logic.ts +0 -11
  78. package/components/CanvasView/canvasView.ts +0 -103
  79. package/components/CanvasView/index.ts +0 -7
  80. package/components/Carousel/carousel.ts +0 -107
  81. package/components/Carousel/logic.ts +0 -36
  82. package/components/Checkbox/checkbox.ts +0 -14
  83. package/components/ChoiceGroup/choiceGroup.ts +0 -172
  84. package/components/ChoiceGroup/logic.ts +0 -14
  85. package/components/Circle/circle.ts +0 -31
  86. package/components/Collapse/collapse.ts +0 -69
  87. package/components/Collapse/logic.ts +0 -14
  88. package/components/CustomDraw/customDraw.ts +0 -50
  89. package/components/CustomDraw/index.ts +0 -7
  90. package/components/DatePicker/datePicker.ts +0 -70
  91. package/components/Dialog/dialog.ts +0 -102
  92. package/components/Dropdown/dropdown.ts +0 -125
  93. package/components/Dropdown/logic.ts +0 -29
  94. package/components/Icon/icon.ts +0 -669
  95. package/components/Image/image.ts +0 -69
  96. package/components/Input/input.ts +0 -139
  97. package/components/Progress/progress.ts +0 -59
  98. package/components/Radio/radio.ts +0 -14
  99. package/components/Rect/rect.ts +0 -35
  100. package/components/Slider/logic.ts +0 -19
  101. package/components/Slider/slider.ts +0 -58
  102. package/components/Switch/logic.ts +0 -8
  103. package/components/Switch/switch.ts +0 -37
  104. package/components/Tabs/logic.ts +0 -14
  105. package/components/Tabs/tabs.ts +0 -78
  106. package/components/Text/text.ts +0 -95
  107. package/components/Textarea/textarea.ts +0 -16
  108. package/components/Upload/upload.ts +0 -66
  109. package/components/draw-utils.ts +0 -230
  110. package/components/shared.ts +0 -15
  111. package/components/size.ts +0 -20
  112. package/components.ts +0 -98
  113. package/engine/__tests__/carousel.test.ts +0 -218
  114. package/engine/__tests__/hit-test.test.ts +0 -282
  115. package/engine/__tests__/layout.test.ts +0 -474
  116. package/engine/carousel.ts +0 -150
  117. package/engine/events.ts +0 -73
  118. package/engine/hit-test.ts +0 -321
  119. package/engine/images.ts +0 -41
  120. package/engine/interaction.ts +0 -442
  121. package/engine/layout.ts +0 -355
  122. package/engine/nodes.ts +0 -166
  123. package/engine/text-controls.ts +0 -122
  124. package/engine/transform.ts +0 -61
  125. package/engine/vnodes.ts +0 -204
  126. package/engine.ts +0 -162
  127. package/image-assets.ts +0 -37
  128. package/index.ts +0 -78
  129. package/input-bridge.ts +0 -285
  130. package/renderer.ts +0 -303
  131. package/scene.ts +0 -122
  132. package/theme.scss +0 -234
  133. package/web-canvas-ui-react-0.1.1.tgz +0 -0
  134. /package/{components/Button/index.ts → types/components/Button/index.d.ts} +0 -0
  135. /package/{components/Carousel/index.ts → types/components/Carousel/index.d.ts} +0 -0
  136. /package/{components/Checkbox/index.ts → types/components/Checkbox/index.d.ts} +0 -0
  137. /package/{components/ChoiceGroup/index.ts → types/components/ChoiceGroup/index.d.ts} +0 -0
  138. /package/{components/Circle/index.ts → types/components/Circle/index.d.ts} +0 -0
  139. /package/{components/Collapse/index.ts → types/components/Collapse/index.d.ts} +0 -0
  140. /package/{components/DatePicker/index.ts → types/components/DatePicker/index.d.ts} +0 -0
  141. /package/{components/Dialog/index.ts → types/components/Dialog/index.d.ts} +0 -0
  142. /package/{components/Dropdown/index.ts → types/components/Dropdown/index.d.ts} +0 -0
  143. /package/{components/Grid/index.ts → types/components/Grid/index.d.ts} +0 -0
  144. /package/{components/GridItem/index.ts → types/components/GridItem/index.d.ts} +0 -0
  145. /package/{components/Group/index.ts → types/components/Group/index.d.ts} +0 -0
  146. /package/{components/Icon/index.ts → types/components/Icon/index.d.ts} +0 -0
  147. /package/{components/Image/index.ts → types/components/Image/index.d.ts} +0 -0
  148. /package/{components/Input/index.ts → types/components/Input/index.d.ts} +0 -0
  149. /package/{components/Progress/index.ts → types/components/Progress/index.d.ts} +0 -0
  150. /package/{components/Radio/index.ts → types/components/Radio/index.d.ts} +0 -0
  151. /package/{components/Rect/index.ts → types/components/Rect/index.d.ts} +0 -0
  152. /package/{components/Slider/index.ts → types/components/Slider/index.d.ts} +0 -0
  153. /package/{components/Switch/index.ts → types/components/Switch/index.d.ts} +0 -0
  154. /package/{components/Tabs/index.ts → types/components/Tabs/index.d.ts} +0 -0
  155. /package/{components/Text/index.ts → types/components/Text/index.d.ts} +0 -0
  156. /package/{components/Textarea/index.ts → types/components/Textarea/index.d.ts} +0 -0
  157. /package/{components/Upload/index.ts → types/components/Upload/index.d.ts} +0 -0
package/README.md CHANGED
@@ -10,20 +10,32 @@ A declarative component library built on Canvas 2D, with **React**, **Vue 3**, *
10
10
 
11
11
  > **Adapters:** React, Vue, Svelte, and Angular import from `@web-canvas-ui/react`, `@web-canvas-ui/vue`, `@web-canvas-ui/svelte`, and `@web-canvas-ui/angular` respectively. Pick the entry that matches your host Canvas framework and do not mix components across adapters — they all reuse the same engine and control drawing implementation.
12
12
 
13
- > **Shared component contract:** Each control lives under `components/<Component>/`. The `components.ts` entry exposes the public API, `<component>.ts` defines the Props type and the Canvas draw function, and `logic.ts` (when needed) holds interaction/business logic specific to that control. Common types are aggregated in `components/types.ts` and re-exported through `web-canvas-ui/types.ts`. React, Vue, Svelte, and Angular adapters share this type contract.
13
+ > **Shared component contract:** Each control lives under `src/canvas-ui/components/<Component>/`. `<component>.ts` defines the Props type and Canvas drawing function, and `logic.ts` (when needed) holds control-specific interaction and business logic. Public types are aggregated in `components/types.ts` and re-exported through `src/canvas-ui/types.ts` and each framework entry. The React, Vue, Svelte, and Angular adapters share this type contract. See the [component development guide](./COMPONENT-DEVELOPMENT.zh-CN.md) (in Chinese) for the full procedure.
14
14
 
15
- ### Packages
16
- - [web-canvas-ui](https://www.npmjs.com/package/web-canvas-ui)
15
+ ### Clone the Repository
16
+
17
+ Clone the project to your local machine and navigate into the directory:
18
+
19
+ ```bash
20
+ git clone https://github.com/web-canvas-ui/web-canvas-ui.git
21
+ cd web-canvas-ui
22
+ npm install
23
+ npm run dev
24
+
25
+ OR
26
+ ```
27
+
28
+ [▶️ Try Live Demo](https://codesandbox.io/p/sandbox/web-canvas-ui-demo-2jhwsn)
17
29
 
18
30
  ## Global Theme Colors
19
31
 
20
32
  Theme colors are centralized in [`theme.scss`](src/canvas-ui/theme.scss) as `$primary: #1668dc`. Changing this single variable updates the accent color for buttons, selected states, focus borders, progress bars, and more. Light variants are mixed with white, and pressed variants darken the primary; the shared scales are also emitted as `--canvas-ui-primary*` CSS variables. `theme.css` is a build artifact — import it as global CSS and do not edit the generated file directly:
21
33
 
22
34
  ```css
23
- @import 'web-canvas-ui/theme.css';
35
+ @import '@web-canvas-ui/react/theme.css';
24
36
  ```
25
37
 
26
- After editing `theme.scss`, run `npm run build:theme` to regenerate the CSS. The compiled CSS custom properties apply to React, Vue, Svelte, and Angular, and provide `.dark` and `[data-theme="dark"]` dark themes. Colors passed explicitly to a component take precedence over theme variables.
38
+ Replace `react` with `vue`, `svelte`, or `angular` for the other packages. After editing `theme.scss`, run `npm run build:theme` to regenerate the CSS. The compiled CSS custom properties apply to React, Vue, Svelte, and Angular, and provide `.dark` and `[data-theme="dark"]` dark themes. Colors passed explicitly to a component take precedence over theme variables.
27
39
 
28
40
  Five built-in primary palettes are provided: blue, green, purple, orange, and red. Add the corresponding class to the outer Canvas container to switch palettes; they also combine with the dark theme:
29
41
 
@@ -68,12 +80,8 @@ To customize the theme for a specific application, override only the variables y
68
80
 
69
81
  ## Environment and Imports
70
82
 
71
- Place the `web-canvas-ui` directory into your project and make sure the host Canvas project is already configured for the chosen framework: React 19+, Vue 3, Svelte 5+, or Angular 17+. Vue uses single-file component templates and does not require a JSX plugin or `jsxImportSource`. Svelte projects need the Svelte compiler and its matching build plugin. Angular projects need `@angular/core` and the Angular build setup. Framework dependencies are provided by the host Canvas project — this directory does not enforce dependencies on any particular framework.
83
+ Install the package for your framework: React 19+, Vue 3, Svelte 5+, or Angular 17+. Framework dependencies are supplied by the host project.
72
84
 
73
- ```
74
- npm install web-canvas-ui
75
- ```
76
- OR
77
85
  ```
78
86
  npm install @web-canvas-ui/react
79
87
 
@@ -84,12 +92,12 @@ npm install @web-canvas-ui/svelte
84
92
  npm install @web-canvas-ui/angular
85
93
  ```
86
94
 
87
- | Framework | Entry |
88
- | ----------- |-------------------------|
89
- | React | `web-canvas-ui/react \ @web-canvas-ui/react` |
90
- | Vue 3 | `web-canvas-ui/vue \ @web-canvas-ui/vue` |
91
- | Svelte 5+ | `web-canvas-ui/svelte \ @web-canvas-ui/svelte` |
92
- | Angular 17+ | `web-canvas-ui/angular \ @web-canvas-ui/angular` |
95
+ | Framework | Entry |
96
+ | ----------- | ------------------------------------------------ |
97
+ | React | `@web-canvas-ui/react` |
98
+ | Vue 3 | `@web-canvas-ui/vue` |
99
+ | Svelte 5+ | `@web-canvas-ui/svelte` |
100
+ | Angular 17+ | `@web-canvas-ui/angular` |
93
101
 
94
102
  Components must be placed inside the corresponding adapter's Canvas container and use the scene components exported by that framework's entry. Do not place plain DOM elements inside a Canvas scene.
95
103
 
@@ -123,9 +131,7 @@ export function ProfileCanvas() {
123
131
  <Canvas ref={canvasRef} width={420} height={220}>
124
132
  <Group x={24} y={24}>
125
133
  <Rect width={340} height={170} color="#f5f8fc" radius={12} />
126
- <Text x={16} y={16} fontSize={20} color="#222">
127
- Profile
128
- </Text>
134
+ <Text x={16} y={16} fontSize={20} color="#222" text="Profile" />
129
135
  <Input
130
136
  x={16}
131
137
  y={54}
@@ -135,9 +141,7 @@ export function ProfileCanvas() {
135
141
  placeholder="Your name"
136
142
  onChange={setName}
137
143
  />
138
- <Text x={16} y={108} width={280} fontSize={16}>
139
- {name ? `Hello, ${name}` : 'Type your name'}
140
- </Text>
144
+ <Text x={16} y={108} width={280} fontSize={16} text={name ? `Hello, ${name}` : 'Type your name'} />
141
145
  <Button
142
146
  x={16}
143
147
  y={136}
@@ -160,7 +164,7 @@ export function ProfileCanvas() {
160
164
 
161
165
  ## Quick Start (Vue 3 Single-File Component)
162
166
 
163
- The Vue adapter lives at the dedicated `web-canvas-ui/vue` entry. Nest Canvas UI components directly in a `.vue` template — no TSX, no JSX plugin, no manual Canvas node arrays:
167
+ The Vue adapter lives in `@web-canvas-ui/vue`. Nest Canvas UI components directly in a `.vue` template — no TSX, no JSX plugin, no manual Canvas node arrays:
164
168
 
165
169
  ```vue
166
170
  <script setup lang="ts">
@@ -190,7 +194,7 @@ function exportPng() {
190
194
  <Canvas ref="canvasRef" :width="420" :height="220">
191
195
  <Group :x="24" :y="24">
192
196
  <Rect :width="340" :height="170" color="#f5f8fc" :radius="12" />
193
- <Text :x="16" :y="16" :font-size="20">Vue 3 Canvas</Text>
197
+ <Text :x="16" :y="16" :font-size="20" text="Vue 3 Canvas" />
194
198
  <Input
195
199
  :x="16"
196
200
  :y="54"
@@ -200,9 +204,7 @@ function exportPng() {
200
204
  placeholder="Your name"
201
205
  @change="name = $event"
202
206
  />
203
- <Text :x="16" :y="104" :width="280">
204
- {{ name ? `Hello, ${name}` : 'Type your name' }}
205
- </Text>
207
+ <Text :x="16" :y="104" :width="280" :text="name ? `Hello, ${name}` : 'Type your name'" />
206
208
  <Button :x="16" :y="142" :width="120" :height="36" @click="exportPng">
207
209
  Export Image
208
210
  </Button>
@@ -262,10 +264,10 @@ The Angular entry provides a standalone `Canvas` component and scene directives.
262
264
  ```ts
263
265
  import { Component, ViewChild } from '@angular/core';
264
266
  import { Button, Canvas, Group, Input, Rect, Text } from '@web-canvas-ui/angular';
265
- import './theme.css';
266
267
 
267
268
  @Component({
268
- selector: 'profile-canvas',
269
+ selector: 'app-root',
270
+ styleUrl: './theme.css',
269
271
  standalone: true,
270
272
  imports: [Canvas, Group, Rect, Text, Input, Button],
271
273
  template: `
@@ -283,7 +285,7 @@ import './theme.css';
283
285
  [y]="48"
284
286
  [value]="name"
285
287
  placeholder="Your name"
286
- (valueChange)="name = $event"
288
+ (valueChange)="onInputChange($event)"
287
289
  ></canvas-input>
288
290
  <canvas-text
289
291
  [x]="16"
@@ -312,6 +314,9 @@ export class ProfileCanvas {
312
314
  link.download = 'profile.png';
313
315
  link.click();
314
316
  }
317
+ onInputChange(e: any) {
318
+ this.name = e;
319
+ }
315
320
  }
316
321
  ```
317
322
 
@@ -449,7 +454,7 @@ import { Canvas, CustomDraw } from '@web-canvas-ui/react';
449
454
  </Canvas>;
450
455
  ```
451
456
 
452
- Each invocation is isolated from the rest of the Canvas drawing state — colors, line widths, and transforms set inside the callback do not leak to other components. Only draw inside the callback; do not update UI state or perform side effects. Drawing errors are re-thrown as-is.
457
+ Each invocation is isolated from the rest of the Canvas drawing state — colors, line widths, and transforms set inside the callback do not leak to other components. Only draw inside the callback; do not update UI state or perform side effects. The renderer logs drawing errors to the console, skips the affected node, and continues drawing other nodes.
453
458
 
454
459
  ### `<Group>`
455
460
 
@@ -461,9 +466,7 @@ Used to group, position, and transform children. Supports [Common Props](#common
461
466
 
462
467
  ```tsx
463
468
  <Group x={20} y={30} scaleX={1.2}>
464
- <Text x={10} y={10}>
465
- Text inside a group
466
- </Text>
469
+ <Text x={10} y={10} text="Text inside a group" />
467
470
  </Group>
468
471
  ```
469
472
 
@@ -479,6 +482,7 @@ Places children in order into fixed-size cells, wrapping to the next row once a
479
482
  | `cellWidth` | `number` | No | — | Fixed logical cell width; takes precedence over `width` auto-distribution. Must be positive. |
480
483
  | `cellHeight` | `number` | Yes | — | Logical cell height; must be positive. |
481
484
  | `gap` | `number` | No | `0` | Equal row and column spacing; must not be negative. |
485
+ | `virtual` | `boolean` | No | `false` | Mount only items near the viewport; requires `height`. |
482
486
  | `onScroll` | `(scrollTop: number) => void` | No | — | Scroll position change callback, in logical pixels. |
483
487
 
484
488
  Direct children keep their own `x` and `y`, plus the offset of the cell they fall into. When `cellWidth` is not passed, columns are equal-width: `(width - gap * (columns - 1)) / columns`. A child's own size is not automatically stretched.
@@ -511,12 +515,26 @@ Once a Grid has a `height`, content beyond the visible area is scrollable via th
511
515
  <Grid columns={1} width={280} height={180} cellHeight={44} gap={4}>
512
516
  {items.map((item) => (
513
517
  <GridItem key={item.id}>
514
- <Text>{item.label}</Text>
518
+ <Text text={item.label} />
515
519
  </GridItem>
516
520
  ))}
517
521
  </Grid>
518
522
  ```
519
523
 
524
+ For large data sets, use `<Grid ... height={180} virtual>` (Angular: `[virtual]="true"`). Only items within the viewport and approximately one row above and below it are mounted; the window updates as you scroll, and row and column spans still affect layout. Offscreen items are unmounted, so store uncontrolled input and other state externally using controlled values and stable keys. Visibility is based on the cell area, not overflow caused by drawing, rotation, or scaling. Initial layout and framework child creation still process all supplied items.
525
+
526
+ Where possible, unchanged static virtual grids reuse their drawing when other components repaint. Scrolling, content changes, and theme changes invalidate it. Grids containing videos, images, `CustomDraw`, or `CanvasView` are drawn normally to keep dynamic content current. In React, memoize the whole Grid element with `useMemo` to avoid recreating and compiling its children when unrelated state changes; include the data and all values affecting the list in the dependency array:
527
+
528
+ ```tsx
529
+ const grid = useMemo(() => (
530
+ <Grid columns={1} width={280} height={180} cellHeight={44} virtual>
531
+ {items.map((item) => (
532
+ <GridItem key={item.id}><Text text={item.label} /></GridItem>
533
+ ))}
534
+ </Grid>
535
+ ), [items]);
536
+ ```
537
+
520
538
  ### `<GridItem>`
521
539
 
522
540
  `GridItem` is a grouping/layout node inside a Grid and does not draw anything itself. It can contain multiple controls, positioning them together as one grid entry; children inside the group still use their own sizes and local coordinates. Placing ordinary controls directly under `Grid` also works — they each occupy one cell by default.
@@ -535,9 +553,7 @@ Grid places items row by row, skipping cells already occupied by spanning items:
535
553
  <Grid columns={3} width={316} cellHeight={50} gap={8}>
536
554
  <GridItem columnSpan={2}>
537
555
  <Rect width={180} height={40} color="#f5f8fc" />
538
- <Text x={8} y={8}>
539
- Group spanning two columns
540
- </Text>
556
+ <Text x={8} y={8} text="Group spanning two columns" />
541
557
  </GridItem>
542
558
  <Rect width={80} height={40} color="#e5efff" />
543
559
  </Grid>
@@ -547,6 +563,8 @@ Vue and Svelte use the same `<GridItem>`; Angular uses `<canvas-grid-item [colum
547
563
 
548
564
  ### `<Image>`
549
565
 
566
+ `Image`, `Text`, and `Icon` accept an optional `onClick: () => void`. Only nodes with a click listener participate in hit testing; the clickable area is the component's bounding box. Angular uses `(click)`; Vue uses `@click`; React and Svelte use `onClick`.
567
+
550
568
  Loads an image from `src` and draws it into the Canvas at the specified size. `objectFit` supports `contain` (default), `cover`, `fill`, `none`, and `scale-down`; `onError(error)` fires on load failure. Angular uses the `(imageError)` event binding for the error callback.
551
569
 
552
570
  | Prop | Type | Required | Default | Description |
@@ -555,6 +573,7 @@ Loads an image from `src` and draws it into the Canvas at the specified size. `o
555
573
  | `width` / `height` | `number` | Yes | — | Canvas logical size. |
556
574
  | `objectFit` | `"contain" \| "cover" \| "fill" \| "none" \| "scale-down"` | No | `"contain"` | Image scaling and cropping mode. |
557
575
  | `onError` | `(error: Error) => void` | No | — | Fires when the image fails to load. |
576
+ | `onClick` | `() => void` | No | — | Click callback. |
558
577
 
559
578
  ```tsx
560
579
  <Image x={16} y={16} src="/avatar.png" width={96} height={96} objectFit="cover" />
@@ -562,6 +581,39 @@ Loads an image from `src` and draws it into the Canvas at the specified size. `o
562
581
 
563
582
  Remote images draw correctly, but browser CORS rules still apply to Canvas export: if the image server does not authorize cross-origin reads, a Canvas containing that image may fail to export as PNG.
564
583
 
584
+ ### `<Video>`
585
+
586
+ Loads a video from `src` and paints its frames into the Canvas through the engine's render loop — no extra animation loop is created. Nodes sharing the same `src` reuse one pooled `<video>` element (a single decode pipeline), which is released automatically once no node references it. `objectFit` supports the same modes as `<Image>`.
587
+
588
+ | Prop | Type | Required | Default | Description |
589
+ | ------------------ | ---------------------------------------------------------- | -------: | -------------- | ------------------------------------------------------------------------------------------- |
590
+ | `src` | `string` | Yes | — | Video URL. |
591
+ | `width` / `height` | `number` | No | Video's native | Canvas logical size; defaults to the video's intrinsic size. |
592
+ | `objectFit` | `"contain" \| "cover" \| "fill" \| "none" \| "scale-down"` | No | `"contain"` | Video scaling and cropping mode, identical to `<Image>`. |
593
+ | `autoplay` | `boolean` | No | `false` | Start playback automatically; browsers require `muted` for autoplay to succeed. |
594
+ | `loop` | `boolean` | No | `false` | Restart from the beginning when playback ends. |
595
+ | `muted` | `boolean` | No | `false` | Mute the audio track. |
596
+ | `paused` | `boolean` | No | — | Declarative play/pause: `false` plays, `true` pauses; omitted leaves control to `autoplay`. |
597
+ | `currentTime` | `number` | No | — | Seek target in seconds; set it once to jump, not on every frame. |
598
+ | `onError` | `(error: Error) => void` | No | — | Fires when the video fails to load. |
599
+ | `onTimeUpdate` | `(currentTime: number, duration: number) => void` | No | — | Fires on playback progress, driven by the video's native `timeupdate` event. |
600
+
601
+ ```tsx
602
+ <Video
603
+ x={16}
604
+ y={16}
605
+ src="/clip.mp4"
606
+ width={320}
607
+ height={180}
608
+ objectFit="cover"
609
+ muted
610
+ autoplay
611
+ loop
612
+ />
613
+ ```
614
+
615
+ Browser autoplay policies apply: without `muted`, playback only starts after a user gesture. Videos are first loaded with CORS; on failure, loading is retried without CORS, although the browser may still report the initial error in its console. A cross-origin video loaded without CORS can play, but drawing it taints the Canvas and prevents pixel reads and PNG export. For export, use a same-origin video or configure the video server to return an `Access-Control-Allow-Origin` header permitting the current site. Angular uses `<canvas-video>`, with `(videoError)` and `(timeUpdate)` event bindings.
616
+
565
617
  ### `<Progress>`
566
618
 
567
619
  Draws a non-interactive progress bar. `value` is clamped between `min` and `max`.
@@ -589,6 +641,8 @@ Draws a non-interactive progress bar. `value` is clamped between `min` and `max`
589
641
  | `Carousel` | `transitionDuration` | `number` | `450` | Horizontal slide transition duration in ms; set `0` to switch instantly. |
590
642
  | `Carousel` | `loop` | `boolean` | `true` | Whether to loop back to the first item at the end. |
591
643
  | `Carousel` | `showArrows` / `showDots` | `boolean` | `true` | Whether to show the prev/next arrows and bottom indicator dots. |
644
+ | `Carousel` | `backgroundColor` | `string` | `"transparent"` | Viewport background color. |
645
+ | `Carousel` | `arrowColor` / `dotColor` / `activeDotColor` | `string` | theme / `"#fff"` / `"rgba(255,255,255,0.65)"` / `"#1677ff"` | Arrow, inactive dot and active dot colors; the listed colors are fallbacks. |
592
646
  | `Carousel` | `onChange` | `(index: number) => void` | — | Fires when the active index changes. |
593
647
  | `CarouselItem` | Children | Canvas UI components | — | Content shown for this slide. |
594
648
 
@@ -618,19 +672,16 @@ Angular uses `<canvas-carousel>` and `<canvas-carousel-item>`; controlled index
618
672
  | `Tabs` | `onChange` | `(key: string) => void` | Fires when the selected tab changes. |
619
673
  | `TabItem` | `id` / `title` | `string` | Unique identifier and label; required. |
620
674
  | `TabItem` | `disabled` | `boolean` | Disables clicking on this tab. |
675
+ | `TabItem` | `size` | `{ width?: number; height?: number }` | Optional in the public type; currently does not determine the header or content area size. |
621
676
  | `TabItem` | Children | Canvas UI components | Canvas content for this tab. |
622
677
 
623
678
  ```tsx
624
679
  <Tabs width={320} height={180} defaultActiveKey="profile">
625
680
  <TabItem id="profile" title="Profile">
626
- <Text x={12} y={12}>
627
- Profile content
628
- </Text>
681
+ <Text x={12} y={12} text="Profile content" />
629
682
  </TabItem>
630
683
  <TabItem id="settings" title="Settings">
631
- <Text x={12} y={12}>
632
- Settings content
633
- </Text>
684
+ <Text x={12} y={12} text="Settings content" />
634
685
  </TabItem>
635
686
  </Tabs>
636
687
  ```
@@ -657,14 +708,10 @@ Each `CollapseItem` header toggles its panel; children serve as panel content.
657
708
  ```tsx
658
709
  <Collapse width={320} defaultActiveKeys={['details']} accordion>
659
710
  <CollapseItem id="details" title="Details" height={72}>
660
- <Text x={12} y={8}>
661
- Panel content
662
- </Text>
711
+ <Text x={12} y={8} text="Panel content" />
663
712
  </CollapseItem>
664
713
  <CollapseItem id="more" title="More">
665
- <Text x={12} y={8}>
666
- Another panel
667
- </Text>
714
+ <Text x={12} y={8} text="Another panel" />
668
715
  </CollapseItem>
669
716
  </Collapse>
670
717
  ```
@@ -695,7 +742,7 @@ The confirmation dialog overlays the Canvas centered by default, painting a mask
695
742
  }}
696
743
  onCancel={() => setOpen(false)}
697
744
  >
698
- <Text width={340}>This action cannot be undone.</Text>
745
+ <Text width={340} text="This action cannot be undone." />
699
746
  </Dialog>
700
747
  ```
701
748
 
@@ -709,7 +756,7 @@ Draws a rectangle. Supports [Common Props](#common-props).
709
756
  | ------------- | -------- | --------------: | -------------------------------------- |
710
757
  | `width` | `number` | `100` | Width. |
711
758
  | `height` | `number` | `40` | Height. |
712
- | `color` | `string` | `"transparent"` | Fill color. |
759
+ | `color` | `string` | theme / `"transparent"` | Fill color. |
713
760
  | `radius` | `number` | `0` | Corner radius. |
714
761
  | `stroke` | `string` | — | Stroke color; omitted means no stroke. |
715
762
  | `strokeWidth` | `number` | `1` | Stroke width. |
@@ -721,25 +768,25 @@ Draws a circle. Supports [Common Props](#common-props).
721
768
  | Prop | Type | Default | Description |
722
769
  | ------------- | -------- | ----------: | -------------------------------------- |
723
770
  | `radius` | `number` | `10` | Circle radius. |
724
- | `color` | `string` | `"#e74c3c"` | Fill color. |
771
+ | `color` | `string` | theme / `"#e74c3c"` | Fill color. |
725
772
  | `stroke` | `string` | — | Stroke color; omitted means no stroke. |
726
773
  | `strokeWidth` | `number` | `1` | Stroke width. |
727
774
 
728
775
  ### `<Text>`
729
776
 
730
- Draws single-line or auto-wrapped text. The node reports the box its rendered lines actually need, so containers such as `<CollapseItem>` can size themselves to it. Supports [Common Props](#common-props).
777
+ Draws single-line or auto-wrapped text. Pass content through `text`; `<Text>` does not accept children. Other non-container components also reject child components; `<Button>` accepts plain text children only. The node reports the box its rendered lines actually need, so containers such as `<CollapseItem>` can size themselves to it. Supports [Common Props](#common-props).
731
778
 
732
779
  | Prop | Type | Default | Description |
733
780
  | ------------ | ------------------------------- | -------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
734
781
  | `text` | `string` | — | Text content. |
735
- | Children | `string \| number` | — | Each framework can supply text via native template children in place of `text`. |
736
782
  | `fontSize` | `number` | `16` | Font size, in logical pixels. |
737
783
  | `width` | `number` | — | Max line width; content wraps beyond it. Monospaced CJK characters also wrap based on measured width. Inside a `<Grid>`, defaults to the cell's width. |
738
784
  | `maxLines` | `number` | — | Maximum lines to show; the last visible line is cut with an ellipsis. Inside a `<Grid>`, defaults to the lines that fit the cell; unlimited when neither is set. |
739
785
  | `fontFamily` | `string` | `"sans-serif"` | Font family. |
740
- | `color` | `string` | `"#333"` | Font color. |
786
+ | `color` | `string` | theme / `"#333"` | Font color. |
741
787
  | `baseline` | `CanvasTextBaseline` | `"top"` | Canvas text baseline. |
742
- | `textAlign` | `"left" \| "center" \| "right"` | `"left"` | Horizontal text alignment; when `width` is set, alignment is relative to the text box. |
788
+ | `textAlign` | `CanvasTextAlign` | `"left"` | Horizontal alignment within the text box; only `center` and `right` are special, other values render as `left`. |
789
+ | `onClick` | `() => void` | — | Click callback. |
743
790
 
744
791
  ### `<Icon>`
745
792
 
@@ -749,9 +796,10 @@ Original vector icons with no dependency on icon fonts or external images. Suppo
749
796
  | ------------- | ---------------------- | ----------: | ---------------------------------------------------------------------------------------- |
750
797
  | `name` | `IconName` | Required | Icon name; see the list below. |
751
798
  | `size` | `number` | `24` | Icon width and height. |
752
- | `color` | `string` | `"#333"` | Icon color; can be set via `--canvas-ui-icon-color`. |
799
+ | `color` | `string` | theme / `"#333"` | Icon color; can be set via `--canvas-ui-icon-color`. |
753
800
  | `variant` | `"outline" \| "solid"` | `"outline"` | `outline` for stroked shapes; `solid` uses thicker strokes and fills the primary shapes. |
754
801
  | `strokeWidth` | `number` | `2` | Outline stroke width; solid style uses at least `4`. |
802
+ | `onClick` | `() => void` | — | Click callback. |
755
803
 
756
804
  Supported: `home`, `house`, `building`, `apartment`, `store`, `mapPin`, `map`, `globe`, `compass`, `navigation`, `flag`, `mountain`, `tree`, `leaf`, `flower`, `sun`, `moon`, `cloud`, `rain`, `snow`, `fire`, `water`, `wind`, `car`, `bus`, `train`, `plane`, `bicycle`, `ship`, `rocket`, `truck`, `walk`, `phone`, `message`, `mail`, `bell`, `calendar`, `clock`, `alarm`, `camera`, `image`, `video`, `music`, `microphone`, `headphones`, `play`, `pause`, `stop`, `record`, `volume`, `wifi`, `bluetooth`, `battery`, `signal`, `power`, `monitor`, `laptop`, `tablet`, `keyboard`, `mouse`, `printer`, `folder`, `file`, `document`, `download`, `upload`, `share`, `link`, `search`, `settings`, `sliders`, `menu`, `close`, `check`, `plus`, `minus`, `edit`, `trash`, `copy`, `save`, `lock`, `unlock`, `key`, `user`, `users`, `heart`, `star`, `bookmark`, `cart`, `bag`, `gift`, `creditCard`, `wallet`, `chart`, `pieChart`, `barChart`, `analytics`, `shield`, `warning`, `info`, `help`, `question`, `tag`, `puzzle`, `code`, `database`, and `cloudDownload`.
757
805
 
@@ -773,10 +821,10 @@ Single-line input. The control's appearance is painted onto the Canvas; a transp
773
821
  | `type` | `"text" \| "password" \| "number"` | `"text"` | Input type. Password content is shown as dots on the Canvas. |
774
822
  | `fontSize` | `number` | `14` | Font size. |
775
823
  | `fontFamily` | `string` | `"sans-serif"` | Font family. |
776
- | `color` | `string` | `"#333"` | Input text color. |
777
- | `bgColor` | `string` | `"#fff"` | Background color. |
778
- | `borderColor` | `string` | `"#ccc"` | Normal border color. |
779
- | `focusBorderColor` | `string` | `"#3498db"` | Focused border color. |
824
+ | `color` | `string` | theme / `"#333"` | Input text color. |
825
+ | `bgColor` | `string` | theme / `"#fff"` | Background color. |
826
+ | `borderColor` | `string` | theme / `"#d9d9d9"` | Normal border color. |
827
+ | `focusBorderColor` | `string` | theme / `"#1677ff"` | Focused border color. |
780
828
  | `borderRadius` | `number` | `4` | Corner radius. |
781
829
  | `padding` | `number` | `8` | Text padding. |
782
830
  | `disabled` | `boolean` | `false` | Disables input. |
@@ -805,17 +853,22 @@ Multi-line text input; inherits value, size, style, and callback props from `<In
805
853
 
806
854
  ### `<Upload>`
807
855
 
808
- Draws a file-picker button. A built-in vector icon and the label are drawn together as one horizontally centered group. Clicking opens the browser's native file picker; this component does not upload to a server.
856
+ Draws a file-picker button. A built-in vector icon and the label are drawn together as one horizontally centered group. Clicking opens the browser's native file picker; this component does not upload to a server. Supports [Common Props](#common-props).
809
857
 
810
858
  | Prop | Type | Default | Description |
811
859
  | ------------------ | ------------------------- | ---------------: | -------------------------------------------------------------------------- |
812
860
  | `width` / `height` | `number` | `120` / `40` | Button size. |
813
861
  | `text` | `string` | `"Choose File"` | Button label. |
814
862
  | `icon` | `IconName` | `"upload"` | Built-in icon drawn before the label; use any name from [`<Icon>`](#icon). |
815
- | `iconSize` | `number` | `fontSize × 1.1` | Icon size. |
863
+ | `iconSize` | `number` | `round(fontSize × 1.1)` | Icon size. |
816
864
  | `accept` | `string` | — | File type filter, e.g. `"image/*,.pdf"`. |
817
865
  | `multiple` | `boolean` | `false` | Allow multi-selection. |
818
866
  | `disabled` | `boolean` | `false` | Disables file selection. |
867
+ | `backgroundColor` | `string` | theme / `"#1677ff"` | Button background color. |
868
+ | `textColor` | `string` | theme / `"#fff"` | Label and icon color. |
869
+ | `borderColor` | `string` | — | Border color; omitted means no border. |
870
+ | `borderRadius` | `number` | `6` | Corner radius. |
871
+ | `fontSize` | `number` | `15` | Label font size. |
819
872
  | `onChange` | `(files: File[]) => void` | — | Fires after files are selected; canceled picks do not fire. |
820
873
 
821
874
  ```tsx
@@ -838,10 +891,10 @@ Canvas-drawn dropdown select. Supports [Common Props](#common-props).
838
891
  | `placeholder` | `string` | `"Select..."` | Text shown when nothing is selected. |
839
892
  | `disabled` | `boolean` | `false` | Disables interaction. |
840
893
  | `fontSize` | `number` | `14` | Font size. |
841
- | `color` | `string` | `"#333"` | Text color. |
842
- | `bgColor` | `string` | `"#fff"` | Control background. |
843
- | `borderColor` | `string` | `"#c7ccd3"` | Normal border color. |
844
- | `focusBorderColor` | `string` | `"#3478f6"` | Opened border color. |
894
+ | `color` | `string` | theme / `"#333"` | Text color; the arrow fallback is `"#555"`. |
895
+ | `bgColor` | `string` | theme / `"#fff"` | Control background. |
896
+ | `borderColor` | `string` | theme / `"#d9d9d9"` | Normal border color. |
897
+ | `focusBorderColor` | `string` | theme / `"#1677ff"` | Opened border color. |
845
898
  | `borderRadius` | `number` | `4` | Corner radius. |
846
899
  | `onChange` | `(value: string) => void` | — | Selection change callback. |
847
900
 
@@ -872,7 +925,13 @@ Canvas-drawn date input; clicking opens the browser's native date picker.
872
925
  | `defaultValue` | `string` | `""` | Uncontrolled initial date value. |
873
926
  | `placeholder` | `string` | `"Select date"` | Text shown when nothing is selected. |
874
927
  | `disabled` | `boolean` | `false` | Disables date selection. |
928
+ | `fontSize` | `number` | `14` | Text font size. |
929
+ | `color` | `string` | theme / `"#333"` | Date text color; icon fallback is `"#666"`. |
930
+ | `bgColor` | `string` | theme / `"#fff"` | Background color. |
931
+ | `borderColor` / `focusBorderColor` | `string` | theme / `"#d9d9d9"` / `"#1677ff"` | Normal and focused border colors; listed colors are fallbacks. |
932
+ | `borderRadius` | `number` | `4` | Corner radius. |
875
933
  | `onChange` | `(value: string) => void` | — | Fires when the date changes. |
934
+ | `onFocus` / `onBlur` | `() => void` | — | Called when focus is gained / lost. |
876
935
 
877
936
  ### `<Radio>` and `<Checkbox>`
878
937
 
@@ -885,6 +944,11 @@ Both accept an `options` array; Radio is single-select and Checkbox is multi-sel
885
944
  | `defaultValue` | Radio: `string`; Checkbox: `string[]` | — | Uncontrolled initial value. |
886
945
  | `direction` | `"horizontal" \| "vertical"` | `"horizontal"` | Option layout direction. |
887
946
  | `width` / `height` | `number` | Auto | Control size. |
947
+ | `size` | `{ width?: number; height?: number }` | — | Each dimension takes precedence over `width` / `height`. |
948
+ | `disabled` | `boolean` | `false` | Disables the whole group. |
949
+ | `gap` / `optionHeight` | `number` | `12` / `28` | Spacing between options and option height. |
950
+ | `fontSize` | `number` | `14` | Option label font size. |
951
+ | `color` / `activeColor` / `disabledColor` / `borderColor` | `string` | theme / `"#333"` / `"#1677ff"` / `"#bfbfbf"` / `"#d9d9d9"` | Label, selected, disabled option and border colors; listed colors are fallbacks. |
888
952
  | `onChange` | Radio: `(value: string) => void`; Checkbox: `(value: string[]) => void` | — | Fires when the selection changes. |
889
953
 
890
954
  ```tsx
@@ -906,9 +970,9 @@ Draggable slider. Supports [Common Props](#common-props).
906
970
  | `value` | `number` | — | Controlled value. |
907
971
  | `defaultValue` | `number` | `min` | Uncontrolled initial value. |
908
972
  | `disabled` | `boolean` | `false` | Disables dragging. |
909
- | `trackColor` | `string` | `"#d7dde5"` | Track color. |
910
- | `activeColor` | `string` | `"#3478f6"` | Filled track and border color. |
911
- | `thumbColor` | `string` | `"#fff"` | Thumb color. |
973
+ | `trackColor` | `string` | theme / `"#f0f0f0"` | Track color. |
974
+ | `activeColor` | `string` | theme / `"#1677ff"` | Filled track and border color. |
975
+ | `thumbColor` | `string` | theme / `"#fff"` | Thumb color. |
912
976
  | `onChange` | `(value: number) => void` | — | Fires when the value changes. |
913
977
 
914
978
  ### `<Switch>`
@@ -921,9 +985,9 @@ Toggle switch. Supports [Common Props](#common-props).
921
985
  | `checked` | `boolean` | — | Controlled checked state. |
922
986
  | `defaultChecked` | `boolean` | `false` | Uncontrolled initial state. |
923
987
  | `disabled` | `boolean` | `false` | Blocks toggling. |
924
- | `onColor` | `string` | `"#3478f6"` | Track color when on. |
925
- | `offColor` | `string` | `"#c7ccd3"` | Track color when off. |
926
- | `thumbColor` | `string` | `"#fff"` | Thumb color. |
988
+ | `onColor` | `string` | theme / `"#1677ff"` | Track color when on. |
989
+ | `offColor` | `string` | theme / `"#d9d9d9"` | Track color when off. |
990
+ | `thumbColor` | `string` | theme / `"#fff"` | Thumb color. |
927
991
  | `onChange` | `(checked: boolean) => void` | — | Fires when the state changes. |
928
992
 
929
993
  ### `<Button>`
@@ -936,8 +1000,8 @@ Canvas-drawn button. Supports [Common Props](#common-props).
936
1000
  | Children | `string \| number` | — | Button label; can be replaced by `text`. |
937
1001
  | `text` | `string` | — | Button label; wins over `children` when both are provided. |
938
1002
  | `fontSize` | `number` | `15` | Font size. |
939
- | `fontColor` | `string` | `"#fff"` | Text color. |
940
- | `backgroundColor` | `string` | `"#3478f6"` | Background color. |
1003
+ | `fontColor` | `string` | theme / `"#fff"` | Text color. |
1004
+ | `backgroundColor` | `string` | theme / `"#1677ff"` | Background color. |
941
1005
  | `borderColor` | `string` | — | Stroke color. |
942
1006
  | `borderRadius` | `number` | `6` | Corner radius. |
943
1007
  | `disabled` | `boolean` | `false` | Disables the button. |
@@ -987,3 +1051,35 @@ const jpegBlob = await canvasRef.current?.toBlob('image/jpeg', 0.9);
987
1051
  ```
988
1052
 
989
1053
  Export size and pixel ratio must be positive numbers. If the scene contains a cross-origin image without server-side CORS authorization, `toDataURL()` throws an error explaining the reason and `toBlob()` rejects with the same error. Configure the image server to return an `Access-Control-Allow-Origin` header that permits the current site, or remove the image before exporting.
1054
+
1055
+ ## File Structure
1056
+
1057
+ Paths below are relative to `src/canvas-ui/`.
1058
+
1059
+ | File | Purpose |
1060
+ | ---- | ------- |
1061
+ | `react/` | React components and Canvas container adapter. |
1062
+ | `vue/` | Vue 3 components and Canvas container adapter. |
1063
+ | `svelte/` | Svelte 5+ adapter and template components. |
1064
+ | `angular/` | Angular standalone Canvas component and scene directives. |
1065
+ | `components/` | Shared implementations, each with its own directory, entry, Props and drawing code, and optional interaction logic. |
1066
+ | `components/types.ts` | Aggregates public component Props types. |
1067
+ | `theme.css` | Light and dark CSS theme variables for Canvas components. |
1068
+ | `types.ts` | Component Props, scene, Canvas, and input-bridge types. |
1069
+ | `renderer.ts` | Drawing registration, scene traversal, and Canvas rendering. |
1070
+ | `scene.ts` | Scene nodes and child reconciliation. |
1071
+ | `input-bridge.ts` | Transparent HTML input bridge for Input and Textarea. |
1072
+ | `engine.ts` | Orchestrates scene updates, rendering, input, and interaction. |
1073
+ | `engine/transform.ts` | Pure matrix math. |
1074
+ | `engine/interaction.ts` | Pointer and wheel interactions and state changes. |
1075
+ | `engine/layout.ts` | Declarative tree preparation and layout. |
1076
+ | `engine/carousel.ts` | Carousel state and animation timing. |
1077
+ | `engine/images.ts` | Image subscription lifecycle. |
1078
+ | `engine/text-controls.ts` | DOM input bridge synchronization. |
1079
+ | `engine/events.ts` | Public and CanvasView event dispatch. |
1080
+ | `engine/hit-test.ts` | Coordinate resolution and hit testing. |
1081
+ | `engine/vnodes.ts` | VNode tree and Grid layout helpers. |
1082
+ | `engine/nodes.ts` | SceneNode predicates and derived values. |
1083
+ | `engine/state.ts` | Internal types, EngineCore interface, and EngineState container. |
1084
+
1085
+ For appearance changes, edit the drawing function in `components/<Component>/<component>.ts`; place component-specific interaction logic in `logic.ts` in the same directory. For shared layout, event, or export behavior, edit the relevant adapter, `engine.ts`, or `renderer.ts`.