Browse Source

Add declaration file for ColorThief

Include declaration for ColorThief since it is written in JavaScript
only.
pull/1/head
TheoryOfNekomata 1 year ago
parent
commit
ac05503e6c
2 changed files with 6 additions and 1 deletions
  1. +5
    -0
      packages/web-kitchensink-reactnext/colorthief.d.ts
  2. +1
    -1
      packages/web-kitchensink-reactnext/src/utils/image.ts

+ 5
- 0
packages/web-kitchensink-reactnext/colorthief.d.ts View File

@@ -0,0 +1,5 @@
declare module 'colorthief' {
export default class ColorThief {
getPalette(image: HTMLImageElement, colorCount: number): Promise<[number, number, number][]>;
}
}

+ 1
- 1
packages/web-kitchensink-reactnext/src/utils/image.ts View File

@@ -1,6 +1,6 @@
import ColorThief from 'colorthief';

export const getImageMetadata = (imageUrl: string) => new Promise<Record<string, string | number>>((resolve, reject) => {
export const getImageMetadata = (imageUrl: string) => new Promise<Record<string, string | number | [number, number, number][]>>((resolve, reject) => {
const image = new Image();
image.addEventListener('load', async (imageLoadEvent) => {
const thisImage = imageLoadEvent.currentTarget as HTMLImageElement;


Loading…
Cancel
Save