drawnui-react 0.1.0-preview.41 → 0.1.0-preview.42

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 (40) hide show
  1. package/README.md +47 -0
  2. package/SKIPPED.md +2 -2
  3. package/dist/controls/SkiaEditor.js +5 -4
  4. package/dist/controls/SkiaImage.d.ts +5 -0
  5. package/dist/controls/SkiaImage.js +32 -5
  6. package/dist/controls/SkiaLabel.d.ts +17 -2
  7. package/dist/controls/SkiaLabel.js +38 -12
  8. package/dist/controls/SkiaLabelFps.d.ts +0 -3
  9. package/dist/controls/SkiaLabelFps.js +1 -11
  10. package/dist/controls/SkiaLayout.js +33 -2
  11. package/dist/controls/SkiaScroll.d.ts +17 -0
  12. package/dist/controls/SkiaScroll.js +51 -6
  13. package/dist/controls/SkiaShell.d.ts +282 -0
  14. package/dist/controls/SkiaShell.js +972 -0
  15. package/dist/controls/SkiaSprite.js +5 -1
  16. package/dist/core/Accessibility.d.ts +12 -0
  17. package/dist/core/Accessibility.js +62 -14
  18. package/dist/core/Canvas.d.ts +31 -8
  19. package/dist/core/Canvas.js +85 -18
  20. package/dist/core/Gestures.d.ts +1 -0
  21. package/dist/core/Props.d.ts +11 -0
  22. package/dist/core/Props.js +44 -0
  23. package/dist/core/SkiaControl.d.ts +21 -2
  24. package/dist/core/SkiaControl.js +55 -11
  25. package/dist/core/SkiaEffect.d.ts +12 -1
  26. package/dist/core/SkiaEffect.js +35 -8
  27. package/dist/core/SkiaImageManager.d.ts +100 -18
  28. package/dist/core/SkiaImageManager.js +309 -64
  29. package/dist/core/Styles.js +7 -1
  30. package/dist/core/Super.d.ts +2 -0
  31. package/dist/core/Super.js +2 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +1 -0
  34. package/dist/react/SkiaShell.d.ts +8 -74
  35. package/dist/react/SkiaShell.js +163 -514
  36. package/dist/react/index.d.ts +5 -0
  37. package/dist/react/index.js +8 -4
  38. package/dist/react/reconciler.d.ts +12 -0
  39. package/dist/react/reconciler.js +22 -46
  40. package/package.json +19 -2
@@ -37,6 +37,8 @@ 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
+ /** JSX tag name -> engine class: add-on packages register their controls here. */
41
+ export { Registry } from "./reconciler";
40
42
  import { DesignerActions, designerAction } from "../core/DesignerActions";
41
43
  export { DesignerActions, designerAction };
42
44
  /**
@@ -65,6 +67,8 @@ export declare function DesignerAction({ Name, onRun }: {
65
67
  type PropsOf<T> = Partial<{
66
68
  [K in keyof T as T[K] extends Function ? (undefined extends T[K] ? K : never) : K extends "Children" | "Views" | "Parent" | "Spans" | "GridStructure" | "AccessibilityId" | "IsAccessibilityElement" | "HasTransform" | "RenderTransformMatrix" | "RenderObjectPrevious" | "LastMeasuredIndex" | "ItemsInsertedAtStart" | "UsingControlStyle" | "Track" | "Thumb" | "FrameOn" | "FrameOff" | "ViewCheckOn" | "ViewOn" | "ViewText" | "Ratio" | "StartThumbX" | "EndThumbX" | "SnapPoints" | "CurrentPosition" | "CurrentSnap" | "ContentOffsetBounds" | "InTransition" | "CanAnimate" | "MaxIndex" | "ChildrenTotal" | "IsAtStart" | "IsAtEnd" | "ScrollProgress" | "ScrollAmount" | "TransitionProgress" | "LastIndex" | "ChildrenCount" | "Horizontal" | "Animator" | "Animation" | "IsPlaying" | "PlayWhenAvailable" | "TotalFrames" | "HasEffects" | "IsDisposed" | "Label" | "IsMultiline" | "HasSelection" | "LayoutVersion" | "LinesCount" | "MeasuredLineHeight" | "Focused" | "SpriteSheet" | "FrameWidth" | "FrameHeight" | "DurationMs" | "FrameDurationMs" | "CurrentSprite" | "Rects" | "HasTapHandler" | "HasDecorations" | "LinesCount" | "Superview" | "DrawingRect" | "MeasuredSize" | "RenderingScale" | "NeedMeasure" | "_superview" | "HitBoxAuto" | "TotalDown" | "TotalTapped" | "TouchDown" | "PostAnimators" | "LoadedSource" | "IsLoading" | "DisplayRect" | "AspectScale" | "Content" | "ContentSize" | "ContentOffsetBounds" | "OverscrollDistance" | "OverScrolled" | "IsUserPanning" | "IsUserFocused" | "IsScrolling" | "IsTemplated" | "FirstVisibleIndex" | "LastVisibleIndex" | "DebugString" | "ChildrenFactory" | "ContextIndex" | "RenderObject" | "UsingCacheType" | "TransitionEffect" | "TransitionFromIndex" | "TransitionToIndex" | "EffectPostRenderers" | "CachedImage" | "ImageBitmap" | "ShouldSubmitOnEnter" | "Header" | "Footer" | "RefreshIndicator" | "ScrollBar" | "ScrollBarHorizontal" | "IsRunning" | "VisibleRatio" | "CurrentIndex" | "LastCompositeRecord" | "DirtyChildrenInternal" | "IsRenderingWithComposition" | "IsHovered" ? never : K]: T[K] extends Thickness ? ThicknessValue : T[K];
67
69
  }>;
70
+ /** The JSX props of an engine control class (for add-on packages that declare their own tags). */
71
+ export type DrawnProps<T> = PropsOf<T>;
68
72
  /** `ref` receives the engine control instance (react-reconciler getPublicInstance). */
