@zag-js/rect-utils 1.46.0 → 1.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
  9. package/dist/affine-transform.d.mts +36 -39
  10. package/dist/affine-transform.d.ts +36 -39
  11. package/dist/affine-transform.js +189 -187
  12. package/dist/affine-transform.mjs +185 -164
  13. package/dist/align.d.mts +2 -5
  14. package/dist/align.d.ts +2 -5
  15. package/dist/align.js +27 -44
  16. package/dist/align.mjs +23 -21
  17. package/dist/angle.d.mts +2 -5
  18. package/dist/angle.d.ts +2 -5
  19. package/dist/angle.js +8 -32
  20. package/dist/angle.mjs +4 -9
  21. package/dist/clamp.d.mts +8 -11
  22. package/dist/clamp.d.ts +8 -11
  23. package/dist/clamp.js +23 -46
  24. package/dist/clamp.mjs +18 -22
  25. package/dist/closest.d.mts +4 -7
  26. package/dist/closest.d.ts +4 -7
  27. package/dist/closest.js +35 -62
  28. package/dist/closest.mjs +29 -37
  29. package/dist/compass.d.mts +4 -7
  30. package/dist/compass.d.ts +4 -7
  31. package/dist/compass.js +48 -48
  32. package/dist/compass.mjs +43 -24
  33. package/dist/constrain.d.mts +2 -5
  34. package/dist/constrain.d.ts +2 -5
  35. package/dist/constrain.js +12 -37
  36. package/dist/constrain.mjs +8 -14
  37. package/dist/contains.d.mts +4 -7
  38. package/dist/contains.d.ts +4 -7
  39. package/dist/contains.js +11 -36
  40. package/dist/contains.mjs +5 -11
  41. package/dist/distance.d.mts +7 -10
  42. package/dist/distance.d.ts +7 -10
  43. package/dist/distance.js +55 -60
  44. package/dist/distance.mjs +48 -34
  45. package/dist/equality.d.mts +4 -7
  46. package/dist/equality.d.ts +4 -7
  47. package/dist/equality.js +13 -38
  48. package/dist/equality.mjs +7 -13
  49. package/dist/from-element.d.mts +12 -15
  50. package/dist/from-element.d.ts +12 -15
  51. package/dist/from-element.js +39 -58
  52. package/dist/from-element.mjs +35 -35
  53. package/dist/from-points.d.mts +2 -5
  54. package/dist/from-points.d.ts +2 -5
  55. package/dist/from-points.js +18 -36
  56. package/dist/from-points.mjs +14 -13
  57. package/dist/from-range.d.mts +2 -5
  58. package/dist/from-range.d.ts +2 -5
  59. package/dist/from-range.js +25 -46
  60. package/dist/from-range.mjs +19 -21
  61. package/dist/from-rotation.d.mts +4 -7
  62. package/dist/from-rotation.d.ts +4 -7
  63. package/dist/from-rotation.js +31 -56
  64. package/dist/from-rotation.mjs +25 -31
  65. package/dist/from-window.d.mts +13 -16
  66. package/dist/from-window.d.ts +13 -16
  67. package/dist/from-window.js +29 -44
  68. package/dist/from-window.mjs +24 -20
  69. package/dist/index.d.mts +22 -22
  70. package/dist/index.d.ts +22 -22
  71. package/dist/index.js +72 -63
  72. package/dist/index.mjs +21 -22
  73. package/dist/intersection.d.mts +4 -7
  74. package/dist/intersection.d.ts +4 -7
  75. package/dist/intersection.js +34 -45
  76. package/dist/intersection.mjs +28 -20
  77. package/dist/operations.d.mts +6 -9
  78. package/dist/operations.d.ts +6 -9
  79. package/dist/operations.js +38 -57
  80. package/dist/operations.mjs +30 -30
  81. package/dist/polygon.d.mts +6 -9
  82. package/dist/polygon.d.ts +6 -9
  83. package/dist/polygon.js +73 -82
  84. package/dist/polygon.mjs +67 -57
  85. package/dist/rect.d.mts +49 -52
  86. package/dist/rect.d.ts +49 -52
  87. package/dist/rect.js +57 -82
  88. package/dist/rect.mjs +46 -52
  89. package/dist/resize.d.mts +3 -6
  90. package/dist/resize.d.ts +3 -6
  91. package/dist/resize.js +73 -102
  92. package/dist/resize.mjs +68 -78
  93. package/dist/types.d.mts +45 -49
  94. package/dist/types.d.ts +45 -49
  95. package/dist/types.js +4 -18
  96. package/dist/types.mjs +1 -0
  97. package/dist/union.d.mts +2 -5
  98. package/dist/union.d.ts +2 -5
  99. package/dist/union.js +16 -39
  100. package/dist/union.mjs +12 -16
  101. package/package.json +3 -3
  102. package/dist/chunk-QZ7TP4HQ.mjs +0 -7
