@figliolia/chalk-animation 1.0.1 → 1.0.3

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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/Animation.js +25 -36
  3. package/dist/cjs/ChalkAnimation.js +26 -21
  4. package/dist/cjs/Decor.js +18 -0
  5. package/dist/cjs/Effects.js +28 -3
  6. package/dist/cjs/FrameRate.js +26 -0
  7. package/dist/cjs/InstanceTracker.js +4 -2
  8. package/dist/cjs/__tests__/ChalkAnimation.test.js +95 -0
  9. package/dist/cjs/package.json +2 -2
  10. package/dist/mjs/Animation.js +20 -33
  11. package/dist/mjs/ChalkAnimation.js +26 -23
  12. package/dist/mjs/Decor.js +14 -0
  13. package/dist/mjs/Effects.js +27 -2
  14. package/dist/mjs/FrameRate.js +24 -0
  15. package/dist/mjs/InstanceTracker.js +2 -2
  16. package/dist/mjs/__tests__/ChalkAnimation.test.js +93 -0
  17. package/dist/mjs/index.js +2 -2
  18. package/dist/mjs/package.json +3 -2
  19. package/dist/types/Animation.d.ts +16 -0
  20. package/dist/types/ChalkAnimation.d.ts +21 -0
  21. package/dist/types/Decor.d.ts +5 -0
  22. package/dist/{mjs → types}/Effects.d.ts +2 -2
  23. package/dist/types/FrameRate.d.ts +11 -0
  24. package/dist/{mjs → types}/InstanceTracker.d.ts +1 -0
  25. package/dist/types/__tests__/ChalkAnimation.test.d.ts +1 -0
  26. package/dist/{cjs → types}/index.d.ts +1 -0
  27. package/dist/types/types.d.ts +6 -0
  28. package/package.json +7 -8
  29. package/src/Animation.ts +20 -34
  30. package/src/ChalkAnimation.ts +25 -26
  31. package/src/Decor.ts +24 -0
  32. package/src/Effects.ts +14 -6
  33. package/src/FrameRate.ts +28 -0
  34. package/src/InstanceTracker.ts +5 -3
  35. package/src/__tests__/ChalkAnimation.test.ts +108 -0
  36. package/src/index.ts +1 -0
  37. package/src/types.ts +14 -0
  38. package/dist/cjs/Animation.d.ts +0 -20
  39. package/dist/cjs/ChalkAnimation.d.ts +0 -10
  40. package/dist/cjs/Effects.d.ts +0 -13
  41. package/dist/cjs/InstanceTracker.d.ts +0 -14
  42. package/dist/cjs/animateString.d.ts +0 -2
  43. package/dist/cjs/animateString.js +0 -18
  44. package/dist/cjs/types.d.ts +0 -1
  45. package/dist/mjs/Animation.d.ts +0 -20
  46. package/dist/mjs/ChalkAnimation.d.ts +0 -10
  47. package/dist/mjs/animateString.d.ts +0 -2
  48. package/dist/mjs/animateString.js +0 -14
  49. package/dist/mjs/index.d.ts +0 -4
  50. package/dist/mjs/types.d.ts +0 -1
  51. package/src/animateString.ts +0 -15
package/src/types.ts CHANGED
@@ -1 +1,15 @@
1
1
  export type AnimationFN = (str: string, frame: number) => string;
