@synnaxlabs/x 0.44.2 → 0.44.4

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 (131) hide show
  1. package/.turbo/turbo-build.log +35 -39
  2. package/dist/base-BLNViP3D.cjs +1 -0
  3. package/dist/{base-DFq0vvGn.js → base-BORMP3mH.js} +14 -11
  4. package/dist/bounds-BQqppNFf.js +186 -0
  5. package/dist/bounds-BXbqBINt.cjs +1 -0
  6. package/dist/bounds.cjs +1 -1
  7. package/dist/bounds.js +1 -1
  8. package/dist/{box-CO_2_DGG.js → box-DRH5SOaY.js} +67 -73
  9. package/dist/box-qgxWXNhm.cjs +1 -0
  10. package/dist/box.cjs +1 -1
  11. package/dist/box.js +1 -1
  12. package/dist/deep.cjs +1 -1
  13. package/dist/deep.js +1 -1
  14. package/dist/{dimensions-CRgergMS.js → dimensions-RaRkesPq.js} +1 -1
  15. package/dist/{dimensions-D2QGoNXO.cjs → dimensions-qY12pyfC.cjs} +1 -1
  16. package/dist/dimensions.cjs +1 -1
  17. package/dist/dimensions.js +1 -1
  18. package/dist/direction-DKdfJwj7.js +19 -0
  19. package/dist/direction-XCdrc4is.cjs +1 -0
  20. package/dist/direction.cjs +1 -1
  21. package/dist/direction.js +1 -1
  22. package/dist/{external-Birv9jaY.js → external-BM_NS5yM.js} +6 -6
  23. package/dist/external-E3ErJeeM.cjs +1 -0
  24. package/dist/index.cjs +3 -3
  25. package/dist/index.js +244 -240
  26. package/dist/{location-Ar5y2DX2.js → location-CGLioInQ.js} +16 -21
  27. package/dist/location-DJ_K4SlP.cjs +1 -0
  28. package/dist/location.cjs +1 -1
  29. package/dist/location.js +1 -1
  30. package/dist/{path-DVFrKaNI.js → path-Blh4wJuA.js} +24 -21
  31. package/dist/path-CPSfCjde.cjs +1 -0
  32. package/dist/record-BwjIgrpU.cjs +1 -0
  33. package/dist/record-tSFQKmdG.js +19 -0
  34. package/dist/record.cjs +1 -1
  35. package/dist/record.js +1 -1
  36. package/dist/{scale-C6qKDbRb.cjs → scale-76Azh2EE.cjs} +1 -1
  37. package/dist/{scale-EWNUk-bn.js → scale-BhIvACdB.js} +4 -4
  38. package/dist/scale.cjs +1 -1
  39. package/dist/scale.js +1 -1
  40. package/dist/{series-EA1uaEDj.js → series-kgnLXSDr.js} +622 -489
  41. package/dist/series-tAhThbnz.cjs +6 -0
  42. package/dist/{spatial-DGpZ2sO3.cjs → spatial-BsGadoUr.cjs} +1 -1
  43. package/dist/{spatial-BSWPzMkK.js → spatial-QY891r0E.js} +1 -1
  44. package/dist/spatial.cjs +1 -1
  45. package/dist/spatial.js +14 -16
  46. package/dist/src/breaker/breaker.d.ts +2 -1
  47. package/dist/src/breaker/breaker.d.ts.map +1 -1
  48. package/dist/src/deep/path.d.ts.map +1 -1
  49. package/dist/src/id/id.d.ts +3 -1
  50. package/dist/src/id/id.d.ts.map +1 -1
  51. package/dist/src/math/math.d.ts +2 -1
  52. package/dist/src/math/math.d.ts.map +1 -1
  53. package/dist/src/record/record.d.ts +18 -0
  54. package/dist/src/record/record.d.ts.map +1 -1
  55. package/dist/src/spatial/base.d.ts +12 -0
  56. package/dist/src/spatial/base.d.ts.map +1 -1
  57. package/dist/src/spatial/direction/direction.d.ts +5 -1
  58. package/dist/src/spatial/direction/direction.d.ts.map +1 -1
  59. package/dist/src/spatial/external.d.ts +0 -1
  60. package/dist/src/spatial/external.d.ts.map +1 -1
  61. package/dist/src/spatial/xy/xy.d.ts +3 -0
  62. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  63. package/dist/src/status/status.d.ts +1 -0
  64. package/dist/src/status/status.d.ts.map +1 -1
  65. package/dist/src/strings/strings.d.ts +1 -1
  66. package/dist/src/strings/strings.d.ts.map +1 -1
  67. package/dist/src/telem/series.d.ts +7 -0
  68. package/dist/src/telem/series.d.ts.map +1 -1
  69. package/dist/src/telem/telem.d.ts +86 -1
  70. package/dist/src/telem/telem.d.ts.map +1 -1
  71. package/dist/src/zod/util.d.ts.map +1 -1
  72. package/dist/telem.cjs +1 -1
  73. package/dist/telem.js +1 -1
  74. package/dist/xy-BKIJiLu_.cjs +1 -0
  75. package/dist/{xy-C_-hb3Q2.js → xy-CBuhMaIo.js} +41 -31
  76. package/dist/xy.cjs +1 -1
  77. package/dist/xy.js +1 -1
  78. package/dist/zod.cjs +1 -1
  79. package/dist/zod.js +1 -1
  80. package/package.json +3 -8
  81. package/src/breaker/breaker.ts +4 -0
  82. package/src/deep/path.spec.ts +14 -0
  83. package/src/deep/path.ts +9 -2
  84. package/src/id/id.ts +8 -4
  85. package/src/math/math.spec.ts +20 -0
  86. package/src/math/math.ts +32 -29
  87. package/src/record/record.spec.ts +31 -0
  88. package/src/record/record.ts +23 -0
  89. package/src/spatial/base.ts +4 -0
  90. package/src/spatial/bounds/bounds.ts +1 -1
  91. package/src/spatial/direction/direction.spec.ts +35 -1
  92. package/src/spatial/direction/direction.ts +12 -0
  93. package/src/spatial/external.ts +0 -1
  94. package/src/spatial/xy/xy.spec.ts +124 -7
  95. package/src/spatial/xy/xy.ts +15 -2
  96. package/src/status/status.ts +11 -0
  97. package/src/strings/strings.spec.ts +3 -0
  98. package/src/strings/strings.ts +2 -1
  99. package/src/telem/series.spec.ts +543 -2
  100. package/src/telem/series.ts +28 -9
  101. package/src/telem/telem.spec.ts +606 -0
  102. package/src/telem/telem.ts +143 -5
  103. package/src/zod/util.ts +5 -3
  104. package/tsconfig.tsbuildinfo +1 -1
  105. package/vite.config.ts +0 -1
  106. package/dist/base-BAM2mqCy.cjs +0 -1
  107. package/dist/bounds-D6e9xoHt.cjs +0 -1
  108. package/dist/bounds-Dj9nG39I.js +0 -174
  109. package/dist/box-Cxki783Y.cjs +0 -1
  110. package/dist/direction-386XDm2w.cjs +0 -1
  111. package/dist/direction-8etxfKaR.js +0 -17
  112. package/dist/external-DsmsSN1Y.cjs +0 -1
  113. package/dist/location-DZi8ftXp.cjs +0 -1
  114. package/dist/path-BeMr8xWN.cjs +0 -1
  115. package/dist/position-DSy2hONH.cjs +0 -1
  116. package/dist/position-PQ6op54I.js +0 -85
  117. package/dist/position.cjs +0 -1
  118. package/dist/position.js +0 -4
  119. package/dist/record-CAcQ5PNX.js +0 -14
  120. package/dist/record-YvCh7bzB.cjs +0 -1
  121. package/dist/series-CcA_WjbJ.cjs +0 -6
  122. package/dist/src/spatial/position/index.d.ts +0 -2
  123. package/dist/src/spatial/position/index.d.ts.map +0 -1
  124. package/dist/src/spatial/position/position.d.ts +0 -20
  125. package/dist/src/spatial/position/position.d.ts.map +0 -1
  126. package/dist/src/spatial/position/position.spec.d.ts +0 -2
  127. package/dist/src/spatial/position/position.spec.d.ts.map +0 -1
  128. package/dist/xy-CUE3QDNn.cjs +0 -1
  129. package/src/spatial/position/index.ts +0 -10
  130. package/src/spatial/position/position.spec.ts +0 -211
  131. package/src/spatial/position/position.ts +0 -157