package/dist/clamp.js CHANGED
@@ -1,51 +1,28 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/clamp.ts
21
- var clamp_exports = {};
22
- __export(clamp_exports, {
23
- clampPoint: () => clampPoint,
24
- clampSize: () => clampSize
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
25
4
  });
26
- module.exports = __toCommonJS(clamp_exports);
27
- var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
28
- var clampPoint = (position, size, boundaryRect) => {
29
- const x = clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width);
30
- const y = clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height);
31
- return { x, y };
5
+ // src/clamp.ts
6
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
7
+ const clampPoint = (position, size, boundaryRect) => {
8
+ return {
9
+ x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
10
+ y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
11
+ };
32
12
  };
33
- var defaultMinSize = {
34
- width: 0,
35
- height: 0
13
+ const defaultMinSize = {
14
+ width: 0,
15
+ height: 0
36
16
  };
37
- var defaultMaxSize = {
38
- width: Infinity,
39
- height: Infinity
17
+ const defaultMaxSize = {
18
+ width: 1e400,
19
+ height: 1e400
40
20
  };
41
- var clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
42
- return {
43
- width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
44
- height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
45
- };
21
+ const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
22
+ return {
23
+ width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
24
+ height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
25
+ };
46
26
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- clampPoint,
50
- clampSize
51
- });
27
+ exports.clampPoint = clampPoint;
28
+ exports.clampSize = clampSize;
package/dist/clamp.mjs CHANGED
@@ -1,27 +1,23 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
1
  // src/clamp.ts
4
- var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
5
- var clampPoint = (position, size, boundaryRect) => {
6
- const x = clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width);
7
- const y = clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height);
8
- return { x, y };
2
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
3
+ const clampPoint = (position, size, boundaryRect) => {
4
+ return {
5
+ x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
6
+ y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
7
+ };
9
8
  };
