Browse Source

Remove hard coded typings file and generate typings

master
Joe Attardi 3 years ago
parent
commit
251d5a87ad
  1. 148
      index.d.ts
  2. 68
      package-lock.json
  3. 7
      package.json
  4. 2
      rollup.config.js
  5. 9
      tsconfig.json

148
index.d.ts

@ -1,148 +0,0 @@
import { ParseObject } from 'twemoji';
export as namespace EmojiButton;
export = EmojiButton;
declare namespace EmojiButton {
export class EmojiButton {
constructor(options?: EmojiButton.Options);
on(event: Event, callback: (selection: EmojiSelection) => void): void;
off(event: Event, callback: (selection: EmojiSelection) => void): void;
hidePicker(): void;
destroyPicker(): void;
showPicker(referenceEl: HTMLElement): void;
togglePicker(referenceEl: HTMLElement): void;
isPickerVisible(): boolean;
setTheme(theme: EmojiTheme): void;
}
export interface Options {
position?: Placement | FixedPosition;
autoHide?: boolean;
autoFocusSearch?: boolean;
showAnimation?: boolean;
showPreview?: boolean;
showSearch?: boolean;
showRecents?: boolean;
showVariants?: boolean;
showCategoryButtons?: boolean;
recentsCount?: number;
emojiVersion?: EmojiVersion;
i18n?: I18NStrings;
zIndex?: number;
theme?: EmojiTheme;
categories?: Category[];
style?: EmojiStyle;
twemojiStyle: Partial<ParseObject>;
emojisPerRow?: number;
rows?: number;
emojiSize?: string;
initialCategory?: Category | 'recents';
custom?: CustomEmoji[];
plugins?: Plugin[];
icons?: Icons;
rootElement?: HTMLElement;
styleProperties?: {
[key: string]: string;
};
}
export interface FixedPosition {
top?: string;
bottom?: string;
left?: string;
right?: string;
}
export interface Plugin {
render(picker: EmojiButton): HTMLElement;
destroy?(): void;
}
export interface EmojiSelection {
name: string;
custom?: boolean;
emoji?: string;
url?: string;
}
export interface CustomEmoji {
name: string;
emoji: string;
}
export type EmojiStyle = 'native' | 'twemoji';
export type EmojiTheme = 'dark' | 'light' | 'auto';
export type Event = 'emoji' | 'hidden';
export type Placement =
| 'auto'
| 'auto-start'
| 'auto-end'
| 'top'
| 'top-start'
| 'top-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'right'
| 'right-start'
| 'right-end'
| 'left'
| 'left-start'
| 'left-end';
export type EmojiVersion =
| '1.0'
| '2.0'
| '3.0'
| '4.0'
| '5.0'
| '11.0'
| '12.0'
| '12.1';
export type Category =
| 'smileys'
| 'people'
| 'animals'
| 'food'
| 'activities'
| 'travel'
| 'objects'
| 'symbols'
| 'flags';
export type I18NCategory =
| 'recents'
| 'smileys'
| 'people'
| 'animals'
| 'food'
| 'activities'
| 'travel'
| 'objects'
| 'symbols'
| 'flags'
| 'custom';
export interface I18NStrings {
search: string;
categories: {
[key in I18NCategory]: string;
};
notFound: string;
}
export interface Icons {
search?: string;
clearSearch?: string;
categories?: {
[key in I18NCategory]?: string;
};
notFound?: string;
}
}

68
package-lock.json

@ -1956,27 +1956,6 @@
}
}
},
"@rollup/plugin-typescript": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-4.1.2.tgz",
"integrity": "sha512-+7UlGat/99e2JbmGNnIauxwEhYLwrL7adO/tSJxUN57xrrS3Ps+ZzYpLCDGPZJ57j+ZJTZLLN89KXW9JMEB+jg==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.0.1",
"resolve": "^1.14.1"
},
"dependencies": {
"resolve": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
"integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
}
}
}
},
"@rollup/pluginutils": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz",
@ -3167,6 +3146,12 @@
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true
},
"commondir": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
"integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
"dev": true
},
"component-emitter": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
@ -4574,6 +4559,17 @@
"to-regex-range": "^5.0.1"
}
},
"find-cache-dir": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
"integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==",
"dev": true,
"requires": {
"commondir": "^1.0.1",
"make-dir": "^3.0.2",
"pkg-dir": "^4.1.0"
}
},
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
@ -9793,6 +9789,36 @@
}
}
},
"rollup-plugin-typescript2": {
"version": "0.29.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.29.0.tgz",
"integrity": "sha512-YytahBSZCIjn/elFugEGQR5qTsVhxhUwGZIsA9TmrSsC88qroGo65O5HZP/TTArH2dm0vUmYWhKchhwi2wL9bw==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.1.0",
"find-cache-dir": "^3.3.1",
"fs-extra": "8.1.0",
"resolve": "1.17.0",
"tslib": "2.0.1"
},
"dependencies": {
"resolve": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
"integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
}
},
"tslib": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
"integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==",
"dev": true
}
}
},
"rollup-pluginutils": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz",

7
package.json

@ -8,7 +8,7 @@
],
"main": "dist/index.js",
"module": "dist/index.js",
"types": "index.d.ts",
"types": "dist/index.d.ts",
"scripts": {
"build": "cross-env NODE_ENV=production rollup -c",
"build:watch": "rollup -cw",
@ -32,7 +32,6 @@
"@babel/preset-env": "^7.10.2",
"@babel/preset-typescript": "^7.10.1",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-typescript": "^4.1.2",
"@types/jest": "^25.2.3",
"@typescript-eslint/eslint-plugin": "^3.1.0",
"@typescript-eslint/parser": "^3.1.0",
@ -50,6 +49,7 @@
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^3.1.2",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.29.0",
"ts-jest": "^26.1.0",
"typescript": "^3.9.5"
},
@ -66,7 +66,6 @@
"twemoji": "^13.0.0"
},
"files": [
"dist",
"index.d.ts"
"dist"
]
}

2
rollup.config.js

@ -2,7 +2,7 @@ import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import typescript from 'rollup-plugin-typescript2';
import { terser } from 'rollup-plugin-terser';
const production = process.env.NODE_ENV === 'production';

9
tsconfig.json

@ -2,13 +2,13 @@
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
@ -63,5 +63,6 @@
/* Advanced Options */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["src/*.ts"]
"include": ["src/*.ts"],
"exclude": ["src/*.test.ts"]
}

Loading…
Cancel
Save