react-native-live-widgets 1.1.1 → 1.2.1

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 (58) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +113 -10
  3. package/android/src/main/java/com/reactnativeliveactivity/bridge/LiveActivityModule.kt +5 -1
  4. package/android/src/main/java/com/reactnativeliveactivity/renderer/DynamicWidgetCanvasRenderer.kt +443 -46
  5. package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetStateStore.kt +86 -24
  6. package/android/src/main/java/com/reactnativeliveactivity/widgets/DynamicHomeScreenWidgetProvider.kt +126 -56
  7. package/android/src/main/res/layout/rn_live_widget_hit_zone.xml +16 -0
  8. package/android/src/main/res/layout/rn_live_widget_host.xml +16 -87
  9. package/docs/GUIDE-EN.md +332 -7
  10. package/docs/GUIDE-VI.md +357 -7
  11. package/docs/index.html +1143 -227
  12. package/docs/llms-full.txt +46 -6
  13. package/docs/llms.txt +37 -7
  14. package/ios/Models/DynamicLayoutModels.swift +11 -1
  15. package/ios/Renderer/DynamicNodeView.swift +169 -14
  16. package/ios/Widgets/DynamicHomeScreenWidget.swift +7 -3
  17. package/lib/builder.d.ts.map +1 -1
  18. package/lib/builder.js +92 -28
  19. package/lib/builder.js.map +1 -1
  20. package/lib/dispatcher.d.ts +7 -0
  21. package/lib/dispatcher.d.ts.map +1 -1
  22. package/lib/dispatcher.js +23 -6
  23. package/lib/dispatcher.js.map +1 -1
  24. package/lib/hooks.d.ts +66 -0
  25. package/lib/hooks.d.ts.map +1 -0
  26. package/lib/hooks.js +171 -0
  27. package/lib/hooks.js.map +1 -0
  28. package/lib/index.d.ts +48 -8
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +216 -35
  31. package/lib/index.js.map +1 -1
  32. package/lib/ir.d.ts +15 -0
  33. package/lib/ir.d.ts.map +1 -0
  34. package/lib/ir.js +379 -0
  35. package/lib/ir.js.map +1 -0
  36. package/lib/jsx.d.ts +87 -0
  37. package/lib/jsx.d.ts.map +1 -0
  38. package/lib/jsx.js +243 -0
  39. package/lib/jsx.js.map +1 -0
  40. package/lib/preview.d.ts +31 -0
  41. package/lib/preview.d.ts.map +1 -0
  42. package/lib/preview.js +735 -0
  43. package/lib/preview.js.map +1 -0
  44. package/lib/types.d.ts +212 -12
  45. package/lib/types.d.ts.map +1 -1
  46. package/lib/types.js +2 -1
  47. package/lib/types.js.map +1 -1
  48. package/package.json +3 -1
  49. package/src/builder.ts +86 -21
  50. package/src/dispatcher.ts +17 -0
  51. package/src/hooks.ts +223 -0
  52. package/src/index.ts +202 -13
  53. package/src/ir.ts +430 -0
  54. package/src/jsx.tsx +326 -0
  55. package/src/preview.tsx +1043 -0
  56. package/src/react-ambient.d.ts +10 -0
  57. package/src/react-native-env.d.ts +44 -0
  58. package/src/types.ts +261 -13
