drawnui-react 0.1.0-preview.8 → 1.0.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 (117) hide show
  1. package/README.md +229 -22
  2. package/SKIPPED.md +38 -29
  3. package/dist/controls/AnimatedFramesRenderer.d.ts +9 -0
  4. package/dist/controls/AnimatedFramesRenderer.js +18 -1
  5. package/dist/controls/DrawnGame.d.ts +44 -0
  6. package/dist/controls/DrawnGame.js +82 -0
  7. package/dist/controls/GridStructure.d.ts +25 -3
  8. package/dist/controls/GridStructure.js +81 -5
  9. package/dist/controls/SkiaBackdrop.d.ts +8 -2
  10. package/dist/controls/SkiaBackdrop.js +42 -14
  11. package/dist/controls/SkiaButton.d.ts +17 -3
  12. package/dist/controls/SkiaButton.js +26 -8
  13. package/dist/controls/SkiaCarousel.d.ts +22 -3
  14. package/dist/controls/SkiaCarousel.js +85 -9
  15. package/dist/controls/SkiaCheckbox.d.ts +0 -1
  16. package/dist/controls/SkiaCheckbox.js +2 -7
  17. package/dist/controls/SkiaDrawer.d.ts +15 -0
  18. package/dist/controls/SkiaDrawer.js +42 -7
  19. package/dist/controls/SkiaEditor.d.ts +51 -2
  20. package/dist/controls/SkiaEditor.js +292 -58
  21. package/dist/controls/SkiaGif.d.ts +7 -0
  22. package/dist/controls/SkiaGif.js +25 -4
  23. package/dist/controls/SkiaImage.d.ts +10 -0
  24. package/dist/controls/SkiaImage.js +80 -19
  25. package/dist/controls/SkiaLabel.d.ts +200 -11
  26. package/dist/controls/SkiaLabel.js +925 -93
  27. package/dist/controls/SkiaLabelFps.d.ts +12 -0
  28. package/dist/controls/SkiaLabelFps.js +35 -0
  29. package/dist/controls/SkiaLayout.d.ts +89 -9
  30. package/dist/controls/SkiaLayout.js +397 -23
  31. package/dist/controls/SkiaLottie.js +5 -3
  32. package/dist/controls/SkiaProgress.d.ts +2 -1
  33. package/dist/controls/SkiaProgress.js +8 -5
  34. package/dist/controls/SkiaRadioButton.d.ts +2 -0
  35. package/dist/controls/SkiaRadioButton.js +16 -4
  36. package/dist/controls/SkiaRichLabel.d.ts +1 -1
  37. package/dist/controls/SkiaRichLabel.js +11 -1
  38. package/dist/controls/SkiaScroll.d.ts +86 -7
  39. package/dist/controls/SkiaScroll.js +361 -40
  40. package/dist/controls/SkiaScrollBar.d.ts +27 -0
  41. package/dist/controls/SkiaScrollBar.js +51 -2
  42. package/dist/controls/SkiaShaderCarousel.d.ts +11 -1
  43. package/dist/controls/SkiaShaderCarousel.js +27 -5
  44. package/dist/controls/SkiaShape.d.ts +15 -2
  45. package/dist/controls/SkiaShape.js +57 -10
  46. package/dist/controls/SkiaShell.d.ts +282 -0
  47. package/dist/controls/SkiaShell.js +972 -0
  48. package/dist/controls/SkiaSlider.d.ts +20 -2
  49. package/dist/controls/SkiaSlider.js +61 -7
  50. package/dist/controls/SkiaSprite.d.ts +4 -0
  51. package/dist/controls/SkiaSprite.js +27 -11
  52. package/dist/controls/SkiaSvg.d.ts +4 -0
  53. package/dist/controls/SkiaSvg.js +28 -4
  54. package/dist/controls/SkiaSwitch.d.ts +0 -1
  55. package/dist/controls/SkiaSwitch.js +4 -8
  56. package/dist/controls/SkiaToggle.d.ts +25 -5
  57. package/dist/controls/SkiaToggle.js +58 -5
  58. package/dist/controls/SnappingLayout.d.ts +12 -1
  59. package/dist/controls/SnappingLayout.js +21 -2
  60. package/dist/controls/TooltipStyle.d.ts +52 -0
  61. package/dist/controls/TooltipStyle.js +88 -0
  62. package/dist/core/Accessibility.d.ts +162 -11
  63. package/dist/core/Accessibility.js +882 -22
  64. package/dist/core/Animators.d.ts +37 -1
  65. package/dist/core/Animators.js +102 -9
  66. package/dist/core/Canvas.d.ts +307 -8
  67. package/dist/core/Canvas.js +1202 -66
  68. package/dist/core/ControlStyle.d.ts +2 -0
  69. package/dist/core/ControlStyle.js +2 -0
  70. package/dist/core/DesignerActions.d.ts +32 -0
  71. package/dist/core/DesignerActions.js +68 -0
  72. package/dist/core/Easing.d.ts +12 -1
  73. package/dist/core/Easing.js +25 -1
  74. package/dist/core/Gestures.d.ts +86 -2
  75. package/dist/core/Gestures.js +184 -4
  76. package/dist/core/Hover.d.ts +51 -0
  77. package/dist/core/Hover.js +140 -0
  78. package/dist/core/ImageEffects.d.ts +2 -0
  79. package/dist/core/ImageEffects.js +2 -0
  80. package/dist/core/KeyboardManager.d.ts +40 -0
  81. package/dist/core/KeyboardManager.js +98 -8
  82. package/dist/core/PopupWindows.d.ts +94 -0
  83. package/dist/core/PopupWindows.js +207 -0
  84. package/dist/core/Props.d.ts +11 -0
  85. package/dist/core/Props.js +44 -0
  86. package/dist/core/ScrollAnimators.d.ts +6 -0
  87. package/dist/core/ScrollAnimators.js +16 -1
  88. package/dist/core/Shaping.d.ts +40 -0
  89. package/dist/core/Shaping.js +224 -0
  90. package/dist/core/SkiaControl.d.ts +306 -13
  91. package/dist/core/SkiaControl.js +681 -75
  92. package/dist/core/SkiaEffect.d.ts +29 -1
  93. package/dist/core/SkiaEffect.js +78 -16
  94. package/dist/core/SkiaImageManager.d.ts +101 -18
  95. package/dist/core/SkiaImageManager.js +318 -63
  96. package/dist/core/Styles.js +7 -1
  97. package/dist/core/Super.d.ts +33 -2
  98. package/dist/core/Super.js +58 -12
  99. package/dist/core/TextInputProxy.d.ts +31 -1
  100. package/dist/core/TextInputProxy.js +97 -15
  101. package/dist/core/Tooltips.d.ts +71 -0
  102. package/dist/core/Tooltips.js +205 -0
  103. package/dist/core/Types.d.ts +11 -1
  104. package/dist/core/Types.js +32 -1
  105. package/dist/core/ViewsAdapter.d.ts +7 -2
  106. package/dist/core/ViewsAdapter.js +10 -3
  107. package/dist/index.d.ts +8 -0
  108. package/dist/index.js +8 -0
  109. package/dist/react/SkiaShell.d.ts +8 -74
  110. package/dist/react/SkiaShell.js +163 -475
  111. package/dist/react/index.d.ts +48 -4
  112. package/dist/react/index.js +210 -43
  113. package/dist/react/reconciler.d.ts +32 -0
  114. package/dist/react/reconciler.js +71 -40
  115. package/dist/vite/index.d.ts +9 -0
  116. package/dist/vite/index.js +36 -3
  117. package/package.json +103 -5
