@tanstack/table-core 9.0.0-beta.5 → 9.0.0-beta.51
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/README.md +2 -0
- package/dist/core/cells/constructCell.cjs +1 -4
- package/dist/core/cells/constructCell.cjs.map +1 -1
- package/dist/core/cells/constructCell.d.cts +4 -4
- package/dist/core/cells/constructCell.d.ts +4 -4
- 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 +7 -7
- package/dist/core/cells/coreCellsFeature.types.d.ts +7 -7
- package/dist/core/cells/coreCellsFeature.utils.d.cts +4 -4
- package/dist/core/cells/coreCellsFeature.utils.d.ts +4 -4
- package/dist/core/columns/constructColumn.cjs +4 -5
- package/dist/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.d.cts +3 -3
- package/dist/core/columns/constructColumn.d.ts +3 -3
- package/dist/core/columns/constructColumn.js +4 -5
- 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.types.d.cts +7 -7
- package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -7
- package/dist/core/columns/coreColumnsFeature.utils.cjs +4 -8
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +9 -9
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +9 -9
- package/dist/core/columns/coreColumnsFeature.utils.js +5 -9
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/coreFeatures.cjs.map +1 -1
- package/dist/core/coreFeatures.d.cts +1 -1
- package/dist/core/coreFeatures.d.ts +1 -1
- package/dist/core/coreFeatures.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.d.cts +2 -2
- package/dist/core/headers/buildHeaderGroups.d.ts +2 -2
- 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.d.cts +2 -2
- package/dist/core/headers/constructHeader.d.ts +2 -2
- 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.types.d.cts +6 -6
- package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.cjs +8 -10
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.js +8 -10
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +7 -15
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +7 -15
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +8 -26
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +16 -16
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +16 -16
- package/dist/core/row-models/coreRowModelsFeature.utils.js +8 -26
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs +4 -6
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
- package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
- package/dist/core/row-models/createCoreRowModel.js +5 -7
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +6 -10
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.d.cts +2 -2
- package/dist/core/rows/constructRow.d.ts +2 -2
- package/dist/core/rows/constructRow.js +7 -10
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.cjs +18 -2
- package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.js +19 -3
- package/dist/core/rows/coreRowsFeature.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +41 -7
- package/dist/core/rows/coreRowsFeature.types.d.ts +41 -7
- package/dist/core/rows/coreRowsFeature.utils.cjs +62 -8
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +24 -5
- package/dist/core/rows/coreRowsFeature.utils.d.ts +24 -5
- package/dist/core/rows/coreRowsFeature.utils.js +61 -10
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +24 -14
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.d.cts +1 -1
- package/dist/core/table/constructTable.d.ts +1 -1
- package/dist/core/table/constructTable.js +24 -14
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +32 -19
- package/dist/core/table/coreTablesFeature.types.d.ts +32 -19
- package/dist/core/table/coreTablesFeature.utils.cjs +38 -14
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +10 -7
- package/dist/core/table/coreTablesFeature.utils.d.ts +10 -7
- package/dist/core/table/coreTablesFeature.utils.js +38 -14
- package/dist/core/table/coreTablesFeature.utils.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 +15 -33
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +15 -33
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +23 -12
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +9 -9
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +9 -9
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +24 -12
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +7 -4
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.cts +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.ts +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
- package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +10 -15
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.cts +2 -2
- package/dist/features/column-faceting/createFacetedRowModel.d.ts +2 -2
- package/dist/features/column-faceting/createFacetedRowModel.js +10 -15
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs +10 -6
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.d.cts +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.d.ts +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.js +11 -7
- package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.cjs +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.js +3 -3
- package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +83 -29
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +83 -29
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +23 -17
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +18 -14
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +18 -14
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +23 -17
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +29 -25
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.cts +10 -4
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +10 -4
- package/dist/features/column-filtering/createFilteredRowModel.js +30 -26
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-filtering/filterFns.cjs +399 -0
- package/dist/features/column-filtering/filterFns.cjs.map +1 -0
- package/dist/features/column-filtering/filterFns.d.cts +210 -0
- package/dist/features/column-filtering/filterFns.d.ts +210 -0
- package/dist/features/column-filtering/filterFns.js +375 -0
- package/dist/features/column-filtering/filterFns.js.map +1 -0
- package/dist/features/column-filtering/filterRowsUtils.cjs +3 -2
- package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.js +3 -2
- package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +4 -16
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.cts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.ts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +6 -18
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +14 -50
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +14 -50
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +6 -61
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +12 -49
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +12 -49
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +8 -60
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +37 -24
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +6 -4
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +6 -4
- package/dist/features/column-grouping/createGroupedRowModel.js +39 -26
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs +17 -21
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.js +18 -22
- package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +28 -3
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +28 -3
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +35 -15
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +26 -14
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +26 -14
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +36 -17
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +124 -143
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.d.cts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.d.ts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.js +125 -144
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +52 -41
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +52 -41
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +161 -162
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +101 -92
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +101 -92
- package/dist/features/column-pinning/columnPinningFeature.utils.js +148 -149
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +1 -4
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +1 -4
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +84 -44
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +6 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +6 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.js +85 -45
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +33 -67
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +34 -68
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +52 -9
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +52 -9
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +88 -45
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +43 -25
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +43 -25
- package/dist/features/column-sizing/columnSizingFeature.utils.js +88 -46
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +25 -36
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +25 -36
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +30 -29
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +18 -18
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +18 -18
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +31 -30
- 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.types.d.cts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +6 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +8 -11
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +8 -11
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +6 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-aggregation/aggregationFns.cjs +246 -0
- package/dist/features/row-aggregation/aggregationFns.cjs.map +1 -0
- package/dist/features/row-aggregation/aggregationFns.d.cts +68 -0
- package/dist/features/row-aggregation/aggregationFns.d.ts +68 -0
- package/dist/features/row-aggregation/aggregationFns.js +235 -0
- package/dist/features/row-aggregation/aggregationFns.js.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.cjs +39 -0
- package/dist/features/row-aggregation/rowAggregationFeature.cjs.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.d.cts +10 -0
- package/dist/features/row-aggregation/rowAggregationFeature.d.ts +10 -0
- package/dist/features/row-aggregation/rowAggregationFeature.js +39 -0
- package/dist/features/row-aggregation/rowAggregationFeature.js.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.cjs +13 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.cjs.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.d.cts +195 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.d.ts +195 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.js +12 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.js.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.cjs +212 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.cjs.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.d.cts +34 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.d.ts +34 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.js +206 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.js.map +1 -0
- 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 +2 -2
- package/dist/features/row-expanding/createExpandedRowModel.d.ts +2 -2
- 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 +6 -15
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +6 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +28 -26
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +10 -10
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +10 -10
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +29 -27
- 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 +2 -2
- package/dist/features/row-pagination/createPaginatedRowModel.d.ts +2 -2
- 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 +5 -14
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +5 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +9 -15
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +17 -17
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +17 -17
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +9 -15
- 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.types.d.cts +2 -2
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +2 -2
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +9 -14
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +7 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +7 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.js +9 -14
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +66 -22
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +67 -23
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +49 -11
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +49 -11
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +128 -72
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +57 -30
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +57 -30
- package/dist/features/row-selection/rowSelectionFeature.utils.js +129 -74
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +69 -50
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.cts +10 -4
- package/dist/features/row-sorting/createSortedRowModel.d.ts +10 -4
- package/dist/features/row-sorting/createSortedRowModel.js +70 -51
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +54 -22
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +54 -22
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +31 -17
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +16 -16
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +16 -16
- package/dist/features/row-sorting/rowSortingFeature.utils.js +31 -17
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/sortFns.cjs +226 -0
- package/dist/features/row-sorting/sortFns.cjs.map +1 -0
- package/dist/features/row-sorting/sortFns.d.cts +98 -0
- package/dist/features/row-sorting/sortFns.d.ts +98 -0
- package/dist/features/row-sorting/sortFns.js +217 -0
- package/dist/features/row-sorting/sortFns.js.map +1 -0
- package/dist/features/stockFeatures.cjs +2 -0
- package/dist/features/stockFeatures.cjs.map +1 -1
- package/dist/features/stockFeatures.d.cts +2 -0
- package/dist/features/stockFeatures.d.ts +2 -0
- package/dist/features/stockFeatures.js +2 -0
- package/dist/features/stockFeatures.js.map +1 -1
- package/dist/flex-render.d.cts +1 -1
- package/dist/flex-render.d.ts +1 -1
- package/dist/helpers/columnHelper.cjs.map +1 -1
- package/dist/helpers/columnHelper.d.cts +2 -2
- package/dist/helpers/columnHelper.d.ts +2 -2
- package/dist/helpers/columnHelper.js.map +1 -1
- package/dist/helpers/metaHelper.cjs +30 -0
- package/dist/helpers/metaHelper.cjs.map +1 -0
- package/dist/helpers/metaHelper.d.cts +26 -0
- package/dist/helpers/metaHelper.d.ts +26 -0
- package/dist/helpers/metaHelper.js +29 -0
- package/dist/helpers/metaHelper.js.map +1 -0
- package/dist/helpers/tableFeatures.cjs +32 -3
- package/dist/helpers/tableFeatures.cjs.map +1 -1
- package/dist/helpers/tableFeatures.d.cts +34 -5
- package/dist/helpers/tableFeatures.d.ts +34 -5
- package/dist/helpers/tableFeatures.js +32 -3
- package/dist/helpers/tableFeatures.js.map +1 -1
- package/dist/index.cjs +23 -3
- package/dist/index.d.cts +31 -28
- package/dist/index.d.ts +31 -28
- package/dist/index.js +8 -5
- package/dist/static-functions.cjs +30 -19
- package/dist/static-functions.d.cts +8 -7
- package/dist/static-functions.d.ts +8 -7
- package/dist/static-functions.js +8 -7
- package/dist/store-reactivity-bindings.cjs +3 -3
- package/dist/store-reactivity-bindings.cjs.map +1 -1
- package/dist/store-reactivity-bindings.d.cts +1 -1
- package/dist/store-reactivity-bindings.d.ts +1 -1
- package/dist/store-reactivity-bindings.js +3 -3
- package/dist/store-reactivity-bindings.js.map +1 -1
- package/dist/types/Cell.d.cts +4 -2
- package/dist/types/Cell.d.ts +4 -2
- package/dist/types/Column.d.cts +15 -15
- package/dist/types/Column.d.ts +15 -15
- package/dist/types/ColumnDef.d.cts +30 -14
- package/dist/types/ColumnDef.d.ts +30 -14
- package/dist/types/Header.d.cts +2 -2
- package/dist/types/Header.d.ts +2 -2
- package/dist/types/HeaderGroup.d.cts +2 -2
- package/dist/types/HeaderGroup.d.ts +2 -2
- package/dist/types/Row.d.cts +6 -4
- package/dist/types/Row.d.ts +6 -4
- package/dist/types/RowModel.d.cts +11 -23
- package/dist/types/RowModel.d.ts +11 -23
- package/dist/types/RowModelFns.d.cts +4 -4
- package/dist/types/RowModelFns.d.ts +4 -4
- package/dist/types/Table.d.cts +26 -31
- package/dist/types/Table.d.ts +26 -31
- package/dist/types/TableFeatures.d.cts +350 -22
- package/dist/types/TableFeatures.d.ts +350 -22
- package/dist/types/TableOptions.d.cts +22 -14
- package/dist/types/TableOptions.d.ts +22 -14
- package/dist/types/TableState.d.cts +6 -6
- package/dist/types/TableState.d.ts +6 -6
- package/dist/types/type-utils.d.cts +8 -1
- package/dist/types/type-utils.d.ts +8 -1
- package/dist/utils.cjs +51 -29
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +30 -8
- package/dist/utils.d.ts +30 -8
- package/dist/utils.js +49 -30
- 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 +8 -3
- package/skills/aggregation/SKILL.md +141 -0
- package/skills/api-not-found/SKILL.md +113 -0
- package/skills/client-vs-server/SKILL.md +164 -0
- package/skills/column-faceting/SKILL.md +97 -0
- package/skills/column-filtering/SKILL.md +87 -0
- package/skills/column-ordering/SKILL.md +75 -0
- package/skills/column-pinning/SKILL.md +89 -0
- package/skills/column-resizing/SKILL.md +91 -0
- package/skills/column-sizing/SKILL.md +72 -0
- package/skills/column-visibility/SKILL.md +75 -0
- package/skills/core/SKILL.md +175 -0
- package/skills/custom-features/SKILL.md +235 -0
- package/skills/expanding/SKILL.md +80 -0
- package/skills/global-filtering/SKILL.md +84 -0
- package/skills/grouping/SKILL.md +51 -401
- package/skills/migrate-v8-to-v9/SKILL.md +274 -416
- package/skills/pagination/SKILL.md +37 -344
- package/skills/row-pinning/SKILL.md +47 -234
- package/skills/row-selection/SKILL.md +75 -302
- package/skills/sorting/SKILL.md +45 -303
- package/skills/table-features/SKILL.md +159 -0
- package/skills/typescript/SKILL.md +126 -0
- package/src/core/cells/coreCellsFeature.types.ts +6 -6
- package/src/core/columns/constructColumn.ts +6 -0
- package/src/core/columns/coreColumnsFeature.types.ts +8 -8
- package/src/core/columns/coreColumnsFeature.utils.ts +4 -4
- package/src/core/coreFeatures.ts +1 -1
- package/src/core/headers/buildHeaderGroups.ts +4 -2
- package/src/core/headers/coreHeadersFeature.types.ts +12 -12
- package/src/core/headers/coreHeadersFeature.utils.ts +7 -8
- package/src/core/row-models/coreRowModelsFeature.types.ts +6 -20
- package/src/core/row-models/coreRowModelsFeature.utils.ts +8 -8
- package/src/core/row-models/createCoreRowModel.ts +7 -6
- package/src/core/rows/constructRow.ts +4 -2
- package/src/core/rows/coreRowsFeature.ts +21 -0
- package/src/core/rows/coreRowsFeature.types.ts +45 -8
- package/src/core/rows/coreRowsFeature.utils.ts +93 -5
- package/src/core/table/constructTable.ts +44 -6
- package/src/core/table/coreTablesFeature.types.ts +45 -20
- package/src/core/table/coreTablesFeature.utils.ts +59 -19
- package/src/experimental-worker-plugin.ts +22 -0
- package/src/features/column-faceting/columnFacetingFeature.types.ts +17 -48
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +53 -18
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +33 -7
- package/src/features/column-faceting/createFacetedRowModel.ts +8 -1
- package/src/features/column-faceting/createFacetedUniqueValues.ts +41 -10
- package/src/features/column-filtering/columnFilteringFeature.ts +3 -2
- package/src/features/column-filtering/columnFilteringFeature.types.ts +117 -41
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +37 -23
- package/src/features/column-filtering/createFilteredRowModel.ts +28 -17
- package/src/features/column-filtering/filterFns.ts +533 -0
- package/src/features/column-filtering/filterRowsUtils.ts +3 -2
- package/src/features/column-grouping/columnGroupingFeature.ts +3 -21
- package/src/features/column-grouping/columnGroupingFeature.types.ts +21 -95
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +4 -87
- package/src/features/column-grouping/createGroupedRowModel.ts +46 -45
- package/src/features/column-ordering/columnOrderingFeature.ts +12 -7
- package/src/features/column-ordering/columnOrderingFeature.types.ts +29 -3
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +59 -8
- package/src/features/column-pinning/columnPinningFeature.ts +76 -59
- package/src/features/column-pinning/columnPinningFeature.types.ts +53 -42
- package/src/features/column-pinning/columnPinningFeature.utils.ts +184 -170
- package/src/features/column-resizing/columnResizingFeature.types.ts +1 -4
- package/src/features/column-resizing/columnResizingFeature.utils.ts +120 -52
- package/src/features/column-sizing/columnSizingFeature.ts +24 -24
- package/src/features/column-sizing/columnSizingFeature.types.ts +53 -8
- package/src/features/column-sizing/columnSizingFeature.utils.ts +143 -62
- package/src/features/column-visibility/columnVisibilityFeature.ts +4 -0
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +4 -4
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +48 -30
- package/src/features/global-filtering/globalFilteringFeature.types.ts +4 -4
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +13 -5
- package/src/features/row-aggregation/aggregationFns.ts +345 -0
- package/src/features/row-aggregation/rowAggregationFeature.ts +60 -0
- package/src/features/row-aggregation/rowAggregationFeature.types.ts +339 -0
- package/src/features/row-aggregation/rowAggregationFeature.utils.ts +430 -0
- package/src/features/row-expanding/rowExpandingFeature.types.ts +8 -23
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +38 -13
- package/src/features/row-pagination/createPaginatedRowModel.ts +1 -1
- package/src/features/row-pagination/rowPaginationFeature.types.ts +6 -21
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +1 -1
- package/src/features/row-pinning/rowPinningFeature.types.ts +4 -4
- package/src/features/row-selection/rowSelectionFeature.ts +53 -3
- package/src/features/row-selection/rowSelectionFeature.types.ts +54 -10
- package/src/features/row-selection/rowSelectionFeature.utils.ts +273 -91
- package/src/features/row-sorting/createSortedRowModel.ts +107 -75
- package/src/features/row-sorting/rowSortingFeature.types.ts +87 -34
- package/src/features/row-sorting/rowSortingFeature.utils.ts +49 -23
- package/src/features/row-sorting/sortFns.ts +366 -0
- package/src/features/stockFeatures.ts +3 -0
- package/src/helpers/columnHelper.ts +4 -4
- package/src/helpers/metaHelper.ts +24 -0
- package/src/helpers/tableFeatures.ts +37 -5
- package/src/index.ts +8 -8
- package/src/static-functions.ts +1 -0
- package/src/store-reactivity-bindings.ts +1 -1
- package/src/types/Cell.ts +4 -2
- package/src/types/Column.ts +13 -9
- package/src/types/ColumnDef.ts +40 -10
- package/src/types/Header.ts +2 -2
- package/src/types/HeaderGroup.ts +6 -6
- package/src/types/Row.ts +6 -4
- package/src/types/RowModel.ts +19 -74
- package/src/types/RowModelFns.ts +10 -10
- package/src/types/Table.ts +52 -27
- package/src/types/TableFeatures.ts +392 -14
- package/src/types/TableOptions.ts +67 -14
- package/src/types/TableState.ts +15 -1
- package/src/types/type-utils.ts +8 -0
- package/src/utils.ts +60 -8
- 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 +120 -0
- package/src/worker/serializeRowModel.ts +80 -0
- package/src/worker/tableWorkerProtocol.ts +105 -0
- package/dist/fns/aggregationFns.cjs +0 -161
- package/dist/fns/aggregationFns.cjs.map +0 -1
- package/dist/fns/aggregationFns.d.cts +0 -85
- package/dist/fns/aggregationFns.d.ts +0 -85
- package/dist/fns/aggregationFns.js +0 -151
- package/dist/fns/aggregationFns.js.map +0 -1
- package/dist/fns/filterFns.cjs +0 -201
- package/dist/fns/filterFns.cjs.map +0 -1
- package/dist/fns/filterFns.d.cts +0 -167
- package/dist/fns/filterFns.d.ts +0 -167
- package/dist/fns/filterFns.js +0 -185
- package/dist/fns/filterFns.js.map +0 -1
- package/dist/fns/sortFns.cjs +0 -118
- package/dist/fns/sortFns.cjs.map +0 -1
- package/dist/fns/sortFns.d.cts +0 -65
- package/dist/fns/sortFns.d.ts +0 -65
- package/dist/fns/sortFns.js +0 -110
- package/dist/fns/sortFns.js.map +0 -1
- package/skills/column-definitions/SKILL.md +0 -333
- package/skills/column-layout/SKILL.md +0 -328
- package/skills/column-layout/references/subsystems.md +0 -220
- package/skills/customizing-feature-behavior/SKILL.md +0 -416
- package/skills/filtering/SKILL.md +0 -357
- package/skills/filtering/references/faceting-and-fuzzy.md +0 -191
- package/skills/row-expanding/SKILL.md +0 -348
- package/skills/setup/SKILL.md +0 -400
- package/skills/state-management/SKILL.md +0 -388
- package/src/fns/aggregationFns.ts +0 -245
- package/src/fns/filterFns.ts +0 -382
- package/src/fns/sortFns.ts +0 -217
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RowData } from "../types/type-utils.js";
|
|
2
|
+
import { TableOptions } from "../types/TableOptions.js";
|
|
3
|
+
import { TableFeatures } from "../types/TableFeatures.js";
|
|
4
|
+
|
|
5
|
+
//#region src/worker/initTableWorker.d.ts
|
|
6
|
+
type TableWorkerConfig<TFeatures extends TableFeatures, TData extends RowData> = Omit<TableOptions<TFeatures, TData>, 'data'>;
|
|
7
|
+
/**
|
|
8
|
+
* Runs a headless "shadow table" inside a dedicated Web Worker.
|
|
9
|
+
*
|
|
10
|
+
* Call this from a user-authored worker entry file, passing the same columns
|
|
11
|
+
* and processing features used on the main thread. The shadow table runs the
|
|
12
|
+
* real table-core row model pipeline (real fns, real Row objects) off the
|
|
13
|
+
* main thread and posts back one payload per stage the main thread requested:
|
|
14
|
+
* a transferable index permutation for flat results, a serialized row tree
|
|
15
|
+
* (with eagerly computed aggregates) when grouping produces synthetic rows.
|
|
16
|
+
*
|
|
17
|
+
* Everything passed here must be thread-portable: `accessorKey` columns or
|
|
18
|
+
* accessors defined in a shared module, and fns from registries or shared
|
|
19
|
+
* modules (no closures over app state).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // table.worker.ts
|
|
24
|
+
* import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'
|
|
25
|
+
* import { columns, sharedFeatures } from './tableConfig'
|
|
26
|
+
*
|
|
27
|
+
* initTableWorker({ features: sharedFeatures, columns })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function initTableWorker<TFeatures extends TableFeatures, TData extends RowData>(config: TableWorkerConfig<TFeatures, TData>): void;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { TableWorkerConfig, initTableWorker };
|
|
33
|
+
//# sourceMappingURL=initTableWorker.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { makeObjectMap } from "../utils.js";
|
|
2
|
+
import { constructTable } from "../core/table/constructTable.js";
|
|
3
|
+
import { storeReactivityBindings } from "../store-reactivity-bindings.js";
|
|
4
|
+
import { serializeRowModel } from "./serializeRowModel.js";
|
|
5
|
+
|
|
6
|
+
//#region src/worker/initTableWorker.ts
|
|
7
|
+
function capitalize(stage) {
|
|
8
|
+
return stage.charAt(0).toUpperCase() + stage.slice(1);
|
|
9
|
+
}
|
|
10
|
+
/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */
|
|
11
|
+
function flattenColumnDefs(defs) {
|
|
12
|
+
return defs.flatMap((def) => def.columns ? flattenColumnDefs(def.columns) : [def]);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Runs a headless "shadow table" inside a dedicated Web Worker.
|
|
16
|
+
*
|
|
17
|
+
* Call this from a user-authored worker entry file, passing the same columns
|
|
18
|
+
* and processing features used on the main thread. The shadow table runs the
|
|
19
|
+
* real table-core row model pipeline (real fns, real Row objects) off the
|
|
20
|
+
* main thread and posts back one payload per stage the main thread requested:
|
|
21
|
+
* a transferable index permutation for flat results, a serialized row tree
|
|
22
|
+
* (with eagerly computed aggregates) when grouping produces synthetic rows.
|
|
23
|
+
*
|
|
24
|
+
* Everything passed here must be thread-portable: `accessorKey` columns or
|
|
25
|
+
* accessors defined in a shared module, and fns from registries or shared
|
|
26
|
+
* modules (no closures over app state).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // table.worker.ts
|
|
31
|
+
* import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'
|
|
32
|
+
* import { columns, sharedFeatures } from './tableConfig'
|
|
33
|
+
*
|
|
34
|
+
* initTableWorker({ features: sharedFeatures, columns })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function initTableWorker(config) {
|
|
38
|
+
let table;
|
|
39
|
+
let dataVersion = 0;
|
|
40
|
+
let coreIndexById = makeObjectMap();
|
|
41
|
+
let aggregateColumnIds = [];
|
|
42
|
+
let lastSentModels = {};
|
|
43
|
+
self.onmessage = (event) => {
|
|
44
|
+
const message = event.data;
|
|
45
|
+
if (message.type === "data") {
|
|
46
|
+
dataVersion = message.dataVersion;
|
|
47
|
+
lastSentModels = {};
|
|
48
|
+
if (!table) {
|
|
49
|
+
table = constructTable({
|
|
50
|
+
...config,
|
|
51
|
+
features: {
|
|
52
|
+
coreReactivityFeature: storeReactivityBindings(),
|
|
53
|
+
...config.features
|
|
54
|
+
},
|
|
55
|
+
data: message.data
|
|
56
|
+
});
|
|
57
|
+
aggregateColumnIds = flattenColumnDefs(config.columns).filter((def) => def.aggregationFn != null || def.aggregatedCell != null).map((def) => def.id ?? (typeof def.accessorKey === "string" ? def.accessorKey.replaceAll(".", "_") : void 0)).filter((id) => id != null);
|
|
58
|
+
} else table.setOptions((prev) => ({
|
|
59
|
+
...prev,
|
|
60
|
+
data: message.data
|
|
61
|
+
}));
|
|
62
|
+
const coreFlatRows = table.getCoreRowModel().flatRows;
|
|
63
|
+
coreIndexById = makeObjectMap();
|
|
64
|
+
for (let i = 0; i < coreFlatRows.length; i++) coreIndexById[coreFlatRows[i].id] = i;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!table) return;
|
|
68
|
+
const start = performance.now();
|
|
69
|
+
table._reactivity.batch(() => {
|
|
70
|
+
for (const [key, value] of Object.entries(message.state)) {
|
|
71
|
+
const baseAtom = table.baseAtoms[key];
|
|
72
|
+
if (baseAtom && value !== void 0) baseAtom.set(value);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const stages = {};
|
|
76
|
+
const transfer = [];
|
|
77
|
+
for (const stage of message.stages) {
|
|
78
|
+
if (!config.features[`${stage}RowModel`]) continue;
|
|
79
|
+
const model = table[`get${capitalize(stage)}RowModel`]();
|
|
80
|
+
if (lastSentModels[stage] === model) {
|
|
81
|
+
stages[stage] = { kind: "unchanged" };
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
lastSentModels[stage] = model;
|
|
85
|
+
stages[stage] = serializeRowModel(model, coreIndexById, aggregateColumnIds, transfer);
|
|
86
|
+
}
|
|
87
|
+
const response = {
|
|
88
|
+
type: "result",
|
|
89
|
+
requestId: message.requestId,
|
|
90
|
+
dataVersion,
|
|
91
|
+
stages,
|
|
92
|
+
computeMs: performance.now() - start
|
|
93
|
+
};
|
|
94
|
+
postMessage(response, { transfer });
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { initTableWorker };
|
|
100
|
+
//# sourceMappingURL=initTableWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initTableWorker.js","names":[],"sources":["../../src/worker/initTableWorker.ts"],"sourcesContent":["import { constructTable } from '../core/table/constructTable'\nimport { storeReactivityBindings } from '../store-reactivity-bindings'\nimport { makeObjectMap } from '../utils'\nimport { serializeRowModel } from './serializeRowModel'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { TableOptions } from '../types/TableOptions'\nimport type { Table_Internal } from '../types/Table'\nimport type {\n TableWorkerRequest,\n TableWorkerResult,\n TableWorkerStage,\n TableWorkerStagePayload,\n} from './tableWorkerProtocol'\n\nexport type TableWorkerConfig<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Omit<TableOptions<TFeatures, TData>, 'data'>\n\nfunction capitalize(stage: string) {\n return stage.charAt(0).toUpperCase() + stage.slice(1)\n}\n\n/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */\nfunction flattenColumnDefs(defs: Array<any>): Array<any> {\n return defs.flatMap((def) =>\n def.columns ? flattenColumnDefs(def.columns) : [def],\n )\n}\n\n/**\n * Runs a headless \"shadow table\" inside a dedicated Web Worker.\n *\n * Call this from a user-authored worker entry file, passing the same columns\n * and processing features used on the main thread. The shadow table runs the\n * real table-core row model pipeline (real fns, real Row objects) off the\n * main thread and posts back one payload per stage the main thread requested:\n * a transferable index permutation for flat results, a serialized row tree\n * (with eagerly computed aggregates) when grouping produces synthetic rows.\n *\n * Everything passed here must be thread-portable: `accessorKey` columns or\n * accessors defined in a shared module, and fns from registries or shared\n * modules (no closures over app state).\n *\n * @example\n * ```ts\n * // table.worker.ts\n * import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'\n * import { columns, sharedFeatures } from './tableConfig'\n *\n * initTableWorker({ features: sharedFeatures, columns })\n * ```\n */\nexport function initTableWorker<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(config: TableWorkerConfig<TFeatures, TData>): void {\n let table: Table_Internal<TFeatures, TData> | undefined\n let dataVersion = 0\n let coreIndexById: Record<string, number> = makeObjectMap()\n let aggregateColumnIds: Array<string> = []\n // Last-sent model identity per stage: the memoized getters return stable\n // objects when their inputs did not change, so identity equality is exactly\n // \"this stage's result is unchanged\".\n let lastSentModels: { [K in TableWorkerStage]?: unknown } = {}\n\n self.onmessage = (event: MessageEvent<TableWorkerRequest<TData>>) => {\n const message = event.data\n\n if (message.type === 'data') {\n dataVersion = message.dataVersion\n lastSentModels = {}\n if (!table) {\n table = constructTable<TFeatures, TData>({\n ...(config as TableOptions<TFeatures, TData>),\n features: {\n coreReactivityFeature: storeReactivityBindings(),\n ...config.features,\n },\n data: message.data,\n })\n // Only columns with an explicit aggregation get eagerly aggregated\n // per group. Sync tables aggregate lazily (visible cells only), so\n // auto-aggregating every column would explode on high-cardinality\n // grouping for values nothing renders. Read the RAW column defs:\n // rowAggregationFeature injects default aggregatedCell/aggregationFn\n // into every resolved columnDef, so the resolved defs can't tell\n // explicit from default.\n aggregateColumnIds = flattenColumnDefs(config.columns as Array<any>)\n .filter(\n (def) => def.aggregationFn != null || def.aggregatedCell != null,\n )\n .map(\n (def) =>\n def.id ??\n (typeof def.accessorKey === 'string'\n ? def.accessorKey.replaceAll('.', '_')\n : undefined),\n )\n .filter((id): id is string => id != null)\n } else {\n table.setOptions((prev) => ({ ...prev, data: message.data }))\n }\n // Map row ids to data positions once per dataset; serialization uses it\n // to express every stage result in terms of core row positions.\n const coreFlatRows = table.getCoreRowModel().flatRows\n coreIndexById = makeObjectMap()\n for (let i = 0; i < coreFlatRows.length; i++) {\n coreIndexById[coreFlatRows[i]!.id] = i\n }\n return\n }\n\n if (!table) return\n\n const start = performance.now()\n\n // Apply the serializable state slices to the shadow table's base atoms.\n table._reactivity.batch(() => {\n for (const [key, value] of Object.entries(message.state)) {\n const baseAtom = (table!.baseAtoms as Record<string, any>)[key]\n if (baseAtom && value !== undefined) {\n baseAtom.set(value)\n }\n }\n })\n\n // Compute exactly the stages the main thread requested, skipping any this\n // shadow table has no row model factory for (the main thread warns).\n const stages: { [K in TableWorkerStage]?: TableWorkerStagePayload } = {}\n const transfer: Array<Transferable> = []\n\n for (const stage of message.stages) {\n if (!(config.features as Record<string, unknown>)[`${stage}RowModel`]) {\n continue\n }\n const model = (table as any)[`get${capitalize(stage)}RowModel`]()\n // Memoized getters return the same object when inputs are unchanged;\n // skip re-serializing (and the main thread skips rebuilding). Safe under\n // single-flight: results are never dropped within a dataVersion.\n if (lastSentModels[stage] === model) {\n stages[stage] = { kind: 'unchanged' }\n continue\n }\n lastSentModels[stage] = model\n stages[stage] = serializeRowModel(\n model,\n coreIndexById,\n aggregateColumnIds,\n transfer,\n )\n }\n\n const response: TableWorkerResult = {\n type: 'result',\n requestId: message.requestId,\n dataVersion,\n stages,\n computeMs: performance.now() - start,\n }\n postMessage(response, { transfer })\n }\n}\n"],"mappings":";;;;;;AAoBA,SAAS,WAAW,OAAe;CACjC,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACtD;;AAGA,SAAS,kBAAkB,MAA8B;CACvD,OAAO,KAAK,SAAS,QACnB,IAAI,UAAU,kBAAkB,IAAI,OAAO,IAAI,CAAC,GAAG,CACrD;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,gBAGd,QAAmD;CACnD,IAAI;CACJ,IAAI,cAAc;CAClB,IAAI,gBAAwC,cAAc;CAC1D,IAAI,qBAAoC,CAAC;CAIzC,IAAI,iBAAwD,CAAC;CAE7D,KAAK,aAAa,UAAmD;EACnE,MAAM,UAAU,MAAM;EAEtB,IAAI,QAAQ,SAAS,QAAQ;GAC3B,cAAc,QAAQ;GACtB,iBAAiB,CAAC;GAClB,IAAI,CAAC,OAAO;IACV,QAAQ,eAAiC;KACvC,GAAI;KACJ,UAAU;MACR,uBAAuB,wBAAwB;MAC/C,GAAG,OAAO;KACZ;KACA,MAAM,QAAQ;IAChB,CAAC;IAQD,qBAAqB,kBAAkB,OAAO,OAAqB,CAAC,CACjE,QACE,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB,IAC9D,CAAC,CACA,KACE,QACC,IAAI,OACH,OAAO,IAAI,gBAAgB,WACxB,IAAI,YAAY,WAAW,KAAK,GAAG,IACnC,OACR,CAAC,CACA,QAAQ,OAAqB,MAAM,IAAI;GAC5C,OACE,MAAM,YAAY,UAAU;IAAE,GAAG;IAAM,MAAM,QAAQ;GAAK,EAAE;GAI9D,MAAM,eAAe,MAAM,gBAAgB,CAAC,CAAC;GAC7C,gBAAgB,cAAc;GAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,cAAc,aAAa,EAAE,CAAE,MAAM;GAEvC;EACF;EAEA,IAAI,CAAC,OAAO;EAEZ,MAAM,QAAQ,YAAY,IAAI;EAG9B,MAAM,YAAY,YAAY;GAC5B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,KAAK,GAAG;IACxD,MAAM,WAAY,MAAO,UAAkC;IAC3D,IAAI,YAAY,UAAU,QACxB,SAAS,IAAI,KAAK;GAEtB;EACF,CAAC;EAID,MAAM,SAAgE,CAAC;EACvE,MAAM,WAAgC,CAAC;EAEvC,KAAK,MAAM,SAAS,QAAQ,QAAQ;GAClC,IAAI,CAAE,OAAO,SAAqC,GAAG,MAAM,YACzD;GAEF,MAAM,QAAS,MAAc,MAAM,WAAW,KAAK,EAAE,UAAU,CAAC;GAIhE,IAAI,eAAe,WAAW,OAAO;IACnC,OAAO,SAAS,EAAE,MAAM,YAAY;IACpC;GACF;GACA,eAAe,SAAS;GACxB,OAAO,SAAS,kBACd,OACA,eACA,oBACA,QACF;EACF;EAEA,MAAM,WAA8B;GAClC,MAAM;GACN,WAAW,QAAQ;GACnB;GACA;GACA,WAAW,YAAY,IAAI,IAAI;EACjC;EACA,YAAY,UAAU,EAAE,SAAS,CAAC;CACpC;AACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const require_utils = require('../utils.cjs');
|
|
2
|
+
const require_constructRow = require('../core/rows/constructRow.cjs');
|
|
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 = require_constructRow.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) => require_utils.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
|
+
exports.rebuildRowModel = rebuildRowModel;
|
|
72
|
+
//# sourceMappingURL=rebuildRowModel.cjs.map
|
|
@@ -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 { TableFeatures } from '../types/TableFeatures'\nimport type { RowData } from '../types/type-utils'\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\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 TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\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<TFeatures, TData> {\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,gBAId,OACA,SAOA,aAC4B;CAC5B,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 { TableFeatures } from '../types/TableFeatures'\nimport type { RowData } from '../types/type-utils'\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\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 TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\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<TFeatures, TData> {\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,gBAId,OACA,SAOA,aAC4B;CAC5B,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
|