2
+
3
+ export type AnimationName =
4
+ | "rainbow"
5
+ | "pulse"
6
+ | "glitch"
7
+ | "radar"
8
+ | "neon"
9
+ | "karaoke";
10
+
11
+ export type MethodLike<T = any> = (...args: any[]) => T;
12
+
13
+ export type MethodKeys<T, R = any> = keyof {
14
+ [K in keyof T as Required<T>[K] extends MethodLike<R> ? K : never]: T[K];
15
+ };
@@ -1,20 +0,0 @@
1
- import type { AnimationFN } from "./types";
2
- import { InstanceTracker } from "./InstanceTracker";
3
- export declare class Animation extends InstanceTracker {
4
- effect: any;
5
- lines: number;
6
- speed: number;
7
- delay: number;
8
- text: string[];
9
- stopped: boolean;
10
- currentFrame: number;
11
- initialized: boolean;
12
- controller: ReturnType<typeof setTimeout> | null;
13
- constructor(effect: AnimationFN, str: string, delay?: number, speed?: number);
14
- render(): void;
15
- frame(): string;
16
- replace(str: string): this;
17
- stop(): this;
18
- start(): this;
19
- private clearFrames;
20
- }
@@ -1,10 +0,0 @@
1
- import { Animation } from "./Animation";
2
- export declare class ChalkAnimation {
3
- static rainbow(str: string, speed?: number): Animation;
4
- static pulse(str: string, speed?: number): Animation;
5
- static glitch(str: string, speed?: number): Animation;
6
- static radar(str: string, speed?: number): Animation;
7
- static neon(str: string, speed?: number): Animation;
8
- static karaoke(str: string, speed?: number): Animation;
9
- static clearAllAnimations(): void;
10
- }
@@ -1,13 +0,0 @@
1
- export declare class Effects {
2
- static longHsv: {
3
- interpolation: string;
4
- hsvSpin: string;
5
- };
6
- static glitchChars: string;
7
- static rainbow(str: string, frame: number): string;
8
- static pulse(str: string, frame: number): string;
9
- static glitch(str: string, frame: number): string;
10
- static radar(str: string, frame: number): string;
11
- static neon(str: string, frame: number): string;
12
- static karaoke(str: string, frame: number): string;
13
- }
@@ -1,14 +0,0 @@
1
- import { AutoIncrementingID } from "@figliolia/event-emitter";
2
- import type { Animation } from "./Animation";
3
- export declare class InstanceTracker {
4
- ID: string;
5
- static readonly LOG: {
6
- (...data: any[]): void;
7
- (message?: any, ...optionalParams: any[]): void;
8
- };
9
- static IDs: AutoIncrementingID;
10
- static bucket: Map<string, Animation>;
11
- constructor();
12
- get instance(): Animation;
13
- static clearAll(): void;
14
- }
@@ -1,2 +0,0 @@
1
- import { Animation } from "./Animation";
2
- export declare function animateString(effect: any, str: string, delay?: number, speed?: number): Animation;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.animateString = void 0;
4
- const Animation_1 = require("./Animation");
5
- function animateString(effect, str, delay = 0, speed = 0) {
6
- if (!speed || speed <= 0) {
7
- throw new Error("Expected `speed` to be an number greater than 0");
8
- }
9
- const animation = new Animation_1.Animation(effect, str, delay, speed);
10
- // setTimeout(() => {
11
- // if (!animation.stopped) {
12
- // animation.start();
13
- // }
14
- // }, delay / speed);
15
- animation.start();
16
- return animation;
17
- }
18
- exports.animateString = animateString;
@@ -1 +0,0 @@
1
- export type AnimationFN = (str: string, frame: number) => string;
@@ -1,20 +0,0 @@
1
- import type { AnimationFN } from "./types";
2
- import { InstanceTracker } from "./InstanceTracker";
3
- export declare class Animation extends InstanceTracker {
4
- effect: any;
5
- lines: number;
6
- speed: number;
7
- delay: number;
8
- text: string[];
9
- stopped: boolean;
10
- currentFrame: number;
11
- initialized: boolean;
12
- controller: ReturnType<typeof setTimeout> | null;
13
- constructor(effect: AnimationFN, str: string, delay?: number, speed?: number);
14
- render(): void;
15
- frame(): string;
16
- replace(str: string): this;
17
- stop(): this;
18
- start(): this;
19
- private clearFrames;
20
- }
@@ -1,10 +0,0 @@
1
- import { Animation } from "./Animation";
2
- export declare class ChalkAnimation {
3
- static rainbow(str: string, speed?: number): Animation;
4
- static pulse(str: string, speed?: number): Animation;
5
- static glitch(str: string, speed?: number): Animation;
6
- static radar(str: string, speed?: number): Animation;
7
- static neon(str: string, speed?: number): Animation;
8
- static karaoke(str: string, speed?: number): Animation;
9
- static clearAllAnimations(): void;
10
- }
@@ -1,2 +0,0 @@
1
- import { Animation } from "./Animation";
2
- export declare function animateString(effect: any, str: string, delay?: number, speed?: number): Animation;
@@ -1,14 +0,0 @@
1
- import { Animation } from "./Animation";
2
- export function animateString(effect, str, delay = 0, speed = 0) {
3
- if (!speed || speed <= 0) {
4
- throw new Error("Expected `speed` to be an number greater than 0");
5
- }
6
- const animation = new Animation(effect, str, delay, speed);
7
- // setTimeout(() => {
8
- // if (!animation.stopped) {
9
- // animation.start();
10
- // }
11
- // }, delay / speed);
12
- animation.start();
13
- return animation;
14
- }
@@ -1,4 +0,0 @@
1
- export { ChalkAnimation } from "./ChalkAnimation";
2
- export type { Animation } from "./Animation";
3
- export type { InstanceTracker } from "./InstanceTracker";
4
- export * from "./types";
@@ -1 +0,0 @@
1
- export type AnimationFN = (str: string, frame: number) => string;
@@ -1,15 +0,0 @@
1
- import { Animation } from "./Animation";
2
-
3
- export function animateString(effect: any, str: string, delay = 0, speed = 0) {
4
- if (!speed || speed <= 0) {
5
- throw new Error("Expected `speed` to be an number greater than 0");
6
- }
7
- const animation = new Animation(effect, str, delay, speed);
8
- // setTimeout(() => {
9
- // if (!animation.stopped) {
10
- // animation.start();
11
- // }
12
- // }, delay / speed);
13
- animation.start();
14
- return animation;
15
- }