tsdf 16.0.3 → 17.0.0-alpha.10

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.
Files changed (39) hide show
  1. package/LICENSE +140 -0
  2. package/README.md +5 -0
  3. package/dist/async-storage.d.ts +2 -0
  4. package/dist/async-storage.js +2 -0
  5. package/dist/asyncStorageAdapter-BMYAF6rt.d.ts +6 -0
  6. package/dist/asyncStorageAdapter-BZSj1ZO5.js +1868 -0
  7. package/dist/asyncStorageAdapters-DbyKyARM.js +3 -0
  8. package/dist/indexed-db-storage.d.ts +14 -0
  9. package/dist/indexed-db-storage.js +2 -0
  10. package/dist/indexedDbPersistentStorage-DlUjN1qY.js +902 -0
  11. package/dist/main.d.ts +1487 -373
  12. package/dist/main.js +16146 -2475
  13. package/dist/opfs-storage.d.ts +2 -0
  14. package/dist/opfs-storage.js +2 -0
  15. package/dist/opfsPersistentStorage-BO_uDxe4.js +838 -0
  16. package/dist/opfsPersistentStorage-CBnUebnf.d.ts +6 -0
  17. package/dist/types-2zQlbxtw.d.ts +1475 -0
  18. package/docs/README.md +98 -0
  19. package/docs/batch-fetching.md +125 -0
  20. package/docs/browser-tabs-sync.md +61 -0
  21. package/docs/cache-limits.md +105 -0
  22. package/docs/collection-store.md +173 -0
  23. package/docs/document-store.md +149 -0
  24. package/docs/fetch-scheduling.md +93 -0
  25. package/docs/hooks.md +416 -0
  26. package/docs/invalidation.md +135 -0
  27. package/docs/list-query-store.md +352 -0
  28. package/docs/mutations.md +266 -0
  29. package/docs/offline.md +207 -0
  30. package/docs/offset-pagination.md +111 -0
  31. package/docs/optimistic-list-updates.md +180 -0
  32. package/docs/partial-resources.md +168 -0
  33. package/docs/persistent-storage.md +290 -0
  34. package/docs/real-time-updates.md +158 -0
  35. package/docs/shared-types.md +181 -0
  36. package/docs/store-manager.md +147 -0
  37. package/package.json +81 -47
  38. package/dist/main.cjs +0 -2511
  39. package/dist/main.d.cts +0 -400
