@synnaxlabs/x 0.8.0 → 0.9.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 +8 -7
- package/dist/binary/index.d.ts +1 -1
- package/dist/change/change.d.ts +4 -2
- package/dist/change/index.d.ts +1 -1
- package/dist/compare/index.d.ts +1 -1
- package/dist/deep/delete.d.ts +1 -1
- package/dist/deep/external.d.ts +7 -7
- package/dist/deep/index.d.ts +1 -1
- package/dist/deep/merge.d.ts +1 -1
- package/dist/deep/path.d.ts +37 -0
- package/dist/deep/path.spec.d.ts +1 -0
- package/dist/destructor.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/kv/index.d.ts +1 -1
- package/dist/mock/index.d.ts +1 -1
- package/dist/observe/index.d.ts +1 -1
- package/dist/observe/observe.d.ts +1 -1
- package/dist/runtime/external.d.ts +2 -2
- package/dist/runtime/index.d.ts +1 -1
- package/dist/shallowCopy.d.ts +1 -0
- package/dist/spatial/bounds.d.ts +48 -9
- package/dist/spatial/box.d.ts +9 -35
- package/dist/spatial/dimensions.d.ts +1 -1
- package/dist/spatial/direction.d.ts +1 -1
- package/dist/spatial/external.d.ts +8 -8
- package/dist/spatial/index.d.ts +1 -1
- package/dist/spatial/location.d.ts +1 -1
- package/dist/spatial/position.d.ts +1 -1
- package/dist/spatial/scale.d.ts +5 -5
- package/dist/spatial/spatial.d.ts +1 -1
- package/dist/spatial/xy.d.ts +5 -2
- package/dist/telem/generate.d.ts +1 -1
- package/dist/telem/index.d.ts +3 -3
- package/dist/telem/series.d.ts +31 -5
- package/dist/telem/telem.d.ts +3 -0
- package/dist/toArray.d.ts +1 -0
- package/dist/x.cjs.js +289 -60
- package/dist/x.cjs.js.map +1 -1
- package/dist/x.es.js +289 -60
- package/dist/x.es.js.map +1 -1
- package/package.json +6 -6
- package/src/change/change.ts +13 -11
- package/src/deep/delete.ts +1 -1
- package/src/deep/external.ts +1 -1
- package/src/deep/path.spec.ts +82 -0
- package/src/deep/path.ts +95 -0
- package/src/destructor.ts +2 -0
- package/src/index.ts +1 -0
- package/src/observe/observe.ts +2 -2
- package/src/shallowCopy.ts +6 -0
- package/src/spatial/bounds.spec.ts +218 -0
- package/src/spatial/bounds.ts +155 -19
- package/src/spatial/box.ts +5 -0
- package/src/spatial/xy.ts +10 -2
- package/src/telem/series.spec.ts +54 -46
- package/src/telem/series.ts +93 -56
- package/src/telem/telem.spec.ts +17 -1
- package/src/telem/telem.ts +28 -0
- package/src/toArray.ts +3 -0
- package/dist/deep/key.d.ts +0 -30
- package/src/deep/key.ts +0 -46
package/dist/x.es.js
CHANGED
|
@@ -5,6 +5,15 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
var _a;
|
|
8
|
+
let urlAlphabet = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
9
|
+
let nanoid = (size = 21) => {
|
|
10
|
+
let id = "";
|
|
11
|
+
let i = size;
|
|
12
|
+
while (i--) {
|
|
13
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
14
|
+
}
|
|
15
|
+
return id;
|
|
16
|
+
};
|
|
8
17
|
const isStringer = (value) => value != null && typeof value === "object" && "toString" in value;
|
|
9
18
|
const primitiveIsZero = (value) => {
|
|
10
19
|
if (isStringer(value))
|
|
@@ -2926,12 +2935,12 @@ class ZodSet extends ZodType {
|
|
|
2926
2935
|
const valueType = this._def.valueType;
|
|
2927
2936
|
function finalizeSet(elements2) {
|
|
2928
2937
|
const parsedSet = /* @__PURE__ */ new Set();
|
|
2929
|
-
for (const
|
|
2930
|
-
if (
|
|
2938
|
+
for (const element2 of elements2) {
|
|
2939
|
+
if (element2.status === "aborted")
|
|
2931
2940
|
return INVALID;
|
|
2932
|
-
if (
|
|
2941
|
+
if (element2.status === "dirty")
|
|
2933
2942
|
status.dirty();
|
|
2934
|
-
parsedSet.add(
|
|
2943
|
+
parsedSet.add(element2.value);
|
|
2935
2944
|
}
|
|
2936
2945
|
return { status: status.value, value: parsedSet };
|
|
2937
2946
|
}
|
|
@@ -3876,25 +3885,57 @@ const ZERO$3 = { lower: 0, upper: 0 };
|
|
|
3876
3885
|
const INFINITE = { lower: -Infinity, upper: Infinity };
|
|
3877
3886
|
const DECIMAL$2 = { lower: 0, upper: 1 };
|
|
3878
3887
|
const CLIP = { lower: -1, upper: 1 };
|
|
3879
|
-
const equals$3 = (
|
|
3888
|
+
const equals$3 = (_a2, _b) => {
|
|
3889
|
+
if (_a2 == null && _b == null)
|
|
3890
|
+
return true;
|
|
3891
|
+
if (_a2 == null || _b == null)
|
|
3892
|
+
return false;
|
|
3893
|
+
const a = construct$5(_a2);
|
|
3894
|
+
const b = construct$5(_b);
|
|
3895
|
+
return (a == null ? void 0 : a.lower) === (b == null ? void 0 : b.lower) && (a == null ? void 0 : a.upper) === (b == null ? void 0 : b.upper);
|
|
3896
|
+
};
|
|
3880
3897
|
const makeValid = (a) => {
|
|
3881
3898
|
if (a.lower > a.upper)
|
|
3882
3899
|
return { lower: a.upper, upper: a.lower };
|
|
3883
3900
|
return a;
|
|
3884
3901
|
};
|
|
3885
3902
|
const clamp$1 = (bounds2, target2) => {
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3903
|
+
const _bounds = construct$5(bounds2);
|
|
3904
|
+
if (target2 < _bounds.lower)
|
|
3905
|
+
return _bounds.lower;
|
|
3906
|
+
if (target2 >= _bounds.upper)
|
|
3907
|
+
return _bounds.upper - 1;
|
|
3890
3908
|
return target2;
|
|
3891
3909
|
};
|
|
3892
|
-
const contains$1 = (bounds2, target2) =>
|
|
3893
|
-
const
|
|
3894
|
-
|
|
3895
|
-
|
|
3910
|
+
const contains$1 = (bounds2, target2) => {
|
|
3911
|
+
const _bounds = construct$5(bounds2);
|
|
3912
|
+
if (typeof target2 === "number")
|
|
3913
|
+
return target2 >= _bounds.lower && target2 < _bounds.upper;
|
|
3914
|
+
const _target = construct$5(target2);
|
|
3915
|
+
return _target.lower >= _bounds.lower && _target.upper <= _bounds.upper;
|
|
3916
|
+
};
|
|
3917
|
+
const overlapsWith = (a, b) => {
|
|
3918
|
+
const _a2 = construct$5(a);
|
|
3919
|
+
const _b = construct$5(b);
|
|
3920
|
+
if (_a2.lower == _b.lower)
|
|
3921
|
+
return true;
|
|
3922
|
+
if (_b.upper == _a2.lower || _b.lower == _a2.upper)
|
|
3923
|
+
return false;
|
|
3924
|
+
return contains$1(_a2, _b.upper) || contains$1(_a2, _b.lower) || contains$1(_b, _a2.upper) || contains$1(_b, _a2.lower);
|
|
3925
|
+
};
|
|
3926
|
+
const span = (a) => {
|
|
3927
|
+
const _a2 = construct$5(a);
|
|
3928
|
+
return _a2.upper - _a2.lower;
|
|
3929
|
+
};
|
|
3930
|
+
const isZero$2 = (a) => {
|
|
3931
|
+
const _a2 = construct$5(a);
|
|
3932
|
+
return _a2.lower === 0 && _a2.upper === 0;
|
|
3933
|
+
};
|
|
3896
3934
|
const spanIsZero = (a) => span(a) === 0;
|
|
3897
|
-
const isFinite$
|
|
3935
|
+
const isFinite$2 = (a) => {
|
|
3936
|
+
const _a2 = construct$5(a);
|
|
3937
|
+
return Number.isFinite(_a2.lower) && Number.isFinite(_a2.upper);
|
|
3938
|
+
};
|
|
3898
3939
|
const max$1 = (bounds2) => ({
|
|
3899
3940
|
lower: Math.min(...bounds2.map((b) => construct$5(b).lower)),
|
|
3900
3941
|
upper: Math.max(...bounds2.map((b) => construct$5(b).upper))
|
|
@@ -3903,6 +3944,75 @@ const min$1 = (bounds2) => ({
|
|
|
3903
3944
|
lower: Math.max(...bounds2.map((b) => construct$5(b).lower)),
|
|
3904
3945
|
upper: Math.min(...bounds2.map((b) => construct$5(b).upper))
|
|
3905
3946
|
});
|
|
3947
|
+
const constructArray = (bounds2) => {
|
|
3948
|
+
const _bounds = construct$5(bounds2);
|
|
3949
|
+
return Array.from({ length: span(bounds2) }, (_, i) => i + _bounds.lower);
|
|
3950
|
+
};
|
|
3951
|
+
const findInsertPosition = (bounds2, target2) => {
|
|
3952
|
+
const _bounds = bounds2.map(construct$5);
|
|
3953
|
+
const index = _bounds.findIndex((b2, i) => contains$1(b2, target2) || target2 < _bounds[i].lower);
|
|
3954
|
+
if (index === -1)
|
|
3955
|
+
return { index: bounds2.length, position: 0 };
|
|
3956
|
+
const b = _bounds[index];
|
|
3957
|
+
if (contains$1(b, target2))
|
|
3958
|
+
return { index, position: target2 - b.lower };
|
|
3959
|
+
return { index, position: 0 };
|
|
3960
|
+
};
|
|
3961
|
+
const ZERO_PLAN = {
|
|
3962
|
+
removeBefore: 0,
|
|
3963
|
+
removeAfter: 0,
|
|
3964
|
+
insertInto: 0,
|
|
3965
|
+
deleteInBetween: 0
|
|
3966
|
+
};
|
|
3967
|
+
const buildInsertionPlan = (bounds2, value) => {
|
|
3968
|
+
const _bounds = bounds2.map(construct$5);
|
|
3969
|
+
const _target = construct$5(value);
|
|
3970
|
+
if (_bounds.length === 0)
|
|
3971
|
+
return ZERO_PLAN;
|
|
3972
|
+
const lower = findInsertPosition(bounds2, _target.lower);
|
|
3973
|
+
const upper = findInsertPosition(bounds2, _target.upper);
|
|
3974
|
+
if (lower.index == bounds2.length)
|
|
3975
|
+
return { ...ZERO_PLAN, insertInto: bounds2.length };
|
|
3976
|
+
if (upper.index == 0)
|
|
3977
|
+
return {
|
|
3978
|
+
...ZERO_PLAN,
|
|
3979
|
+
removeAfter: upper.position
|
|
3980
|
+
};
|
|
3981
|
+
if (lower.index === upper.index) {
|
|
3982
|
+
if (lower.position !== 0 && upper.position !== 0)
|
|
3983
|
+
return null;
|
|
3984
|
+
return {
|
|
3985
|
+
removeAfter: upper.position,
|
|
3986
|
+
removeBefore: lower.position,
|
|
3987
|
+
insertInto: lower.index,
|
|
3988
|
+
deleteInBetween: 0
|
|
3989
|
+
};
|
|
3990
|
+
}
|
|
3991
|
+
let deleteInBetween = upper.index - lower.index;
|
|
3992
|
+
let insertInto = lower.index;
|
|
3993
|
+
let removeBefore = span(_bounds[lower.index]) - lower.position;
|
|
3994
|
+
if (lower.position != 0) {
|
|
3995
|
+
deleteInBetween -= 1;
|
|
3996
|
+
insertInto += 1;
|
|
3997
|
+
} else
|
|
3998
|
+
removeBefore = 0;
|
|
3999
|
+
return {
|
|
4000
|
+
removeBefore,
|
|
4001
|
+
removeAfter: upper.position,
|
|
4002
|
+
insertInto,
|
|
4003
|
+
deleteInBetween
|
|
4004
|
+
};
|
|
4005
|
+
};
|
|
4006
|
+
const insert = (bounds2, value) => {
|
|
4007
|
+
const plan = buildInsertionPlan(bounds2, value);
|
|
4008
|
+
if (plan == null)
|
|
4009
|
+
return bounds2;
|
|
4010
|
+
const _target = construct$5(value);
|
|
4011
|
+
_target.lower += plan.removeBefore;
|
|
4012
|
+
_target.upper -= plan.removeAfter;
|
|
4013
|
+
bounds2.splice(plan.insertInto, plan.deleteInBetween, _target);
|
|
4014
|
+
return bounds2.map(construct$5);
|
|
4015
|
+
};
|
|
3906
4016
|
const bounds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3907
4017
|
__proto__: null,
|
|
3908
4018
|
CLIP,
|
|
@@ -3910,11 +4020,15 @@ const bounds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3910
4020
|
INFINITE,
|
|
3911
4021
|
ZERO: ZERO$3,
|
|
3912
4022
|
bounds: bounds$1,
|
|
4023
|
+
buildInsertionPlan,
|
|
3913
4024
|
clamp: clamp$1,
|
|
3914
4025
|
construct: construct$5,
|
|
4026
|
+
constructArray,
|
|
3915
4027
|
contains: contains$1,
|
|
3916
4028
|
equals: equals$3,
|
|
3917
|
-
|
|
4029
|
+
findInsertPosition,
|
|
4030
|
+
insert,
|
|
4031
|
+
isFinite: isFinite$2,
|
|
3918
4032
|
isZero: isZero$2,
|
|
3919
4033
|
makeValid,
|
|
3920
4034
|
max: max$1,
|
|
@@ -4598,7 +4712,7 @@ const construct$2 = (x2, y2) => {
|
|
|
4598
4712
|
return { x: x2.clientX, y: x2.clientY };
|
|
4599
4713
|
if ("width" in x2)
|
|
4600
4714
|
return { x: x2.width, y: x2.height };
|
|
4601
|
-
return {
|
|
4715
|
+
return { x: x2.x, y: x2.y };
|
|
4602
4716
|
};
|
|
4603
4717
|
const ZERO$2 = { x: 0, y: 0 };
|
|
4604
4718
|
const ONE = { x: 1, y: 1 };
|
|
@@ -4635,7 +4749,7 @@ const translate = (a, b, v, ...cb) => {
|
|
|
4635
4749
|
return { x: p.x + xy2.x, y: p.y + xy2.y };
|
|
4636
4750
|
}, ZERO$2);
|
|
4637
4751
|
};
|
|
4638
|
-
const set = (c, direction2, value) => {
|
|
4752
|
+
const set$1 = (c, direction2, value) => {
|
|
4639
4753
|
const xy2 = construct$2(c);
|
|
4640
4754
|
if (direction2 === "x")
|
|
4641
4755
|
return { x: value, y: xy2.y };
|
|
@@ -4665,6 +4779,10 @@ const isNan = (a) => {
|
|
|
4665
4779
|
const xy2 = construct$2(a);
|
|
4666
4780
|
return Number.isNaN(xy2.x) || Number.isNaN(xy2.y);
|
|
4667
4781
|
};
|
|
4782
|
+
const isFinite$1 = (a) => {
|
|
4783
|
+
const xy2 = construct$2(a);
|
|
4784
|
+
return Number.isFinite(xy2.x) && Number.isFinite(xy2.y);
|
|
4785
|
+
};
|
|
4668
4786
|
const couple$1 = (a) => {
|
|
4669
4787
|
const xy2 = construct$2(a);
|
|
4670
4788
|
return [xy2.x, xy2.y];
|
|
@@ -4686,10 +4804,11 @@ const xy = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4686
4804
|
css: css$1,
|
|
4687
4805
|
distance,
|
|
4688
4806
|
equals: equals$2,
|
|
4807
|
+
isFinite: isFinite$1,
|
|
4689
4808
|
isNan,
|
|
4690
4809
|
isZero: isZero$1,
|
|
4691
4810
|
scale: scale$2,
|
|
4692
|
-
set,
|
|
4811
|
+
set: set$1,
|
|
4693
4812
|
translate,
|
|
4694
4813
|
translateX,
|
|
4695
4814
|
translateY,
|
|
@@ -4764,6 +4883,7 @@ const construct$1 = (first, second, width2 = 0, height2 = 0, coordinateRoot) =>
|
|
|
4764
4883
|
b.two = second;
|
|
4765
4884
|
return b;
|
|
4766
4885
|
};
|
|
4886
|
+
const resize = (b, dims2) => construct$1(b.one, dims2);
|
|
4767
4887
|
const contains = (b, value) => {
|
|
4768
4888
|
const b_ = construct$1(b);
|
|
4769
4889
|
if ("one" in value)
|
|
@@ -4901,6 +5021,7 @@ const box$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
4901
5021
|
positionInCenter,
|
|
4902
5022
|
positionSoVisible,
|
|
4903
5023
|
reRoot,
|
|
5024
|
+
resize,
|
|
4904
5025
|
right,
|
|
4905
5026
|
root,
|
|
4906
5027
|
signedDims,
|
|
@@ -5988,6 +6109,18 @@ const _TimeRange = class _TimeRange {
|
|
|
5988
6109
|
return this.contains(other.start) && this.contains(other.end);
|
|
5989
6110
|
return this.start.beforeEq(other) && this.end.after(other);
|
|
5990
6111
|
}
|
|
6112
|
+
boundBy(other) {
|
|
6113
|
+
const next = new _TimeRange(this.start, this.end);
|
|
6114
|
+
if (other.start.after(this.start))
|
|
6115
|
+
next.start = other.start;
|
|
6116
|
+
if (other.start.after(this.end))
|
|
6117
|
+
next.end = other.start;
|
|
6118
|
+
if (other.end.before(this.end))
|
|
6119
|
+
next.end = other.end;
|
|
6120
|
+
if (other.end.before(this.start))
|
|
6121
|
+
next.start = other.end;
|
|
6122
|
+
return next;
|
|
6123
|
+
}
|
|
5991
6124
|
};
|
|
5992
6125
|
/** The maximum possible time range. */
|
|
5993
6126
|
__publicField(_TimeRange, "MAX", new _TimeRange(TimeStamp.MIN, TimeStamp.MAX));
|
|
@@ -6130,6 +6263,24 @@ __publicField(_DataType, "DENSITIES", /* @__PURE__ */ new Map([
|
|
|
6130
6263
|
[_DataType.JSON.toString(), Density.UNKNOWN],
|
|
6131
6264
|
[_DataType.UUID.toString(), Density.BIT128]
|
|
6132
6265
|
]));
|
|
6266
|
+
/** All the data types. */
|
|
6267
|
+
__publicField(_DataType, "ALL", [
|
|
6268
|
+
_DataType.UNKNOWN,
|
|
6269
|
+
_DataType.FLOAT64,
|
|
6270
|
+
_DataType.FLOAT32,
|
|
6271
|
+
_DataType.INT64,
|
|
6272
|
+
_DataType.INT32,
|
|
6273
|
+
_DataType.INT16,
|
|
6274
|
+
_DataType.INT8,
|
|
6275
|
+
_DataType.UINT64,
|
|
6276
|
+
_DataType.UINT32,
|
|
6277
|
+
_DataType.UINT16,
|
|
6278
|
+
_DataType.UINT8,
|
|
6279
|
+
_DataType.TIMESTAMP,
|
|
6280
|
+
_DataType.UUID,
|
|
6281
|
+
_DataType.STRING,
|
|
6282
|
+
_DataType.JSON
|
|
6283
|
+
]);
|
|
6133
6284
|
__publicField(_DataType, "BIG_INT_TYPES", [_DataType.INT64, _DataType.UINT64, _DataType.TIMESTAMP]);
|
|
6134
6285
|
/** A zod schema for a DataType. */
|
|
6135
6286
|
__publicField(_DataType, "z", z.union([
|
|
@@ -6248,7 +6399,16 @@ const validateFieldNotNull = (name, field) => {
|
|
|
6248
6399
|
};
|
|
6249
6400
|
const FULL_BUFFER = -1;
|
|
6250
6401
|
class Series {
|
|
6251
|
-
constructor(
|
|
6402
|
+
constructor({
|
|
6403
|
+
data,
|
|
6404
|
+
dataType,
|
|
6405
|
+
timeRange,
|
|
6406
|
+
sampleOffset = 0,
|
|
6407
|
+
glBufferUsage = "static",
|
|
6408
|
+
alignment: alignment2 = 0,
|
|
6409
|
+
key = nanoid()
|
|
6410
|
+
}) {
|
|
6411
|
+
__publicField(this, "key", "");
|
|
6252
6412
|
/** The data type of the array */
|
|
6253
6413
|
__publicField(this, "dataType");
|
|
6254
6414
|
/**
|
|
@@ -6282,6 +6442,7 @@ class Series {
|
|
|
6282
6442
|
"must provide a data type when constructing a Series from a buffer"
|
|
6283
6443
|
);
|
|
6284
6444
|
}
|
|
6445
|
+
this.key = key;
|
|
6285
6446
|
this.alignment = alignment2;
|
|
6286
6447
|
this.sampleOffset = sampleOffset ?? 0;
|
|
6287
6448
|
this._data = data;
|
|
@@ -6293,41 +6454,38 @@ class Series {
|
|
|
6293
6454
|
bufferUsage: glBufferUsage
|
|
6294
6455
|
};
|
|
6295
6456
|
}
|
|
6296
|
-
static alloc(length, dataType,
|
|
6457
|
+
static alloc({ length, dataType, ...props }) {
|
|
6297
6458
|
if (length === 0)
|
|
6298
6459
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
6299
6460
|
const data = new new DataType(dataType).Array(length);
|
|
6300
|
-
const arr = new Series(
|
|
6301
|
-
data.buffer,
|
|
6461
|
+
const arr = new Series({
|
|
6462
|
+
data: data.buffer,
|
|
6302
6463
|
dataType,
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
glBufferUsage,
|
|
6306
|
-
alignment2
|
|
6307
|
-
);
|
|
6464
|
+
...props
|
|
6465
|
+
});
|
|
6308
6466
|
arr.writePos = 0;
|
|
6309
6467
|
return arr;
|
|
6310
6468
|
}
|
|
6311
6469
|
static generateTimestamps(length, rate, start) {
|
|
6312
|
-
const
|
|
6470
|
+
const timeRange = start.spanRange(rate.span(length));
|
|
6313
6471
|
const data = new BigInt64Array(length);
|
|
6314
6472
|
for (let i = 0; i < length; i++) {
|
|
6315
6473
|
data[i] = BigInt(start.add(rate.span(i)).valueOf());
|
|
6316
6474
|
}
|
|
6317
|
-
return new Series(data, DataType.TIMESTAMP,
|
|
6475
|
+
return new Series({ data, dataType: DataType.TIMESTAMP, timeRange });
|
|
6318
6476
|
}
|
|
6319
6477
|
get refCount() {
|
|
6320
6478
|
return this._refCount;
|
|
6321
6479
|
}
|
|
6322
6480
|
static fromStrings(data, timeRange) {
|
|
6323
6481
|
const buffer = new TextEncoder().encode(data.join("\n") + "\n");
|
|
6324
|
-
return new Series(buffer, DataType.STRING, timeRange);
|
|
6482
|
+
return new Series({ data: buffer, dataType: DataType.STRING, timeRange });
|
|
6325
6483
|
}
|
|
6326
6484
|
static fromJSON(data, timeRange) {
|
|
6327
6485
|
const buffer = new TextEncoder().encode(
|
|
6328
6486
|
data.map((d) => JSON.stringify(d)).join("\n") + "\n"
|
|
6329
6487
|
);
|
|
6330
|
-
return new Series(buffer, DataType.JSON, timeRange);
|
|
6488
|
+
return new Series({ data: buffer, dataType: DataType.JSON, timeRange });
|
|
6331
6489
|
}
|
|
6332
6490
|
acquire(gl) {
|
|
6333
6491
|
this._refCount++;
|
|
@@ -6429,14 +6587,14 @@ class Series {
|
|
|
6429
6587
|
for (let i = 0; i < this.length; i++) {
|
|
6430
6588
|
data[i] = convertDataType(this.dataType, target2, this.data[i], sampleOffset);
|
|
6431
6589
|
}
|
|
6432
|
-
return new Series(
|
|
6433
|
-
data.buffer,
|
|
6434
|
-
target2,
|
|
6435
|
-
this._timeRange,
|
|
6590
|
+
return new Series({
|
|
6591
|
+
data: data.buffer,
|
|
6592
|
+
dataType: target2,
|
|
6593
|
+
timeRange: this._timeRange,
|
|
6436
6594
|
sampleOffset,
|
|
6437
|
-
this.gl.bufferUsage,
|
|
6438
|
-
this.alignment
|
|
6439
|
-
);
|
|
6595
|
+
glBufferUsage: this.gl.bufferUsage,
|
|
6596
|
+
alignment: this.alignment
|
|
6597
|
+
});
|
|
6440
6598
|
}
|
|
6441
6599
|
calcRawMax() {
|
|
6442
6600
|
if (this.length === 0)
|
|
@@ -6537,8 +6695,9 @@ class Series {
|
|
|
6537
6695
|
if (!this.dataType.equals(DataType.FLOAT32))
|
|
6538
6696
|
throw new Error("Only FLOAT32 arrays can be used in WebGL");
|
|
6539
6697
|
const { buffer, bufferUsage, prevBuffer } = this.gl;
|
|
6540
|
-
if (buffer == null)
|
|
6698
|
+
if (buffer == null) {
|
|
6541
6699
|
this.gl.buffer = gl.createBuffer();
|
|
6700
|
+
}
|
|
6542
6701
|
if (this.writePos === prevBuffer)
|
|
6543
6702
|
return;
|
|
6544
6703
|
gl.bindBuffer(gl.ARRAY_BUFFER, this.gl.buffer);
|
|
@@ -6562,13 +6721,25 @@ class Series {
|
|
|
6562
6721
|
get digest() {
|
|
6563
6722
|
var _a2;
|
|
6564
6723
|
return {
|
|
6724
|
+
key: this.key,
|
|
6565
6725
|
dataType: this.dataType.toString(),
|
|
6566
6726
|
sampleOffset: this.sampleOffset,
|
|
6567
|
-
alignment: this.
|
|
6727
|
+
alignment: this.alignmentBounds,
|
|
6568
6728
|
timeRange: (_a2 = this._timeRange) == null ? void 0 : _a2.toString(),
|
|
6569
6729
|
length: this.length
|
|
6570
6730
|
};
|
|
6571
6731
|
}
|
|
6732
|
+
get memInfo() {
|
|
6733
|
+
return {
|
|
6734
|
+
key: this.key,
|
|
6735
|
+
length: this.length,
|
|
6736
|
+
byteLength: this.byteLength,
|
|
6737
|
+
glBuffer: this.gl.buffer != null
|
|
6738
|
+
};
|
|
6739
|
+
}
|
|
6740
|
+
get alignmentBounds() {
|
|
6741
|
+
return construct$5(this.alignment, this.alignment + this.length);
|
|
6742
|
+
}
|
|
6572
6743
|
maybeGarbageCollectGLBuffer(gl) {
|
|
6573
6744
|
if (this.gl.buffer == null)
|
|
6574
6745
|
return;
|
|
@@ -6584,25 +6755,27 @@ class Series {
|
|
|
6584
6755
|
return this.gl.buffer;
|
|
6585
6756
|
}
|
|
6586
6757
|
slice(start, end) {
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
this.
|
|
6593
|
-
this.
|
|
6594
|
-
this.
|
|
6595
|
-
|
|
6758
|
+
if (start <= 0 && (end == null || end >= this.length))
|
|
6759
|
+
return this;
|
|
6760
|
+
const data = this.data.slice(start, end);
|
|
6761
|
+
return new Series({
|
|
6762
|
+
data,
|
|
6763
|
+
dataType: this.dataType,
|
|
6764
|
+
timeRange: this._timeRange,
|
|
6765
|
+
sampleOffset: this.sampleOffset,
|
|
6766
|
+
glBufferUsage: this.gl.bufferUsage,
|
|
6767
|
+
alignment: this.alignment + start
|
|
6768
|
+
});
|
|
6596
6769
|
}
|
|
6597
6770
|
reAlign(alignment2) {
|
|
6598
|
-
return new Series(
|
|
6599
|
-
this.buffer,
|
|
6600
|
-
this.dataType,
|
|
6601
|
-
TimeRange.ZERO,
|
|
6602
|
-
this.sampleOffset,
|
|
6603
|
-
"static",
|
|
6604
|
-
alignment2
|
|
6605
|
-
);
|
|
6771
|
+
return new Series({
|
|
6772
|
+
data: this.buffer,
|
|
6773
|
+
dataType: this.dataType,
|
|
6774
|
+
timeRange: TimeRange.ZERO,
|
|
6775
|
+
sampleOffset: this.sampleOffset,
|
|
6776
|
+
glBufferUsage: "static",
|
|
6777
|
+
alignment: alignment2
|
|
6778
|
+
});
|
|
6606
6779
|
}
|
|
6607
6780
|
}
|
|
6608
6781
|
const addSamples = (a, b) => {
|
|
@@ -6682,6 +6855,47 @@ const deleteD = (target2, ...keys) => {
|
|
|
6682
6855
|
});
|
|
6683
6856
|
return target2;
|
|
6684
6857
|
};
|
|
6858
|
+
const get = (obj, path, allowNull) => {
|
|
6859
|
+
const parts = path.split(".");
|
|
6860
|
+
let result = obj;
|
|
6861
|
+
for (const part of parts) {
|
|
6862
|
+
const v = result[part];
|
|
6863
|
+
if (v == null) {
|
|
6864
|
+
if (allowNull)
|
|
6865
|
+
return null;
|
|
6866
|
+
throw new Error(`Path ${path} does not exist. ${part} is null`);
|
|
6867
|
+
}
|
|
6868
|
+
result = v;
|
|
6869
|
+
}
|
|
6870
|
+
return result;
|
|
6871
|
+
};
|
|
6872
|
+
const set = (obj, path, value) => {
|
|
6873
|
+
const parts = path.split(".");
|
|
6874
|
+
let result = obj;
|
|
6875
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
6876
|
+
const part = parts[i];
|
|
6877
|
+
if (result[part] == null) {
|
|
6878
|
+
throw new Error(`Path ${path} does not exist`);
|
|
6879
|
+
}
|
|
6880
|
+
result = result[part];
|
|
6881
|
+
}
|
|
6882
|
+
result[parts[parts.length - 1]] = value;
|
|
6883
|
+
};
|
|
6884
|
+
const element = (path, index) => {
|
|
6885
|
+
const parts = path.split(".");
|
|
6886
|
+
if (index < 0)
|
|
6887
|
+
return parts[parts.length + index];
|
|
6888
|
+
return parts[index];
|
|
6889
|
+
};
|
|
6890
|
+
const join = (path) => path.join(".");
|
|
6891
|
+
const has = (obj, path) => {
|
|
6892
|
+
try {
|
|
6893
|
+
get(obj, path);
|
|
6894
|
+
return true;
|
|
6895
|
+
} catch {
|
|
6896
|
+
return false;
|
|
6897
|
+
}
|
|
6898
|
+
};
|
|
6685
6899
|
const merge = (base, ...objects) => {
|
|
6686
6900
|
if (objects.length === 0)
|
|
6687
6901
|
return base;
|
|
@@ -6774,10 +6988,15 @@ const external = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
|
|
|
6774
6988
|
__proto__: null,
|
|
6775
6989
|
copy,
|
|
6776
6990
|
deleteD,
|
|
6991
|
+
element,
|
|
6777
6992
|
equal,
|
|
6993
|
+
get,
|
|
6994
|
+
has,
|
|
6995
|
+
join,
|
|
6778
6996
|
memo,
|
|
6779
6997
|
merge,
|
|
6780
|
-
partialEqual
|
|
6998
|
+
partialEqual,
|
|
6999
|
+
set
|
|
6781
7000
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
6782
7001
|
const debounce = (func, waitFor) => {
|
|
6783
7002
|
let timeout = null;
|
|
@@ -6879,6 +7098,7 @@ let URL$1 = (_a = class {
|
|
|
6879
7098
|
}
|
|
6880
7099
|
}, __publicField(_a, "UNKNOWN", new _a({ host: "unknown", port: 0 })), _a);
|
|
6881
7100
|
const toArray = (value) => Array.isArray(value) ? value : [value];
|
|
7101
|
+
const nullToArr = (value) => Array.isArray(value) ? value : value === null ? [] : [value];
|
|
6882
7102
|
const binary = (arr, target2, compare2) => {
|
|
6883
7103
|
let left2 = 0;
|
|
6884
7104
|
let right2 = arr.length - 1;
|
|
@@ -8973,9 +9193,9 @@ const encoder = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
8973
9193
|
registerCustomTypeEncoder
|
|
8974
9194
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
8975
9195
|
class Observer {
|
|
8976
|
-
constructor() {
|
|
9196
|
+
constructor(handlers) {
|
|
8977
9197
|
__publicField(this, "handlers");
|
|
8978
|
-
this.handlers = /* @__PURE__ */ new Map();
|
|
9198
|
+
this.handlers = handlers ?? /* @__PURE__ */ new Map();
|
|
8979
9199
|
}
|
|
8980
9200
|
onChange(handler) {
|
|
8981
9201
|
this.handlers.set(handler, null);
|
|
@@ -8998,6 +9218,13 @@ const change = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
8998
9218
|
__proto__: null,
|
|
8999
9219
|
Z
|
|
9000
9220
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
9221
|
+
const shallowCopy = (obj) => {
|
|
9222
|
+
if (Array.isArray(obj))
|
|
9223
|
+
return [...obj];
|
|
9224
|
+
if (typeof obj === "object" && obj !== null)
|
|
9225
|
+
return { ...obj };
|
|
9226
|
+
return obj;
|
|
9227
|
+
};
|
|
9001
9228
|
export {
|
|
9002
9229
|
Case,
|
|
9003
9230
|
DataType,
|
|
@@ -9033,10 +9260,12 @@ export {
|
|
|
9033
9260
|
types as kv,
|
|
9034
9261
|
location,
|
|
9035
9262
|
nativeTypedArray,
|
|
9263
|
+
nullToArr,
|
|
9036
9264
|
observe,
|
|
9037
9265
|
primitiveIsZero,
|
|
9038
9266
|
external$1 as runtime,
|
|
9039
9267
|
scale,
|
|
9268
|
+
shallowCopy,
|
|
9040
9269
|
spatial,
|
|
9041
9270
|
throttle,
|
|
9042
9271
|
toArray,
|