From 53551884427eb2264325330359975aff13aa427b Mon Sep 17 00:00:00 2001 From: Joe Westcott Date: Sat, 28 Jan 2023 17:59:48 +0000 Subject: [PATCH 1/2] mark package as sideEffect free --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 96b7d09..2e177c1 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,7 @@ "svg" ], "license": "MIT", + "sideEffects": false, "main": "cjs/index.js", "module": "modules/index.js", "name": "points", From f2660fb37a7d67744e11f785b9804ab521dceb1c Mon Sep 17 00:00:00 2001 From: Joe Westcott Date: Sat, 28 Jan 2023 18:06:48 +0000 Subject: [PATCH 2/2] add typescript types --- index.d.ts | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 86 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..9ee1551 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,85 @@ +declare module "points" { + export type Move = { + x: number; + y: number; + } + + export type AbsoluteMove = { + x: number; + y: number; + moveTo: true; + } + + export type Arc = { + x: number; + y: number; + curve: { + type: "arc"; + rx: number; + ry: number; + sweepFlag?: 1 | 0; + largeArcFlag?: 1 | 0; + xAxisRotation?: number; + } + } + + export type QuadraticBezier = { + x: number; + y: number; + curve: { + type: "quadratic"; + x1: number; + y1: number; + } + } + + export type CubicBezier = { + x: number, + y: number, + curve: { + type: "cubic"; + x1: number; + x2: number; + y1: number; + y2: number; + rx?: number; + ry?: number; + } + } + + export type Command = Move | AbsoluteMove | Arc | QuadraticBezier | CubicBezier; + + export type BoundingBox = { + center: { x: number; y: number; }; + top: number; + left: number; + right: number; + bottom: number; + } + + export type Shape = [AbsoluteMove, ...Command[]]; + + export type Anchor = "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "center"; + + export type Angle = { + center: { x: number; y: number; }; + } + + export type Position = { + angle: number; + x: number; + y: number; + } + + export function add(shape: Shape, pointsRequired: number): Shape; + export function boundingBox(shape: Shape | Shape[]): BoundingBox; + export function cubify(shape: Shape): Shape; + export function length(shape: Shape, accuracy?: number): number; + export function moveIndex(shape: Shape, offset: number): Shape; + export function offset(shape: Shape, x: number, y: number): Shape; + export function position(shape: Shape, interval: number, accuracy?: number): Position; + export function remove(shape: Shape): Shape; + export function reverse(shape: Shape): Shape; + export function rotate(shape: Shape, angle: Angle): Shape; + export function scale(shape: Shape, scaleFactor: number, anchor?: Anchor): Shape; +} \ No newline at end of file diff --git a/package.json b/package.json index 2e177c1..33debe5 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "sideEffects": false, "main": "cjs/index.js", "module": "modules/index.js", + "types": "index.d.ts", "name": "points", "repository": { "type": "git",