@vuu-ui/vuu-data-remote 3.5.0-beta.4 → 3.5.1

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.0-beta.4",
2
+ "version": "3.5.1",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
@@ -11,14 +11,14 @@
11
11
  "type-defs": "node ../../scripts/build-type-defs.mjs"
12
12
  },
13
13
  "devDependencies": {
14
- "@vuu-ui/vuu-data-types": "3.5.0-beta.4",
15
- "@vuu-ui/vuu-table-types": "3.5.0-beta.4",
16
- "@vuu-ui/vuu-filter-types": "3.5.0-beta.4",
17
- "@vuu-ui/vuu-protocol-types": "3.5.0-beta.4"
14
+ "@vuu-ui/vuu-data-types": "3.5.1",
15
+ "@vuu-ui/vuu-table-types": "3.5.1",
16
+ "@vuu-ui/vuu-filter-types": "3.5.1",
17
+ "@vuu-ui/vuu-protocol-types": "3.5.1"
18
18
  },
19
19
  "dependencies": {
20
- "@vuu-ui/vuu-filter-parser": "3.5.0-beta.4",
21
- "@vuu-ui/vuu-utils": "3.5.0-beta.4"
20
+ "@vuu-ui/vuu-filter-parser": "3.5.1",
21
+ "@vuu-ui/vuu-utils": "3.5.1"
22
22
  },
