@synnaxlabs/x 0.14.1 → 0.15.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 +5 -5
- package/dist/telem/generate.d.ts +2 -2
- package/dist/telem/series.d.ts +43 -19
- package/dist/telem/telem.d.ts +14 -9
- package/dist/x.cjs +9 -5
- package/dist/x.cjs.map +1 -1
- package/dist/x.js +2122 -1891
- package/dist/x.js.map +1 -1
- package/package.json +3 -3
- package/src/telem/generate.ts +2 -2
- package/src/telem/series.spec.ts +248 -4
- package/src/telem/series.ts +417 -76
- package/src/telem/telem.spec.ts +9 -0
- package/src/telem/telem.ts +56 -27
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @synnaxlabs/x@0.
|
|
2
|
+
> @synnaxlabs/x@0.15.0 build /home/runner/work/synnax/synnax/x/ts
|
|
3
3
|
> tsc --noEmit && vite build
|
|
4
4
|
|
|
5
5
|
[36mvite v5.1.2 [32mbuilding for production...[36m[39m
|
|
@@ -10,8 +10,8 @@ rendering chunks...
|
|
|
10
10
|
[32m
|
|
11
11
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
12
|
computing gzip size...
|
|
13
|
-
[2mdist/[22m[36mx.js [39m[1m[
|
|
14
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
13
|
+
[2mdist/[22m[36mx.js [39m[1m[2m217.59 kB[22m[1m[22m[2m │ gzip: 50.60 kB[22m[2m │ map: 651.51 kB[22m
|
|
14
|
+
[32m[36m[vite:dts][32m Declaration files built in 3123ms.
|
|
15
15
|
[39m
|
|
16
|
-
[2mdist/[22m[36mx.cjs [39m[1m[
|
|
17
|
-
[32m✓ built in 4.
|
|
16
|
+
[2mdist/[22m[36mx.cjs [39m[1m[2m143.43 kB[22m[1m[22m[2m │ gzip: 40.54 kB[22m[2m │ map: 630.60 kB[22m
|
|
17
|
+
[32m✓ built in 4.05s[39m
|
package/dist/telem/generate.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DataTypeT,
|
|
2
|
-
export declare const randomSeries: (length: number, dataType: DataTypeT) =>
|
|
1
|
+
import { type DataTypeT, type TypedArray } from './telem';
|
|
2
|
+
export declare const randomSeries: (length: number, dataType: DataTypeT) => TypedArray;
|
package/dist/telem/series.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type z } from "zod";
|
|
2
2
|
import { bounds } from '../spatial';
|
|
3
3
|
import { type GLBufferController, type GLBufferUsage } from './gl';
|
|
4
|
-
import { DataType, type
|
|
5
|
-
export type SampleValue = number | bigint;
|
|
4
|
+
import { DataType, type TypedArray, type Rate, Size, TimeRange, TimeStamp, type CrudeDataType, type TelemValue, type NumericTelemValue } from './telem';
|
|
6
5
|
export interface SeriesDigest {
|
|
7
6
|
key: string;
|
|
8
7
|
dataType: string;
|
|
9
|
-
sampleOffset:
|
|
8
|
+
sampleOffset: NumericTelemValue;
|
|
10
9
|
alignment: bounds.Bounds;
|
|
11
10
|
timeRange?: string;
|
|
12
11
|
length: number;
|
|
@@ -15,13 +14,15 @@ export interface SeriesDigest {
|
|
|
15
14
|
interface BaseSeriesProps {
|
|
16
15
|
dataType?: CrudeDataType;
|
|
17
16
|
timeRange?: TimeRange;
|
|
18
|
-
sampleOffset?:
|
|
17
|
+
sampleOffset?: NumericTelemValue;
|
|
19
18
|
glBufferUsage?: GLBufferUsage;
|
|
20
19
|
alignment?: number;
|
|
21
20
|
key?: string;
|
|
22
21
|
}
|
|
22
|
+
export type CrudeSeries = Series | ArrayBuffer | TypedArray | string[] | number[] | boolean[] | unknown[] | TimeStamp[] | Date[] | TelemValue;
|
|
23
|
+
export declare const isCrudeSeries: (value: unknown) => value is CrudeSeries;
|
|
23
24
|
export interface SeriesProps extends BaseSeriesProps {
|
|
24
|
-
data:
|
|
25
|
+
data: CrudeSeries;
|
|
25
26
|
}
|
|
26
27
|
export interface SeriesAllocProps extends BaseSeriesProps {
|
|
27
28
|
capacity: number;
|
|
@@ -37,7 +38,7 @@ export interface SeriesMemInfo {
|
|
|
37
38
|
* Series is a strongly typed array of telemetry samples backed by an underlying binary
|
|
38
39
|
* buffer.
|
|
39
40
|
*/
|
|
40
|
-
export declare class Series {
|
|
41
|
+
export declare class Series<T extends TelemValue = TelemValue> {
|
|
41
42
|
key: string;
|
|
42
43
|
/** The data type of the array */
|
|
43
44
|
readonly dataType: DataType;
|
|
@@ -46,7 +47,7 @@ export declare class Series {
|
|
|
46
47
|
* downwards. Typically used to convert arrays to lower precision while preserving
|
|
47
48
|
* the relative range of actual values.
|
|
48
49
|
*/
|
|
49
|
-
sampleOffset:
|
|
50
|
+
sampleOffset: NumericTelemValue;
|
|
50
51
|
/**
|
|
51
52
|
* Stores information about the buffer state of this array into a WebGL buffer.
|
|
52
53
|
*/
|
|
@@ -56,19 +57,20 @@ export declare class Series {
|
|
|
56
57
|
readonly _timeRange?: TimeRange;
|
|
57
58
|
readonly alignment: number;
|
|
58
59
|
/** A cached minimum value. */
|
|
59
|
-
private
|
|
60
|
+
private _cachedMin?;
|
|
60
61
|
/** A cached maximum value. */
|
|
61
|
-
private
|
|
62
|
+
private _cachedMax?;
|
|
62
63
|
/** The write position of the buffer. */
|
|
63
64
|
private writePos;
|
|
64
65
|
/** Tracks the number of entities currently using this array. */
|
|
65
66
|
private _refCount;
|
|
67
|
+
private _cachedLength?;
|
|
68
|
+
constructor(props: SeriesProps | CrudeSeries);
|
|
66
69
|
static alloc({ capacity: length, dataType, ...props }: SeriesAllocProps): Series;
|
|
67
70
|
static generateTimestamps(length: number, rate: Rate, start: TimeStamp): Series;
|
|
68
71
|
get refCount(): number;
|
|
69
72
|
static fromStrings(data: string[], timeRange?: TimeRange): Series;
|
|
70
73
|
static fromJSON<T>(data: T[], timeRange?: TimeRange): Series;
|
|
71
|
-
constructor({ data, dataType, timeRange, sampleOffset, glBufferUsage, alignment, key, }: SeriesProps);
|
|
72
74
|
acquire(gl?: GLBufferController): void;
|
|
73
75
|
release(): void;
|
|
74
76
|
/**
|
|
@@ -84,7 +86,7 @@ export declare class Series {
|
|
|
84
86
|
get buffer(): ArrayBufferLike;
|
|
85
87
|
private get underlyingData();
|
|
86
88
|
/** @returns a native typed array with the proper data type. */
|
|
87
|
-
get data():
|
|
89
|
+
get data(): TypedArray;
|
|
88
90
|
toStrings(): string[];
|
|
89
91
|
toUUIDs(): string[];
|
|
90
92
|
parseJSON<Z extends z.ZodTypeAny>(schema: Z): Array<z.output<Z>>;
|
|
@@ -98,6 +100,7 @@ export declare class Series {
|
|
|
98
100
|
get byteLength(): Size;
|
|
99
101
|
/** @returns the number of samples in this array. */
|
|
100
102
|
get length(): number;
|
|
103
|
+
private calculateCachedLength;
|
|
101
104
|
/**
|
|
102
105
|
* Creates a new array with a different data type.
|
|
103
106
|
* @param target the data type to convert to.
|
|
@@ -107,34 +110,55 @@ export declare class Series {
|
|
|
107
110
|
* WARNING: This method is expensive and copies the entire underlying array. There
|
|
108
111
|
* also may be untimely precision issues when converting between data types.
|
|
109
112
|
*/
|
|
110
|
-
convert(target: DataType, sampleOffset?:
|
|
113
|
+
convert(target: DataType, sampleOffset?: NumericTelemValue): Series;
|
|
111
114
|
private calcRawMax;
|
|
112
115
|
/** @returns the maximum value in the array */
|
|
113
|
-
get max():
|
|
116
|
+
get max(): NumericTelemValue;
|
|
114
117
|
private calcRawMin;
|
|
115
118
|
/** @returns the minimum value in the array */
|
|
116
|
-
get min():
|
|
119
|
+
get min(): NumericTelemValue;
|
|
117
120
|
/** @returns the bounds of this array. */
|
|
118
121
|
get bounds(): bounds.Bounds;
|
|
119
122
|
private maybeRecomputeMinMax;
|
|
120
123
|
enrich(): void;
|
|
121
|
-
get range():
|
|
122
|
-
at(index: number, required: true):
|
|
123
|
-
at(index: number, required?: false):
|
|
124
|
+
get range(): NumericTelemValue;
|
|
125
|
+
at(index: number, required: true): T;
|
|
126
|
+
at(index: number, required?: false): T | undefined;
|
|
127
|
+
private atVariable;
|
|
124
128
|
/**
|
|
125
129
|
* @returns the index of the first sample that is greater than or equal to the given value.
|
|
126
130
|
* The underlying array must be sorted. If it is not, the behavior of this method is undefined.
|
|
127
131
|
* @param value the value to search for.
|
|
128
132
|
*/
|
|
129
|
-
binarySearch(value:
|
|
133
|
+
binarySearch(value: NumericTelemValue): number;
|
|
130
134
|
updateGLBuffer(gl: GLBufferController): void;
|
|
135
|
+
as(dataType: "string"): Series<string>;
|
|
136
|
+
as(dataType: "number"): Series<number>;
|
|
137
|
+
as(dataType: "bigint"): Series<bigint>;
|
|
138
|
+
as(dataType: "numeric"): Series<NumericTelemValue>;
|
|
131
139
|
get digest(): SeriesDigest;
|
|
132
140
|
get memInfo(): SeriesMemInfo;
|
|
133
141
|
get alignmentBounds(): bounds.Bounds;
|
|
134
142
|
private maybeGarbageCollectGLBuffer;
|
|
135
143
|
get glBuffer(): WebGLBuffer;
|
|
144
|
+
[Symbol.iterator](): Iterator<T>;
|
|
136
145
|
slice(start: number, end?: number): Series;
|
|
137
146
|
reAlign(alignment: number): Series;
|
|
138
147
|
}
|
|
139
|
-
export declare const addSamples: (a:
|
|
148
|
+
export declare const addSamples: (a: NumericTelemValue, b: NumericTelemValue) => NumericTelemValue;
|
|
149
|
+
export declare class MultiSeries<T extends TelemValue = TelemValue> implements Iterable<T> {
|
|
150
|
+
readonly series: Array<Series<T>>;
|
|
151
|
+
constructor(series: Array<Series<T>>);
|
|
152
|
+
as(dataType: "string"): MultiSeries<string>;
|
|
153
|
+
as(dataType: "number"): MultiSeries<number>;
|
|
154
|
+
as(dataType: "bigint"): MultiSeries<bigint>;
|
|
155
|
+
as(dataType: "numeric"): MultiSeries<NumericTelemValue>;
|
|
156
|
+
get dataType(): DataType;
|
|
157
|
+
get timeRange(): TimeRange;
|
|
158
|
+
push(series: Series<T>): void;
|
|
159
|
+
get length(): number;
|
|
160
|
+
at(index: number, required: true): T;
|
|
161
|
+
at(index: number, required?: false): T | undefined;
|
|
162
|
+
[Symbol.iterator](): Iterator<T>;
|
|
163
|
+
}
|
|
140
164
|
export {};
|
package/dist/telem/telem.d.ts
CHANGED
|
@@ -565,10 +565,11 @@ export declare class DataType extends String implements Stringer {
|
|
|
565
565
|
/**
|
|
566
566
|
* @returns the TypedArray constructor for the DataType.
|
|
567
567
|
*/
|
|
568
|
-
get Array():
|
|
568
|
+
get Array(): TypedArrayConstructor;
|
|
569
569
|
equals(other: DataType): boolean;
|
|
570
570
|
/** @returns a string representation of the DataType. */
|
|
571
571
|
toString(): string;
|
|
572
|
+
get isVariable(): boolean;
|
|
572
573
|
get density(): Density;
|
|
573
574
|
/**
|
|
574
575
|
* Checks whether the given TypedArray is of the same type as the DataType.
|
|
@@ -576,7 +577,7 @@ export declare class DataType extends String implements Stringer {
|
|
|
576
577
|
* @param array - The TypedArray to check.
|
|
577
578
|
* @returns True if the TypedArray is of the same type as the DataType.
|
|
578
579
|
*/
|
|
579
|
-
checkArray(array:
|
|
580
|
+
checkArray(array: TypedArray): boolean;
|
|
580
581
|
toJSON(): string;
|
|
581
582
|
get usesBigInt(): boolean;
|
|
582
583
|
/** Represents an Unknown/Invalid DataType. */
|
|
@@ -601,6 +602,8 @@ export declare class DataType extends String implements Stringer {
|
|
|
601
602
|
static readonly UINT16: DataType;
|
|
602
603
|
/** Represents a 8-bit unsigned integer value. */
|
|
603
604
|
static readonly UINT8: DataType;
|
|
605
|
+
/** Represents a boolean value. Alias for UINT8. */
|
|
606
|
+
static readonly BOOLEAN: DataType;
|
|
604
607
|
/** Represents a 64-bit unix epoch. */
|
|
605
608
|
static readonly TIMESTAMP: DataType;
|
|
606
609
|
/** Represents a UUID data type */
|
|
@@ -611,7 +614,7 @@ export declare class DataType extends String implements Stringer {
|
|
|
611
614
|
/** Represents a JSON data type. JSON has an unknown density, and is separated by a
|
|
612
615
|
* newline character. */
|
|
613
616
|
static readonly JSON: DataType;
|
|
614
|
-
static readonly ARRAY_CONSTRUCTORS: Map<string,
|
|
617
|
+
static readonly ARRAY_CONSTRUCTORS: Map<string, TypedArrayConstructor>;
|
|
615
618
|
static readonly ARRAY_CONSTRUCTOR_DATA_TYPES: Map<string, DataType>;
|
|
616
619
|
static readonly DENSITIES: Map<string, Density>;
|
|
617
620
|
/** All the data types. */
|
|
@@ -697,7 +700,7 @@ export type CrudeRate = Rate | number | Number;
|
|
|
697
700
|
export type RateT = number;
|
|
698
701
|
export type CrudeDensity = Density | number | Number;
|
|
699
702
|
export type DensityT = number;
|
|
700
|
-
export type CrudeDataType = DataType | string |
|
|
703
|
+
export type CrudeDataType = DataType | string | TypedArray;
|
|
701
704
|
export type DataTypeT = string;
|
|
702
705
|
export type CrudeSize = Size | number | Number;
|
|
703
706
|
export type SizeT = number;
|
|
@@ -705,9 +708,11 @@ export interface CrudeTimeRange {
|
|
|
705
708
|
start: CrudeTimeStamp;
|
|
706
709
|
end: CrudeTimeStamp;
|
|
707
710
|
}
|
|
708
|
-
export declare const
|
|
709
|
-
export type
|
|
710
|
-
type
|
|
711
|
-
type
|
|
712
|
-
export
|
|
711
|
+
export declare const typedArrayZ: z.ZodUnion<[z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>, z.ZodType<Uint16Array, z.ZodTypeDef, Uint16Array>, z.ZodType<Uint32Array, z.ZodTypeDef, Uint32Array>, z.ZodType<BigUint64Array, z.ZodTypeDef, BigUint64Array>, z.ZodType<Float32Array, z.ZodTypeDef, Float32Array>, z.ZodType<Float64Array, z.ZodTypeDef, Float64Array>, z.ZodType<Int8Array, z.ZodTypeDef, Int8Array>, z.ZodType<Int16Array, z.ZodTypeDef, Int16Array>, z.ZodType<Int32Array, z.ZodTypeDef, Int32Array>, z.ZodType<BigInt64Array, z.ZodTypeDef, BigInt64Array>]>;
|
|
712
|
+
export type TypedArray = z.infer<typeof typedArrayZ>;
|
|
713
|
+
type TypedArrayConstructor = Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | BigUint64ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor | BigInt64ArrayConstructor;
|
|
714
|
+
export type NumericTelemValue = number | bigint;
|
|
715
|
+
export type TelemValue = number | bigint | string | boolean | Date | TimeStamp | TimeSpan;
|
|
716
|
+
export declare const isTelemValue: (value: unknown) => value is TelemValue;
|
|
717
|
+
export declare const convertDataType: (source: DataType, target: DataType, value: NumericTelemValue, offset?: number | bigint) => NumericTelemValue;
|
|
713
718
|
export {};
|