From b0ebb828bf0d6384a8887a6e5ff42f4125f6d4b2 Mon Sep 17 00:00:00 2001 From: Caleb Evans Date: Wed, 12 Jun 2024 16:35:27 -0700 Subject: [PATCH] Add missing types for included plugins --- package.json | 3 +- pnpm-lock.yaml | 88 ++++++++++++++++++++++++++++++++++++++ rollup.config.mjs | 24 ++++++++++- src/jcanvas-crescents.d.ts | 9 ++++ src/jcanvas-donuts.d.ts | 9 ++++ src/jcanvas-handles.d.ts | 16 +++++++ src/jcanvas-hearts.d.ts | 9 ++++ src/jcanvas.d.ts | 4 +- src/jcanvas.ts | 2 +- 9 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 src/jcanvas-crescents.d.ts create mode 100644 src/jcanvas-donuts.d.ts create mode 100644 src/jcanvas-handles.d.ts create mode 100644 src/jcanvas-hearts.d.ts diff --git a/package.json b/package.json index d5b6c18..963e521 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "version": "23.0.0-rc.1", "main": "dist/umd/jcanvas.min.js", "module": "dist/esm/jcanvas.min.js", - "types": "src/jcanvas.d.ts", + "types": "dist/esm/jcanvas.d.ts", "scripts": { "build": "rollup -c", "prepare": "rollup -c", @@ -43,6 +43,7 @@ "prettier": "^3.2.5", "qunit": "^2.21.0", "rollup": "^4.17.2", + "rollup-plugin-copy": "^3.5.0", "rollup-plugin-esbuild": "^6.1.1", "tslib": "^2.6.2", "typescript": "^5.4.5" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17a90ed..ab8054a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ devDependencies: rollup: specifier: ^4.17.2 version: 4.17.2 + rollup-plugin-copy: + specifier: ^3.5.0 + version: 3.5.0 rollup-plugin-esbuild: specifier: ^6.1.1 version: 6.1.1(esbuild@0.21.4)(rollup@4.17.2) @@ -534,12 +537,35 @@ packages: resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} dev: true + /@types/fs-extra@8.1.5: + resolution: {integrity: sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ==} + dependencies: + '@types/node': 20.14.2 + dev: true + + /@types/glob@7.2.0: + resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} + dependencies: + '@types/minimatch': 5.1.2 + '@types/node': 20.14.2 + dev: true + /@types/jquery@3.5.30: resolution: {integrity: sha512-nbWKkkyb919DOUxjmRVk8vwtDb0/k8FKncmUKFi+NY+QXqWltooxTrswvz4LspQwxvLdvzBN1TImr6cw3aQx2A==} dependencies: '@types/sizzle': 2.3.8 dev: true + /@types/minimatch@5.1.2: + resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} + dev: true + + /@types/node@20.14.2: + resolution: {integrity: sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==} + dependencies: + undici-types: 5.26.5 + dev: true + /@types/sizzle@2.3.8: resolution: {integrity: sha512-0vWLNK2D5MT9dg0iOo8GlKguPAU02QjmZitPEsXRuJXU/OGIOt9vT9Fc26wtYuavLxtO45v9PGleoL9Z0k1LHg==} dev: true @@ -777,6 +803,10 @@ packages: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: true + /colorette@1.4.0: + resolution: {integrity: sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==} + dev: true + /commander@7.2.0: resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==} engines: {node: '>= 10'} @@ -1058,6 +1088,15 @@ packages: signal-exit: 4.1.0 dev: true + /fs-extra@8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: true + /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true @@ -1135,6 +1174,20 @@ packages: resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} dev: true + /globby@10.0.1: + resolution: {integrity: sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==} + engines: {node: '>=8'} + dependencies: + '@types/glob': 7.2.0 + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.2 + glob: 7.1.7 + ignore: 5.3.1 + merge2: 1.4.1 + slash: 3.0.0 + dev: true + /globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} @@ -1151,6 +1204,10 @@ packages: resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} dev: true + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: true + /graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true @@ -1221,6 +1278,11 @@ packages: engines: {node: '>=8'} dev: true + /is-plain-object@3.0.1: + resolution: {integrity: sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==} + engines: {node: '>=0.10.0'} + dev: true + /is-reference@1.2.1: resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} dependencies: @@ -1259,6 +1321,12 @@ packages: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} dev: true + /jsonfile@4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + optionalDependencies: + graceful-fs: 4.2.11 + dev: true + /levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -1477,6 +1545,17 @@ packages: glob: 7.1.7 dev: true + /rollup-plugin-copy@3.5.0: + resolution: {integrity: sha512-wI8D5dvYovRMx/YYKtUNt3Yxaw4ORC9xo6Gt9t22kveWz1enG9QrhVlagzwrxSC455xD1dHMKhIJkbsQ7d48BA==} + engines: {node: '>=8.3'} + dependencies: + '@types/fs-extra': 8.1.5 + colorette: 1.4.0 + fs-extra: 8.1.0 + globby: 10.0.1 + is-plain-object: 3.0.1 + dev: true + /rollup-plugin-esbuild@6.1.1(esbuild@0.21.4)(rollup@4.17.2): resolution: {integrity: sha512-CehMY9FAqJD5OUaE/Mi1r5z0kNeYxItmRO2zG4Qnv2qWKF09J2lTy5GUzjJR354ZPrLkCj4fiBN41lo8PzBUhw==} engines: {node: '>=14.18.0'} @@ -1647,6 +1726,15 @@ packages: hasBin: true dev: true + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + dev: true + + /universalify@0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + dev: true + /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: diff --git a/rollup.config.mjs b/rollup.config.mjs index f6f4940..ffa73ad 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,9 +1,12 @@ import commonjs from "@rollup/plugin-commonjs"; import { globSync } from "glob"; import path from "node:path"; +import copy from "rollup-plugin-copy"; import esbuild from "rollup-plugin-esbuild"; -const inputPaths = globSync(["src/jcanvas.ts", "src/jcanvas-*.ts"]); +const inputPaths = globSync(["src/jcanvas.ts", "src/jcanvas-*.ts", ""], { + ignore: "src/*.d.ts", +}); export default inputPaths.map((inputPath) => { const inputFilenameWithoutExtension = path.basename(inputPath, ".ts"); @@ -29,6 +32,23 @@ export default inputPaths.map((inputPath) => { }, }, ], - plugins: [commonjs(), esbuild({ minify: true, target: "es2020" })], + plugins: [ + commonjs(), + esbuild({ minify: true, target: "es2020" }), + copy({ + targets: [ + { + src: `src/${inputFilenameWithoutExtension}.d.ts`, + dest: "dist/umd", + rename: `${inputFilenameWithoutExtension}.min.d.ts`, + }, + { + src: `src/${inputFilenameWithoutExtension}.d.ts`, + dest: "dist/esm", + rename: `${inputFilenameWithoutExtension}.min.d.ts`, + }, + ], + }), + ], }; }); diff --git a/src/jcanvas-crescents.d.ts b/src/jcanvas-crescents.d.ts new file mode 100644 index 0000000..fb779eb --- /dev/null +++ b/src/jcanvas-crescents.d.ts @@ -0,0 +1,9 @@ +/// + +interface JCanvasDefaults { + eclipse: number; +} + +interface JQuery { + drawCrescent(args: Partial): JQuery; +} diff --git a/src/jcanvas-donuts.d.ts b/src/jcanvas-donuts.d.ts new file mode 100644 index 0000000..aed18a2 --- /dev/null +++ b/src/jcanvas-donuts.d.ts @@ -0,0 +1,9 @@ +/// + +interface JCanvasDefaults { + holeSize: number; +} + +interface JQuery { + drawDonut(args: Partial): JQuery; +} diff --git a/src/jcanvas-handles.d.ts b/src/jcanvas-handles.d.ts new file mode 100644 index 0000000..4f9ab8a --- /dev/null +++ b/src/jcanvas-handles.d.ts @@ -0,0 +1,16 @@ +/// + +interface JCanvasDefaults { + handle: JCanvasLayer | null; + guide: JCanvasLayer | null; + aspectRatio: number | null; + resizeFromCenter: boolean; + constrainProportions: boolean; + handlePlacement: "corners" | "sides" | "both"; + minWidth: number; + minHeight: number; + handlestart?: JCanvasLayerCallback; + handlestop?: JCanvasLayerCallback; + handlemove?: JCanvasLayerCallback; + handlecancel?: JCanvasLayerCallback; +} diff --git a/src/jcanvas-hearts.d.ts b/src/jcanvas-hearts.d.ts new file mode 100644 index 0000000..0e5d8de --- /dev/null +++ b/src/jcanvas-hearts.d.ts @@ -0,0 +1,9 @@ +/// + +interface JCanvasDefaults { + size: number; +} + +interface JQuery { + drawHeart(args: Partial): JQuery; +} diff --git a/src/jcanvas.d.ts b/src/jcanvas.d.ts index 1515645..99b814b 100644 --- a/src/jcanvas.d.ts +++ b/src/jcanvas.d.ts @@ -107,7 +107,7 @@ type JCanvasEventName = | JCanvasImageEventName; interface JCanvasMaps { - drawings: Record; + drawings: Record; touchEvents: Partial< Record >; @@ -375,7 +375,7 @@ interface JCanvasDefaults { translate: number; translateX: number; translateY: number; - type: keyof JCanvasMaps["drawings"] | null; + type: string | null; visible: boolean; width: number | null; willReadFrequently: boolean; diff --git a/src/jcanvas.ts b/src/jcanvas.ts index 56eb3e1..0727ddb 100644 --- a/src/jcanvas.ts +++ b/src/jcanvas.ts @@ -201,7 +201,7 @@ class jCanvasDefaults implements JCanvasDefaults { translate: number = 0; translateX: number = 0; translateY: number = 0; - type: keyof (typeof maps)["drawings"] | null = null; + type: string | null = null; visible: boolean = true; width: number | null = null; willReadFrequently: boolean = false;