@@ -0,0 +1,10 @@
1
+ declare namespace React {
2
+ type ReactNode = any;
3
+ type ReactElement<P = any, T = any> = {
4
+ type: T;
5
+ props: P;
6
+ key: any;
7
+ };
8
+ type FC<P = {}> = ((props: P) => any) & { displayName?: string };
9
+ type ComponentType<P = {}> = any;
10
+ }
@@ -1,7 +1,34 @@
1
+ // Ambient declaration for react module imports
2
+ declare module 'react' {
3
+ export type ReactNode = any;
4
+ export type ReactElement<P = any, T = any> = {
5
+ type: T;
6
+ props: P;
7
+ key: any;
8
+ };
9
+ export type FC<P = {}> = ((props: P) => any) & { displayName?: string };
10
+ export function useState<T>(initialState: T | (() => T)): [T, (val: T | ((prev: T) => T)) => void];
11
+ export function useEffect(effect: () => void | (() => void), deps?: readonly any[]): void;
12
+ export function useRef<T>(initialValue: T): { current: T };
13
+ export function useCallback<T extends (...args: any[]) => any>(callback: T, deps: readonly any[]): T;
14
+ export function isValidElement(object: any): boolean;
15
+ export const Children: {
16
+ forEach(children: any, fn: (child: any, index: number) => void): void;
17
+ map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): T[];
18
+ count(children: any): number;
19
+ only<C>(children: C): C;
20
+ toArray(children: any): any[];
21
+ };
22
+ export const Fragment: any;
23
+ const React: any;
24
+ export default React;
25
+ }
26
+
1
27
  // Ambient declaration for react-native to ensure compile safety across all environments
2
28
  declare module 'react-native' {
3
29
  export interface PlatformOSType {
4
30
  OS: 'ios' | 'android' | 'windows' | 'macos' | 'web';
31
+ Version: string | number;
5
32
  select<T>(specifics: { [platform in 'ios' | 'android' | 'default']?: T }): T;
6
33
  }
7
34
  export const Platform: PlatformOSType;
@@ -26,4 +53,21 @@ declare module 'react-native' {
26
53
  registerHeadlessTask(taskKey: string, task: () => (taskData: any) => Promise<void>): void;
27
54
  }
28
55
  export const AppRegistry: AppRegistry;
56
+
57
+ export type ViewStyle = Record<string, any>;
58
+ export type TextStyle = Record<string, any>;
59
+ export type ImageStyle = Record<string, any>;
60
+
61
+ export const View: any;
62
+ export const Text: any;
63
+ export const Image: any;
64
+ export const TouchableOpacity: any;
65
+ export const StyleSheet: {
66
+ create<T extends Record<string, any>>(styles: T): T;
67
+ [key: string]: any;
68
+ };
69
+ export const Dimensions: {
70
+ get(dim: 'window' | 'screen'): { width: number; height: number; scale: number; fontScale: number };
71
+ [key: string]: any;
72
+ };
29
73
  }
package/src/types.ts CHANGED
@@ -27,26 +27,142 @@ export type LayoutNodeType =
27
27
  | 'Custom';
28
28
 
29
29
  /**
30
- * Định dạng màu hỗ trợ chuỗi Hex đơn (ví dụ '#0F172A')
31
- * hoặc Object Dynamic Color tự đổi theo chế độ Sáng / Tối (Dark Mode) của hệ điều hành.
30
+ * Định dạng màu hỗ trợ:
31
+ * - Chuỗi Hex đơn (ví dụ '#0F172A', '#38BDF8AA')
32
+ * - Object Dynamic Color tự đổi theo chế độ Sáng / Tối (Light / Dark Mode)
33
+ * - Chế độ Tinted / Accented trên iOS 18+ và Material You Android.
32
34
  */