23
23
  "files": [
24
24
  "README.md",
@@ -348,9 +348,10 @@ var EMPTY = [];
348
348
  var KeySet = class {
349
349
  constructor(range) {
350
350
  __publicField(this, "keys", /* @__PURE__ */ new Map());
351
+ __publicField(this, "freeKeys", []);
351
352
  __publicField(this, "nextKeyValue", 0);
352
353
  __publicField(this, "range");
353
- this.range = range;
354
+ this.range = { from: range.from, to: range.to };
354
355
  this.init(range);
355
356
  }
356
357
  next(free = EMPTY) {
@@ -362,6 +363,7 @@ var KeySet = class {
362
363
  }
363
364
  init({ from, to }) {
364
365
  this.keys.clear();
366
+ this.freeKeys.length = 0;
365
367
  this.nextKeyValue = 0;
366
368
  for (let rowIndex = from; rowIndex < to; rowIndex++) {
367
369
  const nextKeyValue = this.next();
@@ -369,27 +371,34 @@ var KeySet = class {
369
371
  }
370
372
  return true;
371
373
  }
372
- reset(range) {
373
- const { from, to } = range;
374
- const newSize = to - from;
375
- const currentSize = this.range.to - this.range.from;
376
- this.range = range;
377
- if (currentSize > newSize) {
378
- return this.init(range);
379
- }
380
- const freeKeys = [];
374
+ /**
375
+ * Keys assigned to rows that remain within range are never changed, keys
376
+ * released by rows leaving the range are recycled for rows entering the
377
+ * range. Keys are never re-sequenced, clients may retain rows (and their
378
+ * keys) that remain within range, so re-assigning keys to those rows would
379
+ * risk duplicate keys on the client.
380
+ * Note: range is copied, callers may mutate the range object they pass.
381
+ * Returns false, keys are never resequenced.
382
+ */
383
+ reset({ from, to }) {
384
+ this.range = { from, to };
385
+ const { freeKeys } = this;
381
386
  this.keys.forEach((keyValue, rowIndex) => {
382
387
  if (rowIndex < from || rowIndex >= to) {
383
388
  freeKeys.push(keyValue);
384
389
  this.keys.delete(rowIndex);
385
390
  }
386
391
  });
392
+ let freeKeyIndex = 0;
387
393
  for (let rowIndex = from; rowIndex < to; rowIndex++) {
388
394
  if (!this.keys.has(rowIndex)) {
389
- const nextKeyValue = this.next(freeKeys);
395
+ const nextKeyValue = freeKeyIndex < freeKeys.length ? freeKeys[freeKeyIndex++] : this.nextKeyValue++;
390
396
  this.keys.set(rowIndex, nextKeyValue);
391
397
  }
392
398
  }
399
+ if (freeKeyIndex > 0) {
400
+ freeKeys.splice(0, freeKeyIndex);
401
+ }
393
402
  return false;
394
403
  }
395
404
  keyFor(rowIndex) {
@@ -571,8 +580,9 @@ var ArrayBackedMovingWindow = class {
571
580
  __publicField(this, "setRowCount", (rowCount) => {
572
581
  var _a;
573
582
  (_a = log.info) == null ? void 0 : _a.call(log, \`setRowCount \${rowCount}\`);
574
- if (rowCount < this.internalData.length) {
575
- this.internalData.length = rowCount;
583
+ const dataLength = Math.max(0, rowCount - __privateGet(this, _range).from);
584
+ if (dataLength < this.internalData.length) {
585
+ this.internalData.length = dataLength;
576
586
  }
577
587
  if (rowCount < this.rowCount) {
578
588
  this.rowsWithinRange = 0;
@@ -655,6 +665,7 @@ var ArrayBackedMovingWindow = class {
655
665
  const currentFrom = this.clientRange.from;
656
666
  const currentTo = Math.min(this.clientRange.to, this.rowCount);
657
667
  if (from === currentFrom && to === currentTo) {
668
+ this.clientRange.to = to;
658
669
  return [false, EMPTY_ARRAY];
659
670
  }
660
671
  const originalRange = this.clientRange.copy();
@@ -669,18 +680,9 @@ var ArrayBackedMovingWindow = class {
669
680
  }
670
681
  const clientRows = [];
671
682
  const offset = __privateGet(this, _range).from;
672
- if (to > originalRange.to) {
673
- const start = Math.max(from, originalRange.to);
674
- for (let i = start - offset; i < to - offset; i++) {
675
- const row = this.internalData[i];
676
- if (row) {
677
- clientRows.push(row);
678
- }
679
- }
680
- } else {
681
- const end = Math.min(originalRange.from, to);
682
- for (let i = from - offset; i < end - offset; i++) {
683
- const row = this.internalData[i];
683
+ for (let i = from; i < to; i++) {
684
+ if (i < originalRange.from || i >= originalRange.to) {
685
+ const row = this.internalData[i - offset];
684
686
  if (row) {
685
687
  clientRows.push(row);
686
688
  }
@@ -33,7 +33,8 @@ class ArrayBackedMovingWindow {
33
33
  }
34
34
  setRowCount = (rowCount)=>{
35
35
  log.info?.(`setRowCount ${rowCount}`);
36
- if (rowCount < this.internalData.length) this.internalData.length = rowCount;
36
+ const dataLength = Math.max(0, rowCount - this.#range.from);
37
+ if (dataLength < this.internalData.length) this.internalData.length = dataLength;
37
38
  if (rowCount < this.rowCount) {
38
39
  this.rowsWithinRange = 0;
39
40
  const end = Math.min(rowCount, this.clientRange.to);
@@ -68,10 +69,13 @@ class ArrayBackedMovingWindow {
68
69
  log.debug?.(`setClientRange ${from} - ${to}`);
69
70
  const currentFrom = this.clientRange.from;
70
71
  const currentTo = Math.min(this.clientRange.to, this.rowCount);
71
- if (from === currentFrom && to === currentTo) return [
72
- false,
73
- EMPTY_ARRAY
74
- ];
72
+ if (from === currentFrom && to === currentTo) {
73
+ this.clientRange.to = to;
74
+ return [
75
+ false,
76
+ EMPTY_ARRAY
77
+ ];
78
+ }
75
79
  const originalRange = this.clientRange.copy();
76
80
  this.clientRange.from = from;
77
81
  this.clientRange.to = to;
@@ -82,18 +86,9 @@ class ArrayBackedMovingWindow {
82
86
  }
83
87
  const clientRows = [];
84
88
  const offset = this.#range.from;
85
- if (to > originalRange.to) {
86
- const start = Math.max(from, originalRange.to);
87
- for(let i = start - offset; i < to - offset; i++){
88
- const row = this.internalData[i];
89
- if (row) clientRows.push(row);
90
- }
91
- } else {
92
- const end = Math.min(originalRange.from, to);
93
- for(let i = from - offset; i < end - offset; i++){
94
- const row = this.internalData[i];
95
- if (row) clientRows.push(row);
96
- }
89
+ for(let i = from; i < to; i++)if (i < originalRange.from || i >= originalRange.to) {
90
+ const row = this.internalData[i - offset];
91
+ if (row) clientRows.push(row);
97
92
  }
98
93
  const serverDataRequired = this.bufferBreakout(from, to);
99
94
  return [