@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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @synnaxlabs/x@0.14.1 build /home/runner/work/synnax/synnax/x/ts
2
+ > @synnaxlabs/x@0.15.0 build /home/runner/work/synnax/synnax/x/ts
3
3
  > tsc --noEmit && vite build
4
4
 
5
5
  vite v5.1.2 building for production...
@@ -10,8 +10,8 @@ rendering chunks...
10
10
  
11
11
  [vite:dts] Start generate declaration files...
12
12
  computing gzip size...
13
- dist/x.js 209.89 kB │ gzip: 49.04 kB │ map: 632.82 kB
14
- [vite:dts] Declaration files built in 3265ms.
13
+ dist/x.js 217.59 kB │ gzip: 50.60 kB │ map: 651.51 kB
14
+ [vite:dts] Declaration files built in 3123ms.
15
15
  
16
- dist/x.cjs 137.61 kB │ gzip: 39.21 kB │ map: 612.53 kB
17
- ✓ built in 4.16s
16
+ dist/x.cjs 143.43 kB │ gzip: 40.54 kB │ map: 630.60 kB
17
+ ✓ built in 4.05s
@@ -1,2 +1,2 @@
1
- import { DataTypeT, NativeTypedArray } from './telem';
2
- export declare const randomSeries: (length: number, dataType: DataTypeT) => NativeTypedArray;
1
+ import { type DataTypeT, type TypedArray } from './telem';
2
+ export declare const randomSeries: (length: number, dataType: DataTypeT) => TypedArray;
@@ -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 NativeTypedArray, type Rate, Size, TimeRange, type TimeStamp, type CrudeDataType } from './telem';
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: SampleValue;
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?: SampleValue;
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: ArrayBuffer | NativeTypedArray;
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: SampleValue;
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 _min?;
60
+ private _cachedMin?;
60
61
  /** A cached maximum value. */
61
- private _max?;
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(): NativeTypedArray;
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?: SampleValue): Series;
113
+ convert(target: DataType, sampleOffset?: NumericTelemValue): Series;
111
114
  private calcRawMax;
112
115
  /** @returns the maximum value in the array */
113
- get max(): SampleValue;
116
+ get max(): NumericTelemValue;
114
117
  private calcRawMin;
115
118
  /** @returns the minimum value in the array */
116
- get min(): SampleValue;
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(): SampleValue;
122
- at(index: number, required: true): SampleValue;
123
- at(index: number, required?: false): SampleValue | undefined;
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: SampleValue): number;
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: SampleValue, b: SampleValue) => SampleValue;
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 {};
@@ -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(): NativeTypedArrayConstructor;
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: NativeTypedArray): boolean;
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, NativeTypedArrayConstructor>;
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 | NativeTypedArray;
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 nativeTypedArray: 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>]>;
709
- export type NativeTypedArray = z.infer<typeof nativeTypedArray>;
710
- type NativeTypedArrayConstructor = Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | BigUint64ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor | BigInt64ArrayConstructor;
711
- type TelemValue = number | bigint;
712
- export declare const convertDataType: (source: DataType, target: DataType, value: TelemValue, offset?: number | bigint) => TelemValue;
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 {};