33
- export type DynamicColor = string | { light: string; dark: string };
35
+ export type DynamicColor =
36
+ | string
37
+ | {
38
+ light: string;
39
+ dark: string;
40
+ /** Màu hiển thị ở chế độ Tinted Home Screen trên iOS 18+ hoặc Material You Dynamic Theming Android */
41
+ tinted?: string;
42
+ };
43
+
44
+ export type BorderStyle = 'solid' | 'dashed' | 'dotted';
45
+
46
+ /** Cấu hình đổ bóng (Shadow Modifier) cho Card, Button và Container */
47
+ export interface ShadowProps {
48
+ /** Màu bóng đổ (hỗ trợ DynamicColor) */
49
+ shadowColor?: DynamicColor;
50
+ /** Bán kính mờ của bóng đổ (dp/pt) */
51
+ shadowRadius?: number;
52
+ /** Độ mờ đục từ 0.0 (trong suốt) đến 1.0 (đậm đặc) */
53
+ shadowOpacity?: number;
54
+ /** Độ dời vị trí bóng đổ theo trục X và Y */
55
+ shadowOffset?: { x: number; y: number };
56
+ }
57
+
58
+ /** Cấu hình dải màu chuyển sắc (Gradient Modifier) */
59
+ export interface GradientProps {
60
+ /** Kiểu chuyển sắc: 'linear' (đường thẳng - mặc định) hoặc 'radial' (tâm tròn) */
61
+ type?: 'linear' | 'radial';
62
+ /** Danh sách các màu chuyển tiếp (hỗ trợ DynamicColor cho từng chặng) */
63
+ colors: DynamicColor[];
64
+ /** Điểm bắt đầu theo toạ độ tỉ lệ từ 0.0 đến 1.0 (mặc định { x: 0, y: 0 } top-left) */
65
+ startPoint?: { x: number; y: number };
66
+ /** Điểm kết thúc theo toạ độ tỉ lệ từ 0.0 đến 1.0 (mặc định { x: 1, y: 1 } bottom-right) */
67
+ endPoint?: { x: number; y: number };
68
+ /** Góc gradient theo độ (ví dụ 45, 90, 180) */
69
+ angle?: number;
70
+ }
71
+
72
+ export type TypographyStyle =
73
+ | 'largeTitle'
74
+ | 'title1'
75
+ | 'title2'
76
+ | 'title3'
77
+ | 'headline'
78
+ | 'subheadline'
79
+ | 'body'
80
+ | 'callout'
81
+ | 'footnote'
82
+ | 'caption1'
83
+ | 'caption2';
84
+
85
+ export type FontDesign = 'default' | 'monospaced' | 'rounded' | 'serif';
86
+
87
+ /**
88
+ * ♿ Vai trò ngữ nghĩa cho Trợ năng (Accessibility Semantic Role).
89
+ * Giúp các công cụ đọc màn hình (TalkBack trên Android, VoiceOver trên iOS, Screen Readers)
90
+ * phát âm chính xác bản chất của phần tử thay vì coi tất cả là hình ảnh raster.
91
+ */
92
+ export type AccessibilityRole =
93
+ | 'none'
94
+ | 'button'
95
+ | 'header'
96
+ | 'text'
97
+ | 'image'
98
+ | 'progressbar'
99
+ | 'timer'
100
+ | 'switch'
101
+ | 'checkbox'
102
+ | 'summary'
103
+ | 'alert';
104
+
105
+ /**
106
+ * ♿ Thuộc tính Trợ năng (Accessibility & Semantics Layer).
107
+ * Tách biệt hoàn toàn tầng ngữ nghĩa khỏi tầng vẽ đồ họa (Canvas/SwiftUI),
108
+ * cho phép TalkBack và VoiceOver tiếp cận dữ liệu chính xác ngay cả khi render bằng Canvas.
109
+ */
110
+ export interface AccessibilityProps {
111
+ /** Cho phép công cụ trợ năng (TalkBack/VoiceOver) tiếp cận thành phần này (mặc định true; đặt false cho các icon/hình trang trí decorative) */
112
+ accessible?: boolean;
113
+ /** Mô tả âm thanh phát âm cho người dùng khi TalkBack/VoiceOver lướt tới phần tử */
114
+ accessibilityLabel?: string;
115
+ /** Hướng dẫn hành động bổ sung (ví dụ: "Chạm hai lần để xác nhận chấm công") */
116
+ accessibilityHint?: string;
117
+ /** Vai trò ngữ nghĩa của phần tử (header, button, progressbar, ...) */
118
+ accessibilityRole?: AccessibilityRole;
119
+ /** Giá trị trạng thái đọc lên (ví dụ: "86%", "Đang vận chuyển", "Đã bật") */
120
+ accessibilityValue?: string | number;
121
+ }
34
122
 
35
123
  export interface BaseNode {
36
124
  type: LayoutNodeType;
37
125
  }
38
126
 
