drawnui-react 0.1.0-preview.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.
- package/LICENSE +21 -0
- package/PARITY.md +287 -0
- package/README.md +92 -0
- package/SKIPPED.md +107 -0
- package/dist/controls/AnimatedFramesRenderer.d.ts +58 -0
- package/dist/controls/AnimatedFramesRenderer.js +133 -0
- package/dist/controls/GridStructure.d.ts +79 -0
- package/dist/controls/GridStructure.js +403 -0
- package/dist/controls/RefreshIndicator.d.ts +35 -0
- package/dist/controls/RefreshIndicator.js +82 -0
- package/dist/controls/SkiaBackdrop.d.ts +25 -0
- package/dist/controls/SkiaBackdrop.js +80 -0
- package/dist/controls/SkiaButton.d.ts +58 -0
- package/dist/controls/SkiaButton.js +148 -0
- package/dist/controls/SkiaCarousel.d.ts +133 -0
- package/dist/controls/SkiaCarousel.js +603 -0
- package/dist/controls/SkiaCheckbox.d.ts +21 -0
- package/dist/controls/SkiaCheckbox.js +118 -0
- package/dist/controls/SkiaDecoratedGrid.d.ts +15 -0
- package/dist/controls/SkiaDecoratedGrid.js +46 -0
- package/dist/controls/SkiaDrawer.d.ts +46 -0
- package/dist/controls/SkiaDrawer.js +212 -0
- package/dist/controls/SkiaDynamicDrawnCell.d.ts +11 -0
- package/dist/controls/SkiaDynamicDrawnCell.js +17 -0
- package/dist/controls/SkiaEditor.d.ts +163 -0
- package/dist/controls/SkiaEditor.js +803 -0
- package/dist/controls/SkiaGif.d.ts +54 -0
- package/dist/controls/SkiaGif.js +206 -0
- package/dist/controls/SkiaHotspot.d.ts +13 -0
- package/dist/controls/SkiaHotspot.js +36 -0
- package/dist/controls/SkiaImage.d.ts +75 -0
- package/dist/controls/SkiaImage.js +222 -0
- package/dist/controls/SkiaImageTiles.d.ts +27 -0
- package/dist/controls/SkiaImageTiles.js +76 -0
- package/dist/controls/SkiaLabel.d.ts +160 -0
- package/dist/controls/SkiaLabel.js +580 -0
- package/dist/controls/SkiaLayout.d.ts +163 -0
- package/dist/controls/SkiaLayout.js +723 -0
- package/dist/controls/SkiaLottie.d.ts +75 -0
- package/dist/controls/SkiaLottie.js +290 -0
- package/dist/controls/SkiaProgress.d.ts +40 -0
- package/dist/controls/SkiaProgress.js +80 -0
- package/dist/controls/SkiaRadioButton.d.ts +32 -0
- package/dist/controls/SkiaRadioButton.js +157 -0
- package/dist/controls/SkiaRichLabel.d.ts +77 -0
- package/dist/controls/SkiaRichLabel.js +274 -0
- package/dist/controls/SkiaScroll.d.ts +231 -0
- package/dist/controls/SkiaScroll.js +958 -0
- package/dist/controls/SkiaScrollBar.d.ts +56 -0
- package/dist/controls/SkiaScrollBar.js +158 -0
- package/dist/controls/SkiaShaderCarousel.d.ts +67 -0
- package/dist/controls/SkiaShaderCarousel.js +246 -0
- package/dist/controls/SkiaShape.d.ts +63 -0
- package/dist/controls/SkiaShape.js +317 -0
- package/dist/controls/SkiaSlider.d.ts +74 -0
- package/dist/controls/SkiaSlider.js +243 -0
- package/dist/controls/SkiaSprite.d.ts +99 -0
- package/dist/controls/SkiaSprite.js +324 -0
- package/dist/controls/SkiaSpriteSet.d.ts +27 -0
- package/dist/controls/SkiaSpriteSet.js +75 -0
- package/dist/controls/SkiaSvg.d.ts +43 -0
- package/dist/controls/SkiaSvg.js +181 -0
- package/dist/controls/SkiaSwitch.d.ts +26 -0
- package/dist/controls/SkiaSwitch.js +147 -0
- package/dist/controls/SkiaToggle.d.ts +50 -0
- package/dist/controls/SkiaToggle.js +71 -0
- package/dist/controls/SnappingLayout.d.ts +78 -0
- package/dist/controls/SnappingLayout.js +217 -0
- package/dist/controls/TextSpan.d.ts +70 -0
- package/dist/controls/TextSpan.js +76 -0
- package/dist/core/Accessibility.d.ts +104 -0
- package/dist/core/Accessibility.js +150 -0
- package/dist/core/Animators.d.ts +82 -0
- package/dist/core/Animators.js +247 -0
- package/dist/core/Canvas.d.ts +89 -0
- package/dist/core/Canvas.js +328 -0
- package/dist/core/ControlStyle.d.ts +6 -0
- package/dist/core/ControlStyle.js +11 -0
- package/dist/core/Easing.d.ts +13 -0
- package/dist/core/Easing.js +15 -0
- package/dist/core/Gestures.d.ts +74 -0
- package/dist/core/Gestures.js +104 -0
- package/dist/core/ImageEffects.d.ts +29 -0
- package/dist/core/ImageEffects.js +55 -0
- package/dist/core/KeyboardManager.d.ts +25 -0
- package/dist/core/KeyboardManager.js +54 -0
- package/dist/core/ScrollAnimators.d.ts +90 -0
- package/dist/core/ScrollAnimators.js +244 -0
- package/dist/core/SkiaControl.d.ts +401 -0
- package/dist/core/SkiaControl.js +1239 -0
- package/dist/core/SkiaEffect.d.ts +216 -0
- package/dist/core/SkiaEffect.js +571 -0
- package/dist/core/SkiaImageManager.d.ts +43 -0
- package/dist/core/SkiaImageManager.js +122 -0
- package/dist/core/Super.d.ts +61 -0
- package/dist/core/Super.js +178 -0
- package/dist/core/TextInputProxy.d.ts +31 -0
- package/dist/core/TextInputProxy.js +144 -0
- package/dist/core/Types.d.ts +177 -0
- package/dist/core/Types.js +122 -0
- package/dist/core/ViewsAdapter.d.ts +41 -0
- package/dist/core/ViewsAdapter.js +113 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +48 -0
- package/dist/react/SkiaShell.d.ts +144 -0
- package/dist/react/SkiaShell.js +490 -0
- package/dist/react/index.d.ts +110 -0
- package/dist/react/index.js +158 -0
- package/dist/react/reconciler.d.ts +14 -0
- package/dist/react/reconciler.js +160 -0
- package/package.json +60 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import type { Image, Shader } from "canvaskit-wasm";
|
|
2
|
+
import type { DrawingContext, SkiaControl } from "./SkiaControl";
|
|
3
|
+
import { SkiaValueAnimator } from "./Animators";
|
|
4
|
+
import { type ShaderTileMode, SKRect, Thickness } from "./Types";
|
|
5
|
+
/** C# PostRendererEffectUseBackgroud: how a post-renderer sources its input texture. */
|
|
6
|
+
export type PostRendererEffectUseBackground = "Always" | "Once" | "Never";
|
|
7
|
+
export type SkiaFilterMode = "Linear" | "Nearest";
|
|
8
|
+
export type SkiaMipmapMode = "None" | "Nearest" | "Linear";
|
|
9
|
+
/**
|
|
10
|
+
* C# CachedTexture: a control's rasterized output and the canvas rect it was rasterized over. Texel (0,0) sits at the
|
|
11
|
+
* top-left of Bounds (a cache image); a whole-surface snapshot sets `Origin` = the canvas point its texel (0,0) is at,
|
|
12
|
+
* so the texture shader is translated accordingly. Shaders sample textures in texel space (fragCoord - iOffset).
|
|
13
|
+
*/
|
|
14
|
+
export interface CachedTexture {
|
|
15
|
+
Image: Image;
|
|
16
|
+
Bounds: SKRect;
|
|
17
|
+
Origin?: {
|
|
18
|
+
X: number;
|
|
19
|
+
Y: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mirrors DrawnUi SkiaEffect: something attached to a control through `VisualEffects`. `Update()` re-renders the
|
|
24
|
+
* parent (C# invalidates the parent's cache and redraws), `GetEffectMargin` reports what it paints outside the box.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SkiaEffect {
|
|
27
|
+
/** Set by Attach/Dettach. */
|
|
28
|
+
Parent?: SkiaControl;
|
|
29
|
+
Tag?: string;
|
|
30
|
+
Attach(parent: SkiaControl): void;
|
|
31
|
+
Dettach(): void;
|
|
32
|
+
/** Cached resources must be dropped here, not on the next draw (C# contract). */
|
|
33
|
+
protected OnDisposing(): void;
|
|
34
|
+
Dispose(): void;
|
|
35
|
+
/** Effect parameters changed: the parent's cache is re-recorded and the composition redrawn (C# Parent.Update). */
|
|
36
|
+
Update(): void;
|
|
37
|
+
/** Extra space in PIXELS painted beyond the parent's DrawingRect. */
|
|
38
|
+
GetEffectMargin(_scale: number): Thickness;
|
|
39
|
+
get NeedApply(): boolean;
|
|
40
|
+
}
|
|
41
|
+
/** C# ISkiaGestureProcessor: an effect that receives the parent's gestures before its children; return non-null to consume. */
|
|
42
|
+
export interface ISkiaGestureProcessor {
|
|
43
|
+
ProcessGestures(args: import("./Gestures").SkiaGesturesParameters, apply: import("./Gestures").GestureEventProcessingInfo): SkiaControl | null;
|
|
44
|
+
}
|
|
45
|
+
/** C# IPostRendererEffect: draws over the parent's output after it was painted / from its cache. */
|
|
46
|
+
export interface IPostRendererEffect {
|
|
47
|
+
Render(ctx: DrawingContext): void;
|
|
48
|
+
UseBackground: PostRendererEffectUseBackground;
|
|
49
|
+
AquiredBackground: boolean;
|
|
50
|
+
NeedApply: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare function IsPostRendererEffect(e: SkiaEffect): e is SkiaEffect & IPostRendererEffect;
|
|
53
|
+
/**
|
|
54
|
+
* Mirrors DrawnUi SkiaShaderEffect: an SkSL fragment shader (`ShaderSource` url or inline `ShaderCode`, optionally
|
|
55
|
+
* wrapped by a `ShaderTemplate` at `//script-goes-here`) drawn over the parent control with the Shadertoy-style
|
|
56
|
+
* uniforms `iResolution`, `iImageResolution`, `iTime`, `iOffset`, `iMouse` and the parent's own output as the
|
|
57
|
+
* `iImage1` texture (`UseBackground` Always / Once / Never, `AutoCreateInputTexture`). Extra uniforms through
|
|
58
|
+
* `SetUniform`, extra textures by overriding `CreateTexturesUniforms`. Uniforms not declared by the shader are
|
|
59
|
+
* skipped, declared texture children that are not supplied sample transparent.
|
|
60
|
+
*/
|
|
61
|
+
export declare class SkiaShaderEffect extends SkiaEffect implements IPostRendererEffect {
|
|
62
|
+
/** Url of the .sksl file (fetched once, compiled once per text). */
|
|
63
|
+
get ShaderSource(): string;
|
|
64
|
+
set ShaderSource(v: string);
|
|
65
|
+
/** Inline SkSL, used when ShaderSource is not set. */
|
|
66
|
+
get ShaderCode(): string;
|
|
67
|
+
set ShaderCode(v: string);
|
|
68
|
+
/** Url of a template .sksl whose `//script-goes-here` is replaced by the shader. */
|
|
69
|
+
get ShaderTemplate(): string;
|
|
70
|
+
set ShaderTemplate(v: string);
|
|
71
|
+
/** Snapshot the surface being drawn (true) or the on-screen one. */
|
|
72
|
+
UseContext: boolean;
|
|
73
|
+
/** Create the `iImage1` texture from the parent's output; false for output-only shaders. */
|
|
74
|
+
AutoCreateInputTexture: boolean;
|
|
75
|
+
UseBackground: PostRendererEffectUseBackground;
|
|
76
|
+
AquiredBackground: boolean;
|
|
77
|
+
BlendMode: string;
|
|
78
|
+
FilterMode: SkiaFilterMode;
|
|
79
|
+
MipmapMode: SkiaMipmapMode;
|
|
80
|
+
/** Tile mode of the input textures. */
|
|
81
|
+
TileMode: ShaderTileMode;
|
|
82
|
+
/** Set every Render from the frame time (seconds); can be driven manually. */
|
|
83
|
+
TimeSeconds: number;
|
|
84
|
+
/** Shadertoy iMouse.xy, pixels relative to the control. */
|
|
85
|
+
MouseCurrent: {
|
|
86
|
+
X: number;
|
|
87
|
+
Y: number;
|
|
88
|
+
};
|
|
89
|
+
/** Shadertoy iMouse.zw: where a drag started, zero = not dragging. */
|
|
90
|
+
MouseInitial: {
|
|
91
|
+
X: number;
|
|
92
|
+
Y: number;
|
|
93
|
+
};
|
|
94
|
+
/** Custom uniforms by name (float arrays sized like the SkSL type), merged on top of the standard ones. */
|
|
95
|
+
readonly Uniforms: Map<string, number[]>;
|
|
96
|
+
/** Compilation errors land here; without a handler they are logged. */
|
|
97
|
+
OnCompilationError?: (effect: SkiaShaderEffect, error: string) => void;
|
|
98
|
+
/** Code as loaded/assembled for the last compile. */
|
|
99
|
+
LoadedCode: string;
|
|
100
|
+
private shaderSource;
|
|
101
|
+
private shaderCode;
|
|
102
|
+
private shaderTemplate;
|
|
103
|
+
private compiled?;
|
|
104
|
+
private compiledKey;
|
|
105
|
+
private uniformSlots;
|
|
106
|
+
private uniformFloats;
|
|
107
|
+
private childNames;
|
|
108
|
+
private hasNewShader;
|
|
109
|
+
private compileFailed;
|
|
110
|
+
private loading?;
|
|
111
|
+
private loadedSource?;
|
|
112
|
+
private loadedTemplate?;
|
|
113
|
+
private textureShader?;
|
|
114
|
+
private frozen?;
|
|
115
|
+
private frozenOwned;
|
|
116
|
+
private paint?;
|
|
117
|
+
get IsCompiled(): boolean;
|
|
118
|
+
/** C# NeedApply && IsCompiled; the compile itself is attempted here (sync once the source is loaded) so a fresh effect gets its first chance before the render decides between the plain blit and the shader. */
|
|
119
|
+
get NeedApply(): boolean;
|
|
120
|
+
/** Loads (async, once) and compiles (sync) when needed; true when a compiled effect exists. */
|
|
121
|
+
EnsureCompiled(): boolean;
|
|
122
|
+
SetUniform(name: string, ...values: number[]): this;
|
|
123
|
+
ReleaseFrozenSnapshot(): void;
|
|
124
|
+
private DisposeImage;
|
|
125
|
+
protected ApplyShaderSource(): void;
|
|
126
|
+
/** Snapshot of what the parent painted (C# CreateSnapshot): the surface the pixels are on, mapped through its origin. */
|
|
127
|
+
protected CreateSnapshot(ctx: DrawingContext, destination: SKRect): CachedTexture | undefined;
|
|
128
|
+
/** C# GetPrimaryTexture: the parent's cache, a frozen snapshot (Once) or nothing (Never). */
|
|
129
|
+
protected GetPrimaryTexture(_ctx: DrawingContext, _destination: SKRect): CachedTexture | undefined;
|
|
130
|
+
/** Image → shader with the effect's sampling, translated so texel (0,0) = bounds top-left; cached per image. */
|
|
131
|
+
protected CreateTextureShader(texture: CachedTexture): Shader;
|
|
132
|
+
/** Texture children by name (C# CreateTexturesUniforms). Override to add `iImage2` etc. */
|
|
133
|
+
protected CreateTexturesUniforms(_ctx: DrawingContext, _destination: SKRect, primaryTexture?: Shader): Record<string, Shader | undefined>;
|
|
134
|
+
/** Standard uniforms + `Uniforms` (C# CreateUniforms). Override, call super and add your own with `Set`. */
|
|
135
|
+
protected CreateUniforms(destination: SKRect, textureBounds: SKRect | undefined, values: Float32Array): void;
|
|
136
|
+
/** Writes a uniform by name into the flat float array; undeclared names are skipped like C#. */
|
|
137
|
+
protected Set(values: Float32Array, name: string, ...v: number[]): void;
|
|
138
|
+
private static FetchText;
|
|
139
|
+
/** Fetches ShaderSource / ShaderTemplate when needed; true when the code is ready to compile. */
|
|
140
|
+
private EnsureLoaded;
|
|
141
|
+
protected SendError(error: string): void;
|
|
142
|
+
/** The template wrapping the code; subclasses supply a default (ShaderTransitionEffect). */
|
|
143
|
+
protected GetTemplate(): string;
|
|
144
|
+
protected CompileShader(): void;
|
|
145
|
+
/** Builds this frame's shader (C# CreateShader). */
|
|
146
|
+
CreateShader(ctx: DrawingContext, source: CachedTexture | undefined): {
|
|
147
|
+
shader: Shader;
|
|
148
|
+
children: Shader[];
|
|
149
|
+
} | undefined;
|
|
150
|
+
/** IPostRendererEffect: draws the shader over ctx.Destination (C# Render). */
|
|
151
|
+
Render(ctx: DrawingContext): void;
|
|
152
|
+
protected OnDisposing(): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Mirrors DrawnUi ShaderDoubleTexturesEffect: two input textures. `iImage1` comes from `ControlFrom`'s cache or a
|
|
156
|
+
* `PrimarySource` image, `iImage2` from `ControlTo`'s cache or a `SecondarySource` image (both resized to the parent
|
|
157
|
+
* box like C#), else from the parent as usual.
|
|
158
|
+
*/
|
|
159
|
+
export declare class ShaderDoubleTexturesEffect extends SkiaShaderEffect {
|
|
160
|
+
get ControlFrom(): SkiaControl | undefined;
|
|
161
|
+
set ControlFrom(v: SkiaControl | undefined);
|
|
162
|
+
get ControlTo(): SkiaControl | undefined;
|
|
163
|
+
set ControlTo(v: SkiaControl | undefined);
|
|
164
|
+
get PrimarySource(): string;
|
|
165
|
+
set PrimarySource(v: string);
|
|
166
|
+
get SecondarySource(): string;
|
|
167
|
+
set SecondarySource(v: string);
|
|
168
|
+
private controlFrom?;
|
|
169
|
+
private controlTo?;
|
|
170
|
+
private primarySource;
|
|
171
|
+
private secondarySource;
|
|
172
|
+
private primaryImage?;
|
|
173
|
+
private secondaryImage?;
|
|
174
|
+
private resizedPrimary?;
|
|
175
|
+
private resizedSecondary?;
|
|
176
|
+
private secondary?;
|
|
177
|
+
private LoadTexture;
|
|
178
|
+
/** C# Resize*LoadedBitmap: the file texture spans the parent box. */
|
|
179
|
+
private Resized;
|
|
180
|
+
protected GetPrimaryTexture(ctx: DrawingContext, destination: SKRect): CachedTexture | undefined;
|
|
181
|
+
/** C# GetSecondaryTexture: ControlTo's cache image or the resized SecondarySource, as a clamped shader. */
|
|
182
|
+
protected GetSecondaryTexture(ctx: DrawingContext): Shader | undefined;
|
|
183
|
+
private secondaryImageRef?;
|
|
184
|
+
protected CreateTexturesUniforms(ctx: DrawingContext, destination: SKRect, primaryTexture?: Shader): Record<string, Shader | undefined>;
|
|
185
|
+
protected OnDisposing(): void;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Mirrors DrawnUi ShaderTransitionEffect: `iImage1` = from, `iImage2` = to, plus `progress` (0..1) and `ratio`
|
|
189
|
+
* (width / height) uniforms; without a ShaderTemplate the gl-transitions adapter `DefaultTemplate` wraps a
|
|
190
|
+
* `transition(vec2 uv)` function using `getFromColor` / `getToColor`.
|
|
191
|
+
*/
|
|
192
|
+
export declare class ShaderTransitionEffect extends ShaderDoubleTexturesEffect {
|
|
193
|
+
static readonly DefaultTemplate = "\nuniform float ratio; // width / height\nuniform float progress; // 0.0 - 1.0\nuniform shader iImage1; // Texture\nuniform shader iImage2; // Texture for backside\nuniform float2 iOffset; // Top-left corner of DrawingRect\nuniform float2 iResolution; // Viewport resolution (pixels)\nuniform float2 iImageResolution; // iImage1 resolution (pixels)\nuniform float iTime; // Shader playback time (s)\nuniform float4 iMouse; // Mouse drag pos=.xy Click pos=.zw (pixels)\n\n//In GLSL, the texture coordinate origin is at the bottom-left corner,\n//whereas in SKSL the origin is at the top-left corner.\n\nvec4 getFromColor(vec2 uv) {\n vec2 adjustedUV = float2(uv.x, 1.0 - uv.y) * iImageResolution;\n return iImage1.eval(adjustedUV);\n}\n\nvec4 getToColor(vec2 uv) {\n vec2 adjustedUV = float2(uv.x, 1.0 - uv.y) * iImageResolution;\n return iImage2.eval(adjustedUV);\n}\n\n//script-goes-here\n";
|
|
194
|
+
/** 0 = fully ControlFrom, 1 = fully ControlTo; call Update() after changing. */
|
|
195
|
+
Progress: number;
|
|
196
|
+
protected GetTemplate(): string;
|
|
197
|
+
protected CreateUniforms(destination: SKRect, textureBounds: SKRect | undefined, values: Float32Array): void;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Mirrors DrawnUi AnimatedShaderEffect: a `progress` 0→1 uniform driven by an animator over `DurationMs`
|
|
201
|
+
* (2500) plus `iCenter` (normalized). `Play()` restarts, `Completed` fires when it finishes, `Stop()` is silent.
|
|
202
|
+
*/
|
|
203
|
+
export declare class AnimatedShaderEffect extends SkiaShaderEffect {
|
|
204
|
+
Center: {
|
|
205
|
+
X: number;
|
|
206
|
+
Y: number;
|
|
207
|
+
};
|
|
208
|
+
DurationMs: number;
|
|
209
|
+
Progress: number;
|
|
210
|
+
Completed?: (effect: AnimatedShaderEffect) => void;
|
|
211
|
+
protected Animator?: SkiaValueAnimator;
|
|
212
|
+
Play(): void;
|
|
213
|
+
Stop(): void;
|
|
214
|
+
protected CreateUniforms(destination: SKRect, textureBounds: SKRect | undefined, values: Float32Array): void;
|
|
215
|
+
protected OnDisposing(): void;
|
|
216
|
+
}
|