@@ -18,17 +18,43 @@ export declare class AnimatorBase {
18
18
  StartFrameTimeNanos: number;
19
19
  OnStart?: () => void;
20
20
  OnStop?: () => void;
21
+ /** Paused: the canvas does not tick it and it wakes no frames; Resume goes on from where it was (C# Pause / Resume). */
22
+ IsPaused: boolean;
23
+ /** Paused by the canvas because its control is hidden; resumed when it shows again. */
24
+ PausedWhileHidden: boolean;
25
+ /**
26
+ * Frame time (ns) before which nothing it shows changes: the canvas does not tick it and it keeps no frames coming
27
+ * until then, a timer wakes the frame loop at that time (a GIF or a sprite between two frames; DrawnUi.Rust frame
28
+ * animators sleep between changes). 0 = tick every frame.
29
+ */
30
+ SleepUntilNanos: number;
21
31
  private delayHandle;
32
+ private delayEnd;
33
+ private delayLeft;
34
+ private pausedAt;
22
35
  constructor(parent: SkiaControl);
23
36
  protected Register(): boolean;
24
37
  protected Unregister(): void;
25
38
  Start(delayMs?: number): void;
39
+ /** Freezes the run (and what is left of a start delay); Resume goes on from there. */
40
+ Pause(): void;
41
+ /** Goes on from where Pause froze it: the paused time is not counted. */
42
+ Resume(): void;
26
43
  Stop(): void;
27
44
  /** Returns true when there is nothing more to do (not running / finished). */
28
45
  TickFrame(frameTimeNanos: number): boolean;
29
46
  Dispose(): void;
30
47
  private SetRunning;
31
48
  }
49
+ /**
50
+ * DrawnUi ActionOnTickAnimator: runs `action(frameTimeNanos)` on every frame until stopped, a game loop for
51
+ * DrawnGame or any per-frame work.
52
+ */
53
+ export declare class ActionOnTickAnimator extends AnimatorBase {
54
+ private readonly action;
55
+ constructor(parent: SkiaControl, action: (frameTimeNanos: number) => void);
56
+ TickFrame(frameTimeNanos: number): boolean;
57
+ }
32
58
  /** DrawnUi SkiaValueAnimator: drives mValue from mMinValue to mMaxValue over Speed ms with Easing. */