39
- export interface ContainerProps {
127
+ export interface ContainerProps extends ShadowProps, AccessibilityProps {
40
128
  padding?: number;
41
129
  paddingHorizontal?: number;
42
130
  paddingVertical?: number;
43
131
  spacing?: number;
132
+ /** Khoảng cách giữa các phần tử con (Alias chuẩn React Native Style cho spacing) */
133
+ gap?: number;
134
+ rowGap?: number;
135
+ columnGap?: number;
44
136
  backgroundColor?: DynamicColor;
137
+ /** Gradient màu nền (tự động graceful fallback sang backgroundColor nếu platform không hỗ trợ) */
138
+ gradient?: GradientProps;
45
139
  borderRadius?: number;
140
+ /** Alias bo góc theo cú pháp SwiftUI (tự động ánh xạ sang borderRadius) */
141
+ cornerRadius?: number;
46
142
  borderColor?: DynamicColor;
47
143
  borderWidth?: number;
48
- alignment?: 'leading' | 'center' | 'trailing' | string;
49
- justifyContent?: 'flexStart' | 'center' | 'flexEnd' | 'spaceBetween' | string;
144
+ borderStyle?: BorderStyle;
145
+ alignment?:
146
+ | 'leading'
147
+ | 'center'
148
+ | 'trailing'
149
+ | 'top'
150
+ | 'bottom'
151
+ | 'firstTextBaseline'
152
+ | 'lastTextBaseline'
153
+ | string;
154
+ justifyContent?:
155
+ | 'flexStart'
156
+ | 'center'
157
+ | 'flexEnd'
158
+ | 'spaceBetween'
159
+ | 'spaceAround'
160
+ | 'spaceEvenly'
161
+ | string;
162
+ /** Chiều viết văn bản (Hỗ trợ quốc tế hoá RTL cho tiếng Ả Rập, Do Thái) */
163
+ direction?: 'ltr' | 'rtl' | 'auto';
164
+ /** Cờ bật RTL chủ động cho khối container này */
165
+ isRTL?: boolean;
50
166
  /** Tự động ẩn hoặc làm mờ nội dung khi thiết bị đang khóa màn hình (Bảo mật chuẩn Apple) */
51
167
  privacySensitive?: boolean;
52
168
  /** Chủ động che nội dung thành vệt khối mờ Placeholder (Skeleton Redaction) */
@@ -63,10 +179,19 @@ export type FontWeight =
63
179
  | (string & {})
64
180
  | string;
65
181
 
66
- export interface TextStyle {
182
+ export interface TextStyle extends ShadowProps, AccessibilityProps {
67
183
  color?: DynamicColor;
68
184
  fontSize?: number;
69
185
  fontWeight?: FontWeight;
186
+ /** Hệ thống phân cấp cỡ chữ chuẩn Apple Human Interface Guidelines / Material Design */
187
+ typography?: TypographyStyle;
188
+ /** Kiểu dáng họ font chữ hệ thống */
189
+ fontDesign?: FontDesign;
190
+ /** Tự động co giãn cỡ chữ theo cài đặt Trợ năng (Accessibility Dynamic Type) của hệ điều hành (mặc định true) */
191
+ dynamicType?: boolean;
192
+ textAlign?: 'left' | 'center' | 'right' | 'leading' | 'trailing' | 'auto';
193
+ lineHeight?: number;
194
+ letterSpacing?: number;
70
195
  numberOfLines?: number;
71
196
  strikethroughWhenToggled?: string;
72
197
  /** Tự động làm mờ hoặc ẩn chữ khi màn hình khóa (iOS Privacy Redacted) */
@@ -102,7 +227,7 @@ export interface TextNode extends BaseNode {
102
227
 
103
228
  export interface TimerNode extends BaseNode {
104
229
  type: 'Timer';
105
- props: {
230
+ props: AccessibilityProps & {
106
231
  /** Epoch timestamp tính bằng giây để đếm tới (hoặc đếm từ) */
107
232
  targetTimestamp: number;
108
233
  /** 'countdown': đếm ngược tới mốc; 'countup': đếm tiến từ mốc */
@@ -117,7 +242,7 @@ export interface TimerNode extends BaseNode {
117
242
 
118
243
  export interface ProgressNode extends BaseNode {
119
244
  type: 'Progress';
120
- props: {
245
+ props: AccessibilityProps & {
121
246
  // ── 1. Nguồn dữ liệu tiến trình ─────────────────────────────
122
247
  /** Mốc bắt đầu (epoch giây) nếu dùng timer interval tự chạy */
123
248
  startTimestamp?: number;
@@ -135,6 +260,7 @@ export interface ProgressNode extends BaseNode {
135
260
  height?: number;
136
261
  /** Bo góc thanh. Mặc định bo tròn hoàn toàn */
137
262
  borderRadius?: number;
263
+ cornerRadius?: number;
138
264
 
139
265
  // ── 3. Màu sắc & Gradient ───────────────────────────────────
140
266
  /** Màu thanh khi lấp đầy (dạng '#RRGGBB' hoặc { light, dark }) */
@@ -175,7 +301,7 @@ export interface ProgressNode extends BaseNode {
175
301
 
176
302
  export interface ImageNode extends BaseNode {
177
303
  type: 'Image';
178
- props: {
304
+ props: AccessibilityProps & {
179
305
  /** URL ảnh từ mạng (https://...) - Tự động tải, nén tối ưu RAM và cache vào App Group cho Widget & Live Activity */
180
306
  url?: string;
181
307
  /** Chuỗi ảnh Base64 (có thể kèm tiền tố data:image/png;base64,... hoặc chuỗi raw base64) */
@@ -197,6 +323,7 @@ export interface ImageNode extends BaseNode {
197
323
  padding?: number;
198
324
  /** Bo góc ảnh (đặt bằng width / 2 để tạo ảnh Avatar tròn) */
199
325
  borderRadius?: number;
326
+ cornerRadius?: number;
200
327
  /** Độ dày viền quanh ảnh (ví dụ viền Avatar) */
201
328
  borderWidth?: number;
202
329
  /** Màu viền quanh ảnh */
@@ -219,7 +346,7 @@ export interface SpacerNode extends BaseNode {
219
346
 
220
347
  export interface ButtonNode extends BaseNode {
221
348
  type: 'Button';
222
- props: {
349
+ props: ShadowProps & AccessibilityProps & {
223
350
  title: string;
224
351
  /**
225
352
  * Mã hành động chạy ngầm ngay trên Widget (iOS 17+ AppIntent, không mở App):
@@ -233,13 +360,21 @@ export interface ButtonNode extends BaseNode {
233
360
  /** Mở App và điều hướng tới URL Deep Link cụ thể */
234
361
  deepLink?: string;
235
362
  backgroundColor?: DynamicColor;
363
+ /** Gradient màu nền nút bấm */
364
+ gradient?: GradientProps;
236
365
  textColor?: DynamicColor;
237
366
  fontSize?: number;
238
367
  fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold';
368
+ typography?: TypographyStyle;
369
+ fontDesign?: FontDesign;
239
370
  padding?: number;
240
371
  paddingHorizontal?: number;
241
372
  paddingVertical?: number;
242
373
  borderRadius?: number;
374
+ cornerRadius?: number;
375
+ borderColor?: DynamicColor;
376
+ borderWidth?: number;
377
+ borderStyle?: BorderStyle;
243
378
  fullWidth?: boolean;
244
379
  /** Tiêu đề hiển thị khi nút ở trạng thái đã tick (dùng với actionId 'toggle:<key>') */
245
380
  checkedTitle?: string;
@@ -298,7 +433,7 @@ export interface DividerNode extends BaseNode {
298
433
 
299
434
  export interface GaugeNode extends BaseNode {
300
435
  type: 'Gauge';
301
- props: {
436
+ props: AccessibilityProps & {
302
437
  /** Giá trị tiến độ từ 0.0 đến 1.0 */
303
438
  value: number;
304
439
  /** Chuỗi hiển thị chính giữa đồng hồ (vd "85%", "120 km/h", "420") */
@@ -345,7 +480,7 @@ export interface ChartNode extends BaseNode {
345
480
 
346
481
  export interface ToggleNode extends BaseNode {
347
482
  type: 'Toggle';
348
- props: {
483
+ props: AccessibilityProps & {
349
484
  /** Mã định danh toggle (tự động gắn tiền tố 'toggle:' nếu chưa có) */
350
485
  actionId: string;
351
486
  label: string;
@@ -353,6 +488,7 @@ export interface ToggleNode extends BaseNode {
353
488
  /** 'checkbox' (ô tích) | 'switch' (công tắc gạt) */
354
489
  style?: 'checkbox' | 'switch';
355
490
  checked?: boolean;
491
+ isChecked?: boolean;
356
492
  tintColor?: string;
357
493
  textColor?: string;
358
494
  checkedTextColor?: string;
@@ -374,6 +510,7 @@ export interface BadgeNode extends BaseNode {
374
510
  paddingHorizontal?: number;
375
511
  paddingVertical?: number;
376
512
  borderRadius?: number;
513
+ cornerRadius?: number;
377
514
  };
378
515
  }
379
516
 
@@ -576,6 +713,8 @@ export interface WidgetRemoteConfig {
576
713
  headers?: Record<string, string>;
577
714
  /** Chu kỳ tự động gọi lại API tính bằng phút (mặc định 15 phút) */
578
715
  refreshIntervalMinutes?: number;
716
+ /** Alias ngắn gọn cho refreshIntervalMinutes */
717
+ intervalMinutes?: number;
579
718
  }
580
719
 
581
720
  export interface LiveActivityPushTokens {
@@ -593,3 +732,112 @@ export interface ActiveActivityInfo {
593
732
  activityId: string;
594
733
  pushToken?: string;
595
734
  }
735
+
736
+ /**
737
+ * 📊 Bảng tra cứu năng lực nền tảng (Platform Capability & Fallback Matrix).
738
+ * Cho phép ứng dụng kiểm tra tính năng được hỗ trợ thực tế trên thiết bị đang chạy
739
+ * thay vì phỏng đoán, đảm bảo UI hoạt động ổn định và graceful fallback mượt mà.
740
+ */
741
+ export interface WidgetCapabilities {
742
+ /** Nền tảng hệ điều hành ('ios' hoặc 'android') */
743
+ platform: 'ios' | 'android';
744
+ /** Phiên bản OS (ví dụ '18.1', '17.2', '14.0' Android API 34) */
745
+ osVersion: string | number;
746
+ /** Hỗ trợ Live Activities trên Lock Screen (iOS 16.1+ / Android 8.0+ Ongoing Notification) */
747
+ supportsLiveActivities: boolean;
748
+ /** Hỗ trợ Dynamic Island (iPhone 14 Pro, 15, 16 series) */
749
+ supportsDynamicIsland: boolean;
750
+ /** Hỗ trợ Android 16+ Live Update thông báo kiểu tiến trình ProgressStyle */
751
+ supportsAndroidLiveUpdates: boolean;
752
+ /** Hỗ trợ ghim tiện ích Home Screen Widgets (iOS 14+ / Android 8.0+) */
753
+ supportsHomeWidgets: boolean;
754
+ /** Hỗ trợ tương tác bấm nút chạy ngầm không mở app (iOS 17+ AppIntent / Android PendingIntent) */
755
+ supportsInteractiveIntents: boolean;
756
+ /** Hỗ trợ dải màu chuyển tiếp Linear / Radial Gradient */
757
+ supportsGradients: boolean;
758
+ /** Hỗ trợ bóng đổ Elevation / Shadow layer */
759
+ supportsShadows: boolean;
760
+ /** Hỗ trợ viền nét đứt Dashed / Dotted Stroke */
761
+ supportsDashedBorders: boolean;
762
+ /** Hỗ trợ tự động co giãn cỡ chữ theo Trợ năng (Accessibility Dynamic Type) */
763
+ supportsDynamicType: boolean;
764
+ /** Hỗ trợ bố cục quốc tế hoá từ phải sang trái (RTL: Arabic, Hebrew, ...) */
765
+ supportsRTL: boolean;
766
+ /** Hỗ trợ chế độ màu Tinted / Accented Widgets (iOS 18+ / Android Material You) */
767
+ supportsTintedMode: boolean;
768
+ /** Hỗ trợ hiệu ứng Odometer số lật (iOS 16+ numericText) */
769
+ supportsNumericAnimation: boolean;
770
+ /** Hỗ trợ lớp Trợ năng phân cấp (Accessibility Fallback Layer: VoiceOver & TalkBack contentDescription) */
771
+ supportsAccessibility: boolean;
772
+ }
773
+
774
+ // ─── 14. UI INTERMEDIATE REPRESENTATION (IR) & SEMANTIC TREE (Phase 2) ────────
775
+
776
+ /**
777
+ * Mục tiêu kết xuất của bộ điều phối Renderer Planner.
778
+ * - 'native_remote_view': Kết xuất thành RemoteViews native (TextView, Button, ProgressBar).
779
+ * - 'canvas_bitmap': Kết xuất qua Canvas 2D Bitmap (Gauge 240°, Equalizer, đồ họa phức tạp).
780
+ * - 'composite': Vùng chứa phức hợp kết hợp cả Native Views và Canvas sub-views.
781
+ */
782
+ export type RenderPlanTarget = 'native_remote_view' | 'canvas_bitmap' | 'composite';
783
+
784
+ /**
785
+ * Kế hoạch kết xuất cho từng Node trong cây UI.
786
+ */
787
+ export interface NodeRenderPlan {
788
+ id: string;
789
+ type: LayoutNodeType;
790
+ target: RenderPlanTarget;
791
+ reason: string;
792
+ hasNativeEquivalent: boolean;
793
+ requiresCanvas: boolean;
794
+ childrenTargets?: RenderPlanTarget[];
795
+ }
796
+
797
+ /**
798
+ * ♿ Nút ngữ nghĩa độc lập (Semantic Node) tách biệt hoàn toàn khỏi Renderer.
799
+ */
800
+ export interface SemanticNode {
801
+ id: string;
802
+ path: string;
803
+ type: LayoutNodeType;
804
+ role: AccessibilityRole;
805
+ label: string;
806
+ hint?: string;
807
+ value?: string | number;
808
+ interactive: boolean;
809
+ actionId?: string;
810
+ deepLink?: string;
811
+ isDecorative?: boolean;
812
+ }
813
+
814
+ /**
815
+ * Liên kết trạng thái hai chiều giữa UI và Native Store / JavaScript.
816
+ */
817
+ export interface StateBinding {
818
+ id: string;
819
+ actionId: string;
820
+ bindingType: 'toggle' | 'page' | 'custom';
821
+ targetKey?: string;
822
+ initialValue?: any;
823
+ }
824
+
825
+ /**
826
+ * 🌲 UI Intermediate Representation (Cây đại diện trung gian IR).
827
+ * Chuẩn hóa toàn bộ cấu trúc UI, Semantic Tree, Kế hoạch kết xuất (Render Plan)
828
+ * và Liên kết trạng thái (State Bindings) trước khi chuyển giao cho Renderer nền tảng.
829
+ */
830
+ export interface WidgetIR {
831
+ version: '2.0';
832
+ timestamp: number;
833
+ root: LayoutNode;
834
+ semanticTree: SemanticNode[];
835
+ semanticSummary: string;
836
+ renderPlan: {
837
+ overallStrategy: 'native_first_hybrid' | 'canvas_fallback';
838
+ nativeNodeCount: number;
839
+ canvasNodeCount: number;
840
+ nodes: Record<string, NodeRenderPlan>;
841
+ };
842
+ stateBindings: StateBinding[];
843
+ }