69
73
  type LeafProps<T> = PropsOf<T> & {
70
74
  ref?: Ref<T>;
@@ -165,3 +169,4 @@ export declare function Canvas({ BackgroundColor, RenderingMode, Gestures, Arrow
165
169
  export type { SkiaControl };
166
170
  export * from "../index";
167
171
  export * from "./SkiaShell";
172
+ export { SkiaShell } from "./SkiaShell";
@@ -8,6 +8,8 @@ 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
+ /** JSX tag name -> engine class: add-on packages register their controls here. */
12
+ export { Registry } from "./reconciler";
11
13
  import { DesignerActions, designerAction } from "../core/DesignerActions";
12
14
  export { DesignerActions, designerAction };
13
15
  /**
@@ -277,11 +279,12 @@ function AccessibilityOverlay({ view }) {
277
279
  // the browser scrolls an overflow:hidden container to reveal a focused child; the overlay must stay pinned to the canvas
278
280
  const pin = (e) => { e.currentTarget.scrollTop = 0; e.currentTarget.scrollLeft = 0; };
279
281
  // an active modal (drawnui-cross 6av): the overlay itself is the dialog (role, name, aria-modal) around the dialog's
280
- // controls, which are its elements; aria-modal on a separate element of this flat overlay would hide them
282
+ // controls, which are its elements; aria-modal on a separate element of this flat overlay would hide them. A nameless
283
+ // modal (a popup host) takes the role and name of the dialog inside it: one dialog for readers (6bs)
281
284
  const modal = view.AccessibilityManager.ActiveModal;
282
- const modalNode = modal ? nodes.find((n) => n.Source === modal) : undefined;
285
+ const modalNode = modal ? view.AccessibilityManager.ActiveModalNode : undefined;
283
286
  return (_jsxs("div", { className: "drawnui-a11y-overlay", onScroll: pin, ref: overlayRef, role: modal ? modalNode?.Role ?? "dialog" : undefined, "aria-label": modalNode?.Label, "aria-modal": modal ? true : undefined, children: [_jsx("style", { children: A11Y_CSS }), nodes.map((n) => {
284
- if (n === modalNode)
287
+ if (n === modalNode || (modal && n.Source === modal))
285
288
  return null;
286
289
  const pos = { left: n.Rect.Left, top: n.Rect.Top, width: n.Rect.Width, height: n.Rect.Height };
287
290
  const activate = () => SkiaAccessibilityManager.Activate(n.Source);
@@ -331,5 +334,6 @@ function AccessibilityOverlay({ view }) {
331
334
  // One import for apps: React tags + every engine type (Colors, Thickness, Super, gestures, animators...).
332
335
  // The engine `Canvas` class is shadowed by the React <Canvas> above; reach it via "drawnui-react/core".
333
336
  export * from "../index";
334
- // React-level SkiaShell (routes, back nav bar, useShell())
337
+ // SkiaShell with JSX pages, popups and modals (useShell()); the engine SkiaShell is in "drawnui-react/core"
335
338
  export * from "./SkiaShell";
339
+ export { SkiaShell } from "./SkiaShell";
@@ -24,6 +24,18 @@ export interface DesignerSource {
24
24
  * from the fiber's stack only when asked). Undefined in production builds and for controls made outside React.
25
25
  */
26
26
  export declare function DesignerSourceOf(control: SkiaControl): DesignerSource | undefined;
27
+ /**
28
+ * A portal target other than the canvas: JSX rendered into a place an engine control made for it (the shell's pages,
29
+ * popups, modals). Its top-level controls are handed to it in order.
30
+ */
31
+ export interface DrawnContainer {
32
+ appendChild(child: SkiaControl): void;
33
+ insertBefore(child: SkiaControl, before: SkiaControl): void;
34
+ removeChild(child: SkiaControl): void;
35
+ clear(): void;
36
+ }
37
+ /** Renders `children` into `container` from inside another React tree (contexts reach it), as react-dom createPortal. */
38
+ export declare function createDrawnPortal(children: ReactNode, container: DrawnContainer, key?: string): ReactNode;
27
39
  /** Creates a React root whose container is an engine Canvas. */
28
40
  export declare function createDrawnRoot(canvas: Canvas): {
29
41
  render(children: ReactNode): void;
@@ -1,7 +1,7 @@
1
1
  import { createContext } from "react";
2
2
  import Reconciler from "react-reconciler";
3
3
  import { ConcurrentRoot, DefaultEventPriority } from "react-reconciler/constants";
4
- import { SkiaControl } from "../core/SkiaControl";
4
+ import { ApplyProps as applyProps } from "../core/Props";
5
5
  import { SkiaLabel } from "../controls/SkiaLabel";
6
6
  import { TextSpan } from "../controls/TextSpan";
7
7
  import { SkiaRichLabel } from "../controls/SkiaRichLabel";
@@ -36,46 +36,6 @@ export const Registry = {
36
36
  SkiaLayout, SkiaStack, SkiaRow, SkiaLayer, SkiaWrap, SkiaMasonry, SkiaGrid, SkiaDecoratedGrid, SkiaBackdrop, SkiaEditor, SkiaSprite, SkiaSpriteSet, SkiaLabel, SkiaLabelFps, SkiaRichLabel, TextSpan, SkiaHotspot, SkiaButton, SkiaImage, SkiaImageTiles, SkiaSvg, SkiaLottie, SkiaGif, SkiaScroll, SkiaScrollBar, RefreshIndicator, SkiaShape, SkiaFrame,
37
37
  SkiaSwitch, SkiaCheckbox, SkiaRadioButton, SkiaProgress, SkiaSlider, SkiaCarousel, SkiaShaderCarousel, SkiaDrawer,
38
38
  };
39
- const SKIP = new Set(["children", "key", "ref"]);
40
- /** Props that change how the subtree is composited, not what it contains: repaint, keep caches (DrawnUi RedrawCanvas). */
41
- const REPAINT_ONLY = new Set(["TranslationX", "TranslationY", "TranslationZ", "Rotation", "RotationX", "RotationY", "RotationZ", "ScaleX", "ScaleY", "Scale", "SkewX", "SkewY", "AnchorX", "AnchorY", "Opacity"]);
42
- /** Props that change only how a control looks, never its size (C# NeedDraw): an ImageComposite above redraws only its area. */
43
- const isDrawOnly = (k) => k.endsWith("Color") || k === "FillGradient" || k === "StrokeGradient";
44
- /**
45
- * Assigns changed props straight onto the control (same names as the C# properties).
46
- * Handler props (functions) are swapped without invalidating: inline arrows change identity every render.
47
- */
48
- function applyProps(inst, prev, next) {
49
- let changed = false, repaint = false, layout = false;
50
- for (const k in next) {
51
- if (SKIP.has(k) || (prev && prev[k] === next[k]))
52
- continue;
53
- inst[k] = next[k];
54
- if (typeof next[k] === "function")
55
- continue;
56
- if (REPAINT_ONLY.has(k))
57
- repaint = true;
58
- else {
59
- changed = true;
60
- if (!isDrawOnly(k))
61
- layout = true;
62
- }
63
- }
64
- if (prev)
65
- for (const k in prev)
66
- if (!SKIP.has(k) && !(k in next)) {
67
- inst[k] = new inst.constructor()[k];
68
- changed = layout = true;
69
- }
70
- if (changed && prev) {
71
- if (layout || !(inst instanceof SkiaControl))
72
- inst.Update();
73
- else
74
- inst.UpdateDraw();
75
- }
76
- else if (repaint && prev)
77
- inst.RepaintComposition?.();
78
- }
79
39
  // DrawnUI Designer, dev builds only: the React fiber that created each control (DesignerSourceOf). Vite replaces
80
40
  // import.meta.env.DEV, false in production builds, so the map and its use compile away; without Vite it is undefined
81
41
  // and nothing is kept.
@@ -113,6 +73,7 @@ function appendChild(parent, child) {
113
73
  child.IsChildrenItem = true;
114
74
  parent.AddSubView(child);
115
75
  }
76
+ const IsDrawnContainer = (c) => typeof c.appendChild === "function";
116
77
  // Record<string, unknown> absorbs members that react-reconciler 0.33 reads but @types 0.32 does not declare yet.
117
78
  const hostConfig = {
118
79
  supportsMutation: true,
@@ -151,11 +112,22 @@ const hostConfig = {
151
112
  parent.InsertSubView(parent instanceof SkiaLabel ? parent.Spans.indexOf(before) : 0, child);
152
113
  },
153
114
  removeChild: (parent, child) => parent.RemoveSubView(child),
154
- appendChildToContainer: (canvas, child) => { canvas.Content = child; },
155
- insertInContainerBefore: (canvas, child) => { canvas.Content = child; },
156
- removeChildFromContainer: (canvas, child) => { if (canvas.Content === child)
157
- canvas.Content = undefined; },
158
- clearContainer: (canvas) => { canvas.Content = undefined; },
115
+ appendChildToContainer: (c, child) => { if (IsDrawnContainer(c))
116
+ c.appendChild(child);
117
+ else
118
+ c.Content = child; },
119
+ insertInContainerBefore: (c, child, before) => { if (IsDrawnContainer(c))
120
+ c.insertBefore(child, before);
121
+ else
122
+ c.Content = child; },
123
+ removeChildFromContainer: (c, child) => { if (IsDrawnContainer(c))
124
+ c.removeChild(child);
125
+ else if (c.Content === child)
126
+ c.Content = undefined; },
127
+ clearContainer: (c) => { if (IsDrawnContainer(c))
128
+ c.clear();
129
+ else
130
+ c.Content = undefined; },
159
131
  commitUpdate: (inst, _type, prev, next) => applyProps(inst, prev, next),
160
132
  commitTextUpdate: noop,
161
133
  commitMount: noop,
@@ -202,6 +174,10 @@ const hostConfig = {
202
174
  };
203
175
  const reconciler = Reconciler(hostConfig);
204
176
  const onError = (e) => console.error("DrawnUi.React:", e);
177
+ /** Renders `children` into `container` from inside another React tree (contexts reach it), as react-dom createPortal. */
178
+ export function createDrawnPortal(children, container, key) {
179
+ return reconciler.createPortal(children, container, null, key);
180
+ }
205
181
  /** Creates a React root whose container is an engine Canvas. */
206
182
  export function createDrawnRoot(canvas) {
207
183
  const container = reconciler.createContainer(canvas, ConcurrentRoot, null, false, null, "", onError, onError, onError, noop, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawnui-react",
3
- "version": "0.1.0-preview.41",
3
+ "version": "0.1.0-preview.42",
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)",
@@ -65,19 +65,23 @@
65
65
  "check:animation": "node dev/check.mjs dev/check-animation.ts",
66
66
  "check:shape": "node dev/check.mjs dev/check-shape.ts",
67
67
  "check:label": "node dev/check.mjs dev/check-label.ts",
68
+ "check:label-baseline": "node dev/check.mjs dev/check-label-baseline.ts",
68
69
  "check:image": "node dev/check.mjs dev/check-image.ts",
69
70
  "check:longpress": "node dev/check.mjs dev/check-longpress.ts",
70
71
  "check:hidden": "node dev/check.mjs dev/check-hidden.ts",
71
72
  "check:shell": "node dev/check.mjs dev/check-shell.tsx",
73
+ "check:shell-core": "node dev/check.mjs dev/check-shell-core.ts",
72
74
  "check:wheel-routing": "node dev/check.mjs dev/check-wheel-routing.ts",
73
75
  "check:velocity": "node dev/check.mjs dev/check-velocity.ts",
74
76
  "check:scroll-index": "node dev/check.mjs dev/check-scroll-index.ts",
77
+ "check:scroll-chaining": "node dev/check.mjs dev/check-scroll-chaining.ts",
75
78
  "check:culling": "node dev/check.mjs dev/check-culling.ts",
76
79
  "check:responds": "node dev/check.mjs dev/check-responds.ts",
77
80
  "check:3d": "node dev/check.mjs dev/check-3d.ts",
78
81
  "check:gesture-owner": "node dev/check.mjs dev/check-gesture-owner.ts",
79
82
  "check:shader-cache": "node dev/check.mjs dev/check-shader-cache.ts",
80
83
  "check:shader-content": "node dev/check.mjs dev/check-shader-content.ts",
84
+ "check:shader-time": "node dev/check.mjs dev/check-shader-time.ts",
81
85
  "check:backdrop": "node dev/check.mjs dev/check-backdrop.ts",
82
86
  "check:masonry": "node dev/check.mjs dev/check-masonry.ts",
83
87
  "check:thickness": "node dev/check.mjs dev/check-thickness.ts",
@@ -85,11 +89,13 @@
85
89
  "check:masonry-keys": "node dev/check.mjs dev/check-masonry-keys.ts",
86
90
  "check:carousel-swipe": "node dev/check.mjs dev/check-carousel-swipe.ts",
87
91
  "check:editor-focus": "node dev/check.mjs dev/check-editor-focus.ts",
92
+ "check:editor-lines": "node dev/check.mjs dev/check-editor-lines.ts",
88
93
  "check:shaping": "node dev/check.mjs dev/check-shaping.ts",
89
94
  "check:editor-rtl": "node dev/check.mjs dev/check-editor-rtl.ts",
90
95
  "check:label-direction": "node dev/check.mjs dev/check-label-direction.ts",
91
96
  "check:stack-fit": "node dev/check.mjs dev/check-stack-fit.ts",
92
97
  "check:label-reuse": "node dev/check.mjs dev/check-label-reuse.ts",
98
+ "check:layout-rules": "node dev/check.mjs dev/check-layout-rules.ts",
93
99
  "check:popups-tooltips": "node dev/check.mjs dev/check-popups-tooltips.ts",
94
100
  "check:carousel-loop": "node dev/check.mjs dev/check-carousel-loop.ts",
95
101
  "check:release": "node dev/check.mjs dev/check-release.tsx",
@@ -103,6 +109,7 @@
103
109
  "check:shader-carousel-interrupted": "node dev/check.mjs dev/check-shader-carousel-interrupted.ts",
104
110
  "check:shell-modal": "node dev/check.mjs dev/check-shell-modal.tsx",
105
111
  "check:multitouch": "node dev/check.mjs dev/check-multitouch.ts",
112
+ "check:openlink-nonstop": "node dev/check.mjs dev/check-openlink-nonstop.ts",
106
113
  "check:scroll-size": "node dev/check.mjs dev/check-scroll-size.ts",
107
114
  "check:ripple-primary": "node dev/check.mjs dev/check-ripple-primary.ts",
108
115
  "check:stack-margins": "node dev/check.mjs dev/check-stack-margins.ts",
@@ -112,15 +119,25 @@
112
119
  "check:editor-window": "node dev/check.mjs dev/check-editor-window.ts",
113
120
  "check:system-theme": "node dev/check.mjs dev/check-system-theme.ts",
114
121
  "check:designer-actions": "node dev/check.mjs dev/check-designer-actions.tsx",
122
+ "check:dialog-a11y": "node dev/check.mjs dev/check-dialog-a11y.ts",
115
123
  "check:label-span-effects": "node dev/check.mjs dev/check-label-span-effects.ts",
116
124
  "check:animator-isolation": "node dev/check.mjs dev/check-animator-isolation.ts",
125
+ "check:a11y-opacity": "node dev/check.mjs dev/check-a11y-opacity.ts",
117
126
  "check:quiet-animations": "node dev/check.mjs dev/check-quiet-animations.ts",
127
+ "check:skew-sign": "node dev/check.mjs dev/check-skew-sign.ts",
128
+ "check:styles-code": "node dev/check.mjs dev/check-styles-code.ts",
129
+ "check:composite-removed": "node dev/check.mjs dev/check-composite-removed.ts",
118
130
  "audit:a11y": "node dev/audit-a11y.mjs",
119
131
  "bench:relayout": "node dev/check.mjs dev/bench-relayout.ts",
120
132
  "site:extras": "node dev/site-extras.mjs dist/demo",
121
133
  "build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
122
134
  "prepublishOnly": "npm run build:lib",
123
- "preview": "vite preview samples/demo"
135
+ "preview": "vite preview samples/demo",
136
+ "check:add3d": "node dev/check.mjs dev/check-add3d.ts",
137
+ "check:parent-independent": "node dev/check.mjs dev/check-parent-independent.ts",
138
+ "check:update-while-recording": "node dev/check.mjs dev/check-update-while-recording.ts",
139
+ "check:image-cache": "node dev/check.mjs dev/check-image-cache.ts",
140
+ "browser:canvas-contexts": "node dev/check-canvas-contexts.mjs"
124
141
  },
125
142
  "peerDependencies": {
126
143
  "playwright-core": ">=1.40",