Skip to content

Commit

Permalink
Merge pull request #69 from skgrush/types-declaration
Browse files Browse the repository at this point in the history
Add TypeScript declarations
  • Loading branch information
tholman authored Feb 7, 2024
2 parents 8f56580 + eb132a9 commit eea2e60
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
"version": "1.0.13",
"main": "./dist/cjs.cjs",
"module": "./dist/esm.js",
"types": "./types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./types.d.ts",
"require": "./dist/cjs.cjs",
"import": "./dist/esm.js"
}
},
"files": [
"dist"
"dist",
"types.d.ts"
],
"publishConfig": {
"access": "public",
Expand Down
89 changes: 89 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export type CursorEffectResult = {
destroy(): void;
}

type DefaultOptions = {
readonly element?: HTMLElement;
}

export type BubbleCursorOptions = {
} & DefaultOptions;

export type CharacterCursorOptions = {
readonly characters?: readonly string[];
readonly colors?: readonly string[];
readonly cursorOffset?: { readonly x: number; readonly y: number };
readonly font?: string;
readonly characterLifeSpanFunction?: () => number;
readonly initialCharacterVelocityFunction?: () => { readonly x: number; readonly y: number };
readonly characterScalingFunction?: () => number;
readonly characterNewRotationDegreesFunction?: (age: number, lifeSpan: number) => number;
} & DefaultOptions;

export type ClockCursorOptions = {
readonly dateColor?: string;
readonly faceColor?: string;
readonly secondsColor?: string;
readonly minutesColor?: string;
readonly hoursColor?: string;
} & DefaultOptions;

export type EmojiCursorOptions = {
readonly emoji?: readonly string[];
} & DefaultOptions;

export type FairyDustCursorOptions = {
colors?: readonly string[];
} & DefaultOptions;

export type FollowingDotCursorOptions = {
readonly color?: string;
} & DefaultOptions;

export type GhostCursorOptions = {
readonly randomDelay?: boolean;
readonly minDelay?: number;
readonly maxDelay?: number;
readonly image?: string;
} & DefaultOptions;

export type RainbowCursorOptions = {
length?: number;
colors?: readonly string[];
size?: number;
} & DefaultOptions;

export type SnowflakeCursorOptions = {
} & DefaultOptions;

export type SpringyEmojiCursorOptions = {
readonly emoji?: string;
} & DefaultOptions;

export type TextFlagOptions = {
readonly text?: string;
readonly color?: string;
readonly size?: number;
readonly font?: string;
readonly textSize?: number;
readonly gap?: number;
} & DefaultOptions;

export type TrailingCursorOptions = {
readonly particles?: number;
readonly rate?: number;
readonly baseImageSrc?: number;
} & DefaultOptions;

export function bubbleCursor(options?: BubbleCursorOptions): CursorEffectResult;
export function characterCursor(options?: CharacterCursorOptions): CursorEffectResult;
export function clockCursor(options?: ClockCursorOptions): CursorEffectResult;
export function emojiCursor(options?: EmojiCursorOptions): CursorEffectResult;
export function fairyDustCursor(options?: FairyDustCursorOptions): CursorEffectResult;
export function followingDotCursor(options?: FollowingDotCursorOptions): CursorEffectResult;
export function ghostCursor(options?: GhostCursorOptions): CursorEffectResult;
export function rainbowCursor(options?: RainbowCursorOptions): CursorEffectResult;
export function snowflakeCursor(options?: SnowflakeCursorOptions): CursorEffectResult;
export function springyEmojiCursor(options?: SpringyEmojiCursorOptions): CursorEffectResult;
export function textFlag(options?: TextFlagOptions): CursorEffectResult;
export function trailingCursor(options?: TrailingCursorOptions): CursorEffectResult;

0 comments on commit eea2e60

Please sign in to comment.