Skip to content

Commit

Permalink
Add missing types for included plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Jun 12, 2024
1 parent 12d34b4 commit b0ebb82
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
88 changes: 88 additions & 0 deletions pnpm-lock.yaml

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

24 changes: 22 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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`,
},
],
}),
],
};
});
9 changes: 9 additions & 0 deletions src/jcanvas-crescents.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path="jcanvas.d.ts" />

interface JCanvasDefaults {
eclipse: number;
}

interface JQuery {
drawCrescent(args: Partial<JCanvasObject>): JQuery;
}
9 changes: 9 additions & 0 deletions src/jcanvas-donuts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path="jcanvas.d.ts" />

interface JCanvasDefaults {
holeSize: number;
}

interface JQuery {
drawDonut(args: Partial<JCanvasObject>): JQuery;
}
16 changes: 16 additions & 0 deletions src/jcanvas-handles.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference path="jcanvas.d.ts" />

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;
}
9 changes: 9 additions & 0 deletions src/jcanvas-hearts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path="jcanvas.d.ts" />

interface JCanvasDefaults {
size: number;
}

interface JQuery {
drawHeart(args: Partial<JCanvasObject>): JQuery;
}
4 changes: 2 additions & 2 deletions src/jcanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ type JCanvasEventName =
| JCanvasImageEventName;

interface JCanvasMaps {
drawings: Record<JCanvasLayerType, JCanvasDrawingMethodName>;
drawings: Record<string, JCanvasDrawingMethodName>;
touchEvents: Partial<
Record<JCanvasInteractionEventName, JCanvasTouchEventName>
>;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/jcanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b0ebb82

Please sign in to comment.