drawnui-react 0.1.0-preview.40 → 0.1.0-preview.41
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 +10 -0
- package/dist/core/Canvas.d.ts +19 -0
- package/dist/core/Canvas.js +41 -7
- package/dist/core/DesignerActions.d.ts +32 -0
- package/dist/core/DesignerActions.js +68 -0
- package/dist/core/SkiaControl.d.ts +5 -1
- package/dist/core/SkiaControl.js +9 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/index.d.ts +19 -1
- package/dist/react/index.js +24 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -49,6 +49,16 @@ property names, layout and drawing rules. What you learn here works there, and s
|
|
|
49
49
|
|
|
50
50
|
DrawnUI is MIT licensed in every language and on every platform: desktop, mobile, web and embedded devices. Ship it in commercial products with no attribution badge, no about screen and no per-device royalty.
|
|
51
51
|
|
|
52
|
+
## What's new in 0.1.0-preview.41
|
|
53
|
+
|
|
54
|
+
- **System light and dark:** `Canvas.SystemTheme` and `SystemThemeChanged` report the browser's light or dark appearance
|
|
55
|
+
at start and on every change.
|
|
56
|
+
- **Designer actions:** `designerAction`, `useDesignerAction` and `<DesignerAction>` name app states the DrawnUI Designer
|
|
57
|
+
can jump to.
|
|
58
|
+
- **Animations never stop each other:** an animation whose code fails is logged once, and the other animations and the
|
|
59
|
+
frame keep going.
|
|
60
|
+
- **Quiet replaced animations:** a fade or move replaced by a new one is silent unless your code waits on it.
|
|
61
|
+
|
|
52
62
|
## What's new in 0.1.0-preview.40
|
|
53
63
|
|
|
54
64
|
- **Context menus from the keyboard:** the Menu key, Shift+F10 and a screen reader's context-menu command (VoiceOver
|
package/dist/core/Canvas.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { ContextMenuEventArgs, type GesturesMode, SKPoint, SkiaGesturesParameter
|
|
|
13
13
|
* Frames are drawn only after Update() (invalidation), never continuously.
|
|
14
14
|
* Gestures are accumulated and processed in order at the START of the next frame, like DrawnUi.
|
|
15
15
|
*/
|
|
16
|
+
/** The system's light / dark appearance (DrawnUi.Rust SystemTheme). */
|
|
17
|
+
export type SystemTheme = "Light" | "Dark";
|
|
16
18
|
export declare class Canvas {
|
|
17
19
|
readonly Element: HTMLCanvasElement;
|
|
18
20
|
/** Points a pointer may travel between Down and Up and still count as a tap (AppoMobi TouchEffect default). */
|
|
@@ -43,6 +45,20 @@ export declare class Canvas {
|
|
|
43
45
|
WillFirstTimeDraw?: (sender: Canvas, context: DrawingContext["Context"]) => void;
|
|
44
46
|
/** DrawnView.WasDrawn: raised after every frame has been drawn (the C# event passes no context). */
|
|
45
47
|
WasDrawn?: (sender: Canvas) => void;
|
|
48
|
+
/**
|
|
49
|
+
* The system's light / dark appearance (DrawnUi.Rust `system_theme`): undefined until the host learns it, which it
|
|
50
|
+
* does when the canvas is created (`prefers-color-scheme`), then it follows every change.
|
|
51
|
+
*/
|
|
52
|
+
get SystemTheme(): SystemTheme | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Raised once when the host learns the system theme (set it in the Canvas init / the `<Canvas>` prop to get that first
|
|
55
|
+
* value), then once per change; a repeated value is not raised. No handler, no call; it never asks for a frame.
|
|
56
|
+
*/
|
|
57
|
+
SystemThemeChanged?: (theme: SystemTheme) => void;
|
|
58
|
+
private systemTheme?;
|
|
59
|
+
private themeQuery?;
|
|
60
|
+
private readonly onThemeQuery;
|
|
61
|
+
private SetSystemTheme;
|
|
46
62
|
/** Registry + rate-limited snapshot of accessible controls, rendered by the DOM overlay (DrawnUi AccessibilityManager). */
|
|
47
63
|
readonly AccessibilityManager: SkiaAccessibilityManager;
|
|
48
64
|
/** Mouse hover of the controls (drawnui-cross 6m): ReceivesHover / IsHovered / HoverChanged. */
|
|
@@ -180,6 +196,9 @@ export declare class Canvas {
|
|
|
180
196
|
* focus, a game in it stops getting keys (CanvasLeaveWatchers). Runs once per removal, never per frame.
|
|
181
197
|
*/
|
|
182
198
|
ControlLeft(root: SkiaControl, disposed: boolean): void;
|
|
199
|
+
private static readonly reportedAnimators;
|
|
200
|
+
/** An animator's callback threw: logged once for that animator, the frame goes on. */
|
|
201
|
+
private static ReportAnimatorError;
|
|
183
202
|
/** Ticks every registered animator once; returns how many ran. */
|
|
184
203
|
protected ExecuteAnimators(frameTimeNanos: number): number;
|
|
185
204
|
private wakeTimer;
|
package/dist/core/Canvas.js
CHANGED
|
@@ -7,12 +7,6 @@ import { PopupAnchor, PopupLayer } from "./PopupWindows";
|
|
|
7
7
|
import { KeyboardManager } from "./KeyboardManager";
|
|
8
8
|
import { Colors, SKRect } from "./Types";
|
|
9
9
|
import { ContextMenuEventArgs, GestureEventProcessingInfo, MultitouchTracker, PointerData, SKPoint, SkiaGesturesParameters, TouchActionEventArgs, } from "./Gestures";
|
|
10
|
-
/**
|
|
11
|
-
* Mirrors DrawnUi Canvas (DrawnView): hosts one Content control on an HTML canvas element,
|
|
12
|
-
* owns RenderingScale (devicePixelRatio), the surface, the on-demand frame loop and raw input.
|
|
13
|
-
* Frames are drawn only after Update() (invalidation), never continuously.
|
|
14
|
-
* Gestures are accumulated and processed in order at the START of the next frame, like DrawnUi.
|
|
15
|
-
*/
|
|
16
10
|
export class Canvas {
|
|
17
11
|
Element;
|
|
18
12
|
/** Points a pointer may travel between Down and Up and still count as a tap (AppoMobi TouchEffect default). */
|
|
@@ -43,6 +37,25 @@ export class Canvas {
|
|
|
43
37
|
WillFirstTimeDraw;
|
|
44
38
|
/** DrawnView.WasDrawn: raised after every frame has been drawn (the C# event passes no context). */
|
|
45
39
|
WasDrawn;
|
|
40
|
+
/**
|
|
41
|
+
* The system's light / dark appearance (DrawnUi.Rust `system_theme`): undefined until the host learns it, which it
|
|
42
|
+
* does when the canvas is created (`prefers-color-scheme`), then it follows every change.
|
|
43
|
+
*/
|
|
44
|
+
get SystemTheme() { return this.systemTheme; }
|
|
45
|
+
/**
|
|
46
|
+
* Raised once when the host learns the system theme (set it in the Canvas init / the `<Canvas>` prop to get that first
|
|
47
|
+
* value), then once per change; a repeated value is not raised. No handler, no call; it never asks for a frame.
|
|
48
|
+
*/
|
|
49
|
+
SystemThemeChanged;
|
|
50
|
+
systemTheme;
|
|
51
|
+
themeQuery;
|
|
52
|
+
onThemeQuery = () => this.SetSystemTheme(this.themeQuery.matches ? "Dark" : "Light");
|
|
53
|
+
SetSystemTheme(theme) {
|
|
54
|
+
if (theme === this.systemTheme)
|
|
55
|
+
return;
|
|
56
|
+
this.systemTheme = theme;
|
|
57
|
+
this.SystemThemeChanged?.(theme);
|
|
58
|
+
}
|
|
46
59
|
/** Registry + rate-limited snapshot of accessible controls, rendered by the DOM overlay (DrawnUi AccessibilityManager). */
|
|
47
60
|
AccessibilityManager = new SkiaAccessibilityManager();
|
|
48
61
|
/** Mouse hover of the controls (drawnui-cross 6m): ReceivesHover / IsHovered / HoverChanged. */
|
|
@@ -193,6 +206,11 @@ export class Canvas {
|
|
|
193
206
|
if (!Super.CK)
|
|
194
207
|
throw new Error("DrawnUi: call Super.UseDrawnUi()...BuildAsync() before creating a Canvas");
|
|
195
208
|
init?.(this);
|
|
209
|
+
if (typeof window.matchMedia === "function") {
|
|
210
|
+
this.themeQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
211
|
+
this.themeQuery.addEventListener?.("change", this.onThemeQuery);
|
|
212
|
+
this.onThemeQuery();
|
|
213
|
+
}
|
|
196
214
|
Element.addEventListener("webglcontextlost", this.onContextLost);
|
|
197
215
|
Element.addEventListener("webglcontextrestored", this.onContextRestored);
|
|
198
216
|
window.addEventListener("blur", this.onWindowInactive);
|
|
@@ -408,6 +426,14 @@ export class Canvas {
|
|
|
408
426
|
if (inside(c))
|
|
409
427
|
c.OnLeftCanvas();
|
|
410
428
|
}
|
|
429
|
+
static reportedAnimators = new WeakSet();
|
|
430
|
+
/** An animator's callback threw: logged once for that animator, the frame goes on. */
|
|
431
|
+
static ReportAnimatorError(a, e) {
|
|
432
|
+
if (Canvas.reportedAnimators.has(a))
|
|
433
|
+
return;
|
|
434
|
+
Canvas.reportedAnimators.add(a);
|
|
435
|
+
console.error("DrawnUi: an animator's callback threw; the other animators and the frame go on", e);
|
|
436
|
+
}
|
|
411
437
|
/** Ticks every registered animator once; returns how many ran. */
|
|
412
438
|
ExecuteAnimators(frameTimeNanos) {
|
|
413
439
|
let executed = 0, wake = Infinity;
|
|
@@ -434,7 +460,13 @@ export class Canvas {
|
|
|
434
460
|
wake = Math.min(wake, a.SleepUntilNanos);
|
|
435
461
|
continue;
|
|
436
462
|
} // nothing changes yet
|
|
437
|
-
|
|
463
|
+
// one animator whose callback throws must not stop the others or the frame (DrawnUi.Net catches the pass, Super.Log)
|
|
464
|
+
try {
|
|
465
|
+
a.TickFrame(frameTimeNanos);
|
|
466
|
+
}
|
|
467
|
+
catch (e) {
|
|
468
|
+
Canvas.ReportAnimatorError(a, e);
|
|
469
|
+
}
|
|
438
470
|
executed++;
|
|
439
471
|
if (a.SleepUntilNanos > frameTimeNanos)
|
|
440
472
|
wake = Math.min(wake, a.SleepUntilNanos);
|
|
@@ -519,6 +551,8 @@ export class Canvas {
|
|
|
519
551
|
}
|
|
520
552
|
this.Element.removeEventListener("webglcontextlost", this.onContextLost);
|
|
521
553
|
this.Element.removeEventListener("webglcontextrestored", this.onContextRestored);
|
|
554
|
+
this.themeQuery?.removeEventListener?.("change", this.onThemeQuery);
|
|
555
|
+
this.SystemThemeChanged = undefined;
|
|
522
556
|
window.removeEventListener("blur", this.onWindowInactive);
|
|
523
557
|
window.removeEventListener("focus", this.onWindowActive);
|
|
524
558
|
this.WindowActiveChanged.clear();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions an app declares for the DrawnUI Designer (C# DrawnUi.Draw.DesignerActions): named states it can jump to without
|
|
3
|
+
* being played to them (a level, a game state, a dialog). The designer lists them under the app's screens and runs one on
|
|
4
|
+
* a click; AI agents run them through the designer's MCP (`list_actions`, `run_action`).
|
|
5
|
+
*
|
|
6
|
+
* A path names the action and its groups, slash-separated: "Levels/Level 3" shows as "Level 3" under "Levels". Nothing
|
|
7
|
+
* here runs unless a designer is attached: the list only keeps the names and their callbacks.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* for (let level = 1; level <= 20; level++) designerAction(`Levels/Level ${level}`, () => game.startLevel(level));
|
|
11
|
+
* designerAction("Dialogs/Options", () => game.showOptions());
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class DesignerActions {
|
|
15
|
+
private static readonly items;
|
|
16
|
+
/** Raised after the list changed (an action added, replaced or removed); the designer agent sends the new list. */
|
|
17
|
+
static readonly Changed: Set<() => void>;
|
|
18
|
+
private static RaiseChanged;
|
|
19
|
+
/**
|
|
20
|
+
* Adds an action, or replaces the one with the same path (keeping its place). Returns the function that removes it
|
|
21
|
+
* again (an action a screen offers while it is shown); it removes only this registration, not a later one of the path.
|
|
22
|
+
*/
|
|
23
|
+
static Add(path: string, run: () => void): () => void;
|
|
24
|
+
/** Removes the action with this path, if there is one. */
|
|
25
|
+
static Remove(path: string): void;
|
|
26
|
+
/** The declared actions' paths, in the order they were added. */
|
|
27
|
+
static get Paths(): string[];
|
|
28
|
+
/** Runs the action with this path; false when there is no such action. */
|
|
29
|
+
static Run(path: string): boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Declares a Designer action (DesignerActions.Add); returns the function that removes it. Usable outside React. */
|
|
32
|
+
export declare function designerAction(path: string, run: () => void): () => void;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions an app declares for the DrawnUI Designer (C# DrawnUi.Draw.DesignerActions): named states it can jump to without
|
|
3
|
+
* being played to them (a level, a game state, a dialog). The designer lists them under the app's screens and runs one on
|
|
4
|
+
* a click; AI agents run them through the designer's MCP (`list_actions`, `run_action`).
|
|
5
|
+
*
|
|
6
|
+
* A path names the action and its groups, slash-separated: "Levels/Level 3" shows as "Level 3" under "Levels". Nothing
|
|
7
|
+
* here runs unless a designer is attached: the list only keeps the names and their callbacks.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* for (let level = 1; level <= 20; level++) designerAction(`Levels/Level ${level}`, () => game.startLevel(level));
|
|
11
|
+
* designerAction("Dialogs/Options", () => game.showOptions());
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export class DesignerActions {
|
|
15
|
+
static items = [];
|
|
16
|
+
/** Raised after the list changed (an action added, replaced or removed); the designer agent sends the new list. */
|
|
17
|
+
static Changed = new Set();
|
|
18
|
+
static RaiseChanged() { for (const h of [...DesignerActions.Changed])
|
|
19
|
+
h(); }
|
|
20
|
+
/**
|
|
21
|
+
* Adds an action, or replaces the one with the same path (keeping its place). Returns the function that removes it
|
|
22
|
+
* again (an action a screen offers while it is shown); it removes only this registration, not a later one of the path.
|
|
23
|
+
*/
|
|
24
|
+
static Add(path, run) {
|
|
25
|
+
if (!path || !path.trim())
|
|
26
|
+
throw new Error("DesignerActions: an action needs a path");
|
|
27
|
+
if (typeof run !== "function")
|
|
28
|
+
throw new Error("DesignerActions: an action needs a function");
|
|
29
|
+
const items = DesignerActions.items, at = items.findIndex((x) => x.Path === path);
|
|
30
|
+
const item = { Path: path, Run: run };
|
|
31
|
+
if (at >= 0)
|
|
32
|
+
items[at] = item;
|
|
33
|
+
else
|
|
34
|
+
items.push(item);
|
|
35
|
+
DesignerActions.RaiseChanged();
|
|
36
|
+
let done = false;
|
|
37
|
+
return () => {
|
|
38
|
+
if (done)
|
|
39
|
+
return;
|
|
40
|
+
done = true;
|
|
41
|
+
const i = DesignerActions.items.indexOf(item);
|
|
42
|
+
if (i < 0)
|
|
43
|
+
return;
|
|
44
|
+
DesignerActions.items.splice(i, 1);
|
|
45
|
+
DesignerActions.RaiseChanged();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Removes the action with this path, if there is one. */
|
|
49
|
+
static Remove(path) {
|
|
50
|
+
const i = DesignerActions.items.findIndex((x) => x.Path === path);
|
|
51
|
+
if (i < 0)
|
|
52
|
+
return;
|
|
53
|
+
DesignerActions.items.splice(i, 1);
|
|
54
|
+
DesignerActions.RaiseChanged();
|
|
55
|
+
}
|
|
56
|
+
/** The declared actions' paths, in the order they were added. */
|
|
57
|
+
static get Paths() { return DesignerActions.items.map((x) => x.Path); }
|
|
58
|
+
/** Runs the action with this path; false when there is no such action. */
|
|
59
|
+
static Run(path) {
|
|
60
|
+
const item = DesignerActions.items.find((x) => x.Path === path);
|
|
61
|
+
if (!item)
|
|
62
|
+
return false;
|
|
63
|
+
item.Run();
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Declares a Designer action (DesignerActions.Add); returns the function that removes it. Usable outside React. */
|
|
68
|
+
export function designerAction(path, run) { return DesignerActions.Add(path, run); }
|
|
@@ -682,7 +682,11 @@ export declare class SkiaControl {
|
|
|
682
682
|
AnimateAsync(callback: (value: number) => void, onCancel?: () => void, ms?: number, easing?: Easing, cancel?: AbortSignal): Promise<void>;
|
|
683
683
|
/** callback(start..end) over ms. */
|
|
684
684
|
AnimateRangeAsync(callback: (value: number) => void, start: number, end: number, ms?: number, easing?: Easing, cancel?: AbortSignal): Promise<void>;
|
|
685
|
-
/**
|
|
685
|
+
/**
|
|
686
|
+
* One running animation per kind, like the per-property CancellationTokenSources in C#. A replaced animation rejects
|
|
687
|
+
* with an AbortError for code that awaits it, and is quiet otherwise (as a cancelled, unobserved Task in .NET): no
|
|
688
|
+
* "Uncaught (in promise)" in the console for fire-and-forget calls.
|
|
689
|
+
*/
|
|
686
690
|
private RunOwnAnimation;
|
|
687
691
|
FadeToAsync(end: number, ms?: number, easing?: Easing, cancel?: AbortSignal): Promise<void>;
|
|
688
692
|
ScaleToAsync(x: number, y: number, ms?: number, easing?: Easing, cancel?: AbortSignal): Promise<void>;
|
package/dist/core/SkiaControl.js
CHANGED
|
@@ -1802,14 +1802,21 @@ export class SkiaControl {
|
|
|
1802
1802
|
AnimateRangeAsync(callback, start, end, ms = 250, easing = Easing.Linear, cancel) {
|
|
1803
1803
|
return this.AnimateAsync((v) => callback(start + (end - start) * v), undefined, ms, easing, cancel);
|
|
1804
1804
|
}
|
|
1805
|
-
/**
|
|
1805
|
+
/**
|
|
1806
|
+
* One running animation per kind, like the per-property CancellationTokenSources in C#. A replaced animation rejects
|
|
1807
|
+
* with an AbortError for code that awaits it, and is quiet otherwise (as a cancelled, unobserved Task in .NET): no
|
|
1808
|
+
* "Uncaught (in promise)" in the console for fire-and-forget calls.
|
|
1809
|
+
*/
|
|
1806
1810
|
RunOwnAnimation(kind, run, cancel) {
|
|
1807
1811
|
this.ownAnimations.get(kind)?.abort();
|
|
1808
1812
|
const controller = new AbortController();
|
|
1809
1813
|
this.ownAnimations.set(kind, controller);
|
|
1810
1814
|
cancel?.addEventListener("abort", () => controller.abort(), { once: true });
|
|
1811
|
-
|
|
1815
|
+
const done = run(controller.signal).finally(() => { if (this.ownAnimations.get(kind) === controller)
|
|
1812
1816
|
this.ownAnimations.delete(kind); });
|
|
1817
|
+
done.catch((e) => { if (e?.name !== "AbortError")
|
|
1818
|
+
throw e; }); // only the abort is quiet
|
|
1819
|
+
return done;
|
|
1813
1820
|
}
|
|
1814
1821
|
FadeToAsync(end, ms = 250, easing = Easing.Linear, cancel) {
|
|
1815
1822
|
const start = this.Opacity;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/react/index.d.ts
CHANGED
|
@@ -37,6 +37,22 @@ import type { SkiaShape as SkiaShapeCtrl } from "../controls/SkiaShape";
|
|
|
37
37
|
import type { Color, RenderingModeType } from "../core/Types";
|
|
38
38
|
import type { GesturesMode } from "../core/Gestures";
|
|
39
39
|
export { DesignerSourceOf, type DesignerSource } from "./reconciler";
|
|
40
|
+
import { DesignerActions, designerAction } from "../core/DesignerActions";
|
|
41
|
+
export { DesignerActions, designerAction };
|
|
42
|
+
/**
|
|
43
|
+
* A Designer action that exists while the component is mounted (DesignerActions): `path` is its groups and name,
|
|
44
|
+
* slash-separated ("Levels/Level 3"); `run` is called when the designer runs it (always the latest `run` passed). It is
|
|
45
|
+
* registered again when the path or one of `deps` changes. Nothing runs without a designer attached.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useDesignerAction(path: string, run: () => void, deps?: readonly unknown[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* A Designer action as an element (for JSX and NX): declared while it is mounted, `onRun` called when the designer runs
|
|
50
|
+
* it. Draws nothing. `<DesignerAction Name="Levels/Level 3" onRun={() => startLevel(3)} />`
|
|
51
|
+
*/
|
|
52
|
+
export declare function DesignerAction({ Name, onRun }: {
|
|
53
|
+
Name: string;
|
|
54
|
+
onRun: () => void;
|
|
55
|
+
}): null;
|
|
40
56
|
/**
|
|
41
57
|
* Public settable properties of a control become its JSX props, same PascalCase names as C#.
|
|
42
58
|
*
|
|
@@ -128,6 +144,8 @@ export interface CanvasProps {
|
|
|
128
144
|
WillFirstTimeDraw?: CanvasView["WillFirstTimeDraw"];
|
|
129
145
|
/** DrawnView.WasDrawn: after every drawn frame. */
|
|
130
146
|
WasDrawn?: CanvasView["WasDrawn"];
|
|
147
|
+
/** The system light / dark appearance: once when known (at creation), then once per change. */
|
|
148
|
+
SystemThemeChanged?: CanvasView["SystemThemeChanged"];
|
|
131
149
|
}
|
|
132
150
|
/**
|
|
133
151
|
* Opens a popup window (drawnui-cross 6at) whose content is drawn elements, e.g. a menu:
|
|
@@ -143,7 +161,7 @@ export declare function OpenPopupWindow(canvas: CanvasView, content: ReactNode,
|
|
|
143
161
|
* Mirrors DrawnUi Canvas: the bridge between the DOM (react-dom) and the drawn tree (DrawnUi reconciler).
|
|
144
162
|
* Requires Super.UseDrawnUi()...BuildAsync() to have completed.
|
|
145
163
|
*/
|
|
146
|
-
export declare function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKeyboardNavigation, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn }: CanvasProps): import("react").JSX.Element;
|
|
164
|
+
export declare function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKeyboardNavigation, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn, SystemThemeChanged }: CanvasProps): import("react").JSX.Element;
|
|
147
165
|
export type { SkiaControl };
|
|
148
166
|
export * from "../index";
|
|
149
167
|
export * from "./SkiaShell";
|
package/dist/react/index.js
CHANGED
|
@@ -8,6 +8,27 @@ import { SkiaEditor as SkiaEditorCtrl } from "../controls/SkiaEditor";
|
|
|
8
8
|
import { SkiaScroll as SkiaScrollCtrl } from "../controls/SkiaScroll";
|
|
9
9
|
import { createDrawnRoot } from "./reconciler";
|
|
10
10
|
export { DesignerSourceOf } from "./reconciler";
|
|
11
|
+
import { DesignerActions, designerAction } from "../core/DesignerActions";
|
|
12
|
+
export { DesignerActions, designerAction };
|
|
13
|
+
/**
|
|
14
|
+
* A Designer action that exists while the component is mounted (DesignerActions): `path` is its groups and name,
|
|
15
|
+
* slash-separated ("Levels/Level 3"); `run` is called when the designer runs it (always the latest `run` passed). It is
|
|
16
|
+
* registered again when the path or one of `deps` changes. Nothing runs without a designer attached.
|
|
17
|
+
*/
|
|
18
|
+
export function useDesignerAction(path, run, deps = []) {
|
|
19
|
+
const latest = useRef(run);
|
|
20
|
+
latest.current = run;
|
|
21
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
|
+
useEffect(() => designerAction(path, () => latest.current()), [path, ...deps]);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A Designer action as an element (for JSX and NX): declared while it is mounted, `onRun` called when the designer runs
|
|
26
|
+
* it. Draws nothing. `<DesignerAction Name="Levels/Level 3" onRun={() => startLevel(3)} />`
|
|
27
|
+
*/
|
|
28
|
+
export function DesignerAction({ Name, onRun }) {
|
|
29
|
+
useDesignerAction(Name, onRun);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
11
32
|
/** Typed JSX tags resolved by the reconciler Registry. */
|
|
12
33
|
export const SkiaLayout = "SkiaLayout";
|
|
13
34
|
export const SkiaStack = "SkiaStack";
|
|
@@ -99,7 +120,7 @@ export function OpenPopupWindow(canvas, content, anchor, options) {
|
|
|
99
120
|
* Mirrors DrawnUi Canvas: the bridge between the DOM (react-dom) and the drawn tree (DrawnUi reconciler).
|
|
100
121
|
* Requires Super.UseDrawnUi()...BuildAsync() to have completed.
|
|
101
122
|
*/
|
|
102
|
-
export function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKeyboardNavigation, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn }) {
|
|
123
|
+
export function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKeyboardNavigation, children, style, className, ref: viewRef, ContextMenu, WillFirstTimeDraw, WasDrawn, SystemThemeChanged }) {
|
|
103
124
|
const ref = useRef(null);
|
|
104
125
|
const view = useRef(null);
|
|
105
126
|
const root = useRef(null);
|
|
@@ -111,6 +132,7 @@ export function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKe
|
|
|
111
132
|
c.RenderingMode = RenderingMode;
|
|
112
133
|
c.WillFirstTimeDraw = WillFirstTimeDraw;
|
|
113
134
|
c.WasDrawn = WasDrawn;
|
|
135
|
+
c.SystemThemeChanged = SystemThemeChanged;
|
|
114
136
|
});
|
|
115
137
|
view.current = v;
|
|
116
138
|
root.current = createDrawnRoot(v);
|
|
@@ -133,6 +155,7 @@ export function Canvas({ BackgroundColor, RenderingMode, Gestures, ArrowsStartKe
|
|
|
133
155
|
v.ContextMenu = ContextMenu;
|
|
134
156
|
v.WillFirstTimeDraw = WillFirstTimeDraw;
|
|
135
157
|
v.WasDrawn = WasDrawn;
|
|
158
|
+
v.SystemThemeChanged = SystemThemeChanged;
|
|
136
159
|
root.current.render(children);
|
|
137
160
|
});
|
|
138
161
|
// The drawn surface is aria-hidden; the overlay is the accessibility tree (DrawnUi.Blazor pattern). The host takes the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drawnui-react",
|
|
3
|
-
"version": "0.1.0-preview.
|
|
3
|
+
"version": "0.1.0-preview.41",
|
|
4
4
|
"description": "DrawnUi for React: the DrawnUi (.NET) drawn-UI engine in TypeScript on CanvasKit (Skia WASM). Same controls, same PascalCase API as DrawnUi.Net.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nick Kovalsky (AppoMobi)",
|
|
@@ -110,6 +110,11 @@
|
|
|
110
110
|
"check:composite-effect": "node dev/check.mjs dev/check-composite-effect.ts",
|
|
111
111
|
"check:keyboard-contextmenu": "node dev/check.mjs dev/check-keyboard-contextmenu.ts",
|
|
112
112
|
"check:editor-window": "node dev/check.mjs dev/check-editor-window.ts",
|
|
113
|
+
"check:system-theme": "node dev/check.mjs dev/check-system-theme.ts",
|
|
114
|
+
"check:designer-actions": "node dev/check.mjs dev/check-designer-actions.tsx",
|
|
115
|
+
"check:label-span-effects": "node dev/check.mjs dev/check-label-span-effects.ts",
|
|
116
|
+
"check:animator-isolation": "node dev/check.mjs dev/check-animator-isolation.ts",
|
|
117
|
+
"check:quiet-animations": "node dev/check.mjs dev/check-quiet-animations.ts",
|
|
113
118
|
"audit:a11y": "node dev/audit-a11y.mjs",
|
|
114
119
|
"bench:relayout": "node dev/check.mjs dev/bench-relayout.ts",
|
|
115
120
|
"site:extras": "node dev/site-extras.mjs dist/demo",
|