@vuu-ui/vuu-data-remote 0.13.42 → 0.13.44
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/cjs/inlined-worker.js +29 -11
- package/cjs/inlined-worker.js.map +1 -1
- package/cjs/message-utils.js +16 -3
- package/cjs/message-utils.js.map +1 -1
- package/esm/inlined-worker.js +29 -11
- package/esm/inlined-worker.js.map +1 -1
- package/esm/message-utils.js +16 -3
- package/esm/message-utils.js.map +1 -1
- package/package.json +7 -7
- package/types/inlined-worker.d.ts +1 -1
- package/types/message-utils.d.ts +11 -1
package/cjs/message-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-utils.js","sources":["../../../packages/vuu-data-remote/src/message-utils.ts"],"sourcesContent":["import { TableSchema, WithRequestId } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuTableMetaResponse,\n VuuRow,\n VuuRange,\n} from \"@vuu-ui/vuu-protocol-types\";\n\nexport const hasRequestId = <T extends object>(\n message: T,\n): message is WithRequestId<T> => {\n return \"requestId\" in message;\n};\n\nexport const stripRequestId = <T>({\n requestId,\n ...rest\n}: WithRequestId<T>): [string, T] => [requestId, rest as T];\n\nexport const getFirstAndLastRows = (\n rows: VuuRow[],\n): [VuuRow, VuuRow] | [VuuRow] => {\n let firstRow = rows.at(0) as VuuRow;\n if (firstRow.updateType === \"SIZE\") {\n if (rows.length === 1) {\n return rows as [VuuRow];\n } else {\n firstRow = rows.at(1) as VuuRow;\n }\n }\n const lastRow = rows.at(-1) as VuuRow;\n return [firstRow, lastRow];\n};\n\nexport type ViewportRowMap = { [key: string]: VuuRow[] };\n\nconst insertRow = (rows: VuuRow[], row: VuuRow) => {\n const lastRow = rows.at(-1);\n if (lastRow === undefined || row.rowIndex > lastRow.rowIndex) {\n rows.push(row);\n } else {\n for (let i = 0; i < rows.length; i++) {\n if (row.rowIndex < rows[i].rowIndex) {\n rows.splice(i, 0, row);\n return;\n } else if (row.rowIndex === rows[i].rowIndex) {\n if (row.ts < rows[i].ts) {\n // ignore an earlier update\n } else {\n rows[i] = row;\n }\n return;\n }\n }\n throw Error(\"don't expect to get this far\");\n }\n};\n\nexport const groupRowsByViewport = (rows: VuuRow[]): ViewportRowMap => {\n const result: ViewportRowMap = {};\n for (const row of rows) {\n const rowsForViewport =\n result[row.viewPortId] || (result[row.viewPortId] = []);\n insertRow(rowsForViewport, row);\n }\n return result;\n};\n\nexport const createSchemaFromTableMetadata = ({\n columns,\n dataTypes,\n key,\n table,\n}: Omit<VuuTableMetaResponse, \"type\">): Readonly<TableSchema> => {\n return {\n table,\n columns: columns.map((col, idx) => ({\n name: col,\n serverDataType: dataTypes[idx],\n })),\n key,\n };\n};\n\nexport const gapBetweenLastRowSentToClient = (\n lastRowsReturnedToClient: [number, number],\n pendingUpdates: VuuRow[],\n clientRange: VuuRange,\n): VuuRange | undefined => {\n const firstPendingUpdate = pendingUpdates.at(0);\n const lastPendingUpdate = pendingUpdates.at(-1);\n\n if (firstPendingUpdate && lastPendingUpdate) {\n const [firstRowIndex, lastRowIndex] = lastRowsReturnedToClient;\n
|
|
1
|
+
{"version":3,"file":"message-utils.js","sources":["../../../packages/vuu-data-remote/src/message-utils.ts"],"sourcesContent":["import { TableSchema, WithRequestId } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuTableMetaResponse,\n VuuRow,\n VuuRange,\n} from \"@vuu-ui/vuu-protocol-types\";\n\nexport const hasRequestId = <T extends object>(\n message: T,\n): message is WithRequestId<T> => {\n return \"requestId\" in message;\n};\n\nexport const stripRequestId = <T>({\n requestId,\n ...rest\n}: WithRequestId<T>): [string, T] => [requestId, rest as T];\n\nexport const getFirstAndLastRows = (\n rows: VuuRow[],\n): [VuuRow, VuuRow] | [VuuRow] => {\n let firstRow = rows.at(0) as VuuRow;\n if (firstRow.updateType === \"SIZE\") {\n if (rows.length === 1) {\n return rows as [VuuRow];\n } else {\n firstRow = rows.at(1) as VuuRow;\n }\n }\n const lastRow = rows.at(-1) as VuuRow;\n return [firstRow, lastRow];\n};\n\nexport type ViewportRowMap = { [key: string]: VuuRow[] };\n\nconst insertRow = (rows: VuuRow[], row: VuuRow) => {\n const lastRow = rows.at(-1);\n if (lastRow === undefined || row.rowIndex > lastRow.rowIndex) {\n rows.push(row);\n } else {\n for (let i = 0; i < rows.length; i++) {\n if (row.rowIndex < rows[i].rowIndex) {\n rows.splice(i, 0, row);\n return;\n } else if (row.rowIndex === rows[i].rowIndex) {\n if (row.ts < rows[i].ts) {\n // ignore an earlier update\n } else {\n rows[i] = row;\n }\n return;\n }\n }\n throw Error(\"don't expect to get this far\");\n }\n};\n\nexport const groupRowsByViewport = (rows: VuuRow[]): ViewportRowMap => {\n const result: ViewportRowMap = {};\n for (const row of rows) {\n const rowsForViewport =\n result[row.viewPortId] || (result[row.viewPortId] = []);\n insertRow(rowsForViewport, row);\n }\n return result;\n};\n\nexport const createSchemaFromTableMetadata = ({\n columns,\n dataTypes,\n key,\n table,\n}: Omit<VuuTableMetaResponse, \"type\">): Readonly<TableSchema> => {\n return {\n table,\n columns: columns.map((col, idx) => ({\n name: col,\n serverDataType: dataTypes[idx],\n })),\n key,\n };\n};\n\n/**\n * This is called when we have row updates to process and\n * we have rows in local cache to fill client range.\n * We check here to see if there is any gap between this\n * set of updates and the last set of rows sent to client.\n * If so, it indicates that we have previously received\n * updates but that we did not have all ther rows needed\n * to satisfy client range request, so they were not sent\n * to client. Now we can send them all.\n */\nexport const gapBetweenLastRowSentToClient = (\n lastRowsReturnedToClient: [number, number],\n pendingUpdates: VuuRow[],\n clientRange: VuuRange,\n rowCount: number,\n): VuuRange | undefined => {\n const firstPendingUpdate = pendingUpdates.at(0);\n const lastPendingUpdate = pendingUpdates.at(-1);\n\n if (firstPendingUpdate && lastPendingUpdate) {\n const maxTo = Math.min(rowCount, clientRange.to);\n\n const [firstRowIndex, lastRowIndex] = lastRowsReturnedToClient;\n if (\n lastRowIndex < firstPendingUpdate.rowIndex - 1 &&\n clientRange.from < firstPendingUpdate.rowIndex\n ) {\n return {\n from: Math.max(lastRowIndex + 1, clientRange.from),\n to: firstPendingUpdate.rowIndex,\n };\n } else if (\n firstRowIndex > lastPendingUpdate.rowIndex + 1 &&\n maxTo > lastPendingUpdate.rowIndex\n ) {\n return {\n from: lastPendingUpdate.rowIndex + 1,\n to: Math.min(maxTo, firstRowIndex),\n };\n } else if (firstRowIndex === -1 && lastRowIndex === -1) {\n if (clientRange.from < firstPendingUpdate.rowIndex) {\n return {\n from: clientRange.from,\n to: firstPendingUpdate.rowIndex,\n };\n } else if (maxTo > lastPendingUpdate.rowIndex + 1) {\n return {\n from: lastPendingUpdate.rowIndex + 1,\n to: maxTo,\n };\n }\n }\n }\n};\n"],"names":[],"mappings":";;AAOa,MAAA,YAAA,GAAe,CAC1B,OACgC,KAAA;AAChC,EAAA,OAAO,WAAe,IAAA,OAAA;AACxB;AAEO,MAAM,iBAAiB,CAAI;AAAA,EAChC,SAAA;AAAA,EACA,GAAG;AACL,CAAqC,KAAA,CAAC,WAAW,IAAS;AAE7C,MAAA,mBAAA,GAAsB,CACjC,IACgC,KAAA;AAChC,EAAI,IAAA,QAAA,GAAW,IAAK,CAAA,EAAA,CAAG,CAAC,CAAA;AACxB,EAAI,IAAA,QAAA,CAAS,eAAe,MAAQ,EAAA;AAClC,IAAI,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AACrB,MAAO,OAAA,IAAA;AAAA,KACF,MAAA;AACL,MAAW,QAAA,GAAA,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA;AACtB;AAEF,EAAM,MAAA,OAAA,GAAU,IAAK,CAAA,EAAA,CAAG,CAAE,CAAA,CAAA;AAC1B,EAAO,OAAA,CAAC,UAAU,OAAO,CAAA;AAC3B;AAIA,MAAM,SAAA,GAAY,CAAC,IAAA,EAAgB,GAAgB,KAAA;AACjD,EAAM,MAAA,OAAA,GAAU,IAAK,CAAA,EAAA,CAAG,CAAE,CAAA,CAAA;A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AClB,IAAI,kBAAmB,CAAA;AAAA,SACzB;AAAA,OACS,MAAA,IAAA,KAAA,GAAQ,iBAAkB,CAAA,QAAA,GAAW,CAAG,EAAA;AACjD,QAAO,OAAA;AAAA,UACL,IAAA,EAAM,kBAAkB,QAAW,GAAA,CAAA;AAAA,UACnC,EAAI,EAAA;AAAA,SACN;AAAA;AACF;AACF;AAEJ;;;;;;;;;"}
|
package/esm/inlined-worker.js
CHANGED
|
@@ -535,21 +535,34 @@ var createSchemaFromTableMetadata = ({
|
|
|
535
535
|
key
|
|
536
536
|
};
|
|
537
537
|
};
|
|
538
|
-
var gapBetweenLastRowSentToClient = (lastRowsReturnedToClient, pendingUpdates, clientRange) => {
|
|
538
|
+
var gapBetweenLastRowSentToClient = (lastRowsReturnedToClient, pendingUpdates, clientRange, rowCount) => {
|
|
539
539
|
const firstPendingUpdate = pendingUpdates.at(0);
|
|
540
540
|
const lastPendingUpdate = pendingUpdates.at(-1);
|
|
541
541
|
if (firstPendingUpdate && lastPendingUpdate) {
|
|
542
|
+
const maxTo = Math.min(rowCount, clientRange.to);
|
|
542
543
|
const [firstRowIndex, lastRowIndex] = lastRowsReturnedToClient;
|
|
543
544
|
if (lastRowIndex < firstPendingUpdate.rowIndex - 1 && clientRange.from < firstPendingUpdate.rowIndex) {
|
|
544
545
|
return {
|
|
545
546
|
from: Math.max(lastRowIndex + 1, clientRange.from),
|
|
546
547
|
to: firstPendingUpdate.rowIndex
|
|
547
548
|
};
|
|
548
|
-
} else if (firstRowIndex > lastPendingUpdate.rowIndex + 1 &&
|
|
549
|
+
} else if (firstRowIndex > lastPendingUpdate.rowIndex + 1 && maxTo > lastPendingUpdate.rowIndex) {
|
|
549
550
|
return {
|
|
550
551
|
from: lastPendingUpdate.rowIndex + 1,
|
|
551
|
-
to: Math.min(
|
|
552
|
+
to: Math.min(maxTo, firstRowIndex)
|
|
552
553
|
};
|
|
554
|
+
} else if (firstRowIndex === -1 && lastRowIndex === -1) {
|
|
555
|
+
if (clientRange.from < firstPendingUpdate.rowIndex) {
|
|
556
|
+
return {
|
|
557
|
+
from: clientRange.from,
|
|
558
|
+
to: firstPendingUpdate.rowIndex
|
|
559
|
+
};
|
|
560
|
+
} else if (maxTo > lastPendingUpdate.rowIndex + 1) {
|
|
561
|
+
return {
|
|
562
|
+
from: lastPendingUpdate.rowIndex + 1,
|
|
563
|
+
to: maxTo
|
|
564
|
+
};
|
|
565
|
+
}
|
|
553
566
|
}
|
|
554
567
|
}
|
|
555
568
|
};
|
|
@@ -866,6 +879,10 @@ var Viewport = class {
|
|
|
866
879
|
// Records SIZE only updates
|
|
867
880
|
__publicField(this, "setLastSizeOnlyUpdateSize", (size) => {
|
|
868
881
|
this.lastUpdateStatus.size = size;
|
|
882
|
+
if (size === 0) {
|
|
883
|
+
this.lastRowsReturnedToClient[0] = -1;
|
|
884
|
+
this.lastRowsReturnedToClient[1] = -1;
|
|
885
|
+
}
|
|
869
886
|
});
|
|
870
887
|
__publicField(this, "setLastUpdate", (mode) => {
|
|
871
888
|
const { ts: lastTS, mode: lastMode } = this.lastUpdateStatus;
|
|
@@ -1407,7 +1424,8 @@ var Viewport = class {
|
|
|
1407
1424
|
const missingRows = gapBetweenLastRowSentToClient(
|
|
1408
1425
|
this.lastRowsReturnedToClient,
|
|
1409
1426
|
this.pendingUpdates,
|
|
1410
|
-
this.dataWindow.clientRange
|
|
1427
|
+
this.dataWindow.clientRange,
|
|
1428
|
+
this.dataWindow.rowCount
|
|
1411
1429
|
);
|
|
1412
1430
|
if (missingRows) {
|
|
1413
1431
|
for (let i = missingRows.from; i < missingRows.to; i++) {
|
|
@@ -1431,6 +1449,9 @@ var Viewport = class {
|
|
|
1431
1449
|
}
|
|
1432
1450
|
this.lastRowsReturnedToClient[0] = (_b = (_a = out.at(0)) == null ? void 0 : _a[0]) != null ? _b : -1;
|
|
1433
1451
|
this.lastRowsReturnedToClient[1] = (_d = (_c = out.at(-1)) == null ? void 0 : _c[0]) != null ? _d : -1;
|
|
1452
|
+
} else if (this.pendingUpdates.length > 0) {
|
|
1453
|
+
this.lastRowsReturnedToClient[0] = -1;
|
|
1454
|
+
this.lastRowsReturnedToClient[1] = -1;
|
|
1434
1455
|
}
|
|
1435
1456
|
this.pendingUpdates.length = 0;
|
|
1436
1457
|
this.hasUpdates = false;
|
|
@@ -2064,7 +2085,7 @@ var ServerProxy = class {
|
|
|
2064
2085
|
}
|
|
2065
2086
|
}
|
|
2066
2087
|
handleMessageFromServer(message) {
|
|
2067
|
-
var _a
|
|
2088
|
+
var _a;
|
|
2068
2089
|
const { body, requestId, sessionId } = message;
|
|
2069
2090
|
const pendingRequest = this.pendingRequests.get(requestId);
|
|
2070
2091
|
if (pendingRequest) {
|
|
@@ -2170,7 +2191,7 @@ var ServerProxy = class {
|
|
|
2170
2191
|
{
|
|
2171
2192
|
const viewportRowMap = groupRowsByViewport(body.rows);
|
|
2172
2193
|
if (debugEnabled3) {
|
|
2173
|
-
const [firstRow
|
|
2194
|
+
const [firstRow] = body.rows;
|
|
2174
2195
|
if (body.rows.length === 0) {
|
|
2175
2196
|
infoEnabled2 && info2("handleMessageFromServer TABLE_ROW 0 rows");
|
|
2176
2197
|
} else if ((firstRow == null ? void 0 : firstRow.rowIndex) === -1) {
|
|
@@ -2179,9 +2200,6 @@ var ServerProxy = class {
|
|
|
2179
2200
|
infoEnabled2 && info2(
|
|
2180
2201
|
\`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
|
|
2181
2202
|
);
|
|
2182
|
-
infoEnabled2 && info2(
|
|
2183
|
-
\`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
|
|
2184
|
-
);
|
|
2185
2203
|
} else {
|
|
2186
2204
|
infoEnabled2 && info2(
|
|
2187
2205
|
\`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
|
|
@@ -2189,12 +2207,12 @@ var ServerProxy = class {
|
|
|
2189
2207
|
}
|
|
2190
2208
|
} else {
|
|
2191
2209
|
infoEnabled2 && info2(
|
|
2192
|
-
\`handleMessageFromServer TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${
|
|
2210
|
+
\`handleMessageFromServer TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
|
|
2193
2211
|
);
|
|
2194
2212
|
}
|
|
2195
2213
|
} else {
|
|
2196
2214
|
infoEnabled2 && info2(
|
|
2197
|
-
\`handleMessageFromServer TABLE_ROW \${body.rows.length} rows [\${
|
|
2215
|
+
\`handleMessageFromServer TABLE_ROW \${body.rows.length} rows [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
|
|
2198
2216
|
);
|
|
2199
2217
|
}
|
|
2200
2218
|
}
|