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