@@ -0,0 +1,158 @@
1
+ # Real-Time Updates
2
+
3
+ TSDF has built-in support for real-time data sources like WebSockets or Server-Sent Events. When enabled, stores adjust their fetch behavior to work with push-based data.
4
+
5
+ ## Enabling Real-Time Mode
6
+
7
+ ```ts
8
+ const storeManager = createStoreManager({
9
+ getSessionKey: () => currentTenantId ?? false,
10
+ errorNormalizer: normalizeError,
11
+ dynamicRealtimeThrottleMs: ({ lastFetchDuration, windowIsNotFocused }) => {
12
+ if (windowIsNotFocused) return lastFetchDuration * 10;
13
+ return lastFetchDuration * 2;
14
+ },
15
+ });
16
+
17
+ const store = createDocumentStore<Data>({
18
+ id: 'document-data',
19
+ storeManager,
20
+ usesRealTimeUpdates: true,
21
+ // ...other options
22
+ });
23
+ ```
24
+
25
+ ## Behavior Changes
26
+
27
+ When `usesRealTimeUpdates: true`:
28
+
29
+ | Behavior | Change |
30
+ | --------------------------- | -------------------------------------------------------------- |
31
+ | `disableRefetchOnMount` | Defaults to `true` globally (data comes via push, not polling) |
32
+ | `revalidateOnWindowFocus` | Disabled (real-time transport handles freshness) |
33
+ | `realtimeUpdate` fetch type | Enabled for use with the scheduler |
34
+
35
+ ## Pushing Updates
36
+
37
+ When your real-time transport receives new data, update the store directly:
38
+
39
+ ```ts
40
+ // Document Store
41
+ websocket.on('user-updated', (newData) => {
42
+ store.updateState((draft) => {
43
+ Object.assign(draft, newData);
44
+ });
45
+ });
46
+
47
+ // Collection Store
48
+ websocket.on('product-updated', ({ productId, data }) => {
49
+ store.updateItemState(productId, (draft) => {
50
+ Object.assign(draft, data);
51
+ });
52
+ });
53
+
54
+ // List Query Store
55
+ websocket.on('task-updated', ({ taskId, data }) => {
56
+ store.updateItemState(taskId, (draft) => {
57
+ Object.assign(draft, data);
58
+ });
59
+ });
60
+ ```
61
+
62
+ If the pushed data is partial, you can invalidate instead:
63
+
64
+ ```ts
65
+ websocket.on('task-changed', ({ taskId }) => {
66
+ // Collection Store
67
+ store.invalidateItem(taskId, 'realtimeUpdate');
68
+
69
+ // List Query Store
70
+ store.invalidateQueryAndItems({
71
+ itemPayload: taskId,
72
+ queryPayload: () => true,
73
+ type: 'realtimeUpdate',
74
+ });
75
+ });
76
+ ```
77
+
78
+ ## Adaptive Throttling
79
+
80
+ The `dynamicRealtimeThrottleMs` function controls how often real-time invalidations trigger actual fetches. TSDF defaults to `100ms` while focused and `1000ms` while the window is in the background. Configure it once on `createStoreManager(...)` to share a custom default across stores, or on an individual store to override the manager default. It receives the duration of the last fetch and whether the window is focused:
81
+
82
+ ```ts
83
+ dynamicRealtimeThrottleMs: ({ lastFetchDuration, windowIsNotFocused }) => {
84
+ // If fetch took 200ms, wait at least 400ms before the next one
85
+ // If window is not focused, wait 10x longer
86
+ if (windowIsNotFocused) return lastFetchDuration * 10;
87
+ return lastFetchDuration * 2;
88
+ };
89
+ ```
90
+
91
+ This prevents the UI from being overwhelmed by rapid updates while keeping data fresh.
92
+
93
+ ## Transport Reconnection
94
+
95
+ When your WebSocket or SSE connection drops and reconnects, events may have been missed. Call the manager-level `onTransportReconnect()` once for the shared transport:
96
+
97
+ ```ts
98
+ websocket.on('reconnect', () => {
99
+ storeManager.onTransportReconnect();
100
+ });
101
+ ```
102
+
103
+ Store-level `store.onTransportReconnect()` remains available for stores backed by a dedicated transport.
104
+
105
+ Behavior:
106
+
107
+ - If the window is **focused**: all data is invalidated immediately with `realtimeUpdate` priority
108
+ - If the window is **not focused**: invalidation is deferred until the window regains focus
109
+ - Multiple reconnect calls while unfocused are coalesced (only one invalidation fires on focus)
110
+ - This is a no-op when `usesRealTimeUpdates` is `false`
111
+
112
+ ## Pattern: WebSocket Integration
113
+
114
+ ```ts
115
+ const storeManager = createStoreManager({
116
+ getSessionKey: () => currentTenantId ?? false,
117
+ errorNormalizer: normalizeError,
118
+ });
119
+
120
+ const taskStore = createListQueryStore<Task, TaskFilter, string>({
121
+ id: 'tasks',
122
+ storeManager,
123
+ fetchListFn: (filter, size, { signal }) => api.getTasks(filter, size, signal),
124
+ fetchItemFn: (taskId, { signal }) => api.getTask(taskId, signal),
125
+ usesRealTimeUpdates: true,
126
+ dynamicRealtimeThrottleMs: ({ lastFetchDuration, windowIsNotFocused }) => {
127
+ if (windowIsNotFocused) return 30_000;
128
+ return Math.max(lastFetchDuration * 2, 1000);
129
+ },
130
+ // ...other options
131
+ });
132
+
133
+ // Connect WebSocket
134
+ const ws = connectWebSocket('/tasks');
135
+
136
+ ws.on('task:created', ({ task, taskId }) => {
137
+ taskStore.addItemToState(taskId, task, {
138
+ addItemToQueries: {
139
+ queries: (query) => query.projectId === task.projectId,
140
+ appendTo: 'start',
141
+ },
142
+ });
143
+ });
144
+
145
+ ws.on('task:updated', ({ taskId, changes }) => {
146
+ taskStore.updateItemState(taskId, (draft) => {
147
+ Object.assign(draft, changes);
148
+ });
149
+ });
150
+
151
+ ws.on('task:deleted', ({ taskId }) => {
152
+ taskStore.deleteItemState(taskId);
153
+ });
154
+
155
+ ws.on('reconnect', () => {
156
+ storeManager.onTransportReconnect();
157
+ });
158
+ ```
@@ -0,0 +1,181 @@
1
+ # Shared Types & Utilities
2
+
3
+ Common types and utilities used across all TSDF store types.
4
+
5
+ ## StoreError
6
+
7
+ The normalized error type used across all stores. Your `errorNormalizer` function converts raw exceptions into this shape:
8
+
9
+ ```ts
10
+ type StoreError = {
11
+ code: number;
12
+ id: string;
13
+ message: string;
14
+ path?: string;
15
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
16
+ };
17
+ ```
18
+
19
+ ## StoreFetchError
20
+
21
+ An `Error` subclass returned by `awaitFetch` methods. Contains the same fields as `StoreError` plus a `type` indicating why the fetch failed:
22
+
23
+ - `'fetch'` — the fetch function threw an error
24
+ - `'timeout'` — the fetch exceeded the specified `timeoutMs`
25
+ - `'aborted'` — the fetch was aborted (e.g., due to a mutation starting)
26
+
27
+ ## StoreMutationError
28
+
29
+ An `Error` subclass returned by `performMutation` when the mutation fails.
30
+ It contains the normalized `StoreError` fields plus:
31
+
32
+ - `kind: 'error'`
33
+ - `cause` — the original thrown value, preserved via `Error.cause`
34
+
35
+ ## StoreMutationErrorOptions
36
+
37
+ Options passed to store-level and manager-level `onMutationError` handlers:
38
+
39
+ ```ts
40
+ type StoreMutationErrorOptions = { silentErrors?: boolean };
41
+ ```
42
+
43
+ When `silentErrors` is true, the handler is still called. Use the flag to keep
44
+ centralized logging or recovery behavior while suppressing user-facing
45
+ notifications such as error toasts.
46
+
47
+ ## MutationSkipped
48
+
49
+ A sentinel returned by `performMutation` when the mutation is intentionally not
50
+ run, for example because:
51
+
52
+ - `optimisticUpdate` returned `false`
53
+ - a debounced mutation call was superseded by a newer call
54
+
55
+ Shape:
56
+
57
+ ```ts
58
+ type MutationSkipped = { kind: 'skipped' };
59
+ ```
60
+
61
+ ## Fetch Priorities
62
+
63
+ Priority levels for [fetch scheduling](./fetch-scheduling.md). Higher priority fetches override lower ones:
64
+
65
+ - `lowPriority` (0) — Default hook mount fetches
66
+ - `mediumPriority` (1) — Background refetches
67
+ - `realtimeUpdate` (2) — Push-based updates
68
+ - `highPriority` (3) — Explicit invalidation, user actions
69
+
70
+ ## ValidPayload
71
+
72
+ Payloads that identify items or queries must be one of:
73
+
74
+ - `number` — e.g., `42`
75
+ - `string` — e.g., `'user-123'`
76
+ - `Record<string, unknown>` — e.g., `{ projectId: 'proj-1', status: 'active' }`
77
+
78
+ Payloads are converted to composite keys internally for state storage. Object payloads are serialized deterministically (key order doesn't matter).
79
+
80
+ ## PayloadDebounce
81
+
82
+ Configuration for debouncing automatic fetches triggered by rapid payload
83
+ changes in payload-based hooks.
84
+
85
+ Supported by:
86
+
87
+ - `useItem`
88
+ - `useListQuery`
89
+ - `useMultipleItems`
90
+ - `useMultipleListQueries`
91
+
92
+ Shape:
93
+
94
+ ```ts
95
+ type PayloadDebounce = { ms: number; maxWait?: number; leading?: boolean };
96
+ ```
97
+
98
+ Fields:
99
+
100
+ - `ms` — debounce window in milliseconds
101
+ - `maxWait` — optional upper bound for how long a burst may stay deferred
102
+ - `leading` — allows the first payload in a burst to fetch immediately
103
+
104
+ Important behavior:
105
+
106
+ - The hook still reads from state using the latest payload immediately
107
+ - Only the automatic fetch side is delayed
108
+ - If cached data already exists for the latest payload, the hook can still
109
+ return it immediately while the fetch is deferred
110
+ - `useItem` and `useListQuery` do not support combining `debouncePayload` with
111
+ `ensureIsLoaded`
112
+
113
+ Example:
114
+
115
+ ```tsx
116
+ const result = store.useListQuery(
117
+ { search, status: 'active' },
118
+ { debouncePayload: { ms: 300, leading: true, maxWait: 1200 } },
119
+ );
120
+ ```
121
+
122
+ See [React Hooks](./hooks.md#debouncepayload) for usage patterns.
123
+
124
+ ## IsOffScreenContext
125
+
126
+ A React context that disables all TSDF hooks in a subtree when set to `true`. Useful for tabs, modals, or off-screen content that shouldn't trigger fetches.
127
+
128
+ ```tsx
129
+ import { IsOffScreenContext } from 'tsdf';
130
+
131
+ function TabPanel({ isActive, children }) {
132
+ return (
133
+ <IsOffScreenContext.Provider value={!isActive}>
134
+ {children}
135
+ </IsOffScreenContext.Provider>
136
+ );
137
+ }
138
+ ```
139
+
140
+ When `IsOffScreenContext` is `true`:
141
+
142
+ - Hooks don't trigger fetches
143
+ - Hooks don't respond to invalidation events
144
+ - Individual hooks can override via their `isOffScreen` prop
145
+
146
+ ## fetchTypePriority
147
+
148
+ Numeric mapping of fetch priorities for comparison:
149
+
150
+ ```ts
151
+ import { fetchTypePriority } from 'tsdf';
152
+
153
+ fetchTypePriority.lowPriority; // 0
154
+ fetchTypePriority.mediumPriority; // 1
155
+ fetchTypePriority.realtimeUpdate; // 2
156
+ fetchTypePriority.highPriority; // 3
157
+ ```
158
+
159
+ ## BlockWindowCloseHandler
160
+
161
+ A function that blocks the browser window from closing during mutations. Returns an object with an `unblock` method:
162
+
163
+ ```ts
164
+ const blockWindowClose = () => {
165
+ const handler = (e: BeforeUnloadEvent) => {
166
+ e.preventDefault();
167
+ };
168
+ window.addEventListener('beforeunload', handler);
169
+ return { unblock: () => window.removeEventListener('beforeunload', handler) };
170
+ };
171
+ ```
172
+
173
+ Pass `null` to `createStoreManager({ blockWindowClose })` to disable this behavior.
174
+
175
+ ## MutationDebounce
176
+
177
+ Configuration for debouncing [mutations](./mutations.md):
178
+
179
+ - `context` — Debounce key. Mutations with the same context are debounced together
180
+ - `payload` — The latest payload replaces previous ones during the debounce window
181
+ - `ms` — Milliseconds of inactivity before the mutation executes
@@ -0,0 +1,147 @@
1
+ # Store Manager
2
+
3
+ `createStoreManager(...)` creates the shared session boundary for TSDF stores. Every store requires one manager so data can be scoped by tenant/account, errors can be normalized consistently, and global store/offline APIs can coordinate across store instances.
4
+
5
+ See also: [Persistent Storage](./persistent-storage.md) | [Offline](./offline.md) | [Browser Tabs Sync](./browser-tabs-sync.md)
6
+
7
+ ## Creating A Manager
8
+
9
+ ```ts
10
+ import { createStoreManager } from 'tsdf';
11
+
12
+ const storeManager = createStoreManager({
13
+ getSessionKey: () => currentTenantId ?? false,
14
+ errorNormalizer: (error) => ({
15
+ code: 500,
16
+ id: 'unknown-error',
17
+ message: error.message,
18
+ }),
19
+ lowPriorityThrottleMs: 5,
20
+ baseCoalescingWindowMs: 10,
21
+ dynamicRealtimeThrottleMs: ({ lastFetchDuration, windowIsNotFocused }) =>
22
+ windowIsNotFocused ? lastFetchDuration * 10 : lastFetchDuration * 2,
23
+ blockWindowClose: null,
24
+ revalidateOnWindowFocus: true,
25
+ onMutationError: (error) => {
26
+ console.error('TSDF mutation failed', error);
27
+ },
28
+ onPersistentStorageError: (error) => {
29
+ console.error('TSDF persistence failed', error);
30
+ },
31
+ debug: true,
32
+ });
33
+ ```
34
+
35
+ Options:
36
+
37
+ | Option | Required | Description |
38
+ | --------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
39
+ | `getSessionKey` | Yes | Returns the active tenant/account key. Return `false` while no session is ready. |
40
+ | `errorNormalizer` | Yes | Converts thrown `Error` values into TSDF's shared `StoreError` shape. |
41
+ | `lowPriorityThrottleMs` | No | Default minimum interval between low-priority fetches for attached stores. Defaults to `5`. |
42
+ | `baseCoalescingWindowMs` | No | Default window to group fetch requests for attached stores. Defaults to `10`. |
43
+ | `dynamicRealtimeThrottleMs` | No | Default adaptive throttle for real-time updates in attached stores. Defaults to `100ms` focused and `1000ms` in the background. Store options override it. |
44
+ | `blockWindowClose` | No | Shared window-close blocker for mutations in attached stores. Defaults to `null`. |
45
+ | `revalidateOnWindowFocus` | No | Default focus revalidation policy for attached stores. Store options override it. |
46
+ | `onMutationError` | No | Global fallback for mutation failures when a store does not provide its own handler. |
47
+ | `onPersistentStorageError` | No | Global fallback for persistent storage failures when a store does not provide its own handler. |
48
+ | `debug` | No | Enables browser-tab sync and persistent-storage debug logs. Pass `true` or a logger function. |
49
+ | `offlineSession` | No | Shared offline config used by stores with `persistentStorage.offline`. |
50
+
51
+ The session key is used by browser-tab sync, persistent storage, and offline state. Stores with the same `id` but different session keys are isolated.
52
+
53
+ Stores inherit the manager's `lowPriorityThrottleMs`, `baseCoalescingWindowMs`, and `dynamicRealtimeThrottleMs` unless they provide their own store-level overrides. The built-in `dynamicRealtimeThrottleMs` default returns `100ms` while focused and `1000ms` while the window is in the background. `blockWindowClose` is manager-only so window-close mutation protection is consistent across attached stores.
54
+
55
+ Store-level options can explicitly disable inherited defaults when the option supports disabling: use `revalidateOnWindowFocus: false`, `onMutationError: null`, or `persistentStorage.onPersistentStorageError: null`.
56
+
57
+ ## Debug Logging
58
+
59
+ Pass `debug: true` to log browser-tab sync operations and persistent-storage operations through `console.log`, `console.warn`, and `console.error`. Async persistent storage logs include `durationMs` so slow OPFS, IndexedDB, or custom driver paths can be inspected.
60
+
61
+ ```ts
62
+ const storeManager = createStoreManager({
63
+ getSessionKey: () => currentTenantId ?? false,
64
+ errorNormalizer: normalizeError,
65
+ debug: ({ level, message, details }) => {
66
+ observability[level](message, details);
67
+ },
68
+ });
69
+ ```
70
+
71
+ ## Store Registry
72
+
73
+ The manager tracks attached stores:
74
+
75
+ ```ts
76
+ storeManager.getAllStoreIds();
77
+ storeManager.resetAll(['document-current-user']);
78
+ storeManager.onTransportReconnect();
79
+ ```
80
+
81
+ - `getAllStoreIds()` returns registered logical store ids.
82
+ - `resetAll(ignoreStores)` resets all registered stores except the ignored ids.
83
+ - `onTransportReconnect()` signals a shared real-time transport reconnect to all registered stores.
84
+
85
+ Call each store's `dispose()` when the store instance is permanently discarded so it can unregister listeners and manager state.
86
+
87
+ ## Offline Session
88
+
89
+ Pass `offlineSession` when stores need offline queueing or session-level offline reads:
90
+
91
+ ```ts
92
+ const storeManager = createStoreManager({
93
+ getSessionKey: () => currentTenantId ?? false,
94
+ errorNormalizer: normalizeError,
95
+ offlineSession: {
96
+ network: { enabled: true },
97
+ mutationQueueing: { network: 'allow', outage: 'allow' },
98
+ },
99
+ });
100
+ ```
101
+
102
+ Manager offline methods are safe to call even when no offline session is configured. In that case they return empty/default state, and upload helpers return `Result.err(...)` where applicable.
103
+
104
+ ## Offline Status APIs
105
+
106
+ Read session-wide offline state:
107
+
108
+ ```tsx
109
+ const status = storeManager.useOfflineStatus();
110
+ const entities = storeManager.useOfflineEntities();
111
+ const resolutions = storeManager.useOfflineResolutions();
112
+ ```
113
+
114
+ Synchronous equivalents:
115
+
116
+ - `getOfflineConfig()`
117
+ - `getOfflineRuntimeConfig()`
118
+ - `getOfflineStatus()`
119
+ - `getOfflineEntities()`
120
+ - `getOfflineResolutions()`
121
+ - `getOfflineUploads()`
122
+
123
+ Runtime controls:
124
+
125
+ - `setOfflineRuntimeConfig(update)` returns a `Result<void, Error>`
126
+ - `resetOfflineRuntimeConfig()` restores the static `offlineSession` controls
127
+
128
+ ## Upload APIs
129
+
130
+ When `offlineSession.uploads` is configured, the manager also owns session-scoped upload storage and resolution:
131
+
132
+ ```ts
133
+ await storeManager.saveOfflineUpload({ id: 'avatar', file });
134
+ const resolved = await storeManager.resolveOfflineUpload('avatar');
135
+ ```
136
+
137
+ Upload methods:
138
+
139
+ - `saveOfflineUpload({ id, file })`
140
+ - `replaceOfflineUpload({ id, file })`
141
+ - `loadOfflineUpload(id)`
142
+ - `deleteOfflineUpload(id)`
143
+ - `resolveOfflineUpload(id)`
144
+ - `resolveOfflineUploads(ids)`
145
+ - `useOfflineUploads()`
146
+
147
+ Most upload methods return `Result` objects so UI can branch on `result.ok` without catching thrown errors.
package/package.json CHANGED
@@ -1,75 +1,109 @@
1
1
  {
2
2
  "name": "tsdf",
3
- "version": "16.0.3",
3
+ "version": "17.0.0-alpha.10",
4
4
  "description": "A data fetching solution based on t-state",
5
- "license": "MIT",
5
+ "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "author": "Lucas Santos",
7
7
  "repository": "github:lucasols/tsdf",
8
8
  "type": "module",
9
- "main": "./dist/main.cjs",
10
- "module": "./dist/main.js",
9
+ "main": "./dist/main.js",
11
10
  "types": "./dist/main.d.ts",
12
11
  "exports": {
13
12
  ".": {
13
+ "types": "./dist/main.d.ts",
14
14
  "import": "./dist/main.js",
15
- "require": "./dist/main.cjs"
15
+ "default": "./dist/main.js"
16
+ },
17
+ "./async-storage": {
18
+ "types": "./dist/async-storage.d.ts",
19
+ "import": "./dist/async-storage.js",
20
+ "default": "./dist/async-storage.js"
21
+ },
22
+ "./indexed-db-storage": {
23
+ "types": "./dist/indexed-db-storage.d.ts",
24
+ "import": "./dist/indexed-db-storage.js",
25
+ "default": "./dist/indexed-db-storage.js"
26
+ },
27
+ "./opfs-storage": {
28
+ "types": "./dist/opfs-storage.d.ts",
29
+ "import": "./dist/opfs-storage.js",
30
+ "default": "./dist/opfs-storage.js"
16
31
  }
17
32
  },
18
33
  "files": [
19
- "dist"
34
+ "dist",
35
+ "docs"
20
36
  ],
21
37
  "sideEffects": false,
22
38
  "engines": {
23
39
  "node": ">=16.0.0"
24
40
  },
25
41
  "devDependencies": {
26
- "@lucasols/eslint-plugin-extended-lint": "^1.4.0",
27
- "@testing-library/jest-dom": "^6.1.3",
28
- "@testing-library/react": "^14.0.0",
29
- "@types/node": "^20.8.4",
30
- "@types/react": "^18.2.28",
31
- "@types/react-dom": "^18.2.13",
32
- "@typescript-eslint/eslint-plugin": "^6.7.5",
33
- "@typescript-eslint/parser": "^6.7.5",
34
- "@vitest/ui": "1.0.4",
35
- "eslint": "^8.51.0",
36
- "eslint-plugin-local-rules": "^2.0.0",
37
- "eslint-plugin-react-hooks": "^4.6.0",
38
- "eslint-plugin-vitest": "^0.3.15",
39
- "happy-dom": "^12.9.1",
40
- "jsdom": "^22.1.0",
41
- "prettier": "^3.0.3",
42
- "pretty-format": "^29.7.0",
43
- "react": "^18.2.0",
44
- "react-dom": "^18.2.0",
45
- "tiny-glob": "^0.2.9",
46
- "tsm": "^2.3.0",
47
- "tsup": "^7.2.0",
48
- "typescript": "^5.4.2",
49
- "vite": "^5.1.5",
50
- "vitest": "^1.3.1"
42
+ "@ls-stack/eslint-cfg": "^0.10.0",
43
+ "@ls-stack/extended-lint": "^0.89.3",
44
+ "@playwright/test": "^1.58.2",
45
+ "@testing-library/react": "^16.3.2",
46
+ "@types/node": "^25.0.3",
47
+ "@types/react": "^18.3.27",
48
+ "@types/react-dom": "^18.3.7",
49
+ "@typescript/native-preview": "7.0.0-dev.20260302.1",
50
+ "@vitest/coverage-v8": "4.1.2",
51
+ "@vitest/ui": "^4.1.0",
52
+ "eslint": "^9.39.2",
53
+ "eslint-plugin-react-hooks": "^7.0.1",
54
+ "fake-indexeddb": "^6.2.5",
55
+ "happy-dom": "^20.8.4",
56
+ "knip": "^6.4.1",
57
+ "oxfmt": "^0.40.0",
58
+ "react": "^19.2.3",
59
+ "react-dom": "^19.2.3",
60
+ "simple-git-hooks": "^2.13.1",
61
+ "tsdown": "^0.21.10",
62
+ "typescript": "^5.9.3",
63
+ "vite": "^8.0.0",
64
+ "vitest": "^4.1.0",
65
+ "zod": "^4.3.6"
51
66
  },
52
67
  "dependencies": {
53
- "evtmitter": "^0.3.3",
54
- "immer": "^10.0.3",
68
+ "@evtmitter/react": "^0.1.0",
69
+ "@ls-stack/browser-utils": "^0.3.0",
70
+ "@ls-stack/react-utils": "^0.12.1",
71
+ "@ls-stack/utils": "^3.76.0",
72
+ "@standard-schema/spec": "^1.1.0",
73
+ "evtmitter": "^1.0.2",
55
74
  "klona": "^2.0.6",
56
- "t-state": "^9.0.0"
75
+ "runcheck": "^1.15.0",
76
+ "t-result": "^0.6.1",
77
+ "t-state": "^9.8.2"
78
+ },
79
+ "simple-git-hooks": {
80
+ "pre-commit": "node --no-warnings scripts/preCommitHook.ts"
57
81
  },
58
82
  "peerDependencies": {
59
- "react": "^18.0.0",
60
- "react-dom": "^18.0.0"
83
+ "react": "^18.0.0||^19.0.0",
84
+ "react-dom": "^18.0.0||^19.0.0"
61
85
  },
62
86
  "scripts": {
63
- "test": "vitest --ui --mode development",
64
- "test:changed": "vitest --changed --ui --mode development",
65
- "lint": "pnpm tsc && pnpm eslint && pnpm format",
66
- "eslint": "CI=true eslint --color --ext .jsx,.js,.ts,.tsx src/ test/",
67
- "format": "prettier --write src/**/*.ts",
68
- "tsc": "tsc -p tsconfig.prod.json",
69
- "tsc:watch": "tsc -p tsconfig.prod.json --watch",
70
- "test:run": "vitest run",
71
- "build": "pnpm test:run && pnpm lint && pnpm build:no-test",
72
- "build:no-test": "tsup --dts",
73
- "pre-publish": "./scripts/check-if-is-sync.sh && pnpm build"
87
+ "knip": "knip",
88
+ "test": "vitest --run",
89
+ "test:ui": "vitest --ui",
90
+ "test:watch": "vitest --watch",
91
+ "test:changed": "vitest --changed",
92
+ "test:playwright": "playwright test",
93
+ "test:coverage": "vitest run --coverage",
94
+ "test:all": "vitest --run && playwright test",
95
+ "lint": "pnpm lint:lib && pnpm --filter @tsdf/playground lint",
96
+ "lint:lib": "pnpm tsc && pnpm tsc:isolated && pnpm eslint",
97
+ "eslint": "eslint src/ tests/ --fix",
98
+ "format": "oxfmt src/ tests/ apps/playground/src/",
99
+ "tsc": "tsgo -p tsconfig.prod.json && tsgo -p tsconfig.playwright-fixture.json",
100
+ "tsc:isolated": "tsgo -p tsconfig.isolated.json",
101
+ "playground": "pnpm --filter @tsdf/playground dev",
102
+ "playground:build": "pnpm --filter @tsdf/playground build",
103
+ "build": "pnpm lint && pnpm test:all && pnpm build:no-test",
104
+ "build:no-test": "tsdown",
105
+ "pre-publish": "pnpm build",
106
+ "hooks:install": "simple-git-hooks",
107
+ "hooks:uninstall": "git config --unset core.hooksPath || true && rm -rf .git/hooks/pre-commit"
74
108
  }
75
109
  }