33
59
  export declare class SkiaValueAnimator extends AnimatorBase {
34
60
  mValue: number;
@@ -46,10 +72,20 @@ export declare class SkiaValueAnimator extends AnimatorBase {
46
72
  TickFrame(frameTimeNanos: number): boolean;
47
73
  /** Passed over mValue; subclasses derive their own reported value here. */
48
74
  protected TransformReportedValue(_deltaT: number): number;
49
- /** Updates mValue from elapsed time; true when the target was reached. */
75
+ /**
76
+ * Updates mValue from elapsed time; true when the run is over. The eased value is not clamped to the range: a spring
77
+ * easing goes past its ends, and a run whose mMinValue is above mMaxValue (a ping-pong's way back) goes down.
78
+ */
50
79
  protected UpdateValue(_deltaT: number, deltaFromStart: number): boolean;
51
80
  protected FinishedRunning(): boolean;
52
81
  }
82
+ /** DrawnUi PingPongAnimator: every repeat runs the other way (Repeat -1 = forever by default). */
83
+ export declare class PingPongAnimator extends SkiaValueAnimator {
84
+ /** One way done, the next starts (C# CycleFInished). */
85
+ CycleFinished?: () => void;
86
+ constructor(parent: SkiaControl);
87
+ protected FinishedRunning(): boolean;
88
+ }
53
89
  /** DrawnUi RenderingAnimator: a value animator that paints itself above its Parent (IOverlayEffect). */
54
90
  export declare class RenderingAnimator extends SkiaValueAnimator implements IOverlayEffect {
55
91
  constructor(parent: SkiaControl);
@@ -16,7 +16,20 @@ export class AnimatorBase {
16
16
  StartFrameTimeNanos = 0;
17
17
  OnStart;
18
18
  OnStop;
19
+ /** Paused: the canvas does not tick it and it wakes no frames; Resume goes on from where it was (C# Pause / Resume). */
20
+ IsPaused = false;
21
+ /** Paused by the canvas because its control is hidden; resumed when it shows again. */
22
+ PausedWhileHidden = false;
23
+ /**
24
+ * Frame time (ns) before which nothing it shows changes: the canvas does not tick it and it keeps no frames coming
25
+ * until then, a timer wakes the frame loop at that time (a GIF or a sprite between two frames; DrawnUi.Rust frame
26
+ * animators sleep between changes). 0 = tick every frame.
27
+ */
28
+ SleepUntilNanos = 0;
19
29
  delayHandle = 0;
30
+ delayEnd = 0;
31
+ delayLeft = 0;
32
+ pausedAt = 0;
20
33
  constructor(parent) { this.Parent = parent; }
21
34
  Register() {
22
35
  const parent = this.Parent;
@@ -29,7 +42,14 @@ export class AnimatorBase {
29
42
  if (!parent.PostAnimators.includes(effect))
30
43
  parent.PostAnimators.push(effect);
31
44
  }
32
- const ok = parent.Superview?.RegisterAnimator(this) ?? false;
45
+ const superview = parent.Superview;
46
+ const ok = superview?.RegisterAnimator(this) ?? false;
47
+ // C# SkiaControl.RegisterAnimator: not attached yet, queue it; the parent starts it on its first arrange
48
+ if (!superview && !parent.IsDisposed) {
49
+ const pending = parent.PendingUnattachedAnimators ??= [];
50
+ if (!pending.includes(this))
51
+ pending.push(this);
52
+ }
33
53
  parent.Repaint();
34
54
  return ok;
35
55
  }
@@ -42,6 +62,9 @@ export class AnimatorBase {
42
62
  if (i >= 0)
43
63
  parent.PostAnimators.splice(i, 1);
44
64
  }
65
+ const pending = parent.PendingUnattachedAnimators?.indexOf(this) ?? -1;
66
+ if (pending >= 0)
67
+ parent.PendingUnattachedAnimators.splice(pending, 1);
45
68
  parent.Superview?.UnregisterAnimator(this.Uid);
46
69
  }
47
70
  Start(delayMs = 0) {
@@ -50,6 +73,8 @@ export class AnimatorBase {
50
73
  this.delayHandle = 0;
51
74
  }
52
75
  if (delayMs > 0) {
76
+ // the delay waits without frames
77
+ this.delayEnd = performance.now() + delayMs;
53
78
  this.delayHandle = window.setTimeout(() => { this.delayHandle = 0; this.Start(); }, delayMs);
54
79
  return;
55
80
  }
@@ -62,7 +87,43 @@ export class AnimatorBase {
62
87
  }
63
88
  }
64
89
  }
90
+ /** Freezes the run (and what is left of a start delay); Resume goes on from there. */
91
+ Pause() {
92
+ if (this.IsPaused)
93
+ return;
94
+ this.IsPaused = true;
95
+ this.pausedAt = performance.now();
96
+ if (this.delayHandle) {
97
+ clearTimeout(this.delayHandle);
98
+ this.delayHandle = 0;
99
+ this.delayLeft = Math.max(0, this.delayEnd - this.pausedAt);
100
+ }
101
+ }
102
+ /** Goes on from where Pause froze it: the paused time is not counted. */
103
+ Resume() {
104
+ if (!this.IsPaused)
105
+ return;
106
+ this.IsPaused = false;
107
+ const paused = (performance.now() - this.pausedAt) * 1_000_000;
108
+ if (this.StartFrameTimeNanos !== 0) {
109
+ this.StartFrameTimeNanos += paused;
110
+ this.LastFrameTimeNanos += paused;
111
+ }
112
+ if (this.SleepUntilNanos !== 0)
113
+ this.SleepUntilNanos += paused;
114
+ if (this.delayLeft > 0) {
115
+ const left = this.delayLeft;
116
+ this.delayLeft = 0;
117
+ this.Start(left);
118
+ return;
119
+ }
120
+ this.Parent?.Repaint(); // frames again
121
+ }
65
122
  Stop() {
123
+ this.IsPaused = false;
124
+ this.PausedWhileHidden = false;
125
+ this.SleepUntilNanos = 0;
126
+ this.delayLeft = 0;
66
127
  if (this.delayHandle) {
67
128
  clearTimeout(this.delayHandle);
68
129
  this.delayHandle = 0;
@@ -96,6 +157,21 @@ export class AnimatorBase {
96
157
  this.OnStop?.();
97
158
  }
98
159
  }
160
+ /**
161
+ * DrawnUi ActionOnTickAnimator: runs `action(frameTimeNanos)` on every frame until stopped, a game loop for
162
+ * DrawnGame or any per-frame work.
163
+ */
164
+ export class ActionOnTickAnimator extends AnimatorBase {
165
+ action;
166
+ constructor(parent, action) {
167
+ super(parent);
168
+ this.action = action;
169
+ }
170
+ TickFrame(frameTimeNanos) {
171
+ this.action(frameTimeNanos);
172
+ return super.TickFrame(frameTimeNanos);
173
+ }
174
+ }
99
175
  /** DrawnUi SkiaValueAnimator: drives mValue from mMinValue to mMaxValue over Speed ms with Easing. */
100
176
  export class SkiaValueAnimator extends AnimatorBase {
101
177
  mValue = 0;
@@ -130,23 +206,21 @@ export class SkiaValueAnimator extends AnimatorBase {
130
206
  }
131
207
  /** Passed over mValue; subclasses derive their own reported value here. */
132
208
  TransformReportedValue(_deltaT) { return this.mValue; }
133
- /** Updates mValue from elapsed time; true when the target was reached. */
209
+ /**
210
+ * Updates mValue from elapsed time; true when the run is over. The eased value is not clamped to the range: a spring
211
+ * easing goes past its ends, and a run whose mMinValue is above mMaxValue (a ping-pong's way back) goes down.
212
+ */
134
213
  UpdateValue(_deltaT, deltaFromStart) {
135
214
  const elapsedMs = deltaFromStart / 1_000_000;
136
215
  const progress = this.Speed > 0 ? elapsedMs / this.Speed : 1;
137
216
  const deltaValue = this.mMaxValue - this.mMinValue;
138
217
  const eased = this.Easing.Ease(Math.min(progress, 1));
139
218
  this.Progress = eased;
140
- const value = deltaValue * eased + this.mMinValue;
141
- if (value < this.mMinValue) {
142
- this.mValue = this.mMinValue;
143
- return false;
144
- }
145
- if (value >= this.mMaxValue || progress >= 1) {
219
+ if (progress >= 1) {
146
220
  this.mValue = this.mMaxValue;
147
221
  return true;
148
222
  }
149
- this.mValue = value;
223
+ this.mValue = deltaValue * eased + this.mMinValue;
150
224
  return false;
151
225
  }
152
226
  FinishedRunning() {
@@ -163,6 +237,25 @@ export class SkiaValueAnimator extends AnimatorBase {
163
237
  return true;
164
238
  }
165
239
  }
240
+ /** DrawnUi PingPongAnimator: every repeat runs the other way (Repeat -1 = forever by default). */
241
+ export class PingPongAnimator extends SkiaValueAnimator {
242
+ /** One way done, the next starts (C# CycleFInished). */
243
+ CycleFinished;
244
+ constructor(parent) { super(parent); this.Repeat = -1; }
245
+ FinishedRunning() {
246
+ if (this.Repeat !== 0) {
247
+ this.CycleFinished?.();
248
+ if (this.Repeat > 0)
249
+ this.Repeat--;
250
+ [this.mMinValue, this.mMaxValue] = [this.mMaxValue, this.mMinValue];
251
+ this.mValue = this.mMinValue;
252
+ this.LastFrameTimeNanos = 0;
253
+ this.StartFrameTimeNanos = 0;
254
+ return false;
255
+ }
256
+ return super.FinishedRunning();
257
+ }
258
+ }
166
259
  /** DrawnUi RenderingAnimator: a value animator that paints itself above its Parent (IOverlayEffect). */
167
260
  export class RenderingAnimator extends SkiaValueAnimator {
168
261
  constructor(parent) { super(parent); }
@@ -1,19 +1,27 @@
1
1
  import type { Surface } from "canvaskit-wasm";
2
- import type { DrawingContext, SkiaControl } from "./SkiaControl";
2
+ import { type DrawingContext, SkiaControl } from "./SkiaControl";
3
3
  import type { AnimatorBase } from "./Animators";
4
4
  import { SkiaAccessibilityManager } from "./Accessibility";
5
- import { type Color, type RenderingModeType } from "./Types";
6
- import { ContextMenuEventArgs, type GesturesMode, SkiaGesturesParameters, TouchActionEventArgs } from "./Gestures";
5
+ import { HoverManager } from "./Hover";
6
+ import { type TooltipStyleLike } from "./Tooltips";
7
+ import { PopupAnchor, type PopupId, type PopupWindowOptions } from "./PopupWindows";
8
+ import { type Color, type RenderingModeType, SKRect } from "./Types";
9
+ import { ContextMenuEventArgs, type GesturesMode, SKPoint, SkiaGesturesParameters, TouchActionEventArgs } from "./Gestures";
7
10
  /**
8
11
  * Mirrors DrawnUi Canvas (DrawnView): hosts one Content control on an HTML canvas element,
9
12
  * owns RenderingScale (devicePixelRatio), the surface, the on-demand frame loop and raw input.
10
13
  * Frames are drawn only after Update() (invalidation), never continuously.
11
14
  * Gestures are accumulated and processed in order at the START of the next frame, like DrawnUi.
12
15
  */
16
+ /** The system's light / dark appearance (DrawnUi.Rust SystemTheme). */
17
+ export type SystemTheme = "Light" | "Dark";
13
18
  export declare class Canvas {
14
19
  readonly Element: HTMLCanvasElement;
15
20
  /** Points a pointer may travel between Down and Up and still count as a tap (AppoMobi TouchEffect default). */
16
21
  static TappedCancelMoveThresholdPoints: number;
22
+ /** Alias of TouchEffect.LongPressTimeMsDefault: how long a press is held still to be a LongPressing. */
23
+ static get LongPressTimeMs(): number;
24
+ static set LongPressTimeMs(ms: number);
17
25
  BackgroundColor: Color;
18
26
  /** Accelerated = WebGL surface, Default = software. Read once at first frame. */
19
27
  RenderingMode: RenderingModeType;
@@ -35,8 +43,96 @@ export declare class Canvas {
35
43
  WillFirstTimeDraw?: (sender: Canvas, context: DrawingContext["Context"]) => void;
36
44
  /** DrawnView.WasDrawn: raised after every frame has been drawn (the C# event passes no context). */
37
45
  WasDrawn?: (sender: Canvas) => void;
46
+ /**
47
+ * The system's light / dark appearance (DrawnUi.Rust `system_theme`): undefined until the host learns it, which it
48
+ * does when the canvas is created (`prefers-color-scheme`), then it follows every change.
49
+ */
50
+ get SystemTheme(): SystemTheme | undefined;
51
+ /**
52
+ * Raised once when the host learns the system theme (set it in the Canvas init / the `<Canvas>` prop to get that first
53
+ * value), then once per change; a repeated value is not raised. No handler, no call; it never asks for a frame.
54
+ */
55
+ SystemThemeChanged?: (theme: SystemTheme) => void;
56
+ private systemTheme?;
57
+ private themeQuery?;
58
+ private readonly onThemeQuery;
59
+ private SetSystemTheme;
38
60
  /** Registry + rate-limited snapshot of accessible controls, rendered by the DOM overlay (DrawnUi AccessibilityManager). */
39
61
  readonly AccessibilityManager: SkiaAccessibilityManager;
62
+ /** Mouse hover of the controls (drawnui-cross 6m): ReceivesHover / IsHovered / HoverChanged. */
63
+ readonly Hover: HoverManager;
64
+ private tooltipController?;
65
+ /** Made on first use: a canvas that never shows a tooltip allocates nothing for it. */
66
+ private get tooltip();
67
+ /** Look and timing of the tooltips on this canvas; unset uses `Super.TooltipStyle`. */
68
+ TooltipStyle?: TooltipStyleLike;
69
+ get TooltipStyleUsed(): TooltipStyleLike;
70
+ /** The text of the tooltip shown now, undefined when none is shown. */
71
+ get ShownTooltip(): string | undefined;
72
+ private popupLayer?;
73
+ /** Made on first use, like the tooltip. */
74
+ private get popups();
75
+ private popupKeysHooked;
76
+ /** Raised when a popup window closed: picked, a press outside, Escape, the wheel, window blur or ClosePopupWindow. */
77
+ readonly PopupWindowClosed: Set<(id: PopupId) => void>;
78
+ /** The root controls of the open popup windows, bottom to top: a read-only view for tools (a new array per read). */
79
+ get PopupWindowRoots(): readonly SkiaControl[];
80
+ private wasDrawnListeners?;
81
+ /**
82
+ * Handlers run at the end of every drawn frame, after the `WasDrawn` callback and before the surface is flushed (a
83
+ * tool drawing an overlay on `Surface.getCanvas()`). Made on first use: a canvas without listeners does no work.
84
+ */
85
+ get WasDrawnListeners(): Set<(sender: Canvas) => void>;
86
+ private readonly raiseWasDrawn;
87
+ /**
88
+ * Shows `content` over everything, opening from `anchor` the way native menus do: at a point (a right click, canvas
89
+ * points), or below a rect or a control (a dropdown), flipped to the other side where it does not fit. It closes with
90
+ * a press outside it, Escape, the wheel outside it, window blur, `ClosePopupWindow` and the options.
91
+ */
92
+ OpenPopupWindow(content: SkiaControl, anchor: PopupAnchor | SKPoint | SKRect | SkiaControl | {
93
+ X: number;
94
+ Y: number;
95
+ }, options?: PopupWindowOptions): PopupId;
96
+ /** Closes the popup window (nothing when it is closed already). */
97
+ ClosePopupWindow(id: PopupId): void;
98
+ /** Closes every popup window. */
99
+ ClosePopupWindows(): void;
100
+ /** The popup window is still open. */
101
+ IsPopupWindowOpen(id: PopupId): boolean;
102
+ /**
103
+ * Moves the keyboard and screen-reader focus to `control` at the end of the next frame, for app code such as a custom
104
+ * menu that moves its highlight (C# DrawnView.SetAccessibilityFocus). A control not drawn yet gets it once it is, within
105
+ * 3 seconds. It wins over the library's own moves in the same frame (a closed popup window giving the keyboard back to
106
+ * its opener); undefined cancels a move still waiting. The focus ring shows only if the keyboard is in use.
107
+ */
108
+ SetAccessibilityFocus(control?: SkiaControl): void;
109
+ /**
110
+ * The drawn control with the keyboard and screen-reader focus (C# KeyboardFocusNode). Set undefined to let no drawn
111
+ * control keep it: the DOM focus goes back to the canvas and the keys belong to the app; a control moves it there.
112
+ */
113
+ get KeyboardFocusNode(): SkiaControl | undefined;
114
+ set KeyboardFocusNode(control: SkiaControl | undefined);
115
+ /** True while a popup window that takes input is open. */
116
+ get HasPopupWindows(): boolean;
117
+ /** The content of the top popup window that takes input. */
118
+ get TopPopupWindow(): SkiaControl | undefined;
119
+ /** The window stopped being active (blur): popup windows and the tooltip close, as native menus do. */
120
+ OnWindowDeactivated(): void;
121
+ /**
122
+ * The browser window (tab) has the keyboard (C# DrawnView.IsWindowActive): false after its blur, true again after its
123
+ * focus. A focused editor hides its caret while it is false.
124
+ */
125
+ IsWindowActive: boolean;
126
+ /** Raised when IsWindowActive changes (C# WindowActiveChanged). */
127
+ readonly WindowActiveChanged: Set<(active: boolean) => void>;
128
+ private SetWindowActive;
129
+ RaisePopupWindowClosed(id: PopupId): void;
130
+ private AfterPopupsChanged;
131
+ private readonly onPopupKey;
132
+ private HookPopupKeys;
133
+ private readonly onWindowBlur;
134
+ private readonly onWindowInactive;
135
+ private readonly onWindowActive;
40
136
  private content?;
41
137
  get Content(): SkiaControl | undefined;
42
138
  set Content(value: SkiaControl | undefined);
@@ -47,6 +143,25 @@ export declare class Canvas {
47
143
  private frameId;
48
144
  private disposed;
49
145
  private readonly observer;
146
+ /**
147
+ * The device pixels the element covers, as the browser reports them (ResizeObserver device-pixel-content-box). At a
148
+ * fractional display scale the rounded CSS size can be a pixel off (701.3 x 333.3 CSS px at 1.25 cover 877 x 416 device
149
+ * px), and the browser would then resample the whole canvas, softening every glyph.
150
+ */
151
+ private devicePixels?;
152
+ /** The element's CSS width when the device-pixel box was reported. */
153
+ private devicePixelsCss;
154
+ /** The WebGL context is lost: no frames until the browser restores it. */
155
+ private contextLost;
156
+ /**
157
+ * The GPU context generation, unique across canvases: a new one when this canvas is made and when its WebGL context
158
+ * is restored. Every GPU object made under another one (Image caches, picture caches that may replay them, kept
159
+ * composite surfaces, effect textures; also those a control brought from another canvas) is remade at its next draw
160
+ * (DrawnUi.Rust Gpu::epoch). A texture of another WebGL context draws nothing.
161
+ */
162
+ GpuEpoch: number;
163
+ private static gpuEpochs;
164
+ private static NextGpuEpoch;
50
165
  /** `init` runs before the first frame is drawn: the place to attach `WillFirstTimeDraw` / `WasDrawn` for that frame. */
51
166
  constructor(Element: HTMLCanvasElement, init?: (canvas: Canvas) => void);
52
167
  /** Request a redraw (full measure + arrange + render) on the next animation frame. */
@@ -61,6 +176,28 @@ export declare class Canvas {
61
176
  * redrawn content lands in the same paint and no blank frame is ever shown while dragging.
62
177
  */
63
178
  private OnResized;
179
+ /**
180
+ * Registers the WebGL context without `WEBGL_polygon_mode` (drawnui-cross 6bt): Emscripten turns on every extension it
181
+ * knows while it registers a context, nothing here draws with that one, and WebKit warns "non-portable extension
182
+ * enabled" for it. The lookup is hidden only for this synchronous call (creating the context here first would change
183
+ * the attributes CanvasKit asks for).
184
+ */
185
+ private static WithoutPolygonMode;
186
+ /**
187
+ * WebGL context lost: keep the browser restoring it (preventDefault) and stop the frames. The old Skia context is
188
+ * abandoned here, while the context is lost: WebGL ignores every call on a lost context without a word, so the GL
189
+ * deletes Skia makes while it lets go of its objects stay silent (done after the restore, they reach the new
190
+ * generation and every one logs "object does not belong to this context"). CanvasKit has no `abandonContext`;
191
+ * `releaseResourcesAndAbandonContext` is its only way, and after it freeing an old image or surface makes no GL call.
192
+ */
193
+ private readonly onContextLost;
194
+ /**
195
+ * WebGL context restored (as DrawnUi.Rust and the C# Wasm / Blazor heads): every GL object of the lost generation is
196
+ * gone, and the old Skia context was abandoned when it was lost. The same WebGL object is registered again (the old
197
+ * handle deleted first, which clears the canvas' context object) with a new GrContext and surface; GpuEpoch makes the
198
+ * old generation's GPU objects remake themselves.
199
+ */
200
+ private readonly onContextRestored;
64
201
  /** Draws one frame immediately (outside the rAF loop) and presents it. */
65
202
  private DrawNow;
66
203
  private Draw;
@@ -73,10 +210,44 @@ export declare class Canvas {
73
210
  readonly AnimatingControls: Map<number, AnimatorBase>;
74
211
  RegisterAnimator(animator: AnimatorBase): boolean;
75
212
  UnregisterAnimator(uid: number): void;
213
+ /**
214
+ * `root` leaves this canvas (removed from its parent, replaced as content, disposed): what runs for its subtree stops,
215
+ * as DrawnUi.Rust 44c718f. Its animators leave the frame loop: disposed, they stop; only removed, they pause and wait on
216
+ * their control (PendingUnattachedAnimators), going on from there when it is arranged on a canvas again. A focused editor in it loses the
217
+ * focus, a game in it stops getting keys (CanvasLeaveWatchers). Runs once per removal, never per frame.
218
+ */
219
+ ControlLeft(root: SkiaControl, disposed: boolean): void;
220
+ private static readonly reportedAnimators;
221
+ /** An animator's callback threw: logged once for that animator, the frame goes on. */
222
+ /**
223
+ * One exception never stops the frame loop (drawnui-cross 6ch, DrawnUi.Net 3db4eba3): app code the frame runs (a
224
+ * listener, a gesture handler) is called through this; a throw is logged once per source and the frame goes on.
225
+ */
226
+ private static Guard;
227
+ private static readonly reportedSources;
228
+ /**
229
+ * Draws a frame and always shows it: a throw inside it (app drawing code) is logged once, the canvas state is reset and
230
+ * the frame loop goes on (a running animation or game keeps asking for frames).
231
+ */
232
+ private DrawGuarded;
233
+ private static reportedFrameError;
234
+ private static ReportAnimatorError;
76
235
  /** Ticks every registered animator once; returns how many ran. */
77
236
  protected ExecuteAnimators(frameTimeNanos: number): number;
237
+ private wakeTimer;
238
+ private wakeAtNanos;
239
+ /** One timer for the earliest sleeping animator: the frame loop wakes then, no frames run in between. */
240
+ private WakeAt;
78
241
  /** Frames drawn so far (SkiaBackdrop uses it to refresh once after a cached record). */
79
242
  FrameIndex: number;
243
+ /**
244
+ * DrawnView.WheelDeltaPerNotch: the Wheel.Delta one mouse-wheel notch produces, 100 CSS pixels in Chrome and Edge. A
245
+ * scroll moves by the event's share of a notch, so a touchpad, which sends many small events, scrolls as far as the
246
+ * fingers moved. 0 = units unknown: every event scrolls one line.
247
+ */
248
+ WheelDeltaPerNotch: number;
249
+ /** Vsync time of the last frame the animators ran on (nanoseconds, the performance.now() timeline). */
250
+ FrameTimeNanos: number;
80
251
  /** On-screen surface (SkiaBackdrop snapshots it). */
81
252
  get Surface(): Surface | undefined;
82
253
  /**
@@ -99,19 +270,105 @@ export declare class Canvas {
99
270
  private readonly pointerDownArgs;
100
271
  private readonly previousTouchArgs;
101
272
  private readonly pendingGestures;
273
+ private textDrag?;
274
+ private readonly pageSelection;
275
+ private pageSelectionKeys;
276
+ /**
277
+ * The text selected on the page: the labels a mouse drag selected, joined with new lines, in page order; else the
278
+ * selection of the label in focus. Empty when nothing is selected.
279
+ */
280
+ get SelectedText(): string;
281
+ /** True while a mouse drag selection holds page text: the page, not a label, owns Ctrl+C. */
282
+ get OwnsTextSelectionKeys(): boolean;
283
+ /** Puts SelectedText on the clipboard through Super.SetClipboardText. False when nothing is selected. */
284
+ CopyTextSelection(): boolean;
285
+ /** Drops the page text selection (every label a drag selected) and the selection of the label in focus. */
286
+ ClearTextSelection(): void;
287
+ /**
288
+ * Before a gesture goes to the controls: a mouse drag that is selecting text keeps its moves (a scroll under it does
289
+ * not scroll), a main-button press drops the previous page selection. True when the gesture was used here.
290
+ */
291
+ private PreviewTextSelectionGesture;
292
+ /**
293
+ * After a mouse main-button press went to the controls: when it landed on no interactive control (empty space, a
294
+ * scroll's empty area, a selectable label), a drag from here selects text. Not inside a scroll that holds no
295
+ * selectable text: that one keeps scrolling by mouse drag.
296
+ */
297
+ private AfterTextSelectionDown;
298
+ /** Frame start: while a drag holds the pointer past a scroll's top or bottom edge, the scroll follows it. */
299
+ private ProcessTextSelectionFrame;
300
+ private UpdateTextDrag;
301
+ private AttachPageSelectionKeys;
302
+ private static readonly noChar;
303
+ private readonly onPageSelectionKey;
102
304
  private readonly onPointer;
305
+ /** The mouse left the canvas: hover ends at once, also while content moves. */
306
+ private readonly onPointerLeave;
103
307
  private readonly preventTouch;
308
+ /** Points of this canvas, up from its bottom, that the on-screen keyboard covers (0 when none). */
309
+ KeyboardCovered: number;
310
+ private keyboardScroll?;
311
+ private readonly onViewportResize;
312
+ /**
313
+ * Measures the part the keyboard covers (the visual viewport shrinks when it opens) and, when the focused text field sits
314
+ * in a scroll with AdaptToKeyboardAuto, hands that scroll the field and the covered height; the scroll it adapted lets go
315
+ * when the keyboard closes or the field moves to another scroll. Runs on viewport resizes and focus changes only.
316
+ */
317
+ private ApplyKeyboard;
318
+ /** When the last touch releases came (ms), at most two. */
319
+ private readonly touchUps;
320
+ private replayingTap;
321
+ /**
322
+ * iOS Safari (measured on an iPhone, iOS 26.6.1) takes the second tap of a double tap for itself: it sends no pointer or
323
+ * touch event for it, only click, click and dblclick. A dblclick that follows ONE touch release (the other browsers
324
+ * deliver both taps first) brings that tap back as a touch tap at its place, so a double tap reaches the controls (a 3D
325
+ * viewer's reset).
326
+ */
327
+ private readonly onDoubleClick;
328
+ /**
329
+ * The end of a touch is the user gesture iOS opens the soft keyboard from (a focus() in pointerup does not open it): the
330
+ * press's gestures run now, inside it, so a field they focus focuses its input here, and a tap on the focused field gives
331
+ * its input focus again.
332
+ */
333
+ /** A finger or a pen is down on the canvas: a text field focused now takes its input focus in the touchend (onTouchEnd). */
334
+ get TouchPressed(): boolean;
335
+ private readonly onTouchEnd;
336
+ /** Gestures="Enabled": touch / pen pointers whose Down a control used (see OnTouchAction). */
337
+ private readonly claimedTouches;
338
+ /** Gestures="Enabled": while a claimed touch is down the page may not take its drag. */
339
+ private readonly preventClaimedTouch;
104
340
  /** Called when no control handled a context-menu request; return true to suppress the browser's canvas menu. */
105
341
  ContextMenu?: (sender: Canvas, e: ContextMenuEventArgs) => boolean | void;
106
342
  /** DOM contextmenu (right click / long press / Menu key) -> ContextMenuEventArgs routed through the tree like a tap. */
107
343
  private readonly onContextMenu;
344
+ /** A context-menu request at a point of the page (client CSS px), routed through the tree like a tap; true when one took it. */
345
+ private RaiseContextMenu;
346
+ /** The touch or pen press going on: its context menu is raised once, by the browser's contextmenu or after its long press. */
347
+ private touchMenu?;
348
+ /** The long press of a touch press was just queued: its context menu follows the LongPressing (client CSS px). */
349
+ private touchMenuDue?;
350
+ /** A touch or pen press starts (on the canvas, or on selectable text of the overlay): its context menu is still to come. */
351
+ StartTouchPress(): void;
352
+ /**
353
+ * The context menu of the touch press now (Source "touch"), raised once per press whoever asks first: the browser's own
354
+ * contextmenu (Android Chrome fires one on a long press) or the press's long press (iOS Safari fires none). True when a
355
+ * handler took it: the browser's own menu is then suppressed where it can be.
356
+ */
357
+ RaiseTouchContextMenu(clientX: number, clientY: number, native?: MouseEvent): boolean;
358
+ /**
359
+ * The Menu key, Shift+F10 or a screen reader's context-menu command on the control in keyboard focus (the DOM
360
+ * `contextmenu` of its overlay node): its context menu opens at its center, from it or the first control above it with
361
+ * a ContextMenu handler, then the Canvas' own (Source "keyboard", as every DrawnUI engine). True when one took it.
362
+ */
363
+ OpenContextMenuFromKeyboard(control: SkiaControl, native: MouseEvent): boolean;
108
364
  private cursorPointer;
109
365
  /**
110
366
  * DrawnUi.Blazor shows `cursor: pointer` over interactive controls through its overlay elements; here the overlay
111
- * is pointer-events:none, so the mouse position is tested against the accessibility snapshot (the accessible
112
- * controls' rects in points, already sorted and rate-limited), each hit control answering WantsPointerCursor
113
- * (itself tappable, or a tappable span of a label), and the canvas element's cursor is switched only when the
114
- * answer changes. Mouse moves only, no work without a mouse and none in the frame loop.
367
+ * is pointer-events:none, so the canvas decides from the hover hit path (Hover.Path: the controls under the mouse by
368
+ * the routing rules of ProcessGestures, so nothing below a popup that blocks gestures below): a control in the
369
+ * accessibility tree (it has a role) that answers WantsPointerCursor (itself tappable, or a tappable span of a label)
370
+ * shows the hand. A popup's close-on-background-tap wrapper has no role, so its backdrop shows none. The canvas
371
+ * element's cursor is switched only when the answer changes. Mouse moves only, none in the frame loop.
115
372
  */
116
373
  private UpdateCursor;
117
374
  /**
@@ -144,9 +401,22 @@ export declare class Canvas {
144
401
  private readonly UpdateTouchAction;
145
402
  private pageObserver?;
146
403
  private AttachInput;
404
+ /** The page's own overscroll-behavior before Lock set it to none (html, body), put back on detach. */
405
+ private pageOverscroll?;
147
406
  private DetachInput;
148
407
  /** Port of DrawnUi.Blazor Canvas.OnTouchAction: per-pointer state machine producing Down / Panning / Tapped / Up. */
149
408
  OnTouchAction(args: TouchActionEventArgs): void;
409
+ /** The fingers down, for TouchActionEventArgs.Manipulation (pinch and turn). */
410
+ private readonly fingers;
411
+ /** The press had a second finger: it is no tap (AppoMobi.Blazor.Gestures). */
412
+ private multiTouch;
413
+ private readonly longPressTimers;
414
+ private readonly longPressed;
415
+ /** The long press of a new press: due LongPressTimeMs later unless the pointer moves away or lets go. */
416
+ private ArmLongPress;
417
+ /** The long press of a held touch, now (the browser's context menu came first): queued gestures first, then it; its timer is off. */
418
+ private LongPressNow;
419
+ private DisarmLongPress;
150
420
  private OnGestureEvent;
151
421
  private ProcessPendingGestures;
152
422
  /**
@@ -158,6 +428,35 @@ export declare class Canvas {
158
428
  private gestureOwner;
159
429
  /** DrawnUi IsSavedGesture: the types replayed to the owner instead of being routed again. */
160
430
  private static IsSavedGesture;
161
- /** Entry into the control tree, same shape as DrawnUi Canvas.ProcessGestures. */
431
+ private arrowsStart;
432
+ /**
433
+ * While no drawn control has keyboard focus (or only one behind the active modal), the arrow keys start keyboard
434
+ * navigation as the first Tab does: Down and Right go to the first Tab stop, Up and Left to the last, and the key is used
435
+ * for that. Once a control has focus the arrows work as usual (inside a list or a menu). Off by default, since games use
436
+ * the arrows as their own keys while nothing is focused: an app turns it on for its menu screens and off while playing.
437
+ */
438
+ get ArrowsStartKeyboardNavigation(): boolean;
439
+ set ArrowsStartKeyboardNavigation(v: boolean);
440
+ private readonly onArrowKey;
441
+ private focusedChild?;
442
+ private focusAtDown?;
443
+ private tapNoFocus;
444
+ private reportingFocus;
445
+ /**
446
+ * A control that left the canvas (removed or disposed) is let go by the focus, the gesture dispatch and the tooltips,
447
+ * so the last control that took input does not keep its page alive (C# 4cb28ab6). Checked once per frame.
448
+ */
449
+ private ForgetGoneControls;
450
+ /** The control that has the canvas focus (an editor while it edits, a CanBeFocused control that was tapped). */
451
+ get FocusedChild(): SkiaControl | undefined;
452
+ /**
453
+ * Moves the focus. The new control is asked first and the focus moves only when it takes it (a tap on a button leaves an
454
+ * editor focused); undefined clears it. Nothing moves while the focused control has LockFocus. `setter` is a control
455
+ * that focused itself already (an editor on its press) or the focused control letting go itself (Escape, submit).
456
+ */
457
+ ReportFocus(value: SkiaControl | undefined, setter?: SkiaControl): void;
458
+ /** Entry into the control tree; on a completed tap the focus follows it (C# Canvas: focus only on Tapped). */
162
459
  protected ProcessGestures(root: SkiaControl, args: SkiaGesturesParameters): SkiaControl | null;
460
+ /** Same shape as DrawnUi Canvas.ProcessGestures. */
461
+ private RouteGestures;
163
462
  }