tsdf 18.1.1 → 18.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async-storage.d.ts +1 -1
- package/dist/async-storage.js +1 -1
- package/dist/{asyncStorageAdapter-DgsuE-T8.d.ts → asyncStorageAdapter-BDWpJ1vC.d.ts} +1 -1
- package/dist/{asyncStorageAdapter-CxDIO_Pv.js → asyncStorageAdapter-NrI38v4g.js} +83 -2
- package/dist/{asyncStorageAdapters-Dno2qiLy.js → asyncStorageAdapters-Daewq7dv.js} +2 -2
- package/dist/indexed-db-storage.d.ts +2 -4
- package/dist/indexed-db-storage.js +1 -1
- package/dist/{indexedDbPersistentStorage-BEJA8z8c.js → indexedDbPersistentStorage-JJdUGGI8.js} +5 -3
- package/dist/main.d.ts +78 -15
- package/dist/main.js +609 -83
- package/dist/opfs-storage.d.ts +1 -1
- package/dist/opfs-storage.js +1 -1
- package/dist/{opfsPersistentStorage-BngS1m0X.d.ts → opfsPersistentStorage-CcdWYuhc.d.ts} +1 -1
- package/dist/{opfsPersistentStorage-CZThibFg.js → opfsPersistentStorage-amwSWm_p.js} +27 -4
- package/dist/{types-BlyGC_PO.d.ts → types-2UJIjziu.d.ts} +112 -14
- package/docs/list-query-store.md +1 -0
- package/docs/offline.md +111 -3
- package/docs/optimistic-list-updates.md +37 -1
- package/docs/partial-resources.md +2 -0
- package/docs/persistent-storage.md +51 -3
- package/docs/store-manager.md +27 -5
- package/package.json +9 -10
package/docs/store-manager.md
CHANGED
|
@@ -52,6 +52,7 @@ Options:
|
|
|
52
52
|
| `debugLogger` | No | Enables verbose development-only browser-tab sync, focus revalidation, and persistent-storage debug logs. Pass `true` or a logger function. |
|
|
53
53
|
| `logger` | No | Enables low-volume production-safe logs such as persistent-storage quota cleanup. Defaults to console logging; pass `false` to disable or a function to customize. |
|
|
54
54
|
| `offlineSession` | No | Shared offline config used by stores with `persistentStorage.offline`. |
|
|
55
|
+
| `removedStores` | No | Stores deleted from the app whose persisted data TSDF removes once, in every session. See [Deleting a store](./persistent-storage.md#deleting-a-store). |
|
|
55
56
|
|
|
56
57
|
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.
|
|
57
58
|
|
|
@@ -92,7 +93,7 @@ storeManager.onTransportReconnect();
|
|
|
92
93
|
|
|
93
94
|
- `getAllStoreIds()` returns registered logical store ids.
|
|
94
95
|
- `resetAll(ignoreStores)` resets all registered stores except the ignored ids.
|
|
95
|
-
- `onTransportReconnect()` signals a shared real-time transport reconnect to all registered stores.
|
|
96
|
+
- `onTransportReconnect()` signals a shared real-time transport reconnect to all registered stores. It is ignored while the offline session is in offline mode: stores revalidate by themselves when they recover (see [Revalidation After Recovering](./offline.md#revalidation-after-recovering)).
|
|
96
97
|
|
|
97
98
|
Call each store's `dispose()` when the store instance is permanently discarded so it can unregister listeners and manager state.
|
|
98
99
|
|
|
@@ -111,7 +112,7 @@ const storeManager = createStoreManager({
|
|
|
111
112
|
});
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
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.
|
|
115
|
+
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 and `resolveOfflineResolution(...)` return `Result.err(...)` where applicable.
|
|
115
116
|
|
|
116
117
|
## Offline Status APIs
|
|
117
118
|
|
|
@@ -137,23 +138,44 @@ Runtime controls:
|
|
|
137
138
|
- `setOfflineRuntimeConfig(update)` returns a `Result<void, Error>`
|
|
138
139
|
- `resetOfflineRuntimeConfig()` restores the static `offlineSession` controls
|
|
139
140
|
|
|
141
|
+
Resolution actions:
|
|
142
|
+
|
|
143
|
+
- `resolveOfflineResolution(resolutionId, 'retry' | 'discard')` applies a generic action to any resolution of the session by delegating to the registered store that owns it, so session-wide UI does not need the store instance or the operation name
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const result = await storeManager.resolveOfflineResolution(
|
|
147
|
+
resolution.id,
|
|
148
|
+
'discard',
|
|
149
|
+
);
|
|
150
|
+
if (!result.ok) console.warn(result.error.code, result.error.message);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
It resolves to a `Result<void, OfflineResolutionActionError>` instead of throwing. `error.code` tells why the action was not applied: `resolution-not-found`, `store-not-registered` (the owning store was not created with this manager), `retry-not-supported` (conflict records), `resolution-blocked`, `offline-not-configured`, or `action-failed`. See [Offline](./offline.md#resolving-from-a-session-wide-ui) for details. `requeue` and `commit` stay on the owning store's `resolveOfflineResolution(...)`.
|
|
154
|
+
|
|
140
155
|
## Upload APIs
|
|
141
156
|
|
|
142
157
|
When `offlineSession.uploads` is configured, the manager also owns session-scoped upload storage and resolution:
|
|
143
158
|
|
|
144
159
|
```ts
|
|
145
|
-
await storeManager.saveOfflineUpload({
|
|
160
|
+
await storeManager.saveOfflineUpload({
|
|
161
|
+
id: 'avatar',
|
|
162
|
+
file,
|
|
163
|
+
// Optional per-upload data for the session `upload` transport.
|
|
164
|
+
metadata: { kind: 'profile', userId },
|
|
165
|
+
});
|
|
146
166
|
const resolved = await storeManager.resolveOfflineUpload('avatar');
|
|
147
167
|
```
|
|
148
168
|
|
|
149
169
|
Upload methods:
|
|
150
170
|
|
|
151
|
-
- `saveOfflineUpload({ id, file })`
|
|
152
|
-
- `replaceOfflineUpload({ id, file })`
|
|
171
|
+
- `saveOfflineUpload({ id, file, metadata? })`
|
|
172
|
+
- `replaceOfflineUpload({ id, file, metadata? })` keeps the saved metadata unless new `metadata` is passed
|
|
153
173
|
- `loadOfflineUpload(id)`
|
|
154
174
|
- `deleteOfflineUpload(id)`
|
|
155
175
|
- `resolveOfflineUpload(id)`
|
|
156
176
|
- `resolveOfflineUploads(ids)`
|
|
157
177
|
- `useOfflineUploads()`
|
|
158
178
|
|
|
179
|
+
`metadata` is a JSON-serializable `ValidPayload` persisted with the upload. The `upload` transport receives it in its context and `getOfflineUploads()` / `useOfflineUploads()` expose it on each `OfflineUpload`. See [Offline: Upload metadata](./offline.md#upload-metadata).
|
|
180
|
+
|
|
159
181
|
Most upload methods return `Result` objects so UI can branch on `result.ok` without catching thrown errors.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdf",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.3.0",
|
|
4
4
|
"description": "A data fetching solution based on t-state",
|
|
5
5
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
6
6
|
"author": "Lucas Santos",
|
|
@@ -42,26 +42,24 @@
|
|
|
42
42
|
"node": ">=16.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@ls-stack/
|
|
46
|
-
"@ls-stack/extended-lint": "^0.89.3",
|
|
45
|
+
"@ls-stack/fast-lint": "^0.7.0",
|
|
47
46
|
"@playwright/test": "^1.58.2",
|
|
48
47
|
"@testing-library/react": "^16.3.2",
|
|
49
48
|
"@types/node": "^25.0.3",
|
|
50
49
|
"@types/react": "^18.3.27",
|
|
51
50
|
"@types/react-dom": "^18.3.7",
|
|
52
|
-
"@typescript/native-preview": "7.0.0-dev.20260302.1",
|
|
53
51
|
"@vitest/coverage-v8": "4.1.2",
|
|
54
52
|
"@vitest/ui": "^4.1.0",
|
|
55
|
-
"eslint": "^9.39.2",
|
|
56
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
57
53
|
"fake-indexeddb": "^6.2.5",
|
|
58
54
|
"happy-dom": "^20.8.4",
|
|
59
55
|
"knip": "^6.4.1",
|
|
60
56
|
"oxfmt": "^0.40.0",
|
|
57
|
+
"oxlint": "1.94.0",
|
|
61
58
|
"react": "^19.2.3",
|
|
62
59
|
"react-dom": "^19.2.3",
|
|
63
60
|
"simple-git-hooks": "^2.13.1",
|
|
64
61
|
"tsdown": "^0.21.10",
|
|
62
|
+
"tsrs": "0.25.0-ts7.1.0-beta",
|
|
65
63
|
"typescript": "^5.9.3",
|
|
66
64
|
"vite": "^8.0.0",
|
|
67
65
|
"vitest": "^4.1.0",
|
|
@@ -96,11 +94,12 @@
|
|
|
96
94
|
"test:coverage": "vitest run --coverage",
|
|
97
95
|
"test:all": "vitest --run && playwright test",
|
|
98
96
|
"lint": "pnpm lint:lib && pnpm --filter @tsdf/playground lint",
|
|
99
|
-
"lint:lib": "pnpm
|
|
100
|
-
"
|
|
97
|
+
"lint:lib": "pnpm oxlint && pnpm fast-lint && pnpm typecheck:extra",
|
|
98
|
+
"oxlint": "oxlint --type-check src/ tests/ --deny-warnings --fix",
|
|
99
|
+
"fast-lint": "fast-lint src/ tests/ --max-warnings 0 --fix",
|
|
101
100
|
"format": "oxfmt src/ tests/ apps/playground/src/",
|
|
102
|
-
"
|
|
103
|
-
"
|
|
101
|
+
"typecheck": "tsrs --fast && pnpm typecheck:extra",
|
|
102
|
+
"typecheck:extra": "tsrs --fast -p tsconfig.isolated.json && tsrs --fast -p tsconfig.playwright-fixture.json",
|
|
104
103
|
"dev": "pnpm --filter @tsdf/playground dev",
|
|
105
104
|
"playground:build": "pnpm --filter @tsdf/playground build",
|
|
106
105
|
"build": "pnpm lint && pnpm test:all && pnpm build:no-test",
|