@effectweb/tanstack-table 0.5.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EffectWeb contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @effectweb/tanstack-table
2
+
3
+ EffectWeb lifecycle and observation adapter for `@tanstack/table-core` **v9**. Configure normal TanStack features and options, then call `createTable(options, project)`.
4
+
5
+ The result exposes `table`, an EffectWeb `source`, and `dispose`. The adapter supplies store reactivity, coalesces publications, copies the projection before protecting it, and releases subscriptions on disposal. Existing snapshots remain immutable while TanStack internals remain mutable.
6
+
7
+ `project(table)` must return cloneable data only: rows, IDs, primitive cell values and selected state. Never return Table/Row/Column instances, callbacks or stores. Applications keep their APIs, permissions, column/filter descriptions, templates and styles outside this package. TanStack core exports are re-exported for feature configuration; rendering is owned by EffectWeb.
@@ -0,0 +1,13 @@
1
+ import { type Table, type TableFeatures, type TableOptions, type RowData } from '@tanstack/table-core';
2
+ import { type Source } from 'effectweb';
3
+ export * from '@tanstack/table-core';
4
+ /**
5
+ * Scope one TanStack v9 table and publish a data-only projection. Do not return row,
6
+ * column, store or table instances from project: those are mutable library resources.
7
+ */
8
+ export interface TableController<F extends TableFeatures, T extends RowData, Model> {
9
+ readonly table: Table<F, T>;
10
+ readonly source: Source<Model>;
11
+ readonly dispose: () => void;
12
+ }
13
+ export declare function createTable<F extends TableFeatures, T extends RowData, Model>(options: TableOptions<F, T>, project: (table: Table<F, T>) => Model): TableController<F, T, Model>;
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ import { constructTable, } from '@tanstack/table-core';
2
+ import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings';
3
+ import { projectionSource } from 'effectweb';
4
+ import { shareValue } from 'effectweb/share';
5
+ export * from '@tanstack/table-core';
6
+ export function createTable(options, project) {
7
+ let disposed = false;
8
+ const cleanups = [];
9
+ const reactivity = {
10
+ ...storeReactivityBindings(),
11
+ addSubscription(subscription) {
12
+ cleanups.push(() => subscription.unsubscribe());
13
+ },
14
+ schedule(run) {
15
+ queueMicrotask(() => {
16
+ if (!disposed)
17
+ run();
18
+ });
19
+ },
20
+ unmount() {
21
+ for (const stop of cleanups.splice(0).reverse())
22
+ stop();
23
+ },
24
+ };
25
+ const table = constructTable({
26
+ ...options,
27
+ features: { ...options.features, coreReactivityFeature: reactivity },
28
+ });
29
+ const source = projectionSource({
30
+ project: () => structuredClone(project(table)),
31
+ reconcile: (previous, next) => shareValue(previous, next),
32
+ });
33
+ const state = table.store.subscribe(source.changed);
34
+ const settings = table.optionsStore?.subscribe(source.changed);
35
+ source.start();
36
+ return {
37
+ table,
38
+ source,
39
+ dispose() {
40
+ if (disposed)
41
+ return;
42
+ disposed = true;
43
+ state.unsubscribe();
44
+ settings?.unsubscribe();
45
+ reactivity.unmount();
46
+ source.dispose();
47
+ },
48
+ };
49
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@effectweb/tanstack-table",
3
+ "version": "0.5.1",
4
+ "license": "MIT",
5
+ "files": [
6
+ "dist",
7
+ "README.md",
8
+ "LICENSE"
9
+ ],
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "dependencies": {
22
+ "@tanstack/table-core": "9.2.4"
23
+ },
24
+ "peerDependencies": {
25
+ "effect": "4.0.0-rc.112",
26
+ "effectweb": "^0.5.1"
27
+ }
28
+ }