@synnaxlabs/x 0.44.3 → 0.45.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.
- package/.turbo/turbo-build.log +37 -41
- package/dist/{base-DFq0vvGn.js → base-DRybODwJ.js} +16 -12
- package/dist/base-KIBsp6TI.cjs +1 -0
- package/dist/binary.cjs +1 -1
- package/dist/binary.js +1 -1
- package/dist/{bounds-CRK04jp7.cjs → bounds-C2TKFgVk.cjs} +1 -1
- package/dist/{bounds-8OC_obRs.js → bounds-DeUXrllt.js} +11 -11
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/{box-CO_2_DGG.js → box-BYuq-Gjx.js} +67 -73
- package/dist/box-Blu-4d1n.cjs +1 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +1 -1
- package/dist/caseconv.cjs +1 -1
- package/dist/caseconv.js +1 -1
- package/dist/compare.cjs +1 -1
- package/dist/compare.js +1 -1
- package/dist/{dimensions-D2QGoNXO.cjs → dimensions-Cg5Owbwn.cjs} +1 -1
- package/dist/{dimensions-CRgergMS.js → dimensions-DC0uLPwn.js} +1 -1
- package/dist/dimensions.cjs +1 -1
- package/dist/dimensions.js +1 -1
- package/dist/direction-C_b4tfRN.js +19 -0
- package/dist/direction-DqQB9M37.cjs +1 -0
- package/dist/direction.cjs +1 -1
- package/dist/direction.js +1 -1
- package/dist/{index-B5l_quQn.js → index-BHXRDFYj.js} +1 -1
- package/dist/index-Bxlv0uf_.js +57 -0
- package/dist/{index-CBMHFqs4.js → index-C452Pas0.js} +25 -22
- package/dist/{index-BQe8OIgm.cjs → index-CwGPVvbl.cjs} +1 -1
- package/dist/index-uDxeM-cl.cjs +1 -0
- package/dist/index-xaxa1hoa.cjs +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +452 -392
- package/dist/location-BPoXwOni.cjs +1 -0
- package/dist/{location-Ar5y2DX2.js → location-CVxysrHI.js} +40 -44
- package/dist/location.cjs +1 -1
- package/dist/location.js +1 -1
- package/dist/record-BwjIgrpU.cjs +1 -0
- package/dist/record-tSFQKmdG.js +19 -0
- package/dist/record.cjs +1 -1
- package/dist/record.js +1 -1
- package/dist/{scale-C3fEtXxW.cjs → scale-BHs716im.cjs} +1 -1
- package/dist/{scale-Db1Gunj0.js → scale-DjxC6ep2.js} +4 -4
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/series-C6ZwNf8i.cjs +6 -0
- package/dist/{series-Cl3Vh_u-.js → series-W5Aafjeu.js} +303 -270
- package/dist/{spatial-BSWPzMkK.js → spatial-DnsaOypA.js} +1 -1
- package/dist/{spatial-DGpZ2sO3.cjs → spatial-DrxzaD5U.cjs} +1 -1
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +14 -16
- package/dist/src/caseconv/caseconv.d.ts +9 -0
- package/dist/src/caseconv/caseconv.d.ts.map +1 -1
- package/dist/src/color/color.d.ts +7 -0
- package/dist/src/color/color.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/primitive/primitive.d.ts +4 -0
- package/dist/src/primitive/primitive.d.ts.map +1 -1
- package/dist/src/record/record.d.ts +18 -0
- package/dist/src/record/record.d.ts.map +1 -1
- package/dist/src/spatial/base.d.ts +12 -0
- package/dist/src/spatial/base.d.ts.map +1 -1
- package/dist/src/spatial/direction/direction.d.ts +5 -1
- package/dist/src/spatial/direction/direction.d.ts.map +1 -1
- package/dist/src/spatial/external.d.ts +0 -1
- package/dist/src/spatial/external.d.ts.map +1 -1
- package/dist/src/spatial/location/location.d.ts +2 -2
- package/dist/src/spatial/location/location.d.ts.map +1 -1
- package/dist/src/spatial/xy/xy.d.ts +3 -0
- package/dist/src/spatial/xy/xy.d.ts.map +1 -1
- package/dist/src/status/status.d.ts +2 -1
- package/dist/src/status/status.d.ts.map +1 -1
- package/dist/src/telem/series.d.ts +1 -0
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +23 -6
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/src/undefined.d.ts +2 -0
- package/dist/src/undefined.d.ts.map +1 -0
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/dist/xy-DWwtHmgn.cjs +1 -0
- package/dist/{xy-C_-hb3Q2.js → xy-DYPw8-8C.js} +41 -31
- package/dist/xy.cjs +1 -1
- package/dist/xy.js +1 -1
- package/package.json +2 -7
- package/src/caseconv/caseconv.spec.ts +30 -0
- package/src/caseconv/caseconv.ts +46 -0
- package/src/color/color.spec.ts +40 -0
- package/src/color/color.ts +72 -0
- package/src/index.ts +1 -0
- package/src/primitive/primitive.spec.ts +9 -0
- package/src/primitive/primitive.ts +9 -0
- package/src/record/record.spec.ts +31 -0
- package/src/record/record.ts +23 -0
- package/src/spatial/base.ts +4 -0
- package/src/spatial/direction/direction.spec.ts +35 -1
- package/src/spatial/direction/direction.ts +12 -0
- package/src/spatial/external.ts +0 -1
- package/src/spatial/location/location.ts +2 -0
- package/src/spatial/xy/xy.spec.ts +124 -7
- package/src/spatial/xy/xy.ts +15 -2
- package/src/status/status.spec.ts +52 -0
- package/src/status/status.ts +19 -6
- package/src/telem/series.ts +2 -0
- package/src/telem/telem.spec.ts +352 -0
- package/src/telem/telem.ts +85 -18
- package/src/{spatial/position/index.ts → undefined.ts} +5 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +0 -1
- package/dist/base-BAM2mqCy.cjs +0 -1
- package/dist/box-Cxki783Y.cjs +0 -1
- package/dist/direction-386XDm2w.cjs +0 -1
- package/dist/direction-8etxfKaR.js +0 -17
- package/dist/index-D2xcvEO5.js +0 -46
- package/dist/index-DOJlZHqJ.cjs +0 -1
- package/dist/index-DdhM_E4k.cjs +0 -1
- package/dist/location-DZi8ftXp.cjs +0 -1
- package/dist/position-DSy2hONH.cjs +0 -1
- package/dist/position-PQ6op54I.js +0 -85
- package/dist/position.cjs +0 -1
- package/dist/position.js +0 -4
- package/dist/record-CAcQ5PNX.js +0 -14
- package/dist/record-YvCh7bzB.cjs +0 -1
- package/dist/series-BcF7A8Je.cjs +0 -6
- package/dist/src/spatial/position/index.d.ts +0 -2
- package/dist/src/spatial/position/index.d.ts.map +0 -1
- package/dist/src/spatial/position/position.d.ts +0 -20
- package/dist/src/spatial/position/position.d.ts.map +0 -1
- package/dist/src/spatial/position/position.spec.d.ts +0 -2
- package/dist/src/spatial/position/position.spec.d.ts.map +0 -1
- package/dist/xy-CUE3QDNn.cjs +0 -1
- package/src/spatial/position/position.spec.ts +0 -211
- package/src/spatial/position/position.ts +0 -157
|
@@ -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
|
-
};
|