@vuu-ui/vuu-data-remote 2.1.13 → 2.1.15

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.
@@ -321,7 +321,6 @@ var InvalidLoginMessages = [
321
321
  INVALID_TOKEN,
322
322
  TOKEN_EXPIRED
323
323
  ];
324
- var isErrorMessage = (message) => typeof message == "object" && (message == null ? void 0 : message.type) === "ERROR";
325
324
  var isLoginErrorMessage = (message) => typeof message === "string" && InvalidLoginMessages.includes(message);
326
325
  var isSelectRequest = (message) => message && typeof message === "object" && "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
327
326
  var isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
@@ -590,9 +589,13 @@ var ArrayBackedMovingWindow = class {
590
589
  get range() {
591
590
  return __privateGet(this, _range);
592
591
  }
593
- get hasAllRowsWithinRange() {
594
- return this.rowsWithinRange === this.clientRange.to - this.clientRange.from || this.rowCount > 0 && this.clientRange.from + this.rowsWithinRange === this.rowCount;
595
- }
592
+ // get hasAllRowsWithinRange(): boolean {
593
+ // return (
594
+ // this.rowsWithinRange === this.clientRange.to - this.clientRange.from ||
595
+ // (this.rowCount > 0 &&
596
+ // this.clientRange.from + this.rowsWithinRange === this.rowCount)
597
+ // );
598
+ // }
596
599
  // Check to see if set of rows is outside the current viewport range, indicating
597
600
  // that veiwport is being scrolled quickly and server is not able to keep up.
598
601
  outOfRange(firstIndex, lastIndex) {
@@ -906,9 +909,7 @@ var Viewport = class {
906
909
  this.table = table;
907
910
  this.sort = sort;
908
911
  this.title = title;
909
- infoEnabled && (info == null ? void 0 : info(
910
- \`constructor #\${viewport} \${table.table} bufferSize=\${bufferSize}\`
911
- ));
912
+ infoEnabled && (info == null ? void 0 : info(\`\${table.table} #\${viewport}, bufferSize=\${bufferSize}\`));
912
913
  this.dataWindow = new ArrayBackedMovingWindow(
913
914
  __privateGet(this, _clientRange),
914
915
  range,
@@ -1223,6 +1224,7 @@ var Viewport = class {
1223
1224
  }
1224
1225
  suspend() {
1225
1226
  this.suspended = true;
1227
+ this.pendingUpdates.length = 0;
1226
1228
  info == null ? void 0 : info("suspend");
1227
1229
  }
1228
1230
  resume() {
@@ -1360,9 +1362,11 @@ var Viewport = class {
1360
1362
  }
1361
1363
  if (row.updateType === "U") {
1362
1364
  if ((_c = this.dataWindow) == null ? void 0 : _c.setAtIndex(row)) {
1363
- this.hasUpdates = true;
1364
- if (!this.batchMode) {
1365
- this.pendingUpdates.push(row);
1365
+ if (this.suspended !== true) {
1366
+ this.hasUpdates = true;
1367
+ if (!this.batchMode) {
1368
+ this.pendingUpdates.push(row);
1369
+ }
1366
1370
  }
1367
1371
  }
1368
1372
  }
@@ -1498,9 +1502,9 @@ var WebSocketConnection = class extends EventEmitter {
1498
1502
  __privateAdd(this, _ws);
1499
1503
  __publicField(this, "receive", (evt) => {
1500
1504
  if (isLoginErrorMessage(evt.data)) {
1501
- console.log(\`[WebSocketConnection] closed because of login issue\`);
1505
+ console.warn(\`[WebSocketConnection] closed because of login issue\`);
1502
1506
  if (__privateGet(this, _deferredOpen)) {
1503
- console.log(\`... and qwe have a deferred connection\`);
1507
+ console.warn(\`... and we have a deferred connection\`);
1504
1508
  }
1505
1509
  __privateGet(this, _callback).call(this, {
1506
1510
  type: "LOGIN_REJECTED",
@@ -1511,7 +1515,7 @@ var WebSocketConnection = class extends EventEmitter {
1511
1515
  const vuuMessageFromServer = parseWebSocketMessage(evt.data);
1512
1516
  if (debugEnabled3) {
1513
1517
  if (vuuMessageFromServer.body.type !== "HB") {
1514
- debug3(\`\${vuuMessageFromServer.body.type}\`);
1518
+ debug3(\`<=== \${vuuMessageFromServer.body.type}\`);
1515
1519
  if (vuuMessageFromServer.body.type === "CHANGE_VP_SUCCESS") {
1516
1520
  debug3(JSON.stringify(vuuMessageFromServer.body));
1517
1521
  }
@@ -1530,7 +1534,7 @@ var WebSocketConnection = class extends EventEmitter {
1530
1534
  var _a;
1531
1535
  if (msg.body.type === "CHANGE_VP_RANGE") {
1532
1536
  info2 == null ? void 0 : info2(
1533
- \`CHANGE_VP_RANGE<#\${msg.requestId}> \${msg.body.from}-\${msg.body.to}\`
1537
+ \`===> CHANGE_VP_RANGE<#\${msg.requestId}> \${msg.body.from}-\${msg.body.to}\`
1534
1538
  );
1535
1539
  }
1536
1540
  (_a = __privateGet(this, _ws)) == null ? void 0 : _a.send(JSON.stringify(msg));
@@ -1770,13 +1774,7 @@ var ServerProxy = class {
1770
1774
  pendingSubscription,
1771
1775
  pendingTableSchema
1772
1776
  ]);
1773
- if (isErrorMessage(tableSchema)) {
1774
- this.postMessageToClient({
1775
- clientViewportId: message.viewport,
1776
- type: "subscribe-failed",
1777
- msg: \`failed to fetch schema for table \${message.table.table}: \${tableSchema.msg}\`
1778
- });
1779
- } else if (isCreateVpSuccess(subscribeResponse)) {
1777
+ if (isCreateVpSuccess(subscribeResponse)) {
1780
1778
  const { viewPortId: serverViewportId } = subscribeResponse;
1781
1779
  const { status: previousViewportStatus } = viewport;
1782
1780
  if (message.viewport !== serverViewportId) {
@@ -1824,11 +1822,6 @@ var ServerProxy = class {
1824
1822
  });
1825
1823
  }
1826
1824
  } else {
1827
- this.postMessageToClient({
1828
- clientViewportId: message.viewport,
1829
- type: "subscribe-failed",
1830
- msg: \`failed to open subscription on table \${message.table.table}: \${subscribeResponse.msg}\`
1831
- });
1832
1825
  }
1833
1826
  } else {
1834
1827
  error2(\`spurious subscribe call \${message.viewport}\`);
@@ -2214,8 +2207,7 @@ var ServerProxy = class {
2214
2207
  }
2215
2208
  case "GET_TABLE_META": {
2216
2209
  this.getTableMeta(message.table, requestId).then((tableSchema) => {
2217
- if (isErrorMessage(tableSchema)) {
2218
- } else if (tableSchema) {
2210
+ if (tableSchema) {
2219
2211
  this.postMessageToClient({
2220
2212
  type: "TABLE_META_RESP",
2221
2213
  tableSchema,
@@ -2236,9 +2228,10 @@ var ServerProxy = class {
2236
2228
  }
2237
2229
  getTableMeta(table, requestId = nextRequestId()) {
2238
2230
  if (isSessionTable(table)) {
2239
- return this.awaitResponseToMessage({ type: "GET_TABLE_META", table }, requestId).then(
2240
- (resp) => isErrorMessage(resp) ? resp : createSchemaFromTableMetadata(resp)
2241
- );
2231
+ return this.awaitResponseToMessage(
2232
+ { type: "GET_TABLE_META", table },
2233
+ requestId
2234
+ ).then(createSchemaFromTableMetadata);
2242
2235
  }
2243
2236
  const key = \`\${table.module}:\${table.table}\`;
2244
2237
  let tableMetaRequest = this.cachedTableMetaRequests.get(key);
@@ -2249,13 +2242,7 @@ var ServerProxy = class {
2249
2242
  );
2250
2243
  this.cachedTableMetaRequests.set(key, tableMetaRequest);
2251
2244
  }
2252
- return tableMetaRequest == null ? void 0 : tableMetaRequest.then((response) => {
2253
- if (isErrorMessage(response)) {
2254
- return response;
2255
- } else {
2256
- return this.cacheTableMeta(response);
2257
- }
2258
- });
2245
+ return tableMetaRequest == null ? void 0 : tableMetaRequest.then((response) => this.cacheTableMeta(response));
2259
2246
  }
2260
2247
  awaitResponseToMessage(message, requestId = nextRequestId()) {
2261
2248
  return new Promise((resolve, reject) => {
@@ -2419,26 +2406,26 @@ var ServerProxy = class {
2419
2406
  if (debugEnabled4) {
2420
2407
  const [firstRow] = body.rows;
2421
2408
  if (body.rows.length === 0) {
2422
- infoEnabled2 && info3("handleMessageFromServer TABLE_ROW 0 rows");
2409
+ infoEnabled2 && info3("<=== TABLE_ROW 0 rows");
2423
2410
  } else if ((firstRow == null ? void 0 : firstRow.rowIndex) === -1) {
2424
2411
  if (body.rows.length === 1) {
2425
2412
  if (firstRow.updateType === "SIZE") {
2426
2413
  infoEnabled2 && info3(
2427
- \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
2414
+ \`<=== [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
2428
2415
  );
2429
2416
  } else {
2430
2417
  infoEnabled2 && info3(
2431
- \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
2418
+ \`<=== [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
2432
2419
  );
2433
2420
  }
2434
2421
  } else {
2435
2422
  infoEnabled2 && info3(
2436
- \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2423
+ \`<=== TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2437
2424
  );
2438
2425
  }
2439
2426
  } else {
2440
2427
  infoEnabled2 && info3(
2441
- \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2428
+ \`<=== TABLE_ROW \${body.rows.length} rows [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2442
2429
  );
2443
2430
  }
2444
2431
  }
@@ -2460,7 +2447,9 @@ var ServerProxy = class {
2460
2447
  const viewport = this.viewports.get(body.viewPortId);
2461
2448
  if (viewport) {
2462
2449
  const { from, to } = body;
2463
- infoEnabled2 && info3(\`CHANGE_VP_RANGE_SUCCESS<#\${requestId}> \${from} - \${to}\`);
2450
+ infoEnabled2 && info3(
2451
+ \`<=== CHANGE_VP_RANGE_SUCCESS<#\${requestId}> \${from} - \${to}\`
2452
+ );
2464
2453
  viewport.completeOperation(requestId, from, to);
2465
2454
  }
2466
2455
  }
@@ -2605,7 +2594,7 @@ var ServerProxy = class {
2605
2594
  error2(body.msg);
2606
2595
  break;
2607
2596
  default:
2608
- infoEnabled2 && info3(\`handleMessageFromServer \${body["type"]}.\`);
2597
+ infoEnabled2 && info3(\`<=== \${body["type"]}.\`);
2609
2598
  }
2610
2599
  }
2611
2600
  cacheTableMeta(messageBody) {
@@ -2645,7 +2634,7 @@ var ServerProxy = class {
2645
2634
  const size = viewport.getNewRowCount();
2646
2635
  if (size !== void 0 || rows && rows.length > 0) {
2647
2636
  debugEnabled4 && debug4(
2648
- \`postMessageToClient #\${viewport.clientViewportId} viewport-update \${mode}, \${(_a = rows == null ? void 0 : rows.length) != null ? _a : "no"} rows, size \${size}\`
2637
+ \`===> #\${viewport.clientViewportId} viewport-update \${mode}, \${(_a = rows == null ? void 0 : rows.length) != null ? _a : "no"} rows, size \${size}\`
2649
2638
  );
2650
2639
  if (mode) {
2651
2640
  this.postMessageToClient({
@@ -2712,15 +2701,15 @@ var handleMessageFromClient = async ({
2712
2701
  webSocketConnection == null ? void 0 : webSocketConnection.close();
2713
2702
  break;
2714
2703
  case "subscribe":
2715
- infoEnabled3 && info4(\`client subscribe: \${JSON.stringify(message)}\`);
2704
+ infoEnabled3 && info4(\`===> \${JSON.stringify(message)}\`);
2716
2705
  serverProxy.subscribe(message);
2717
2706
  break;
2718
2707
  case "unsubscribe":
2719
- infoEnabled3 && info4(\`client unsubscribe: \${JSON.stringify(message)}\`);
2708
+ infoEnabled3 && info4(\`===> \${JSON.stringify(message)}\`);
2720
2709
  serverProxy.unsubscribe(message.viewport);
2721
2710
  break;
2722
2711
  default:
2723
- infoEnabled3 && info4(\`client message: \${JSON.stringify(message)}\`);
2712
+ infoEnabled3 && info4(\`===> \${JSON.stringify(message)}\`);
2724
2713
  serverProxy.handleMessageFromClient(message);
2725
2714
  }
2726
2715
  };