@tanstack/table-core 9.0.0-beta.31 → 9.0.0-beta.34
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/dist/core/cells/constructCell.cjs +1 -4
- package/dist/core/cells/constructCell.cjs.map +1 -1
- package/dist/core/cells/constructCell.d.cts +1 -1
- package/dist/core/cells/constructCell.d.ts +1 -1
- package/dist/core/cells/constructCell.js +1 -4
- package/dist/core/cells/constructCell.js.map +1 -1
- package/dist/core/cells/coreCellsFeature.types.d.cts +1 -1
- package/dist/core/cells/coreCellsFeature.types.d.ts +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.ts +1 -1
- package/dist/core/columns/constructColumn.cjs +3 -9
- package/dist/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.js +3 -9
- package/dist/core/columns/constructColumn.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.cjs +12 -18
- package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.js +12 -18
- package/dist/core/columns/coreColumnsFeature.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.cjs +2 -6
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.js +2 -6
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs +1 -2
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.js +1 -2
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/constructHeader.cjs +1 -4
- package/dist/core/headers/constructHeader.cjs.map +1 -1
- package/dist/core/headers/constructHeader.js +1 -4
- package/dist/core/headers/constructHeader.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs +8 -11
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.js +8 -11
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs +2 -4
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js +2 -4
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +3 -3
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +3 -3
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +6 -24
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.js +6 -24
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs +2 -3
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +1 -1
- package/dist/core/row-models/createCoreRowModel.d.ts +1 -1
- package/dist/core/row-models/createCoreRowModel.js +2 -3
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +2 -8
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.js +2 -8
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.cjs +4 -1
- package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.js +4 -1
- package/dist/core/rows/coreRowsFeature.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.cjs +3 -4
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.js +3 -4
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +4 -10
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js +4 -10
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/experimental-worker-plugin.cjs +14 -0
- package/dist/experimental-worker-plugin.d.cts +5 -0
- package/dist/experimental-worker-plugin.d.ts +5 -0
- package/dist/experimental-worker-plugin.js +6 -0
- package/dist/features/column-faceting/columnFacetingFeature.cjs +12 -18
- package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.js +12 -18
- package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +7 -25
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +7 -25
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +8 -14
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.cts +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.ts +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.js +8 -14
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +10 -13
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +10 -13
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +12 -18
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.cts +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +12 -18
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +1 -4
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +1 -4
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +8 -13
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +8 -13
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +3 -7
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js +3 -7
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs +13 -19
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.js +13 -19
- package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +6 -11
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +6 -11
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +78 -114
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.js +78 -114
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +15 -28
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.js +15 -28
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +12 -16
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.js +12 -16
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +24 -48
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +24 -48
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +11 -18
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.js +11 -18
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +25 -40
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +25 -40
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +3 -6
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +3 -6
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.cjs +1 -2
- package/dist/features/global-filtering/globalFilteringFeature.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.js +1 -2
- package/dist/features/global-filtering/globalFilteringFeature.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +3 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +3 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.cjs +6 -10
- package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.cts +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.ts +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.js +6 -10
- package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +8 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +8 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs +6 -10
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.cts +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.ts +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.js +6 -10
- package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +8 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +8 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.cjs +4 -16
- package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.js +4 -16
- package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +7 -12
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.js +7 -12
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +30 -60
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +30 -60
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +11 -18
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.js +12 -19
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +20 -14
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.cts +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.ts +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +21 -15
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +10 -14
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +10 -14
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/flex-render.d.cts +1 -1
- package/dist/flex-render.d.ts +1 -1
- package/dist/fns/filterFns.cjs +8 -12
- package/dist/fns/filterFns.cjs.map +1 -1
- package/dist/fns/filterFns.js +8 -12
- package/dist/fns/filterFns.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +18 -18
- package/dist/index.d.ts +18 -18
- package/dist/index.js +2 -2
- package/dist/store-reactivity-bindings.cjs +2 -2
- package/dist/store-reactivity-bindings.cjs.map +1 -1
- package/dist/store-reactivity-bindings.js +2 -2
- package/dist/store-reactivity-bindings.js.map +1 -1
- package/dist/types/Cell.d.cts +1 -1
- package/dist/types/Cell.d.ts +1 -1
- package/dist/types/Column.d.cts +7 -7
- package/dist/types/Column.d.ts +7 -7
- package/dist/types/ColumnDef.d.cts +6 -6
- package/dist/types/ColumnDef.d.ts +6 -6
- package/dist/types/Header.d.cts +1 -1
- package/dist/types/Header.d.ts +1 -1
- package/dist/types/Row.d.cts +2 -2
- package/dist/types/Row.d.ts +2 -2
- package/dist/types/RowModel.d.cts +4 -4
- package/dist/types/RowModel.d.ts +4 -4
- package/dist/types/RowModelFns.d.cts +2 -2
- package/dist/types/RowModelFns.d.ts +2 -2
- package/dist/types/Table.d.cts +9 -9
- package/dist/types/Table.d.ts +9 -9
- package/dist/types/TableFeatures.d.cts +4 -4
- package/dist/types/TableFeatures.d.ts +4 -4
- package/dist/types/TableOptions.d.cts +7 -7
- package/dist/types/TableOptions.d.ts +7 -7
- package/dist/types/TableState.d.cts +6 -6
- package/dist/types/TableState.d.ts +6 -6
- package/dist/utils.cjs +23 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +23 -13
- package/dist/utils.js.map +1 -1
- package/dist/worker/createTableWorker.cjs +189 -0
- package/dist/worker/createTableWorker.cjs.map +1 -0
- package/dist/worker/createTableWorker.d.cts +102 -0
- package/dist/worker/createTableWorker.d.ts +102 -0
- package/dist/worker/createTableWorker.js +186 -0
- package/dist/worker/createTableWorker.js.map +1 -0
- package/dist/worker/createWorkerRowModel.cjs +78 -0
- package/dist/worker/createWorkerRowModel.cjs.map +1 -0
- package/dist/worker/createWorkerRowModel.d.cts +42 -0
- package/dist/worker/createWorkerRowModel.d.ts +42 -0
- package/dist/worker/createWorkerRowModel.js +78 -0
- package/dist/worker/createWorkerRowModel.js.map +1 -0
- package/dist/worker/initTableWorker.cjs +100 -0
- package/dist/worker/initTableWorker.cjs.map +1 -0
- package/dist/worker/initTableWorker.d.cts +33 -0
- package/dist/worker/initTableWorker.d.ts +33 -0
- package/dist/worker/initTableWorker.js +100 -0
- package/dist/worker/initTableWorker.js.map +1 -0
- package/dist/worker/rebuildRowModel.cjs +72 -0
- package/dist/worker/rebuildRowModel.cjs.map +1 -0
- package/dist/worker/rebuildRowModel.d.cts +9 -0
- package/dist/worker/rebuildRowModel.d.ts +9 -0
- package/dist/worker/rebuildRowModel.js +72 -0
- package/dist/worker/rebuildRowModel.js.map +1 -0
- package/dist/worker/serializeRowModel.cjs +53 -0
- package/dist/worker/serializeRowModel.cjs.map +1 -0
- package/dist/worker/serializeRowModel.js +52 -0
- package/dist/worker/serializeRowModel.js.map +1 -0
- package/dist/worker/tableWorkerProtocol.cjs +29 -0
- package/dist/worker/tableWorkerProtocol.cjs.map +1 -0
- package/dist/worker/tableWorkerProtocol.d.cts +88 -0
- package/dist/worker/tableWorkerProtocol.d.ts +88 -0
- package/dist/worker/tableWorkerProtocol.js +27 -0
- package/dist/worker/tableWorkerProtocol.js.map +1 -0
- package/package.json +6 -2
- package/src/core/rows/coreRowsFeature.ts +1 -0
- package/src/experimental-worker-plugin.ts +22 -0
- package/src/features/row-selection/rowSelectionFeature.utils.ts +2 -1
- package/src/features/row-sorting/createSortedRowModel.ts +31 -10
- package/src/features/row-sorting/rowSortingFeature.utils.ts +2 -10
- package/src/utils.ts +21 -0
- package/src/worker/createTableWorker.ts +357 -0
- package/src/worker/createWorkerRowModel.ts +121 -0
- package/src/worker/initTableWorker.ts +164 -0
- package/src/worker/rebuildRowModel.ts +117 -0
- package/src/worker/serializeRowModel.ts +80 -0
- package/src/worker/tableWorkerProtocol.ts +105 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebuildRowModel.cjs","names":["constructRow","hasOwn"],"sources":["../../src/worker/rebuildRowModel.ts"],"sourcesContent":["import { constructRow } from '../core/rows/constructRow'\nimport { hasOwn } from '../utils'\nimport type { RowModel } from '../core/row-models/coreRowModelsFeature.types'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRowNode,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\n/** Payloads that carry data; `unchanged` never reaches the rebuilder. */\nexport type TableWorkerDataPayload = Exclude<\n TableWorkerStagePayload,\n { kind: 'unchanged' }\n>\n\ntype AnyTable = Table_Internal<any, any>\n\n// Main-thread side: payload + this table's core rows -> RowModel. Mirrors how\n// the sync row models treat rows: data rows are reused (with depth/parentId\n// rewritten, exactly like createGroupedRowModel does), synthetic group rows\n// are reconstructed via constructRow with their worker-computed aggregates\n// pre-seeded so no aggregation ever runs on the main thread.\n\nfunction collectLeafRows(subRows: Array<any>, out: Array<any>) {\n for (let i = 0; i < subRows.length; i++) {\n const row = subRows[i]\n if (row.groupingColumnId == null) {\n out.push(row)\n } else {\n collectLeafRows(row.subRows, out)\n }\n }\n}\n\nexport function rebuildRowModel(\n table: AnyTable,\n payload: TableWorkerDataPayload,\n /**\n * Whether a flat payload should rewrite row depth/parentId. Mirrors core:\n * the grouped model's passthrough resets them, the filtered model never\n * touches them. Without this distinction a filtered rebuild could zero the\n * depths a grouped/sorted tree rebuild just assigned to shared row objects.\n */\n resetDepths: boolean,\n): RowModel<any, any> {\n const core = table.getCoreRowModel()\n\n if (payload.kind === 'flat') {\n const { indices } = payload\n const rows = new Array(indices.length)\n for (let i = 0; i < indices.length; i++) {\n const row: any = core.flatRows[indices[i]!]!\n if (resetDepths) {\n row.depth = 0\n row.parentId = undefined\n }\n rows[i] = row\n }\n return { rows, flatRows: rows, rowsById: core.rowsById }\n }\n\n const flatRows: Array<any> = []\n // Data rows resolve through the prototype chain to the core map; only\n // synthetic group rows are added on top.\n const rowsById: Record<string, any> = Object.create(core.rowsById)\n\n const rebuildRows = (\n nodes: Array<TableWorkerRowNode>,\n depth: number,\n parentId: string | undefined,\n ): Array<any> => {\n const rows = new Array(nodes.length)\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]!\n if (typeof node === 'number') {\n const row: any = core.flatRows[node]!\n row.depth = depth\n row.parentId = parentId\n flatRows.push(row)\n rows[i] = row\n continue\n }\n\n const subRows = rebuildRows(node.children, depth + 1, node.id)\n const leafRows: Array<any> = []\n collectLeafRows(subRows, leafRows)\n\n const row: any = constructRow(\n table,\n node.id,\n leafRows[0]?.original,\n node.index,\n depth,\n undefined,\n parentId,\n )\n const aggregates = node.aggregates\n Object.assign(row, {\n groupingColumnId: node.groupingColumnId,\n groupingValue: node.groupingValue,\n subRows,\n leafRows,\n getValue: (columnId: string) =>\n hasOwn(aggregates, columnId) ? aggregates[columnId] : undefined,\n })\n\n flatRows.push(row)\n rowsById[node.id] = row\n rows[i] = row\n }\n return rows\n }\n\n const rows = rebuildRows(payload.children, 0, undefined)\n\n return { rows, flatRows, rowsById }\n}\n"],"mappings":";;;;AAuBA,SAAS,gBAAgB,SAAqB,KAAiB;CAC7D,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACvC,MAAM,MAAM,QAAQ;EACpB,IAAI,IAAI,oBAAoB,MAC1B,IAAI,KAAK,GAAG;OAEZ,gBAAgB,IAAI,SAAS,GAAG;CAEpC;AACF;AAEA,SAAgB,gBACd,OACA,SAOA,aACoB;CACpB,MAAM,OAAO,MAAM,gBAAgB;CAEnC,IAAI,QAAQ,SAAS,QAAQ;EAC3B,MAAM,EAAE,YAAY;EACpB,MAAM,OAAO,IAAI,MAAM,QAAQ,MAAM;EACrC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,MAAW,KAAK,SAAS,QAAQ;GACvC,IAAI,aAAa;IACf,IAAI,QAAQ;IACZ,IAAI,WAAW;GACjB;GACA,KAAK,KAAK;EACZ;EACA,OAAO;GAAE;GAAM,UAAU;GAAM,UAAU,KAAK;EAAS;CACzD;CAEA,MAAM,WAAuB,CAAC;CAG9B,MAAM,WAAgC,OAAO,OAAO,KAAK,QAAQ;CAEjE,MAAM,eACJ,OACA,OACA,aACe;EACf,MAAM,OAAO,IAAI,MAAM,MAAM,MAAM;EACnC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;GACrC,MAAM,OAAO,MAAM;GACnB,IAAI,OAAO,SAAS,UAAU;IAC5B,MAAM,MAAW,KAAK,SAAS;IAC/B,IAAI,QAAQ;IACZ,IAAI,WAAW;IACf,SAAS,KAAK,GAAG;IACjB,KAAK,KAAK;IACV;GACF;GAEA,MAAM,UAAU,YAAY,KAAK,UAAU,QAAQ,GAAG,KAAK,EAAE;GAC7D,MAAM,WAAuB,CAAC;GAC9B,gBAAgB,SAAS,QAAQ;GAEjC,MAAM,MAAWA,kCACf,OACA,KAAK,IACL,SAAS,EAAE,EAAE,UACb,KAAK,OACL,OACA,QACA,QACF;GACA,MAAM,aAAa,KAAK;GACxB,OAAO,OAAO,KAAK;IACjB,kBAAkB,KAAK;IACvB,eAAe,KAAK;IACpB;IACA;IACA,WAAW,aACTC,qBAAO,YAAY,QAAQ,IAAI,WAAW,YAAY;GAC1D,CAAC;GAED,SAAS,KAAK,GAAG;GACjB,SAAS,KAAK,MAAM;GACpB,KAAK,KAAK;EACZ;EACA,OAAO;CACT;CAIA,OAAO;EAAE,MAFI,YAAY,QAAQ,UAAU,GAAG,MAElC;EAAG;EAAU;CAAS;AACpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TableWorkerStagePayload } from "./tableWorkerProtocol.cjs";
|
|
2
|
+
//#region src/worker/rebuildRowModel.d.ts
|
|
3
|
+
/** Payloads that carry data; `unchanged` never reaches the rebuilder. */
|
|
4
|
+
type TableWorkerDataPayload = Exclude<TableWorkerStagePayload, {
|
|
5
|
+
kind: 'unchanged';
|
|
6
|
+
}>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { TableWorkerDataPayload };
|
|
9
|
+
//# sourceMappingURL=rebuildRowModel.d.cts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TableWorkerStagePayload } from "./tableWorkerProtocol.js";
|
|
2
|
+
//#region src/worker/rebuildRowModel.d.ts
|
|
3
|
+
/** Payloads that carry data; `unchanged` never reaches the rebuilder. */
|
|
4
|
+
type TableWorkerDataPayload = Exclude<TableWorkerStagePayload, {
|
|
5
|
+
kind: 'unchanged';
|
|
6
|
+
}>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { TableWorkerDataPayload };
|
|
9
|
+
//# sourceMappingURL=rebuildRowModel.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { hasOwn } from "../utils.js";
|
|
2
|
+
import { constructRow } from "../core/rows/constructRow.js";
|
|
3
|
+
|
|
4
|
+
//#region src/worker/rebuildRowModel.ts
|
|
5
|
+
function collectLeafRows(subRows, out) {
|
|
6
|
+
for (let i = 0; i < subRows.length; i++) {
|
|
7
|
+
const row = subRows[i];
|
|
8
|
+
if (row.groupingColumnId == null) out.push(row);
|
|
9
|
+
else collectLeafRows(row.subRows, out);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function rebuildRowModel(table, payload, resetDepths) {
|
|
13
|
+
const core = table.getCoreRowModel();
|
|
14
|
+
if (payload.kind === "flat") {
|
|
15
|
+
const { indices } = payload;
|
|
16
|
+
const rows = new Array(indices.length);
|
|
17
|
+
for (let i = 0; i < indices.length; i++) {
|
|
18
|
+
const row = core.flatRows[indices[i]];
|
|
19
|
+
if (resetDepths) {
|
|
20
|
+
row.depth = 0;
|
|
21
|
+
row.parentId = void 0;
|
|
22
|
+
}
|
|
23
|
+
rows[i] = row;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
rows,
|
|
27
|
+
flatRows: rows,
|
|
28
|
+
rowsById: core.rowsById
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const flatRows = [];
|
|
32
|
+
const rowsById = Object.create(core.rowsById);
|
|
33
|
+
const rebuildRows = (nodes, depth, parentId) => {
|
|
34
|
+
const rows = new Array(nodes.length);
|
|
35
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
36
|
+
const node = nodes[i];
|
|
37
|
+
if (typeof node === "number") {
|
|
38
|
+
const row = core.flatRows[node];
|
|
39
|
+
row.depth = depth;
|
|
40
|
+
row.parentId = parentId;
|
|
41
|
+
flatRows.push(row);
|
|
42
|
+
rows[i] = row;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const subRows = rebuildRows(node.children, depth + 1, node.id);
|
|
46
|
+
const leafRows = [];
|
|
47
|
+
collectLeafRows(subRows, leafRows);
|
|
48
|
+
const row = constructRow(table, node.id, leafRows[0]?.original, node.index, depth, void 0, parentId);
|
|
49
|
+
const aggregates = node.aggregates;
|
|
50
|
+
Object.assign(row, {
|
|
51
|
+
groupingColumnId: node.groupingColumnId,
|
|
52
|
+
groupingValue: node.groupingValue,
|
|
53
|
+
subRows,
|
|
54
|
+
leafRows,
|
|
55
|
+
getValue: (columnId) => hasOwn(aggregates, columnId) ? aggregates[columnId] : void 0
|
|
56
|
+
});
|
|
57
|
+
flatRows.push(row);
|
|
58
|
+
rowsById[node.id] = row;
|
|
59
|
+
rows[i] = row;
|
|
60
|
+
}
|
|
61
|
+
return rows;
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
rows: rebuildRows(payload.children, 0, void 0),
|
|
65
|
+
flatRows,
|
|
66
|
+
rowsById
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { rebuildRowModel };
|
|
72
|
+
//# sourceMappingURL=rebuildRowModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebuildRowModel.js","names":[],"sources":["../../src/worker/rebuildRowModel.ts"],"sourcesContent":["import { constructRow } from '../core/rows/constructRow'\nimport { hasOwn } from '../utils'\nimport type { RowModel } from '../core/row-models/coreRowModelsFeature.types'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRowNode,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\n/** Payloads that carry data; `unchanged` never reaches the rebuilder. */\nexport type TableWorkerDataPayload = Exclude<\n TableWorkerStagePayload,\n { kind: 'unchanged' }\n>\n\ntype AnyTable = Table_Internal<any, any>\n\n// Main-thread side: payload + this table's core rows -> RowModel. Mirrors how\n// the sync row models treat rows: data rows are reused (with depth/parentId\n// rewritten, exactly like createGroupedRowModel does), synthetic group rows\n// are reconstructed via constructRow with their worker-computed aggregates\n// pre-seeded so no aggregation ever runs on the main thread.\n\nfunction collectLeafRows(subRows: Array<any>, out: Array<any>) {\n for (let i = 0; i < subRows.length; i++) {\n const row = subRows[i]\n if (row.groupingColumnId == null) {\n out.push(row)\n } else {\n collectLeafRows(row.subRows, out)\n }\n }\n}\n\nexport function rebuildRowModel(\n table: AnyTable,\n payload: TableWorkerDataPayload,\n /**\n * Whether a flat payload should rewrite row depth/parentId. Mirrors core:\n * the grouped model's passthrough resets them, the filtered model never\n * touches them. Without this distinction a filtered rebuild could zero the\n * depths a grouped/sorted tree rebuild just assigned to shared row objects.\n */\n resetDepths: boolean,\n): RowModel<any, any> {\n const core = table.getCoreRowModel()\n\n if (payload.kind === 'flat') {\n const { indices } = payload\n const rows = new Array(indices.length)\n for (let i = 0; i < indices.length; i++) {\n const row: any = core.flatRows[indices[i]!]!\n if (resetDepths) {\n row.depth = 0\n row.parentId = undefined\n }\n rows[i] = row\n }\n return { rows, flatRows: rows, rowsById: core.rowsById }\n }\n\n const flatRows: Array<any> = []\n // Data rows resolve through the prototype chain to the core map; only\n // synthetic group rows are added on top.\n const rowsById: Record<string, any> = Object.create(core.rowsById)\n\n const rebuildRows = (\n nodes: Array<TableWorkerRowNode>,\n depth: number,\n parentId: string | undefined,\n ): Array<any> => {\n const rows = new Array(nodes.length)\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]!\n if (typeof node === 'number') {\n const row: any = core.flatRows[node]!\n row.depth = depth\n row.parentId = parentId\n flatRows.push(row)\n rows[i] = row\n continue\n }\n\n const subRows = rebuildRows(node.children, depth + 1, node.id)\n const leafRows: Array<any> = []\n collectLeafRows(subRows, leafRows)\n\n const row: any = constructRow(\n table,\n node.id,\n leafRows[0]?.original,\n node.index,\n depth,\n undefined,\n parentId,\n )\n const aggregates = node.aggregates\n Object.assign(row, {\n groupingColumnId: node.groupingColumnId,\n groupingValue: node.groupingValue,\n subRows,\n leafRows,\n getValue: (columnId: string) =>\n hasOwn(aggregates, columnId) ? aggregates[columnId] : undefined,\n })\n\n flatRows.push(row)\n rowsById[node.id] = row\n rows[i] = row\n }\n return rows\n }\n\n const rows = rebuildRows(payload.children, 0, undefined)\n\n return { rows, flatRows, rowsById }\n}\n"],"mappings":";;;;AAuBA,SAAS,gBAAgB,SAAqB,KAAiB;CAC7D,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;EACvC,MAAM,MAAM,QAAQ;EACpB,IAAI,IAAI,oBAAoB,MAC1B,IAAI,KAAK,GAAG;OAEZ,gBAAgB,IAAI,SAAS,GAAG;CAEpC;AACF;AAEA,SAAgB,gBACd,OACA,SAOA,aACoB;CACpB,MAAM,OAAO,MAAM,gBAAgB;CAEnC,IAAI,QAAQ,SAAS,QAAQ;EAC3B,MAAM,EAAE,YAAY;EACpB,MAAM,OAAO,IAAI,MAAM,QAAQ,MAAM;EACrC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,MAAW,KAAK,SAAS,QAAQ;GACvC,IAAI,aAAa;IACf,IAAI,QAAQ;IACZ,IAAI,WAAW;GACjB;GACA,KAAK,KAAK;EACZ;EACA,OAAO;GAAE;GAAM,UAAU;GAAM,UAAU,KAAK;EAAS;CACzD;CAEA,MAAM,WAAuB,CAAC;CAG9B,MAAM,WAAgC,OAAO,OAAO,KAAK,QAAQ;CAEjE,MAAM,eACJ,OACA,OACA,aACe;EACf,MAAM,OAAO,IAAI,MAAM,MAAM,MAAM;EACnC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;GACrC,MAAM,OAAO,MAAM;GACnB,IAAI,OAAO,SAAS,UAAU;IAC5B,MAAM,MAAW,KAAK,SAAS;IAC/B,IAAI,QAAQ;IACZ,IAAI,WAAW;IACf,SAAS,KAAK,GAAG;IACjB,KAAK,KAAK;IACV;GACF;GAEA,MAAM,UAAU,YAAY,KAAK,UAAU,QAAQ,GAAG,KAAK,EAAE;GAC7D,MAAM,WAAuB,CAAC;GAC9B,gBAAgB,SAAS,QAAQ;GAEjC,MAAM,MAAW,aACf,OACA,KAAK,IACL,SAAS,EAAE,EAAE,UACb,KAAK,OACL,OACA,QACA,QACF;GACA,MAAM,aAAa,KAAK;GACxB,OAAO,OAAO,KAAK;IACjB,kBAAkB,KAAK;IACvB,eAAe,KAAK;IACpB;IACA;IACA,WAAW,aACT,OAAO,YAAY,QAAQ,IAAI,WAAW,YAAY;GAC1D,CAAC;GAED,SAAS,KAAK,GAAG;GACjB,SAAS,KAAK,MAAM;GACpB,KAAK,KAAK;EACZ;EACA,OAAO;CACT;CAIA,OAAO;EAAE,MAFI,YAAY,QAAQ,UAAU,GAAG,MAElC;EAAG;EAAU;CAAS;AACpC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/worker/serializeRowModel.ts
|
|
3
|
+
function isCloneSafe(value) {
|
|
4
|
+
return typeof value !== "function" && typeof value !== "symbol";
|
|
5
|
+
}
|
|
6
|
+
function serializeRows(rows, coreIndexById, aggregateColumnIds) {
|
|
7
|
+
const nodes = new Array(rows.length);
|
|
8
|
+
for (let i = 0; i < rows.length; i++) {
|
|
9
|
+
const row = rows[i];
|
|
10
|
+
if (row.groupingColumnId == null) {
|
|
11
|
+
nodes[i] = coreIndexById[row.id];
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const aggregates = {};
|
|
15
|
+
for (let c = 0; c < aggregateColumnIds.length; c++) {
|
|
16
|
+
const columnId = aggregateColumnIds[c];
|
|
17
|
+
const value = row.getValue(columnId);
|
|
18
|
+
if (value !== void 0 && isCloneSafe(value)) aggregates[columnId] = value;
|
|
19
|
+
}
|
|
20
|
+
if (!(row.groupingColumnId in aggregates)) {
|
|
21
|
+
const value = row.getValue(row.groupingColumnId);
|
|
22
|
+
if (value !== void 0 && isCloneSafe(value)) aggregates[row.groupingColumnId] = value;
|
|
23
|
+
}
|
|
24
|
+
nodes[i] = {
|
|
25
|
+
id: row.id,
|
|
26
|
+
groupingColumnId: row.groupingColumnId,
|
|
27
|
+
groupingValue: row.groupingValue,
|
|
28
|
+
index: row.index,
|
|
29
|
+
aggregates,
|
|
30
|
+
children: serializeRows(row.subRows, coreIndexById, aggregateColumnIds)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return nodes;
|
|
34
|
+
}
|
|
35
|
+
function serializeRowModel(model, coreIndexById, aggregateColumnIds, transfer) {
|
|
36
|
+
if (model.flatRows.length === model.rows.length) {
|
|
37
|
+
const indices = new Uint32Array(model.rows.length);
|
|
38
|
+
for (let i = 0; i < indices.length; i++) indices[i] = coreIndexById[model.rows[i].id];
|
|
39
|
+
transfer.push(indices.buffer);
|
|
40
|
+
return {
|
|
41
|
+
kind: "flat",
|
|
42
|
+
indices
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
kind: "tree",
|
|
47
|
+
children: serializeRows(model.rows, coreIndexById, aggregateColumnIds)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.serializeRowModel = serializeRowModel;
|
|
53
|
+
//# sourceMappingURL=serializeRowModel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeRowModel.cjs","names":[],"sources":["../../src/worker/serializeRowModel.ts"],"sourcesContent":["import type { RowModel } from '../core/row-models/coreRowModelsFeature.types'\nimport type {\n TableWorkerRowNode,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\n// Worker-side: RowModel -> transferable payload. Stage-agnostic; the payload\n// kind is chosen from the model's shape (synthetic rows present or not).\n\nfunction isCloneSafe(value: unknown): boolean {\n return typeof value !== 'function' && typeof value !== 'symbol'\n}\n\nfunction serializeRows(\n rows: Array<any>,\n coreIndexById: Record<string, number>,\n aggregateColumnIds: Array<string>,\n): Array<TableWorkerRowNode> {\n const nodes = new Array<TableWorkerRowNode>(rows.length)\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i]\n if (row.groupingColumnId == null) {\n // Data row: its position in `options.data` is all the main thread needs.\n nodes[i] = coreIndexById[row.id]!\n continue\n }\n // Synthetic group row: compute aggregates eagerly (the expensive per-group\n // work we want off the main thread), but only for columns with an explicit\n // aggregation; sync tables aggregate lazily, so eagerly auto-aggregating\n // every column would explode on high-cardinality grouping.\n const aggregates: Record<string, unknown> = {}\n for (let c = 0; c < aggregateColumnIds.length; c++) {\n const columnId = aggregateColumnIds[c]!\n const value = row.getValue(columnId)\n if (value !== undefined && isCloneSafe(value)) {\n aggregates[columnId] = value\n }\n }\n // The group's own column always serializes its display value (the first\n // leaf's value) so grouped cells render.\n if (!(row.groupingColumnId in aggregates)) {\n const value = row.getValue(row.groupingColumnId)\n if (value !== undefined && isCloneSafe(value)) {\n aggregates[row.groupingColumnId] = value\n }\n }\n nodes[i] = {\n id: row.id,\n groupingColumnId: row.groupingColumnId,\n groupingValue: row.groupingValue,\n index: row.index,\n aggregates,\n children: serializeRows(row.subRows, coreIndexById, aggregateColumnIds),\n }\n }\n return nodes\n}\n\nexport function serializeRowModel(\n model: RowModel<any, any>,\n coreIndexById: Record<string, number>,\n aggregateColumnIds: Array<string>,\n transfer: Array<Transferable>,\n): TableWorkerStagePayload {\n // Flat fast path: no synthetic rows anywhere (flatRows === rows for flat\n // data). A Uint32Array permutation transfers at zero-copy cost.\n if (model.flatRows.length === model.rows.length) {\n const indices = new Uint32Array(model.rows.length)\n for (let i = 0; i < indices.length; i++) {\n indices[i] = coreIndexById[model.rows[i]!.id]!\n }\n transfer.push(indices.buffer)\n return { kind: 'flat', indices }\n }\n\n return {\n kind: 'tree',\n children: serializeRows(model.rows, coreIndexById, aggregateColumnIds),\n }\n}\n"],"mappings":";;AASA,SAAS,YAAY,OAAyB;CAC5C,OAAO,OAAO,UAAU,cAAc,OAAO,UAAU;AACzD;AAEA,SAAS,cACP,MACA,eACA,oBAC2B;CAC3B,MAAM,QAAQ,IAAI,MAA0B,KAAK,MAAM;CACvD,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,IAAI,IAAI,oBAAoB,MAAM;GAEhC,MAAM,KAAK,cAAc,IAAI;GAC7B;EACF;EAKA,MAAM,aAAsC,CAAC;EAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,QAAQ,KAAK;GAClD,MAAM,WAAW,mBAAmB;GACpC,MAAM,QAAQ,IAAI,SAAS,QAAQ;GACnC,IAAI,UAAU,UAAa,YAAY,KAAK,GAC1C,WAAW,YAAY;EAE3B;EAGA,IAAI,EAAE,IAAI,oBAAoB,aAAa;GACzC,MAAM,QAAQ,IAAI,SAAS,IAAI,gBAAgB;GAC/C,IAAI,UAAU,UAAa,YAAY,KAAK,GAC1C,WAAW,IAAI,oBAAoB;EAEvC;EACA,MAAM,KAAK;GACT,IAAI,IAAI;GACR,kBAAkB,IAAI;GACtB,eAAe,IAAI;GACnB,OAAO,IAAI;GACX;GACA,UAAU,cAAc,IAAI,SAAS,eAAe,kBAAkB;EACxE;CACF;CACA,OAAO;AACT;AAEA,SAAgB,kBACd,OACA,eACA,oBACA,UACyB;CAGzB,IAAI,MAAM,SAAS,WAAW,MAAM,KAAK,QAAQ;EAC/C,MAAM,UAAU,IAAI,YAAY,MAAM,KAAK,MAAM;EACjD,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,QAAQ,KAAK,cAAc,MAAM,KAAK,EAAE,CAAE;EAE5C,SAAS,KAAK,QAAQ,MAAM;EAC5B,OAAO;GAAE,MAAM;GAAQ;EAAQ;CACjC;CAEA,OAAO;EACL,MAAM;EACN,UAAU,cAAc,MAAM,MAAM,eAAe,kBAAkB;CACvE;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/worker/serializeRowModel.ts
|
|
2
|
+
function isCloneSafe(value) {
|
|
3
|
+
return typeof value !== "function" && typeof value !== "symbol";
|
|
4
|
+
}
|
|
5
|
+
function serializeRows(rows, coreIndexById, aggregateColumnIds) {
|
|
6
|
+
const nodes = new Array(rows.length);
|
|
7
|
+
for (let i = 0; i < rows.length; i++) {
|
|
8
|
+
const row = rows[i];
|
|
9
|
+
if (row.groupingColumnId == null) {
|
|
10
|
+
nodes[i] = coreIndexById[row.id];
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const aggregates = {};
|
|
14
|
+
for (let c = 0; c < aggregateColumnIds.length; c++) {
|
|
15
|
+
const columnId = aggregateColumnIds[c];
|
|
16
|
+
const value = row.getValue(columnId);
|
|
17
|
+
if (value !== void 0 && isCloneSafe(value)) aggregates[columnId] = value;
|
|
18
|
+
}
|
|
19
|
+
if (!(row.groupingColumnId in aggregates)) {
|
|
20
|
+
const value = row.getValue(row.groupingColumnId);
|
|
21
|
+
if (value !== void 0 && isCloneSafe(value)) aggregates[row.groupingColumnId] = value;
|
|
22
|
+
}
|
|
23
|
+
nodes[i] = {
|
|
24
|
+
id: row.id,
|
|
25
|
+
groupingColumnId: row.groupingColumnId,
|
|
26
|
+
groupingValue: row.groupingValue,
|
|
27
|
+
index: row.index,
|
|
28
|
+
aggregates,
|
|
29
|
+
children: serializeRows(row.subRows, coreIndexById, aggregateColumnIds)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return nodes;
|
|
33
|
+
}
|
|
34
|
+
function serializeRowModel(model, coreIndexById, aggregateColumnIds, transfer) {
|
|
35
|
+
if (model.flatRows.length === model.rows.length) {
|
|
36
|
+
const indices = new Uint32Array(model.rows.length);
|
|
37
|
+
for (let i = 0; i < indices.length; i++) indices[i] = coreIndexById[model.rows[i].id];
|
|
38
|
+
transfer.push(indices.buffer);
|
|
39
|
+
return {
|
|
40
|
+
kind: "flat",
|
|
41
|
+
indices
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
kind: "tree",
|
|
46
|
+
children: serializeRows(model.rows, coreIndexById, aggregateColumnIds)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { serializeRowModel };
|
|
52
|
+
//# sourceMappingURL=serializeRowModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeRowModel.js","names":[],"sources":["../../src/worker/serializeRowModel.ts"],"sourcesContent":["import type { RowModel } from '../core/row-models/coreRowModelsFeature.types'\nimport type {\n TableWorkerRowNode,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\n// Worker-side: RowModel -> transferable payload. Stage-agnostic; the payload\n// kind is chosen from the model's shape (synthetic rows present or not).\n\nfunction isCloneSafe(value: unknown): boolean {\n return typeof value !== 'function' && typeof value !== 'symbol'\n}\n\nfunction serializeRows(\n rows: Array<any>,\n coreIndexById: Record<string, number>,\n aggregateColumnIds: Array<string>,\n): Array<TableWorkerRowNode> {\n const nodes = new Array<TableWorkerRowNode>(rows.length)\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i]\n if (row.groupingColumnId == null) {\n // Data row: its position in `options.data` is all the main thread needs.\n nodes[i] = coreIndexById[row.id]!\n continue\n }\n // Synthetic group row: compute aggregates eagerly (the expensive per-group\n // work we want off the main thread), but only for columns with an explicit\n // aggregation; sync tables aggregate lazily, so eagerly auto-aggregating\n // every column would explode on high-cardinality grouping.\n const aggregates: Record<string, unknown> = {}\n for (let c = 0; c < aggregateColumnIds.length; c++) {\n const columnId = aggregateColumnIds[c]!\n const value = row.getValue(columnId)\n if (value !== undefined && isCloneSafe(value)) {\n aggregates[columnId] = value\n }\n }\n // The group's own column always serializes its display value (the first\n // leaf's value) so grouped cells render.\n if (!(row.groupingColumnId in aggregates)) {\n const value = row.getValue(row.groupingColumnId)\n if (value !== undefined && isCloneSafe(value)) {\n aggregates[row.groupingColumnId] = value\n }\n }\n nodes[i] = {\n id: row.id,\n groupingColumnId: row.groupingColumnId,\n groupingValue: row.groupingValue,\n index: row.index,\n aggregates,\n children: serializeRows(row.subRows, coreIndexById, aggregateColumnIds),\n }\n }\n return nodes\n}\n\nexport function serializeRowModel(\n model: RowModel<any, any>,\n coreIndexById: Record<string, number>,\n aggregateColumnIds: Array<string>,\n transfer: Array<Transferable>,\n): TableWorkerStagePayload {\n // Flat fast path: no synthetic rows anywhere (flatRows === rows for flat\n // data). A Uint32Array permutation transfers at zero-copy cost.\n if (model.flatRows.length === model.rows.length) {\n const indices = new Uint32Array(model.rows.length)\n for (let i = 0; i < indices.length; i++) {\n indices[i] = coreIndexById[model.rows[i]!.id]!\n }\n transfer.push(indices.buffer)\n return { kind: 'flat', indices }\n }\n\n return {\n kind: 'tree',\n children: serializeRows(model.rows, coreIndexById, aggregateColumnIds),\n }\n}\n"],"mappings":";AASA,SAAS,YAAY,OAAyB;CAC5C,OAAO,OAAO,UAAU,cAAc,OAAO,UAAU;AACzD;AAEA,SAAS,cACP,MACA,eACA,oBAC2B;CAC3B,MAAM,QAAQ,IAAI,MAA0B,KAAK,MAAM;CACvD,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,IAAI,IAAI,oBAAoB,MAAM;GAEhC,MAAM,KAAK,cAAc,IAAI;GAC7B;EACF;EAKA,MAAM,aAAsC,CAAC;EAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,QAAQ,KAAK;GAClD,MAAM,WAAW,mBAAmB;GACpC,MAAM,QAAQ,IAAI,SAAS,QAAQ;GACnC,IAAI,UAAU,UAAa,YAAY,KAAK,GAC1C,WAAW,YAAY;EAE3B;EAGA,IAAI,EAAE,IAAI,oBAAoB,aAAa;GACzC,MAAM,QAAQ,IAAI,SAAS,IAAI,gBAAgB;GAC/C,IAAI,UAAU,UAAa,YAAY,KAAK,GAC1C,WAAW,IAAI,oBAAoB;EAEvC;EACA,MAAM,KAAK;GACT,IAAI,IAAI;GACR,kBAAkB,IAAI;GACtB,eAAe,IAAI;GACnB,OAAO,IAAI;GACX;GACA,UAAU,cAAc,IAAI,SAAS,eAAe,kBAAkB;EACxE;CACF;CACA,OAAO;AACT;AAEA,SAAgB,kBACd,OACA,eACA,oBACA,UACyB;CAGzB,IAAI,MAAM,SAAS,WAAW,MAAM,KAAK,QAAQ;EAC/C,MAAM,UAAU,IAAI,YAAY,MAAM,KAAK,MAAM;EACjD,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,QAAQ,KAAK,cAAc,MAAM,KAAK,EAAE,CAAE;EAE5C,SAAS,KAAK,QAAQ,MAAM;EAC5B,OAAO;GAAE,MAAM;GAAQ;EAAQ;CACjC;CAEA,OAAO;EACL,MAAM;EACN,UAAU,cAAc,MAAM,MAAM,eAAe,kBAAkB;CACvE;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/worker/tableWorkerProtocol.ts
|
|
3
|
+
/**
|
|
4
|
+
* Row model stages that can be offloaded to the worker, in pipeline order.
|
|
5
|
+
* Everything else in this module is derived from this list; adding a stage
|
|
6
|
+
* means adding an entry here and to `tableWorkerStageStateDeps`.
|
|
7
|
+
*/
|
|
8
|
+
const tableWorkerPipeline = [
|
|
9
|
+
"filtered",
|
|
10
|
+
"grouped",
|
|
11
|
+
"sorted",
|
|
12
|
+
"expanded"
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* The state slices each stage's computation depends on. The main thread sends
|
|
16
|
+
* the union of deps for its registered stages; a change to any of them
|
|
17
|
+
* triggers one worker round trip.
|
|
18
|
+
*/
|
|
19
|
+
const tableWorkerStageStateDeps = {
|
|
20
|
+
filtered: ["columnFilters", "globalFilter"],
|
|
21
|
+
grouped: ["grouping"],
|
|
22
|
+
sorted: ["sorting"],
|
|
23
|
+
expanded: ["expanded"]
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.tableWorkerPipeline = tableWorkerPipeline;
|
|
28
|
+
exports.tableWorkerStageStateDeps = tableWorkerStageStateDeps;
|
|
29
|
+
//# sourceMappingURL=tableWorkerProtocol.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableWorkerProtocol.cjs","names":[],"sources":["../../src/worker/tableWorkerProtocol.ts"],"sourcesContent":["import type { RowData } from '../types/type-utils'\n\n/**\n * Row model stages that can be offloaded to the worker, in pipeline order.\n * Everything else in this module is derived from this list; adding a stage\n * means adding an entry here and to `tableWorkerStageStateDeps`.\n */\nexport const tableWorkerPipeline = [\n 'filtered',\n 'grouped',\n 'sorted',\n 'expanded',\n] as const\n\nexport type TableWorkerStage = (typeof tableWorkerPipeline)[number]\n\n/**\n * The state slices each stage's computation depends on. The main thread sends\n * the union of deps for its registered stages; a change to any of them\n * triggers one worker round trip.\n */\nexport const tableWorkerStageStateDeps: Record<\n TableWorkerStage,\n Array<string>\n> = {\n filtered: ['columnFilters', 'globalFilter'],\n grouped: ['grouping'],\n sorted: ['sorting'],\n expanded: ['expanded'],\n}\n\n/**\n * A serialized synthetic (group) row. Leaf rows serialize as their position in\n * `options.data`; group rows carry what `constructRow` + the grouped row model\n * need to rebuild them, plus eagerly computed aggregate values so no\n * aggregation runs on the main thread.\n */\nexport interface TableWorkerGroupNode {\n id: string\n groupingColumnId: string\n groupingValue: unknown\n index: number\n aggregates: Record<string, unknown>\n children: Array<TableWorkerRowNode>\n}\n\nexport type TableWorkerRowNode = number | TableWorkerGroupNode\n\n/**\n * A stage result. Flat models (every row is a data row) travel as a\n * transferable index permutation; models containing synthetic rows (grouping)\n * travel as a tree. The kind is chosen from the model's actual shape at\n * runtime, not from the stage name: a sorted model is flat without grouping\n * and a tree with it.\n *\n * `unchanged` means the stage's model is identical to the last one sent for\n * this dataset (its memoized inputs did not change); the main thread keeps\n * its previous result and skips the rebuild entirely.\n */\nexport type TableWorkerStagePayload =\n | { kind: 'flat'; indices: Uint32Array }\n | { kind: 'tree'; children: Array<TableWorkerRowNode> }\n | { kind: 'unchanged' }\n\nexport type TableWorkerRequest<TData extends RowData = any> =\n | {\n type: 'data'\n dataVersion: number\n data: Array<TData>\n }\n | {\n type: 'process'\n requestId: number\n dataVersion: number\n /** The stages the main thread has worker-backed row models for. */\n stages: Array<TableWorkerStage>\n /** Serializable state slices (union of the stages' deps). */\n state: Record<string, unknown>\n }\n\nexport interface TableWorkerResult {\n type: 'result'\n requestId: number\n dataVersion: number\n stages: { [K in TableWorkerStage]?: TableWorkerStagePayload }\n computeMs: number\n}\n\nexport type TableWorkerResponse = TableWorkerResult\n\n/**\n * The state slice added by `workerRowModelsFeature`. `version` bumps when a\n * worker result lands (driving re-renders through the normal state path);\n * `isPending` is true while a request is in flight. The timing fields expose\n * the last result's worker compute time and full round trip for devtools and\n * debugging.\n */\nexport interface TableState_WorkerRowModels {\n workerRowModels: {\n version: number\n isPending: boolean\n lastComputeMs?: number\n lastRoundTripMs?: number\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;AACF;;;;;;AASA,MAAa,4BAGT;CACF,UAAU,CAAC,iBAAiB,cAAc;CAC1C,SAAS,CAAC,UAAU;CACpB,QAAQ,CAAC,SAAS;CAClB,UAAU,CAAC,UAAU;AACvB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { RowData } from "../types/type-utils.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/worker/tableWorkerProtocol.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Row model stages that can be offloaded to the worker, in pipeline order.
|
|
6
|
+
* Everything else in this module is derived from this list; adding a stage
|
|
7
|
+
* means adding an entry here and to `tableWorkerStageStateDeps`.
|
|
8
|
+
*/
|
|
9
|
+
declare const tableWorkerPipeline: readonly ["filtered", "grouped", "sorted", "expanded"];
|
|
10
|
+
type TableWorkerStage = (typeof tableWorkerPipeline)[number];
|
|
11
|
+
/**
|
|
12
|
+
* The state slices each stage's computation depends on. The main thread sends
|
|
13
|
+
* the union of deps for its registered stages; a change to any of them
|
|
14
|
+
* triggers one worker round trip.
|
|
15
|
+
*/
|
|
16
|
+
declare const tableWorkerStageStateDeps: Record<TableWorkerStage, Array<string>>;
|
|
17
|
+
/**
|
|
18
|
+
* A serialized synthetic (group) row. Leaf rows serialize as their position in
|
|
19
|
+
* `options.data`; group rows carry what `constructRow` + the grouped row model
|
|
20
|
+
* need to rebuild them, plus eagerly computed aggregate values so no
|
|
21
|
+
* aggregation runs on the main thread.
|
|
22
|
+
*/
|
|
23
|
+
interface TableWorkerGroupNode {
|
|
24
|
+
id: string;
|
|
25
|
+
groupingColumnId: string;
|
|
26
|
+
groupingValue: unknown;
|
|
27
|
+
index: number;
|
|
28
|
+
aggregates: Record<string, unknown>;
|
|
29
|
+
children: Array<TableWorkerRowNode>;
|
|
30
|
+
}
|
|
31
|
+
type TableWorkerRowNode = number | TableWorkerGroupNode;
|
|
32
|
+
/**
|
|
33
|
+
* A stage result. Flat models (every row is a data row) travel as a
|
|
34
|
+
* transferable index permutation; models containing synthetic rows (grouping)
|
|
35
|
+
* travel as a tree. The kind is chosen from the model's actual shape at
|
|
36
|
+
* runtime, not from the stage name: a sorted model is flat without grouping
|
|
37
|
+
* and a tree with it.
|
|
38
|
+
*
|
|
39
|
+
* `unchanged` means the stage's model is identical to the last one sent for
|
|
40
|
+
* this dataset (its memoized inputs did not change); the main thread keeps
|
|
41
|
+
* its previous result and skips the rebuild entirely.
|
|
42
|
+
*/
|
|
43
|
+
type TableWorkerStagePayload = {
|
|
44
|
+
kind: 'flat';
|
|
45
|
+
indices: Uint32Array;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'tree';
|
|
48
|
+
children: Array<TableWorkerRowNode>;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'unchanged';
|
|
51
|
+
};
|
|
52
|
+
type TableWorkerRequest<TData extends RowData = any> = {
|
|
53
|
+
type: 'data';
|
|
54
|
+
dataVersion: number;
|
|
55
|
+
data: Array<TData>;
|
|
56
|
+
} | {
|
|
57
|
+
type: 'process';
|
|
58
|
+
requestId: number;
|
|
59
|
+
dataVersion: number; /** The stages the main thread has worker-backed row models for. */
|
|
60
|
+
stages: Array<TableWorkerStage>; /** Serializable state slices (union of the stages' deps). */
|
|
61
|
+
state: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
interface TableWorkerResult {
|
|
64
|
+
type: 'result';
|
|
65
|
+
requestId: number;
|
|
66
|
+
dataVersion: number;
|
|
67
|
+
stages: { [K in TableWorkerStage]?: TableWorkerStagePayload };
|
|
68
|
+
computeMs: number;
|
|
69
|
+
}
|
|
70
|
+
type TableWorkerResponse = TableWorkerResult;
|
|
71
|
+
/**
|
|
72
|
+
* The state slice added by `workerRowModelsFeature`. `version` bumps when a
|
|
73
|
+
* worker result lands (driving re-renders through the normal state path);
|
|
74
|
+
* `isPending` is true while a request is in flight. The timing fields expose
|
|
75
|
+
* the last result's worker compute time and full round trip for devtools and
|
|
76
|
+
* debugging.
|
|
77
|
+
*/
|
|
78
|
+
interface TableState_WorkerRowModels {
|
|
79
|
+
workerRowModels: {
|
|
80
|
+
version: number;
|
|
81
|
+
isPending: boolean;
|
|
82
|
+
lastComputeMs?: number;
|
|
83
|
+
lastRoundTripMs?: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { TableState_WorkerRowModels, TableWorkerGroupNode, TableWorkerRequest, TableWorkerResponse, TableWorkerResult, TableWorkerRowNode, TableWorkerStage, TableWorkerStagePayload, tableWorkerPipeline, tableWorkerStageStateDeps };
|
|
88
|
+
//# sourceMappingURL=tableWorkerProtocol.d.cts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { RowData } from "../types/type-utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/worker/tableWorkerProtocol.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Row model stages that can be offloaded to the worker, in pipeline order.
|
|
6
|
+
* Everything else in this module is derived from this list; adding a stage
|
|
7
|
+
* means adding an entry here and to `tableWorkerStageStateDeps`.
|
|
8
|
+
*/
|
|
9
|
+
declare const tableWorkerPipeline: readonly ["filtered", "grouped", "sorted", "expanded"];
|
|
10
|
+
type TableWorkerStage = (typeof tableWorkerPipeline)[number];
|
|
11
|
+
/**
|
|
12
|
+
* The state slices each stage's computation depends on. The main thread sends
|
|
13
|
+
* the union of deps for its registered stages; a change to any of them
|
|
14
|
+
* triggers one worker round trip.
|
|
15
|
+
*/
|
|
16
|
+
declare const tableWorkerStageStateDeps: Record<TableWorkerStage, Array<string>>;
|
|
17
|
+
/**
|
|
18
|
+
* A serialized synthetic (group) row. Leaf rows serialize as their position in
|
|
19
|
+
* `options.data`; group rows carry what `constructRow` + the grouped row model
|
|
20
|
+
* need to rebuild them, plus eagerly computed aggregate values so no
|
|
21
|
+
* aggregation runs on the main thread.
|
|
22
|
+
*/
|
|
23
|
+
interface TableWorkerGroupNode {
|
|
24
|
+
id: string;
|
|
25
|
+
groupingColumnId: string;
|
|
26
|
+
groupingValue: unknown;
|
|
27
|
+
index: number;
|
|
28
|
+
aggregates: Record<string, unknown>;
|
|
29
|
+
children: Array<TableWorkerRowNode>;
|
|
30
|
+
}
|
|
31
|
+
type TableWorkerRowNode = number | TableWorkerGroupNode;
|
|
32
|
+
/**
|
|
33
|
+
* A stage result. Flat models (every row is a data row) travel as a
|
|
34
|
+
* transferable index permutation; models containing synthetic rows (grouping)
|
|
35
|
+
* travel as a tree. The kind is chosen from the model's actual shape at
|
|
36
|
+
* runtime, not from the stage name: a sorted model is flat without grouping
|
|
37
|
+
* and a tree with it.
|
|
38
|
+
*
|
|
39
|
+
* `unchanged` means the stage's model is identical to the last one sent for
|
|
40
|
+
* this dataset (its memoized inputs did not change); the main thread keeps
|
|
41
|
+
* its previous result and skips the rebuild entirely.
|
|
42
|
+
*/
|
|
43
|
+
type TableWorkerStagePayload = {
|
|
44
|
+
kind: 'flat';
|
|
45
|
+
indices: Uint32Array;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'tree';
|
|
48
|
+
children: Array<TableWorkerRowNode>;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'unchanged';
|
|
51
|
+
};
|
|
52
|
+
type TableWorkerRequest<TData extends RowData = any> = {
|
|
53
|
+
type: 'data';
|
|
54
|
+
dataVersion: number;
|
|
55
|
+
data: Array<TData>;
|
|
56
|
+
} | {
|
|
57
|
+
type: 'process';
|
|
58
|
+
requestId: number;
|
|
59
|
+
dataVersion: number; /** The stages the main thread has worker-backed row models for. */
|
|
60
|
+
stages: Array<TableWorkerStage>; /** Serializable state slices (union of the stages' deps). */
|
|
61
|
+
state: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
interface TableWorkerResult {
|
|
64
|
+
type: 'result';
|
|
65
|
+
requestId: number;
|
|
66
|
+
dataVersion: number;
|
|
67
|
+
stages: { [K in TableWorkerStage]?: TableWorkerStagePayload };
|
|
68
|
+
computeMs: number;
|
|
69
|
+
}
|
|
70
|
+
type TableWorkerResponse = TableWorkerResult;
|
|
71
|
+
/**
|
|
72
|
+
* The state slice added by `workerRowModelsFeature`. `version` bumps when a
|
|
73
|
+
* worker result lands (driving re-renders through the normal state path);
|
|
74
|
+
* `isPending` is true while a request is in flight. The timing fields expose
|
|
75
|
+
* the last result's worker compute time and full round trip for devtools and
|
|
76
|
+
* debugging.
|
|
77
|
+
*/
|
|
78
|
+
interface TableState_WorkerRowModels {
|
|
79
|
+
workerRowModels: {
|
|
80
|
+
version: number;
|
|
81
|
+
isPending: boolean;
|
|
82
|
+
lastComputeMs?: number;
|
|
83
|
+
lastRoundTripMs?: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { TableState_WorkerRowModels, TableWorkerGroupNode, TableWorkerRequest, TableWorkerResponse, TableWorkerResult, TableWorkerRowNode, TableWorkerStage, TableWorkerStagePayload, tableWorkerPipeline, tableWorkerStageStateDeps };
|
|
88
|
+
//# sourceMappingURL=tableWorkerProtocol.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/worker/tableWorkerProtocol.ts
|
|
2
|
+
/**
|
|
3
|
+
* Row model stages that can be offloaded to the worker, in pipeline order.
|
|
4
|
+
* Everything else in this module is derived from this list; adding a stage
|
|
5
|
+
* means adding an entry here and to `tableWorkerStageStateDeps`.
|
|
6
|
+
*/
|
|
7
|
+
const tableWorkerPipeline = [
|
|
8
|
+
"filtered",
|
|
9
|
+
"grouped",
|
|
10
|
+
"sorted",
|
|
11
|
+
"expanded"
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* The state slices each stage's computation depends on. The main thread sends
|
|
15
|
+
* the union of deps for its registered stages; a change to any of them
|
|
16
|
+
* triggers one worker round trip.
|
|
17
|
+
*/
|
|
18
|
+
const tableWorkerStageStateDeps = {
|
|
19
|
+
filtered: ["columnFilters", "globalFilter"],
|
|
20
|
+
grouped: ["grouping"],
|
|
21
|
+
sorted: ["sorting"],
|
|
22
|
+
expanded: ["expanded"]
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { tableWorkerPipeline, tableWorkerStageStateDeps };
|
|
27
|
+
//# sourceMappingURL=tableWorkerProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableWorkerProtocol.js","names":[],"sources":["../../src/worker/tableWorkerProtocol.ts"],"sourcesContent":["import type { RowData } from '../types/type-utils'\n\n/**\n * Row model stages that can be offloaded to the worker, in pipeline order.\n * Everything else in this module is derived from this list; adding a stage\n * means adding an entry here and to `tableWorkerStageStateDeps`.\n */\nexport const tableWorkerPipeline = [\n 'filtered',\n 'grouped',\n 'sorted',\n 'expanded',\n] as const\n\nexport type TableWorkerStage = (typeof tableWorkerPipeline)[number]\n\n/**\n * The state slices each stage's computation depends on. The main thread sends\n * the union of deps for its registered stages; a change to any of them\n * triggers one worker round trip.\n */\nexport const tableWorkerStageStateDeps: Record<\n TableWorkerStage,\n Array<string>\n> = {\n filtered: ['columnFilters', 'globalFilter'],\n grouped: ['grouping'],\n sorted: ['sorting'],\n expanded: ['expanded'],\n}\n\n/**\n * A serialized synthetic (group) row. Leaf rows serialize as their position in\n * `options.data`; group rows carry what `constructRow` + the grouped row model\n * need to rebuild them, plus eagerly computed aggregate values so no\n * aggregation runs on the main thread.\n */\nexport interface TableWorkerGroupNode {\n id: string\n groupingColumnId: string\n groupingValue: unknown\n index: number\n aggregates: Record<string, unknown>\n children: Array<TableWorkerRowNode>\n}\n\nexport type TableWorkerRowNode = number | TableWorkerGroupNode\n\n/**\n * A stage result. Flat models (every row is a data row) travel as a\n * transferable index permutation; models containing synthetic rows (grouping)\n * travel as a tree. The kind is chosen from the model's actual shape at\n * runtime, not from the stage name: a sorted model is flat without grouping\n * and a tree with it.\n *\n * `unchanged` means the stage's model is identical to the last one sent for\n * this dataset (its memoized inputs did not change); the main thread keeps\n * its previous result and skips the rebuild entirely.\n */\nexport type TableWorkerStagePayload =\n | { kind: 'flat'; indices: Uint32Array }\n | { kind: 'tree'; children: Array<TableWorkerRowNode> }\n | { kind: 'unchanged' }\n\nexport type TableWorkerRequest<TData extends RowData = any> =\n | {\n type: 'data'\n dataVersion: number\n data: Array<TData>\n }\n | {\n type: 'process'\n requestId: number\n dataVersion: number\n /** The stages the main thread has worker-backed row models for. */\n stages: Array<TableWorkerStage>\n /** Serializable state slices (union of the stages' deps). */\n state: Record<string, unknown>\n }\n\nexport interface TableWorkerResult {\n type: 'result'\n requestId: number\n dataVersion: number\n stages: { [K in TableWorkerStage]?: TableWorkerStagePayload }\n computeMs: number\n}\n\nexport type TableWorkerResponse = TableWorkerResult\n\n/**\n * The state slice added by `workerRowModelsFeature`. `version` bumps when a\n * worker result lands (driving re-renders through the normal state path);\n * `isPending` is true while a request is in flight. The timing fields expose\n * the last result's worker compute time and full round trip for devtools and\n * debugging.\n */\nexport interface TableState_WorkerRowModels {\n workerRowModels: {\n version: number\n isPending: boolean\n lastComputeMs?: number\n lastRoundTripMs?: number\n }\n}\n"],"mappings":";;;;;;AAOA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;AACF;;;;;;AASA,MAAa,4BAGT;CACF,UAAU,CAAC,iBAAiB,cAAc;CAC1C,SAAS,CAAC,UAAU;CACpB,QAAQ,CAAC,SAAS;CAClB,UAAU,CAAC,UAAU;AACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.34",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
"import": "./dist/index.js",
|
|
36
36
|
"require": "./dist/index.cjs"
|
|
37
37
|
},
|
|
38
|
+
"./experimental-worker-plugin": {
|
|
39
|
+
"import": "./dist/experimental-worker-plugin.js",
|
|
40
|
+
"require": "./dist/experimental-worker-plugin.cjs"
|
|
41
|
+
},
|
|
38
42
|
"./flex-render": {
|
|
39
43
|
"import": "./dist/flex-render.js",
|
|
40
44
|
"require": "./dist/flex-render.cjs"
|
|
@@ -55,7 +59,7 @@
|
|
|
55
59
|
},
|
|
56
60
|
"sideEffects": false,
|
|
57
61
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
62
|
+
"node": ">=20"
|
|
59
63
|
},
|
|
60
64
|
"files": [
|
|
61
65
|
"dist/",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Worker row models sub-entry (experimental POC).
|
|
3
|
+
*
|
|
4
|
+
* Offloads row model stages to a dedicated worker running a headless "shadow
|
|
5
|
+
* table" built with the same table-core row model pipeline. The main thread
|
|
6
|
+
* receives transferable index permutations and rebuilds its row models from
|
|
7
|
+
* them, stale-while-revalidate style.
|
|
8
|
+
*
|
|
9
|
+
* Main thread:
|
|
10
|
+
* - `createTableWorker` — one shared handle per table worker
|
|
11
|
+
* - `createWorkerRowModel` — turns any flat row model stage into a
|
|
12
|
+
* worker-backed factory for the matching `features` slot
|
|
13
|
+
* - `workerRowModelsFeature` — registers the `workerRowModels` state slice
|
|
14
|
+
*
|
|
15
|
+
* Worker entry (user-authored file):
|
|
16
|
+
* - `initTableWorker` — runs the shadow table; computes only the stages whose
|
|
17
|
+
* row model factories are registered in its config
|
|
18
|
+
*/
|
|
19
|
+
export * from './worker/tableWorkerProtocol'
|
|
20
|
+
export * from './worker/initTableWorker'
|
|
21
|
+
export * from './worker/createTableWorker'
|
|
22
|
+
export * from './worker/createWorkerRowModel'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callMemoOrStaticFn,
|
|
3
3
|
cloneState,
|
|
4
|
+
copyInstancePropertiesWithoutMemos,
|
|
4
5
|
hasOwn,
|
|
5
6
|
makeObjectMap,
|
|
6
7
|
} from '../../utils'
|
|
@@ -738,7 +739,7 @@ export function selectRowsFn<
|
|
|
738
739
|
if (isSelected) {
|
|
739
740
|
// Preserve prototype chain so methods like getValue() remain accessible
|
|
740
741
|
const cloned = Object.create(Object.getPrototypeOf(row))
|
|
741
|
-
|
|
742
|
+
copyInstancePropertiesWithoutMemos(cloned, row)
|
|
742
743
|
cloned.subRows = newSubRows
|
|
743
744
|
result.push(cloned)
|
|
744
745
|
}
|