@synnaxlabs/x 0.7.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/.eslintrc.cjs +18 -0
- package/.turbo/turbo-build.log +16 -0
- package/.vscode/settings.json +3 -0
- package/LICENSE +4 -0
- package/README.md +44 -0
- package/dist/binary/encoder.d.ts +59 -0
- package/dist/binary/encoder.spec.d.ts +1 -0
- package/dist/binary/index.d.ts +1 -0
- package/dist/case.d.ts +5 -0
- package/dist/change/change.d.ts +32 -0
- package/dist/change/index.d.ts +1 -0
- package/dist/clamp.d.ts +1 -0
- package/dist/compare/compare.d.ts +39 -0
- package/dist/compare/index.d.ts +1 -0
- package/dist/debounce.d.ts +2 -0
- package/dist/deep/copy.d.ts +1 -0
- package/dist/deep/delete.d.ts +2 -0
- package/dist/deep/delete.spec.d.ts +1 -0
- package/dist/deep/equal.d.ts +8 -0
- package/dist/deep/equal.spec.d.ts +1 -0
- package/dist/deep/external.d.ts +7 -0
- package/dist/deep/index.d.ts +1 -0
- package/dist/deep/key.d.ts +30 -0
- package/dist/deep/memo.d.ts +1 -0
- package/dist/deep/merge.d.ts +2 -0
- package/dist/deep/merge.spec.d.ts +1 -0
- package/dist/deep/partial.d.ts +3 -0
- package/dist/destructor.d.ts +1 -0
- package/dist/identity.d.ts +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/join.d.ts +1 -0
- package/dist/kv/index.d.ts +1 -0
- package/dist/kv/types.d.ts +32 -0
- package/dist/mock/MockGLBufferController.d.ts +20 -0
- package/dist/mock/index.d.ts +1 -0
- package/dist/observe/index.d.ts +1 -0
- package/dist/observe/observe.d.ts +11 -0
- package/dist/optional.d.ts +1 -0
- package/dist/primitive.d.ts +8 -0
- package/dist/record.d.ts +14 -0
- package/dist/renderable.d.ts +4 -0
- package/dist/runtime/detect.d.ts +9 -0
- package/dist/runtime/external.d.ts +2 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/os.d.ts +9 -0
- package/dist/search.d.ts +15 -0
- package/dist/spatial/base.d.ts +102 -0
- package/dist/spatial/bounds.d.ts +31 -0
- package/dist/spatial/bounds.spec.d.ts +1 -0
- package/dist/spatial/box.d.ts +265 -0
- package/dist/spatial/box.spec.d.ts +1 -0
- package/dist/spatial/dimensions.d.ts +59 -0
- package/dist/spatial/dimensions.spec.d.ts +1 -0
- package/dist/spatial/direction.d.ts +10 -0
- package/dist/spatial/direction.spec.d.ts +1 -0
- package/dist/spatial/external.d.ts +8 -0
- package/dist/spatial/index.d.ts +1 -0
- package/dist/spatial/location.d.ts +52 -0
- package/dist/spatial/location.spec.d.ts +1 -0
- package/dist/spatial/position.d.ts +2 -0
- package/dist/spatial/scale.d.ts +241 -0
- package/dist/spatial/scale.spec.d.ts +1 -0
- package/dist/spatial/spatial.d.ts +1 -0
- package/dist/spatial/xy.d.ts +116 -0
- package/dist/spatial/xy.spec.d.ts +1 -0
- package/dist/telem/encode.d.ts +1 -0
- package/dist/telem/generate.d.ts +2 -0
- package/dist/telem/gl.d.ts +11 -0
- package/dist/telem/index.d.ts +3 -0
- package/dist/telem/series.d.ts +104 -0
- package/dist/telem/series.spec.d.ts +1 -0
- package/dist/telem/telem.d.ts +633 -0
- package/dist/telem/telem.spec.d.ts +1 -0
- package/dist/toArray.d.ts +1 -0
- package/dist/transform.d.ts +1 -0
- package/dist/unique.d.ts +1 -0
- package/dist/url/index.d.ts +1 -0
- package/dist/url/url.d.ts +46 -0
- package/dist/url/url.spec.d.ts +1 -0
- package/dist/worker/worker.d.ts +32 -0
- package/dist/worker/worker.spec.d.ts +1 -0
- package/dist/x.cjs.js +9046 -0
- package/dist/x.cjs.js.map +1 -0
- package/dist/x.es.js +9047 -0
- package/dist/x.es.js.map +1 -0
- package/package.json +42 -0
- package/src/binary/encoder.spec.ts +31 -0
- package/src/binary/encoder.ts +118 -0
- package/src/binary/index.ts +10 -0
- package/src/case.ts +31 -0
- package/src/change/change.ts +31 -0
- package/src/change/index.ts +10 -0
- package/src/clamp.ts +14 -0
- package/src/compare/compare.ts +116 -0
- package/src/compare/index.ts +10 -0
- package/src/debounce.ts +45 -0
- package/src/deep/copy.ts +13 -0
- package/src/deep/delete.spec.ts +36 -0
- package/src/deep/delete.ts +27 -0
- package/src/deep/equal.spec.ts +82 -0
- package/src/deep/equal.ts +65 -0
- package/src/deep/external.ts +15 -0
- package/src/deep/index.ts +10 -0
- package/src/deep/key.ts +46 -0
- package/src/deep/merge.spec.ts +63 -0
- package/src/deep/merge.ts +41 -0
- package/src/deep/partial.ts +14 -0
- package/src/destructor.ts +10 -0
- package/src/identity.ts +14 -0
- package/src/index.ts +34 -0
- package/src/join.ts +14 -0
- package/src/kv/index.ts +10 -0
- package/src/kv/types.ts +52 -0
- package/src/mock/MockGLBufferController.ts +70 -0
- package/src/mock/index.ts +10 -0
- package/src/observe/index.ts +10 -0
- package/src/observe/observe.ts +33 -0
- package/src/optional.ts +10 -0
- package/src/primitive.ts +46 -0
- package/src/record.ts +45 -0
- package/src/renderable.ts +20 -0
- package/src/runtime/detect.ts +34 -0
- package/src/runtime/external.ts +11 -0
- package/src/runtime/index.ts +10 -0
- package/src/runtime/os.ts +38 -0
- package/src/search.ts +40 -0
- package/src/spatial/base.ts +80 -0
- package/src/spatial/bounds.spec.ts +99 -0
- package/src/spatial/bounds.ts +80 -0
- package/src/spatial/box.spec.ts +137 -0
- package/src/spatial/box.ts +326 -0
- package/src/spatial/dimensions.spec.ts +47 -0
- package/src/spatial/dimensions.ts +64 -0
- package/src/spatial/direction.spec.ts +25 -0
- package/src/spatial/direction.ts +47 -0
- package/src/spatial/external.ts +17 -0
- package/src/spatial/index.ts +10 -0
- package/src/spatial/location.spec.ts +24 -0
- package/src/spatial/location.ts +124 -0
- package/src/spatial/position.ts +26 -0
- package/src/spatial/scale.spec.ts +74 -0
- package/src/spatial/scale.ts +351 -0
- package/src/spatial/spatial.ts +17 -0
- package/src/spatial/xy.spec.ts +68 -0
- package/src/spatial/xy.ts +164 -0
- package/src/telem/encode.ts +22 -0
- package/src/telem/generate.ts +19 -0
- package/src/telem/gl.ts +22 -0
- package/src/telem/index.ts +12 -0
- package/src/telem/series.spec.ts +289 -0
- package/src/telem/series.ts +449 -0
- package/src/telem/telem.spec.ts +302 -0
- package/src/telem/telem.ts +1237 -0
- package/src/toArray.ts +11 -0
- package/src/transform.ts +10 -0
- package/src/unique.ts +10 -0
- package/src/url/index.ts +10 -0
- package/src/url/url.spec.ts +47 -0
- package/src/url/url.ts +113 -0
- package/src/worker/worker.spec.ts +41 -0
- package/src/worker/worker.ts +86 -0
- package/tsconfig.json +7 -0
- package/tsconfig.vite.json +4 -0
- package/vite.config.ts +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ALIGNMENTS, alignment, type Alignment, ORDERS, order, type Order, } from '../spatial/base';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { clientXY, xy, type ClientXY, type XY, type Direction } from '../spatial/base';
|
|
3
|
+
export { clientXY, xy, type ClientXY as Client, type XY };
|
|
4
|
+
/** A crude representation of a {@link XY} coordinate as a zod schema. */
|
|
5
|
+
export declare const crudeZ: z.ZodUnion<[z.ZodNumber, z.ZodObject<{
|
|
6
|
+
x: z.ZodNumber;
|
|
7
|
+
y: z.ZodNumber;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}, {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{
|
|
15
|
+
width: z.ZodNumber;
|
|
16
|
+
height: z.ZodNumber;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}, {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}>, z.ZodObject<{
|
|
24
|
+
signedWidth: z.ZodNumber;
|
|
25
|
+
signedHeight: z.ZodNumber;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
signedWidth: number;
|
|
28
|
+
signedHeight: number;
|
|
29
|
+
}, {
|
|
30
|
+
signedWidth: number;
|
|
31
|
+
signedHeight: number;
|
|
32
|
+
}>, z.ZodObject<{
|
|
33
|
+
clientX: z.ZodNumber;
|
|
34
|
+
clientY: z.ZodNumber;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
clientX: number;
|
|
37
|
+
clientY: number;
|
|
38
|
+
}, {
|
|
39
|
+
clientX: number;
|
|
40
|
+
clientY: number;
|
|
41
|
+
}>]>;
|
|
42
|
+
/** A crude representation of a {@link XY} coordinate. */
|
|
43
|
+
export type Crude = z.infer<typeof crudeZ>;
|
|
44
|
+
/**
|
|
45
|
+
* @constructs XY
|
|
46
|
+
* @param x - A crude representation of the XY coordinate as a number, number couple,
|
|
47
|
+
* dimensions, signed dimensions, or client XY.
|
|
48
|
+
* @param y - If x is a number, the y coordinate. If x is a number and this argument is
|
|
49
|
+
* not given, the y coordinate is assumed to be the same as the x coordinate.
|
|
50
|
+
*/
|
|
51
|
+
export declare const construct: (x: Crude, y?: number) => XY;
|
|
52
|
+
/** An x and y coordinate of zero */
|
|
53
|
+
export declare const ZERO: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
/** An x and y coordinate of one */
|
|
58
|
+
export declare const ONE: {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
};
|
|
62
|
+
/** An x and y coordinate of infinity */
|
|
63
|
+
export declare const INFINITY: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
};
|
|
67
|
+
/** An x and y coordinate of NaN */
|
|
68
|
+
export declare const NAN: {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
};
|
|
72
|
+
/** @returns true if the two XY coordinates are semantically equal. */
|
|
73
|
+
export declare const equals: (a: Crude, b: Crude, threshold?: number) => boolean;
|
|
74
|
+
/** Is zero is true if the XY coordinate has a semantic x and y value of zero. */
|
|
75
|
+
export declare const isZero: (c: Crude) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @returns the given coordinate scaled by the given factors. If only one factor is given,
|
|
78
|
+
* the y factor is assumed to be the same as the x factor.
|
|
79
|
+
*/
|
|
80
|
+
export declare const scale: (c: Crude, x: number, y?: number) => XY;
|
|
81
|
+
/** @returns the given coordinate translated in the X direction by the given amount. */
|
|
82
|
+
export declare const translateX: (c: Crude, x: number) => XY;
|
|
83
|
+
/** @returns the given coordinate translated in the Y direction by the given amount. */
|
|
84
|
+
export declare const translateY: (c: Crude, y: number) => XY;
|
|
85
|
+
type TranslateOverloadOne = (a: Crude, b: Crude, ...cb: Crude[]) => XY;
|
|
86
|
+
type TranslateOverloadTwo = (a: Crude, direction: Direction, value: number) => XY;
|
|
87
|
+
/**
|
|
88
|
+
* @returns the given coordinate translated by an arbitrary number of translation
|
|
89
|
+
* coordinates.
|
|
90
|
+
*/
|
|
91
|
+
export declare const translate: TranslateOverloadOne & TranslateOverloadTwo;
|
|
92
|
+
/**
|
|
93
|
+
* @returns the given coordinate the given direction set to the given value.
|
|
94
|
+
* @example set({ x: 1, y: 2 }, "x", 3) // { x: 3, y: 2 }
|
|
95
|
+
*/
|
|
96
|
+
export declare const set: (c: Crude, direction: Direction, value: number) => XY;
|
|
97
|
+
/** @returns the magnitude of the distance between the two given coordinates. */
|
|
98
|
+
export declare const distance: (ca: Crude, cb: Crude) => number;
|
|
99
|
+
/** @returns the magnitude of the x distance between the two given coordinates. */
|
|
100
|
+
export declare const xDistance: (ca: Crude, cb: Crude) => number;
|
|
101
|
+
/** @returns the magnitude of the y distance between the two given coordinates. */
|
|
102
|
+
export declare const yDistance: (ca: Crude, cb: Crude) => number;
|
|
103
|
+
/**
|
|
104
|
+
* @returns the translation that would need to be applied to move the first coordinate
|
|
105
|
+
* to the second coordinate.
|
|
106
|
+
*/
|
|
107
|
+
export declare const translation: (ca: Crude, cb: Crude) => XY;
|
|
108
|
+
/** @returns true if both the x and y coordinates of the given coordinate are NaN. */
|
|
109
|
+
export declare const isNan: (a: Crude) => boolean;
|
|
110
|
+
/** @returns the coordinate represented as a couple of the form [x, y]. */
|
|
111
|
+
export declare const couple: (a: Crude) => [number, number];
|
|
112
|
+
/** @returns the coordinate represented as css properties in the form { left, top }. */
|
|
113
|
+
export declare const css: (a: Crude) => {
|
|
114
|
+
left: number;
|
|
115
|
+
top: number;
|
|
116
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GLBufferController {
|
|
2
|
+
createBuffer: () => WebGLBuffer | null;
|
|
3
|
+
bufferData: ((target: number, data: ArrayBufferLike, usage: number) => void) & ((target: number, size: number, usage: number) => void);
|
|
4
|
+
bufferSubData: (target: number, offset: number, data: ArrayBufferLike) => void;
|
|
5
|
+
bindBuffer: (target: number, buffer: WebGLBuffer | null) => void;
|
|
6
|
+
deleteBuffer: (buffer: WebGLBuffer | null) => void;
|
|
7
|
+
ARRAY_BUFFER: number;
|
|
8
|
+
STATIC_DRAW: number;
|
|
9
|
+
DYNAMIC_DRAW: number;
|
|
10
|
+
}
|
|
11
|
+
export type GLBufferUsage = "static" | "dynamic";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type z } from "zod";
|
|
2
|
+
import { bounds } from '../spatial';
|
|
3
|
+
import { type GLBufferController, type GLBufferUsage } from '../telem/gl';
|
|
4
|
+
import { DataType, type NativeTypedArray, type Rate, Size, TimeRange, type TimeStamp, type CrudeDataType } from '../telem/telem';
|
|
5
|
+
export type SampleValue = number | bigint;
|
|
6
|
+
export interface SeriesDigest {
|
|
7
|
+
dataType: string;
|
|
8
|
+
sampleOffset: SampleValue;
|
|
9
|
+
alignment: number;
|
|
10
|
+
timeRange?: string;
|
|
11
|
+
length: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Series is a strongly typed array of telemetry samples backed by an underlying binary
|
|
15
|
+
* buffer.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Series {
|
|
18
|
+
/** The data type of the array */
|
|
19
|
+
readonly dataType: DataType;
|
|
20
|
+
/**
|
|
21
|
+
* A sample offset that can be used to shift the values of all samples upwards or
|
|
22
|
+
* downwards. Typically used to convert arrays to lower precision while preserving
|
|
23
|
+
* the relative range of actual values.
|
|
24
|
+
*/
|
|
25
|
+
sampleOffset: SampleValue;
|
|
26
|
+
/**
|
|
27
|
+
* Stores information about the buffer state of this array into a WebGL buffer.
|
|
28
|
+
*/
|
|
29
|
+
private readonly gl;
|
|
30
|
+
/** The underlying data. */
|
|
31
|
+
private readonly _data;
|
|
32
|
+
readonly _timeRange?: TimeRange;
|
|
33
|
+
readonly alignment: number;
|
|
34
|
+
/** A cached minimum value. */
|
|
35
|
+
private _min?;
|
|
36
|
+
/** A cached maximum value. */
|
|
37
|
+
private _max?;
|
|
38
|
+
/** The write position of the buffer. */
|
|
39
|
+
private writePos;
|
|
40
|
+
/** Tracks the number of entities currently using this array. */
|
|
41
|
+
private _refCount;
|
|
42
|
+
static alloc(length: number, dataType: CrudeDataType, timeRange?: TimeRange, sampleOffset?: SampleValue, glBufferUsage?: GLBufferUsage, alignment?: number): Series;
|
|
43
|
+
static generateTimestamps(length: number, rate: Rate, start: TimeStamp): Series;
|
|
44
|
+
get refCount(): number;
|
|
45
|
+
static fromStrings(data: string[], timeRange?: TimeRange): Series;
|
|
46
|
+
static fromJSON<T>(data: T[], timeRange?: TimeRange): Series;
|
|
47
|
+
constructor(data: ArrayBuffer | NativeTypedArray, dataType?: CrudeDataType, timeRange?: TimeRange, sampleOffset?: SampleValue, glBufferUsage?: GLBufferUsage, alignment?: number);
|
|
48
|
+
acquire(gl?: GLBufferController): void;
|
|
49
|
+
release(): void;
|
|
50
|
+
write(other: Series): number;
|
|
51
|
+
/** @returns the underlying buffer backing this array. */
|
|
52
|
+
get buffer(): ArrayBufferLike;
|
|
53
|
+
private get underlyingData();
|
|
54
|
+
/** @returns a native typed array with the proper data type. */
|
|
55
|
+
get data(): NativeTypedArray;
|
|
56
|
+
toStrings(): string[];
|
|
57
|
+
toUUIDs(): string[];
|
|
58
|
+
parseJSON<Z extends z.ZodTypeAny>(schema: Z): Array<z.output<Z>>;
|
|
59
|
+
/** @returns the time range of this array. */
|
|
60
|
+
get timeRange(): TimeRange;
|
|
61
|
+
/** @returns the capacity of the underlying buffer in bytes. */
|
|
62
|
+
get byteCap(): Size;
|
|
63
|
+
/** @returns the capacity of the underlying buffer in samples. */
|
|
64
|
+
get cap(): number;
|
|
65
|
+
/** @returns the length of the underlying buffer in samples. */
|
|
66
|
+
get byteLength(): Size;
|
|
67
|
+
/** @returns the number of samples in this array. */
|
|
68
|
+
get length(): number;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new array with a different data type.
|
|
71
|
+
* @param target the data type to convert to.
|
|
72
|
+
* @param sampleOffset an offset to apply to each sample. This can help with precision
|
|
73
|
+
* issues when converting between data types.
|
|
74
|
+
*
|
|
75
|
+
* WARNING: This method is expensive and copies the entire underlying array. There
|
|
76
|
+
* also may be untimely precision issues when converting between data types.
|
|
77
|
+
*/
|
|
78
|
+
convert(target: DataType, sampleOffset?: SampleValue): Series;
|
|
79
|
+
private calcRawMax;
|
|
80
|
+
/** @returns the maximum value in the array */
|
|
81
|
+
get max(): SampleValue;
|
|
82
|
+
private calcRawMin;
|
|
83
|
+
/** @returns the minimum value in the array */
|
|
84
|
+
get min(): SampleValue;
|
|
85
|
+
/** @returns the bounds of this array. */
|
|
86
|
+
get bounds(): bounds.Bounds;
|
|
87
|
+
private maybeRecomputeMinMax;
|
|
88
|
+
enrich(): void;
|
|
89
|
+
get range(): SampleValue;
|
|
90
|
+
at(index: number): SampleValue;
|
|
91
|
+
/**
|
|
92
|
+
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
93
|
+
* The underlying array must be sorted. If it is not, the behavior of this method is undefined.
|
|
94
|
+
* @param value the value to search for.
|
|
95
|
+
*/
|
|
96
|
+
binarySearch(value: SampleValue): number;
|
|
97
|
+
updateGLBuffer(gl: GLBufferController): void;
|
|
98
|
+
get digest(): SeriesDigest;
|
|
99
|
+
private maybeGarbageCollectGLBuffer;
|
|
100
|
+
get glBuffer(): WebGLBuffer;
|
|
101
|
+
slice(start: number, end?: number): Series;
|
|
102
|
+
reAlign(alignment: number): Series;
|
|
103
|
+
}
|
|
104
|
+
export declare const addSamples: (a: SampleValue, b: SampleValue) => SampleValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|