@@ -1,211 +0,0 @@
1
- // Copyright 2025 Synnax Labs, Inc.
2
- //
3
- // Use of this software is governed by the Business Source License included in the file
4
- // licenses/BSL.txt.
5
- //
6
- // As of the Change Date specified in that file, in accordance with the Business Source
7
- // License, use of this software will be governed by the Apache License, Version 2.0,
8
- // included in the file licenses/APL.txt.
9
-
10
- import { describe, expect, it } from "vitest";
11
-
12
- import { box } from "@/spatial";
13
- import { type Alignment } from "@/spatial/base";
14
- import { location } from "@/spatial/location";
15
- import { position } from "@/spatial/position";
16
-
17
- type Spec = [position.DialogProps, location.XY];
18
-
19
- describe("position", () => {
20
- describe("dialog", () => {
21
- const SPEC_CASE_1: Spec = [
22
- {
23
- container: box.construct(0, 0, 100, 100),
24
- target: box.construct(45, 55, 10, 10),
25
- dialog: box.construct(0, 0, 20, 20),
26
- },
27
- location.CENTER_LEFT,
28
- ];
29
-
30
- const SPEC_CASE_2: Spec = [
31
- {
32
- container: box.construct(0, 0, 100, 100),
33
- target: box.construct(45, 55, 10, 10),
34
- dialog: box.construct(0, 0, 20, 20),
35
- initial: "top",
36
- },
37
- location.TOP_CENTER,
38
- ];
39
-
40
- const SPEC_CASE_3: Spec = [
41
- {
42
- container: box.construct(0, 0, 100, 100),
43
- target: box.construct(45, 55, 10, 10),
44
- dialog: box.construct(0, 0, 20, 20),
45
- initial: "bottom",
46
- },
47
- location.BOTTOM_CENTER,
48
- ];
49
-
50
- const SPEC_CASE_4: Spec = [
51
- {
52
- container: box.construct(0, 0, 100, 100),
53
- target: box.construct(45, 55, 10, 10),
54
- dialog: box.construct(0, 0, 20, 20),
55
- initial: "left",
56
- },
57
- location.CENTER_LEFT,
58
- ];
59
-
60
- const SPEC_CASE_5: Spec = [
61
- {
62
- container: box.construct(0, 0, 100, 100),
63
- target: box.construct(45, 55, 10, 10),
64
- dialog: box.construct(0, 0, 20, 20),
65
- initial: "right",
66
- },
67
- location.CENTER_RIGHT,
68
- ];
69
-
70
- // Target is in bottom right corner
71
- const SPEC_CASE_6: Spec = [
72
- {
73
- container: box.construct(0, 0, 100, 100),
74
- target: box.construct(90, 90, 10, 10),
75
- dialog: box.construct(0, 0, 20, 20),
76
- },
77
- location.CENTER_LEFT,
78
- ];
79
-
80
- // Target is in the top left corner
81
- const SPEC_CASE_7: Spec = [
82
- {
83
- container: box.construct(0, 0, 100, 100),
84
- target: box.construct(0, 0, 10, 10),
85
- dialog: box.construct(0, 0, 20, 20),
86
- },
87
- location.BOTTOM_CENTER,
88
- ];
89
-
90
- const SPEC_CASE_8: Spec = [
91
- {
92
- container: {
93
- one: { x: 0, y: 0 },
94
- two: { x: 1707, y: 1075 },
95
- root: { x: "left", y: "top" },
96
- },
97
- target: {
98
- one: { x: 79, y: 965 },
99
- two: { x: 1647, y: 992 },
100
- root: { x: "left", y: "top" },
101
- },
102
- dialog: {
103
- one: { x: 79.53125, y: 781 },
104
- two: { x: 1647.53125, y: 1141 },
105
- root: { x: "left", y: "top" },
106
- },
107
- initial: { x: "center" },
108
- alignments: ["center"],
109
- },
110
- location.TOP_CENTER,
111
- ];
112
-
113
- const SPEC_CASE_9: Spec = [
114
- {
115
- container: {
116
- one: { x: 0, y: 0 },
117
- two: { x: 1707, y: 697 },
118
- root: { x: "left", y: "top" },
119
- },
120
- target: {
121
- one: { x: 79, y: 587 },
122
- two: { x: 1647, y: 614 },
123
- root: { x: "left", y: "top" },
124
- },
125
- dialog: {
126
- one: { x: 79, y: 991 },
127
- two: { x: 1647, y: 1351 },
128
- root: { x: "left", y: "top" },
129
- },
130
- initial: { x: "center" },
131
- alignments: ["center"],
132
- },
133
- location.TOP_CENTER,
134
- ];
135
-
136
- // const SPEC_CASE_10 = [
137
- // {
138
- // container: {
139
- // one: { x: 0, y: 0 },
140
- // two: { x: 1707, y: 697 },
141
- // root: { x: "left", y: "top" },
142
- // },
143
- // target: {
144
- // one: { x: 78, y: 4 },
145
- // two: { x: 278, y: 31 },
146
- // root: { x: "left", y: "top" },
147
- // },
148
- // dialog: {
149
- // one: { x: 78, y: 4 },
150
- // two: { x: 78, y: 4 },
151
- // root: { x: "left", y: "top" },
152
- // },
153
- // alignments: ["end"],
154
- // disable: ["center"],
155
- // },
156
- // location.BOTTOM_LEFT,
157
- // ];
158
-
159
- const SPECS: Spec[] = [
160
- SPEC_CASE_1,
161
- SPEC_CASE_2,
162
- SPEC_CASE_3,
163
- SPEC_CASE_4,
164
- SPEC_CASE_5,
165
- SPEC_CASE_6,
166
- SPEC_CASE_7,
167
- SPEC_CASE_8,
168
- SPEC_CASE_9,
169
- // SPEC_CASE_10,
170
- ];
171
-
172
- SPECS.forEach(([props, expected]) => {
173
- it(`should position dialog correctly`, () => {
174
- expect(position.dialog(props).location).toEqual(expected);
175
- });
176
- });
177
- });
178
- describe("getRoot", () => {
179
- const SPECS: Array<[location.XY, Alignment, location.XY]> = [
180
- [location.TOP_LEFT, "start", location.BOTTOM_RIGHT],
181
- [location.TOP_LEFT, "center", location.BOTTOM_CENTER],
182
- [location.TOP_LEFT, "end", location.BOTTOM_LEFT],
183
- [location.TOP_RIGHT, "start", location.BOTTOM_LEFT],
184
- [location.TOP_RIGHT, "center", location.BOTTOM_CENTER],
185
- [location.TOP_RIGHT, "end", location.BOTTOM_RIGHT],
186
- [location.TOP_CENTER, "start", location.BOTTOM_LEFT],
187
- [location.TOP_CENTER, "center", location.BOTTOM_CENTER],
188
- [location.TOP_CENTER, "end", location.BOTTOM_RIGHT],
189
- [location.CENTER_LEFT, "start", location.BOTTOM_RIGHT],
190
- [location.CENTER_LEFT, "center", location.CENTER_RIGHT],
191
- [location.CENTER_LEFT, "end", location.TOP_RIGHT],
192
- [location.CENTER_RIGHT, "start", location.BOTTOM_LEFT],
193
- [location.CENTER_RIGHT, "center", location.CENTER_LEFT],
194
- [location.CENTER_RIGHT, "end", location.TOP_LEFT],
195
- [location.BOTTOM_LEFT, "start", location.TOP_RIGHT],
196
- [location.BOTTOM_LEFT, "center", location.TOP_CENTER],
197
- [location.BOTTOM_LEFT, "end", location.TOP_LEFT],
198
- [location.BOTTOM_RIGHT, "start", location.TOP_LEFT],
199
- [location.BOTTOM_RIGHT, "center", location.TOP_CENTER],
200
- [location.BOTTOM_RIGHT, "end", location.TOP_RIGHT],
201
- [location.BOTTOM_CENTER, "start", location.TOP_LEFT],
202
- [location.BOTTOM_CENTER, "center", location.TOP_CENTER],
203
- [location.BOTTOM_CENTER, "end", location.TOP_RIGHT],
204
- ];
205
- SPECS.forEach(([option, order, expected]) => {
206
- it(`should position get the correct positioning root for ${location.xyToString(option)} and ${order}`, () => {
207
- expect(position.getRoot(option, order)).toEqual(expected);
208
- });
209
- });
210
- });
211
- });
@@ -1,157 +0,0 @@
1
- // Copyright 2025 Synnax Labs, Inc.
2
- //
3
- // Use of this software is governed by the Business Source License included in the file
4
- // licenses/BSL.txt.
5
- //
6
- // As of the Change Date specified in that file, in accordance with the Business Source
7
- // License, use of this software will be governed by the Apache License, Version 2.0,
8
- // included in the file licenses/APL.txt.
9
-
10
- import { type Alignment, type XLocation, type YLocation } from "@/spatial/base";
11
- import { box } from "@/spatial/box";
12
- import { direction } from "@/spatial/direction";
13
- import { location } from "@/spatial/location";
14
-
15
- export interface DialogProps {
16
- container: box.Crude;
17
- target: box.Crude;
18
- dialog: box.Crude;
19
- alignments?: Alignment[];
20
- initial?: location.Outer | Partial<location.XY> | location.XY;
21
- prefer?: Array<location.Outer | Partial<location.XY> | location.XY>;
22
- disable?: Array<location.Location | Partial<location.XY>>;
23
- }
24
-
25
- export const parseLocationOptions = (
26
- initial?: location.Outer | Partial<location.XY> | location.XY,
27
- ): Partial<location.XY> => {
28
- if (initial == null) return { x: undefined, y: undefined };
29
- const parsedXYLoc = location.xy.safeParse(initial);
30
- if (parsedXYLoc.success) return parsedXYLoc.data;
31
- const parsedLoc = location.location.safeParse(initial);
32
- if (parsedLoc.success) {
33
- const isX = direction.construct(parsedLoc.data) === "x";
34
- return isX
35
- ? { x: parsedLoc.data as XLocation, y: undefined }
36
- : { x: undefined, y: parsedLoc.data as YLocation };
37
- }
38
- return initial as Partial<location.XY>;
39
- };
40
-
41
- export interface DialogReturn {
42
- location: location.XY;
43
- adjustedDialog: box.Box;
44
- }
45
-
46
- export const dialog = ({
47
- container: containerCrude,
48
- target: targetCrude,
49
- dialog: dialogCrude,
50
- initial,
51
- prefer,
52
- alignments = ["start"],
53
- disable = [],
54
- }: DialogProps): DialogReturn => {
55
- const initialLocs = parseLocationOptions(initial);
56
-
57
- let options = location.XY_LOCATIONS;
58
- if (prefer != null) {
59
- const parsedPrefer = prefer.map((p) => parseLocationOptions(p));
60
- options = options.slice().sort((a, b) => {
61
- const hasPreferA = parsedPrefer.findIndex((p) => location.xyMatches(a, p));
62
- const hasPreferB = parsedPrefer.findIndex((p) => location.xyMatches(b, p));
63
- if (hasPreferA > -1 && hasPreferB > -1) return hasPreferA - hasPreferB;
64
- if (hasPreferA > -1) return -1;
65
- if (hasPreferB > -1) return 1;
66
- return 0;
67
- });
68
- }
69
- const mappedOptions = options
70
- .filter(
71
- (l) =>
72
- !location.xyEquals(l, location.CENTER) &&
73
- (initialLocs.x == null || l.x === initialLocs.x) &&
74
- (initialLocs.y == null || l.y === initialLocs.y) &&
75
- !disable.some((d) => location.xyMatches(l, d)),
76
- )
77
- .map((l) => alignments?.map((a) => [l, a]))
78
- .flat() as Array<[location.XY, Alignment]>;
79
-
80
- const container = box.construct(containerCrude);
81
- const target = box.construct(targetCrude);
82
- const dialog = box.construct(dialogCrude);
83
-
84
- // maximum value of a number in js
85
- let bestOptionArea = -Infinity;
86
- const res: DialogReturn = { location: location.CENTER, adjustedDialog: dialog };
87
- mappedOptions.forEach(([option, alignment]) => {
88
- const [adjustedBox, area] = evaluateOption({
89
- option,
90
- alignment,
91
- container,
92
- target,
93
- dialog,
94
- });
95
- if (area > bestOptionArea) {
96
- bestOptionArea = area;
97
- res.location = option;
98
- res.adjustedDialog = adjustedBox;
99
- }
100
- });
101
-
102
- return res;
103
- };
104
-
105
- interface EvaluateOptionProps {
106
- option: location.XY;
107
- alignment: Alignment;
108
- container: box.Box;
109
- target: box.Box;
110
- dialog: box.Box;
111
- }
112
-
113
- const evaluateOption = ({
114
- option,
115
- alignment,
116
- container,
117
- target,
118
- dialog,
119
- }: EvaluateOptionProps): [box.Box, number] => {
120
- const root = getRoot(option, alignment);
121
- const targetPoint = box.xyLoc(target, option);
122
- const dialogBox = box.constructWithAlternateRoot(
123
- targetPoint.x,
124
- targetPoint.y,
125
- box.width(dialog),
126
- box.height(dialog),
127
- root,
128
- location.TOP_LEFT,
129
- );
130
- const area = box.area(box.intersection(dialogBox, container));
131
- return [dialogBox, area];
132
- };
133
-
134
- const X_ALIGNMENT_MAP: Record<Alignment, location.X | location.Center> = {
135
- start: "left",
136
- center: "center",
137
- end: "right",
138
- };
139
-
140
- const Y_ALIGNMENT_MAP: Record<Alignment, location.Y | location.Center> = {
141
- start: "bottom",
142
- center: "center",
143
- end: "top",
144
- };
145
-
146
- export const getRoot = (option: location.XY, alignment: Alignment): location.XY => {
147
- const out: location.XY = { x: "center", y: "center" };
148
- if (option.y !== "center") {
149
- out.y = location.swap(option.y) as location.Y;
150
- const swapper = option.x === "left" ? location.swap : (v: location.Location) => v;
151
- out.x = swapper(X_ALIGNMENT_MAP[alignment]) as location.X;
152
- } else {
153
- out.x = location.swap(option.x) as location.X;
154
- out.y = Y_ALIGNMENT_MAP[alignment];
155
- }
156
- return out;
157
- };