@vuu-ui/vuu-data-remote 0.8.22-debug → 0.8.23-debug

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/esm/index.js CHANGED
@@ -163,31 +163,31 @@ var getCookieValue = (name) => {
163
163
  };
164
164
 
165
165
  // ../vuu-utils/src/range-utils.ts
166
- function getFullRange({ from, to }, bufferSize = 0, rowCount = Number.MAX_SAFE_INTEGER) {
167
- if (bufferSize === 0) {
168
- if (rowCount < from) {
166
+ function getFullRange({ from, to }, bufferSize = 0, totalRowCount = Number.MAX_SAFE_INTEGER) {
167
+ if (from === 0 && to === 0) {
168
+ return { from, to };
169
+ } else if (bufferSize === 0) {
170
+ if (totalRowCount < from) {
169
171
  return { from: 0, to: 0 };
170
172
  } else {
171
- return { from, to: Math.min(to, rowCount) };
173
+ return { from, to: Math.min(to, totalRowCount) };
172
174
  }
173
175
  } else if (from === 0) {
174
- return { from, to: Math.min(to + bufferSize, rowCount) };
176
+ return { from, to: Math.min(to + bufferSize, totalRowCount) };
175
177
  } else {
176
- const rangeSize = to - from;
177
- const buff = Math.round(bufferSize / 2);
178
- const shortfallBefore = from - buff < 0;
179
- const shortFallAfter = rowCount - (to + buff) < 0;
180
- if (shortfallBefore && shortFallAfter) {
181
- return { from: 0, to: rowCount };
178
+ const shortfallBefore = from - bufferSize < 0;
179
+ const shortfallAfter = totalRowCount - (to + bufferSize) < 0;
180
+ if (shortfallBefore && shortfallAfter) {
181
+ return { from: 0, to: totalRowCount };
182
182
  } else if (shortfallBefore) {
183
- return { from: 0, to: rangeSize + bufferSize };
184
- } else if (shortFallAfter) {
183
+ return { from: 0, to: to + bufferSize };
184
+ } else if (shortfallAfter) {
185
185
  return {
186
- from: Math.max(0, rowCount - (rangeSize + bufferSize)),
187
- to: rowCount
186
+ from: Math.max(0, from - bufferSize),
187
+ to: totalRowCount
188
188
  };
189
189
  } else {
190
- return { from: from - buff, to: to + buff };
190
+ return { from: from - bufferSize, to: to + bufferSize };
191
191
  }
192
192
  }
193
193
  }
@@ -293,54 +293,67 @@ var RangeMonitor = class {
293
293
  };
294
294
 
295
295
  // ../vuu-utils/src/keyset.ts
296
+ var EMPTY = [];
296
297
  var KeySet = class {
297
298
  constructor(range) {
298
299
  this.keys = /* @__PURE__ */ new Map();
299
- this.free = [];
300
300
  this.nextKeyValue = 0;
301
- this.reset(range);
301
+ this.range = range;
302
+ this.init(range);
302
303
  }
303
- next() {
304
- if (this.free.length > 0) {
305
- return this.free.shift();
304
+ next(free = EMPTY) {
305
+ if (free.length > 0) {
306
+ return free.shift();
306
307
  } else {
307
308
  return this.nextKeyValue++;
308
309
  }
309
310
  }
310
- reset({ from, to }) {
311
+ init({ from, to }) {
312
+ this.keys.clear();
313
+ this.nextKeyValue = 0;
314
+ for (let rowIndex = from; rowIndex < to; rowIndex++) {
315
+ const nextKeyValue = this.next();
316
+ this.keys.set(rowIndex, nextKeyValue);
317
+ }
318
+ return true;
319
+ }
320
+ reset(range) {
321
+ const { from, to } = range;
322
+ const newSize = to - from;
323
+ const currentSize = this.range.to - this.range.from;
324
+ this.range = range;
325
+ if (currentSize > newSize) {
326
+ return this.init(range);
327
+ }
328
+ const freeKeys = [];
311
329
  this.keys.forEach((keyValue, rowIndex) => {
312
330
  if (rowIndex < from || rowIndex >= to) {
313
- this.free.push(keyValue);
331
+ freeKeys.push(keyValue);
314
332
  this.keys.delete(rowIndex);
315
333
  }
316
334
  });
317
- const size = to - from;
318
- if (this.keys.size + this.free.length > size) {
319
- this.free.length = Math.max(0, size - this.keys.size);
320
- }
321
335
  for (let rowIndex = from; rowIndex < to; rowIndex++) {
322
336
  if (!this.keys.has(rowIndex)) {
323
- const nextKeyValue = this.next();
337
+ const nextKeyValue = this.next(freeKeys);
324
338
  this.keys.set(rowIndex, nextKeyValue);
325
339
  }
326
340
  }
327
- if (this.nextKeyValue > this.keys.size) {
328
- this.nextKeyValue = this.keys.size;
329
- }
341
+ return false;
330
342
  }
331
343
  keyFor(rowIndex) {
332
344
  const key = this.keys.get(rowIndex);
333
345
  if (key === void 0) {
334
346
  console.log(\`key not found
335
347
  keys: \${this.toDebugString()}
336
- free : \${this.free.join(",")}
337
348
  \`);
338
349
  throw Error(\`KeySet, no key found for rowIndex \${rowIndex}\`);
339
350
  }
340
351
  return key;
341
352
  }
342
353
  toDebugString() {
343
- return Array.from(this.keys.entries()).map(([k, v]) => \`\${k}=>\${v}\`).join(",");
354
+ return \`\${this.keys.size} keys
355
+ \${Array.from(this.keys.entries()).sort(([key1], [key2]) => key1 - key2).map(([k, v]) => \`\${k}=>\${v}\`).join(",")}]
356
+ \`;
344
357
  }
345
358
  };
346
359
 
@@ -876,8 +889,9 @@ var Viewport = class {
876
889
  filterSpec: filter,
877
890
  range,
878
891
  sort,
879
- groupBy
880
- }, tableSchema) {
892
+ groupBy,
893
+ table
894
+ }, baseTableSchema) {
881
895
  this.serverViewportId = viewPortId;
882
896
  this.status = "subscribed";
883
897
  this.aggregations = aggregations;
@@ -885,6 +899,13 @@ var Viewport = class {
885
899
  this.groupBy = groupBy;
886
900
  this.isTree = groupBy && groupBy.length > 0;
887
901
  this.dataWindow.setRange(range.from, range.to);
902
+ const tableSchema = table === baseTableSchema.table.table ? baseTableSchema : {
903
+ ...baseTableSchema,
904
+ table: {
905
+ ...baseTableSchema.table,
906
+ session: table
907
+ }
908
+ };
888
909
  return {
889
910
  aggregations,
890
911
  type: "subscribed",
@@ -2338,7 +2359,7 @@ async function connect(connectionString, protocol, callback, retryLimitDisconnec
2338
2359
  };
2339
2360
  return makeConnection(connectionString, protocol, callback);
2340
2361
  }
2341
- async function reconnect(connection) {
2362
+ async function reconnect(_) {
2342
2363
  throw Error("connection broken");
2343
2364
  }
2344
2365
  async function makeConnection(url, protocol, callback, connection) {