Skip to content

Commit

Permalink
fix: type exports (#214)
Browse files Browse the repository at this point in the history
* Fix types bundle artifact for RecursivePartial
Properly export PositionerOptions
Bump packages

* update(types) allow PositionerOptions (in HanziWriterOptions) to be optional

* update(package.json) downgrade jest-canvas-mock to fix broken tests
  • Loading branch information
jamsch authored Jan 19, 2021
1 parent 48f5037 commit 009be80
Show file tree
Hide file tree
Showing 5 changed files with 1,209 additions and 1,076 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build/*",
"examples/*",
"babel.config.js",
"rollup.config.js",
"jest-setup.js"
],
"rules": {
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@
"module": "dist/index.esm.js",
"types": "dist/types/index.esm.d.ts",
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@babel/preset-typescript": "^7.10.4",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-node-resolve": "^9.0.0",
"@sinonjs/fake-timers": "^6.0.1",
"@types/jest": "^26.0.14",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-node-resolve": "^11.1.0",
"@sinonjs/fake-timers": "^7.0.2",
"@types/jest": "^26.0.20",
"@types/nise": "^1.4.0",
"@types/sinonjs__fake-timers": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^4.4.0",
"@typescript-eslint/parser": "^4.4.0",
"@wessberg/rollup-plugin-ts": "^1.3.5",
"codecov": "^3.8.0",
"eslint": "^7.11.0",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"codecov": "^3.8.1",
"eslint": "^7.18.0",
"hanzi-writer-data": "^2.0.1",
"jest-canvas-mock": "2.1.0",
"jest-cli": "^26.5.3",
"jest-cli": "^26.6.3",
"jest-fetch-mock": "^3.0.3",
"nise": "^4.0.4",
"prettier": "^2.2.1",
"rollup": "^2.29.0",
"rollup": "^2.36.2",
"rollup-plugin-filesize": "^9.1.0",
"rollup-plugin-license": "^2.2.0",
"rollup-plugin-terser": "^7.0.2",
"semantic-release": "^17.2.0",
"semantic-release": "^17.3.3",
"typescript": "^4.1.3"
},
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions src/Positioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ const [from, to] = CHARACTER_BOUNDS;
const preScaledWidth = to.x - from.x;
const preScaledHeight = to.y - from.y;

interface PositionerOptions {
export type PositionerOptions = {
/** Default: 0 */
width: number;
/** Default: 0 */
height: number;
/** Default: 20 */
padding: number;
}
};

export default class Positioner {
padding: number;
Expand Down
14 changes: 4 additions & 10 deletions src/typings/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import RenderTargetBase from '../renderers/RenderTargetBase';
import { HanziWriterRendererConstructor } from '../renderers/HanziWriterRendererBase';
import type { PositionerOptions } from '../Positioner';

export type { PositionerOptions };

export type CharacterJson = {
strokes: string[];
Expand Down Expand Up @@ -68,15 +71,6 @@ export type QuizOptions = {
onComplete?: (summary: { character: string; totalMistakes: number }) => void;
};

export type PositionerOptions = {
/** Default: 20 */
padding?: number;
/** Default: 0 */
width?: number;
/** Default: 0 */
height?: number;
};

export type LoadingManagerOptions = {
charDataLoader: CharDataLoaderFn;
onLoadCharDataSuccess?: null | ((data: CharacterJson) => void);
Expand Down Expand Up @@ -122,7 +116,7 @@ type BaseHanziWriterOptions = {
strokeHighlightDuration: number;
};

export type HanziWriterOptions = PositionerOptions &
export type HanziWriterOptions = Partial<PositionerOptions> &
QuizOptions &
ColorOptions &
LoadingManagerOptions &
Expand Down
Loading

0 comments on commit 009be80

Please sign in to comment.