10
- var defaultMinSize = {
11
- width: 0,
12
- height: 0
9
+ const defaultMinSize = {
10
+ width: 0,
11
+ height: 0
13
12
  };
14
- var defaultMaxSize = {
15
- width: Infinity,
16
- height: Infinity
13
+ const defaultMaxSize = {
14
+ width: 1e400,
15
+ height: 1e400
17
16
  };
18
- var clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
19
- return {
20
- width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
21
- height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
22
- };
23
- };
24
- export {
25
- clampPoint,
26
- clampSize
17
+ const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
18
+ return {
19
+ width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
20
+ height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
21
+ };
27
22
  };
23
+ export { clampPoint, clampSize };
@@ -1,7 +1,4 @@
1
- import { Point, Rect, RectSide } from './types.mjs';
2
-
3
- declare function closest(...pts: Point[]): (a: Point) => Point;
4
- declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
5
- declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
6
-
7
- export { closest, closestSideToPoint, closestSideToRect };
1
+ import { Point, Rect, RectSide } from "./types.mjs";
2
+ export declare function closest(...pts: Point[]): (a: Point) => Point;
3
+ export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
4
+ export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
package/dist/closest.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import { Point, Rect, RectSide } from './types.js';
2
-
3
- declare function closest(...pts: Point[]): (a: Point) => Point;
4
- declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
5
- declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
6
-
7
- export { closest, closestSideToPoint, closestSideToRect };
1
+ import { Point, Rect, RectSide } from "./types.js";
2
+ export declare function closest(...pts: Point[]): (a: Point) => Point;
3
+ export declare function closestSideToRect(ref: Rect, r: Rect): RectSide;
4
+ export declare function closestSideToPoint(ref: Rect, p: Point): RectSide;
package/dist/closest.js CHANGED
@@ -1,69 +1,42 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/closest.ts
21
- var closest_exports = {};
22
- __export(closest_exports, {
23
- closest: () => closest,
24
- closestSideToPoint: () => closestSideToPoint,
25
- closestSideToRect: () => closestSideToRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
26
4
  });
27
- module.exports = __toCommonJS(closest_exports);
28
- var import_distance = require("./distance.js");
5
+ const require_distance = require("./distance.js");
6
+ // src/closest.ts
29
7
  function closest(...pts) {
30
- return (a) => {
31
- const ds = pts.map((b) => (0, import_distance.distance)(b, a));
32
- const c = Math.min.apply(Math, ds);
33
- return pts[ds.indexOf(c)];
34
- };
8
+ return (a) => {
9
+ const ds = pts.map((b) => require_distance.distance(b, a));
10
+ const c = Math.min.apply(Math, ds);
11
+ return pts[ds.indexOf(c)];
12
+ };
35
13
  }
36
14
  function closestSideToRect(ref, r) {
37
- if (r.maxX <= ref.minX) return "left";
38
- if (r.minX >= ref.maxX) return "right";
39
- if (r.maxY <= ref.minY) return "top";
40
- if (r.minY >= ref.maxY) return "bottom";
41
- return "left";
15
+ if (r.maxX <= ref.minX) return "left";
16
+ if (r.minX >= ref.maxX) return "right";
17
+ if (r.maxY <= ref.minY) return "top";
18
+ if (r.minY >= ref.maxY) return "bottom";
19
+ return "left";
42
20
  }
43
21
  function closestSideToPoint(ref, p) {
44
- const { x, y } = p;
45
- const dl = x - ref.minX;
46
- const dr = ref.maxX - x;
47
- const dt = y - ref.minY;
48
- const db = ref.maxY - y;
49
- let closest2 = dl;
50
- let side = "left";
51
- if (dr < closest2) {
52
- closest2 = dr;
53
- side = "right";
54
- }
55
- if (dt < closest2) {
56
- closest2 = dt;
57
- side = "top";
58
- }
59
- if (db < closest2) {
60
- side = "bottom";
61
- }
62
- return side;
22
+ const { x, y } = p;
23
+ const dl = x - ref.minX;
24
+ const dr = ref.maxX - x;
25
+ const dt = y - ref.minY;
26
+ const db = ref.maxY - y;
27
+ let closest = dl;
28
+ let side = "left";
29
+ if (dr < closest) {
30
+ closest = dr;
31
+ side = "right";
32
+ }
33
+ if (dt < closest) {
34
+ closest = dt;
35
+ side = "top";
36
+ }
37
+ if (db < closest) side = "bottom";
38
+ return side;
63
39
  }
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- closest,
67
- closestSideToPoint,
68
- closestSideToRect
69
- });
40
+ exports.closest = closest;
41
+ exports.closestSideToPoint = closestSideToPoint;
42
+ exports.closestSideToRect = closestSideToRect;
package/dist/closest.mjs CHANGED
@@ -1,44 +1,36 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/closest.ts
4
1
  import { distance } from "./distance.mjs";
2
+ // src/closest.ts
5
3
  function closest(...pts) {
6
- return (a) => {
7
- const ds = pts.map((b) => distance(b, a));
8
- const c = Math.min.apply(Math, ds);
9
- return pts[ds.indexOf(c)];
10
- };
4
+ return (a) => {
5
+ const ds = pts.map((b) => distance(b, a));
6
+ const c = Math.min.apply(Math, ds);
7
+ return pts[ds.indexOf(c)];
8
+ };
11
9
  }
12
10
  function closestSideToRect(ref, r) {
13
- if (r.maxX <= ref.minX) return "left";
14
- if (r.minX >= ref.maxX) return "right";
15
- if (r.maxY <= ref.minY) return "top";
16
- if (r.minY >= ref.maxY) return "bottom";
17
- return "left";
11
+ if (r.maxX <= ref.minX) return "left";
12
+ if (r.minX >= ref.maxX) return "right";
13
+ if (r.maxY <= ref.minY) return "top";
14
+ if (r.minY >= ref.maxY) return "bottom";
15
+ return "left";
18
16
  }
19
17
  function closestSideToPoint(ref, p) {
20
- const { x, y } = p;
21
- const dl = x - ref.minX;
22
- const dr = ref.maxX - x;
23
- const dt = y - ref.minY;
24
- const db = ref.maxY - y;
25
- let closest2 = dl;
26
- let side = "left";
27
- if (dr < closest2) {
28
- closest2 = dr;
29
- side = "right";
30
- }
31
- if (dt < closest2) {
32
- closest2 = dt;
33
- side = "top";
34
- }
35
- if (db < closest2) {
36
- side = "bottom";
37
- }
38
- return side;
18
+ const { x, y } = p;
19
+ const dl = x - ref.minX;
20
+ const dr = ref.maxX - x;
21
+ const dt = y - ref.minY;
22
+ const db = ref.maxY - y;
23
+ let closest = dl;
24
+ let side = "left";
25
+ if (dr < closest) {
26
+ closest = dr;
27
+ side = "right";
28
+ }
29
+ if (dt < closest) {
30
+ closest = dt;
31
+ side = "top";
32
+ }
33
+ if (db < closest) side = "bottom";
34
+ return side;
39
35
  }
