@shopify/klint 0.0.9 → 0.0.92
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/dist/elements/index.cjs +946 -0
- package/dist/{plugins → elements}/index.d.cts +3 -78
- package/dist/elements/index.d.ts +656 -0
- package/dist/elements/index.js +913 -0
- package/dist/index.cjs +941 -17
- package/dist/index.d.cts +7 -81
- package/dist/index.d.ts +7 -81
- package/dist/index.js +941 -17
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -362,80 +362,6 @@ declare class Easing implements KlintEasing {
|
|
|
362
362
|
log: () => void;
|
|
363
363
|
}
|
|
364
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
365
|
type KlintStateValue = unknown;
|
|
440
366
|
type KlintStateCallback = (key: string, value: KlintStateValue) => void;
|
|
441
367
|
interface KlintState {
|
|
@@ -667,10 +593,9 @@ declare class Thing implements KlintThing {
|
|
|
667
593
|
log(): void;
|
|
668
594
|
}
|
|
669
595
|
|
|
670
|
-
interface
|
|
596
|
+
interface KlintElements {
|
|
671
597
|
Color: Color;
|
|
672
598
|
Easing: Easing;
|
|
673
|
-
SVGfont: SVGfont;
|
|
674
599
|
State: State;
|
|
675
600
|
Vector: Vector;
|
|
676
601
|
Time: Time;
|
|
@@ -680,7 +605,7 @@ interface KlintPlugins {
|
|
|
680
605
|
|
|
681
606
|
declare const EPSILON = 0.0001;
|
|
682
607
|
type KlintContexts = KlintContext | KlintOffscreenContext;
|
|
683
|
-
interface KlintOffscreenContext extends CanvasRenderingContext2D, KlintFunctions,
|
|
608
|
+
interface KlintOffscreenContext extends CanvasRenderingContext2D, KlintFunctions, KlintElements {
|
|
684
609
|
width: number;
|
|
685
610
|
height: number;
|
|
686
611
|
__dpr: number;
|
|
@@ -766,7 +691,7 @@ declare function useKlint(): {
|
|
|
766
691
|
context: KlintContext | null;
|
|
767
692
|
initCoreContext: (canvas: HTMLCanvasElement, options: KlintCanvasOptions) => KlintContext;
|
|
768
693
|
};
|
|
769
|
-
|
|
694
|
+
KlintMouse: () => {
|
|
770
695
|
mouse: KlintMouse;
|
|
771
696
|
onClick: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
772
697
|
onMouseIn: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
@@ -774,17 +699,17 @@ declare function useKlint(): {
|
|
|
774
699
|
onMouseDown: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
775
700
|
onMouseUp: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
776
701
|
};
|
|
777
|
-
|
|
702
|
+
KlintScroll: () => {
|
|
778
703
|
scroll: KlintScroll;
|
|
779
704
|
onScroll: (callback: (ctx: KlintContext, scroll: KlintScroll, e: WheelEvent) => void) => (ctx: KlintContext, scroll: KlintScroll, e: WheelEvent) => void;
|
|
780
705
|
};
|
|
781
|
-
|
|
706
|
+
KlintWindow: () => {
|
|
782
707
|
onResize: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
783
708
|
onBlur: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
784
709
|
onFocus: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
785
710
|
onVisibilityChange: (callback: (ctx: KlintContext, isVisible: boolean) => void) => (ctx: KlintContext, isVisible: boolean) => void;
|
|
786
711
|
};
|
|
787
|
-
|
|
712
|
+
KlintImage: () => {
|
|
788
713
|
images: Record<string, HTMLImageElement>;
|
|
789
714
|
loadImage: (key: string, url: string) => Promise<HTMLImageElement>;
|
|
790
715
|
loadImages: (imageMap: Record<string, string>) => Promise<Map<string, HTMLImageElement>>;
|
|
@@ -793,6 +718,7 @@ declare function useKlint(): {
|
|
|
793
718
|
clearImages: () => void;
|
|
794
719
|
};
|
|
795
720
|
togglePlay: (playing?: boolean) => void;
|
|
721
|
+
useDev: () => void;
|
|
796
722
|
};
|
|
797
723
|
declare const useProps: <T extends object = Record<string, unknown>>(props: T) => {
|
|
798
724
|
get: <K extends keyof T>(key: K) => T[K];
|
package/dist/index.d.ts
CHANGED
|
@@ -362,80 +362,6 @@ declare class Easing implements KlintEasing {
|
|
|
362
362
|
log: () => void;
|
|
363
363
|
}
|
|
364
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
365
|
type KlintStateValue = unknown;
|
|
440
366
|
type KlintStateCallback = (key: string, value: KlintStateValue) => void;
|
|
441
367
|
interface KlintState {
|
|
@@ -667,10 +593,9 @@ declare class Thing implements KlintThing {
|
|
|
667
593
|
log(): void;
|
|
668
594
|
}
|
|
669
595
|
|
|
670
|
-
interface
|
|
596
|
+
interface KlintElements {
|
|
671
597
|
Color: Color;
|
|
672
598
|
Easing: Easing;
|
|
673
|
-
SVGfont: SVGfont;
|
|
674
599
|
State: State;
|
|
675
600
|
Vector: Vector;
|
|
676
601
|
Time: Time;
|
|
@@ -680,7 +605,7 @@ interface KlintPlugins {
|
|
|
680
605
|
|
|
681
606
|
declare const EPSILON = 0.0001;
|
|
682
607
|
type KlintContexts = KlintContext | KlintOffscreenContext;
|
|
683
|
-
interface KlintOffscreenContext extends CanvasRenderingContext2D, KlintFunctions,
|
|
608
|
+
interface KlintOffscreenContext extends CanvasRenderingContext2D, KlintFunctions, KlintElements {
|
|
684
609
|
width: number;
|
|
685
610
|
height: number;
|
|
686
611
|
__dpr: number;
|
|
@@ -766,7 +691,7 @@ declare function useKlint(): {
|
|
|
766
691
|
context: KlintContext | null;
|
|
767
692
|
initCoreContext: (canvas: HTMLCanvasElement, options: KlintCanvasOptions) => KlintContext;
|
|
768
693
|
};
|
|
769
|
-
|
|
694
|
+
KlintMouse: () => {
|
|
770
695
|
mouse: KlintMouse;
|
|
771
696
|
onClick: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
772
697
|
onMouseIn: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
@@ -774,17 +699,17 @@ declare function useKlint(): {
|
|
|
774
699
|
onMouseDown: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
775
700
|
onMouseUp: (callback: (ctx: KlintContext, e: MouseEvent) => void) => (ctx: KlintContext, e: MouseEvent) => void;
|
|
776
701
|
};
|
|
777
|
-
|
|
702
|
+
KlintScroll: () => {
|
|
778
703
|
scroll: KlintScroll;
|
|
779
704
|
onScroll: (callback: (ctx: KlintContext, scroll: KlintScroll, e: WheelEvent) => void) => (ctx: KlintContext, scroll: KlintScroll, e: WheelEvent) => void;
|
|
780
705
|
};
|
|
781
|
-
|
|
706
|
+
KlintWindow: () => {
|
|
782
707
|
onResize: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
783
708
|
onBlur: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
784
709
|
onFocus: (callback: (ctx: KlintContext) => void) => (ctx: KlintContext) => void;
|
|
785
710
|
onVisibilityChange: (callback: (ctx: KlintContext, isVisible: boolean) => void) => (ctx: KlintContext, isVisible: boolean) => void;
|
|
786
711
|
};
|
|
787
|
-
|
|
712
|
+
KlintImage: () => {
|
|
788
713
|
images: Record<string, HTMLImageElement>;
|
|
789
714
|
loadImage: (key: string, url: string) => Promise<HTMLImageElement>;
|
|
790
715
|
loadImages: (imageMap: Record<string, string>) => Promise<Map<string, HTMLImageElement>>;
|
|
@@ -793,6 +718,7 @@ declare function useKlint(): {
|
|
|
793
718
|
clearImages: () => void;
|
|
794
719
|
};
|
|
795
720
|
togglePlay: (playing?: boolean) => void;
|
|
721
|
+
useDev: () => void;
|
|
796
722
|
};
|
|
797
723
|
declare const useProps: <T extends object = Record<string, unknown>>(props: T) => {
|
|
798
724
|
get: <K extends keyof T>(key: K) => T[K];
|