@shopify/klint 0.0.4
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 +36 -0
- package/dist/index.cjs +1179 -0
- package/dist/index.d.ts +810 -0
- package/dist/index.js +1135 -0
- package/dist/plugins/index.cjs +1180 -0
- package/dist/plugins/index.d.ts +731 -0
- package/dist/plugins/index.js +1146 -0
- package/package.json +80 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type KlintCoreFunctionNames = keyof typeof KlintCoreFunctions;
|
|
4
|
+
type KlintCoreFunctions = {
|
|
5
|
+
[K in KlintCoreFunctionNames]: ReturnType<(typeof KlintCoreFunctions)[K]>;
|
|
6
|
+
};
|
|
7
|
+
declare const KlintCoreFunctions: {
|
|
8
|
+
saveCanvas: (ctx: KlintContext) => () => void;
|
|
9
|
+
fullscreen: (ctx: KlintContext) => () => void;
|
|
10
|
+
play: (ctx: KlintContext) => () => void;
|
|
11
|
+
pause: (ctx: KlintContext) => () => void;
|
|
12
|
+
redraw: () => () => void;
|
|
13
|
+
extend: (ctx: KlintContext) => (name: string, data: unknown, enforceReplace?: boolean) => void;
|
|
14
|
+
passImage: () => (element: HTMLImageElement) => HTMLImageElement | null;
|
|
15
|
+
passImages: () => (elements: HTMLImageElement[]) => (HTMLImageElement | null)[];
|
|
16
|
+
saveConfig: (ctx: KlintContexts) => (from?: KlintContexts) => KlintConfig;
|
|
17
|
+
restoreConfig: (ctx: KlintContext) => (config: KlintConfig) => void;
|
|
18
|
+
describe: (ctx: KlintContext) => (description: string) => void;
|
|
19
|
+
createOffscreen: (ctx: KlintContext) => (id: string, width: number, height: number, options?: KlintCanvasOptions, callback?: (ctx: KlintOffscreenContext) => void) => KlintOffscreenContext | HTMLImageElement;
|
|
20
|
+
getOffscreen: (ctx: KlintContext) => (id: string) => KlintOffscreenContext | HTMLImageElement;
|
|
21
|
+
};
|
|
22
|
+
type KlintFunctionNames = keyof typeof KlintFunctions;
|
|
23
|
+
type KlintFunctions = {
|
|
24
|
+
[K in KlintFunctionNames]: ReturnType<(typeof KlintFunctions)[K]>;
|
|
25
|
+
};
|
|
26
|
+
declare const KlintFunctions: {
|
|
27
|
+
readonly extend: (ctx: KlintContexts) => (name: string, data: unknown, enforceReplace?: boolean) => void;
|
|
28
|
+
readonly background: (ctx: KlintContexts) => (color?: string) => void;
|
|
29
|
+
readonly reset: (ctx: KlintContexts) => () => void;
|
|
30
|
+
readonly clear: (ctx: KlintContexts) => () => void;
|
|
31
|
+
readonly fillColor: (ctx: KlintContexts) => (color: string | CanvasGradient) => void;
|
|
32
|
+
readonly strokeColor: (ctx: KlintContexts) => (color: string | CanvasGradient) => void;
|
|
33
|
+
readonly noFill: (ctx: KlintContexts) => () => void;
|
|
34
|
+
readonly noStroke: (ctx: KlintContexts) => () => void;
|
|
35
|
+
readonly strokeWidth: (ctx: KlintContexts) => (width: number) => void;
|
|
36
|
+
readonly strokeJoin: (ctx: KlintContexts) => (join: CanvasLineJoin) => void;
|
|
37
|
+
readonly strokeCap: (ctx: KlintContexts) => (cap: CanvasLineCap) => void;
|
|
38
|
+
readonly push: (ctx: KlintContexts) => () => void;
|
|
39
|
+
readonly pop: (ctx: KlintContexts) => () => void;
|
|
40
|
+
readonly point: (ctx: KlintContexts) => (x: number, y: number) => void;
|
|
41
|
+
readonly checkTransparency: (ctx: KlintContexts) => (toCheck: string) => boolean;
|
|
42
|
+
readonly drawIfVisible: (ctx: KlintContexts) => () => void;
|
|
43
|
+
readonly line: (ctx: KlintContexts) => (x1: number, y1: number, x2: number, y2: number) => void;
|
|
44
|
+
readonly circle: (ctx: KlintContexts) => (x: number, y: number, radius: number, radius2?: number) => void;
|
|
45
|
+
readonly disk: (ctx: KlintContexts) => (x: number, y: number, radius: number, startAngle?: number, endAngle?: number, closed?: boolean) => void;
|
|
46
|
+
readonly rectangle: (ctx: KlintContexts) => (x: number, y: number, width: number, height?: number) => void;
|
|
47
|
+
readonly roundedRectangle: (ctx: KlintContexts) => (x: number, y: number, width: number, radius: number | number[], height?: number) => void;
|
|
48
|
+
readonly polygon: (ctx: KlintContexts) => (x: number, y: number, radius: number, sides: number, radius2?: number, rotation?: number) => void;
|
|
49
|
+
readonly beginShape: (ctx: KlintContexts) => () => void;
|
|
50
|
+
readonly beginContour: (ctx: KlintContexts) => () => void;
|
|
51
|
+
readonly vertex: (ctx: KlintContexts) => (x: number, y: number) => void;
|
|
52
|
+
readonly endContour: (ctx: KlintContexts) => (forceRevert?: boolean) => void;
|
|
53
|
+
readonly endShape: (ctx: KlintContexts) => (close?: boolean) => void;
|
|
54
|
+
readonly gradient: (ctx: KlintContexts) => (x1?: number, y1?: number, x2?: number, y2?: number) => CanvasGradient;
|
|
55
|
+
readonly radialGradient: (ctx: KlintContexts) => (x1?: number, y1?: number, r1?: number, x2?: number, y2?: number, r2?: number) => CanvasGradient;
|
|
56
|
+
readonly conicGradient: (ctx: KlintContexts) => (angle?: number, x1?: number, y1?: number) => CanvasGradient;
|
|
57
|
+
readonly addColorStop: () => (gradient: CanvasGradient, offset?: number, color?: string) => void;
|
|
58
|
+
readonly constrain: () => (val: number, floor: number, ceil: number) => number;
|
|
59
|
+
readonly lerp: (ctx: KlintContexts) => (A: number, B: number, mix: number, bounded?: boolean) => number;
|
|
60
|
+
readonly fract: () => (n: number, mod: number, mode?: "precise" | "fast" | "faster") => number;
|
|
61
|
+
readonly distance: (ctx: KlintContexts) => (x1: number, y1: number, x2: number, y2: number, mode?: "precise" | "fast" | "faster") => number;
|
|
62
|
+
readonly squareDistance: () => (x1: number, y1: number, x2: number, y2: number) => number;
|
|
63
|
+
readonly dot: () => (x1: number, y1: number, x2: number, y2: number) => number;
|
|
64
|
+
readonly remap: (ctx: KlintContexts) => (n: number, A: number, B: number, C: number, D: number, bounded?: boolean) => number;
|
|
65
|
+
readonly textFont: (ctx: KlintContexts) => (font: string) => void;
|
|
66
|
+
readonly textSize: (ctx: KlintContexts) => (size: number) => void;
|
|
67
|
+
readonly textStyle: (ctx: KlintContexts) => (style: string) => void;
|
|
68
|
+
readonly textWeight: (ctx: KlintContexts) => (weight: string) => void;
|
|
69
|
+
readonly textQuality: (ctx: KlintContexts) => (quality?: "speed" | "auto" | "legibility" | "precision") => void;
|
|
70
|
+
readonly textSpacing: (ctx: KlintContexts) => (kind: "letter" | "word", value: number) => void;
|
|
71
|
+
readonly computeTextStyle: (ctx: KlintContexts) => () => void;
|
|
72
|
+
readonly alignText: (ctx: KlintContexts) => (horizontal: CanvasTextAlign, vertical?: CanvasTextBaseline) => void;
|
|
73
|
+
readonly textLeading: (ctx: KlintContexts) => (spacing: number) => void;
|
|
74
|
+
readonly computeFont: (ctx: KlintContexts) => () => void;
|
|
75
|
+
readonly textWidth: (ctx: KlintContexts) => (text: string) => number;
|
|
76
|
+
readonly text: (ctx: KlintContexts) => (text: string | number | undefined, x: number, y: number, maxWidth?: number | undefined) => void;
|
|
77
|
+
readonly image: (ctx: KlintContexts) => (image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | KlintContexts, x: number, y: number, arg3?: number, arg4?: number, arg5?: number, arg6?: number, arg7?: number, arg8?: number) => void;
|
|
78
|
+
readonly loadPixels: (ctx: KlintContexts) => () => ImageData;
|
|
79
|
+
readonly updatePixels: (ctx: KlintContexts) => (pixels: Uint8ClampedArray | number[]) => void;
|
|
80
|
+
readonly readPixels: (ctx: KlintContexts) => (x: number, y: number, w?: number, h?: number) => number[];
|
|
81
|
+
readonly scaleTo: () => (originWidth: number, originHeight: number, destinationWidth: number, destinationHeight: number, cover?: boolean) => number;
|
|
82
|
+
readonly opacity: (ctx: KlintContexts) => (value: number) => void;
|
|
83
|
+
readonly blend: (ctx: KlintContexts) => (blend: GlobalCompositeOperation) => void;
|
|
84
|
+
readonly setCanvasOrigin: (ctx: KlintContexts) => (type: "center" | "corner") => void;
|
|
85
|
+
readonly setImageOrigin: (ctx: KlintContexts) => (type: "center" | "corner") => void;
|
|
86
|
+
readonly setRectOrigin: (ctx: KlintContexts) => (type: "center" | "corner") => void;
|
|
87
|
+
readonly withConfig: (ctx: KlintContexts) => (config: KlintConfig) => void;
|
|
88
|
+
readonly toBase64: (ctx: KlintContexts) => (type?: string, quality?: number) => string;
|
|
89
|
+
readonly saveConfig: (ctx: KlintContexts) => (from?: KlintContexts) => KlintConfig;
|
|
90
|
+
readonly restoreConfig: (ctx: KlintContexts) => (config: KlintConfig) => void;
|
|
91
|
+
readonly resizeCanvas: (ctx: KlintContexts) => (width: number, height: number) => void;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
interface KlintColor {
|
|
95
|
+
colors: readonly string[];
|
|
96
|
+
coral: string;
|
|
97
|
+
brown: string;
|
|
98
|
+
mustard: string;
|
|
99
|
+
crimson: string;
|
|
100
|
+
navy: string;
|
|
101
|
+
sky: string;
|
|
102
|
+
olive: string;
|
|
103
|
+
charcoal: string;
|
|
104
|
+
peach: string;
|
|
105
|
+
rose: string;
|
|
106
|
+
plum: string;
|
|
107
|
+
sage: string;
|
|
108
|
+
drab: string;
|
|
109
|
+
taupe: string;
|
|
110
|
+
midnight: string;
|
|
111
|
+
golden: string;
|
|
112
|
+
orange: string;
|
|
113
|
+
slate: string;
|
|
114
|
+
hex(color: string): string;
|
|
115
|
+
rgb(r: number, g: number, b: number): string;
|
|
116
|
+
rgba(r: number, g: number, b: number, alpha: number): string;
|
|
117
|
+
gray(value: number, alpha?: number): string;
|
|
118
|
+
hsl(h: number, s: number, l: number): string;
|
|
119
|
+
hsla(h: number, s: number, l: number, alpha: number): string;
|
|
120
|
+
lch(l: number, c: number, h: number): string;
|
|
121
|
+
lcha(l: number, c: number, h: number, alpha: number): string;
|
|
122
|
+
lab(l: number, a: number, b: number): string;
|
|
123
|
+
laba(l: number, a: number, b: number, alpha: number): string;
|
|
124
|
+
oklch(l: number, c: number, h: number): string;
|
|
125
|
+
oklcha(l: number, c: number, h: number, alpha: number): string;
|
|
126
|
+
oklab(l: number, a: number, b: number): string;
|
|
127
|
+
oklaba(l: number, a: number, b: number, alpha: number): string;
|
|
128
|
+
blendColors(colorA: string, colorB: string, factor: number, colorMode?: string): string;
|
|
129
|
+
createPalette(baseColor: string, steps?: number): string[];
|
|
130
|
+
complementary(color: string): string;
|
|
131
|
+
analogous(color: string, angle?: number): [string, string];
|
|
132
|
+
triadic(color: string): [string, string];
|
|
133
|
+
saturate(color: string, amount: number): string;
|
|
134
|
+
lighten(color: string, amount: number): string;
|
|
135
|
+
darken(color: string, amount: number): string;
|
|
136
|
+
}
|
|
137
|
+
declare class Color implements KlintColor {
|
|
138
|
+
/**
|
|
139
|
+
* Array of predefined colors in the Klint color palette
|
|
140
|
+
*/
|
|
141
|
+
colors: readonly ["#E84D37", "#7F4C2F", "#EDBC2F", "#BF3034", "#18599D", "#45A7C6", "#8CB151", "#252120", "#ECA088", "#C9B1B8", "#8F3064", "#7B8870", "#C0C180", "#4B423D", "#1A2A65", "#EAA550", "#F17B04", "#404757"];
|
|
142
|
+
get coral(): "#E84D37";
|
|
143
|
+
get brown(): "#7F4C2F";
|
|
144
|
+
get mustard(): "#EDBC2F";
|
|
145
|
+
get crimson(): "#BF3034";
|
|
146
|
+
get navy(): "#18599D";
|
|
147
|
+
get sky(): "#45A7C6";
|
|
148
|
+
get olive(): "#8CB151";
|
|
149
|
+
get charcoal(): "#252120";
|
|
150
|
+
get peach(): "#ECA088";
|
|
151
|
+
get rose(): "#C9B1B8";
|
|
152
|
+
get plum(): "#8F3064";
|
|
153
|
+
get sage(): "#7B8870";
|
|
154
|
+
get drab(): "#C0C180";
|
|
155
|
+
get taupe(): "#4B423D";
|
|
156
|
+
get midnight(): "#1A2A65";
|
|
157
|
+
get golden(): "#EAA550";
|
|
158
|
+
get orange(): "#F17B04";
|
|
159
|
+
get slate(): "#404757";
|
|
160
|
+
/**
|
|
161
|
+
* Ensures a color string has a # prefix
|
|
162
|
+
* @param color - Color string in hex format (with or without #)
|
|
163
|
+
* @returns Hex color string with # prefix
|
|
164
|
+
*/
|
|
165
|
+
hex(color: string): string;
|
|
166
|
+
/**
|
|
167
|
+
* Creates an RGB color string
|
|
168
|
+
* @param r - Red component (0-255)
|
|
169
|
+
* @param g - Green component (0-255)
|
|
170
|
+
* @param b - Blue component (0-255)
|
|
171
|
+
* @returns RGB color string
|
|
172
|
+
*/
|
|
173
|
+
rgb(r: number, g: number, b: number): string;
|
|
174
|
+
/**
|
|
175
|
+
* Creates an RGBA color string
|
|
176
|
+
* @param r - Red component (0-255)
|
|
177
|
+
* @param g - Green component (0-255)
|
|
178
|
+
* @param b - Blue component (0-255)
|
|
179
|
+
* @param alpha - Alpha/opacity value (0-1)
|
|
180
|
+
* @returns RGBA color string
|
|
181
|
+
*/
|
|
182
|
+
rgba(r: number, g: number, b: number, alpha: number): string;
|
|
183
|
+
/**
|
|
184
|
+
* Creates a grayscale color
|
|
185
|
+
* @param value - Gray value (0-255)
|
|
186
|
+
* @param alpha - Optional alpha/opacity value (0-1)
|
|
187
|
+
* @returns RGB or RGBA grayscale color string
|
|
188
|
+
*/
|
|
189
|
+
gray(value: number, alpha?: number): string;
|
|
190
|
+
/**
|
|
191
|
+
* Creates an HSL color string
|
|
192
|
+
* @param h - Hue (0-360)
|
|
193
|
+
* @param s - Saturation percentage (0-100)
|
|
194
|
+
* @param l - Lightness percentage (0-100)
|
|
195
|
+
* @returns HSL color string
|
|
196
|
+
*/
|
|
197
|
+
hsl(h: number, s: number, l: number): string;
|
|
198
|
+
/**
|
|
199
|
+
* Creates an HSLA color string
|
|
200
|
+
* @param h - Hue (0-360)
|
|
201
|
+
* @param s - Saturation percentage (0-100)
|
|
202
|
+
* @param l - Lightness percentage (0-100)
|
|
203
|
+
* @param alpha - Alpha/opacity value (0-1)
|
|
204
|
+
* @returns HSLA color string
|
|
205
|
+
*/
|
|
206
|
+
hsla(h: number, s: number, l: number, alpha: number): string;
|
|
207
|
+
/**
|
|
208
|
+
* Creates an LCH color string
|
|
209
|
+
* @param l - Lightness percentage (0-100)
|
|
210
|
+
* @param c - Chroma value
|
|
211
|
+
* @param h - Hue (0-360)
|
|
212
|
+
* @returns LCH color string
|
|
213
|
+
*/
|
|
214
|
+
lch(l: number, c: number, h: number): string;
|
|
215
|
+
/**
|
|
216
|
+
* Creates an LCH color string with alpha
|
|
217
|
+
* @param l - Lightness percentage (0-100)
|
|
218
|
+
* @param c - Chroma value
|
|
219
|
+
* @param h - Hue (0-360)
|
|
220
|
+
* @param alpha - Alpha/opacity value (0-1)
|
|
221
|
+
* @returns LCH color string with alpha
|
|
222
|
+
*/
|
|
223
|
+
lcha(l: number, c: number, h: number, alpha: number): string;
|
|
224
|
+
/**
|
|
225
|
+
* Creates a LAB color string
|
|
226
|
+
* @param l - Lightness percentage (0-100)
|
|
227
|
+
* @param a - A-axis value (green to red)
|
|
228
|
+
* @param b - B-axis value (blue to yellow)
|
|
229
|
+
* @returns LAB color string
|
|
230
|
+
*/
|
|
231
|
+
lab(l: number, a: number, b: number): string;
|
|
232
|
+
/**
|
|
233
|
+
* Creates a LAB color string with alpha
|
|
234
|
+
* @param l - Lightness percentage (0-100)
|
|
235
|
+
* @param a - A-axis value (green to red)
|
|
236
|
+
* @param b - B-axis value (blue to yellow)
|
|
237
|
+
* @param alpha - Alpha/opacity value (0-1)
|
|
238
|
+
* @returns LAB color string with alpha
|
|
239
|
+
*/
|
|
240
|
+
laba(l: number, a: number, b: number, alpha: number): string;
|
|
241
|
+
/**
|
|
242
|
+
* Creates an OKLCH color string
|
|
243
|
+
* @param l - Lightness value (0-1)
|
|
244
|
+
* @param c - Chroma value
|
|
245
|
+
* @param h - Hue (0-360)
|
|
246
|
+
* @returns OKLCH color string
|
|
247
|
+
*/
|
|
248
|
+
oklch(l: number, c: number, h: number): string;
|
|
249
|
+
/**
|
|
250
|
+
* Creates an OKLCH color string with alpha
|
|
251
|
+
* @param l - Lightness value (0-1)
|
|
252
|
+
* @param c - Chroma value
|
|
253
|
+
* @param h - Hue (0-360)
|
|
254
|
+
* @param alpha - Alpha/opacity value (0-1)
|
|
255
|
+
* @returns OKLCH color string with alpha
|
|
256
|
+
*/
|
|
257
|
+
oklcha(l: number, c: number, h: number, alpha: number): string;
|
|
258
|
+
/**
|
|
259
|
+
* Creates an OKLAB color string
|
|
260
|
+
* @param l - Lightness value (0-1)
|
|
261
|
+
* @param a - A-axis value (green to red)
|
|
262
|
+
* @param b - B-axis value (blue to yellow)
|
|
263
|
+
* @returns OKLAB color string
|
|
264
|
+
*/
|
|
265
|
+
oklab(l: number, a: number, b: number): string;
|
|
266
|
+
/**
|
|
267
|
+
* Creates an OKLAB color string with alpha
|
|
268
|
+
* @param l - Lightness value (0-1)
|
|
269
|
+
* @param a - A-axis value (green to red)
|
|
270
|
+
* @param b - B-axis value (blue to yellow)
|
|
271
|
+
* @param alpha - Alpha/opacity value (0-1)
|
|
272
|
+
* @returns OKLAB color string with alpha
|
|
273
|
+
*/
|
|
274
|
+
oklaba(l: number, a: number, b: number, alpha: number): string;
|
|
275
|
+
/**
|
|
276
|
+
* Blends two colors using CSS color-mix
|
|
277
|
+
* @param colorA - First color
|
|
278
|
+
* @param colorB - Second color
|
|
279
|
+
* @param factor - Blend factor (0-1) where 0 is colorA and 1 is colorB
|
|
280
|
+
* @param colorMode - Color space to blend in (e.g., "oklch", "hsl")
|
|
281
|
+
* @returns Blended color string
|
|
282
|
+
*/
|
|
283
|
+
blendColors(colorA: string, colorB: string, factor: number, colorMode?: string): string;
|
|
284
|
+
/**
|
|
285
|
+
* Creates a palette of colors based on a single base color
|
|
286
|
+
* @param baseColor - The base color to create palette from
|
|
287
|
+
* @param steps - Number of steps in each direction (lighter/darker)
|
|
288
|
+
* @returns Array of color strings forming a palette
|
|
289
|
+
*/
|
|
290
|
+
createPalette(baseColor: string, steps?: number): string[];
|
|
291
|
+
/**
|
|
292
|
+
* Creates a complementary color (opposite on the color wheel)
|
|
293
|
+
* @param color - Base color
|
|
294
|
+
* @returns Complementary color string
|
|
295
|
+
*/
|
|
296
|
+
complementary(color: string): string;
|
|
297
|
+
/**
|
|
298
|
+
* Creates analogous colors (adjacent on the color wheel)
|
|
299
|
+
* @param color - Base color
|
|
300
|
+
* @param angle - Angle of separation in degrees
|
|
301
|
+
* @returns Tuple of two analogous color strings
|
|
302
|
+
*/
|
|
303
|
+
analogous(color: string, angle?: number): [string, string];
|
|
304
|
+
/**
|
|
305
|
+
* Creates a triadic color scheme (three colors evenly spaced on the color wheel)
|
|
306
|
+
* @param color - Base color
|
|
307
|
+
* @returns Tuple of two additional colors to form a triadic scheme
|
|
308
|
+
*/
|
|
309
|
+
triadic(color: string): [string, string];
|
|
310
|
+
/**
|
|
311
|
+
* Increases the saturation of a color
|
|
312
|
+
* @param color - Base color
|
|
313
|
+
* @param amount - Amount to saturate (percentage)
|
|
314
|
+
* @returns Saturated color string
|
|
315
|
+
*/
|
|
316
|
+
saturate(color: string, amount: number): string;
|
|
317
|
+
/**
|
|
318
|
+
* Lightens a color by mixing with white
|
|
319
|
+
* @param color - Base color
|
|
320
|
+
* @param amount - Amount to lighten (percentage)
|
|
321
|
+
* @returns Lightened color string
|
|
322
|
+
*/
|
|
323
|
+
lighten(color: string, amount: number): string;
|
|
324
|
+
/**
|
|
325
|
+
* Darkens a color by mixing with black
|
|
326
|
+
* @param color - Base color
|
|
327
|
+
* @param amount - Amount to darken (percentage)
|
|
328
|
+
* @returns Darkened color string
|
|
329
|
+
*/
|
|
330
|
+
darken(color: string, amount: number): string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
interface KlintEasing {
|
|
334
|
+
context: KlintContexts;
|
|
335
|
+
normalize: (val: number) => number;
|
|
336
|
+
expand: (val: number) => number;
|
|
337
|
+
inout: (val: number, power?: number) => number;
|
|
338
|
+
in: (val: number, power?: number) => number;
|
|
339
|
+
out: (val: number, power?: number) => number;
|
|
340
|
+
overshootIn: (val: number) => number;
|
|
341
|
+
overshootOut: (val: number) => number;
|
|
342
|
+
overshootInOut: (val: number) => number;
|
|
343
|
+
}
|
|
344
|
+
declare class Easing implements KlintEasing {
|
|
345
|
+
context: KlintContexts;
|
|
346
|
+
constructor(ctx: KlintContexts);
|
|
347
|
+
normalize: (val: number) => number;
|
|
348
|
+
expand: (val: number) => number;
|
|
349
|
+
inout: (val: number, power?: number) => number;
|
|
350
|
+
in: (val: number, power?: number) => number;
|
|
351
|
+
out: (val: number, power?: number) => number;
|
|
352
|
+
overshootIn: (val: number) => number;
|
|
353
|
+
overshootOut: (val: number) => number;
|
|
354
|
+
overshootInOut: (val: number) => number;
|
|
355
|
+
bounceOut: (val: number) => number;
|
|
356
|
+
bounceIn: (val: number) => number;
|
|
357
|
+
bounceInOut: (val: number) => number;
|
|
358
|
+
elasticIn: (val: number) => number;
|
|
359
|
+
elasticOut: (val: number) => number;
|
|
360
|
+
elasticInOut: (val: number) => number;
|
|
361
|
+
smoothstep: (val: number, x0?: number, x1?: number) => number;
|
|
362
|
+
log: () => void;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
type SVGFontPaths = Array<Array<Array<{
|
|
366
|
+
x: number;
|
|
367
|
+
y: number;
|
|
368
|
+
}>>>;
|
|
369
|
+
interface FontMetrics {
|
|
370
|
+
fontFamily: string;
|
|
371
|
+
fontWeight: string;
|
|
372
|
+
unitsPerEm: number;
|
|
373
|
+
ascent: number;
|
|
374
|
+
descent: number;
|
|
375
|
+
xHeight: number;
|
|
376
|
+
capHeight: number;
|
|
377
|
+
}
|
|
378
|
+
interface GlyphMetrics {
|
|
379
|
+
name: string;
|
|
380
|
+
unicode: string;
|
|
381
|
+
horizAdvX: number;
|
|
382
|
+
d?: string;
|
|
383
|
+
}
|
|
384
|
+
interface KlintSVGfont {
|
|
385
|
+
context: KlintContexts;
|
|
386
|
+
metrics: FontMetrics;
|
|
387
|
+
glyphs: Map<string, GlyphMetrics>;
|
|
388
|
+
parse(font: string): void;
|
|
389
|
+
}
|
|
390
|
+
interface PointOptions {
|
|
391
|
+
factor: number;
|
|
392
|
+
align?: "center" | "left" | "right";
|
|
393
|
+
center?: "alphabetic" | "middle" | "top";
|
|
394
|
+
letterSpacing?: number;
|
|
395
|
+
treshold?: number;
|
|
396
|
+
}
|
|
397
|
+
interface DisplacementParams {
|
|
398
|
+
point: {
|
|
399
|
+
x: number;
|
|
400
|
+
y: number;
|
|
401
|
+
};
|
|
402
|
+
position: {
|
|
403
|
+
x: number;
|
|
404
|
+
y: number;
|
|
405
|
+
};
|
|
406
|
+
groupIndex: number;
|
|
407
|
+
letterSpacing: number;
|
|
408
|
+
}
|
|
409
|
+
interface DisplacementCallback {
|
|
410
|
+
(params: DisplacementParams): {
|
|
411
|
+
x: number;
|
|
412
|
+
y: number;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
declare class SVGfont implements KlintSVGfont {
|
|
416
|
+
readonly context: KlintContexts;
|
|
417
|
+
readonly metrics: FontMetrics;
|
|
418
|
+
readonly glyphs: Map<string, GlyphMetrics>;
|
|
419
|
+
private font;
|
|
420
|
+
private SCALE;
|
|
421
|
+
private targetXHeight;
|
|
422
|
+
constructor(context: KlintContexts);
|
|
423
|
+
parse(font: string, desiredXHeight?: number): void;
|
|
424
|
+
toJSON(): {
|
|
425
|
+
metrics: FontMetrics;
|
|
426
|
+
glyphs: Record<string, GlyphMetrics>;
|
|
427
|
+
};
|
|
428
|
+
getPoints(text: string, options: PointOptions): Array<Array<Array<{
|
|
429
|
+
x: number;
|
|
430
|
+
y: number;
|
|
431
|
+
}>>>;
|
|
432
|
+
flatten(points: SVGFontPaths, displacement?: DisplacementCallback): Array<{
|
|
433
|
+
x: number;
|
|
434
|
+
y: number;
|
|
435
|
+
}>;
|
|
436
|
+
draw(points: SVGFontPaths, displacement?: DisplacementCallback): void;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
type KlintStateValue = unknown;
|
|
440
|
+
type KlintStateCallback = (key: string, value: KlintStateValue) => void;
|
|
441
|
+
interface KlintState {
|
|
442
|
+
set(key: string, value: KlintStateValue, callback?: KlintStateCallback): void;
|
|
443
|
+
get(key: string, callback?: KlintStateCallback): KlintStateValue;
|
|
444
|
+
has(key: string): boolean;
|
|
445
|
+
delete(key: string, callback?: (key: string) => void): void;
|
|
446
|
+
log(): Map<string, KlintStateValue>;
|
|
447
|
+
}
|
|
448
|
+
declare class State implements KlintState {
|
|
449
|
+
private store;
|
|
450
|
+
set(key: string, value: KlintStateValue, callback?: KlintStateCallback): void;
|
|
451
|
+
get(key: string, callback?: KlintStateCallback): unknown;
|
|
452
|
+
has(key: string): boolean;
|
|
453
|
+
delete(key: string, callback?: (key: string) => void): void;
|
|
454
|
+
log(): Map<string, unknown>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Interface defining a 2D vector with various vector operations
|
|
459
|
+
*/
|
|
460
|
+
interface KlintVector {
|
|
461
|
+
x: number;
|
|
462
|
+
y: number;
|
|
463
|
+
add: (v: KlintVector) => KlintVector;
|
|
464
|
+
sub: (v: KlintVector) => KlintVector;
|
|
465
|
+
mult: (n: number) => KlintVector;
|
|
466
|
+
div: (n: number) => KlintVector;
|
|
467
|
+
rotate: (angle: number) => KlintVector;
|
|
468
|
+
mag: () => number;
|
|
469
|
+
length: () => number;
|
|
470
|
+
dot: (v: KlintVector) => number;
|
|
471
|
+
dist: (v: KlintVector) => number;
|
|
472
|
+
angle: () => number;
|
|
473
|
+
copy: () => KlintVector;
|
|
474
|
+
normalize: () => KlintVector;
|
|
475
|
+
set: (x: number, y: number, z?: number, w?: number) => KlintVector;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* A 2D vector class with various vector operations
|
|
479
|
+
*/
|
|
480
|
+
declare class Vector implements KlintVector {
|
|
481
|
+
/** X-coordinate of the vector */
|
|
482
|
+
x: number;
|
|
483
|
+
/** Y-coordinate of the vector */
|
|
484
|
+
y: number;
|
|
485
|
+
/**
|
|
486
|
+
* Creates a new Vector
|
|
487
|
+
* @param x - X-coordinate (default: 0)
|
|
488
|
+
* @param y - Y-coordinate (default: 0)
|
|
489
|
+
*/
|
|
490
|
+
constructor(x?: number, y?: number);
|
|
491
|
+
/**
|
|
492
|
+
* Adds another vector to this vector
|
|
493
|
+
* @param v - Vector to add
|
|
494
|
+
* @returns This vector after addition
|
|
495
|
+
*/
|
|
496
|
+
add(v: KlintVector): Vector;
|
|
497
|
+
/**
|
|
498
|
+
* Subtracts another vector from this vector
|
|
499
|
+
* @param v - Vector to subtract
|
|
500
|
+
* @returns This vector after subtraction
|
|
501
|
+
*/
|
|
502
|
+
sub(v: KlintVector): Vector;
|
|
503
|
+
/**
|
|
504
|
+
* Multiplies this vector by a scalar
|
|
505
|
+
* @param n - Scalar to multiply by
|
|
506
|
+
* @returns This vector after multiplication
|
|
507
|
+
*/
|
|
508
|
+
mult(n: number): Vector;
|
|
509
|
+
/**
|
|
510
|
+
* Divides this vector by a scalar
|
|
511
|
+
* @param n - Scalar to divide by
|
|
512
|
+
* @returns This vector after division
|
|
513
|
+
*/
|
|
514
|
+
div(n: number): Vector;
|
|
515
|
+
/**
|
|
516
|
+
* Rotates this vector by an angle
|
|
517
|
+
* @param angle - Angle in radians
|
|
518
|
+
* @returns This vector after rotation
|
|
519
|
+
*/
|
|
520
|
+
rotate(angle: number): Vector;
|
|
521
|
+
/**
|
|
522
|
+
* Calculates the magnitude (length) of this vector
|
|
523
|
+
* @returns The magnitude of the vector
|
|
524
|
+
*/
|
|
525
|
+
mag(): number;
|
|
526
|
+
/**
|
|
527
|
+
* Alias for mag() - calculates the length of this vector
|
|
528
|
+
* @returns The length of the vector
|
|
529
|
+
*/
|
|
530
|
+
length(): number;
|
|
531
|
+
/**
|
|
532
|
+
* Calculates the dot product of this vector with another vector
|
|
533
|
+
* @param v - The other vector
|
|
534
|
+
* @returns The dot product
|
|
535
|
+
*/
|
|
536
|
+
dot(v: KlintVector): number;
|
|
537
|
+
/**
|
|
538
|
+
* Calculates the distance between this vector and another vector
|
|
539
|
+
* @param v - The other vector
|
|
540
|
+
* @returns The distance between the vectors
|
|
541
|
+
*/
|
|
542
|
+
dist(v: KlintVector): number;
|
|
543
|
+
/**
|
|
544
|
+
* Calculates the angle of this vector
|
|
545
|
+
* @returns The angle in radians
|
|
546
|
+
*/
|
|
547
|
+
angle(): number;
|
|
548
|
+
/**
|
|
549
|
+
* Creates a copy of this vector
|
|
550
|
+
* @returns A new Vector with the same coordinates
|
|
551
|
+
*/
|
|
552
|
+
copy(): Vector;
|
|
553
|
+
/**
|
|
554
|
+
* Normalizes this vector (sets its magnitude to 1)
|
|
555
|
+
* @returns This vector after normalization
|
|
556
|
+
*/
|
|
557
|
+
normalize(): Vector;
|
|
558
|
+
/**
|
|
559
|
+
* Sets the coordinates of this vector
|
|
560
|
+
* @param x - New X-coordinate
|
|
561
|
+
* @param y - New Y-coordinate
|
|
562
|
+
* @returns This vector after setting coordinates
|
|
563
|
+
*/
|
|
564
|
+
set(x: number, y: number): Vector;
|
|
565
|
+
/**
|
|
566
|
+
* Creates a new vector at a specified angle and distance from a center point
|
|
567
|
+
* @param center - The center point vector
|
|
568
|
+
* @param a - The angle in radians
|
|
569
|
+
* @param r - The radius (distance from center)
|
|
570
|
+
* @returns A new Vector at the calculated position
|
|
571
|
+
*/
|
|
572
|
+
static fromAngle(center: Vector, a: number, r: number): Vector;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
interface KlintTime {
|
|
576
|
+
context: KlintContexts;
|
|
577
|
+
timeline(key: string): KlintTime;
|
|
578
|
+
use(progress: number): KlintTime;
|
|
579
|
+
for(duration: number): KlintTime;
|
|
580
|
+
}
|
|
581
|
+
declare class Time implements KlintTime {
|
|
582
|
+
context: KlintContexts;
|
|
583
|
+
private timelines;
|
|
584
|
+
private currentTimeline;
|
|
585
|
+
private readonly DEFAULT_DURATION;
|
|
586
|
+
private staggers;
|
|
587
|
+
constructor(ctx: KlintContexts);
|
|
588
|
+
timeline(key: string): this;
|
|
589
|
+
use(progress: number): this;
|
|
590
|
+
for(duration: number): this;
|
|
591
|
+
stagger(num: number, offset?: number, callback?: (progress: number, id: number, num: number) => void): this | {
|
|
592
|
+
id: number;
|
|
593
|
+
progress: number;
|
|
594
|
+
}[];
|
|
595
|
+
between(from: number | undefined, to: number | undefined, callback: (progress: number) => void): this;
|
|
596
|
+
progress(): number;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
type TextMetrics = {
|
|
600
|
+
width: number;
|
|
601
|
+
height: number;
|
|
602
|
+
baseline: number;
|
|
603
|
+
};
|
|
604
|
+
interface KlintText {
|
|
605
|
+
context: KlintContexts;
|
|
606
|
+
findTextSize: (text: string, dist: number, estimate?: number, direction?: "x" | "y") => number;
|
|
607
|
+
getTextMetrics: (text: string) => TextMetrics;
|
|
608
|
+
splitTo: (text: string, kind: "letters" | "words" | "lines" | "all", options?: {
|
|
609
|
+
maxWidth?: number;
|
|
610
|
+
lineSpacing?: number;
|
|
611
|
+
letterSpacing?: number;
|
|
612
|
+
wordSpacing?: number;
|
|
613
|
+
}) => Array<{
|
|
614
|
+
char: string;
|
|
615
|
+
x: number;
|
|
616
|
+
y: number;
|
|
617
|
+
metrics: TextMetrics;
|
|
618
|
+
letterIndex?: number;
|
|
619
|
+
wordIndex?: number;
|
|
620
|
+
lineIndex?: number;
|
|
621
|
+
}>;
|
|
622
|
+
circularText: (text: string, radius?: number, fill?: "fill" | "kerned" | "words", offset?: number, arc?: number) => void;
|
|
623
|
+
textBounds: (text: string) => {
|
|
624
|
+
x: number;
|
|
625
|
+
y: number;
|
|
626
|
+
width: number;
|
|
627
|
+
height: number;
|
|
628
|
+
};
|
|
629
|
+
log: () => void;
|
|
630
|
+
}
|
|
631
|
+
declare class Text implements KlintText {
|
|
632
|
+
context: KlintContexts;
|
|
633
|
+
constructor(ctx: KlintContexts);
|
|
634
|
+
findTextSize: (text: string, dist: number, estimate?: number, direction?: "x" | "y") => number;
|
|
635
|
+
getTextMetrics: (text: string) => TextMetrics;
|
|
636
|
+
splitTo: (text: string, kind: "letters" | "words" | "lines" | "all", options?: {
|
|
637
|
+
maxWidth?: number;
|
|
638
|
+
lineSpacing?: number;
|
|
639
|
+
letterSpacing?: number;
|
|
640
|
+
wordSpacing?: number;
|
|
641
|
+
}) => {
|
|
642
|
+
letterIndex?: number | undefined;
|
|
643
|
+
wordIndex?: number | undefined;
|
|
644
|
+
lineIndex?: number | undefined;
|
|
645
|
+
char: string;
|
|
646
|
+
x: number;
|
|
647
|
+
y: number;
|
|
648
|
+
metrics: TextMetrics;
|
|
649
|
+
}[];
|
|
650
|
+
circularText: (text: string, radius?: number, fill?: "fill" | "kerned" | "words", offset?: number, arc?: number) => void;
|
|
651
|
+
textBounds: (text: string) => {
|
|
652
|
+
x: number;
|
|
653
|
+
y: number;
|
|
654
|
+
width: number;
|
|
655
|
+
height: number;
|
|
656
|
+
};
|
|
657
|
+
log: () => void;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
interface KlintThing {
|
|
661
|
+
context: KlintContexts;
|
|
662
|
+
log(): void;
|
|
663
|
+
}
|
|
664
|
+
declare class Thing implements KlintThing {
|
|
665
|
+
context: KlintContexts;
|
|
666
|
+
constructor(ctx: KlintContexts);
|
|
667
|
+
log(): void;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
interface KlintPlugins {
|
|
671
|
+
Color: Color;
|
|
672
|
+
Easing: Easing;
|
|
673
|
+
SVGfont: SVGfont;
|
|
674
|
+
State: State;
|
|
675
|
+
Vector: Vector;
|
|
676
|
+
Time: Time;
|
|
677
|
+
Text: Text;
|
|
678
|
+
Thing: Thing;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
declare const EPSILON = 0.0001;
|
|
682
|
+
type KlintContexts = KlintContext | KlintOffscreenContext;
|
|
683
|
+
interface KlintOffscreenContext extends CanvasRenderingContext2D, KlintFunctions, KlintPlugins {
|
|
684
|
+
width: number;
|
|
685
|
+
height: number;
|
|
686
|
+
__dpr: number;
|
|
687
|
+
__startedShape: boolean;
|
|
688
|
+
__currentShape: number[][] | null;
|
|
689
|
+
__startedContour: boolean;
|
|
690
|
+
__currentContours: number[][][] | null;
|
|
691
|
+
__currentContour: number[][] | null;
|
|
692
|
+
__isReadyToDraw: boolean;
|
|
693
|
+
__isMainContext: boolean;
|
|
694
|
+
__imageOrigin: "corner" | "center";
|
|
695
|
+
__rectangleOrigin: "corner" | "center";
|
|
696
|
+
__canvasOrigin: "corner" | "center";
|
|
697
|
+
__computedTextFont: string;
|
|
698
|
+
__textFont: string;
|
|
699
|
+
__textSize: number;
|
|
700
|
+
__textStyle: string;
|
|
701
|
+
__textWeight: string;
|
|
702
|
+
__textAlignment: {
|
|
703
|
+
horizontal: CanvasTextAlign;
|
|
704
|
+
vertical: CanvasTextBaseline;
|
|
705
|
+
};
|
|
706
|
+
[key: string]: any;
|
|
707
|
+
}
|
|
708
|
+
interface KlintContext extends KlintOffscreenContext, KlintCoreFunctions {
|
|
709
|
+
frame: number;
|
|
710
|
+
time: number;
|
|
711
|
+
deltaTime: number;
|
|
712
|
+
fps: number;
|
|
713
|
+
__lastTargetTime: number;
|
|
714
|
+
__lastRealTime: number;
|
|
715
|
+
__isPlaying: boolean;
|
|
716
|
+
__offscreens: Map<string, KlintOffscreenContext | HTMLImageElement>;
|
|
717
|
+
}
|
|
718
|
+
interface KlintCanvasOptions {
|
|
719
|
+
alpha?: string;
|
|
720
|
+
willreadfrequently?: string;
|
|
721
|
+
autoplay?: string;
|
|
722
|
+
ignoreResize?: string;
|
|
723
|
+
noloop?: string;
|
|
724
|
+
ignoreFunctions?: string;
|
|
725
|
+
static?: string;
|
|
726
|
+
nocanvas?: string;
|
|
727
|
+
fps?: number;
|
|
728
|
+
unsafemode?: string;
|
|
729
|
+
origin?: "corner" | "center";
|
|
730
|
+
}
|
|
731
|
+
type KlintConfig = Partial<Pick<KlintContext, (typeof CONFIG_PROPS)[number]>>;
|
|
732
|
+
interface KlintContextWrapper {
|
|
733
|
+
context: KlintContext | null;
|
|
734
|
+
initCoreContext: (canvas: HTMLCanvasElement, options: KlintCanvasOptions) => KlintContext;
|
|
735
|
+
}
|
|
736
|
+
declare const CONFIG_PROPS: readonly ["lineWidth", "strokeStyle", "lineJoin", "lineCap", "fillStyle", "font", "textAlign", "textBaseline", "textRendering", "wordSpacing", "letterSpacing", "globalAlpha", "globalCompositeOperation", "origin", "transform", "__imageOrigin", "__rectangleOrigin", "__textFont", "__textWeight", "__textStyle", "__textSize", "__textAlignment", "__isPlaying"];
|
|
737
|
+
interface KlintProps {
|
|
738
|
+
context: KlintContextWrapper;
|
|
739
|
+
draw: (ctx: KlintContext) => void;
|
|
740
|
+
setup?: (ctx: KlintContext) => void;
|
|
741
|
+
preload?: (ctx: KlintContext) => Promise<void>;
|
|
742
|
+
options?: KlintCanvasOptions;
|
|
743
|
+
onResize?: (ctx: KlintContext) => void;
|
|
744
|
+
onVisible?: (ctx: KlintContext) => void;
|
|
745
|
+
}
|
|
746
|
+
declare function Klint({ context, setup, draw, options, preload, onVisible, }: KlintProps): React.JSX.Element;
|
|
747
|
+
|
|
748
|
+
interface KlintMouse {
|
|
749
|
+
x: number;
|
|
750
|
+
y: number;
|
|
751
|
+
px: number;
|
|
752
|
+
py: number;
|
|
753
|
+
vx: number;
|
|
754
|
+
vy: number;
|
|
755
|
+
angle: number;
|
|
756
|
+
isPressed: boolean;
|
|
757
|
+
isHover: boolean;
|
|
758
|
+
}
|
|
759
|
+
interface KlintScroll {
|
|
760
|
+
distance: number;
|
|
761
|
+
velocity: number;
|
|
762
|
+
lastTime: number;
|
|
763
|
+
}
|
|
764
|
+
declare function useKlint(): {
|
|
765
|
+
context: {
|
|
766
|
+
context: KlintContext | null;
|
|
767
|
+
initCoreContext: (canvas: HTMLCanvasElement, options: KlintCanvasOptions) => KlintContext;
|
|
768
|
+
};
|
|
769
|
+
useMouse: () => {
|
|
770
|
+
mouse: KlintMouse;
|
|
771
|
+
onClick: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
772
|
+
onMouseIn: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
773
|
+
onMouseOut: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
774
|
+
onMouseDown: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
775
|
+
onMouseUp: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
776
|
+
};
|
|
777
|
+
useScroll: () => {
|
|
778
|
+
scroll: KlintScroll;
|
|
779
|
+
onScroll: (callback: (ctx: KlintContext, scroll: KlintScroll, e: WheelEvent) => void) => (ctx: KlintContext, scroll: KlintScroll, e: WheelEvent) => void;
|
|
780
|
+
};
|
|
781
|
+
useWindow: () => {
|
|
782
|
+
onResize: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
783
|
+
onBlur: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
784
|
+
onFocus: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
785
|
+
onVisibilityChange: (callback: (ctx: KlintContext, isVisible: boolean) => void) => (ctx: KlintContext, isVisible: boolean) => void;
|
|
786
|
+
};
|
|
787
|
+
useImage: () => {
|
|
788
|
+
images: Record<string, HTMLImageElement>;
|
|
789
|
+
loadImage: (key: string, url: string) => Promise<HTMLImageElement>;
|
|
790
|
+
loadImages: (imageMap: Record<string, string>) => Promise<Map<string, HTMLImageElement>>;
|
|
791
|
+
getImage: (key: string) => HTMLImageElement | undefined;
|
|
792
|
+
hasImage: (key: string) => boolean;
|
|
793
|
+
clearImages: () => void;
|
|
794
|
+
};
|
|
795
|
+
togglePlay: (playing?: boolean) => void;
|
|
796
|
+
};
|
|
797
|
+
declare const useProps: <T extends object = Record<string, unknown>>(props: T) => {
|
|
798
|
+
get: <K extends keyof T>(key: K) => T[K];
|
|
799
|
+
has: <K extends keyof T>(key: K) => boolean;
|
|
800
|
+
props: T;
|
|
801
|
+
};
|
|
802
|
+
declare const useStorage: <T extends object = Record<string, unknown>>(initialProps?: T) => {
|
|
803
|
+
get: <K extends keyof T>(key: K) => T[K];
|
|
804
|
+
set: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
805
|
+
has: <K extends keyof T>(key: K) => boolean;
|
|
806
|
+
remove: <K extends keyof T>(key: K) => void;
|
|
807
|
+
store: T;
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
export { CONFIG_PROPS, EPSILON, Klint, KlintCanvasOptions, KlintConfig, KlintContext, KlintContextWrapper, KlintContexts, KlintCoreFunctions, KlintFunctions, KlintMouse, KlintOffscreenContext, KlintProps, KlintScroll, useKlint, useProps, useStorage };
|