40
- export {
41
- closest,
42
- closestSideToPoint,
43
- closestSideToRect
44
- };
36
+ export { closest, closestSideToPoint, closestSideToRect };
@@ -1,7 +1,4 @@
1
- import { Point } from './types.mjs';
2
-
3
- type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
4
- declare const compassDirectionMap: Record<CompassDirection, Point>;
5
- declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
6
-
7
- export { type CompassDirection, compassDirectionMap, oppositeDirectionMap };
1
+ import { Point } from "./types.mjs";
2
+ export type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
3
+ export declare const compassDirectionMap: Record<CompassDirection, Point>;
4
+ export declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
package/dist/compass.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import { Point } from './types.js';
2
-
3
- type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
4
- declare const compassDirectionMap: Record<CompassDirection, Point>;
5
- declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
6
-
7
- export { type CompassDirection, compassDirectionMap, oppositeDirectionMap };
1
+ import { Point } from "./types.js";
2
+ export type CompassDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
3
+ export declare const compassDirectionMap: Record<CompassDirection, Point>;
4
+ export declare const oppositeDirectionMap: Record<CompassDirection, CompassDirection>;
package/dist/compass.js CHANGED
@@ -1,51 +1,51 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/compass.ts
21
- var compass_exports = {};
22
- __export(compass_exports, {
23
- compassDirectionMap: () => compassDirectionMap,
24
- oppositeDirectionMap: () => oppositeDirectionMap
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
25
4
  });
26
- module.exports = __toCommonJS(compass_exports);
27
- var compassDirectionMap = {
28
- n: { x: 0.5, y: 0 },
29
- ne: { x: 1, y: 0 },
30
- e: { x: 1, y: 0.5 },
31
- se: { x: 1, y: 1 },
32
- s: { x: 0.5, y: 1 },
33
- sw: { x: 0, y: 1 },
34
- w: { x: 0, y: 0.5 },
35
- nw: { x: 0, y: 0 }
5
+ // src/compass.ts
6
+ const compassDirectionMap = {
7
+ n: {
8
+ x: .5,
9
+ y: 0
10
+ },
11
+ ne: {
12
+ x: 1,
13
+ y: 0
14
+ },
15
+ e: {
16
+ x: 1,
17
+ y: .5
18
+ },
19
+ se: {
20
+ x: 1,
21
+ y: 1
22
+ },
23
+ s: {
24
+ x: .5,
25
+ y: 1
26
+ },
27
+ sw: {
28
+ x: 0,
29
+ y: 1
30
+ },
31
+ w: {
32
+ x: 0,
33
+ y: .5
34
+ },
35
+ nw: {
36
+ x: 0,
37
+ y: 0
38
+ }
36
39
  };
37
- var oppositeDirectionMap = {
38
- n: "s",
39
- ne: "sw",
40
- e: "w",
41
- se: "nw",
42
- s: "n",
43
- sw: "ne",
44
- w: "e",
45
- nw: "se"
40
+ const oppositeDirectionMap = {
41
+ n: "s",
42
+ ne: "sw",
43
+ e: "w",
44
+ se: "nw",
45
+ s: "n",
46
+ sw: "ne",
47
+ w: "e",
48
+ nw: "se"
46
49
  };
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- compassDirectionMap,
50
- oppositeDirectionMap
51
- });
50
+ exports.compassDirectionMap = compassDirectionMap;
51
+ exports.oppositeDirectionMap = oppositeDirectionMap;
package/dist/compass.mjs CHANGED
@@ -1,27 +1,46 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
1
  // src/compass.ts
