drawnui-react 0.1.0-preview.41 → 0.1.0-preview.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -7
- package/SKIPPED.md +7 -7
- package/dist/controls/GridStructure.d.ts +9 -1
- package/dist/controls/GridStructure.js +41 -1
- package/dist/controls/SkiaEditor.d.ts +4 -1
- package/dist/controls/SkiaEditor.js +25 -6
- package/dist/controls/SkiaImage.d.ts +5 -0
- package/dist/controls/SkiaImage.js +32 -5
- package/dist/controls/SkiaLabel.d.ts +85 -4
- package/dist/controls/SkiaLabel.js +406 -20
- package/dist/controls/SkiaLabelFps.d.ts +0 -3
- package/dist/controls/SkiaLabelFps.js +1 -11
- package/dist/controls/SkiaLayout.js +33 -2
- package/dist/controls/SkiaScroll.d.ts +51 -2
- package/dist/controls/SkiaScroll.js +150 -9
- package/dist/controls/SkiaShape.d.ts +2 -0
- package/dist/controls/SkiaShape.js +7 -0
- package/dist/controls/SkiaShell.d.ts +282 -0
- package/dist/controls/SkiaShell.js +972 -0
- package/dist/controls/SkiaSprite.js +5 -1
- package/dist/core/Accessibility.d.ts +30 -13
- package/dist/core/Accessibility.js +237 -43
- package/dist/core/Canvas.d.ts +122 -14
- package/dist/core/Canvas.js +585 -47
- package/dist/core/Gestures.d.ts +11 -1
- package/dist/core/Gestures.js +12 -1
- package/dist/core/PopupWindows.js +2 -0
- package/dist/core/Props.d.ts +11 -0
- package/dist/core/Props.js +44 -0
- package/dist/core/ScrollAnimators.d.ts +6 -0
- package/dist/core/ScrollAnimators.js +7 -1
- package/dist/core/SkiaControl.d.ts +24 -4
- package/dist/core/SkiaControl.js +59 -13
- package/dist/core/SkiaEffect.d.ts +12 -1
- package/dist/core/SkiaEffect.js +35 -8
- package/dist/core/SkiaImageManager.d.ts +101 -18
- package/dist/core/SkiaImageManager.js +318 -63
- package/dist/core/Styles.js +7 -1
- package/dist/core/Super.d.ts +4 -0
- package/dist/core/Super.js +4 -9
- package/dist/core/TextInputProxy.d.ts +31 -1
- package/dist/core/TextInputProxy.js +97 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/SkiaShell.d.ts +8 -74
- package/dist/react/SkiaShell.js +163 -514
- package/dist/react/index.d.ts +6 -1
- package/dist/react/index.js +51 -40
- package/dist/react/reconciler.d.ts +12 -0
- package/dist/react/reconciler.js +22 -46
- package/package.json +37 -4
package/dist/core/Canvas.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Surface } from "canvaskit-wasm";
|
|
2
|
-
import { type DrawingContext,
|
|
2
|
+
import { type DrawingContext, SkiaControl } from "./SkiaControl";
|
|
3
3
|
import type { AnimatorBase } from "./Animators";
|
|
4
4
|
import { SkiaAccessibilityManager } from "./Accessibility";
|
|
5
5
|
import { HoverManager } from "./Hover";
|
|
@@ -19,11 +19,9 @@ export declare class Canvas {
|
|
|
19
19
|
readonly Element: HTMLCanvasElement;
|
|
20
20
|
/** Points a pointer may travel between Down and Up and still count as a tap (AppoMobi TouchEffect default). */
|
|
21
21
|
static TappedCancelMoveThresholdPoints: number;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
static LongPressTimeMs: 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);
|
|
27
25
|
BackgroundColor: Color;
|
|
28
26
|
/** Accelerated = WebGL surface, Default = software. Read once at first frame. */
|
|
29
27
|
RenderingMode: RenderingModeType;
|
|
@@ -145,13 +143,25 @@ export declare class Canvas {
|
|
|
145
143
|
private frameId;
|
|
146
144
|
private disposed;
|
|
147
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;
|
|
148
154
|
/** The WebGL context is lost: no frames until the browser restores it. */
|
|
149
155
|
private contextLost;
|
|
150
156
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
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.
|
|
153
161
|
*/
|
|
154
162
|
GpuEpoch: number;
|
|
163
|
+
private static gpuEpochs;
|
|
164
|
+
private static NextGpuEpoch;
|
|
155
165
|
/** `init` runs before the first frame is drawn: the place to attach `WillFirstTimeDraw` / `WasDrawn` for that frame. */
|
|
156
166
|
constructor(Element: HTMLCanvasElement, init?: (canvas: Canvas) => void);
|
|
157
167
|
/** Request a redraw (full measure + arrange + render) on the next animation frame. */
|
|
@@ -166,15 +176,26 @@ export declare class Canvas {
|
|
|
166
176
|
* redrawn content lands in the same paint and no blank frame is ever shown while dragging.
|
|
167
177
|
*/
|
|
168
178
|
private OnResized;
|
|
169
|
-
/**
|
|
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
|
+
*/
|
|
170
193
|
private readonly onContextLost;
|
|
171
194
|
/**
|
|
172
195
|
* WebGL context restored (as DrawnUi.Rust and the C# Wasm / Blazor heads): every GL object of the lost generation is
|
|
173
|
-
* gone
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* GL call. Then the same WebGL object is registered again (the old handle deleted first, which clears the canvas'
|
|
177
|
-
* context object) with a new GrContext and surface; GpuEpoch makes the old generation's GPU objects remake themselves.
|
|
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.
|
|
178
199
|
*/
|
|
179
200
|
private readonly onContextRestored;
|
|
180
201
|
/** Draws one frame immediately (outside the rAF loop) and presents it. */
|
|
@@ -198,6 +219,18 @@ export declare class Canvas {
|
|
|
198
219
|
ControlLeft(root: SkiaControl, disposed: boolean): void;
|
|
199
220
|
private static readonly reportedAnimators;
|
|
200
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;
|
|
201
234
|
private static ReportAnimatorError;
|
|
202
235
|
/** Ticks every registered animator once; returns how many ran. */
|
|
203
236
|
protected ExecuteAnimators(frameTimeNanos: number): number;
|
|
@@ -237,10 +270,69 @@ export declare class Canvas {
|
|
|
237
270
|
private readonly pointerDownArgs;
|
|
238
271
|
private readonly previousTouchArgs;
|
|
239
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;
|
|
240
304
|
private readonly onPointer;
|
|
241
305
|
/** The mouse left the canvas: hover ends at once, also while content moves. */
|
|
242
306
|
private readonly onPointerLeave;
|
|
243
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;
|
|
244
336
|
/** Gestures="Enabled": touch / pen pointers whose Down a control used (see OnTouchAction). */
|
|
245
337
|
private readonly claimedTouches;
|
|
246
338
|
/** Gestures="Enabled": while a claimed touch is down the page may not take its drag. */
|
|
@@ -249,6 +341,20 @@ export declare class Canvas {
|
|
|
249
341
|
ContextMenu?: (sender: Canvas, e: ContextMenuEventArgs) => boolean | void;
|
|
250
342
|
/** DOM contextmenu (right click / long press / Menu key) -> ContextMenuEventArgs routed through the tree like a tap. */
|
|
251
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;
|
|
252
358
|
/**
|
|
253
359
|
* The Menu key, Shift+F10 or a screen reader's context-menu command on the control in keyboard focus (the DOM
|
|
254
360
|
* `contextmenu` of its overlay node): its context menu opens at its center, from it or the first control above it with
|
|
@@ -308,6 +414,8 @@ export declare class Canvas {
|
|
|
308
414
|
private readonly longPressed;
|
|
309
415
|
/** The long press of a new press: due LongPressTimeMs later unless the pointer moves away or lets go. */
|
|
310
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;
|
|
311
419
|
private DisarmLongPress;
|
|
312
420
|
private OnGestureEvent;
|
|
313
421
|
private ProcessPendingGestures;
|