From c1d33f8e582d4b2bd2605ec067df621b8ec2b567 Mon Sep 17 00:00:00 2001 From: Michael Bullington Date: Thu, 19 Aug 2021 13:00:55 -0400 Subject: [PATCH 1/2] Add TS types, increment to version 1.1.0 --- index.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..ac33dc3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,39 @@ +declare module "potpack" { + export interface PotpackBox { + w: number; + h: number; + /** + * X coordinate in the resulting container. + */ + x?: number; + /** + * Y coordinate in the resulting container. + */ + y?: number; + } + + interface PotpackStats { + /** + * Width of the resulting container. + */ + w: number; + /** + * Height of the resulting container. + */ + h: number; + /** + * The space utilization value (0 to 1). Higher is better. + */ + fill: number; + } + + /** + * Packs 2D rectangles into a near-square container. + * + * Mutates the {@link boxes} array: it's sorted by height, + * and box objects are augmented with `x`, `y` coordinates. + */ + const potpack: (boxes: PotpackBox[]) => PotpackStats; + + export default potpack; +} diff --git a/package.json b/package.json index 62938fe..ff325e4 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "potpack", - "version": "1.0.1", + "version": "1.1.0", "description": "A tiny library for packing 2D rectangles (for sprite layouts)", "main": "index", "module": "index.mjs", "unpkg": "index.js", "jsdelivr": "index.js", + "types": "index.d.ts", "files": [ "index.mjs", "index.js" From 5dfb7d85155da3c7d7eb7439b48a1947891a416d Mon Sep 17 00:00:00 2001 From: Michael Bullington Date: Thu, 19 Aug 2021 13:26:51 -0400 Subject: [PATCH 2/2] switch down version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff325e4..50195f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "potpack", - "version": "1.1.0", + "version": "1.0.1", "description": "A tiny library for packing 2D rectangles (for sprite layouts)", "main": "index", "module": "index.mjs",