4
- var compassDirectionMap = {
5
- n: { x: 0.5, y: 0 },
6
- ne: { x: 1, y: 0 },
7
- e: { x: 1, y: 0.5 },
8
- se: { x: 1, y: 1 },
9
- s: { x: 0.5, y: 1 },
10
- sw: { x: 0, y: 1 },
11
- w: { x: 0, y: 0.5 },
12
- nw: { x: 0, y: 0 }
2
+ const compassDirectionMap = {
3
+ n: {
4
+ x: .5,
5
+ y: 0
6
+ },
7
+ ne: {
8
+ x: 1,
9
+ y: 0
10
+ },
11
+ e: {
12
+ x: 1,
13
+ y: .5
14
+ },
15
+ se: {
16
+ x: 1,
17
+ y: 1
18
+ },
19
+ s: {
20
+ x: .5,
21
+ y: 1
22
+ },
23
+ sw: {
24
+ x: 0,
25
+ y: 1
26
+ },
27
+ w: {
28
+ x: 0,
29
+ y: .5
30
+ },
31
+ nw: {
32
+ x: 0,
33
+ y: 0
34
+ }
13
35
  };
14
- var oppositeDirectionMap = {
15
- n: "s",
16
- ne: "sw",
17
- e: "w",
18
- se: "nw",
19
- s: "n",
20
- sw: "ne",
21
- w: "e",
22
- nw: "se"
23
- };
24
- export {
25
- compassDirectionMap,
26
- oppositeDirectionMap
36
+ const oppositeDirectionMap = {
37
+ n: "s",
38
+ ne: "sw",
39
+ e: "w",
40
+ se: "nw",
41
+ s: "n",
42
+ sw: "ne",
43
+ w: "e",
44
+ nw: "se"
27
45
  };
46
+ export { compassDirectionMap, oppositeDirectionMap };
@@ -1,5 +1,2 @@
1
- import { RectInit } from './types.mjs';
2
-
3
- declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
4
-
5
- export { constrainRect };
1
+ import { RectInit } from "./types.mjs";
2
+ export declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
@@ -1,5 +1,2 @@
1
- import { RectInit } from './types.js';
2
-
3
- declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
4
-
5
- export { constrainRect };
1
+ import { RectInit } from "./types.js";
2
+ export declare const constrainRect: (rect: RectInit, boundary: RectInit) => RectInit;
package/dist/constrain.js CHANGED
@@ -1,39 +1,14 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/constrain.ts
21
- var constrain_exports = {};
22
- __export(constrain_exports, {
23
- constrainRect: () => constrainRect
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(constrain_exports);
26
- var constrainRect = (rect, boundary) => {
27
- const left = Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width));
28
- const top = Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height));
29
- return {
30
- x: left,
31
- y: top,
32
- width: Math.min(rect.width, boundary.width),
33
- height: Math.min(rect.height, boundary.height)
34
- };
5
+ // src/constrain.ts
6
+ const constrainRect = (rect, boundary) => {
7
+ return {
8
+ x: Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width)),
9
+ y: Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height)),
10
+ width: Math.min(rect.width, boundary.width),
11
+ height: Math.min(rect.height, boundary.height)
12
+ };
35
13
  };
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- constrainRect
39
- });
14
+ exports.constrainRect = constrainRect;
@@ -1,16 +1,10 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
1
  // src/constrain.ts
4
- var constrainRect = (rect, boundary) => {
5
- const left = Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width));
6
- const top = Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height));
7
- return {
8
- x: left,
9
- y: top,
10
- width: Math.min(rect.width, boundary.width),
11
- height: Math.min(rect.height, boundary.height)
12
- };
13
- };
14
- export {
15
- constrainRect
2
+ const constrainRect = (rect, boundary) => {
3
+ return {
4
+ x: Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width)),
5
+ y: Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height)),
6
+ width: Math.min(rect.width, boundary.width),
7
+ height: Math.min(rect.height, boundary.height)
8
+ };
16
9
  };
10
+ export { constrainRect };
@@ -1,7 +1,4 @@
1
- import { Rect, Point } from './types.mjs';
2
-
3
- declare function containsPoint(r: Rect, p: Point): boolean;
4
- declare function containsRect(a: Rect, b: Rect): boolean;
5
- declare function contains(r: Rect, v: Rect | Point): boolean;
6
-
7
- export { contains, containsPoint, containsRect };
1
+ import { Point, Rect } from "./types.mjs";
2
+ export declare function containsPoint(r: Rect, p: Point): boolean;
3
+ export declare function containsRect(a: Rect, b: Rect): boolean;
4
+ export declare function contains(r: Rect, v: Rect | Point): boolean;
@@ -1,7 +1,4 @@
1
- import { Rect, Point } from './types.js';
2
-
3
- declare function containsPoint(r: Rect, p: Point): boolean;
4
- declare function containsRect(a: Rect, b: Rect): boolean;
5
- declare function contains(r: Rect, v: Rect | Point): boolean;
6
-
7
- export { contains, containsPoint, containsRect };
1
+ import { Point, Rect } from "./types.js";
2
+ export declare function containsPoint(r: Rect, p: Point): boolean;
3
+ export declare function containsRect(a: Rect, b: Rect): boolean;
4
+ export declare function contains(r: Rect, v: Rect | Point): boolean;